Skip to content

Commit

Permalink
error out on non-serializeable evm tx (#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyusufatik authored Dec 19, 2024
1 parent 2b51f7b commit d240484
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 4 additions & 6 deletions crates/evm/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -131,14 +132,11 @@ impl<C: sov_modules_api::Context> Evm<C> {
) -> Result<CallResponse, SoftConfirmationModuleCallError> {
// use of `self.block_env` is allowed here

// TODO: should not include non deserilizable transactions
let users_txs: Vec<TransactionSignedEcRecovered> = txs
.into_iter()
.filter_map(|tx| match tx.try_into() {
Ok(tx) => Some(tx),
Err(_) => None,
})
.collect();
.map(|tx| tx.try_into())
.collect::<Result<Vec<_>, 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());
Expand Down
1 change: 1 addition & 0 deletions crates/sequencer/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
}
}
}
Expand Down

0 comments on commit d240484

Please sign in to comment.