diff --git a/fvm/src/call_manager/default.rs b/fvm/src/call_manager/default.rs index d3ac28332..c78912da6 100644 --- a/fvm/src/call_manager/default.rs +++ b/fvm/src/call_manager/default.rs @@ -186,6 +186,11 @@ where method, params: params.as_ref().map(Into::into), value: value.clone(), + gas_limit: std::cmp::min( + gas_limit.unwrap_or(Gas::from_milligas(u64::MAX)).round_up(), + self.gas_tracker.gas_available().round_up(), + ), + read_only, }); } @@ -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())?; diff --git a/fvm/src/trace/mod.rs b/fvm/src/trace/mod.rs index fcbec8287..745410773 100644 --- a/fvm/src/trace/mod.rs +++ b/fvm/src/trace/mod.rs @@ -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; @@ -19,13 +20,19 @@ pub type ExecutionTrace = Vec; #[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, value: TokenAmount, + gas_limit: u64, + read_only: bool, }, CallReturn(ExitCode, Option), CallError(SyscallError), + /// Emitted every time we successfully invoke an actor + InvokeActor(Cid), }