diff --git a/src/fork.rs b/src/fork.rs index 1f6ea70b..71d30c63 100644 --- a/src/fork.rs +++ b/src/fork.rs @@ -723,7 +723,7 @@ impl ForkDetails { #[cfg(test)] mod tests { use zksync_basic_types::{AccountTreeId, L1BatchNumber, H256}; - use zksync_state::ReadStorage; + use zksync_state::interface::ReadStorage; use zksync_types::{api::TransactionVariant, StorageKey}; use crate::config::cache::CacheConfig; diff --git a/src/http_fork_source.rs b/src/http_fork_source.rs index 16a9685b..18ccfbce 100644 --- a/src/http_fork_source.rs +++ b/src/http_fork_source.rs @@ -87,7 +87,7 @@ impl ForkSource for HttpForkSource { let client = self.create_client(); block_on(async move { client.get_transaction_by_hash(hash).await }) - .map(|maybe_transaction| { + .inspect(|maybe_transaction| { if let Some(transaction) = &maybe_transaction { self.cache .write() @@ -99,7 +99,6 @@ impl ForkSource for HttpForkSource { ) }); } - maybe_transaction }) .wrap_err("fork http client failed") } @@ -133,7 +132,7 @@ impl ForkSource for HttpForkSource { let client = self.create_client(); block_on(async move { client.get_raw_block_transactions(block_number).await }) .wrap_err("fork http client failed") - .map(|transactions| { + .inspect(|transactions| { if !transactions.is_empty() { self.cache .write() @@ -147,7 +146,6 @@ impl ForkSource for HttpForkSource { ) }); } - transactions }) } @@ -167,7 +165,7 @@ impl ForkSource for HttpForkSource { let client = self.create_client(); block_on(async move { client.get_block_by_hash(hash, full_transactions).await }) - .map(|block| { + .inspect(|block| { if let Some(block) = &block { self.cache .write() @@ -179,7 +177,6 @@ impl ForkSource for HttpForkSource { ) }); } - block }) .wrap_err("fork http client failed") } @@ -211,7 +208,7 @@ impl ForkSource for HttpForkSource { .get_block_by_number(block_number, full_transactions) .await }) - .map(|block| { + .inspect(|block| { if let Some(block) = &block { self.cache .write() @@ -225,7 +222,6 @@ impl ForkSource for HttpForkSource { ) }); } - block }) .wrap_err("fork http client failed") } @@ -313,7 +309,7 @@ impl ForkSource for HttpForkSource { let client = self.create_client(); block_on(async move { client.get_bridge_contracts().await }) - .map(|bridge_addresses| { + .inspect(|bridge_addresses| { self.cache .write() .map(|mut guard| guard.set_bridge_addresses(bridge_addresses.clone())) @@ -323,7 +319,6 @@ impl ForkSource for HttpForkSource { err ) }); - bridge_addresses }) .wrap_err("fork http client failed") } @@ -342,7 +337,7 @@ impl ForkSource for HttpForkSource { let client = self.create_client(); block_on(async move { client.get_confirmed_tokens(from, limit).await }) - .map(|confirmed_tokens| { + .inspect(|confirmed_tokens| { self.cache .write() .map(|mut guard| { @@ -354,7 +349,6 @@ impl ForkSource for HttpForkSource { err ) }); - confirmed_tokens }) .wrap_err("fork http client failed") } diff --git a/src/node/in_memory.rs b/src/node/in_memory.rs index e339a61f..342abb34 100644 --- a/src/node/in_memory.rs +++ b/src/node/in_memory.rs @@ -1947,7 +1947,7 @@ mod tests { ); let mut tx = L2Tx::new_signed( - deployed_address, + Some(deployed_address), hex::decode("bbf55335").unwrap(), // keccak selector for "transact_retrieve1()" Nonce(1), Fee { diff --git a/src/node/in_memory_ext.rs b/src/node/in_memory_ext.rs index 59cd612e..0a793246 100644 --- a/src/node/in_memory_ext.rs +++ b/src/node/in_memory_ext.rs @@ -398,7 +398,7 @@ mod tests { use std::str::FromStr; use std::sync::{Arc, RwLock}; use zksync_basic_types::{Nonce, H256}; - use zksync_state::ReadStorage; + use zksync_state::interface::ReadStorage; use zksync_types::{api::BlockNumber, fee::Fee, l2::L2Tx, PackedEthSignature}; #[tokio::test] @@ -563,7 +563,7 @@ mod tests { // construct a tx let mut tx = L2Tx::new( - Address::random(), + Some(Address::random()), vec![], Nonce(0), Fee { diff --git a/src/resolver.rs b/src/resolver.rs index 6db63897..fc98c634 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -80,15 +80,13 @@ impl SignEthClient { .get(url) .send() .await - .map_err(|err| { - self.on_reqwest_err(&err); - err + .inspect_err(|err| { + self.on_reqwest_err(err); })? .text() .await - .map_err(|err| { - self.on_reqwest_err(&err); - err + .inspect_err(|err| { + self.on_reqwest_err(err); }) } diff --git a/src/testing.rs b/src/testing.rs index 7fb487c3..da9f9970 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -436,7 +436,7 @@ impl TransactionBuilder { pub fn build(&mut self) -> L2Tx { let mut tx = L2Tx::new_signed( - Address::random(), + Some(Address::random()), vec![], Nonce(0), Fee { @@ -537,7 +537,7 @@ pub fn deploy_contract( .expect("failed encoding function data"); let mut tx = L2Tx::new_signed( - zksync_types::CONTRACT_DEPLOYER_ADDRESS, + Some(zksync_types::CONTRACT_DEPLOYER_ADDRESS), data.to_vec(), nonce, Fee { @@ -563,6 +563,7 @@ pub fn deploy_contract( #[derive(Debug, Default, Clone)] pub struct LogBuilder { block_number: U64, + block_timestamp: U64, address: Option, topics: Option>, } @@ -606,6 +607,7 @@ impl LogBuilder { transaction_log_index: Default::default(), log_type: Default::default(), removed: Some(false), + block_timestamp: Some(self.block_timestamp), } } } diff --git a/src/utils.rs b/src/utils.rs index 565a9aa9..f9bba0da 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -343,13 +343,7 @@ mod tests { #[test] fn test_utc_datetime_from_epoch_ms() { let actual = utc_datetime_from_epoch_ms(1623931200000); - assert_eq!( - DateTime::::from_naive_utc_and_offset( - chrono::NaiveDateTime::from_timestamp_opt(1623931200, 0).unwrap(), - Utc - ), - actual - ); + assert_eq!(DateTime::from_timestamp(1623931200, 0).unwrap(), actual); } #[test]