From d08d72e5c38c460d15be8233c502fb3a0b3f2c5b Mon Sep 17 00:00:00 2001 From: clabby Date: Wed, 7 Feb 2024 21:51:07 -0500 Subject: [PATCH] feat(op): `Ecotone` reject blob txs (#6480) Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com> --- crates/interfaces/src/executor.rs | 3 +++ crates/payload/optimism/src/error.rs | 3 +++ crates/payload/optimism/src/lib.rs | 9 ++++++++- crates/revm/src/optimism/processor.rs | 11 ++++++++++- crates/transaction-pool/src/validate/eth.rs | 2 +- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/crates/interfaces/src/executor.rs b/crates/interfaces/src/executor.rs index e6d2d1f3f..c3f14c4a6 100644 --- a/crates/interfaces/src/executor.rs +++ b/crates/interfaces/src/executor.rs @@ -135,6 +135,9 @@ pub enum OptimismBlockExecutionError { /// Thrown when force deploy of create2deployer code fails. #[error("failed to force create2deployer account code")] ForceCreate2DeployerFail, + /// Thrown when a blob transaction is included in a sequencer's block. + #[error("blob transaction included in sequencer block")] + BlobTransactionRejected, } impl BlockExecutionError { diff --git a/crates/payload/optimism/src/error.rs b/crates/payload/optimism/src/error.rs index 7877ec48f..6df19d267 100644 --- a/crates/payload/optimism/src/error.rs +++ b/crates/payload/optimism/src/error.rs @@ -17,4 +17,7 @@ pub enum OptimismPayloadBuilderError { /// Thrown when force deploy of create2deployer code fails. #[error("failed to force create2deployer account code")] ForceCreate2DeployerFail, + /// Thrown when a blob transaction is included in a sequencer's block. + #[error("blob transaction included in sequencer block")] + BlobTransactionRejected, } diff --git a/crates/payload/optimism/src/lib.rs b/crates/payload/optimism/src/lib.rs index c34876498..1807b0fc2 100644 --- a/crates/payload/optimism/src/lib.rs +++ b/crates/payload/optimism/src/lib.rs @@ -23,7 +23,7 @@ mod builder { constants::{BEACON_NONCE, EMPTY_RECEIPTS, EMPTY_TRANSACTIONS}, proofs, revm::env::tx_env_with_recovered, - Block, Hardfork, Header, IntoRecoveredTransaction, Receipt, Receipts, + Block, Hardfork, Header, IntoRecoveredTransaction, Receipt, Receipts, TxType, EMPTY_OMMER_ROOT_HASH, U256, }; use reth_provider::{BundleStateWithReceipts, StateProviderFactory}; @@ -269,6 +269,13 @@ mod builder { return Ok(BuildOutcome::Cancelled) } + // A sequencer's block should never contain blob transactions. + if matches!(sequencer_tx.tx_type(), TxType::EIP4844) { + return Err(PayloadBuilderError::other( + OptimismPayloadBuilderError::BlobTransactionRejected, + )) + } + // Convert the transaction to a [TransactionSignedEcRecovered]. This is // purely for the purposes of utilizing the [tx_env_with_recovered] function. // Deposit transactions do not have signatures, so if the tx is a deposit, this diff --git a/crates/revm/src/optimism/processor.rs b/crates/revm/src/optimism/processor.rs index 83eb113b2..c1e4e964d 100644 --- a/crates/revm/src/optimism/processor.rs +++ b/crates/revm/src/optimism/processor.rs @@ -3,7 +3,9 @@ use reth_interfaces::executor::{ BlockExecutionError, BlockValidationError, OptimismBlockExecutionError, }; use reth_node_api::ConfigureEvmEnv; -use reth_primitives::{revm_primitives::ResultAndState, BlockWithSenders, Hardfork, Receipt, U256}; +use reth_primitives::{ + revm_primitives::ResultAndState, BlockWithSenders, Hardfork, Receipt, TxType, U256, +}; use reth_provider::{BlockExecutor, BlockExecutorStats, BundleStateWithReceipts}; use revm::DatabaseCommit; use std::time::Instant; @@ -95,6 +97,13 @@ where .into()) } + // An optimism block should never contain blob transactions. + if matches!(transaction.tx_type(), TxType::EIP4844) { + return Err(BlockExecutionError::OptimismBlockExecution( + OptimismBlockExecutionError::BlobTransactionRejected, + )) + } + // Cache the depositor account prior to the state transition for the deposit nonce. // // Note that this *only* needs to be done post-regolith hardfork, as deposit nonces diff --git a/crates/transaction-pool/src/validate/eth.rs b/crates/transaction-pool/src/validate/eth.rs index 9d35153cc..e41907e84 100644 --- a/crates/transaction-pool/src/validate/eth.rs +++ b/crates/transaction-pool/src/validate/eth.rs @@ -143,7 +143,7 @@ where mut transaction: Tx, ) -> TransactionValidationOutcome { #[cfg(feature = "optimism")] - if transaction.is_deposit() { + if transaction.is_deposit() || transaction.is_eip4844() { return TransactionValidationOutcome::Invalid( transaction, InvalidTransactionError::TxTypeNotSupported.into(),