From f0051e10161cb045b82d885df23f0f8fd42e1de4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 31 Jul 2025 13:37:40 +0200 Subject: [PATCH] fix: use primitive header type for fetching header (#17691) --- crates/stages/stages/src/stages/execution.rs | 27 ++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/stages/stages/src/stages/execution.rs b/crates/stages/stages/src/stages/execution.rs index 50313f24d4..08e969c479 100644 --- a/crates/stages/stages/src/stages/execution.rs +++ b/crates/stages/stages/src/stages/execution.rs @@ -1,5 +1,5 @@ use crate::stages::MERKLE_STAGE_DEFAULT_INCREMENTAL_THRESHOLD; -use alloy_consensus::{BlockHeader, Header}; +use alloy_consensus::BlockHeader; use alloy_primitives::BlockNumber; use num_traits::Zero; use reth_config::config::ExecutionConfig; @@ -256,8 +256,9 @@ where + BlockReader< Block = ::Block, Header = ::BlockHeader, - > + StaticFileProviderFactory - + StatsReader + > + StaticFileProviderFactory< + Primitives: NodePrimitives, + > + StatsReader + BlockHashReader + StateWriter::Receipt> + StateCommitmentProvider, @@ -560,12 +561,15 @@ where } } -fn execution_checkpoint( +fn execution_checkpoint( provider: &StaticFileProvider, start_block: BlockNumber, max_block: BlockNumber, checkpoint: StageCheckpoint, -) -> Result { +) -> Result +where + N: NodePrimitives, +{ Ok(match checkpoint.execution_stage_checkpoint() { // If checkpoint block range fully matches our range, // we take the previously used stage checkpoint as-is. @@ -628,10 +632,13 @@ fn execution_checkpoint( } /// Calculates the total amount of gas used from the headers in the given range. -pub fn calculate_gas_used_from_headers( +pub fn calculate_gas_used_from_headers( provider: &StaticFileProvider, range: RangeInclusive, -) -> Result { +) -> Result +where + N: NodePrimitives, +{ debug!(target: "sync::stages::execution", ?range, "Calculating gas used from headers"); let mut gas_total = 0; @@ -641,10 +648,10 @@ pub fn calculate_gas_used_from_headers( for entry in provider.fetch_range_iter( StaticFileSegment::Headers, *range.start()..*range.end() + 1, - |cursor, number| cursor.get_one::>(number.into()), + |cursor, number| cursor.get_one::>(number.into()), )? { - let Header { gas_used, .. } = entry?; - gas_total += gas_used; + let entry = entry?; + gas_total += entry.gas_used(); } let duration = start.elapsed();