pub struct InMemoryNode<S: Clone> { /* private fields */ }
Expand description

In-memory node, that can be used for local & unit testing. It also supports the option of forking testnet/mainnet. All contents are removed when object is destroyed.

Implementations§

source§

impl<S: ForkSource + Debug + Clone> InMemoryNode<S>

source

pub fn new( fork: Option<ForkDetails>, observability: Option<Observability>, config: InMemoryNodeConfig, gas_overrides: Option<GasConfig> ) -> Self

source

pub fn get_inner(&self) -> Arc<RwLock<InMemoryNodeInner<S>>>

source

pub fn get_cache_config(&self) -> Result<CacheConfig, String>

source

pub fn get_fork_url(&self) -> Result<String, String>

source

pub fn reset(&self, fork: Option<ForkDetails>) -> Result<(), String>

source

pub fn apply_txs(&self, txs: Vec<L2Tx>) -> Result<(), String>

Applies multiple transactions - but still one per L1 batch.

source

pub fn set_rich_account(&self, address: H160)

Adds a lot of tokens to a given account.

source

pub fn run_l2_call(&self, l2_tx: L2Tx) -> Result<ExecutionResult, String>

Runs L2 ‘eth call’ method - that doesn’t commit to a block.

source

pub fn run_l2_tx_raw( &self, l2_tx: L2Tx, execution_mode: TxExecutionMode, tracers: Vec<TracerPointer<StorageView<ForkStorage<S>>, HistoryDisabled>>, execute_bootloader: bool ) -> Result<(HashMap<StorageKey, H256>, VmExecutionResultAndLogs, Vec<Call>, Block<TransactionVariant>, HashMap<U256, Vec<U256>>, BlockContext), String>

Executes the given L2 transaction and returns all the VM logs. The bootloader can be omitted via specifying the execute_bootloader boolean. This causes the VM to produce 1 L2 block per L1 block, instead of the usual 2 blocks per L1 block.

NOTE

This function must only rely on data populated initially via ForkDetails: * InMemoryNodeInner::current_timestamp * InMemoryNodeInner::current_batch * InMemoryNodeInner::current_miniblock * InMemoryNodeInner::current_miniblock_hash * InMemoryNodeInner::fee_input_provider

And must NEVER rely on data updated in InMemoryNodeInner during previous runs: (if used, they must never panic and/or have meaningful defaults) * InMemoryNodeInner::block_hashes * InMemoryNodeInner::blocks * InMemoryNodeInner::tx_results

This is because external users of the library may call this function to perform an isolated VM operation (optionally without bootloader execution) with an external storage and get the results back. So any data populated in Self::run_l2_tx will not be available for the next invocation.

source

pub fn run_l2_tx( &self, l2_tx: L2Tx, execution_mode: TxExecutionMode ) -> Result<(), String>

Runs L2 transaction and commits it to a new block.

source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> InMemoryNode<S>

source

pub fn increase_time(&self, time_delta_seconds: u64) -> Result<u64>

Increase the current timestamp for the node

Parameters
  • time_delta: The number of seconds to increase time by
Returns

The applied time delta to current_timestamp value for the InMemoryNodeInner.

source

pub fn set_next_block_timestamp(&self, timestamp: u64) -> Result<u64>

Set the current timestamp for the node. The timestamp must be in future.

Parameters
  • timestamp: The timestamp to set the time to
Returns

The new timestamp value for the InMemoryNodeInner.

source

pub fn set_time(&self, time: u64) -> Result<i128>

Set the current timestamp for the node. Warning: This will allow you to move backwards in time, which may cause new blocks to appear to be mined before old blocks. This will result in an invalid state.

Parameters
  • time: The timestamp to set the time to
Returns

The difference between the current_timestamp and the new timestamp for the InMemoryNodeInner.

source

pub fn mine_block(&self) -> Result<String>

Force a single block to be mined.

Will mine an empty block (containing zero transactions)

Returns

The string “0x0”.

source

pub fn snapshot(&self) -> Result<U64>

Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created. A snapshot can only be reverted once. After a successful evm_revert, the same snapshot id cannot be used again. Consider creating a new snapshot after each evm_revert if you need to revert to the same point multiple times.

Returns

The U64 identifier for this snapshot.

source

pub fn revert_snapshot(&self, snapshot_id: U64) -> Result<bool>

Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. This deletes the given snapshot, as well as any snapshots taken after (e.g.: reverting to id 0x1 will delete snapshots with ids 0x1, 0x2, etc.)

