Skip to content

Commit 39a7575

Browse files
committed
Address review
1 parent 19271a8 commit 39a7575

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

fvm/src/call_manager/default.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use fvm_ipld_encoding::{RawBytes, DAG_CBOR};
44
use fvm_shared::actor::builtin::Type;
55
use fvm_shared::address::{Address, Protocol};
66
use fvm_shared::econ::TokenAmount;
7-
use fvm_shared::error::ExitCode;
7+
use fvm_shared::error::{ErrorNumber, ExitCode};
88
use fvm_shared::version::NetworkVersion;
99
use fvm_shared::{ActorID, MethodNum, METHOD_SEND};
1010
use num_traits::Zero;
@@ -13,7 +13,7 @@ use super::{Backtrace, CallManager, InvocationResult, NO_DATA_BLOCK_ID};
1313
use crate::call_manager::backtrace::Frame;
1414
use crate::call_manager::FinishRet;
1515
use crate::gas::GasTracker;
16-
use crate::kernel::{ClassifyResult, ExecutionError, Kernel, Result};
16+
use crate::kernel::{ClassifyResult, ExecutionError, Kernel, Result, SyscallError};
1717
use crate::machine::Machine;
1818
use crate::syscalls::error::Abort;
1919
use crate::trace::{ExecutionEvent, ExecutionTrace, SendParams};
@@ -125,7 +125,16 @@ where
125125
self.call_stack_depth -= 1;
126126

127127
if self.machine.context().tracing {
128-
self.exec_trace.push(ExecutionEvent::Return(result.clone()));
128+
self.exec_trace.push(ExecutionEvent::Return(match result {
129+
Err(ref e) => Err(match e {
130+
ExecutionError::OutOfGas => {
131+
SyscallError::new(ErrorNumber::Forbidden, "out of gas")
132+
}
133+
ExecutionError::Fatal(_) => SyscallError::new(ErrorNumber::Forbidden, "fatal"),
134+
ExecutionError::Syscall(s) => s.clone(),
135+
}),
136+
Ok(ref v) => Ok(v.clone()),
137+
}));
129138
}
130139

131140
result

fvm/src/kernel/error.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use std::fmt::Display;
33
use derive_more::Display;
44
use fvm_shared::error::ErrorNumber;
55

6-
use crate::kernel::ExecutionError::{Fatal, OutOfGas, Syscall};
7-
86
/// Execution result.
97
pub type Result<T> = std::result::Result<T, ExecutionError>;
108

@@ -37,16 +35,6 @@ pub enum ExecutionError {
3735
Fatal(anyhow::Error),
3836
}
3937

40-
impl Clone for ExecutionError {
41-
fn clone(&self) -> Self {
42-
match self {
43-
OutOfGas => OutOfGas,
44-
Syscall(v) => Syscall(v.clone()),
45-
Fatal(v) => Fatal(anyhow::Error::msg(v.to_string())),
46-
}
47-
}
48-
}
49-
5038
impl ExecutionError {
5139
/// Returns true if the error is fatal. A fatal error means that something went wrong
5240
/// when processing the message. This might be due to the message, the state of the filecoin

fvm/src/machine/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ impl NetworkConfig {
129129

130130
/// Enable actor debugging. This is a consensus-critical option (affects gas usage) so it should
131131
/// only be enabled for local testing or as a network-wide parameter.
132-
pub fn enable_actor_debugging(&mut self, enabled: bool) -> &mut Self {
133-
self.actor_debugging = enabled;
132+
pub fn enable_actor_debugging(&mut self) -> &mut Self {
133+
self.actor_debugging = true;
134134
self
135135
}
136136

@@ -180,6 +180,8 @@ pub struct MachineContext {
180180
/// DEFAULT: Total FIL supply (likely not what you want).
181181
pub circ_supply: TokenAmount,
182182

183+
/// Whether or not to produce execution traces in the returned result.
184+
/// Not consensus-critical, but has a performance impact.
183185
pub tracing: bool,
184186
}
185187

@@ -196,7 +198,7 @@ impl MachineContext {
196198
self
197199
}
198200

199-
/// Set [`MachineContext::tracing`].
201+
/// Enable execution traces. [`MachineContext::tracing`].
200202
pub fn enable_tracing(&mut self) -> &mut Self {
201203
self.tracing = true;
202204
self

fvm/src/trace/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use fvm_shared::econ::TokenAmount;
44
use fvm_shared::{ActorID, MethodNum};
55

66
use crate::call_manager::InvocationResult;
7-
use crate::kernel::Result;
7+
use crate::kernel::SyscallError;
88

99
/// Execution Trace, only for informational and debugging purposes.
1010
pub type ExecutionTrace = Vec<ExecutionEvent>;
1111

1212
#[derive(Clone, Debug)]
1313
pub enum ExecutionEvent {
1414
Call(SendParams),
15-
Return(Result<InvocationResult>),
15+
Return(Result<InvocationResult, SyscallError>),
1616
}
1717

1818
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)