reth_engine_tree

Trait BlockchainTreeEngine

pub trait BlockchainTreeEngine:
    BlockchainTreeViewer
    + Send
    + Sync {
    // Required methods
    fn buffer_block(
        &self,
        block: SealedBlockWithSenders,
    ) -> Result<(), InsertBlockError>;
    fn insert_block(
        &self,
        block: SealedBlockWithSenders,
        validation_kind: BlockValidationKind,
    ) -> Result<InsertPayloadOk, InsertBlockError>;
    fn finalize_block(&self, finalized_block: u64) -> Result<(), ProviderError>;
    fn connect_buffered_blocks_to_canonical_hashes_and_finalize(
        &self,
        last_finalized_block: u64,
    ) -> Result<(), CanonicalError>;
    fn update_block_hashes_and_clear_buffered(
        &self,
    ) -> Result<BTreeMap<u64, FixedBytes<32>>, CanonicalError>;
    fn connect_buffered_blocks_to_canonical_hashes(
        &self,
    ) -> Result<(), CanonicalError>;
    fn make_canonical(
        &self,
        block_hash: FixedBytes<32>,
    ) -> Result<CanonicalOutcome, CanonicalError>;

    // Provided methods
    fn insert_block_without_senders(
        &self,
        block: SealedBlock,
        validation_kind: BlockValidationKind,
    ) -> Result<InsertPayloadOk, InsertBlockError> { ... }
    fn buffer_block_without_senders(
        &self,
        block: SealedBlock,
    ) -> Result<(), InsertBlockError> { ... }
}
Expand description

Re-export of the blockchain tree API.

Required Methods§

fn buffer_block( &self, block: SealedBlockWithSenders, ) -> Result<(), InsertBlockError>

Buffer block with senders

fn insert_block( &self, block: SealedBlockWithSenders, validation_kind: BlockValidationKind, ) -> Result<InsertPayloadOk, InsertBlockError>

Inserts block with senders

The validation_kind parameter controls which validation checks are performed.

Caution: If the block was received from the consensus layer, this should always be called with BlockValidationKind::Exhaustive to validate the state root, if possible to adhere to the engine API spec.

fn finalize_block(&self, finalized_block: u64) -> Result<(), ProviderError>

Finalize blocks up until and including finalized_block, and remove them from the tree.

fn connect_buffered_blocks_to_canonical_hashes_and_finalize( &self, last_finalized_block: u64, ) -> Result<(), CanonicalError>

Reads the last N canonical hashes from the database and updates the block indices of the tree by attempting to connect the buffered blocks to canonical hashes.

N is the maximum of max_reorg_depth and the number of block hashes needed to satisfy the BLOCKHASH opcode in the EVM.

§Note

This finalizes last_finalized_block prior to reading the canonical hashes (using BlockchainTreeEngine::finalize_block).

fn update_block_hashes_and_clear_buffered( &self, ) -> Result<BTreeMap<u64, FixedBytes<32>>, CanonicalError>

Update all block hashes. iterate over present and new list of canonical hashes and compare them. Remove all mismatches, disconnect them, removes all chains and clears all buffered blocks before the tip.

fn connect_buffered_blocks_to_canonical_hashes( &self, ) -> Result<(), CanonicalError>

Reads the last N canonical hashes from the database and updates the block indices of the tree by attempting to connect the buffered blocks to canonical hashes.

N is the maximum of max_reorg_depth and the number of block hashes needed to satisfy the BLOCKHASH opcode in the EVM.

fn make_canonical( &self, block_hash: FixedBytes<32>, ) -> Result<CanonicalOutcome, CanonicalError>

Make a block and its parent chain part of the canonical chain by committing it to the database.

§Note

This unwinds the database if necessary, i.e. if parts of the canonical chain have been re-orged.

§Returns

Returns Ok if the blocks were canonicalized, or if the blocks were already canonical.

Provided Methods§

fn insert_block_without_senders( &self, block: SealedBlock, validation_kind: BlockValidationKind, ) -> Result<InsertPayloadOk, InsertBlockError>

Recover senders and call BlockchainTreeEngine::insert_block.

This will recover all senders of the transactions in the block first, and then try to insert the block.

fn buffer_block_without_senders( &self, block: SealedBlock, ) -> Result<(), InsertBlockError>

Recover senders and call BlockchainTreeEngine::buffer_block.

This will recover all senders of the transactions in the block first, and then try to buffer the block.

Implementations on Foreign Types§

Source§

impl BlockchainTreeEngine for NoopBlockchainTree

Source§

fn buffer_block( &self, _block: SealedBlockWithSenders, ) -> Result<(), InsertBlockError>

Source§

fn insert_block( &self, block: SealedBlockWithSenders, _validation_kind: BlockValidationKind, ) -> Result<InsertPayloadOk, InsertBlockError>

Source§

fn finalize_block(&self, _finalized_block: u64) -> Result<(), ProviderError>

Source§

fn connect_buffered_blocks_to_canonical_hashes_and_finalize( &self, _last_finalized_block: u64, ) -> Result<(), CanonicalError>

Source§

fn update_block_hashes_and_clear_buffered( &self, ) -> Result<BTreeMap<u64, FixedBytes<32>>, CanonicalError>

Source§

fn connect_buffered_blocks_to_canonical_hashes( &self, ) -> Result<(), CanonicalError>

Source§

fn make_canonical( &self, block_hash: FixedBytes<32>, ) -> Result<CanonicalOutcome, CanonicalError>

§

impl<N> BlockchainTreeEngine for BlockchainProvider<N>
where N: ProviderNodeTypes,

§

fn buffer_block( &self, block: SealedBlockWithSenders, ) -> Result<(), InsertBlockError>

§

fn insert_block( &self, block: SealedBlockWithSenders, validation_kind: BlockValidationKind, ) -> Result<InsertPayloadOk, InsertBlockError>

§

fn finalize_block(&self, finalized_block: u64) -> Result<(), ProviderError>

§

fn connect_buffered_blocks_to_canonical_hashes_and_finalize( &self, last_finalized_block: u64, ) -> Result<(), CanonicalError>

§

fn update_block_hashes_and_clear_buffered( &self, ) -> Result<BTreeMap<u64, FixedBytes<32>>, CanonicalError>

§

fn connect_buffered_blocks_to_canonical_hashes( &self, ) -> Result<(), CanonicalError>

§

fn make_canonical( &self, block_hash: FixedBytes<32>, ) -> Result<CanonicalOutcome, CanonicalError>

Source§

impl<N, E> BlockchainTreeEngine for ShareableBlockchainTree<N, E>
where N: TreeNodeTypes, E: BlockExecutorProvider,

Source§

fn buffer_block( &self, block: SealedBlockWithSenders, ) -> Result<(), InsertBlockError>

Source§

fn insert_block( &self, block: SealedBlockWithSenders, validation_kind: BlockValidationKind, ) -> Result<InsertPayloadOk, InsertBlockError>

Source§

fn finalize_block(&self, finalized_block: u64) -> Result<(), ProviderError>

Source§

fn connect_buffered_blocks_to_canonical_hashes_and_finalize( &self, last_finalized_block: u64, ) -> Result<(), CanonicalError>

Source§

fn update_block_hashes_and_clear_buffered( &self, ) -> Result<BTreeMap<u64, FixedBytes<32>>, CanonicalError>

Source§

fn connect_buffered_blocks_to_canonical_hashes( &self, ) -> Result<(), CanonicalError>

Source§

fn make_canonical( &self, block_hash: FixedBytes<32>, ) -> Result<CanonicalOutcome, CanonicalError>

Implementors§