Problem
The Tier-0 parity gate (D-034) is currently defined as “shared scenario passes on three targets” — behavior only. A contract could pass Mollusk while exceeding Solana’s default compute budget, or pass revm while consuming far more EVM gas than a production deployment can afford. Declaring parity without budgets risks declaring fake parity, and codegen quality regressions have no tripwire. The direct-assembly Solana route is already extremely efficient today. Locking those numbers in now turns an accidental advantage into an intentional, measured contract:| Entrypoint | Compute units |
|---|---|
initialize | 56 |
increment | 63 |
get (writes return data) | 163 |
Summary
Extend the testkit scenario schema with optional per-step resource budgets:baselineis the measured cost on a reference toolchain version.toleranceis a relative band (e.g.0.05= ±5%).- Harnesses report the actual budget consumed for each step.
- The runner fails a step when the actual cost exceeds
baseline * (1 + tolerance). - A missing
budgettable means “not asserted yet”; the runner still reports the measured value so authors can lock baselines.
Design Goals
- Codegen quality is a testable gate, not an afterthought.
- Baselines are pinned with toolchain versions so upgrades are explicit.
- Tolerance bands absorb noise from host timing, allocator state, and small optimizer changes without letting silent regressions through.
- Budgets are optional per step so scenarios can be added before baselines are measured.
- This RFC does not define protocol fee modeling or transaction pricing.
- It does not replace the formal verification roadmap (FV-5 checked arithmetic is complementary).
- It does not add new fixtures; it adds budget fields to existing scenarios.
Budget Metrics per Target
| Target | Metric | Source |
|---|---|---|
evm | gas | revm gas_used after step execution |
solana-sbpf-asm | cu | Mollusk compute_units_consumed |
wasm-near | near_gas | wasmtime instruction / host-call cost model or NEAR host gas counter |
move_gas, wasm_instr) without
changing the schema shape.
Schema Extension
The existingExpectation struct gains a budget field:
Baseline Locking
Baselines are recorded in the scenario file, not in a separate manifest. Each baseline implicitly belongs to a reference toolchain recorded in the scenario metadata:Harness Changes
EachChainHarness returns a CallOutcome with an optional budget field:
harness-solanareadsresult.compute_units_consumedfrom Mollusk.harness-evmreadstx_result.gas_used()from revm.harness-nearuses a host-side gas counter inruntime/offline-host; if exact NEAR gas is not available, the harness reports an approximate instruction/host-call cost and marks the assertion asinfo-onlyuntil the model improves.
Runner Behavior
- Parse the scenario and expand the target matrix as today.
- After each step, collect the actual budget from the harness.
- If the scenario asserts a budget for that step/target, compare actual
against
baseline * (1 + tolerance). - If the scenario does not assert a budget, print the measured value as an informational line so authors can copy it into the scenario.
- Cross-target trace equivalence still compares observable outcomes only; budgets are per-target, not cross-target.
Acceptance Criteria
testkit/scenarios/counter.tomlincludes locked baselines for the three Tier-0 targets.- A deliberate regression in Solana CU or EVM gas fails
just testkit. - The runner prints measured budget for every step, even when no baseline is asserted.
- Baseline changes are reviewable in the scenario TOML, not hidden in lock files.
Milestones
- M1: Extend scenario schema and
CallOutcomewith budget fields; add Solana CU reporting (Mollusk already exposes this). - M2: Add EVM gas reporting through revm and lock Counter baselines.
- M3: Add NEAR gas reporting via the offline host; lock Counter baselines
or mark as
info-onlyif the model is approximate. - M4: Update Gate G0 definition (target-roadmap + validation-gates) so shared-scenario parity requires budget assertions.
Pairing with Runtime Error Model
Workstream 33 extends the scenario schema withexpect.error. The budget and
error schema changes should land together so testkit undergoes only one schema
migration. Coordinate with RFC 0011 (Workstream 33).
Non-goals
- No protocol-fee or transaction-cost modeling.
- No cross-target budget comparison (EVM gas is not comparable to Solana CU).
- No artifact-size budgets yet; ELF/bytecode size stays in artifact metadata and golden files.
Related
- RFC 0007: testkit scenario model.
- RFC 0009: CLI surface testkit invokes; budget reporting must work through the new surface.
- Workstream 26: testkit M2/M3 schema freeze.
- Workstream 33: runtime error model + client generation.
- target-roadmap.md: Tier-0 parity gate D-034.