mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
added SealedHeaderFor alias to validate.rs and without_evm.rs (#14103)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -6629,6 +6629,7 @@ dependencies = [
|
|||||||
"reth-node-events",
|
"reth-node-events",
|
||||||
"reth-node-metrics",
|
"reth-node-metrics",
|
||||||
"reth-primitives",
|
"reth-primitives",
|
||||||
|
"reth-primitives-traits",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
"reth-prune",
|
"reth-prune",
|
||||||
"reth-prune-types",
|
"reth-prune-types",
|
||||||
|
|||||||
@ -48,6 +48,7 @@ reth-static-file.workspace = true
|
|||||||
reth-trie = { workspace = true, features = ["metrics"] }
|
reth-trie = { workspace = true, features = ["metrics"] }
|
||||||
reth-trie-db = { workspace = true, features = ["metrics"] }
|
reth-trie-db = { workspace = true, features = ["metrics"] }
|
||||||
reth-trie-common = { workspace = true, optional = true }
|
reth-trie-common = { workspace = true, optional = true }
|
||||||
|
reth-primitives-traits.workspace = true
|
||||||
|
|
||||||
# ethereum
|
# ethereum
|
||||||
alloy-eips.workspace = true
|
alloy-eips.workspace = true
|
||||||
@ -109,4 +110,5 @@ arbitrary = [
|
|||||||
"reth-stages-types?/arbitrary",
|
"reth-stages-types?/arbitrary",
|
||||||
"reth-trie-common?/arbitrary",
|
"reth-trie-common?/arbitrary",
|
||||||
"alloy-consensus/arbitrary",
|
"alloy-consensus/arbitrary",
|
||||||
|
"reth-primitives-traits/arbitrary",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -4,6 +4,7 @@ use alloy_rlp::Decodable;
|
|||||||
use reth_codecs::Compact;
|
use reth_codecs::Compact;
|
||||||
use reth_node_builder::NodePrimitives;
|
use reth_node_builder::NodePrimitives;
|
||||||
use reth_primitives::{SealedBlock, SealedHeader, StaticFileSegment};
|
use reth_primitives::{SealedBlock, SealedHeader, StaticFileSegment};
|
||||||
|
use reth_primitives_traits::SealedHeaderFor;
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
providers::StaticFileProvider, BlockWriter, StageCheckpointWriter, StaticFileProviderFactory,
|
providers::StaticFileProvider, BlockWriter, StageCheckpointWriter, StaticFileProviderFactory,
|
||||||
StaticFileWriter, StorageLocation,
|
StaticFileWriter, StorageLocation,
|
||||||
@ -59,7 +60,7 @@ where
|
|||||||
/// height.
|
/// height.
|
||||||
fn append_first_block<Provider>(
|
fn append_first_block<Provider>(
|
||||||
provider_rw: &Provider,
|
provider_rw: &Provider,
|
||||||
header: &SealedHeader<<Provider::Primitives as NodePrimitives>::BlockHeader>,
|
header: &SealedHeaderFor<Provider::Primitives>,
|
||||||
total_difficulty: U256,
|
total_difficulty: U256,
|
||||||
) -> Result<(), eyre::Error>
|
) -> Result<(), eyre::Error>
|
||||||
where
|
where
|
||||||
|
|||||||
@ -18,8 +18,10 @@ use reth_engine_primitives::PayloadValidator;
|
|||||||
use reth_errors::{BlockExecutionError, ConsensusError, ProviderError};
|
use reth_errors::{BlockExecutionError, ConsensusError, ProviderError};
|
||||||
use reth_evm::execute::{BlockExecutorProvider, Executor};
|
use reth_evm::execute::{BlockExecutorProvider, Executor};
|
||||||
use reth_metrics::{metrics, metrics::Gauge, Metrics};
|
use reth_metrics::{metrics, metrics::Gauge, Metrics};
|
||||||
use reth_primitives::{GotExpected, NodePrimitives, RecoveredBlock, SealedHeader};
|
use reth_primitives::{GotExpected, NodePrimitives, RecoveredBlock};
|
||||||
use reth_primitives_traits::{constants::GAS_LIMIT_BOUND_DIVISOR, BlockBody, SealedBlock};
|
use reth_primitives_traits::{
|
||||||
|
constants::GAS_LIMIT_BOUND_DIVISOR, BlockBody, SealedBlock, SealedHeaderFor,
|
||||||
|
};
|
||||||
use reth_provider::{BlockExecutionOutput, BlockReaderIdExt, StateProviderFactory};
|
use reth_provider::{BlockExecutionOutput, BlockReaderIdExt, StateProviderFactory};
|
||||||
use reth_revm::{cached::CachedReads, database::StateProviderDatabase};
|
use reth_revm::{cached::CachedReads, database::StateProviderDatabase};
|
||||||
use reth_rpc_api::BlockSubmissionValidationApiServer;
|
use reth_rpc_api::BlockSubmissionValidationApiServer;
|
||||||
@ -144,7 +146,6 @@ where
|
|||||||
}
|
}
|
||||||
self.consensus.validate_header_against_parent(block.sealed_header(), &latest_header)?;
|
self.consensus.validate_header_against_parent(block.sealed_header(), &latest_header)?;
|
||||||
self.validate_gas_limit(registered_gas_limit, &latest_header, block.sealed_header())?;
|
self.validate_gas_limit(registered_gas_limit, &latest_header, block.sealed_header())?;
|
||||||
|
|
||||||
let latest_header_hash = latest_header.hash();
|
let latest_header_hash = latest_header.hash();
|
||||||
let state_provider = self.provider.state_by_block_hash(latest_header_hash)?;
|
let state_provider = self.provider.state_by_block_hash(latest_header_hash)?;
|
||||||
|
|
||||||
@ -191,10 +192,10 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensures that fields of [`BidTrace`] match the fields of the [`SealedHeader`].
|
/// Ensures that fields of [`BidTrace`] match the fields of the [`SealedHeaderFor`].
|
||||||
fn validate_message_against_header(
|
fn validate_message_against_header(
|
||||||
&self,
|
&self,
|
||||||
header: &SealedHeader<<E::Primitives as NodePrimitives>::BlockHeader>,
|
header: &SealedHeaderFor<E::Primitives>,
|
||||||
message: &BidTrace,
|
message: &BidTrace,
|
||||||
) -> Result<(), ValidationApiError> {
|
) -> Result<(), ValidationApiError> {
|
||||||
if header.hash() != message.block_hash {
|
if header.hash() != message.block_hash {
|
||||||
@ -229,8 +230,8 @@ where
|
|||||||
fn validate_gas_limit(
|
fn validate_gas_limit(
|
||||||
&self,
|
&self,
|
||||||
registered_gas_limit: u64,
|
registered_gas_limit: u64,
|
||||||
parent_header: &SealedHeader<<E::Primitives as NodePrimitives>::BlockHeader>,
|
parent_header: &SealedHeaderFor<E::Primitives>,
|
||||||
header: &SealedHeader<<E::Primitives as NodePrimitives>::BlockHeader>,
|
header: &SealedHeaderFor<E::Primitives>,
|
||||||
) -> Result<(), ValidationApiError> {
|
) -> Result<(), ValidationApiError> {
|
||||||
let max_gas_limit =
|
let max_gas_limit =
|
||||||
parent_header.gas_limit() + parent_header.gas_limit() / GAS_LIMIT_BOUND_DIVISOR - 1;
|
parent_header.gas_limit() + parent_header.gas_limit() / GAS_LIMIT_BOUND_DIVISOR - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user