Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check versioned hash version for EIP-4844 transactions #6601

Merged
merged 7 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/primitives/src/transaction/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}

Expand Down
10 changes: 9 additions & 1 deletion crates/primitives/src/transaction/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/eth_dao_fork.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
4 changes: 2 additions & 2 deletions crates/transaction-pool/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading