From 3192ffdb92edc11a8c8dec33f7b2d2c25ae95042 Mon Sep 17 00:00:00 2001 From: rakita Date: Thu, 19 Dec 2024 10:02:34 +0100 Subject: [PATCH] chore: EVM transact, make output generic for POSTEXEC (#1931) * fix: clear JournalState and set first journal vec * chore: EVM transact make output generic for POSTEXEC * Make ExecCommit generic on HaltReason --- crates/revm/src/evm.rs | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index bfbf6c24b0..c89ef51bc7 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -4,7 +4,8 @@ use context_interface::{ block::BlockSetter, journaled_state::JournaledState, result::{ - EVMError, ExecutionResult, HaltReason, InvalidHeader, InvalidTransaction, ResultAndState, + EVMError, ExecutionResult, HaltReasonTrait, InvalidHeader, InvalidTransaction, + ResultAndState, }, transaction::TransactionSetter, BlockGetter, CfgGetter, DatabaseGetter, ErrorGetter, JournalStateGetter, @@ -39,7 +40,7 @@ impl Evm { } } -impl EvmCommit +impl EvmCommit for Evm> where CTX: TransactionSetter @@ -70,11 +71,12 @@ where Context = CTX, Error = ERROR, ExecResult = FrameResult, - // TODO make output generics - Output = ResultAndState, + // TODO make output more generics + Output = ResultAndState, >, + HALT: HaltReasonTrait, { - type CommitOutput = Result, ERROR>; + type CommitOutput = Result, ERROR>; fn exec_commit(&mut self) -> Self::CommitOutput { let res = self.transact(); @@ -112,19 +114,13 @@ where ExecResult = FrameResult, Frame: Frame, >, - POSTEXEC: PostExecutionHandler< - Context = CTX, - Error = ERROR, - ExecResult = FrameResult, - // TODO make output generics - Output = ResultAndState, - >, + POSTEXEC: PostExecutionHandler, { type Transaction = ::Transaction; type Block = ::Block; - type Output = Result, ERROR>; + type Output = Result<::Output, ERROR>; fn set_block(&mut self, block: Self::Block) { self.context.set_block(block); @@ -176,12 +172,7 @@ where ExecResult = FrameResult, Frame: Frame, >, - POSTEXEC: PostExecutionHandler< - Context = CTX, - Error = ERROR, - ExecResult = FrameResult, - Output = ResultAndState, - >, + POSTEXEC: PostExecutionHandler, { /// Pre verify transaction by checking Environment, initial gas spend and if caller /// has enough balance to pay for the gas. @@ -201,7 +192,9 @@ where /// /// This function will not validate the transaction. #[inline] - pub fn transact_preverified(&mut self) -> Result, ERROR> { + pub fn transact_preverified( + &mut self, + ) -> Result<::Output, ERROR> { let initial_gas_spend = self .handler .validation() @@ -233,7 +226,7 @@ where /// /// This function will validate the transaction. #[inline] - pub fn transact(&mut self) -> Result, ERROR> { + pub fn transact(&mut self) -> Result<::Output, ERROR> { let initial_gas_spend = self.preverify_transaction_inner().inspect_err(|_| { self.clear(); })?; @@ -248,7 +241,7 @@ where fn transact_preverified_inner( &mut self, initial_gas_spend: u64, - ) -> Result, ERROR> { + ) -> Result<::Output, ERROR> { let context = &mut self.context; let pre_exec = self.handler.pre_execution();