Parameters
  • snapshot_id: The snapshot id to revert.
Returns

true if a snapshot was reverted, otherwise false.

source

pub fn set_balance(&self, address: Address, balance: U256) -> Result<bool>

source

pub fn set_nonce(&self, address: Address, nonce: U256) -> Result<bool>

source

pub fn mine_blocks( &self, num_blocks: Option<U64>, interval: Option<U64> ) -> Result<bool>

source

pub fn reset_network(&self, reset_spec: Option<ResetRequest>) -> Result<bool>

source

pub fn impersonate_account(&self, address: Address) -> Result<bool>

source

pub fn stop_impersonating_account(&self, address: Address) -> Result<bool>

source

pub fn set_code(&self, address: Address, code: Vec<u8>) -> Result<()>

source

pub fn set_storage_at( &self, address: Address, slot: U256, value: U256 ) -> Result<bool>

Trait Implementations§

source§

impl<S: Clone + Clone> Clone for InMemoryNode<S>

source§

fn clone(&self) -> InMemoryNode<S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> ConfigurationApiNamespaceT for InMemoryNode<S>

source§

fn config_get_show_calls(&self) -> Result<String>

Get the InMemoryNodeInner’s show_calls property as a string Read more
source§

fn config_get_show_outputs(&self) -> Result<bool>

Get the InMemoryNodeInner’s show_outputs property as a boolean Read more
source§

fn config_get_current_timestamp(&self) -> Result<u64>

Get the InMemoryNodeInner’s current_timestamp property Read more
source§

fn config_set_show_calls(&self, value: String) -> Result<String>

Set show_calls for the InMemoryNodeInner Read more
source§

fn config_set_show_outputs(&self, value: bool) -> Result<bool>

Set show_outputs for the InMemoryNodeInner Read more
source§

fn config_set_show_storage_logs(&self, value: String) -> Result<String>

Set show_storage_logs for the InMemoryNodeInner Read more
source§

fn config_set_show_vm_details(&self, value: String) -> Result<String>

Set show_vm_details for the InMemoryNodeInner Read more
source§

fn config_set_show_gas_details(&self, value: String) -> Result<String>

Set show_gas_details for the InMemoryNodeInner Read more
source§

fn config_set_resolve_hashes(&self, value: bool) -> Result<bool>

Set resolve_hashes for the InMemoryNodeInner Read more
source§

fn config_set_log_level(&self, level: LogLevel) -> Result<bool>

Set the logging for the InMemoryNodeInner Read more
source§

fn config_set_logging(&self, directive: String) -> Result<bool>

Set the logging for the InMemoryNodeInner Read more
source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> DebugNamespaceT for InMemoryNode<S>

source§

fn trace_call( &self, request: CallRequest, block: Option<BlockId>, options: Option<TracerConfig> ) -> RpcResult<DebugCall>

Trace execution of a transaction.

source§

fn trace_block_by_number( &self, block: BlockNumber, options: Option<TracerConfig> ) -> RpcResult<Vec<ResultDebugCall>>

source§

fn trace_block_by_hash( &self, hash: H256, options: Option<TracerConfig> ) -> RpcResult<Vec<ResultDebugCall>>

source§

fn trace_transaction( &self, tx_hash: H256, options: Option<TracerConfig> ) -> RpcResult<Option<DebugCall>>

source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.
source§

impl<S: ForkSource + Debug + Clone> Default for InMemoryNode<S>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EthNamespaceT for InMemoryNode<S>

source§

fn chain_id(&self) -> RpcResult<U64>

Returns the chain ID of the node.

source§

fn call( &self, req: CallRequest, _block: Option<BlockIdVariant> ) -> RpcResult<Bytes>

Calls the specified function on the L2 contract with the given arguments.

Arguments
  • req - The call request containing the function name and arguments.
  • _block - The block ID variant (unused).
Returns

A boxed future containing the result of the function call.

source§

fn get_balance( &self, address: Address, _block: Option<BlockIdVariant> ) -> RpcResult<U256>

Returns the balance of the specified address.

Arguments
  • address - The address to get the balance of.
  • _block - The block ID variant (optional).
Returns

A BoxFuture that resolves to a Result containing the balance of the specified address as a U256 or a jsonrpc_core::Error if an error occurred.

source§

fn get_block_by_number( &self, block_number: BlockNumber, full_transactions: bool ) -> RpcResult<Option<Block<TransactionVariant>>>

