From 81310b96d36e7d26caeccf3a0d1e87b6f65afdad Mon Sep 17 00:00:00 2001 From: Wodann Date: Tue, 24 Jan 2023 12:10:30 -0300 Subject: [PATCH 1/2] improvement: add logs & return value to revert --- crates/primitives/src/result.rs | 8 ++++++-- crates/revm/src/evm_impl.rs | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/primitives/src/result.rs b/crates/primitives/src/result.rs index 514214ed46..75b833c5b4 100644 --- a/crates/primitives/src/result.rs +++ b/crates/primitives/src/result.rs @@ -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, + return_value: Bytes, + }, /// Reverted for various reasons and spend all gas. Halt { reason: Halt, @@ -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 diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index 0adaa3d92d..037c7027a5 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -225,7 +225,14 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact 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())) From 59e74dc93b38e03716784dbd3f46498ec1225bc3 Mon Sep 17 00:00:00 2001 From: Wodann Date: Thu, 26 Jan 2023 10:43:39 -0300 Subject: [PATCH 2/2] improvement: review suggestions --- crates/primitives/src/result.rs | 6 +----- crates/revm/src/evm_impl.rs | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/crates/primitives/src/result.rs b/crates/primitives/src/result.rs index 75b833c5b4..0f2e8a0b16 100644 --- a/crates/primitives/src/result.rs +++ b/crates/primitives/src/result.rs @@ -24,11 +24,7 @@ pub enum ExecutionResult { output: Output, }, /// Reverted by `REVERT` opcode that doesn't spend all gas. - Revert { - gas_used: u64, - logs: Vec, - return_value: Bytes, - }, + Revert { gas_used: u64, output: Bytes }, /// Reverted for various reasons and spend all gas. Halt { reason: Halt, diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index 037c7027a5..f01631ef8e 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -227,8 +227,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact }, SuccessOrHalt::Revert => ExecutionResult::Revert { gas_used, - logs, - return_value: match output { + output: match output { Output::Call(return_value) => return_value, Output::Create(return_value, _) => return_value, },