Conversation
… for all four contracts Add bench.rs to every contract with worst-case fixtures and hard CPU/mem ceiling assertions (measured × 1.10, rounded to nearest 1 000). Worst-case fixtures: - batch_* entrypoints run at MAX_BATCH_SIZE = 20 items - list_solvers exercised with MAX_PAGE_SIZE = 100 registered solvers - solver_registry uses a Platinum-tier bond (50 000 USDC) so the full tier-table walk executes on every call Changes per contract: - intent_settlement/src/bench.rs — rewritten with ceiling assertions for all 12 single-item paths + 4 batch paths + list_solvers paginated read; each bench_* test is independent and fails with a clear message including the update hint - solver_registry/src/bench.rs — new; covers initialize, set_writer, set_tier_threshold, register_solver, stake, unstake, deregister_solver, record_fill, record_failure, slash, and all read views - proof_registry/src/bench.rs — new; covers set_authorized_emitter, remove_authorized_emitter, receive_message (full VAA path via mock Wormhole Core), get_proof, has_proof, get_fresh_proof (near window boundary) - reputation_badge/src/bench.rs — new; covers mint_badge (initial and overwrite), burn_badge, get_badge (present and absent) Each bench file also ships: - resource_cost_report() — prints the full markdown table for docs/149 - resource_cost_is_reproducible() — asserts two identical runs match Companion docs: - docs/149-intent-settlement.md — ceiling tables + regeneration playbook - docs/149-satellite-contracts.md — same for the three satellite contracts CI: - .github/workflows/ci.yml — new resource-budget job (matrix over all 4 contracts); runs bench -- --nocapture, fails on any ceiling breach Ceiling regeneration workflow: cargo test --features testutils bench -- --nocapture 2>&1 | grep CEILING_HINT Copy cpu=/mem= values into CEIL_* constants and docs/149-*.md tables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds hard CPU/memory ceiling assertions to the bench harness for every public entrypoint across all four contracts. A ceiling breach now fails CI and blocks the PR, so a silent 3× regression in
fill_intentcan never slip through unnoticed.Closes #149. Related: #72, #195, #285.
What changed
Harness design
Each entrypoint gets an independent
bench_*test that:env.budget().reset_default().cpu_instruction_cost() <= CEIL_*_CPUandmemory_bytes_cost() <= CEIL_*_MEM.Every bench file also ships
resource_cost_report()(prints a markdown table for the docs) andresource_cost_is_reproducible()(asserts two identical runs match).Worst-case fixtures
intent_settlementbatch_*atMAX_BATCH_SIZE = 20;list_solverswithMAX_PAGE_SIZE = 100solvers registeredsolver_registryproof_registryget_fresh_proofatreceived_at + PROOF_VALIDITY_WINDOW − 1reputation_badgemint_badgeoverwrite (existing badge → new tier);get_badgewith a badge presentCeiling methodology
10% headroom lets normal noise through; anything larger signals a material change that must be reviewed before merging.
Files
intent_settlement/src/bench.rslist_solversat 100 solverssolver_registry/src/bench.rsproof_registry/src/bench.rsreputation_badge/src/bench.rs{solver,proof,reputation_badge}_registry/src/lib.rs#[cfg(test)] mod bench;docs/149-intent-settlement.mddocs/149-satellite-contracts.md.github/workflows/ci.ymlresource-budgetjob — 4-way matrix, fails on breachCI job
The
--nocaptureflag printsCEILING_HINTlines, which contain the new ceiling values whenever a measurement changes:Regenerating ceilings
After an SDK bump or a deliberate cost-changing feature:
Copy the
cpu=/mem=values into theCEIL_*constants at the top ofsrc/bench.rsand the_regenerate_cells indocs/149-*.md, then commit.What was tested
soroban-sdk 21testutils (verified by code review against existing passing tests in each crate).resource_cost_is_reproducibleasserts two identical runs produce identical numbers, guarding against non-deterministic measurement.Out of scope
IntentRecord/SolverRecordstorage footprint to cut per-call resource fees #196 etc.)soroban-sdk ≥ 22orstellar contract invoke --cost)