Returns a block by its number.

Arguments
  • block_number - A BlockNumber enum variant representing the block number to retrieve.
  • full_transactions - A boolean value indicating whether to retrieve full transactions or not.
Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an Option of Block<TransactionVariant>.

source§

fn get_code( &self, address: Address, _block: Option<BlockIdVariant> ) -> RpcResult<Bytes>

Returns the code stored at the specified address.

Arguments
  • address - The address to retrieve the code from.
  • _block - An optional block ID variant.
Returns

A BoxFuture containing the result of the operation, which is a jsonrpc_core::Result containing the code as a Bytes object.

source§

fn get_transaction_count( &self, address: Address, _block: Option<BlockIdVariant> ) -> RpcResult<U256>

Returns the transaction count for a given address.

Arguments
  • address - The address to get the transaction count for.
  • _block - Optional block ID variant.
Returns

Returns a BoxFuture containing the transaction count as a U256 wrapped in a jsonrpc_core::Result.

source§

fn get_transaction_receipt( &self, hash: H256 ) -> RpcResult<Option<TransactionReceipt>>

Retrieves the transaction receipt for a given transaction hash.

Arguments
  • hash - The hash of the transaction to retrieve the receipt for.
Returns

A BoxFuture that resolves to an Option of a TransactionReceipt or an error.

source§

fn send_raw_transaction(&self, tx_bytes: Bytes) -> RpcResult<H256>

Sends a raw transaction to the L2 network.

Arguments
  • tx_bytes - The transaction bytes to send.
Returns

A future that resolves to the hash of the transaction if successful, or an error if the transaction is invalid or execution fails.

source§

fn get_block_by_hash( &self, hash: H256, full_transactions: bool ) -> RpcResult<Option<Block<TransactionVariant>>>

Returns a block by its hash. Currently, only hashes for blocks in memory are supported.

Arguments
  • hash - A H256 type representing the hash of the block to retrieve.
  • full_transactions - A boolean value indicating whether to retrieve full transactions or not.
Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an Option of Block<TransactionVariant>.

source§

fn get_transaction_by_hash(&self, hash: H256) -> RpcResult<Option<Transaction>>

Returns a future that resolves to an optional transaction with the given hash.

Arguments
  • hash - A 32-byte hash of the transaction.
Returns

A jsonrpc_core::BoxFuture that resolves to a jsonrpc_core::Result containing an optional zksync_types::api::Transaction.

source§

fn get_block_number(&self) -> RpcResult<U64>

Returns the current block number as a U64 wrapped in a BoxFuture.

source§

fn estimate_gas( &self, req: CallRequest, _block: Option<BlockNumber> ) -> RpcResult<U256>

Estimates the gas required for a given call request.

Arguments
  • req - A CallRequest struct representing the call request to estimate gas for.
  • _block - An optional BlockNumber struct representing the block number to estimate gas for.
Returns

A BoxFuture containing a Result with a U256 representing the estimated gas required.

source§

fn gas_price(&self) -> RpcResult<U256>

Returns the current gas price in U256 format.

source§

fn new_filter(&self, filter: Filter) -> RpcResult<U256>

Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.

Arguments
  • filter: The filter options - fromBlock: - Integer block number, or the string “latest”, “earliest” or “pending”. toBlock: - Integer block number, or the string “latest”, “earliest” or “pending”. address: - Contract address or a list of addresses from which the logs should originate. topics: - [H256] topics. Topics are order-dependent. Each topic can also be an array with “or” options.

If the from fromBlock or toBlock option are equal to “latest” the filter continually appends logs for newly mined blocks. Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters: * [] “anything” * [A] “A in first position (and anything after)” * [null, B] “anything in first position AND B in second position (and anything after)” * [A, B] “A in first position AND B in second position (and anything after)” * [[A, B], [A, B]] “(A OR B) in first position AND (A OR B) in second position (and anything after)”

Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an U256 filter id.

source§

fn new_block_filter(&self) -> RpcResult<U256>

Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.

Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an U256 filter id.

source§

fn new_pending_transaction_filter(&self) -> RpcResult<U256>

Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.

Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an U256 filter id.

source§

fn uninstall_filter(&self, id: U256) -> RpcResult<bool>

Uninstalls a filter with given id. Should always be called when watch is no longer needed.

Arguments
  • id: The filter id
Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an U256 filter id.

source§

fn get_logs(&self, filter: Filter) -> RpcResult<Vec<Log>>

