Skip to content

Commit

Permalink
fix: revert backtrace frame from entrypoint to method (#1956)
Browse files Browse the repository at this point in the history
This is a pretty public API (information gets displayed to the user) and
I'd rather not go about changing it at the moment. We'll probably bring
this back eventually, but I'm trying to cut a release and integrate with
the FFI with minimal outward-facing changes.
  • Loading branch information
Stebalien authored Dec 15, 2023
1 parent 6722164 commit 7ae3403
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
10 changes: 4 additions & 6 deletions fvm/src/call_manager/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ use std::fmt::Display;

use fvm_shared::address::Address;
use fvm_shared::error::{ErrorNumber, ExitCode};
use fvm_shared::ActorID;
use fvm_shared::{ActorID, MethodNum};

use crate::kernel::SyscallError;

use super::Entrypoint;

/// A call backtrace records the actors an error was propagated through, from
/// the moment it was emitted. The original error is the _cause_. Backtraces are
/// useful for identifying the root cause of an error.
Expand Down Expand Up @@ -78,8 +76,8 @@ impl Backtrace {
pub struct Frame {
/// The actor that exited with this code.
pub source: ActorID,
/// The entrypoint that was invoked.
pub entrypoint: Entrypoint,
/// The method that was invoked.
pub method: MethodNum,
/// The exit code.
pub code: ExitCode,
/// The abort message.
Expand All @@ -92,7 +90,7 @@ impl Display for Frame {
f,
"{} (method {}) -- {} ({})",
Address::new_id(self.source),
self.entrypoint,
self.method,
&self.message,
self.code,
)
Expand Down
23 changes: 14 additions & 9 deletions fvm/src/call_manager/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,16 +859,21 @@ where
};

if !code.is_success() {
if let Some(err) = last_error {
cm.backtrace.begin(err);
// Only record backtrace frames for explicit messages sent by the user. We
// may want to record frames for failed upgrades, but that complicates
// things a bit and I'd like to keep this API the same for now.
if let &Entrypoint::Invoke(method) = &entrypoint {
if let Some(err) = last_error {
cm.backtrace.begin(err);
}

cm.backtrace.push_frame(Frame {
source: to,
method,
message,
code,
});
}

cm.backtrace.push_frame(Frame {
source: to,
entrypoint,
message,
code,
});
}

res
Expand Down

0 comments on commit 7ae3403

Please sign in to comment.