feat(evm): executor hooks

This commit is contained in:
Alexey Shekhirin
2024-07-16 16:14:26 +01:00
parent f93029719b
commit 6e79dd44d5

View File

@@ -179,6 +179,27 @@ pub trait BlockExecutorProvider: Send + Sync + Clone + Unpin + 'static {
DB: Database<Error: Into<ProviderError> + Display>;
}
/// Executor hooks to extend the behaviour of [`Executor`].
///
/// The hooks are inserted in [`Executor::execute`] lifecycle and called in the following order:
/// 1. [`ExecutorHooks::pre_state_changes`]
/// 1. Executor does pre-block state changes, such as system contract calls.
/// 1. [`ExecutorHooks::pre_transactions`]
/// 1. Executor executes transactions
/// 1. [`ExecutorHooks::post_transactins`]
/// 1. Executor does post-block state changes, such as system contract calls.
/// 1. [`ExecutorHooks::post_state_changes`]
pub trait ExecutorHooks {
/// Called before any pre-block state changes are applied, such as system contract calls.
fn pre_state_changes(&self);
/// Called before any transactions are executed.
fn pre_transactions(&self);
/// Called after all transactions are executed.
fn post_transactins(&self);
/// Called after all post-block state changes are applied, such as system contract calls.
fn post_state_changes(&self);
}
#[cfg(test)]
mod tests {
use super::*;