diff --git a/src/components/abciapp/Cargo.toml b/src/components/abciapp/Cargo.toml index f2a4e393c..0ec73a366 100644 --- a/src/components/abciapp/Cargo.toml +++ b/src/components/abciapp/Cargo.toml @@ -44,8 +44,8 @@ ruc = { version = "1.0.5", default-features = false, features = ["compact"] } module-evm = { path = "../contracts/modules/evm"} ethereum-types = { version = "0.13.1", default-features = false } -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } abci = { git = "https://github.com/FindoraNetwork/tendermint-abci", tag = "0.7.5" } config = { path = "../config"} diff --git a/src/components/abciapp/src/abci/server/mod.rs b/src/components/abciapp/src/abci/server/mod.rs index 8983e406e..dc252eebd 100644 --- a/src/components/abciapp/src/abci/server/mod.rs +++ b/src/components/abciapp/src/abci/server/mod.rs @@ -56,13 +56,17 @@ impl ABCISubmissionServer { None => { pnk!(AccountBaseAPP::new( tempfile::tempdir().unwrap().path(), - CFG.disable_eth_empty_blocks + CFG.disable_eth_empty_blocks, + CFG.arc_history, + CFG.arc_fresh )) } Some(basedir) => { pnk!(AccountBaseAPP::new( Path::new(basedir), - CFG.disable_eth_empty_blocks + CFG.disable_eth_empty_blocks, + CFG.arc_history, + CFG.arc_fresh )) } }; diff --git a/src/components/abciapp/src/bins/abcid.rs b/src/components/abciapp/src/bins/abcid.rs index 949b61c50..0f78f14b4 100644 --- a/src/components/abciapp/src/bins/abcid.rs +++ b/src/components/abciapp/src/bins/abcid.rs @@ -13,8 +13,7 @@ use { fn main() { globutils::logging::init_logging(None); - - tracing::info!(concat!( + tracing::info!(target: "abciapp", concat!( "Build: ", env!("VERGEN_SHA"), " ", diff --git a/src/components/abciapp/src/bins/findorad.rs b/src/components/abciapp/src/bins/findorad.rs index cf450af88..6c66de5c3 100644 --- a/src/components/abciapp/src/bins/findorad.rs +++ b/src/components/abciapp/src/bins/findorad.rs @@ -49,6 +49,13 @@ fn node_command() -> Result<()> { .checkpoint_file .clone() .unwrap_or_else(|| String::from("./checkpoint.toml")); + let arc_history_arg = { + if let Some(interval) = CFG.arc_history.1 { + format!("{},{}", CFG.arc_history.0, interval) + } else { + format!("{}", CFG.arc_history.0) + } + }; abcid .arg("--submission-service-port") @@ -58,7 +65,9 @@ fn node_command() -> Result<()> { .arg("--checkpoint-file") .arg(&checkpoint_file) .arg("--ledger-dir") - .arg(&CFG.ledger_dir); + .arg(&CFG.ledger_dir) + .arg("--arc-history") + .arg(&arc_history_arg); for (condition, action) in [ (CFG.enable_query_service, "--enable-query-service"), @@ -67,6 +76,7 @@ fn node_command() -> Result<()> { (CFG.enable_snapshot, "--enable-snapshot"), (CFG.snapshot_list, "--snapshot-list"), (CFG.snapshot_rollback, "--snapshot-rollback"), + (CFG.arc_fresh, "--arc-fresh"), ] { if condition { abcid.arg(action); diff --git a/src/components/config/src/abci/mod.rs b/src/components/config/src/abci/mod.rs index 0b0b4301f..6c039a132 100644 --- a/src/components/config/src/abci/mod.rs +++ b/src/components/config/src/abci/mod.rs @@ -318,6 +318,8 @@ pub mod global_cfg { pub struct Config { pub abci_host: String, pub abci_port: u16, + pub arc_history: (u16, Option), + pub arc_fresh: bool, pub tendermint_host: String, pub tendermint_port: u16, pub submission_service_port: u16, @@ -351,6 +353,8 @@ pub mod global_cfg { .about("An ABCI node implementation of FindoraNetwork.") .arg_from_usage("--abcid-host=[ABCId IP]") .arg_from_usage("--abcid-port=[ABCId Port]") + .arg_from_usage("--arc-history=[EVM archive node tracing history, format \"PERIOD,INTERVAL\" in days]") + .arg_from_usage("--arc-fresh 'EVM archive node with fresh tracing history'") .arg_from_usage("--tendermint-host=[Tendermint IP]") .arg_from_usage("--tendermint-port=[Tendermint Port]") .arg_from_usage("--submission-service-port=[Submission Service Port]") @@ -394,6 +398,39 @@ pub mod global_cfg { .unwrap_or_else(|| "26658".to_owned()) .parse::() .c(d!("Invalid `abcid-port`."))?; + let arh = { + let trace = m + .value_of("arc-history") + .map(|v| v.to_owned()) + .or_else(|| env::var("ARC-HISTORY").ok()) + .unwrap_or_else(|| "90,10".to_string()) + .trim() + .to_owned(); + if trace.is_empty() { + return Err(eg!("empty trace")); + } + if trace.contains(',') { + let t = trace.split(',').collect::>(); + let trace = t + .first() + .expect("missing trace period") + .parse::() + .c(d!("invalid trace period"))?; + let interval = Some( + t.get(1) + .expect("missing trace interval") + .parse::() + .c(d!("invalid trace interval"))?, + ); + (trace, interval) + } else if !trace.is_empty() { + let trace = trace.parse::().c(d!("invalid trace period"))?; + (trace, None) + } else { + return Err(eg!("invalid trace")); + } + }; + let arf = m.is_present("arc-fresh"); let th = m .value_of("tendermint-host") .map(|v| v.to_owned()) @@ -465,6 +502,8 @@ pub mod global_cfg { let res = Config { abci_host: ah, abci_port: ap, + arc_history: arh, + arc_fresh: arf, tendermint_host: th, tendermint_port: tp, submission_service_port: ssp, diff --git a/src/components/config/src/findora/mod.rs b/src/components/config/src/findora/mod.rs index 36fa156c2..e4081b65b 100644 --- a/src/components/config/src/findora/mod.rs +++ b/src/components/config/src/findora/mod.rs @@ -151,6 +151,8 @@ pub mod config { pub struct Config { pub tendermint_host: String, pub tendermint_port: u16, + pub arc_history: (u16, Option), + pub arc_fresh: bool, pub submission_service_port: u16, pub ledger_service_port: u16, pub enable_query_service: bool, @@ -182,6 +184,8 @@ pub mod config { let node = SubCommand::with_name("node") .about("Start findora node.") .arg_from_usage("-c, --config=[FILE] 'Path to $TMHOM/config/config.toml'") + .arg_from_usage("--arc-history=[EVM archive node tracing history, format \"PERIOD,INTERVAL\" in days]") + .arg_from_usage("--arc-fresh 'EVM archive node with fresh tracing history'") .arg_from_usage("-H, --tendermint-host=[Tendermint Node IP]") .arg_from_usage("-P, --tendermint-port=[Tendermint Node Port]") .arg_from_usage("--submission-service-port=[Submission Service Port]") @@ -276,6 +280,39 @@ pub mod config { .unwrap_or_else(|| "26657".to_owned()) .parse::() .c(d!())?; + let arh = { + let trace = m + .value_of("arc-history") + .map(|v| v.to_owned()) + .or_else(|| env::var("ARC-HISTORY").ok()) + .unwrap_or_else(|| "90,10".to_string()) + .trim() + .to_owned(); + if trace.is_empty() { + return Err(eg!("empty trace")); + } + if trace.contains(',') { + let t = trace.split(',').collect::>(); + let trace = t + .first() + .expect("missing trace period") + .parse::() + .c(d!("invalid trace period"))?; + let interval = Some( + t.get(1) + .expect("missing trace interval") + .parse::() + .c(d!("invalid trace interval"))?, + ); + (trace, interval) + } else if !trace.is_empty() { + let trace = trace.parse::().c(d!("invalid trace period"))?; + (trace, None) + } else { + return Err(eg!("invalid trace")); + } + }; + let arf = m.is_present("arc-fresh"); let ssp = m .value_of("submission-service-port") .map(|v| v.to_owned()) @@ -336,6 +373,8 @@ pub mod config { let res = Config { tendermint_host: th, tendermint_port: tp, + arc_history: arh, + arc_fresh: arf, submission_service_port: ssp, ledger_service_port: lsp, enable_query_service: eqs, diff --git a/src/components/contracts/baseapp/Cargo.toml b/src/components/contracts/baseapp/Cargo.toml index 74bc31e81..493dcd3db 100644 --- a/src/components/contracts/baseapp/Cargo.toml +++ b/src/components/contracts/baseapp/Cargo.toml @@ -25,8 +25,8 @@ serde_json = "1.0.40" attohttpc = { version = "0.18", default-features = false, features = ["compress", "json", "tls-rustls"] } base64 = "0.13" once_cell = "1.10.0" -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } -fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } +fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } sha3 = "0.8" config = { path = "../../config"} diff --git a/src/components/contracts/baseapp/src/lib.rs b/src/components/contracts/baseapp/src/lib.rs index 3a899fe32..2b808a323 100644 --- a/src/components/contracts/baseapp/src/lib.rs +++ b/src/components/contracts/baseapp/src/lib.rs @@ -37,22 +37,21 @@ use parking_lot::RwLock; use primitive_types::{H160, H256, U256}; use ruc::{eg, Result}; use std::{borrow::BorrowMut, path::Path, sync::Arc}; -use storage::state::ChainState; +use storage::state::{ChainState, ChainStateOpts}; +use tracing::info; lazy_static! { /// An identifier that distinguishes different EVM chains. static ref EVM_CAHIN_ID: u64 = std::env::var("EVM_CHAIN_ID").map( |id| id.as_str().parse::().unwrap()).unwrap_or(2152); - static ref CHAIN_STATE_MIN_VERSIONS: u64 = BLOCKS_IN_DAY * std::env::var("CHAIN_STATE_VERSIONS").map( - |ver|ver.as_str().parse::().expect("chainstate versions should be a valid integer") - ).unwrap_or(90); } const APP_NAME: &str = "findora"; const CHAIN_STATE_PATH: &str = "state.db"; const CHAIN_HISTORY_DATA_PATH: &str = "history.db"; const BLOCKS_IN_DAY: u64 = 4 * 60 * 24; +const SNAPSHOT_INTERVAL: u64 = 10 * 24; #[derive(Clone)] pub struct BaseApp { @@ -161,22 +160,33 @@ impl module_xhub::Config for BaseApp { } impl BaseApp { - pub fn new(basedir: &Path, empty_block: bool) -> Result { - tracing::info!( - "create new baseapp with basedir {:?}, empty_block {}, history {} blocks", - basedir, - empty_block, - *CHAIN_STATE_MIN_VERSIONS + pub fn new( + basedir: &Path, + empty_block: bool, + arc_history: (u16, Option), + is_fresh: bool, + ) -> Result { + info!( + target: "baseapp", + "create new baseapp with basedir {:?}, empty_block {}, trace history {:?} days, is_fresh {}", + basedir, empty_block, arc_history, is_fresh ); // Creates a fresh chain state db and history db let fdb_path = basedir.join(CHAIN_STATE_PATH); let fdb = FinDB::open(fdb_path.as_path())?; - let chain_state = Arc::new(RwLock::new(ChainState::new( - fdb, - "findora_db".to_owned(), - *CHAIN_STATE_MIN_VERSIONS, - ))); + + let opts = ChainStateOpts { + name: Some("findora_db".to_owned()), + ver_window: BLOCKS_IN_DAY * arc_history.0 as u64, + cleanup_aux: is_fresh, + interval: arc_history + .1 + .map_or(SNAPSHOT_INTERVAL * arc_history.0 as u64, |v| { + BLOCKS_IN_DAY * v as u64 + }), + }; + let chain_state = Arc::new(RwLock::new(ChainState::create_with_opts(fdb, opts))); let rdb_path = basedir.join(CHAIN_HISTORY_DATA_PATH); let rdb = RocksDB::open(rdb_path.as_path())?; @@ -298,6 +308,10 @@ impl BaseApp { } } + pub fn create_context_at(&self, height: u64) -> Option { + self.check_state.state_at(height) + } + /// retrieve the context for the txBytes and other memoized values. pub fn retrieve_context(&mut self, mode: RunTxMode) -> &mut Context { let ctx = if mode == RunTxMode::Deliver { diff --git a/src/components/contracts/modules/account/Cargo.toml b/src/components/contracts/modules/account/Cargo.toml index 73fe420c1..a22538a03 100644 --- a/src/components/contracts/modules/account/Cargo.toml +++ b/src/components/contracts/modules/account/Cargo.toml @@ -15,7 +15,7 @@ primitive-types = { version = "0.11.1", default-features = false, features = ["r ruc = "1.0" serde = { version = "1.0.124", features = ["derive"] } serde_json = "1.0.64" -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } # primitives, don't depend on any modules fp-core = { path = "../../primitives/core" } @@ -28,9 +28,9 @@ config = {path = "../../../config"} [dev-dependencies] parking_lot = "0.12" rand_chacha = "0.3" -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } -fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } +fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } [features] -web3_service = ["enterprise-web3"] \ No newline at end of file +web3_service = ["enterprise-web3"] diff --git a/src/components/contracts/modules/ethereum/Cargo.toml b/src/components/contracts/modules/ethereum/Cargo.toml index 8f6ccaf0c..8b3243bdb 100644 --- a/src/components/contracts/modules/ethereum/Cargo.toml +++ b/src/components/contracts/modules/ethereum/Cargo.toml @@ -37,8 +37,8 @@ enterprise-web3 = { path = "../../primitives/enterprise-web3", optional = true baseapp = { path = "../../baseapp" } fp-mocks = { path = "../../primitives/mocks" } module-account = { path = "../account" } -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } -fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } +fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } [features] default = [] diff --git a/src/components/contracts/modules/evm/Cargo.toml b/src/components/contracts/modules/evm/Cargo.toml index 6bac465ee..163e19cb4 100644 --- a/src/components/contracts/modules/evm/Cargo.toml +++ b/src/components/contracts/modules/evm/Cargo.toml @@ -24,8 +24,8 @@ serde_json = "1.0.64" sha3 = { version = "0.10", default-features = false } hex = "0.4.2" ethabi = "17.1.0" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } # primitives, don't depend on any modules fp-core = { path = "../../primitives/core" } @@ -35,8 +35,8 @@ fp-traits = { path = "../../primitives/traits" } fp-types = { path = "../../primitives/types" } fp-utils = { path = "../../primitives/utils" } config = { path = "../../../config"} -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } -fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } +fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } ledger = { path = "../../../../ledger" } enterprise-web3 = { path = "../../primitives/enterprise-web3", optional = true } @@ -49,4 +49,4 @@ module-ethereum = { path = "../ethereum" } serde_json = "1.0.64" [features] -web3_service = ["enterprise-web3"] \ No newline at end of file +web3_service = ["enterprise-web3"] diff --git a/src/components/contracts/modules/evm/precompile/Cargo.toml b/src/components/contracts/modules/evm/precompile/Cargo.toml index 3e59e2ede..1b2cc1baf 100644 --- a/src/components/contracts/modules/evm/precompile/Cargo.toml +++ b/src/components/contracts/modules/evm/precompile/Cargo.toml @@ -17,7 +17,7 @@ evm-precompile-sha3fips = {path = "./sha3fips" } evm-precompile-modexp = { path = "./modexp" } evm-precompile-frc20 = { path = "./frc20" } evm-precompile-eth-pairings = { path = "./eth-pairings" } -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v0.2.2" } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } fp-core = { path = "../../../primitives/core" } parking_lot = "0.12" -fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v0.2.2" } +fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } diff --git a/src/components/contracts/modules/evm/src/runtime/runner.rs b/src/components/contracts/modules/evm/src/runtime/runner.rs index 7525ac9b1..ffc945948 100644 --- a/src/components/contracts/modules/evm/src/runtime/runner.rs +++ b/src/components/contracts/modules/evm/src/runtime/runner.rs @@ -16,6 +16,7 @@ use fp_types::actions::evm::*; use ruc::*; use sha3::{Digest, Keccak256}; use std::marker::PhantomData; +use tracing::{debug, trace}; #[derive(Default)] pub struct ActionRunner { @@ -96,7 +97,7 @@ impl ActionRunner { let used_gas = U256::from(executor.used_gas()); let actual_fee = executor.fee(gas_price); - tracing::debug!( + debug!( target: "evm", "Execution {:?} [source: {:?}, value: {}, gas_price {}, gas_limit: {}, actual_fee: {}]", reason, @@ -115,7 +116,7 @@ impl ActionRunner { let state = executor.into_state(); for address in state.substate.deletes { - tracing::debug!( + debug!( target: "evm", "Deleting account at {:?}", address @@ -124,7 +125,7 @@ impl ActionRunner { } for log in &state.substate.logs { - tracing::trace!( + trace!( target: "evm", "Inserting log for {:?}, topics ({}) {:?}, data ({}): {:?}]", log.address, @@ -176,7 +177,7 @@ impl ActionRunner { let state = executor.into_state(); for address in state.substate.deletes { - tracing::debug!( + debug!( target: "evm", "Deleting account at {:?}", address @@ -185,7 +186,7 @@ impl ActionRunner { } for log in &state.substate.logs { - tracing::trace!( + trace!( target: "evm", "Inserting log for {:?}, topics ({}) {:?}, data ({}): {:?}]", log.address, @@ -232,7 +233,7 @@ impl ActionRunner { let state = executor.into_state(); for address in state.substate.deletes { - tracing::debug!( + debug!( target: "evm", "Deleting account at {:?}", address @@ -241,7 +242,7 @@ impl ActionRunner { } for log in &state.substate.logs { - tracing::trace!( + trace!( target: "evm", "Inserting log for {:?}, topics ({}) {:?}, data ({}): {:?}]", log.address, diff --git a/src/components/contracts/modules/evm/src/runtime/stack.rs b/src/components/contracts/modules/evm/src/runtime/stack.rs index ed8f9fd2d..b5d22ccad 100644 --- a/src/components/contracts/modules/evm/src/runtime/stack.rs +++ b/src/components/contracts/modules/evm/src/runtime/stack.rs @@ -15,7 +15,7 @@ use fp_traits::{ }; use fp_utils::timestamp_converter; use std::{collections::btree_set::BTreeSet, marker::PhantomData, mem}; -use tracing::info; +use tracing::{debug, error, info}; pub struct FindoraStackSubstate<'context, 'config> { pub ctx: &'context Context, @@ -284,7 +284,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> fn set_storage(&mut self, address: H160, index: H256, value: H256) { if value == H256::default() { - tracing::debug!( + debug!( target: "evm", "Removing storage for {:?} [index: {:?}]", address, @@ -296,7 +296,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> &index.into(), ); } else { - tracing::debug!( + debug!( target: "evm", "Updating storage for {:?} [index: {:?}, value: {:?}]", address, @@ -309,7 +309,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> &index.into(), &value, ) { - tracing::error!( + error!( target: "evm", "Failed updating storage for {:?} [index: {:?}, value: {:?}], error: {:?}", address, @@ -365,6 +365,11 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> } fn reset_storage(&mut self, address: H160) { + debug!( + target: "evm", + "Removing storage with prefix {:?}", + address, + ); AccountStorages::remove_prefix( self.ctx.state.write().borrow_mut(), &address.into(), @@ -381,7 +386,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> fn set_code(&mut self, address: H160, code: Vec) { let code_len = code.len(); - tracing::debug!( + debug!( target: "evm", "Inserting code ({} bytes) at {:?}", code_len, @@ -392,7 +397,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> let result = App::::create_account(self.ctx, address.into(), code); if let Err(e) = result { - tracing::error!( + error!( target: "evm", "Failed inserting code ({} bytes) at {:?}, error: {:?}", code_len, diff --git a/src/components/contracts/primitives/core/Cargo.toml b/src/components/contracts/primitives/core/Cargo.toml index 42d2a6f1b..292045260 100644 --- a/src/components/contracts/primitives/core/Cargo.toml +++ b/src/components/contracts/primitives/core/Cargo.toml @@ -16,8 +16,8 @@ parking_lot = "0.12" primitive-types = { version = "0.11.1", default-features = false, features = ["rlp", "byteorder", "serde"] } ruc = "1.0" serde = { version = "1.0.124", features = ["derive"] } -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0", optional = true } -fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0", optional = true } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4", optional = true } +fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4", optional = true } serde_with = { version = "2.0.1"} # primitives diff --git a/src/components/contracts/primitives/core/src/context.rs b/src/components/contracts/primitives/core/src/context.rs index 3edf19d8a..d1d34c8df 100644 --- a/src/components/contracts/primitives/core/src/context.rs +++ b/src/components/contracts/primitives/core/src/context.rs @@ -53,6 +53,22 @@ impl Context { } } + pub fn state_at(&self, height: u64) -> Option { + let state = self.state.read().state_at(height); + let db = State::new(self.db.read().chain_state(), false); + match state { + Ok(state) => Some(Context { + state: Arc::new(RwLock::new(state)), + db: Arc::new(RwLock::new(db)), + run_mode: RunTxMode::None, + header: Default::default(), + header_hash: Default::default(), + eth_cache: Default::default(), + }), + _ => None, + } + } + pub fn copy_with_state(&self) -> Self { Context { state: Arc::new(RwLock::new(self.state.read().copy())), diff --git a/src/components/contracts/primitives/mocks/Cargo.toml b/src/components/contracts/primitives/mocks/Cargo.toml index 6feb0138e..ac613434c 100644 --- a/src/components/contracts/primitives/mocks/Cargo.toml +++ b/src/components/contracts/primitives/mocks/Cargo.toml @@ -18,7 +18,7 @@ rand_chacha = "0.3" rlp = "0.5" serde_json = "1.0" sha3 = "0.10" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } # primitives fp-traits = { path = "../traits" } diff --git a/src/components/contracts/primitives/mocks/src/lib.rs b/src/components/contracts/primitives/mocks/src/lib.rs index e34b7fdd1..302bf14f2 100644 --- a/src/components/contracts/primitives/mocks/src/lib.rs +++ b/src/components/contracts/primitives/mocks/src/lib.rs @@ -23,8 +23,9 @@ use std::sync::Mutex; use std::time::SystemTime; lazy_static! { - pub static ref BASE_APP: Mutex = - Mutex::new(BaseApp::new(create_temp_db_path().as_path(), false).unwrap()); + pub static ref BASE_APP: Mutex = Mutex::new( + BaseApp::new(create_temp_db_path().as_path(), false, (0, None), false).unwrap() + ); pub static ref ALICE_ECDSA: KeyPair = generate_address(1); pub static ref BOB_ECDSA: KeyPair = generate_address(2); pub static ref ALICE_XFR: XfrKeyPair = diff --git a/src/components/contracts/primitives/storage/Cargo.toml b/src/components/contracts/primitives/storage/Cargo.toml index 7d74e505a..bdb5e4c61 100644 --- a/src/components/contracts/primitives/storage/Cargo.toml +++ b/src/components/contracts/primitives/storage/Cargo.toml @@ -15,10 +15,10 @@ ruc = "1.0" serde = { version = "1.0.124", features = ["derive"] } serde_json = "1.0" sha2 = "0.10" -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } # primitives fp-core = { path = "../core" } [dev-dependencies] -temp_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } +temp_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } diff --git a/src/components/contracts/primitives/types/Cargo.toml b/src/components/contracts/primitives/types/Cargo.toml index 21242aea8..d840c46cf 100644 --- a/src/components/contracts/primitives/types/Cargo.toml +++ b/src/components/contracts/primitives/types/Cargo.toml @@ -21,8 +21,8 @@ serde = { version = "1.0.124", features = ["derive"] } serde_json = "1.0" serde-big-array = "0.4" sha3 = "0.10" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } # primitives fp-utils = { path = "../utils" } diff --git a/src/components/contracts/rpc/src/eth.rs b/src/components/contracts/rpc/src/eth.rs index 22beb8cbd..042f59104 100644 --- a/src/components/contracts/rpc/src/eth.rs +++ b/src/components/contracts/rpc/src/eth.rs @@ -360,9 +360,9 @@ impl EthApi for EthApiImpl { fn call( &self, request: CallRequest, - _: Option, + block_number: Option, ) -> BoxFuture> { - debug!(target: "eth_rpc", "call, request:{:?}", request); + debug!(target: "eth_rpc", "call, height {:?}, request:{:?}", block_number, request); let mut request = request; let curr_height = match self.block_number() { @@ -412,18 +412,14 @@ impl EthApi for EthApiImpl { nonce, } = request; - let block = account_base_app.read().current_block(None); + let id = native_block_id(block_number); + let block = account_base_app + .read() + .current_block(id) + .ok_or_else(|| internal_err("failed to get block"))?; + // use given gas limit or query current block's limit - let gas_limit = match gas { - Some(amount) => amount, - None => { - if let Some(block) = block.clone() { - block.header.gas_limit - } else { - ::BlockGasLimit::get() - } - } - }; + let gas_limit = gas.unwrap_or(block.header.gas_limit); let data = data.map(|d| d.0).unwrap_or_default(); let mut config = ::config().clone(); @@ -431,18 +427,13 @@ impl EthApi for EthApiImpl { let mut ctx = account_base_app .read() - .create_query_context(None, false) - .map_err(|err| { - internal_err(format!("create query context error: {err:?}",)) - })?; - if let Some(block) = block { - ctx.header - .mut_time() - .set_seconds(block.header.timestamp as i64); - ctx.header.height = block.header.number.as_u64() as i64; - ctx.header.proposer_address = - Vec::from(block.header.beneficiary.as_bytes()) - } + .create_context_at(block.header.number.as_u64()) + .ok_or_else(|| internal_err("create query context error"))?; + ctx.header + .mut_time() + .set_seconds(block.header.timestamp as i64); + ctx.header.height = block.header.number.as_u64() as i64; + ctx.header.proposer_address = Vec::from(block.header.beneficiary.as_bytes()); match to { Some(to) => { @@ -993,14 +984,15 @@ impl EthApi for EthApiImpl { } let allowance = available / gas_price; if highest < allowance { - tracing::warn!( - "Gas estimation capped by limited funds original {} balance {} sent {} feecap {} fundable {}", - highest, - balance, - request.value.unwrap_or_default(), - gas_price, - allowance - ); + warn!( + target: "eth_rpc", + "Gas estimation capped by limited funds original {} balance {} sent {} feecap {} fundable {}", + highest, + balance, + request.value.unwrap_or_default(), + gas_price, + allowance + ); highest = allowance; } } diff --git a/src/components/finutils/Cargo.toml b/src/components/finutils/Cargo.toml index 1782f2f98..01e29b35b 100644 --- a/src/components/finutils/Cargo.toml +++ b/src/components/finutils/Cargo.toml @@ -25,9 +25,9 @@ tokio = "1.10.1" wasm-bindgen = { version = "=0.2.73", features = ["serde-serialize"] } getrandom = "0.2" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } ruc = "1.0" rucv3 = { package = "ruc", version = "3.0" } diff --git a/src/components/wallet_mobile/Cargo.toml b/src/components/wallet_mobile/Cargo.toml index 53086d49a..ae87fe366 100644 --- a/src/components/wallet_mobile/Cargo.toml +++ b/src/components/wallet_mobile/Cargo.toml @@ -32,8 +32,8 @@ serde = { version = "1.0.124", features = ["derive"] } serde_derive = "^1.0.59" serde_json = "1.0" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } finutils = { path = "../finutils", default-features = false, features = []} fp-types = { path = "../contracts/primitives/types" } diff --git a/src/components/wasm/Cargo.toml b/src/components/wasm/Cargo.toml index fbd9de16d..67b5f5550 100644 --- a/src/components/wasm/Cargo.toml +++ b/src/components/wasm/Cargo.toml @@ -36,9 +36,9 @@ ruc = "1.0" # OR the compiling will fail. getrandom = { version = "0.2", features = ["js"] } -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } finutils = { path = "../finutils", default-features = false } globutils = { path = "../../libs/globutils" } diff --git a/src/ledger/Cargo.toml b/src/ledger/Cargo.toml index b01a0231b..c11f12ea9 100644 --- a/src/ledger/Cargo.toml +++ b/src/ledger/Cargo.toml @@ -34,9 +34,9 @@ fp-utils = { path = "../components/contracts/primitives/utils" } itertools = "0.10" ruc = "1.0" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } bulletproofs = { git = "https://github.com/FindoraNetwork/bulletproofs", tag = "v1.0.1-f" } fbnc = { version = "0.2.9", default-features = false} @@ -68,10 +68,10 @@ features = ["f16", "serde"] parking_lot = "0.12" # sodiumoxide = "0.2.1" fs2 = "0.4" -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v0.2.2", optional = true } -fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v0.2.2", optional = true } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4", optional = true } +fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4", optional = true } sparse_merkle_tree = { path = "../libs/sparse_merkle_tree" } -noah-accumulators = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah-accumulators = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } [target.'cfg(target_arch = "wasm32")'.dependencies] parking_lot = { version = "0.11", features = ["wasm-bindgen"] } diff --git a/src/libs/credentials/Cargo.toml b/src/libs/credentials/Cargo.toml index 8b1819d3a..e470b6906 100644 --- a/src/libs/credentials/Cargo.toml +++ b/src/libs/credentials/Cargo.toml @@ -12,5 +12,5 @@ linear-map = {version = "1.2.0", features = ["serde_impl"] } serde = "1.0.124" serde_derive = "1.0" wasm-bindgen = { version = "=0.2.73", features = ["serde-serialize"] } -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } diff --git a/src/libs/globutils/Cargo.toml b/src/libs/globutils/Cargo.toml index 01bc71da1..fcc4613db 100644 --- a/src/libs/globutils/Cargo.toml +++ b/src/libs/globutils/Cargo.toml @@ -12,9 +12,9 @@ serde_json = "1.0" time = "0.3" rand = "0.8" cryptohash = { path = "../cryptohash" } -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } +noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } hex = "0.4.2" bip32 = "0.3.0" diff --git a/src/libs/sparse_merkle_tree/Cargo.toml b/src/libs/sparse_merkle_tree/Cargo.toml index aa3178d52..c90f569fd 100644 --- a/src/libs/sparse_merkle_tree/Cargo.toml +++ b/src/libs/sparse_merkle_tree/Cargo.toml @@ -23,9 +23,9 @@ serde = "1.0.124" serde_derive = "1.0" serde_json = "1.0" sha2 = "0.10" -storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v0.2.2" } -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" } +storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } +noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.2" } [dev-dependencies] -temp_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v0.2.2" } +temp_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } quickcheck = "0.9.0" diff --git a/tools/devnet/env.sh b/tools/devnet/env.sh index a7be04db9..ff39e0979 100755 --- a/tools/devnet/env.sh +++ b/tools/devnet/env.sh @@ -35,11 +35,11 @@ PRIV_KEY="o9gXFI5ft1VOkzYhvFpgUTWVoskM1CEih0zJcm3-EAQ=" # create directories and file mkdir -p $WALLET mkdir -p $DEVNET -echo "$MNEMONIC" > $WALLET/mnenomic.key +echo "$MNEMONIC" >$WALLET/mnenomic.key # setup endpoint -$BIN/fn setup -S $ENDPOINT > /dev/null -$BIN/fn setup -O $WALLET/mnenomic.key > /dev/null +$BIN/fn setup -S $ENDPOINT >/dev/null +$BIN/fn setup -O $WALLET/mnenomic.key >/dev/null # show envs if [ "$1" == "s" ]; then