From baa3665cc7cd9347453d6b43e32ab06fc867ac4f Mon Sep 17 00:00:00 2001 From: simonjiao Date: Tue, 3 Jan 2023 11:58:38 +0800 Subject: [PATCH] Fo 1159 main (#772) * honor block_number in call rpc * replace crate log with tracing * add clean_aux() fmerk update * update logging and enable snapshot * avoid overflow * update storage version to v1.1.4 * rename trace/fresh options Co-authored-by: simonjiao Co-authored-by: harry --- src/components/abciapp/Cargo.toml | 2 +- .../abciapp/src/abci/server/callback/mod.rs | 36 ++++++++------- src/components/abciapp/src/abci/server/mod.rs | 8 +++- .../src/api/query_server/query_api/mod.rs | 2 +- .../abciapp/src/api/submission_server/mod.rs | 2 +- .../api/submission_server/submission_api.rs | 2 +- src/components/abciapp/src/bins/abcid.rs | 2 +- src/components/abciapp/src/bins/findorad.rs | 12 ++++- src/components/config/src/abci/mod.rs | 39 ++++++++++++++++ src/components/config/src/findora/mod.rs | 39 ++++++++++++++++ src/components/contracts/baseapp/Cargo.toml | 6 +-- src/components/contracts/baseapp/src/app.rs | 22 ++++----- src/components/contracts/baseapp/src/lib.rs | 44 ++++++++++++------ .../contracts/modules/account/Cargo.toml | 6 +-- .../contracts/modules/ethereum/Cargo.toml | 6 +-- .../contracts/modules/ethereum/src/impls.rs | 4 +- .../contracts/modules/evm/Cargo.toml | 7 +-- .../modules/evm/precompile/frc20/Cargo.toml | 2 +- .../modules/evm/precompile/frc20/src/lib.rs | 2 +- .../modules/evm/precompile/utils/Cargo.toml | 2 +- .../modules/evm/precompile/utils/src/data.rs | 3 +- .../modules/evm/src/runtime/runner.rs | 7 +-- .../modules/evm/src/runtime/stack.rs | 17 ++++--- .../contracts/modules/xhub/Cargo.toml | 2 +- .../contracts/modules/xhub/src/impls.rs | 2 +- .../contracts/primitives/core/Cargo.toml | 4 +- .../contracts/primitives/core/src/context.rs | 16 +++++++ .../contracts/primitives/mocks/src/lib.rs | 5 +- .../primitives/rpc-server/Cargo.toml | 2 +- .../primitives/rpc-server/src/lib.rs | 2 +- .../contracts/primitives/storage/Cargo.toml | 4 +- src/components/contracts/rpc/Cargo.toml | 2 +- src/components/contracts/rpc/src/eth.rs | 46 ++++++++----------- .../contracts/rpc/src/eth_pubsub.rs | 2 +- src/components/contracts/rpc/src/lib.rs | 4 +- src/components/contracts/rpc/src/net.rs | 2 +- src/ledger/Cargo.toml | 2 +- src/ledger/src/store/mod.rs | 6 ++- src/libs/bitmap/Cargo.toml | 2 +- src/libs/merkle_tree/Cargo.toml | 2 +- tools/devnet/startnodes.sh | 1 + 41 files changed, 253 insertions(+), 125 deletions(-) diff --git a/src/components/abciapp/Cargo.toml b/src/components/abciapp/Cargo.toml index 41ccbcb51..19f64c051 100644 --- a/src/components/abciapp/Cargo.toml +++ b/src/components/abciapp/Cargo.toml @@ -17,7 +17,7 @@ path = "src/bins/abcid.rs" parking_lot = "0.12" base64 = "0.12" bincode = "1.3.1" -log = "0.4.8" +tracing = "0.1" rand = "0.8" rand_chacha = "0.2" rand_core = { version = "0.5", default-features = false, features = ["alloc"] } diff --git a/src/components/abciapp/src/abci/server/callback/mod.rs b/src/components/abciapp/src/abci/server/callback/mod.rs index 24ad037c4..b3563e662 100644 --- a/src/components/abciapp/src/abci/server/callback/mod.rs +++ b/src/components/abciapp/src/abci/server/callback/mod.rs @@ -40,6 +40,7 @@ use { Arc, }, }, + tracing::info }; #[cfg(feature = "web3_service")] @@ -95,7 +96,7 @@ pub fn info(s: &mut ABCISubmissionServer, req: &RequestInfo) -> ResponseInfo { drop(state); - log::info!(target: "abciapp", "======== Last committed height: {} ========", h); + info!(target: "abciapp", "======== Last committed height: {} ========", h); if la.all_commited() { la.begin_block(); @@ -242,7 +243,7 @@ pub fn deliver_tx( if tx.valid_in_abci() { // Log print for monitor purpose if td_height < EVM_FIRST_BLOCK_HEIGHT { - log::info!(target: "abciapp", + info!(target: "abciapp", "EVM transaction(FindoraTx) detected at early height {}: {:?}", td_height, tx ); @@ -271,7 +272,7 @@ pub fn deliver_tx( if let Err(err) = s.account_base_app.write().deliver_findora_tx(&tx) { - log::info!(target: "abciapp", "deliver convert account tx failed: {:?}", err); + info!(target: "abciapp", "deliver convert account tx failed: {:?}", err); resp.code = 1; resp.log = @@ -348,7 +349,7 @@ pub fn deliver_tx( } else { // Log print for monitor purpose if td_height < EVM_FIRST_BLOCK_HEIGHT { - log::info!( + info!( target: "abciapp", "EVM transaction(EvmTx) detected at early height {}: {:?}", @@ -456,6 +457,7 @@ pub fn commit(s: &mut ABCISubmissionServer, req: &RequestCommit) -> ResponseComm use enterprise_web3::{Setter, REDIS_CLIENT, WEB3_SERVICE_START_HEIGHT}; use std::collections::HashMap; use std::mem::replace; + use tracing::error; let height = state.get_tendermint_height() as u32; if height as u64 > *WEB3_SERVICE_START_HEIGHT { @@ -466,28 +468,28 @@ pub fn commit(s: &mut ABCISubmissionServer, req: &RequestCommit) -> ResponseComm let nonce_map = if let Ok(mut nonce_map) = NONCE_MAP.lock() { replace(&mut *nonce_map, HashMap::new()) } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; let code_map = if let Ok(mut code_map) = CODE_MAP.lock() { replace(&mut *code_map, HashMap::new()) } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; let balance_map = if let Ok(mut balance_map) = BALANCE_MAP.lock() { replace(&mut *balance_map, HashMap::new()) } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; let state_list = if let Ok(mut state_list) = STATE_UPDATE_LIST.lock() { replace(&mut *state_list, vec![]) } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; @@ -500,14 +502,14 @@ pub fn commit(s: &mut ABCISubmissionServer, req: &RequestCommit) -> ResponseComm let txs = if let Ok(mut txs) = TXS.lock() { replace(&mut *txs, vec![]) } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; let receipts = if let Ok(mut receipts) = RECEIPTS.lock() { replace(&mut *receipts, vec![]) } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; @@ -521,27 +523,27 @@ pub fn commit(s: &mut ABCISubmissionServer, req: &RequestCommit) -> ResponseComm { setter .set_height(height) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); for (addr, code) in code_map.iter() { setter .set_byte_code(height, *addr, code.clone()) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } for (addr, nonce) in nonce_map.iter() { setter .set_nonce(height, *addr, *nonce) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } for (addr, balance) in balance_map.iter() { setter .set_balance(height, *addr, *balance) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } @@ -553,14 +555,14 @@ pub fn commit(s: &mut ABCISubmissionServer, req: &RequestCommit) -> ResponseComm state.index.clone(), state.value.clone(), ) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } if let Some(block) = block { setter .set_block_info(block, receipts, txs) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } } @@ -578,7 +580,7 @@ fn app_hash( mut la_hash: Vec, mut cs_hash: Vec, ) -> Vec { - log::info!(target: "abciapp", + info!(target: "abciapp", "app_hash_{}: {}_{}, height: {}", when, hex::encode(la_hash.clone()), 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/api/query_server/query_api/mod.rs b/src/components/abciapp/src/api/query_server/query_api/mod.rs index 57b636fbe..e05bf8b14 100644 --- a/src/components/abciapp/src/api/query_server/query_api/mod.rs +++ b/src/components/abciapp/src/api/query_server/query_api/mod.rs @@ -24,7 +24,7 @@ use { }, }, ledger_api::*, - log::info, + tracing::info, parking_lot::RwLock, ruc::*, serde::{Deserialize, Serialize}, diff --git a/src/components/abciapp/src/api/submission_server/mod.rs b/src/components/abciapp/src/api/submission_server/mod.rs index 7aed3660f..32b7ad723 100644 --- a/src/components/abciapp/src/api/submission_server/mod.rs +++ b/src/components/abciapp/src/api/submission_server/mod.rs @@ -271,7 +271,7 @@ pub enum TxCatalog { pub fn try_tx_catalog(tx: &[u8], log: bool) -> TxCatalog { // print tx if log { - log::info!(target: "abciapp", "try_tx_catalog: {:?}", base64::encode(tx)); + tracing::info!(target: "abciapp", "try_tx_catalog: {:?}", base64::encode(tx)); } let len = EVM_TX_TAG.len(); diff --git a/src/components/abciapp/src/api/submission_server/submission_api.rs b/src/components/abciapp/src/api/submission_server/submission_api.rs index 1714733a6..1a1f746bd 100644 --- a/src/components/abciapp/src/api/submission_server/submission_api.rs +++ b/src/components/abciapp/src/api/submission_server/submission_api.rs @@ -8,7 +8,7 @@ use { actix_web::{error, middleware, web, App, HttpServer}, finutils::api::NetworkRoute, ledger::data_model::Transaction, - log::info, + tracing::info, parking_lot::RwLock, rand_core::{CryptoRng, RngCore}, ruc::*, diff --git a/src/components/abciapp/src/bins/abcid.rs b/src/components/abciapp/src/bins/abcid.rs index 036b92568..5d30e8276 100644 --- a/src/components/abciapp/src/bins/abcid.rs +++ b/src/components/abciapp/src/bins/abcid.rs @@ -13,7 +13,7 @@ use { fn main() { globutils::logging::init_logging(None); - log::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 de6858503..f60506afd 100644 --- a/src/components/abciapp/src/bins/findorad.rs +++ b/src/components/abciapp/src/bins/findorad.rs @@ -51,6 +51,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") @@ -60,7 +67,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"), @@ -69,6 +78,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 5169d8490..b1423a7fe 100644 --- a/src/components/config/src/abci/mod.rs +++ b/src/components/config/src/abci/mod.rs @@ -288,6 +288,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, @@ -321,6 +323,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]") @@ -364,6 +368,39 @@ pub mod global_cfg { .unwrap_or_else(|| "26658".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 th = m .value_of("tendermint-host") .map(|v| v.to_owned()) @@ -434,6 +471,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..df7fd0381 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 1a83b9ba2..8438da858 100644 --- a/src/components/contracts/baseapp/Cargo.toml +++ b/src/components/contracts/baseapp/Cargo.toml @@ -15,15 +15,15 @@ ethereum-types = {version = "0.13.1", default-features = false} futures = "0.3.16" lazy_static = "1.4.0" ledger = {path = "../../../ledger"} -log = "0.4" +tracing = "0.1" parking_lot = "0.12" primitive-types = {version = "0.11.1", default-features = false, features = ["rlp", "byteorder", "serde"]} protobuf = "2.16" ruc = "1.0" serde = {version = "1.0.124", features = ["derive"]} serde_json = "1.0.40" -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" # primitives diff --git a/src/components/contracts/baseapp/src/app.rs b/src/components/contracts/baseapp/src/app.rs index b131f122c..a30c252a5 100644 --- a/src/components/contracts/baseapp/src/app.rs +++ b/src/components/contracts/baseapp/src/app.rs @@ -4,7 +4,7 @@ use fp_core::context::RunTxMode; use fp_evm::BlockId; use fp_types::assemble::convert_unchecked_transaction; use fp_utils::tx::EvmRawTxWrapper; -use log::{debug, error, info}; +use tracing::{debug, error, info}; use primitive_types::U256; use ruc::*; @@ -96,7 +96,7 @@ impl crate::BaseApp { if let Ok(mut code_map) = PENDING_CODE_MAP.lock() { replace(&mut *code_map, HashMap::new()) } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; let state_list = if let Ok(mut state_list) = @@ -104,7 +104,7 @@ impl crate::BaseApp { { replace(&mut *state_list, vec![]) } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; if 0 == ar.code { @@ -121,12 +121,12 @@ impl crate::BaseApp { setter .set_pending_tx(tx) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); for (addr, code) in code_map.iter() { setter .set_pending_code(*addr, code.clone()) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } for state in state_list.iter() { @@ -136,7 +136,7 @@ impl crate::BaseApp { state.index.clone(), state.value.clone(), ) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } } @@ -230,7 +230,7 @@ impl crate::BaseApp { let map = replace(m, vec![]); map.clone() } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; let state_list = if let Ok(mut state_list) = @@ -240,7 +240,7 @@ impl crate::BaseApp { let v2 = replace(v, vec![]); v2.clone() } else { - log::error!("{}", ""); + error!("{}", ""); Default::default() }; if 0 == ar.code { @@ -257,13 +257,13 @@ impl crate::BaseApp { setter .remove_pending_tx(tx) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); for addr in code_map.iter() { setter .remove_pending_code(*addr) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } @@ -273,7 +273,7 @@ impl crate::BaseApp { address.clone(), index.clone(), ) - .map_err(|e| log::error!("{:?}", e)) + .map_err(|e| error!("{:?}", e)) .unwrap_or(()); } } diff --git a/src/components/contracts/baseapp/src/lib.rs b/src/components/contracts/baseapp/src/lib.rs index 116b1e5d9..398b66269 100644 --- a/src/components/contracts/baseapp/src/lib.rs +++ b/src/components/contracts/baseapp/src/lib.rs @@ -36,22 +36,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 { @@ -155,22 +154,33 @@ impl module_xhub::Config for BaseApp { } impl BaseApp { - pub fn new(basedir: &Path, empty_block: bool) -> Result { - log::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())?; @@ -292,6 +302,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 3829103ac..2f9cc3eba 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,7 +28,7 @@ enterprise-web3 = { path = "../../primitives/enterprise-web3", optional = true rand_chacha = "0.2" parking_lot = "0.12" zei = { git = "https://github.com/FindoraNetwork/zei", branch = "stable-main" } -fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" } +fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } [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 2f1c9b6a5..18a15b893 100644 --- a/src/components/contracts/modules/ethereum/Cargo.toml +++ b/src/components/contracts/modules/ethereum/Cargo.toml @@ -13,7 +13,7 @@ abci = { git = "https://github.com/FindoraNetwork/tendermint-abci", tag = "0.7.4 ethereum = { version = "0.12.0", default-features = false, features = ["with-serde"] } ethereum-types = { version = "0.13.1", default-features = false } evm = { version = "0.35.0", default-features = false, features = ["with-serde"] } -log = "0.4" +tracing = "0.1" rand = "0.8" rlp = "0.5" ruc = "1.0" @@ -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/ethereum/src/impls.rs b/src/components/contracts/modules/ethereum/src/impls.rs index 8a0ac81c7..e9f274c26 100644 --- a/src/components/contracts/modules/ethereum/src/impls.rs +++ b/src/components/contracts/modules/ethereum/src/impls.rs @@ -21,7 +21,7 @@ use fp_types::{ crypto::{secp256k1_ecdsa_recover, HA256}, }; use fp_utils::{proposer_converter, timestamp_converter}; -use log::{debug, info}; +use tracing::{debug, info}; use ruc::*; use sha3::{Digest, Keccak256}; @@ -171,7 +171,7 @@ impl App { let block = BlockAny::from(block); b.replace(block); } else { - log::error!("the block is not none"); + tracing::error!(target: "ethereum", "the block is not none"); } } if let Ok(mut txs) = TXS.lock() { diff --git a/src/components/contracts/modules/evm/Cargo.toml b/src/components/contracts/modules/evm/Cargo.toml index 02e0eab76..a0df88a04 100644 --- a/src/components/contracts/modules/evm/Cargo.toml +++ b/src/components/contracts/modules/evm/Cargo.toml @@ -16,7 +16,7 @@ evm-runtime = { version = "0.30.0", default-features = false } evm-gasometer = { version = "0.30.0", default-features = false } ethereum = { version = "0.12.0", default-features = false, features = ["with-serde"] } impl-trait-for-tuples = "0.2" -log = "0.4" +tracing = "0.1" rlp = { version = "0.5", default-features = false } ruc = "1.0" serde = { version = "1.0.124", features = ["derive"] } @@ -32,8 +32,9 @@ 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 } diff --git a/src/components/contracts/modules/evm/precompile/frc20/Cargo.toml b/src/components/contracts/modules/evm/precompile/frc20/Cargo.toml index 99853a7b2..e5845d173 100644 --- a/src/components/contracts/modules/evm/precompile/frc20/Cargo.toml +++ b/src/components/contracts/modules/evm/precompile/frc20/Cargo.toml @@ -13,7 +13,7 @@ ethereum-types = { version = "0.13.1", default-features = false } evm = { version = "0.35.0", default-features = false, features = ["with-serde"] } evm-precompile-utils = { path = "../utils"} fp-traits = { path = "../../../../primitives/traits" } -log = "0.4" +tracing = "0.1" module-evm = { path = "../../../../modules/evm"} num_enum = { version = "0.5.4", default-features = false } slices = "0.2.0" diff --git a/src/components/contracts/modules/evm/precompile/frc20/src/lib.rs b/src/components/contracts/modules/evm/precompile/frc20/src/lib.rs index 88d438c00..cc95a5459 100644 --- a/src/components/contracts/modules/evm/precompile/frc20/src/lib.rs +++ b/src/components/contracts/modules/evm/precompile/frc20/src/lib.rs @@ -12,7 +12,7 @@ use evm_precompile_utils::{ error, Address, EvmDataReader, EvmDataWriter, EvmResult, Gasometer, LogsBuilder, }; use fp_traits::{account::AccountAsset, evm::AddressMapping}; -use log::debug; +use tracing::debug; use module_evm::{ precompile::{FinState, Precompile, PrecompileId, PrecompileResult}, Config, diff --git a/src/components/contracts/modules/evm/precompile/utils/Cargo.toml b/src/components/contracts/modules/evm/precompile/utils/Cargo.toml index c1c3ce142..d525e8599 100644 --- a/src/components/contracts/modules/evm/precompile/utils/Cargo.toml +++ b/src/components/contracts/modules/evm/precompile/utils/Cargo.toml @@ -9,7 +9,7 @@ description = "Utils to write EVM precompiles." ethereum = { version = "0.12.0", default-features = false, features = ["with-serde"] } ethereum-types = { version = "0.13.1", default-features = false } evm = { version = "0.35.0", default-features = false, features = ["with-serde"] } -log = "0.4" +tracing = "0.1" num_enum = { version = "0.5.3", default-features = false } precompile-utils-macro = { path = "macro" } sha3 = { version = "0.8", default-features = false } diff --git a/src/components/contracts/modules/evm/precompile/utils/src/data.rs b/src/components/contracts/modules/evm/precompile/utils/src/data.rs index 49f13c2d4..99684f5f6 100644 --- a/src/components/contracts/modules/evm/precompile/utils/src/data.rs +++ b/src/components/contracts/modules/evm/precompile/utils/src/data.rs @@ -18,6 +18,7 @@ use super::{error, EvmResult}; use core::{any::type_name, ops::Range}; use ethereum_types::{H160, H256, U256}; use std::{convert::TryInto, vec, vec::Vec}; +use tracing::trace; /// The `address` type of Solidity. /// H160 could represent 2 types of data (bytes20 and address) that are not encoded the same way. @@ -91,7 +92,7 @@ impl<'a> EvmDataReader<'a> { .map_err(|_| error("tried to parse selector out of bounds"))?, ); T::try_from_primitive(u32::from_be_bytes(buffer)).map_err(|_| { - log::trace!( + trace!( target: "precompile", "Failed to match function selector for {}", type_name::() diff --git a/src/components/contracts/modules/evm/src/runtime/runner.rs b/src/components/contracts/modules/evm/src/runtime/runner.rs index ef5421a0d..9e6ed735f 100644 --- a/src/components/contracts/modules/evm/src/runtime/runner.rs +++ b/src/components/contracts/modules/evm/src/runtime/runner.rs @@ -13,6 +13,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); - log::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 { - log::debug!( + debug!( target: "evm", "Deleting account at {:?}", address @@ -124,7 +125,7 @@ impl ActionRunner { } for log in &state.substate.logs { - log::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 63f08be19..252c505a8 100644 --- a/src/components/contracts/modules/evm/src/runtime/stack.rs +++ b/src/components/contracts/modules/evm/src/runtime/stack.rs @@ -15,9 +15,9 @@ use fp_traits::{ evm::{BlockHashMapping, FeeCalculator}, }; use fp_utils::timestamp_converter; -use log::info; use std::{collections::btree_set::BTreeSet, marker::PhantomData, mem}; use storage::state::State; +use tracing::{debug, error, info}; pub struct FindoraStackSubstate<'context, 'config> { pub ctx: &'context Context, @@ -326,7 +326,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> fn set_storage(&mut self, address: H160, index: H256, value: H256) { if value == H256::default() { - log::debug!( + debug!( target: "evm", "Removing storage for {:?} [index: {:?}]", address, @@ -338,7 +338,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> &index.into(), ); } else { - log::debug!( + debug!( target: "evm", "Updating storage for {:?} [index: {:?}, value: {:?}]", address, @@ -351,7 +351,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> &index.into(), &value, ) { - log::error!( + error!( target: "evm", "Failed updating storage for {:?} [index: {:?}, value: {:?}], error: {:?}", address, @@ -407,6 +407,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(), @@ -423,7 +428,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> fn set_code(&mut self, address: H160, code: Vec) { let code_len = code.len(); - log::debug!( + debug!( target: "evm", "Inserting code ({} bytes) at {:?}", code_len, @@ -435,7 +440,7 @@ impl<'context, 'vicinity, 'config, C: Config> StackState<'config> let result = App::::create_account(self.ctx, address.into(), code); if let Err(e) = result { - log::error!( + error!( target: "evm", "Failed inserting code ({} bytes) at {:?}, error: {:?}", code_len, diff --git a/src/components/contracts/modules/xhub/Cargo.toml b/src/components/contracts/modules/xhub/Cargo.toml index 3966579a2..a7def8bee 100644 --- a/src/components/contracts/modules/xhub/Cargo.toml +++ b/src/components/contracts/modules/xhub/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" abci = { git = "https://github.com/FindoraNetwork/tendermint-abci", tag = "0.7.4" } lazy_static = "1.4.0" ledger = { path = "../../../../ledger" } -log = "0.4" +tracing = "0.1" primitive-types = { version = "0.11.1", default-features = false, features = ["rlp", "byteorder", "serde"] } ruc = "1.0" serde = { version = "1.0.124", features = ["derive"] } diff --git a/src/components/contracts/modules/xhub/src/impls.rs b/src/components/contracts/modules/xhub/src/impls.rs index b50b155da..c279760dd 100644 --- a/src/components/contracts/modules/xhub/src/impls.rs +++ b/src/components/contracts/modules/xhub/src/impls.rs @@ -6,7 +6,7 @@ use fp_traits::{account::AccountAsset, evm::DecimalsMapping}; use fp_types::actions::xhub::NonConfidentialTransfer; use fp_types::{actions::xhub::NonConfidentialOutput, crypto::Address}; use ledger::data_model::ASSET_TYPE_FRA; -use log::debug; +use tracing::debug; use primitive_types::U256; use ruc::*; diff --git a/src/components/contracts/primitives/core/Cargo.toml b/src/components/contracts/primitives/core/Cargo.toml index a6f90ce48..cada06661 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 = "1.9.4"} # 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/src/lib.rs b/src/components/contracts/primitives/mocks/src/lib.rs index e251935ac..11fa1bd49 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::time::SystemTime; use zei::xfr::sig::XfrKeyPair; 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/rpc-server/Cargo.toml b/src/components/contracts/primitives/rpc-server/Cargo.toml index c5f4d0dbd..1305327d2 100644 --- a/src/components/contracts/primitives/rpc-server/Cargo.toml +++ b/src/components/contracts/primitives/rpc-server/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" futures = "0.3.16" jsonrpc-core = { git = "https://github.com/FindoraNetwork/jsonrpc.git", package = "jsonrpc-core" } pubsub = { git = "https://github.com/FindoraNetwork/jsonrpc.git", package = "jsonrpc-pubsub" } -log = "0.4.8" +tracing = "0.1" serde_json = "1.0.41" http = { git = "https://github.com/FindoraNetwork/jsonrpc.git", package = "jsonrpc-http-server" } diff --git a/src/components/contracts/primitives/rpc-server/src/lib.rs b/src/components/contracts/primitives/rpc-server/src/lib.rs index c31f387f3..88d1da5b5 100644 --- a/src/components/contracts/primitives/rpc-server/src/lib.rs +++ b/src/components/contracts/primitives/rpc-server/src/lib.rs @@ -23,7 +23,7 @@ mod middleware; use jsonrpc_core::{IoHandlerExtension, MetaIoHandler}; -use log::error; +use tracing::error; use pubsub::PubSubMetadata; use std::io; diff --git a/src/components/contracts/primitives/storage/Cargo.toml b/src/components/contracts/primitives/storage/Cargo.toml index 389fd11ee..316ea0aa1 100644 --- a/src/components/contracts/primitives/storage/Cargo.toml +++ b/src/components/contracts/primitives/storage/Cargo.toml @@ -15,11 +15,11 @@ ruc = "1.0" serde = { version = "1.0.124", features = ["derive"] } serde_json = "1.0" sha2 = "0.9.5" -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" } config = { path = "../../../config"} [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/rpc/Cargo.toml b/src/components/contracts/rpc/Cargo.toml index 2a274622c..003bc245e 100644 --- a/src/components/contracts/rpc/Cargo.toml +++ b/src/components/contracts/rpc/Cargo.toml @@ -28,7 +28,7 @@ jsonrpc-http-server = { git = "https://github.com/FindoraNetwork/jsonrpc.git", p jsonrpc-tcp-server = { git = "https://github.com/FindoraNetwork/jsonrpc.git", package = "jsonrpc-tcp-server" } libsecp256k1 = { version = "0.5", features = ["static-context", "hmac"] } lazy_static = "1.4.0" -log = "0.4.8" +tracing = "0.1" rand = "0.8" parking_lot = "0.12" rlp = "0.5" diff --git a/src/components/contracts/rpc/src/eth.rs b/src/components/contracts/rpc/src/eth.rs index 8a86e73b0..a58edea31 100644 --- a/src/components/contracts/rpc/src/eth.rs +++ b/src/components/contracts/rpc/src/eth.rs @@ -30,7 +30,7 @@ use fp_utils::tx::EvmRawTxWrapper; use hex_literal::hex; use jsonrpc_core::{futures::future, BoxFuture, Result}; use lazy_static::lazy_static; -use log::{debug, warn}; +use tracing::{debug, warn}; use parking_lot::RwLock; use sha3::{Digest, Keccak256}; use std::collections::BTreeMap; @@ -317,9 +317,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 account_base_app = self.account_base_app.clone(); @@ -334,18 +334,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(); @@ -353,18 +349,14 @@ 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("failed to create context"))?; + + 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) => { @@ -820,7 +812,7 @@ impl EthApi for EthApiImpl { } let allowance = available / gas_price; if highest < allowance { - log::warn!( + warn!( "Gas estimation capped by limited funds original {} balance {} sent {} feecap {} fundable {}", highest, balance, diff --git a/src/components/contracts/rpc/src/eth_pubsub.rs b/src/components/contracts/rpc/src/eth_pubsub.rs index 56bcbac22..e3613c728 100644 --- a/src/components/contracts/rpc/src/eth_pubsub.rs +++ b/src/components/contracts/rpc/src/eth_pubsub.rs @@ -18,7 +18,7 @@ use futures::{ use jsonrpc_core::Result as JsonRpcResult; use jsonrpc_pubsub::{manager::SubscriptionManager, typed::Subscriber, SubscriptionId}; use lazy_static::lazy_static; -use log::{debug, warn}; +use tracing::{debug, warn}; use parking_lot::RwLock; use sha3::{Digest, Keccak256}; use std::collections::BTreeMap; diff --git a/src/components/contracts/rpc/src/lib.rs b/src/components/contracts/rpc/src/lib.rs index 0efa7b08b..6a0578100 100644 --- a/src/components/contracts/rpc/src/lib.rs +++ b/src/components/contracts/rpc/src/lib.rs @@ -18,7 +18,7 @@ use fp_rpc_core::{ use fp_rpc_server::{rpc_handler, start_http, start_ws, RpcHandler, RpcMiddleware}; use fp_utils::ecdsa::SecpPair; use jsonrpc_core::types::error::{Error, ErrorCode}; -use log::error; +use tracing::error; use parking_lot::RwLock; use rustc_hex::ToHex; use serde_json::Value; @@ -99,7 +99,7 @@ pub fn start_web3_service( // Wrapper for HTTP and WS servers that makes sure they are properly shut down. mod waiting { - use log::debug; + use tracing::debug; pub struct HttpServer(pub Option); impl Drop for HttpServer { diff --git a/src/components/contracts/rpc/src/net.rs b/src/components/contracts/rpc/src/net.rs index 63be90373..f853c8408 100644 --- a/src/components/contracts/rpc/src/net.rs +++ b/src/components/contracts/rpc/src/net.rs @@ -2,7 +2,7 @@ use baseapp::BaseApp; use fp_rpc_core::types::PeerCount; use fp_rpc_core::NetApi; use jsonrpc_core::{BoxFuture, Result}; -use log::warn; +use tracing::warn; pub struct NetApiImpl; diff --git a/src/ledger/Cargo.toml b/src/ledger/Cargo.toml index 2aa4bcda4..f99c38883 100644 --- a/src/ledger/Cargo.toml +++ b/src/ledger/Cargo.toml @@ -13,7 +13,7 @@ curve25519-dalek = { version = "3.0", features = ["serde"] } ed25519-dalek = "1.0.0" hex = "0.4.2" lazy_static = { version = "1.2.0" } -log="*" +tracing = "0.1" rand = "=0.7.3" rand_chacha = "0.2" rand_core = { version = "0.5", default-features = false, features = ["alloc"] } diff --git a/src/ledger/src/store/mod.rs b/src/ledger/src/store/mod.rs index 52ead3d33..60e9b316b 100644 --- a/src/ledger/src/store/mod.rs +++ b/src/ledger/src/store/mod.rs @@ -1385,10 +1385,12 @@ impl LedgerStatus { .or_insert_with(HashSet::new) .insert(TxoSID(txo_sid)); let utxo = Utxo(tx_output); - *self + let mut e = self .nonconfidential_balances .entry(utxo.0.record.public_key) - .or_insert(0) += utxo.get_nonconfidential_balance(); + .or_insert(0); + *e.deref_mut() = + e.saturating_add(utxo.get_nonconfidential_balance()); self.utxos.insert(TxoSID(txo_sid), utxo); txn_utxo_sids.push(TxoSID(txo_sid)); } diff --git a/src/libs/bitmap/Cargo.toml b/src/libs/bitmap/Cargo.toml index d2ca35475..6e7eb2c63 100644 --- a/src/libs/bitmap/Cargo.toml +++ b/src/libs/bitmap/Cargo.toml @@ -11,7 +11,7 @@ parking_lot = "0.12" arrayref = "0.3.5" cryptohash = { path = "../cryptohash" } itertools = "0.10.5" -log = "0.4.8" +tracing = "0.1" rand = "0.8" rand_chacha = "0.2" serde = "1.0.124" diff --git a/src/libs/merkle_tree/Cargo.toml b/src/libs/merkle_tree/Cargo.toml index 48ea98e76..833aac469 100644 --- a/src/libs/merkle_tree/Cargo.toml +++ b/src/libs/merkle_tree/Cargo.toml @@ -14,7 +14,7 @@ cryptohash = { path = "../cryptohash" } hex = "0.4.2" itertools = "0.10.5" lazy_static = { version = "1.2.0" } -log = "0.4.8" +tracing = "0.1" rand = "0.8" rand_chacha = "0.2" serde = { version = "1.0.124", features =["derive"] } diff --git a/tools/devnet/startnodes.sh b/tools/devnet/startnodes.sh index a35667c48..8a9237904 100755 --- a/tools/devnet/startnodes.sh +++ b/tools/devnet/startnodes.sh @@ -20,6 +20,7 @@ if [ -z "$Node" ] || ([ ! -z "$Node" ] && [ "$Node" = "$node" ]); then LEDGER_DIR=$DEVNET/$node/abci \ ENABLE_QUERY_SERVICE=true \ ENABLE_ETH_API_SERVICE=true \ + ARC_HISTORY=4,2 \ abcid $DEVNET/$node >> $DEVNET/$node/abcid.log 2>&1 & fi done