Function forest_filecoin::state_manager::utils::structured::parse_events
source · pub fn parse_events(
events: Vec<ExecutionEvent>,
) -> Result<Option<ExecutionTrace>, BuildExecutionTraceError>
Expand description
Construct a single ExecutionTrace
s from a linear array of ExecutionEvent
s.
This function is so-called because it similar to the parse step in a traditional compiler:
text --lex--> tokens --parse--> AST
ExecutionEvent --parse--> ExecutionTrace
This function is notable in that GasCharge
s which precede a ExecutionTrace
at the root level
are attributed to that node.
We call this “front loading”, and is copied from this (rather obscure) code in filecoin-ffi
GasCharge GasCharge Call GasCharge Call CallError CallReturn
────┬──── ────┬──── ─┬── ────┬──── ─┬── ───┬───── ────┬─────
│ │ │ │ │ │ │
│ │ │ │ └─(T)──┘ │
│ │ └───────┴───(T)───┴──────────────┘
└─────────┴──────────────────►│
("front loaded" GasCharges) │
(T)
(T): a ExecutionTrace node
Multiple call trees and trailing gas will be warned and ignored.
If no call tree is found, returns [Ok(None)
]