1010
1111use reth_consensus:: { Consensus , ConsensusError , PostExecutionInput } ;
1212use reth_consensus_common:: validation:: {
13- validate_4844_header_standalone, validate_against_parent_eip1559_base_fee ,
14- validate_against_parent_hash_number , validate_against_parent_timestamp ,
15- validate_block_pre_execution , validate_header_base_fee , validate_header_extradata ,
16- validate_header_gas,
13+ validate_4844_header_standalone, validate_against_parent_4844 ,
14+ validate_against_parent_eip1559_base_fee , validate_against_parent_hash_number ,
15+ validate_against_parent_timestamp , validate_block_pre_execution , validate_header_base_fee ,
16+ validate_header_extradata , validate_header_gas,
1717} ;
1818use reth_primitives:: {
19- constants:: MINIMUM_GAS_LIMIT , eip4844:: calculate_excess_blob_gas, BlockWithSenders , Chain ,
20- ChainSpec , GotExpected , Hardfork , Header , SealedBlock , SealedHeader , EMPTY_OMMER_ROOT_HASH ,
21- U256 ,
19+ constants:: MINIMUM_GAS_LIMIT , BlockWithSenders , Chain , ChainSpec , Hardfork , Header ,
20+ SealedBlock , SealedHeader , EMPTY_OMMER_ROOT_HASH , U256 ,
2221} ;
2322use std:: { sync:: Arc , time:: SystemTime } ;
2423
@@ -40,41 +39,6 @@ impl EthBeaconConsensus {
4039 Self { chain_spec }
4140 }
4241
43- /// Validates that the EIP-4844 header fields are correct with respect to the parent block. This
44- /// ensures that the `blob_gas_used` and `excess_blob_gas` fields exist in the child header, and
45- /// that the `excess_blob_gas` field matches the expected `excess_blob_gas` calculated from the
46- /// parent header fields.
47- pub fn validate_against_parent_4844 (
48- header : & SealedHeader ,
49- parent : & SealedHeader ,
50- ) -> Result < ( ) , ConsensusError > {
51- // From [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844#header-extension):
52- //
53- // > For the first post-fork block, both parent.blob_gas_used and parent.excess_blob_gas
54- // > are evaluated as 0.
55- //
56- // This means in the first post-fork block, calculate_excess_blob_gas will return 0.
57- let parent_blob_gas_used = parent. blob_gas_used . unwrap_or ( 0 ) ;
58- let parent_excess_blob_gas = parent. excess_blob_gas . unwrap_or ( 0 ) ;
59-
60- if header. blob_gas_used . is_none ( ) {
61- return Err ( ConsensusError :: BlobGasUsedMissing )
62- }
63- let excess_blob_gas = header. excess_blob_gas . ok_or ( ConsensusError :: ExcessBlobGasMissing ) ?;
64-
65- let expected_excess_blob_gas =
66- calculate_excess_blob_gas ( parent_excess_blob_gas, parent_blob_gas_used) ;
67- if expected_excess_blob_gas != excess_blob_gas {
68- return Err ( ConsensusError :: ExcessBlobGasDiff {
69- diff : GotExpected { got : excess_blob_gas, expected : expected_excess_blob_gas } ,
70- parent_excess_blob_gas,
71- parent_blob_gas_used,
72- } )
73- }
74-
75- Ok ( ( ) )
76- }
77-
7842 /// Checks the gas limit for consistency between parent and self headers.
7943 ///
8044 /// The maximum allowable difference between self and parent gas limits is determined by the
@@ -175,7 +139,7 @@ impl Consensus for EthBeaconConsensus {
175139
176140 // ensure that the blob gas fields for this block
177141 if self . chain_spec . is_cancun_active_at_timestamp ( header. timestamp ) {
178- Self :: validate_against_parent_4844 ( header, parent) ?;
142+ validate_against_parent_4844 ( header, parent) ?;
179143 }
180144
181145 Ok ( ( ) )
0 commit comments