feat: add new crate op-beacon-core (#7848)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Rupam Dey
2024-04-26 15:45:07 +05:30
committed by GitHub
parent 4278bc24ca
commit d833f1aed9
5 changed files with 154 additions and 2 deletions

View File

@ -3,7 +3,10 @@
use reth_consensus::ConsensusError;
use reth_interfaces::RethResult;
use reth_primitives::{
constants::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK},
constants::{
eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK},
MAXIMUM_EXTRA_DATA_SIZE,
},
BlockNumber, ChainSpec, GotExpected, Hardfork, Header, InvalidTransactionError, SealedBlock,
SealedHeader, Transaction, TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxEip4844,
TxLegacy,
@ -321,6 +324,18 @@ pub fn validate_4844_header_standalone(header: &SealedHeader) -> Result<(), Cons
Ok(())
}
/// Validates the header's extradata according to the beacon consensus rules.
///
/// From yellow paper: extraData: An arbitrary byte array containing data relevant to this block.
/// This must be 32 bytes or fewer; formally Hx.
pub fn validate_header_extradata(header: &Header) -> Result<(), ConsensusError> {
if header.extra_data.len() > MAXIMUM_EXTRA_DATA_SIZE {
Err(ConsensusError::ExtraDataExceedsMax { len: header.extra_data.len() })
} else {
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;