Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zjb0807 committed Sep 24, 2024
1 parent 3711eb7 commit ff8a060
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions modules/evm/src/runner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu
(reason, maybe_address, return_data)
}
RuntimeKind::Call(code_address) => {
let return_data =
self.cleanup_for_call(code_address, &reason, runtime.inner.machine().return_value());
let (reason, return_data) =
self.cleanup_for_call(code_address, reason, runtime.inner.machine().return_value());
(reason, None, return_data)
}
RuntimeKind::Execute => (reason, None, runtime.inner.machine().return_value()),
Expand Down Expand Up @@ -1070,9 +1070,9 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu
}) {
return match result {
Ok(PrecompileOutput { exit_status, output }) => {
// let _ = self.exit_substate(StackExitKind::Succeeded);
let e = self.exit_substate(StackExitKind::Succeeded);
try_or_fail!(e);
if let Err(e) = self.exit_substate(StackExitKind::Succeeded) {
return Capture::Exit((e.into(), Vec::new()));
}
Capture::Exit((ExitReason::Succeed(exit_status), output))
}
Err(PrecompileFailure::Error { exit_status }) => {
Expand Down Expand Up @@ -1180,25 +1180,32 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu
}
}

fn cleanup_for_call(&mut self, code_address: H160, reason: &ExitReason, return_data: Vec<u8>) -> Vec<u8> {
fn cleanup_for_call(
&mut self,
code_address: H160,
reason: ExitReason,
return_data: Vec<u8>,
) -> (ExitReason, Vec<u8>) {
log::debug!(target: "evm", "Call execution using address {}: {:?}", code_address, reason);
match reason {
ExitReason::Succeed(_) => {
let _ = self.exit_substate(StackExitKind::Succeeded);
return_data
if let Err(e) = self.exit_substate(StackExitKind::Succeeded) {
return (e.into(), Vec::new());
}
(reason, return_data)
}
ExitReason::Error(_) => {
let _ = self.exit_substate(StackExitKind::Failed);
Vec::new()
(reason, Vec::new())
}
ExitReason::Revert(_) => {
let _ = self.exit_substate(StackExitKind::Reverted);
return_data
(reason, return_data)
}
ExitReason::Fatal(_) => {
self.state.metadata_mut().gasometer.fail();
let _ = self.exit_substate(StackExitKind::Failed);
Vec::new()
(reason, Vec::new())
}
}
}
Expand Down

0 comments on commit ff8a060

Please sign in to comment.