Skip to content

Commit

Permalink
improvement: add logs & return value to revert
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Jan 25, 2023
1 parent 6bdc8b9 commit 81310b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions crates/primitives/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ pub enum ExecutionResult {
output: Output,
},
/// Reverted by `REVERT` opcode that doesn't spend all gas.
Revert { gas_used: u64 },
Revert {
gas_used: u64,
logs: Vec<Log>,
return_value: Bytes,
},
/// Reverted for various reasons and spend all gas.
Halt {
reason: Halt,
Expand All @@ -51,7 +55,7 @@ impl ExecutionResult {

pub fn gas_used(&self) -> u64 {
let (Self::Success { gas_used, .. }
| Self::Revert { gas_used }
| Self::Revert { gas_used, .. }
| Self::Halt { gas_used, .. }) = self;

*gas_used
Expand Down
9 changes: 8 additions & 1 deletion crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,14 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact<DB::Error>
logs,
output,
},
SuccessOrHalt::Revert => ExecutionResult::Revert { gas_used },
SuccessOrHalt::Revert => ExecutionResult::Revert {
gas_used,
logs,
return_value: match output {
Output::Call(return_value) => return_value,
Output::Create(return_value, _) => return_value,
},
},
SuccessOrHalt::Halt(reason) => ExecutionResult::Halt { reason, gas_used },
SuccessOrHalt::FatalExternalError => {
return Err(EVMError::Database(self.data.error.take().unwrap()))
Expand Down

0 comments on commit 81310b9

Please sign in to comment.