pub fn parse_events(
    events: Vec<ExecutionEvent>,
) -> Result<Option<ExecutionTrace>, BuildExecutionTraceError>
Expand description

Construct a single ExecutionTraces from a linear array of ExecutionEvents.

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 GasCharges 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)]