Struct era_test_node::node::InMemoryNode
source · 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>
impl<S: ForkSource + Debug + Clone> InMemoryNode<S>
pub fn new( fork: Option<ForkDetails>, observability: Option<Observability>, config: InMemoryNodeConfig, gas_overrides: Option<GasConfig> ) -> Self
pub fn get_inner(&self) -> Arc<RwLock<InMemoryNodeInner<S>>>
pub fn get_cache_config(&self) -> Result<CacheConfig, String>
pub fn get_fork_url(&self) -> Result<String, String>
pub fn reset(&self, fork: Option<ForkDetails>) -> Result<(), String>
sourcepub fn apply_txs(&self, txs: Vec<L2Tx>) -> Result<(), String>
pub fn apply_txs(&self, txs: Vec<L2Tx>) -> Result<(), String>
Applies multiple transactions - but still one per L1 batch.
sourcepub fn set_rich_account(&self, address: H160)
pub fn set_rich_account(&self, address: H160)
Adds a lot of tokens to a given account.
sourcepub fn run_l2_call(&self, l2_tx: L2Tx) -> Result<ExecutionResult, String>
pub fn run_l2_call(&self, l2_tx: L2Tx) -> Result<ExecutionResult, String>
Runs L2 ‘eth call’ method - that doesn’t commit to a block.
sourcepub 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>
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§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> InMemoryNode<S>
sourcepub fn increase_time(&self, time_delta_seconds: u64) -> Result<u64>
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.
sourcepub fn set_next_block_timestamp(&self, timestamp: u64) -> Result<u64>
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.
sourcepub fn set_time(&self, time: u64) -> Result<i128>
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.
sourcepub fn mine_block(&self) -> Result<String>
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”.
sourcepub fn snapshot(&self) -> Result<U64>
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.
sourcepub fn revert_snapshot(&self, snapshot_id: U64) -> Result<bool>
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
.
pub fn set_balance(&self, address: Address, balance: U256) -> Result<bool>
pub fn set_nonce(&self, address: Address, nonce: U256) -> Result<bool>
pub fn mine_blocks( &self, num_blocks: Option<U64>, interval: Option<U64> ) -> Result<bool>
pub fn reset_network(&self, reset_spec: Option<ResetRequest>) -> Result<bool>
pub fn impersonate_account(&self, address: Address) -> Result<bool>
pub fn stop_impersonating_account(&self, address: Address) -> Result<bool>
pub fn set_code(&self, address: Address, code: Vec<u8>) -> Result<()>
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>
impl<S: Clone + Clone> Clone for InMemoryNode<S>
source§fn clone(&self) -> InMemoryNode<S>
fn clone(&self) -> InMemoryNode<S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> ConfigurationApiNamespaceT for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> ConfigurationApiNamespaceT for InMemoryNode<S>
source§fn config_get_show_calls(&self) -> Result<String>
fn config_get_show_calls(&self) -> Result<String>
source§fn config_get_show_outputs(&self) -> Result<bool>
fn config_get_show_outputs(&self) -> Result<bool>
source§fn config_get_current_timestamp(&self) -> Result<u64>
fn config_get_current_timestamp(&self) -> Result<u64>
source§fn config_set_show_calls(&self, value: String) -> Result<String>
fn config_set_show_calls(&self, value: String) -> Result<String>
source§fn config_set_show_outputs(&self, value: bool) -> Result<bool>
fn config_set_show_outputs(&self, value: bool) -> Result<bool>
source§fn config_set_show_storage_logs(&self, value: String) -> Result<String>
fn config_set_show_storage_logs(&self, value: String) -> Result<String>
source§fn config_set_show_vm_details(&self, value: String) -> Result<String>
fn config_set_show_vm_details(&self, value: String) -> Result<String>
source§fn config_set_show_gas_details(&self, value: String) -> Result<String>
fn config_set_show_gas_details(&self, value: String) -> Result<String>
source§fn config_set_resolve_hashes(&self, value: bool) -> Result<bool>
fn config_set_resolve_hashes(&self, value: bool) -> Result<bool>
source§fn config_set_log_level(&self, level: LogLevel) -> Result<bool>
fn config_set_log_level(&self, level: LogLevel) -> Result<bool>
source§fn config_set_logging(&self, directive: String) -> Result<bool>
fn config_set_logging(&self, directive: String) -> Result<bool>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.source§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> DebugNamespaceT for InMemoryNode<S>
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>
fn trace_call( &self, request: CallRequest, block: Option<BlockId>, options: Option<TracerConfig> ) -> RpcResult<DebugCall>
Trace execution of a transaction.
fn trace_block_by_number( &self, block: BlockNumber, options: Option<TracerConfig> ) -> RpcResult<Vec<ResultDebugCall>>
fn trace_block_by_hash( &self, hash: H256, options: Option<TracerConfig> ) -> RpcResult<Vec<ResultDebugCall>>
fn trace_transaction( &self, tx_hash: H256, options: Option<TracerConfig> ) -> RpcResult<Option<DebugCall>>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.source§impl<S: ForkSource + Debug + Clone> Default for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone> Default for InMemoryNode<S>
source§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EthNamespaceT for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EthNamespaceT for InMemoryNode<S>
source§fn get_balance(
&self,
address: Address,
_block: Option<BlockIdVariant>
) -> RpcResult<U256>
fn get_balance( &self, address: Address, _block: Option<BlockIdVariant> ) -> RpcResult<U256>
source§fn get_block_by_number(
&self,
block_number: BlockNumber,
full_transactions: bool
) -> RpcResult<Option<Block<TransactionVariant>>>
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
- ABlockNumber
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_transaction_count(
&self,
address: Address,
_block: Option<BlockIdVariant>
) -> RpcResult<U256>
fn get_transaction_count( &self, address: Address, _block: Option<BlockIdVariant> ) -> RpcResult<U256>
source§fn get_transaction_receipt(
&self,
hash: H256
) -> RpcResult<Option<TransactionReceipt>>
fn get_transaction_receipt( &self, hash: H256 ) -> RpcResult<Option<TransactionReceipt>>
source§fn send_raw_transaction(&self, tx_bytes: Bytes) -> RpcResult<H256>
fn send_raw_transaction(&self, tx_bytes: Bytes) -> RpcResult<H256>
source§fn get_block_by_hash(
&self,
hash: H256,
full_transactions: bool
) -> RpcResult<Option<Block<TransactionVariant>>>
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
- AH256
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>>
fn get_transaction_by_hash(&self, hash: H256) -> RpcResult<Option<Transaction>>
source§fn get_block_number(&self) -> RpcResult<U64>
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>
fn estimate_gas( &self, req: CallRequest, _block: Option<BlockNumber> ) -> RpcResult<U256>
Estimates the gas required for a given call request.
Arguments
req
- ACallRequest
struct representing the call request to estimate gas for._block
- An optionalBlockNumber
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 new_filter(&self, filter: Filter) -> RpcResult<U256>
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>
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>
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>
fn uninstall_filter(&self, id: U256) -> RpcResult<bool>
source§fn get_logs(&self, filter: Filter) -> RpcResult<Vec<Log>>
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. Seenew_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>
fn get_filter_logs(&self, id: U256) -> RpcResult<FilterChanges>
source§fn get_filter_changes(&self, id: U256) -> RpcResult<FilterChanges>
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>
fn get_storage( &self, address: Address, idx: U256, block: Option<BlockIdVariant> ) -> RpcResult<H256>
source§fn get_transaction_by_block_hash_and_index(
&self,
block_hash: H256,
index: Index
) -> RpcResult<Option<Transaction>>
fn get_transaction_by_block_hash_and_index( &self, block_hash: H256, index: Index ) -> RpcResult<Option<Transaction>>
source§fn get_transaction_by_block_number_and_index(
&self,
block_number: BlockNumber,
index: Index
) -> RpcResult<Option<Transaction>>
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>
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>>
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>
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.
fn get_block_transaction_count_by_number( &self, block_number: BlockNumber ) -> RpcResult<Option<U256>>
fn get_block_transaction_count_by_hash( &self, block_hash: H256 ) -> RpcResult<Option<U256>>
fn syncing(&self) -> RpcResult<SyncState>
fn coinbase(&self) -> RpcResult<Address>
fn compilers(&self) -> RpcResult<Vec<String>>
fn hashrate(&self) -> RpcResult<U256>
fn get_uncle_count_by_block_hash(&self, _hash: H256) -> RpcResult<Option<U256>>
fn get_uncle_count_by_block_number( &self, _number: BlockNumber ) -> RpcResult<Option<U256>>
fn mining(&self) -> RpcResult<bool>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.source§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EthTestNodeNamespaceT for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EthTestNodeNamespaceT for InMemoryNode<S>
source§fn send_transaction(&self, tx: CallRequest) -> BoxFuture<Result<H256>>
fn send_transaction(&self, tx: CallRequest) -> BoxFuture<Result<H256>>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.source§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EvmNamespaceT for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> EvmNamespaceT for InMemoryNode<S>
source§fn increase_time(&self, time_delta_seconds: u64) -> RpcResult<u64>
fn increase_time(&self, time_delta_seconds: u64) -> RpcResult<u64>
source§fn set_next_block_timestamp(&self, timestamp: u64) -> RpcResult<u64>
fn set_next_block_timestamp(&self, timestamp: u64) -> RpcResult<u64>
source§fn set_time(&self, time: u64) -> RpcResult<i128>
fn set_time(&self, time: u64) -> RpcResult<i128>
source§fn snapshot(&self) -> RpcResult<U64>
fn snapshot(&self) -> RpcResult<U64>
source§fn revert_snapshot(&self, snapshot_id: U64) -> RpcResult<bool>
fn revert_snapshot(&self, snapshot_id: U64) -> RpcResult<bool>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.source§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> HardhatNamespaceT for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> HardhatNamespaceT for InMemoryNode<S>
source§fn set_balance(&self, address: Address, balance: U256) -> RpcResult<bool>
fn set_balance(&self, address: Address, balance: U256) -> RpcResult<bool>
source§fn set_nonce(&self, address: Address, balance: U256) -> RpcResult<bool>
fn set_nonce(&self, address: Address, balance: U256) -> RpcResult<bool>
source§fn hardhat_mine(
&self,
num_blocks: Option<U64>,
interval: Option<U64>
) -> RpcResult<bool>
fn hardhat_mine( &self, num_blocks: Option<U64>, interval: Option<U64> ) -> RpcResult<bool>
source§fn reset_network(&self, reset_spec: Option<ResetRequest>) -> RpcResult<bool>
fn reset_network(&self, reset_spec: Option<ResetRequest>) -> RpcResult<bool>
source§fn impersonate_account(&self, address: Address) -> RpcResult<bool>
fn impersonate_account(&self, address: Address) -> RpcResult<bool>
source§fn stop_impersonating_account(&self, address: Address) -> RpcResult<bool>
fn stop_impersonating_account(&self, address: Address) -> RpcResult<bool>
hardhat_impersonateAccount
The method returns true
if the account was being impersonated and false
otherwise. Read moresource§fn set_code(&self, address: Address, code: Vec<u8>) -> RpcResult<()>
fn set_code(&self, address: Address, code: Vec<u8>) -> RpcResult<()>
source§fn set_storage_at(
&self,
address: Address,
slot: U256,
value: U256
) -> RpcResult<bool>
fn set_storage_at( &self, address: Address, slot: U256, value: U256 ) -> RpcResult<bool>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.source§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> NetNamespaceT for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> NetNamespaceT for InMemoryNode<S>
fn net_version(&self) -> Result<String>
fn net_peer_count(&self) -> Result<U256>
fn net_listening(&self) -> Result<bool>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.source§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> Web3NamespaceT for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> Web3NamespaceT for InMemoryNode<S>
fn web3_client_version(&self) -> Result<String>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.source§impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> ZksNamespaceT for InMemoryNode<S>
impl<S: ForkSource + Debug + Clone + Send + Sync + 'static> ZksNamespaceT for InMemoryNode<S>
source§fn estimate_fee(&self, req: CallRequest) -> RpcResult<Fee>
fn estimate_fee(&self, req: CallRequest) -> RpcResult<Fee>
source§fn get_raw_block_transactions(
&self,
block_number: L2BlockNumber
) -> RpcResult<Vec<Transaction>>
fn get_raw_block_transactions( &self, block_number: L2BlockNumber ) -> RpcResult<Vec<Transaction>>
source§fn get_all_account_balances(
&self,
address: Address
) -> BoxFuture<Result<HashMap<Address, U256>>>
fn get_all_account_balances( &self, address: Address ) -> BoxFuture<Result<HashMap<Address, U256>>>
source§fn get_block_details(
&self,
block_number: L2BlockNumber
) -> RpcResult<Option<BlockDetails>>
fn get_block_details( &self, block_number: L2BlockNumber ) -> RpcResult<Option<BlockDetails>>
source§fn get_transaction_details(
&self,
hash: H256
) -> RpcResult<Option<TransactionDetails>>
fn get_transaction_details( &self, hash: H256 ) -> RpcResult<Option<TransactionDetails>>
source§fn get_l1_batch_details(
&self,
_batch: L1BatchNumber
) -> RpcResult<Option<L1BatchDetails>>
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 typezksync_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>>>
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.
fn get_proof( &self, _address: Address, _keys: Vec<H256>, _l1_batch_number: L1BatchNumber ) -> RpcResult<Proof>
fn estimate_gas_l1_to_l2(&self, _req: CallRequest) -> RpcResult<U256>
fn get_main_contract(&self) -> RpcResult<Address>
fn get_testnet_paymaster(&self) -> RpcResult<Option<Address>>
fn get_bridge_contracts(&self) -> RpcResult<BridgeAddresses>
fn l1_chain_id(&self) -> RpcResult<U64>
fn get_confirmed_tokens( &self, from: u32, limit: u8 ) -> BoxFuture<Result<Vec<Token>>>
fn get_token_price(&self, token_address: Address) -> RpcResult<BigDecimal>
fn get_l2_to_l1_msg_proof( &self, _block: L2BlockNumber, _sender: Address, _msg: H256, _l2_log_position: Option<usize> ) -> RpcResult<Option<L2ToL1LogProof>>
fn get_l2_to_l1_log_proof( &self, _tx_hash: H256, _index: Option<usize> ) -> RpcResult<Option<L2ToL1LogProof>>
fn get_l1_batch_number(&self) -> RpcResult<U64>
fn get_miniblock_range( &self, _batch: L1BatchNumber ) -> BoxFuture<Result<Option<(U64, U64)>>>
fn get_l1_gas_price(&self) -> RpcResult<U64>
fn get_protocol_version( &self, _version_id: Option<u16> ) -> RpcResult<Option<ProtocolVersion>>
source§fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
IoDelegate
, wiring rpc calls to the trait methods.Auto Trait Implementations§
impl<S> RefUnwindSafe for InMemoryNode<S>
impl<S> Send for InMemoryNode<S>
impl<S> Sync for InMemoryNode<S>
impl<S> Unpin for InMemoryNode<S>
impl<S> UnwindSafe for InMemoryNode<S>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request