Skip to main content

Trace

Trait Trace 

Source
pub trait Trace: LoadState + Call
where Self::Error: FromEvmError<Self::Evm>,
{ // Provided methods fn inspect<'a>( &self, db: &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, evm_env: EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, tx_env: impl IntoTxEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx>, inspector: impl InspectorFor<Self::Evm, &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>>, ) -> Result<ExecResultAndState<ExecutionResult<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::HaltReason>>, Self::Error> { ... } fn spawn_trace_transaction_in_block<F, R>( &self, hash: FixedBytes<32>, config: TracingInspectorConfig, f: F, ) -> impl Future<Output = Result<Option<R>, Self::Error>> + Send where Self: LoadTransaction, F: FnOnce(TransactionInfo, TracingInspector, ExecResultAndState<ExecutionResult<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::HaltReason>>, State<StateProviderDatabase<StateProviderTraitObjWrapper>>) -> Result<R, Self::Error> + Send + 'static, R: Send + 'static { ... } fn spawn_trace_transaction_in_block_with_inspector<Insp, F, R>( &self, hash: FixedBytes<32>, inspector: Insp, f: F, ) -> impl Future<Output = Result<Option<R>, Self::Error>> + Send where Self: LoadTransaction, F: FnOnce(TransactionInfo, Insp, ExecResultAndState<ExecutionResult<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::HaltReason>>, State<StateProviderDatabase<StateProviderTraitObjWrapper>>) -> Result<R, Self::Error> + Send + 'static, Insp: for<'a> InspectorFor<Self::Evm, &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>> + Send + 'static, R: Send + 'static { ... } fn replay_block_until( &self, db: &mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, target_tx_index: usize, ) -> Result<(), Self::Error> { ... } fn inspect_transaction_in_block<'a>( &self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, db: &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, inspector: impl InspectorFor<Self::Evm, &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>>, target_tx_index: usize, target_tx_env: impl IntoTxEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx>, ) -> Result<(ExecResultAndState<ExecutionResult<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::HaltReason>>, EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>), Self::Error> { ... } fn trace_block_until<F, R>( &self, block_id: BlockId, block: Option<Arc<RecoveredBlock<<Self::Provider as BlockReader>::Block>>>, highest_index: Option<u64>, config: TracingInspectorConfig, f: F, ) -> impl Future<Output = Result<Option<Vec<R>>, Self::Error>> + Send where Self: LoadBlock, F: Fn(TransactionInfo, TracingCtx<'_, Recovered<&<Self::Provider as TransactionsProvider>::Transaction>, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Evm<&mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, TracingInspector>>) -> Result<R, Self::Error> + Send + 'static, R: Send + 'static { ... } fn trace_block_until_with_inspector<Setup, Insp, F, R>( &self, block_id: BlockId, block: Option<Arc<RecoveredBlock<<Self::Provider as BlockReader>::Block>>>, highest_index: Option<u64>, inspector_setup: Setup, f: F, ) -> impl Future<Output = Result<Option<Vec<R>>, Self::Error>> + Send where Self: LoadBlock, F: Fn(TransactionInfo, TracingCtx<'_, Recovered<&<Self::Provider as TransactionsProvider>::Transaction>, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Evm<&mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, Insp>>) -> Result<R, Self::Error> + Send + 'static, Setup: FnMut() -> Insp + Send + 'static, Insp: Clone + for<'a> InspectorFor<Self::Evm, &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>>, R: Send + 'static { ... } fn trace_block_with<F, R>( &self, block_id: BlockId, block: Option<Arc<RecoveredBlock<<Self::Provider as BlockReader>::Block>>>, config: TracingInspectorConfig, f: F, ) -> impl Future<Output = Result<Option<Vec<R>>, Self::Error>> + Send where Self: LoadBlock, F: Fn(TransactionInfo, TracingCtx<'_, Recovered<&<Self::Provider as TransactionsProvider>::Transaction>, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Evm<&mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, TracingInspector>>) -> Result<R, Self::Error> + Send + 'static, R: Send + 'static { ... } fn trace_block_inspector<Setup, Insp, F, R>( &self, block_id: BlockId, block: Option<Arc<RecoveredBlock<<Self::Provider as BlockReader>::Block>>>, insp_setup: Setup, f: F, ) -> impl Future<Output = Result<Option<Vec<R>>, Self::Error>> + Send where Self: LoadBlock, F: Fn(TransactionInfo, TracingCtx<'_, Recovered<&<Self::Provider as TransactionsProvider>::Transaction>, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Evm<&mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, Insp>>) -> Result<R, Self::Error> + Send + 'static, Setup: FnMut() -> Insp + Send + 'static, Insp: Clone + for<'a> InspectorFor<Self::Evm, &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>>, R: Send + 'static { ... } fn apply_pre_execution_changes( &self, block: &RecoveredBlock<<Self::Provider as BlockReader>::Block>, db: &mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, ) -> Result<(), Self::Error> { ... } }
Available on crate feature rpc only.
Expand description

Executes CPU heavy tasks.

Provided Methods§

Source

fn inspect<'a>( &self, db: &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, evm_env: EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, tx_env: impl IntoTxEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx>, inspector: impl InspectorFor<Self::Evm, &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>>, ) -> Result<ExecResultAndState<ExecutionResult<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::HaltReason>>, Self::Error>

Executes the TxEnvFor with reth_evm::EvmEnv against the given StateCacheDb without committing state changes.

Source

fn spawn_trace_transaction_in_block<F, R>( &self, hash: FixedBytes<32>, config: TracingInspectorConfig, f: F, ) -> impl Future<Output = Result<Option<R>, Self::Error>> + Send

Retrieves the transaction if it exists and returns its trace.

Before the transaction is traced, all previous transaction in the block are applied to the state by executing them first. The callback f is invoked with the ResultAndState after the transaction was executed and the database that points to the beginning of the transaction.

Note: Implementers should use a threadpool where blocking is allowed, such as BlockingTaskPool.

Source

fn spawn_trace_transaction_in_block_with_inspector<Insp, F, R>( &self, hash: FixedBytes<32>, inspector: Insp, f: F, ) -> impl Future<Output = Result<Option<R>, Self::Error>> + Send

Retrieves the transaction if it exists and returns its trace.

Before the transaction is traced, all previous transaction in the block are applied to the state by executing them first. The callback f is invoked with the ResultAndState after the transaction was executed and the database that points to the beginning of the transaction.

Note: Implementers should use a threadpool where blocking is allowed, such as BlockingTaskPool.

Source

fn replay_block_until( &self, db: &mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, target_tx_index: usize, ) -> Result<(), Self::Error>

Replays all transactions before the target transaction index.

All transactions before the target transaction are executed and their changes are written to the runtime db (StateCacheDb).

If the target index is greater than or equal to the block’s transaction count, all transactions are replayed.

Source

fn inspect_transaction_in_block<'a>( &self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, db: &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, inspector: impl InspectorFor<Self::Evm, &'a mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>>, target_tx_index: usize, target_tx_env: impl IntoTxEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx>, ) -> Result<(ExecResultAndState<ExecutionResult<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::HaltReason>>, EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>), Self::Error>

