feat: add header AT to provider (#13030)

Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
This commit is contained in:
Matthias Seitz
2024-12-02 14:24:48 +01:00
committed by GitHub
parent 519a10ae99
commit 332cce1f9b
71 changed files with 669 additions and 434 deletions

View File

@ -29,6 +29,7 @@ reth-transaction-pool.workspace = true
reth-stages-api.workspace = true
# alloy
alloy-consensus.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types-engine.workspace = true

View File

@ -1,5 +1,6 @@
//! Contains the implementation of the mining mode for the local engine.
use alloy_consensus::BlockHeader;
use alloy_primitives::{TxHash, B256};
use alloy_rpc_types_engine::{CancunPayloadFields, ExecutionPayloadSidecar, ForkchoiceState};
use eyre::OptionExt;
@ -114,7 +115,7 @@ where
to_engine,
mode,
payload_builder,
last_timestamp: latest_header.timestamp,
last_timestamp: latest_header.timestamp(),
last_block_hashes: vec![latest_header.hash()],
};

View File

@ -540,9 +540,13 @@ impl<N, P: Debug, E: Debug, T: EngineTypes + Debug, V: Debug> std::fmt::Debug
impl<N, P, E, T, V> EngineApiTreeHandler<N, P, E, T, V>
where
N: NodePrimitives<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>,
N: NodePrimitives<
Block = reth_primitives::Block,
BlockHeader = reth_primitives::Header,
Receipt = reth_primitives::Receipt,
>,
P: DatabaseProviderFactory
+ BlockReader<Block = reth_primitives::Block>
+ BlockReader<Block = N::Block, Header = N::BlockHeader>
+ StateProviderFactory
+ StateReader<Receipt = reth_primitives::Receipt>
+ Clone
@ -1357,7 +1361,7 @@ where
// update the tracked chain height, after backfill sync both the canonical height and
// persisted height are the same
self.state.tree_state.set_canonical_head(new_head.num_hash());
self.persistence_state.finish(new_head.hash(), new_head.number);
self.persistence_state.finish(new_head.hash(), new_head.number());
// update the tracked canonical head
self.canonical_in_memory_state.set_canonical_head(new_head);
@ -1622,7 +1626,7 @@ where
// the hash could belong to an unknown block or a persisted block
if let Some(header) = self.provider.header(&hash)? {
debug!(target: "engine::tree", %hash, number = %header.number, "found canonical state for block in database");
debug!(target: "engine::tree", %hash, number = %header.number(), "found canonical state for block in database");
// the block is known and persisted
let historical = self.provider.state_by_block_hash(hash)?;
return Ok(Some(historical))