Skip to main content

fvm/trace/
mod.rs

1use cid::Cid;
2// Copyright 2021-2023 Protocol Labs
3// SPDX-License-Identifier: Apache-2.0, MIT
4use fvm_ipld_encoding::ipld_block::IpldBlock;
5use fvm_shared::address::Address;
6use fvm_shared::econ::TokenAmount;
7use fvm_shared::error::ExitCode;
8use fvm_shared::state::ActorState;
9use fvm_shared::{ActorID, MethodNum};
10
11use crate::gas::GasCharge;
12use crate::kernel::SyscallError;
13
14/// Execution Trace, only for informational and debugging purposes.
15pub type ExecutionTrace = Vec<ExecutionEvent>;
16
17/// The type of operation being performed in an Ipld ExecutionEvent.
18#[derive(Clone, Debug, PartialEq)]
19pub enum IpldOperation {
20    Get, // open
21    Put, // link
22}
23
24/// An "event" that happened during execution.
25///
26/// This is marked as `non_exhaustive` so we can introduce additional event types later.
27#[derive(Clone, Debug)]
28#[non_exhaustive]
29pub enum ExecutionEvent {
30    GasCharge(GasCharge),
31    /// Emitted on each send call regardless whether we actually end up invoking the
32    /// actor or not (e.g. if we don't have enough gas or if the actor does not exist)
33    Call {
34        from: ActorID,
35        to: Address,
36        method: MethodNum,
37        params: Option<IpldBlock>,
38        value: TokenAmount,
39        gas_limit: u64,
40        read_only: bool,
41    },
42    CallReturn(ExitCode, Option<IpldBlock>),
43    CallError(SyscallError),
44    /// Emitted every time an actor is successfully invoked.
45    InvokeActor {
46        id: ActorID,
47        state: ActorState,
48    },
49    Log(String),
50    Ipld {
51        op: IpldOperation,
52        cid: Cid,
53        size: usize,
54    },
55}