Replays all transactions before the target transaction without inspection, then executes the target transaction with the configured inspector, all on the given EVM.

Source

fn trace_block_until<F, R>( &self, block_id: BlockId, block: Option<Arc<RecoveredBlock<<Self::Provider as BlockReader>::Block>>>, highest_index: Option<u64>, config: TracingInspectorConfig, f: F, ) -> impl Future<Output = Result<Option<Vec<R>>, Self::Error>> + Send

Executes all transactions of a block up to a given index.

If a highest_index is given, this will only execute the first highest_index transactions, in other words, it will stop executing transactions after the highest_indexth transaction. If highest_index is None, all transactions are executed.

Source

fn trace_block_until_with_inspector<Setup, Insp, F, R>( &self, block_id: BlockId, block: Option<Arc<RecoveredBlock<<Self::Provider as BlockReader>::Block>>>, highest_index: Option<u64>, inspector_setup: Setup, f: F, ) -> impl Future<Output = Result<Option<Vec<R>>, Self::Error>> + Send

Executes all transactions of a block.

If a highest_index is given, this will only execute the first highest_index transactions, in other words, it will stop executing transactions after the highest_indexth transaction.

Note: This expect tx index to be 0-indexed, so the first transaction is at index 0.

This accepts a inspector_setup closure that returns the inspector to be used for tracing the transactions.

Source

fn trace_block_with<F, R>( &self, block_id: BlockId, block: Option<Arc<RecoveredBlock<<Self::Provider as BlockReader>::Block>>>, config: TracingInspectorConfig, f: F, ) -> impl Future<Output = Result<Option<Vec<R>>, Self::Error>> + Send

Executes all transactions of a block and returns a list of callback results invoked for each transaction in the block.

This

  1. fetches all transactions of the block
  2. configures the EVM env
  3. loops over all transactions and executes them
  4. calls the callback with the transaction info, the execution result, the changed state after the transaction StateCacheDb and the database that points to the state right before the transaction.
Source

fn trace_block_inspector<Setup, Insp, F, R>( &self, block_id: BlockId, block: Option<Arc<RecoveredBlock<<Self::Provider as BlockReader>::Block>>>, insp_setup: Setup, f: F, ) -> impl Future<Output = Result<Option<Vec<R>>, Self::Error>> + Send

Executes all transactions of a block and returns a list of callback results invoked for each transaction in the block.

This

  1. fetches all transactions of the block
  2. configures the EVM env
  3. loops over all transactions and executes them
  4. calls the callback with the transaction info, the execution result, the changed state after the transaction EvmState and the database that points to the state right before the transaction, in other words the state the transaction was executed on: changed_state = tx(cached_state)

This accepts a inspector_setup closure that returns the inspector to be used for tracing a transaction. This is invoked for each transaction.

Source

fn apply_pre_execution_changes( &self, block: &RecoveredBlock<<Self::Provider as BlockReader>::Block>, db: &mut State<StateProviderDatabase<StateProviderTraitObjWrapper>>, ) -> Result<(), Self::Error>

Applies chain-specific state transitions required before executing a block.

Note: This should only be called when tracing an entire block vs individual transactions. When tracing transactions on top of an already committed block state, those transitions are already applied.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<N, Rpc> Trace for EthApi<N, Rpc>
where EthApiError: FromEvmError<<N as RpcNodeCore>::Evm>, Rpc: RpcConvert<Primitives = <N as RpcNodeCore>::Primitives, Error = EthApiError, Evm = <N as RpcNodeCore>::Evm>, N: RpcNodeCore,