Struct era_test_node::node::InMemoryNodeInner
source · pub struct InMemoryNodeInner<S> {Show 17 fields
pub current_timestamp: u64,
pub current_batch: u32,
pub current_miniblock: u64,
pub current_miniblock_hash: H256,
pub fee_input_provider: TestNodeFeeInputProvider,
pub tx_results: HashMap<H256, TransactionResult>,
pub blocks: HashMap<H256, Block<TransactionVariant>>,
pub block_hashes: HashMap<u64, H256>,
pub filters: EthFilters,
pub fork_storage: ForkStorage<S>,
pub config: InMemoryNodeConfig,
pub console_log_handler: ConsoleLogHandler,
pub system_contracts: SystemContracts,
pub impersonated_accounts: HashSet<Address>,
pub rich_accounts: HashSet<H160>,
pub previous_states: IndexMap<H256, HashMap<StorageKey, StorageValue>>,
pub observability: Option<Observability>,
}
Expand description
Helper struct for InMemoryNode. S - is the Source of the Fork.
Fields§
§current_timestamp: u64
The latest timestamp that was already generated. Next block will be current_timestamp + 1
current_batch: u32
The latest batch number that was already generated. Next block will be current_batch + 1
current_miniblock: u64
The latest miniblock number that was already generated. Next transaction will go to the block current_miniblock + 1
current_miniblock_hash: H256
The latest miniblock hash.
fee_input_provider: TestNodeFeeInputProvider
The fee input provider.
tx_results: HashMap<H256, TransactionResult>
§blocks: HashMap<H256, Block<TransactionVariant>>
§block_hashes: HashMap<u64, H256>
§filters: EthFilters
§fork_storage: ForkStorage<S>
§config: InMemoryNodeConfig
§console_log_handler: ConsoleLogHandler
§system_contracts: SystemContracts
§impersonated_accounts: HashSet<Address>
§rich_accounts: HashSet<H160>
§previous_states: IndexMap<H256, HashMap<StorageKey, StorageValue>>
Keeps track of historical states indexed via block hash. Limited to MAX_PREVIOUS_STATES.
observability: Option<Observability>
An optional handle to the observability stack
Implementations§
source§impl<S: Debug + ForkSource> InMemoryNodeInner<S>
impl<S: Debug + ForkSource> InMemoryNodeInner<S>
sourcepub fn new(
fork: Option<ForkDetails>,
observability: Option<Observability>,
config: InMemoryNodeConfig,
gas_overrides: Option<GasConfig>
) -> Self
pub fn new( fork: Option<ForkDetails>, observability: Option<Observability>, config: InMemoryNodeConfig, gas_overrides: Option<GasConfig> ) -> Self
Create the state to be used implementing InMemoryNode.
sourcepub fn create_l1_batch_env<ST: ReadStorage>(
&self,
storage: StoragePtr<ST>
) -> (L1BatchEnv, BlockContext)
pub fn create_l1_batch_env<ST: ReadStorage>( &self, storage: StoragePtr<ST> ) -> (L1BatchEnv, BlockContext)
Create [L1BatchEnv] to be used in the VM.
We compute l1/l2 block details from storage to support fork testing, where the storage can be updated mid execution and no longer matches with the initial node’s state. The L1 & L2 timestamps are also compared with node’s timestamp to ensure it always increases monotonically.
pub fn create_system_env( &self, base_system_contracts: BaseSystemContracts, execution_mode: TxExecutionMode ) -> SystemEnv
sourcepub fn estimate_gas_impl(&self, req: CallRequest) -> Result<Fee>
pub fn estimate_gas_impl(&self, req: CallRequest) -> Result<Fee>
sourcepub fn set_impersonated_account(&mut self, address: Address) -> bool
pub fn set_impersonated_account(&mut self, address: Address) -> bool
Sets the impersonated_account
field of the node.
This field is used to override the tx.initiator_account
field of the transaction in the run_l2_tx
method.
sourcepub fn stop_impersonating_account(&mut self, address: Address) -> bool
pub fn stop_impersonating_account(&mut self, address: Address) -> bool
Clears the impersonated_account
field of the node.
sourcepub fn archive_state(&mut self) -> Result<(), String>
pub fn archive_state(&mut self) -> Result<(), String>
Archives the current state for later queries.
Trait Implementations§
source§impl<S: Clone> Clone for InMemoryNodeInner<S>
impl<S: Clone> Clone for InMemoryNodeInner<S>
source§fn clone(&self) -> InMemoryNodeInner<S>
fn clone(&self) -> InMemoryNodeInner<S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<S> RefUnwindSafe for InMemoryNodeInner<S>
impl<S> Send for InMemoryNodeInner<S>
impl<S> Sync for InMemoryNodeInner<S>
impl<S> Unpin for InMemoryNodeInner<S>
impl<S> UnwindSafe for InMemoryNodeInner<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