Skip to content

Commit

Permalink
improvement: add logs & return value to revert (#343)
Browse files Browse the repository at this point in the history
* improvement: add logs & return value to revert

* improvement: review suggestions
  • Loading branch information
Wodann authored Jan 26, 2023
1 parent 142a1c9 commit 72355f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/primitives/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum ExecutionResult {
output: Output,
},
/// Reverted by `REVERT` opcode that doesn't spend all gas.
Revert { gas_used: u64 },
Revert { gas_used: u64, output: Bytes },
/// Reverted for various reasons and spend all gas.
Halt {
reason: Halt,
Expand All @@ -51,7 +51,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
8 changes: 7 additions & 1 deletion crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,13 @@ 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,
output: 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 72355f4

Please sign in to comment.