@@ -13,7 +13,7 @@ use alloy_evm::{
1313 } ,
1414 eth:: { EthBlockExecutor , EthTxResult } ,
1515} ;
16- use alloy_sol_types:: SolEvent as _;
16+ use alloy_sol_types:: { SolCall as _ , SolEvent as _} ;
1717use reth_evm:: block:: StateDB ;
1818use reth_revm:: { Inspector , context:: result:: ResultAndState } ;
1919use tempo_evm:: { TempoBlockExecutionCtx , TempoReceiptBuilder } ;
@@ -22,9 +22,7 @@ use tempo_revm::evm::TempoContext;
2222use tempo_zone_contracts:: IZoneOutbox ;
2323use zone_chainspec:: ZoneChainSpec ;
2424use zone_l1:: state:: L1StateProvider ;
25- use zone_precompiles:: {
26- ADVANCE_TEMPO_SELECTOR , L1StorageReader , is_finalize_withdrawal_batch_calldata,
27- } ;
25+ use zone_precompiles:: { ADVANCE_TEMPO_SELECTOR , L1StorageReader } ;
2826use zone_primitives:: constants:: { ZONE_INBOX_ADDRESS , ZONE_OUTBOX_ADDRESS } ;
2927
3028use crate :: { L1OverlayDB , ZoneEvm } ;
@@ -106,7 +104,8 @@ impl ZoneTransactionKind {
106104 }
107105
108106 if tx. calls ( ) . any ( |( kind, input) | {
109- kind. to ( ) == Some ( & ZONE_OUTBOX_ADDRESS ) && is_finalize_withdrawal_batch_calldata ( input)
107+ kind. to ( ) == Some ( & ZONE_OUTBOX_ADDRESS )
108+ && input. starts_with ( & IZoneOutbox :: finalizeWithdrawalBatchCall:: SELECTOR )
110109 } ) {
111110 return Self :: FinalizeWithdrawalBatch ;
112111 }
@@ -285,7 +284,7 @@ mod tests {
285284 use reth_chainspec:: EthChainSpec as _;
286285 use reth_primitives_traits:: Recovered ;
287286 use revm:: database:: { CacheDB , EmptyDB } ;
288- use tempo_chainspec:: spec:: DEV ;
287+ use tempo_chainspec:: { hardfork :: TempoHardfork , spec:: DEV } ;
289288 use tempo_evm:: TempoBlockExecutionCtx ;
290289 use tempo_precompiles:: {
291290 DEFAULT_FEE_TOKEN , TIP_FEE_MANAGER_ADDRESS ,
@@ -461,14 +460,74 @@ mod tests {
461460 ZONE_OUTBOX_ADDRESS ,
462461 Bytes :: copy_from_slice ( & IZoneOutbox :: finalizeWithdrawalBatchCall:: SELECTOR ) ,
463462 ) ;
464- let error = ZoneBlockPhase :: Executing
465- . validate_transaction ( & malformed_finalize)
466- . unwrap_err ( ) ;
467463 assert_eq ! (
468- error. to_string( ) ,
469- "system transactions after advanceTempo must call \
470- ZoneOutbox.finalizeWithdrawalBatch"
464+ ZoneBlockPhase :: Executing
465+ . validate_transaction( & malformed_finalize)
466+ . unwrap( ) ,
467+ ZoneBlockPhase :: WithdrawalsFinalized
468+ ) ;
469+
470+ let mut trailing_calldata = IZoneOutbox :: finalizeWithdrawalBatchCall {
471+ count : U256 :: ZERO ,
472+ blockNumber : 1 ,
473+ encryptedSenders : vec ! [ ] ,
474+ }
475+ . abi_encode ( ) ;
476+ trailing_calldata. extend_from_slice ( & [ 0 ; 32 ] ) ;
477+ let trailing_finalize = system_tx ( ZONE_OUTBOX_ADDRESS , trailing_calldata. into ( ) ) ;
478+ assert_eq ! (
479+ ZoneBlockPhase :: Executing
480+ . validate_transaction( & trailing_finalize)
481+ . unwrap( ) ,
482+ ZoneBlockPhase :: WithdrawalsFinalized
483+ ) ;
484+ }
485+
486+ #[ test]
487+ fn malformed_t11_finalization_does_not_advance_block_phase ( ) {
488+ let mut zone_genesis = DEV . genesis ( ) . clone ( ) ;
489+ zone_genesis. config . chain_id = zone_chain_id ( DEV . chain ( ) . id ( ) , 2 ) . unwrap ( ) ;
490+ let chain_spec = std:: sync:: Arc :: new ( ZoneChainSpec :: from_genesis ( zone_genesis) . unwrap ( ) ) ;
491+ let factory =
492+ ZoneEvmFactory :: new ( chain_spec. clone ( ) , MockL1Reader :: default ( ) , Address :: ZERO ) ;
493+ let mut env = EvmEnv :: default ( ) ;
494+ env. cfg_env . spec = TempoHardfork :: T11 ;
495+ let evm = factory. create_evm ( CacheDB :: new ( EmptyDB :: default ( ) ) , env) ;
496+ let ctx = TempoBlockExecutionCtx {
497+ inner : EthBlockExecutionCtx {
498+ parent_hash : B256 :: ZERO ,
499+ parent_beacon_block_root : None ,
500+ ommers : & [ ] ,
501+ withdrawals : None ,
502+ extra_data : Bytes :: new ( ) ,
503+ tx_count_hint : Some ( 1 ) ,
504+ slot_number : None ,
505+ } ,
506+ general_gas_limit : 0 ,
507+ shared_gas_limit : 0 ,
508+ validator_set : None ,
509+ consensus_context : None ,
510+ subblock_fee_recipients : Default :: default ( ) ,
511+ } ;
512+ let mut executor = ZoneBlockExecutor :: new ( evm, ctx, & chain_spec) ;
513+ executor. phase = ZoneBlockPhase :: Executing ;
514+
515+ let tx = Recovered :: new_unchecked (
516+ system_tx (
517+ ZONE_OUTBOX_ADDRESS ,
518+ Bytes :: copy_from_slice ( & IZoneOutbox :: finalizeWithdrawalBatchCall:: SELECTOR ) ,
519+ ) ,
520+ TEMPO_SYSTEM_TX_SENDER ,
521+ ) ;
522+ let error = executor. execute_transaction_without_commit ( tx) . unwrap_err ( ) ;
523+
524+ assert ! (
525+ error
526+ . to_string( )
527+ . contains( "system transaction execution failed" ) ,
528+ "unexpected error: {error}"
471529 ) ;
530+ assert_eq ! ( executor. phase, ZoneBlockPhase :: Executing ) ;
472531 }
473532
474533 #[ test]
0 commit comments