diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index 9d0bc100a1..99b5557149 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -172,8 +172,12 @@ impl Env { // ensure the total blob gas spent is at most equal to the limit // assert blob_gas_used <= MAX_BLOB_GAS_PER_BLOCK - if self.tx.blob_hashes.len() > MAX_BLOB_NUMBER_PER_BLOCK as usize { - return Err(InvalidTransaction::TooManyBlobs); + let num_blobs = self.tx.blob_hashes.len(); + if num_blobs > MAX_BLOB_NUMBER_PER_BLOCK as usize { + return Err(InvalidTransaction::TooManyBlobs { + have: num_blobs, + max: MAX_BLOB_NUMBER_PER_BLOCK as usize, + }); } } } else { diff --git a/crates/primitives/src/result.rs b/crates/primitives/src/result.rs index 516ce25160..659c4fe357 100644 --- a/crates/primitives/src/result.rs +++ b/crates/primitives/src/result.rs @@ -242,7 +242,10 @@ pub enum InvalidTransaction { /// `to` must be present BlobCreateTransaction, /// Transaction has more then [`crate::MAX_BLOB_NUMBER_PER_BLOCK`] blobs - TooManyBlobs, + TooManyBlobs { + max: usize, + have: usize, + }, /// Blob transaction contains a versioned hash with an incorrect version BlobVersionNotSupported, /// EOF TxCreate transaction is not supported before Prague hardfork. @@ -339,7 +342,9 @@ impl fmt::Display for InvalidTransaction { } Self::EmptyBlobs => write!(f, "empty blobs"), Self::BlobCreateTransaction => write!(f, "blob create transaction"), - Self::TooManyBlobs => write!(f, "too many blobs"), + Self::TooManyBlobs { max, have } => { + write!(f, "too many blobs, have {have}, max {max}") + } Self::BlobVersionNotSupported => write!(f, "blob version not supported"), Self::EofInitcodesNotSupported => write!(f, "EOF initcodes not supported"), Self::EofCrateShouldHaveToAddress => write!(f, "EOF crate should have `to` address"),