chore(storage): use chain spec from provider field (#7723)

This commit is contained in:
Alexey Shekhirin
2024-04-18 16:23:27 +02:00
committed by GitHub
parent 58cb524d73
commit 4ca86fb4d2
5 changed files with 10 additions and 17 deletions

View File

@ -709,7 +709,6 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
/// Return range of blocks and its execution result
fn get_take_block_range<const TAKE: bool>(
&self,
chain_spec: &ChainSpec,
range: impl RangeBounds<BlockNumber> + Clone,
) -> ProviderResult<Vec<SealedBlockWithSenders>> {
// For block we need Headers, Bodies, Uncles, withdrawals, Transactions, Signers
@ -768,7 +767,8 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
};
// withdrawal can be missing
let shanghai_is_active = chain_spec.is_shanghai_active_at_timestamp(header.timestamp);
let shanghai_is_active =
self.chain_spec.is_shanghai_active_at_timestamp(header.timestamp);
let mut withdrawals = Some(Withdrawals::default());
if shanghai_is_active {
if let Some((block_number, _)) = block_withdrawals.as_ref() {
@ -2376,7 +2376,6 @@ impl<TX: DbTxMut + DbTx> BlockExecutionWriter for DatabaseProvider<TX> {
/// Return range of blocks and its execution result
fn get_or_take_block_and_execution_range<const TAKE: bool>(
&self,
chain_spec: &ChainSpec,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Chain> {
if TAKE {
@ -2447,7 +2446,7 @@ impl<TX: DbTxMut + DbTx> BlockExecutionWriter for DatabaseProvider<TX> {
}
// get blocks
let blocks = self.get_take_block_range::<TAKE>(chain_spec, range.clone())?;
let blocks = self.get_take_block_range::<TAKE>(range.clone())?;
let unwind_to = blocks.first().map(|b| b.number.saturating_sub(1));
// get execution res
let execution_state = self.unwind_or_peek_state::<TAKE>(range.clone())?;

View File

@ -6,8 +6,8 @@ use auto_impl::auto_impl;
use reth_db::models::StoredBlockBodyIndices;
use reth_interfaces::provider::ProviderResult;
use reth_primitives::{
Block, BlockHashOrNumber, BlockId, BlockNumber, BlockNumberOrTag, BlockWithSenders, ChainSpec,
Header, PruneModes, Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader, B256,
Block, BlockHashOrNumber, BlockId, BlockNumber, BlockNumberOrTag, BlockWithSenders, Header,
PruneModes, Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader, B256,
};
use reth_trie::{updates::TrieUpdates, HashedPostState};
use std::ops::RangeInclusive;
@ -268,25 +268,22 @@ pub trait BlockExecutionWriter: BlockWriter + BlockReader + Send + Sync {
/// Get range of blocks and its execution result
fn get_block_and_execution_range(
&self,
chain_spec: &ChainSpec,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Chain> {
self.get_or_take_block_and_execution_range::<false>(chain_spec, range)
self.get_or_take_block_and_execution_range::<false>(range)
}
/// Take range of blocks and its execution result
fn take_block_and_execution_range(
&self,
chain_spec: &ChainSpec,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Chain> {
self.get_or_take_block_and_execution_range::<true>(chain_spec, range)
self.get_or_take_block_and_execution_range::<true>(range)
}
/// Return range of blocks and its execution result
fn get_or_take_block_and_execution_range<const TAKE: bool>(
&self,
chain_spec: &ChainSpec,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Chain>;
}