Returns an array of all logs matching a given filter.

Arguments
  • filter: The filter options - fromBlock - Integer block number, or the string “latest”, “earliest” or “pending”. toBlock - Integer block number, or the string “latest”, “earliest” or “pending”. address - Contract address or a list of addresses from which the logs should originate. topics - [H256] topics. Topics are order-dependent. Each topic can also be an array with “or” options. See new_filter documention for how to specify topics.
Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an array of logs.

source§

fn get_filter_logs(&self, id: U256) -> RpcResult<FilterChanges>

Returns an array of all logs matching filter with given id.

Arguments
  • id: The filter id
Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an array of logs.

source§

fn get_filter_changes(&self, id: U256) -> RpcResult<FilterChanges>

Polling method for a filter, which returns an array of logs, block hashes, or transaction hashes, depending on the filter type, which occurred since last poll.

Arguments
  • id: The filter id
Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to an array of logs, block hashes, or transaction hashes, depending on the filter type, which occurred since last poll.

  • Filters created with eth_newFilter return [zksync_types::api::Log] objects.
  • Filters created with eth_newBlockFilter return block hashes.
  • Filters created with eth_newPendingTransactionFilter return transaction hashes.
source§

fn get_storage( &self, address: Address, idx: U256, block: Option<BlockIdVariant> ) -> RpcResult<H256>

Returns the value from a storage position at a given address.

Arguments
  • address: Address of the storage
  • idx: Integer of the position in the storage
  • block: The block storage to target
Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to a [H256] value in the storage.

source§

fn get_transaction_by_block_hash_and_index( &self, block_hash: H256, index: Index ) -> RpcResult<Option<Transaction>>

Returns information about a transaction by block hash and transaction index position.

Arguments
  • block_hash: Hash of a block
  • index: Integer of the transaction index position
Returns

A BoxFuture containing a jsonrpc_core::Result that maybe resolves to a [zksync_types::api::Transaction], if found.

source§

fn get_transaction_by_block_number_and_index( &self, block_number: BlockNumber, index: Index ) -> RpcResult<Option<Transaction>>

Returns information about a transaction by block number and transaction index position.

Arguments
  • block_number: A block number, or the string “earliest”, “latest” or “pending”.
  • index: Integer of the transaction index position
Returns

A BoxFuture containing a jsonrpc_core::Result that maybe resolves to a [zksync_types::api::Transaction], if found.

source§

fn protocol_version(&self) -> RpcResult<String>

Returns the protocol version.

Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to a hex String of the version number.

source§

fn accounts(&self) -> RpcResult<Vec<H160>>

Returns a list of available accounts.

This function fetches the accounts from the inner state, and returns them as a list of addresses (H160).

Errors

Returns a jsonrpc_core::Result error if acquiring a write lock on the inner state fails.

Returns

A BoxFuture containing a jsonrpc_core::Result that resolves to a Vec<H160> of addresses.

source§

fn fee_history( &self, block_count: U64, _newest_block: BlockNumber, reward_percentiles: Vec<f32> ) -> RpcResult<FeeHistory>

Returns the fee history for a given range of blocks.

Note: This implementation is limited to using the hard-coded value of L2_GAS_PRICE as the history gas price

Arguments
  • block_count - The number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. It will return less than the requested range if not all blocks are available.
  • newest_block - The highest number block of the requested range. As this implementation is using hard-coded values, this argument is ignored.
  • reward_percentiles - A list of percentile values with a monotonic increase in value.
Returns

A BoxFuture containing a Result with a FeeHistory representing the fee history of the specified range of blocks.

source§

fn get_block_transaction_count_by_number( &self, block_number: BlockNumber ) -> RpcResult<Option<U256>>

source§

fn get_block_transaction_count_by_hash( &self, block_hash: H256 ) -> RpcResult<Option<U256>>

source§

fn syncing(&self) -> RpcResult<SyncState>

source§

fn coinbase(&self) -> RpcResult<Address>

source§

fn compilers(&self) -> RpcResult<Vec<String>>

source§

fn hashrate(&self) -> RpcResult<U256>

source§

fn get_uncle_count_by_block_hash(&self, _hash: H256) -> RpcResult<Option<U256>>

source§

fn get_uncle_count_by_block_number( &self, _number: BlockNumber ) -> RpcResult<Option<U256>>

source§

fn mining(&self) -> RpcResult<bool>

source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EthTestNodeNamespaceT for InMemoryNode<S>

