Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new fields to message trace for supporting new trace api #1823

Merged
merged 5 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions fvm/src/call_manager/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ where
method,
params: params.as_ref().map(Into::into),
value: value.clone(),
gas_limit: std::cmp::min(
fridrik01 marked this conversation as resolved.
Show resolved Hide resolved
gas_limit.unwrap_or(Gas::from_milligas(u64::MAX)).round_up(),
self.gas_tracker.gas_available().round_up(),
),
read_only,
});
}

Expand Down Expand Up @@ -654,6 +659,10 @@ where
.get_actor(to)?
.ok_or_else(|| syscall_error!(NotFound; "actor does not exist: {}", to))?;

if self.machine.context().tracing {
self.trace(ExecutionEvent::InvokeActor(state.code));
}

// Transfer, if necessary.
if !value.is_zero() {
let t = self.charge_gas(self.price_list().on_value_transfer())?;
Expand Down
7 changes: 7 additions & 0 deletions fvm/src/trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use fvm_shared::{ActorID, MethodNum};

use crate::gas::GasCharge;
use crate::kernel::SyscallError;
use crate::Cid;

/// Execution Trace, only for informational and debugging purposes.
pub type ExecutionTrace = Vec<ExecutionEvent>;
Expand All @@ -19,13 +20,19 @@ pub type ExecutionTrace = Vec<ExecutionEvent>;
#[non_exhaustive]
pub enum ExecutionEvent {
GasCharge(GasCharge),
/// Emitted on each send call regardless whether we actually end up invoking the
/// actor or not (e.g. if we don't have enough gas or if the actor does not exist)
Call {
from: ActorID,
to: Address,
method: MethodNum,
params: Option<IpldBlock>,
value: TokenAmount,
gas_limit: u64,
read_only: bool,
},
CallReturn(ExitCode, Option<IpldBlock>),
CallError(SyscallError),
/// Emitted every time we successfully invoke an actor
InvokeActor(Cid),
fridrik01 marked this conversation as resolved.
Show resolved Hide resolved
}