Skip to content

Add budget consistency test (VariantC, 55 builtins)#7663

Draft
Unisay wants to merge 1 commit intomasterfrom
yura/budget-consistency-experiment
Draft

Add budget consistency test (VariantC, 55 builtins)#7663
Unisay wants to merge 1 commit intomasterfrom
yura/budget-consistency-experiment

Conversation

@Unisay
Copy link
Contributor

@Unisay Unisay commented Mar 13, 2026

Summary

  • Adds a test that verifies all three CEK evaluation paths produce identical ExBudget for a single "kitchen sink" UPLC term exercising 55 builtins available at changPV (PV9, batch 1–4)
  • The three paths: direct (defaultCekParametersForVariant), benchmark (mkDynEvaluationContext), and production (V3.mkEvaluationContext with [Int64])
  • Confirms that noinline vs inline and JSON round-trip differences do not affect budget calculation

Context

Addresses the concern from https://github.com/IntersectMBO/plutus-private/issues/2084 that different cost model construction paths might produce divergent budgets.

Builtin coverage

Category Count Examples
Integer arithmetic 10 AddInteger, DivideInteger, EqualsInteger
ByteString ops 8 AppendByteString, SliceByteString, IndexByteString
Crypto hashes 5 Sha2_256, Blake2b_256, Keccak_256
String ops 4 AppendString, EncodeUtf8, DecodeUtf8
Data ctors/dtors 15 IData, UnConstrData, SerialiseData, MkPairData
Conversion 2 IntegerToByteString, ByteStringToInteger
1-Force polymorphic 8 IfThenElse, HeadList, MkCons, Trace, ChooseData
2-Force polymorphic 3 FstPair, SndPair, ChooseList

Not covered: BLS12_381 (need group elements), signature verification (need valid sigs), batch 5-6 (not available at changPV).

Test results

All three paths agree: ExBudget {exBudgetCPU = ExCPU 19495026, exBudgetMemory = ExMemory 37516}

Test plan

  • cabal test plutus-ledger-api-test --test-option="-p" --test-option="/Budget consistency/" — all 5 tests pass
  • CI passes

@Unisay Unisay self-assigned this Mar 13, 2026
…ariantB)

Compare three evaluation paths (direct, benchmark, production) for both
VariantC (V3) and VariantB (V2). For each variant, compare CostModelParams
maps key-by-key in addition to ExBudget totals.

VariantB reveals a structural discrepancy: Path A/B has 332 params (full
cost model) while Path C has 206 params (V3-only builtins cleared). All
206 shared params have identical values and budgets match for V2 terms.
@Unisay Unisay force-pushed the yura/budget-consistency-experiment branch from f6d33d7 to 76b675a Compare March 13, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant