mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(engine, tree): witness invalid block hook (#10685)
This commit is contained in:
@ -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
|
||||
|
||||
36
crates/engine/primitives/src/invalid_block_hook.rs
Normal file
36
crates/engine/primitives/src/invalid_block_hook.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user