source§

fn send_transaction(&self, tx: CallRequest) -> BoxFuture<Result<H256>>

Sends a transaction to the L2 network. Can be used for the impersonated account.

Arguments
  • tx - A CallRequest struct representing the transaction.
Returns

A future that resolves to the hash of the transaction if successful, or an error if the transaction is invalid or execution fails.

source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EvmNamespaceT for InMemoryNode<S>

source§

fn increase_time(&self, time_delta_seconds: u64) -> RpcResult<u64>

Increase the current timestamp for the node Read more
source§

fn evm_mine(&self) -> RpcResult<String>

Force a single block to be mined. Read more
source§

fn set_next_block_timestamp(&self, timestamp: u64) -> RpcResult<u64>

Set the current timestamp for the node. The timestamp must be in future. Read more
source§

fn set_time(&self, time: u64) -> RpcResult<i128>

Set the current timestamp for the node. Warning: This will allow you to move backwards in time, which may cause new blocks to appear to be mined before old blocks. This will result in an invalid state. Read more
source§

fn snapshot(&self) -> RpcResult<U64>

Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created. A snapshot can only be reverted once. After a successful evm_revert, the same snapshot id cannot be used again. Consider creating a new snapshot after each evm_revert if you need to revert to the same point multiple times. Read more
source§

fn revert_snapshot(&self, snapshot_id: U64) -> RpcResult<bool>

Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. This deletes the given snapshot, as well as any snapshots taken after (e.g.: reverting to id 0x1 will delete snapshots with ids 0x1, 0x2, etc.) Read more
source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> HardhatNamespaceT for InMemoryNode<S>

source§

fn set_balance(&self, address: Address, balance: U256) -> RpcResult<bool>

Sets the balance of the given address to the given balance. Read more
source§

fn set_nonce(&self, address: Address, balance: U256) -> RpcResult<bool>

Modifies an account’s nonce by overwriting it. Read more
source§

fn hardhat_mine( &self, num_blocks: Option<U64>, interval: Option<U64> ) -> RpcResult<bool>

Sometimes you may want to advance the latest block number of the network by a large number of blocks. One way to do this would be to call the evm_mine RPC method multiple times, but this is too slow if you want to mine thousands of blocks. The hardhat_mine method can mine any number of blocks at once, in constant time. (It exhibits the same performance no matter how many blocks are mined.) Read more
source§

fn reset_network(&self, reset_spec: Option<ResetRequest>) -> RpcResult<bool>

Reset the state of the network back to a fresh forked state, or disable forking. Read more
source§

fn impersonate_account(&self, address: Address) -> RpcResult<bool>

Hardhat Network allows you to send transactions impersonating specific account and contract addresses. To impersonate an account use this method, passing the address to impersonate as its parameter. After calling this method, any transactions with this sender will be executed without verification. Multiple addresses can be impersonated at once. Read more
source§

fn stop_impersonating_account(&self, address: Address) -> RpcResult<bool>

Use this method to stop impersonating an account after having previously used hardhat_impersonateAccount The method returns true if the account was being impersonated and false otherwise. Read more
source§

fn set_code(&self, address: Address, code: Vec<u8>) -> RpcResult<()>

Modifies the bytecode stored at an account’s address. Read more
source§

fn set_storage_at( &self, address: Address, slot: U256, value: U256 ) -> RpcResult<bool>

Directly modifies the storage of a contract at a specified slot. Read more
source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> NetNamespaceT for InMemoryNode<S>

source§

fn net_version(&self) -> Result<String>

source§

fn net_peer_count(&self) -> Result<U256>

source§

fn net_listening(&self) -> Result<bool>

source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> Web3NamespaceT for InMemoryNode<S>

source§

fn web3_client_version(&self) -> Result<String>

source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.
source§

impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> ZksNamespaceT for InMemoryNode<S>

source§

fn estimate_fee(&self, req: CallRequest) -> RpcResult<Fee>

Estimates the gas fee data required for a given call request.

Arguments
  • req - A CallRequest struct representing the call request to estimate gas for.
Returns

A BoxFuture containing a Result with a Fee representing the estimated gas data required.

source§

fn get_raw_block_transactions( &self, block_number: L2BlockNumber ) -> RpcResult<Vec<Transaction>>

Returns data of transactions in a block.

Arguments
  • block - Block number
Returns

A BoxFuture containing a Result with a Vec of Transactions representing the transactions in the block.

source§

fn get_all_account_balances( &self, address: Address ) -> BoxFuture<Result<HashMap<Address, U256>>>

Get all known balances for a given account.

Arguments
  • address - The user address with balances to check.
Returns

A BoxFuture containing a Result with a (Token, Balance) map where account has non-zero value.

source§

fn get_block_details( &self, block_number: L2BlockNumber ) -> RpcResult<Option<BlockDetails>>

Get block details.

Arguments
  • blockNumber - u32 miniblock number
Returns

A BoxFuture containing a Result with an Option<BlockDetails> representing details of the block (if found).

source§

fn get_transaction_details( &self, hash: H256 ) -> RpcResult<Option<TransactionDetails>>

Get transaction details.

Arguments
  • transactionHash - H256 hash of the transaction
Returns

A BoxFuture containing a Result with an Option<TransactionDetails> representing details of the transaction (if found).

source§

fn get_l1_batch_details( &self, _batch: L1BatchNumber ) -> RpcResult<Option<L1BatchDetails>>

Retrieves details for a given L1 batch.

This method is intended to handle queries related to L1 batch details. However, as of the current implementation, L1 communication is not supported. Instead of an error or no method found, this method intentionally returns {"jsonrpc":"2.0","result":null,"id":1} to ensure compatibility with block explorer integration.

Parameters
  • _batch: The batch number of type zksync_basic_types::L1BatchNumber for which the details are to be fetched.
Returns

A boxed future resolving to a jsonrpc_core::Result containing an Option of zksync_types::api::L1BatchDetails. Given the current implementation, this will always be None.

source§

fn get_bytecode_by_hash(&self, hash: H256) -> RpcResult<Option<Vec<u8>>>

Returns bytecode of a transaction given by its hash.

Parameters
  • hash: Hash address.
Returns

A boxed future resolving to a jsonrpc_core::Result containing an Option of bytes.

source§

fn get_proof( &self, _address: Address, _keys: Vec<H256>, _l1_batch_number: L1BatchNumber ) -> RpcResult<Proof>

source§

fn estimate_gas_l1_to_l2(&self, _req: CallRequest) -> RpcResult<U256>

source§

fn get_main_contract(&self) -> RpcResult<Address>

source§

fn get_testnet_paymaster(&self) -> RpcResult<Option<Address>>

source§

fn get_bridge_contracts(&self) -> RpcResult<BridgeAddresses>

source§

fn l1_chain_id(&self) -> RpcResult<U64>

source§

fn get_confirmed_tokens( &self, from: u32, limit: u8 ) -> BoxFuture<Result<Vec<Token>>>

source§

fn get_token_price(&self, token_address: Address) -> RpcResult<BigDecimal>

source§

fn get_l2_to_l1_msg_proof( &self, _block: L2BlockNumber, _sender: Address, _msg: H256, _l2_log_position: Option<usize> ) -> RpcResult<Option<L2ToL1LogProof>>

source§

fn get_l2_to_l1_log_proof( &self, _tx_hash: H256, _index: Option<usize> ) -> RpcResult<Option<L2ToL1LogProof>>

source§

fn get_l1_batch_number(&self) -> RpcResult<U64>

source§

fn get_miniblock_range( &self, _batch: L1BatchNumber ) -> BoxFuture<Result<Option<(U64, U64)>>>

source§

fn get_l1_gas_price(&self) -> RpcResult<U64>

source§

fn get_protocol_version( &self, _version_id: Option<u16> ) -> RpcResult<Option<ProtocolVersion>>

source§

fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>

Create an IoDelegate, wiring rpc calls to the trait methods.

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for InMemoryNode<S>

§

impl<S> Send for InMemoryNode<S>
where S: Send + Sync,

§

impl<S> Sync for InMemoryNode<S>
where S: Send + Sync,

§

impl<S> Unpin for InMemoryNode<S>

§

impl<S> UnwindSafe for InMemoryNode<S>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> Cast<U> for T
where U: FromCast<T>,

§

fn cast(self) -> U

Numeric cast from self to T.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromCast<T> for T

§

fn from_cast(t: T) -> T

Numeric cast from T to Self.
§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> PipeOp<T> for T

§

fn to<F, U>(self, f: F) -> U
where F: FnOnce(T) -> U,

§

fn op<F>(self, f: F) -> T
where F: FnOnce(&mut T),

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> JsonSchemaMaybe for T

§

impl<T> MaybeSend for T
where T: Send,