feat(engine, tree): witness invalid block hook (#10685)

This commit is contained in:
Alexey Shekhirin
2024-09-06 12:56:03 +01:00
committed by GitHub
parent db7834dd51
commit 3ec5d373c1
15 changed files with 393 additions and 100 deletions

View File

@ -13,7 +13,10 @@ workspace = true
[dependencies]
# reth
reth-chainspec.workspace = true
reth-execution-types.workspace = true
reth-payload-primitives.workspace = true
reth-primitives.workspace = true
reth-trie.workspace = true
# misc
serde.workspace = true
serde.workspace = true

View File

@ -0,0 +1,36 @@
use reth_execution_types::BlockExecutionOutput;
use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader, B256};
use reth_trie::updates::TrieUpdates;
/// An invalid block hook.
pub trait InvalidBlockHook: Send + Sync {
/// Invoked when an invalid block is encountered.
fn on_invalid_block(
&self,
parent_header: &SealedHeader,
block: &SealedBlockWithSenders,
output: &BlockExecutionOutput<Receipt>,
trie_updates: Option<(&TrieUpdates, B256)>,
);
}
impl<F> InvalidBlockHook for F
where
F: Fn(
&SealedHeader,
&SealedBlockWithSenders,
&BlockExecutionOutput<Receipt>,
Option<(&TrieUpdates, B256)>,
) + Send
+ Sync,
{
fn on_invalid_block(
&self,
parent_header: &SealedHeader,
block: &SealedBlockWithSenders,
output: &BlockExecutionOutput<Receipt>,
trie_updates: Option<(&TrieUpdates, B256)>,
) {
self(parent_header, block, output, trie_updates)
}
}

View File

@ -8,6 +8,9 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
mod invalid_block_hook;
pub use invalid_block_hook::InvalidBlockHook;
use reth_chainspec::ChainSpec;
pub use reth_payload_primitives::{
BuiltPayload, EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes,