mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: check versioned hash version for EIP-4844 transactions (#6601)
This commit is contained in:
@ -139,14 +139,14 @@ impl TxEip4844 {
|
||||
// convert to KzgCommitment
|
||||
let commitment = KzgCommitment::from(*commitment.deref());
|
||||
|
||||
// Calculate the versioned hash
|
||||
//
|
||||
// TODO: should this method distinguish the type of validation failure? For example
|
||||
// whether a certain versioned hash does not match, or whether the blob proof
|
||||
// validation failed?
|
||||
// calculate & verify the versioned hash
|
||||
// https://eips.ethereum.org/EIPS/eip-4844#execution-layer-validation
|
||||
let calculated_versioned_hash = kzg_to_versioned_hash(commitment);
|
||||
if *versioned_hash != calculated_versioned_hash {
|
||||
return Err(BlobTransactionValidationError::InvalidProof)
|
||||
return Err(BlobTransactionValidationError::WrongVersionedHash {
|
||||
have: *versioned_hash,
|
||||
expected: calculated_versioned_hash,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ use crate::{
|
||||
kzg::{
|
||||
self, Blob, Bytes48, KzgSettings, BYTES_PER_BLOB, BYTES_PER_COMMITMENT, BYTES_PER_PROOF,
|
||||
},
|
||||
Signature, Transaction, TransactionSigned, TxEip4844, TxHash, EIP4844_TX_TYPE_ID,
|
||||
Signature, Transaction, TransactionSigned, TxEip4844, TxHash, B256, EIP4844_TX_TYPE_ID,
|
||||
};
|
||||
use alloy_rlp::{Decodable, Encodable, Error as RlpError, Header};
|
||||
use bytes::BufMut;
|
||||
@ -35,6 +35,14 @@ pub enum BlobTransactionValidationError {
|
||||
/// The inner transaction is not a blob transaction.
|
||||
#[error("unable to verify proof for non blob transaction: {0}")]
|
||||
NotBlobTransaction(u8),
|
||||
/// The versioned hash is incorrect.
|
||||
#[error("wrong versioned hash: have {have}, expected {expected}")]
|
||||
WrongVersionedHash {
|
||||
/// The versioned hash we got
|
||||
have: B256,
|
||||
/// The versioned hash we expected
|
||||
expected: B256,
|
||||
},
|
||||
}
|
||||
|
||||
/// A response to `GetPooledTransactions` that includes blob data, their commitments, and their
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
//! DAO FOrk related constants from [EIP-779](https://eips.ethereum.org/EIPS/eip-779).
|
||||
//! DAO Fork related constants from [EIP-779](https://eips.ethereum.org/EIPS/eip-779).
|
||||
//! It happened on Ethereum block 1_920_000
|
||||
|
||||
use reth_primitives::{address, Address};
|
||||
|
||||
@ -143,10 +143,10 @@ pub enum Eip4844PoolTransactionError {
|
||||
/// Thrown if we're unable to find the blob for a transaction that was previously extracted
|
||||
#[error("blob sidecar not found for EIP4844 transaction")]
|
||||
MissingEip4844BlobSidecar,
|
||||
/// Thrown if an EIP-4844 without any blobs arrives
|
||||
/// Thrown if an EIP-4844 transaction without any blobs arrives
|
||||
#[error("blobless blob transaction")]
|
||||
NoEip4844Blobs,
|
||||
/// Thrown if an EIP-4844 without any blobs arrives
|
||||
/// Thrown if an EIP-4844 transaction without any blobs arrives
|
||||
#[error("too many blobs in transaction: have {have}, permitted {permitted}")]
|
||||
TooManyEip4844Blobs {
|
||||
/// Number of blobs the transaction has
|
||||
|
||||
Reference in New Issue
Block a user