diff --git a/crates/cli/src/bytecode_override.rs b/crates/cli/src/bytecode_override.rs index 85e1d2ed..bc9e6d40 100644 --- a/crates/cli/src/bytecode_override.rs +++ b/crates/cli/src/bytecode_override.rs @@ -1,6 +1,5 @@ use std::fs; -use anvil_zksync_core::fork::ForkSource; use anvil_zksync_core::node::InMemoryNode; use eyre::Context; use hex::FromHex; @@ -20,10 +19,7 @@ struct Bytecode { // Loads a list of bytecodes and addresses from the directory and then inserts them directly // into the Node's storage. -pub fn override_bytecodes( - node: &InMemoryNode, - bytecodes_dir: String, -) -> eyre::Result<()> { +pub fn override_bytecodes(node: &InMemoryNode, bytecodes_dir: String) -> eyre::Result<()> { for entry in fs::read_dir(bytecodes_dir)? { let entry = entry?; let path = entry.path(); diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index b0c88c97..e8fe5a98 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -8,8 +8,7 @@ use anvil_zksync_config::constants::{ }; use anvil_zksync_config::types::SystemContractsOptions; use anvil_zksync_config::ForkPrintInfo; -use anvil_zksync_core::fork::{ForkDetails, ForkSource}; -use anvil_zksync_core::http_fork_source::HttpForkSource; +use anvil_zksync_core::fork::ForkDetails; use anvil_zksync_core::namespaces::{ AnvilNamespaceT, ConfigurationApiNamespaceT, DebugNamespaceT, EthNamespaceT, EthTestNodeNamespaceT, EvmNamespaceT, HardhatNamespaceT, NetNamespaceT, Web3NamespaceT, @@ -43,12 +42,10 @@ mod logging_middleware; mod utils; #[allow(clippy::too_many_arguments)] -async fn build_json_http< - S: std::marker::Sync + std::marker::Send + 'static + ForkSource + std::fmt::Debug + Clone, ->( +async fn build_json_http( addr: SocketAddr, log_level_filter: LevelFilter, - node: InMemoryNode, + node: InMemoryNode, enable_health_api: bool, ) -> tokio::task::JoinHandle<()> { let (sender, recv) = oneshot::channel::<()>(); @@ -280,7 +277,7 @@ async fn main() -> anyhow::Result<()> { }; let block_sealer = BlockSealer::new(sealing_mode); - let node: InMemoryNode = InMemoryNode::new( + let node: InMemoryNode = InMemoryNode::new( fork_details, Some(observability), &config, diff --git a/crates/core/src/fork.rs b/crates/core/src/fork.rs index fcac9379..79368e8d 100644 --- a/crates/core/src/fork.rs +++ b/crates/core/src/fork.rs @@ -18,7 +18,6 @@ use std::{ convert::{TryFrom, TryInto}, fmt, future::Future, - marker::PhantomData, str::FromStr, sync::{Arc, RwLock}, }; @@ -99,13 +98,13 @@ impl ForkNetwork { /// If forking is enabled, it reads missing data from remote location. /// S - is a struct that is used for source of the fork. #[derive(Debug, Clone)] -pub struct ForkStorage { - pub inner: Arc>>, +pub struct ForkStorage { + pub inner: Arc>, pub chain_id: L2ChainId, } #[derive(Debug)] -pub struct ForkStorageInner { +pub struct ForkStorageInner { // Underlying local storage pub raw_storage: InMemoryStorage, // Cache of data that was read from remote location. @@ -115,11 +114,9 @@ pub struct ForkStorageInner { // If set - it hold the necessary information on where to fetch the data. // If not set - it will simply read from underlying storage. pub fork: Option>, - // ForkSource type no longer needed but retained to keep the old interface. - pub dummy: PhantomData, } -impl ForkStorage { +impl ForkStorage { pub fn new( fork: Option, system_contracts_options: &SystemContractsOptions, @@ -145,7 +142,6 @@ impl ForkStorage { value_read_cache: Default::default(), fork: fork.map(Box::new), factory_dep_cache: Default::default(), - dummy: Default::default(), })), chain_id, } @@ -304,7 +300,7 @@ impl ForkStorage { } } -impl ReadStorage for ForkStorage { +impl ReadStorage for ForkStorage { fn is_write_initial(&mut self, key: &StorageKey) -> bool { self.is_write_initial_internal(key).unwrap() } @@ -322,7 +318,7 @@ impl ReadStorage for ForkStorage { } } -impl ReadStorage for &ForkStorage { +impl ReadStorage for &ForkStorage { fn read_value(&mut self, key: &StorageKey) -> zksync_types::StorageValue { self.read_value_internal(key).unwrap() } @@ -340,7 +336,7 @@ impl ReadStorage for &ForkStorage { } } -impl ForkStorage { +impl ForkStorage { pub fn set_value(&mut self, key: StorageKey, value: zksync_types::StorageValue) { let mut mutator = self.inner.write().unwrap(); mutator.raw_storage.set_value(key, value) @@ -922,7 +918,7 @@ mod tests { cache_config: CacheConfig::None, }; - let mut fork_storage: ForkStorage = + let mut fork_storage: ForkStorage = ForkStorage::new(Some(fork_details), &options, false, None); assert!(fork_storage.is_write_initial(&never_written_key)); @@ -985,7 +981,7 @@ mod tests { fee_params: None, cache_config: CacheConfig::None, }; - let mut fork_storage: ForkStorage = ForkStorage::new( + let mut fork_storage: ForkStorage = ForkStorage::new( Some(fork_details), &SystemContractsOptions::default(), false, diff --git a/crates/core/src/node/anvil.rs b/crates/core/src/node/anvil.rs index 6f0e3b4c..008344a1 100644 --- a/crates/core/src/node/anvil.rs +++ b/crates/core/src/node/anvil.rs @@ -6,15 +6,12 @@ use zksync_web3_decl::error::Web3Error; use crate::namespaces::DetailedTransaction; use crate::utils::Numeric; use crate::{ - fork::ForkSource, namespaces::{AnvilNamespaceT, ResetRequest, RpcResult}, node::InMemoryNode, utils::{into_jsrpc_error, into_jsrpc_error_message, IntoBoxedFuture}, }; -impl AnvilNamespaceT - for InMemoryNode -{ +impl AnvilNamespaceT for InMemoryNode { fn dump_state(&self, preserve_historical_states: Option) -> RpcResult { self.dump_state(preserve_historical_states.unwrap_or(false)) .map_err(|err| { @@ -231,7 +228,7 @@ impl AnvilNames } fn stop_impersonating_account(&self, address: Address) -> RpcResult<()> { - InMemoryNode::::stop_impersonating_account(self, address) + InMemoryNode::stop_impersonating_account(self, address) .map(|_| ()) .map_err(|err| { tracing::error!("failed stopping to impersonate account: {:?}", err); diff --git a/crates/core/src/node/block_producer.rs b/crates/core/src/node/block_producer.rs index f97523f3..e6f9f666 100644 --- a/crates/core/src/node/block_producer.rs +++ b/crates/core/src/node/block_producer.rs @@ -1,24 +1,22 @@ -use crate::fork::ForkSource; use crate::node::pool::{TxBatch, TxPool}; use crate::node::sealer::BlockSealer; use crate::node::InMemoryNode; use crate::system_contracts::SystemContracts; -use std::fmt; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use zksync_multivm::interface::TxExecutionMode; -pub struct BlockProducer { - node: InMemoryNode, +pub struct BlockProducer { + node: InMemoryNode, pool: TxPool, block_sealer: BlockSealer, system_contracts: SystemContracts, } -impl BlockProducer { +impl BlockProducer { pub fn new( - node: InMemoryNode, + node: InMemoryNode, pool: TxPool, block_sealer: BlockSealer, system_contracts: SystemContracts, @@ -32,7 +30,7 @@ impl BlockProducer { } } -impl Future for BlockProducer { +impl Future for BlockProducer { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { diff --git a/crates/core/src/node/config_api.rs b/crates/core/src/node/config_api.rs index c2ac5b2a..cd6a6e16 100644 --- a/crates/core/src/node/config_api.rs +++ b/crates/core/src/node/config_api.rs @@ -1,6 +1,5 @@ use crate::node::time::ReadTime; use crate::{ - fork::ForkSource, namespaces::{ConfigurationApiNamespaceT, Result}, node::InMemoryNode, utils::into_jsrpc_error, @@ -10,9 +9,7 @@ use anvil_zksync_config::types::{ }; use zksync_web3_decl::error::Web3Error; -impl ConfigurationApiNamespaceT - for InMemoryNode -{ +impl ConfigurationApiNamespaceT for InMemoryNode { fn config_get_show_calls(&self) -> Result { self.get_inner() .read() diff --git a/crates/core/src/node/debug.rs b/crates/core/src/node/debug.rs index c2ee6017..05cd6af3 100644 --- a/crates/core/src/node/debug.rs +++ b/crates/core/src/node/debug.rs @@ -17,15 +17,12 @@ use zksync_web3_decl::error::Web3Error; use crate::{ deps::storage_view::StorageView, - fork::ForkSource, namespaces::{DebugNamespaceT, Result, RpcResult}, node::{InMemoryNode, MAX_TX_SIZE}, utils::{create_debug_output, into_jsrpc_error, to_real_block_number}, }; -impl DebugNamespaceT - for InMemoryNode -{ +impl DebugNamespaceT for InMemoryNode { fn trace_block_by_number( &self, block: BlockNumber, @@ -247,12 +244,11 @@ mod tests { use super::*; use crate::{ deps::system_contracts::bytecode_from_slice, - http_fork_source::HttpForkSource, node::{InMemoryNode, TransactionResult}, testing::{self, LogBuilder}, }; - fn deploy_test_contracts(node: &InMemoryNode) -> (Address, Address) { + fn deploy_test_contracts(node: &InMemoryNode) -> (Address, Address) { let private_key = K256PrivateKey::from_bytes(H256::repeat_byte(0xee)).unwrap(); let from_account = private_key.address(); node.set_rich_account(from_account, U256::from(DEFAULT_ACCOUNT_BALANCE)); @@ -291,7 +287,7 @@ mod tests { #[tokio::test] async fn test_trace_deployed_contract() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let (primary_deployed_address, secondary_deployed_address) = deploy_test_contracts(&node); // trace a call to the primary contract @@ -340,7 +336,7 @@ mod tests { #[tokio::test] async fn test_trace_only_top() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let (primary_deployed_address, _) = deploy_test_contracts(&node); @@ -377,7 +373,7 @@ mod tests { #[tokio::test] async fn test_trace_reverts() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let (primary_deployed_address, _) = deploy_test_contracts(&node); @@ -412,7 +408,7 @@ mod tests { #[tokio::test] async fn test_trace_transaction() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); { let mut writer = inner.write().unwrap(); @@ -440,7 +436,7 @@ mod tests { #[tokio::test] async fn test_trace_transaction_only_top() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); { let mut writer = inner.write().unwrap(); @@ -476,7 +472,7 @@ mod tests { #[tokio::test] async fn test_trace_transaction_not_found() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let result = node .trace_transaction(H256::repeat_byte(0x1), None) .await @@ -486,7 +482,7 @@ mod tests { #[tokio::test] async fn test_trace_block_by_hash_empty() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); { let mut writer = inner.write().unwrap(); @@ -502,7 +498,7 @@ mod tests { #[tokio::test] async fn test_trace_block_by_hash() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); { let mut writer = inner.write().unwrap(); @@ -530,7 +526,7 @@ mod tests { #[tokio::test] async fn test_trace_block_by_number() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); { let mut writer = inner.write().unwrap(); diff --git a/crates/core/src/node/eth.rs b/crates/core/src/node/eth.rs index 2b11a643..ad95d3ee 100644 --- a/crates/core/src/node/eth.rs +++ b/crates/core/src/node/eth.rs @@ -27,7 +27,6 @@ use zksync_web3_decl::{ use crate::{ filters::{FilterType, LogFilter}, - fork::ForkSource, namespaces::{EthNamespaceT, EthTestNodeNamespaceT, RpcResult}, node::{InMemoryNode, TransactionResult, MAX_TX_SIZE, PROTOCOL_VERSION}, utils::{ @@ -36,7 +35,7 @@ use crate::{ }, }; -impl InMemoryNode { +impl InMemoryNode { fn call_impl( &self, req: zksync_types::transaction_request::CallRequest, @@ -190,9 +189,7 @@ impl InMemoryNo } } -impl EthNamespaceT - for InMemoryNode -{ +impl EthNamespaceT for InMemoryNode { /// Returns the chain ID of the node. fn chain_id(&self) -> RpcResult { match self.get_inner().read() { @@ -1436,9 +1433,7 @@ impl EthNamespa } } -impl EthTestNodeNamespaceT - for InMemoryNode -{ +impl EthTestNodeNamespaceT for InMemoryNode { /// Sends a transaction to the L2 network. Can be used for the impersonated account. /// /// # Arguments @@ -1463,7 +1458,6 @@ mod tests { use super::*; use crate::{ fork::ForkDetails, - http_fork_source::HttpForkSource, node::{compute_hash, InMemoryNode, Snapshot}, testing::{ self, default_tx_debug_info, ForkBlockConfig, LogBuilder, MockServer, @@ -1487,8 +1481,8 @@ mod tests { use zksync_types::{web3, Nonce}; use zksync_web3_decl::types::{SyncState, ValueOrArray}; - async fn test_node(url: &str) -> InMemoryNode { - InMemoryNode::::default_fork(Some( + async fn test_node(url: &str) -> InMemoryNode { + InMemoryNode::default_fork(Some( ForkDetails::from_network(url, None, &CacheConfig::None) .await .unwrap(), @@ -1497,14 +1491,14 @@ mod tests { #[tokio::test] async fn test_eth_syncing() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let syncing = node.syncing().await.expect("failed syncing"); assert!(matches!(syncing, SyncState::NotSyncing)); } #[tokio::test] async fn test_get_fee_history_with_1_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let fee_history = node .fee_history(U64::from(1), BlockNumber::Latest, vec![25.0, 50.0, 75.0]) @@ -1525,7 +1519,7 @@ mod tests { #[tokio::test] async fn test_get_fee_history_with_no_reward_percentiles() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let fee_history = node .fee_history(U64::from(1), BlockNumber::Latest, vec![]) @@ -1547,7 +1541,7 @@ mod tests { #[tokio::test] async fn test_get_fee_history_with_multiple_blocks() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); testing::apply_tx(&node, H256::repeat_byte(0x01)); // Act @@ -1577,7 +1571,7 @@ mod tests { #[tokio::test] async fn test_get_block_by_hash_returns_none_for_non_existing_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let result = node .get_block_by_hash(H256::repeat_byte(0x01), false) @@ -1589,7 +1583,7 @@ mod tests { #[tokio::test] async fn test_node_has_genesis_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let block = node .get_block_by_number(BlockNumber::Latest, false) @@ -1603,7 +1597,7 @@ mod tests { #[tokio::test] async fn test_node_creates_genesis_block_with_hash_and_zero_parent_hash() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let block = node .get_block_by_hash(compute_hash(0, []), false) @@ -1616,7 +1610,7 @@ mod tests { #[tokio::test] async fn test_node_produces_blocks_with_parent_hash_links() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); testing::apply_tx(&node, H256::repeat_byte(0x01)); let genesis_block = node @@ -1641,7 +1635,7 @@ mod tests { #[tokio::test] async fn test_get_block_by_hash_for_produced_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let tx_hash = H256::repeat_byte(0x01); let (expected_block_hash, _, _) = testing::apply_tx(&node, tx_hash); let genesis_block = node @@ -1757,7 +1751,7 @@ mod tests { #[tokio::test] async fn test_get_block_by_number_returns_none_for_non_existing_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let result = node .get_block_by_number(BlockNumber::Number(U64::from(42)), false) @@ -1769,7 +1763,7 @@ mod tests { #[tokio::test] async fn test_get_block_by_number_for_produced_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let tx_hash = H256::repeat_byte(0x01); let (expected_block_hash, _, _) = testing::apply_tx(&node, tx_hash); let expected_block_number = 1; @@ -1823,7 +1817,7 @@ mod tests { #[tokio::test] async fn test_get_block_by_number_for_produced_block_full_txs() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let tx_hash = H256::repeat_byte(0x01); let (block_hash, _, tx) = testing::apply_tx(&node, tx_hash); let expected_block_number = 1; @@ -1903,7 +1897,7 @@ mod tests { #[tokio::test] async fn test_get_block_by_number_for_latest_block_produced_locally() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); testing::apply_tx(&node, H256::repeat_byte(0x01)); // The latest block, will be the 'virtual' one with 0 transactions (block 2). @@ -2008,7 +2002,7 @@ mod tests { #[tokio::test] async fn test_get_block_transaction_count_by_hash_for_produced_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let (expected_block_hash, _, _) = testing::apply_tx(&node, H256::repeat_byte(0x01)); let actual_transaction_count = node @@ -2060,7 +2054,7 @@ mod tests { #[tokio::test] async fn test_get_block_transaction_count_by_number_for_produced_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); testing::apply_tx(&node, H256::repeat_byte(0x01)); let actual_transaction_count = node @@ -2183,7 +2177,7 @@ mod tests { #[tokio::test] async fn test_get_transaction_receipt_uses_produced_block_hash() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let tx_hash = H256::repeat_byte(0x01); let (expected_block_hash, _, _) = testing::apply_tx(&node, tx_hash); @@ -2198,7 +2192,7 @@ mod tests { #[tokio::test] async fn test_new_block_filter_returns_filter_id() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let actual_filter_id = node .new_block_filter() @@ -2210,7 +2204,7 @@ mod tests { #[tokio::test] async fn test_new_filter_returns_filter_id() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let actual_filter_id = node .new_filter(Filter::default()) @@ -2222,7 +2216,7 @@ mod tests { #[tokio::test] async fn test_new_pending_transaction_filter_returns_filter_id() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let actual_filter_id = node .new_pending_transaction_filter() @@ -2234,7 +2228,7 @@ mod tests { #[tokio::test] async fn test_uninstall_filter_returns_true_if_filter_exists() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let filter_id = node .new_block_filter() .await @@ -2250,7 +2244,7 @@ mod tests { #[tokio::test] async fn test_uninstall_filter_returns_false_if_filter_does_not_exist() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let actual_result = node .uninstall_filter(U256::from(100)) @@ -2262,7 +2256,7 @@ mod tests { #[tokio::test] async fn test_get_filter_changes_returns_block_hash_updates_only_once() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let filter_id = node .new_block_filter() .await @@ -2294,7 +2288,7 @@ mod tests { #[tokio::test] async fn test_get_filter_changes_returns_log_updates_only_once() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let filter_id = node .new_filter(Filter { from_block: None, @@ -2328,7 +2322,7 @@ mod tests { #[tokio::test] async fn test_get_filter_changes_returns_pending_transaction_updates_only_once() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let filter_id = node .new_pending_transaction_filter() .await @@ -2356,7 +2350,7 @@ mod tests { #[tokio::test] async fn test_produced_block_archives_previous_blocks() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let input_storage_key = StorageKey::new( AccountTreeId::new(H160::repeat_byte(0x1)), @@ -2399,7 +2393,7 @@ mod tests { #[tokio::test] async fn test_get_storage_fetches_zero_value_for_non_existent_key() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let value = node .get_storage(H160::repeat_byte(0xf1), U256::from(1024), None) @@ -2461,7 +2455,7 @@ mod tests { ); let input_storage_value = H256::repeat_byte(0xcd); - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); node.get_inner() .write() .map(|mut writer| { @@ -2562,7 +2556,7 @@ mod tests { #[tokio::test] async fn test_get_storage_fetches_state_for_deployed_smart_contract_in_current_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let private_key = K256PrivateKey::from_bytes(H256::repeat_byte(0xef)).unwrap(); let from_account = private_key.address(); @@ -2594,7 +2588,7 @@ mod tests { #[tokio::test] async fn test_get_storage_fetches_state_for_deployed_smart_contract_in_old_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let private_key = K256PrivateKey::from_bytes(H256::repeat_byte(0xef)).unwrap(); let from_account = private_key.address(); @@ -2651,7 +2645,7 @@ mod tests { #[tokio::test] async fn test_get_filter_logs_returns_matching_logs_for_valid_id() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); // populate tx receipts with 2 tx each having logs { @@ -2710,7 +2704,7 @@ mod tests { #[tokio::test] async fn test_get_filter_logs_returns_error_for_invalid_id() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); // populate tx receipts with 2 tx each having logs { @@ -2739,7 +2733,7 @@ mod tests { #[tokio::test] async fn test_get_logs_returns_matching_logs() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); // populate tx receipts with 2 tx each having logs { @@ -2808,7 +2802,7 @@ mod tests { #[tokio::test] async fn test_accounts() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let private_key = H256::repeat_byte(0x01); let from_account = K256PrivateKey::from_bytes(private_key).unwrap().address(); @@ -2829,7 +2823,7 @@ mod tests { #[tokio::test] async fn test_snapshot() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); let mut inner = inner.write().unwrap(); @@ -2930,7 +2924,7 @@ mod tests { #[tokio::test] async fn test_snapshot_restore() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); let mut inner = inner.write().unwrap(); @@ -3056,7 +3050,7 @@ mod tests { #[tokio::test] async fn test_get_transaction_by_block_hash_and_index_returns_none_for_invalid_block_hash() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let input_tx_hash = H256::repeat_byte(0x01); let (input_block_hash, _, _) = testing::apply_tx(&node, input_tx_hash); let invalid_block_hash = H256::repeat_byte(0xab); @@ -3072,7 +3066,7 @@ mod tests { #[tokio::test] async fn test_get_transaction_by_block_hash_and_index_returns_none_for_invalid_index() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let input_tx_hash = H256::repeat_byte(0x01); let (input_block_hash, _, _) = testing::apply_tx(&node, input_tx_hash); @@ -3086,7 +3080,7 @@ mod tests { #[tokio::test] async fn test_get_transaction_by_block_hash_and_index_returns_transaction_for_valid_input() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let input_tx_hash = H256::repeat_byte(0x01); let (input_block_hash, _, _) = testing::apply_tx(&node, input_tx_hash); @@ -3191,7 +3185,7 @@ mod tests { #[tokio::test] async fn test_get_transaction_by_block_number_and_index_returns_none_for_invalid_block_number() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let input_tx_hash = H256::repeat_byte(0x01); let (input_block_hash, _, _) = testing::apply_tx(&node, input_tx_hash); let invalid_block_hash = H256::repeat_byte(0xab); @@ -3210,7 +3204,7 @@ mod tests { #[tokio::test] async fn test_get_transaction_by_block_number_and_index_returns_none_for_invalid_index() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let input_tx_hash = H256::repeat_byte(0x01); testing::apply_tx(&node, input_tx_hash); @@ -3224,7 +3218,7 @@ mod tests { #[tokio::test] async fn test_get_transaction_by_block_number_and_index_returns_transaction_for_valid_input() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let input_tx_hash = H256::repeat_byte(0x01); let (_, input_block_number, _) = testing::apply_tx(&node, input_tx_hash); @@ -3342,7 +3336,7 @@ mod tests { #[tokio::test] async fn test_protocol_version_returns_currently_supported_version() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let expected_version = String::from(PROTOCOL_VERSION); let actual_version = node diff --git a/crates/core/src/node/evm.rs b/crates/core/src/node/evm.rs index e34ba3d5..3b8d9e75 100644 --- a/crates/core/src/node/evm.rs +++ b/crates/core/src/node/evm.rs @@ -3,15 +3,12 @@ use zksync_web3_decl::error::Web3Error; use crate::utils::Numeric; use crate::{ - fork::ForkSource, namespaces::{EvmNamespaceT, RpcResult}, node::InMemoryNode, utils::{into_jsrpc_error, IntoBoxedFuture}, }; -impl EvmNamespaceT - for InMemoryNode -{ +impl EvmNamespaceT for InMemoryNode { fn increase_time(&self, time_delta_seconds: Numeric) -> RpcResult { self.increase_time(time_delta_seconds) .map_err(|err| { diff --git a/crates/core/src/node/hardhat.rs b/crates/core/src/node/hardhat.rs index 43e9c040..ef502820 100644 --- a/crates/core/src/node/hardhat.rs +++ b/crates/core/src/node/hardhat.rs @@ -2,15 +2,12 @@ use zksync_types::{Address, U256, U64}; use zksync_web3_decl::error::Web3Error; use crate::{ - fork::ForkSource, namespaces::{HardhatNamespaceT, ResetRequest, RpcResult}, node::InMemoryNode, utils::{into_jsrpc_error, into_jsrpc_error_message, IntoBoxedFuture}, }; -impl HardhatNamespaceT - for InMemoryNode -{ +impl HardhatNamespaceT for InMemoryNode { fn set_balance(&self, address: Address, balance: U256) -> RpcResult { self.set_balance(address, balance) .map_err(|err| { @@ -66,7 +63,7 @@ impl HardhatNam } fn stop_impersonating_account(&self, address: Address) -> RpcResult { - InMemoryNode::::stop_impersonating_account(self, address) + InMemoryNode::stop_impersonating_account(self, address) .map_err(|err| { tracing::error!("failed stopping to impersonate account: {:?}", err); into_jsrpc_error(Web3Error::InternalError(err)) diff --git a/crates/core/src/node/in_memory.rs b/crates/core/src/node/in_memory.rs index 422dee58..19e11a16 100644 --- a/crates/core/src/node/in_memory.rs +++ b/crates/core/src/node/in_memory.rs @@ -10,7 +10,7 @@ use crate::{ console_log::ConsoleLogHandler, deps::{storage_view::StorageView, InMemoryStorage}, filters::EthFilters, - fork::{ForkDetails, ForkSource, ForkStorage}, + fork::{ForkDetails, ForkStorage}, formatter, node::{ call_error_tracer::CallErrorTracer, fee_model::TestNodeFeeInputProvider, @@ -237,8 +237,7 @@ impl TransactionResult { /// Helper struct for InMemoryNode. /// S - is the Source of the Fork. -#[derive(Clone)] -pub struct InMemoryNodeInner { +pub struct InMemoryNodeInner { /// The latest batch number that was already generated. /// Next block will be current_batch + 1 pub current_batch: u32, @@ -258,7 +257,7 @@ pub struct InMemoryNodeInner { // Map from filter_id to the eth filter pub filters: EthFilters, // Underlying storage - pub fork_storage: ForkStorage, + pub fork_storage: ForkStorage, // Configuration. pub config: TestNodeConfig, pub console_log_handler: ConsoleLogHandler, @@ -276,7 +275,7 @@ pub struct TxExecutionOutput { bytecodes: HashMap>, } -impl InMemoryNodeInner { +impl InMemoryNodeInner { /// Create the state to be used implementing [InMemoryNode]. pub fn new( fork: Option, @@ -759,7 +758,7 @@ impl InMemoryNodeInner { tx_gas_limit: u64, batch_env: L1BatchEnv, system_env: SystemEnv, - fork_storage: &ForkStorage, + fork_storage: &ForkStorage, ) -> VmExecutionResultAndLogs { let tx: Transaction = l2_tx.clone().into(); @@ -1080,9 +1079,9 @@ pub struct Snapshot { /// It also supports the option of forking testnet/mainnet. /// All contents are removed when object is destroyed. #[derive(Clone)] -pub struct InMemoryNode { +pub struct InMemoryNode { /// A thread safe reference to the [InMemoryNodeInner]. - pub(crate) inner: Arc>>, + pub(crate) inner: Arc>, /// List of snapshots of the [InMemoryNodeInner]. This is bounded at runtime by [MAX_SNAPSHOTS]. pub(crate) snapshots: Arc>>, /// Configuration option that survives reset. @@ -1106,7 +1105,7 @@ fn contract_address_from_tx_result(execution_result: &VmExecutionResultAndLogs) None } -impl Default for InMemoryNode { +impl Default for InMemoryNode { fn default() -> Self { let impersonation = ImpersonationManager::default(); let pool = TxPool::new(impersonation.clone()); @@ -1123,7 +1122,7 @@ impl Default for InMemoryNode { } } -impl InMemoryNode { +impl InMemoryNode { pub fn new( fork: Option, observability: Option, @@ -1175,17 +1174,17 @@ impl InMemoryNode { ) } - pub fn get_inner(&self) -> Arc>> { + pub fn get_inner(&self) -> Arc> { self.inner.clone() } - pub fn read_inner(&self) -> anyhow::Result>> { + pub fn read_inner(&self) -> anyhow::Result> { self.inner .read() .map_err(|e| anyhow::anyhow!("InMemoryNode lock is poisoned: {}", e)) } - pub fn write_inner(&self) -> anyhow::Result>> { + pub fn write_inner(&self) -> anyhow::Result> { self.inner .write() .map_err(|e| anyhow::anyhow!("InMemoryNode lock is poisoned: {}", e)) @@ -2036,19 +2035,18 @@ mod tests { use anvil_zksync_config::types::SystemContractsOptions; use anvil_zksync_config::TestNodeConfig; use ethabi::{Token, Uint}; - use std::fmt::Debug; use zksync_types::{utils::deployed_address_create, K256PrivateKey, Nonce}; use super::*; - use crate::{http_fork_source::HttpForkSource, node::InMemoryNode, testing}; + use crate::{node::InMemoryNode, testing}; - fn test_vm( - node: &InMemoryNode, + fn test_vm( + node: &InMemoryNode, system_contracts: BaseSystemContracts, ) -> ( BlockContext, L1BatchEnv, - Vm>, HistoryDisabled>, + Vm, HistoryDisabled>, ) { let inner = node.inner.read().unwrap(); let storage = StorageView::new(inner.fork_storage.clone()).into_rc_ptr(); @@ -2061,7 +2059,7 @@ mod tests { #[tokio::test] async fn test_run_l2_tx_validates_tx_gas_limit_too_high() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let tx = testing::TransactionBuilder::new() .set_gas_limit(U256::from(u64::MAX) + 1) .build(); @@ -2082,7 +2080,7 @@ mod tests { #[tokio::test] async fn test_run_l2_tx_validates_tx_max_fee_per_gas_too_low() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let tx = testing::TransactionBuilder::new() .set_max_fee_per_gas(U256::from(DEFAULT_L2_GAS_PRICE - 1)) .build(); @@ -2107,7 +2105,7 @@ mod tests { #[tokio::test] async fn test_run_l2_tx_validates_tx_max_priority_fee_per_gas_higher_than_max_fee_per_gas() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let tx = testing::TransactionBuilder::new() .set_max_priority_fee_per_gas(U256::from(250_000_000 + 1)) .build(); @@ -2141,7 +2139,7 @@ mod tests { #[tokio::test] async fn test_run_l2_tx_raw_does_not_panic_on_external_storage_call() { // Perform a transaction to get storage to an intermediate state - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let tx = testing::TransactionBuilder::new().build(); node.set_rich_account( tx.common_data.initiator_address, @@ -2161,7 +2159,7 @@ mod tests { let impersonation = ImpersonationManager::default(); let pool = TxPool::new(impersonation.clone()); let sealer = BlockSealer::new(BlockSealerMode::immediate(1000, pool.add_tx_listener())); - let node: InMemoryNode = InMemoryNode::new( + let node = InMemoryNode::new( Some(ForkDetails { fork_source: Box::new(mock_db), chain_id: TEST_NODE_NETWORK_ID.into(), @@ -2201,7 +2199,7 @@ mod tests { let impersonation = ImpersonationManager::default(); let pool = TxPool::new(impersonation.clone()); let sealer = BlockSealer::new(BlockSealerMode::immediate(1000, pool.add_tx_listener())); - let node = InMemoryNode::::new( + let node = InMemoryNode::new( None, None, &TestNodeConfig { diff --git a/crates/core/src/node/in_memory_ext.rs b/crates/core/src/node/in_memory_ext.rs index 376f731c..a80984e3 100644 --- a/crates/core/src/node/in_memory_ext.rs +++ b/crates/core/src/node/in_memory_ext.rs @@ -3,10 +3,7 @@ use crate::node::pool::TxBatch; use crate::node::sealer::BlockSealerMode; use crate::utils::Numeric; use crate::{ - fork::{ForkDetails, ForkSource}, - namespaces::ResetRequest, - node::InMemoryNode, - utils::bytecode_to_factory_dep, + fork::ForkDetails, namespaces::ResetRequest, node::InMemoryNode, utils::bytecode_to_factory_dep, }; use anyhow::{anyhow, Context}; use std::convert::TryInto; @@ -27,7 +24,7 @@ type Result = anyhow::Result; /// and can be used to revert the node to an earlier point in time. const MAX_SNAPSHOTS: u8 = 100; -impl InMemoryNode { +impl InMemoryNode { /// Increase the current timestamp for the node /// /// # Parameters @@ -500,8 +497,8 @@ mod tests { use crate::fork::ForkStorage; use crate::namespaces::EthNamespaceT; use crate::node::time::{ReadTime, TimestampManager}; + use crate::node::InMemoryNode; use crate::node::{BlockSealer, ImpersonationManager, InMemoryNodeInner, Snapshot, TxPool}; - use crate::{http_fork_source::HttpForkSource, node::InMemoryNode}; use std::str::FromStr; use std::sync::{Arc, RwLock}; use zksync_multivm::interface::storage::ReadStorage; @@ -512,7 +509,7 @@ mod tests { #[tokio::test] async fn test_set_balance() { let address = Address::from_str("0x36615Cf349d7F6344891B1e7CA7C72883F5dc049").unwrap(); - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let balance_before = node.get_balance(address, None).await.unwrap(); @@ -527,7 +524,7 @@ mod tests { #[tokio::test] async fn test_set_nonce() { let address = Address::from_str("0x36615Cf349d7F6344891B1e7CA7C72883F5dc049").unwrap(); - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let nonce_before = node.get_transaction_count(address, None).await.unwrap(); @@ -547,7 +544,7 @@ mod tests { #[tokio::test] async fn test_mine_blocks_default() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let start_block = node .get_block_by_number(zksync_types::api::BlockNumber::Latest, false) @@ -580,7 +577,7 @@ mod tests { #[tokio::test] async fn test_mine_blocks() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let start_block = node .get_block_by_number(zksync_types::api::BlockNumber::Latest, false) @@ -612,7 +609,7 @@ mod tests { let old_system_contracts_options = Default::default(); let time = TimestampManager::new(123); let impersonation = ImpersonationManager::default(); - let old_inner = InMemoryNodeInner:: { + let old_inner = InMemoryNodeInner { current_batch: 100, current_miniblock: 300, current_miniblock_hash: H256::random(), @@ -632,7 +629,7 @@ mod tests { let pool = TxPool::new(impersonation.clone()); let sealer = BlockSealer::new(BlockSealerMode::immediate(1000, pool.add_tx_listener())); - let node = InMemoryNode:: { + let node = InMemoryNode { inner: Arc::new(RwLock::new(old_inner)), snapshots: old_snapshots, system_contracts_options: old_system_contracts_options, @@ -667,7 +664,7 @@ mod tests { #[tokio::test] async fn test_impersonate_account() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let to_impersonate = Address::from_str("0xd8da6bf26964af9d7eed9e03e53415d37aa96045").unwrap(); @@ -737,7 +734,7 @@ mod tests { #[tokio::test] async fn test_set_code() { let address = Address::repeat_byte(0x1); - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let new_code = vec![0x1u8; 32]; let code_before = node @@ -760,7 +757,7 @@ mod tests { #[tokio::test] async fn test_set_storage_at() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let address = Address::repeat_byte(0x1); let slot = U256::from(37); let value = U256::from(42); @@ -780,7 +777,7 @@ mod tests { #[tokio::test] async fn test_increase_time_zero_value() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let increase_value_seconds = 0u64; let timestamp_before = node.time.current_timestamp(); @@ -801,7 +798,7 @@ mod tests { #[tokio::test] async fn test_increase_time_max_value() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let increase_value_seconds = u64::MAX; let timestamp_before = node.time.current_timestamp(); @@ -823,7 +820,7 @@ mod tests { #[tokio::test] async fn test_increase_time() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let increase_value_seconds = 100u64; let timestamp_before = node.time.current_timestamp(); @@ -844,7 +841,7 @@ mod tests { #[tokio::test] async fn test_set_next_block_timestamp_future() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let new_timestamp = 10_000u64; let timestamp_before = node.time.current_timestamp(); @@ -866,7 +863,7 @@ mod tests { #[tokio::test] async fn test_set_next_block_timestamp_past_fails() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let timestamp_before = node.time.current_timestamp(); @@ -883,7 +880,7 @@ mod tests { #[tokio::test] async fn test_set_next_block_timestamp_same_value() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let new_timestamp = 1000u64; let timestamp_before = node.time.current_timestamp(); @@ -901,7 +898,7 @@ mod tests { #[tokio::test] async fn test_set_time_future() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let new_time = 10_000u64; let timestamp_before = node.time.current_timestamp(); @@ -919,7 +916,7 @@ mod tests { #[tokio::test] async fn test_set_time_past() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let new_time = 10u64; let timestamp_before = node.time.current_timestamp(); @@ -937,7 +934,7 @@ mod tests { #[tokio::test] async fn test_set_time_same_value() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let new_time = 1000u64; let timestamp_before = node.time.current_timestamp(); @@ -958,7 +955,7 @@ mod tests { #[tokio::test] async fn test_set_time_edges() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); for new_time in [0, u64::MAX] { let timestamp_before = node.time.current_timestamp(); @@ -986,7 +983,7 @@ mod tests { #[tokio::test] async fn test_mine_block() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let start_block = node .get_block_by_number(zksync_types::api::BlockNumber::Latest, false) @@ -1020,7 +1017,7 @@ mod tests { #[tokio::test] async fn test_evm_snapshot_creates_incrementing_ids() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let snapshot_id_1 = node.snapshot().expect("failed creating snapshot 1"); let snapshot_id_2 = node.snapshot().expect("failed creating snapshot 2"); @@ -1031,7 +1028,7 @@ mod tests { #[tokio::test] async fn test_evm_revert_snapshot_restores_state() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let initial_block = node .get_block_number() @@ -1059,7 +1056,7 @@ mod tests { #[tokio::test] async fn test_evm_revert_snapshot_removes_all_snapshots_following_the_reverted_one() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let _snapshot_id_1 = node.snapshot().expect("failed creating snapshot"); let snapshot_id_2 = node.snapshot().expect("failed creating snapshot"); @@ -1076,7 +1073,7 @@ mod tests { #[tokio::test] async fn test_evm_revert_snapshot_fails_for_invalid_snapshot_id() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let result = node.revert_snapshot(U64::from(100)); assert!(result.is_err()); @@ -1084,7 +1081,7 @@ mod tests { #[tokio::test] async fn test_node_set_chain_id() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let new_chain_id = 261; let _ = node.set_chain_id(new_chain_id); diff --git a/crates/core/src/node/net.rs b/crates/core/src/node/net.rs index ea7b7a03..f52fb46c 100644 --- a/crates/core/src/node/net.rs +++ b/crates/core/src/node/net.rs @@ -1,14 +1,11 @@ use crate::{ - fork::ForkSource, namespaces::{NetNamespaceT, Result}, node::InMemoryNode, }; use anvil_zksync_config::constants::TEST_NODE_NETWORK_ID; use zksync_types::U256; -impl NetNamespaceT - for InMemoryNode -{ +impl NetNamespaceT for InMemoryNode { fn net_version(&self) -> Result { let chain_id = self .get_inner() diff --git a/crates/core/src/node/web3.rs b/crates/core/src/node/web3.rs index 1b7402d5..d54bbc9c 100644 --- a/crates/core/src/node/web3.rs +++ b/crates/core/src/node/web3.rs @@ -1,12 +1,9 @@ use crate::{ - fork::ForkSource, namespaces::{Result, Web3NamespaceT}, node::InMemoryNode, }; -impl Web3NamespaceT - for InMemoryNode -{ +impl Web3NamespaceT for InMemoryNode { fn web3_client_version(&self) -> Result { Ok("zkSync/v2.0".to_string()) } diff --git a/crates/core/src/node/zks.rs b/crates/core/src/node/zks.rs index 281cf1d2..ef132eab 100644 --- a/crates/core/src/node/zks.rs +++ b/crates/core/src/node/zks.rs @@ -17,7 +17,6 @@ use zksync_utils::h256_to_u256; use zksync_web3_decl::error::Web3Error; use crate::{ - fork::ForkSource, namespaces::{RpcResult, ZksNamespaceT}, node::{InMemoryNode, TransactionResult}, utils::{ @@ -26,9 +25,7 @@ use crate::{ }, }; -impl ZksNamespaceT - for InMemoryNode -{ +impl ZksNamespaceT for InMemoryNode { /// Estimates the gas fee data required for a given call request. /// /// # Arguments @@ -588,7 +585,6 @@ mod tests { use super::*; use crate::{ fork::ForkDetails, - http_fork_source::HttpForkSource, node::InMemoryNode, testing, testing::{ForkBlockConfig, MockServer}, @@ -596,7 +592,7 @@ mod tests { #[tokio::test] async fn test_estimate_fee() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let mock_request = CallRequest { from: Some( @@ -633,7 +629,7 @@ mod tests { #[tokio::test] async fn test_get_token_price_given_eth_should_return_price() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let mock_address = Address::from_str("0x0000000000000000000000000000000000000000") .expect("Failed to parse address"); @@ -648,7 +644,7 @@ mod tests { #[tokio::test] async fn test_get_token_price_given_capitalized_link_address_should_return_price() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let mock_address = Address::from_str("0x40609141Db628BeEE3BfAB8034Fc2D8278D0Cc78") .expect("Failed to parse address"); @@ -663,7 +659,7 @@ mod tests { #[tokio::test] async fn test_get_token_price_given_unknown_address_should_return_error() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let mock_address = Address::from_str("0x0000000000000000000000000000000000000042") .expect("Failed to parse address"); @@ -678,7 +674,7 @@ mod tests { #[tokio::test] async fn test_get_transaction_details_local() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); { let mut writer = inner.write().unwrap(); @@ -741,7 +737,7 @@ mod tests { }), ); - let node = InMemoryNode::::default_fork(Some( + let node = InMemoryNode::default_fork(Some( ForkDetails::from_network(&mock_server.url(), None, &CacheConfig::None) .await .unwrap(), @@ -760,7 +756,7 @@ mod tests { #[tokio::test] async fn test_get_block_details_local() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); { let mut writer = inner.write().unwrap(); @@ -827,7 +823,7 @@ mod tests { }), ); - let node = InMemoryNode::::default_fork(Some( + let node = InMemoryNode::default_fork(Some( ForkDetails::from_network(&mock_server.url(), None, &CacheConfig::None) .await .unwrap(), @@ -848,7 +844,7 @@ mod tests { #[tokio::test] async fn test_get_bridge_contracts_uses_default_values_if_local() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let expected_bridge_addresses = BridgeAddresses { l1_shared_default_bridge: Default::default(), l2_shared_default_bridge: Default::default(), @@ -905,7 +901,7 @@ mod tests { }), ); - let node = InMemoryNode::::default_fork(Some( + let node = InMemoryNode::default_fork(Some( ForkDetails::from_network(&mock_server.url(), None, &CacheConfig::None) .await .unwrap(), @@ -923,7 +919,7 @@ mod tests { #[tokio::test] async fn test_get_bytecode_by_hash_returns_local_value_if_available() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let input_hash = H256::repeat_byte(0x1); let input_bytecode = vec![0x1]; node.get_inner() @@ -968,7 +964,7 @@ mod tests { }), ); - let node = InMemoryNode::::default_fork(Some( + let node = InMemoryNode::default_fork(Some( ForkDetails::from_network(&mock_server.url(), None, &CacheConfig::None) .await .unwrap(), @@ -987,7 +983,7 @@ mod tests { #[tokio::test] async fn test_get_raw_block_transactions_local() { // Arrange - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let inner = node.get_inner(); { let mut writer = inner.write().unwrap(); @@ -1089,7 +1085,7 @@ mod tests { }), ); - let node = InMemoryNode::::default_fork(Some( + let node = InMemoryNode::default_fork(Some( ForkDetails::from_network(&mock_server.url(), None, &CacheConfig::None) .await .unwrap(), @@ -1104,7 +1100,7 @@ mod tests { #[tokio::test] async fn test_get_all_account_balances_empty() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let balances = node .get_all_account_balances(Address::zero()) .await @@ -1114,7 +1110,7 @@ mod tests { #[tokio::test] async fn test_get_confirmed_tokens_eth() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let balances = node .get_confirmed_tokens(0, 100) .await @@ -1125,7 +1121,7 @@ mod tests { #[tokio::test] async fn test_get_l1_chain_id() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let chain_id = node.l1_chain_id().await.expect("get chain id").as_u32(); assert_eq!(TEST_NODE_NETWORK_ID, chain_id); } @@ -1268,7 +1264,7 @@ mod tests { }), ); - let node = InMemoryNode::::default_fork(Some( + let node = InMemoryNode::default_fork(Some( ForkDetails::from_network(&mock_server.url(), Some(1), &CacheConfig::None) .await .unwrap(), @@ -1296,7 +1292,7 @@ mod tests { #[tokio::test] async fn test_get_base_token_l1_address() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let token_address = node .get_base_token_l1_address() .await diff --git a/crates/core/src/testing.rs b/crates/core/src/testing.rs index 55aeec3d..d4cdced5 100644 --- a/crates/core/src/testing.rs +++ b/crates/core/src/testing.rs @@ -473,10 +473,7 @@ impl TransactionBuilder { } /// Applies a transaction with a given hash to the node and returns the block hash. -pub fn apply_tx( - node: &InMemoryNode, - tx_hash: H256, -) -> (H256, U64, L2Tx) { +pub fn apply_tx(node: &InMemoryNode, tx_hash: H256) -> (H256, U64, L2Tx) { let next_miniblock = node .get_inner() .read() @@ -497,8 +494,8 @@ pub fn apply_tx( } /// Deploys a contract with the given bytecode. -pub fn deploy_contract( - node: &InMemoryNode, +pub fn deploy_contract( + node: &InMemoryNode, tx_hash: H256, private_key: &K256PrivateKey, bytecode: Vec, @@ -888,7 +885,6 @@ mod test { use zksync_utils::h256_to_u256; use super::*; - use crate::http_fork_source::HttpForkSource; #[test] fn test_block_response_builder_set_hash() { @@ -976,7 +972,7 @@ mod test { #[tokio::test] async fn test_apply_tx() { - let node = InMemoryNode::::default(); + let node = InMemoryNode::default(); let (actual_block_hash, actual_block_number, _) = apply_tx(&node, H256::repeat_byte(0x01)); assert_eq!(