Skip to main content

Module eval

Module eval 

Source
Expand description

Script budgets measured inside the wallet, with Aiken’s uplc, instead of asking Ogmios (through Koios) to evaluate a draft.

The answer has the shape of Ogmios’s evaluateTransaction answer, so crate::build::Budgets::from_ogmios reads either, and a failed script is put in words the same way.

Evaluating locally is what lets a chain of transactions be built before any of it is on chain: a transaction can spend the outputs of one that hasn’t been sent yet, since the wallet hands the evaluator every UTxO itself (resolve_outputs). uplc 1.1.23 matched the chain’s budgets exactly on recorded preprod transactions (Seedelf spends, and Lovejoin’s mixes and withdraws) under both the 297- and 350-parameter V3 cost models; 1.1.21 didn’t, which is why it must be kept current across hard forks.

Structs§

Resolved
A UTxO the evaluator can see: where it is, and its output’s CBOR.

Functions§

declared_covers
Whether the budgets tx_cbor declares cover what answer measured (Ogmios’s evaluateTransaction answer, or evaluate’s), redeemer by redeemer; the reason when they don’t, a failed script included.
evaluate
Measures every script in tx_cbor against known, the UTxOs it spends and reads (from Koios rows, earlier transactions of a chain, or the bundled references). Answers as Ogmios does: { result: [{ validator: { purpose, index }, budget: { memory, cpu } }] }, or { error: … } naming the script that failed.
ogmios_utxos
A built transaction’s outputs as Ogmios v6 UTxOs, for evaluateTransaction’s additionalUtxo: with them the network’s own evaluator can measure a transaction whose parents aren’t on chain yet (a chain’s first mix, on its unsent deposit). That’s the check that the wallet’s evaluator still costs scripts as the network does.
refusal
Why the evaluator can’t take row, in words, or None when it can. A reference script on the row isn’t carried over, so such a row is refused rather than evaluated wrongly; anyone can send one, to a Seedelf too. So is a row whose datum is nested past cbor::MAX_DEPTH: the evaluator’s decoder would overflow the stack on it. Nothing measured in the wallet (a Seedelf spend, a session’s merged return, Lovejoin) can spend such a UTxO.
resolve_outputs
Every output of a built transaction, as UTxOs a later transaction in the same chain can spend before this one is on chain.
resolve_row
A Koios UTxO row as the evaluator needs it, unless it’s one the evaluator can’t take (refusal).
seedelf_references
The Seedelf contracts’ reference UTxOs on a network (true is preprod, as everywhere in the workspace).
slot_at
The slot unix_ms (milliseconds since 1970) falls in, on preprod (network_flag) or mainnet: what a transaction’s validity interval is counted in. A time before the Shelley era gives its first slot.