From d2404847c81fbb74accc1828afeb33a668741d6a Mon Sep 17 00:00:00 2001 From: Esad Yusuf Atik Date: Thu, 19 Dec 2024 14:38:03 +0300 Subject: [PATCH] error out on non-serializeable evm tx (#1625) --- crates/evm/src/call.rs | 10 ++++------ crates/sequencer/src/runner.rs | 1 + .../rollup-interface/src/state_machine/stf.rs | 5 +++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/evm/src/call.rs b/crates/evm/src/call.rs index 5dc5e4b61..1d6dcb99e 100644 --- a/crates/evm/src/call.rs +++ b/crates/evm/src/call.rs @@ -5,6 +5,7 @@ use revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId}; use sov_modules_api::prelude::*; use sov_modules_api::{native_error, CallResponse, SoftConfirmationModuleCallError, WorkingSet}; +use crate::conversions::ConversionError; use crate::evm::db::EvmDb; use crate::evm::executor::{self}; use crate::evm::handler::{CitreaExternal, CitreaExternalExt}; @@ -131,14 +132,11 @@ impl Evm { ) -> Result { // use of `self.block_env` is allowed here - // TODO: should not include non deserilizable transactions let users_txs: Vec = txs .into_iter() - .filter_map(|tx| match tx.try_into() { - Ok(tx) => Some(tx), - Err(_) => None, - }) - .collect(); + .map(|tx| tx.try_into()) + .collect::, ConversionError>>() + .map_err(|_| SoftConfirmationModuleCallError::EvmTxNotSerializable)?; let cfg = self.cfg.get(working_set).expect("Evm config must be set"); let active_evm_spec = citrea_spec_id_to_evm_spec_id(context.active_spec()); diff --git a/crates/sequencer/src/runner.rs b/crates/sequencer/src/runner.rs index 19004e4b1..f60b512ce 100644 --- a/crates/sequencer/src/runner.rs +++ b/crates/sequencer/src/runner.rs @@ -358,6 +358,7 @@ where working_set_to_discard = working_set.revert().to_revertable(); continue; }, + sov_modules_api::SoftConfirmationModuleCallError::EvmTxNotSerializable => panic!("Fed a non-serializable tx"), // we don't call the rule enforcer in the sequencer -- yet at least sov_modules_api::SoftConfirmationModuleCallError::RuleEnforcerUnauthorized => unreachable!(), }, diff --git a/crates/sovereign-sdk/rollup-interface/src/state_machine/stf.rs b/crates/sovereign-sdk/rollup-interface/src/state_machine/stf.rs index da4d54ac3..04543ac02 100644 --- a/crates/sovereign-sdk/rollup-interface/src/state_machine/stf.rs +++ b/crates/sovereign-sdk/rollup-interface/src/state_machine/stf.rs @@ -292,6 +292,8 @@ pub enum SoftConfirmationModuleCallError { EvmMisplacedSystemTx, /// Address does not have enough funds to pay for L1 fee EvmNotEnoughFundsForL1Fee, + /// An EVM transaction in the soft confirmation was not serializable + EvmTxNotSerializable, /// The sov-tx was not sent by the rule enforcer authority RuleEnforcerUnauthorized, /// The EVM transaction type is not supported @@ -395,6 +397,9 @@ impl std::fmt::Display for SoftConfirmationModuleCallError { SoftConfirmationModuleCallError::RuleEnforcerUnauthorized => { write!(f, "Rule enforcer unauthorized") } + SoftConfirmationModuleCallError::EvmTxNotSerializable => { + write!(f, "EVM tx not serializable") + } } } }