Repository navigation
Conversation
Add a resource-cost harness for register_merchant, create_invoice, pay_invoice, pay_invoices_batch and get_invoices, a script that regenerates the numbers, and the measured tables with maximum safe batch sizes (17 invoices per pay_invoices_batch call, 98 stored invoices for get_invoices). The shade crate does not build on main, so the numbers come from the last compiling commit; the caveats are documented.
lmduy2612
reviewed
Nov 10, 2026
lmduy2612
left a comment
There was a problem hiding this comment.
Reviewed contracts/shade/tests/resource_costs.rs, scripts/resource-costs/measure-shade.sh, and docs/reference/resource-costs.md. Resetting the Soroban environment budget to unlimited before each single top-level batch invocation and reading env.cost_estimate().resources() is a clean way to capture linear scaling past per-transaction ledger limits.
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
Measures and publishes Soroban resource costs for the Shade hub operations, with maximum safe batch sizes and a reproducible way to regenerate them.
Type of Change
Linked Issue
Fixes #497
Changes Made
docs/reference/resource-costs.md: measured cost tables forregister_merchant,create_invoice,pay_invoice,pay_invoices_batchandget_invoices, alongside the existingprocess_billing_cycletable; safe batch sizes; measurement caveats; most-expensive-operations summarycontracts/shade/tests/resource_costs.rs: harness usingenv.cost_estimate().resources()scripts/resource-costs/measure-shade.sh: regenerates the numbersResults:
pay_invoices_batchmax safe batch is 17 invoices (event bytes bind first);get_invoicesfails on read entries beyond 98 stored invoices;pay_invoiceis the heaviest single call (about 0.56M instructions).Important caveat
The
shadecrate does not compile on currentmain(KYC and campaign-royalty code was merged without itsDataKey,ContractErrorand event definitions; vesting structs and mod lines are duplicated). The Shade numbers are therefore measured on the last compiling commit (4c97ca0) in a temporary worktree, with a small patch applying the samepay_invoices_batchsingle-auth fix thatmainalready has. The script runs in place oncemainbuilds again.purchase_tickets_bulkis not measured (it does not exist in that snapshot) and the testnet fee range is not published (no testnet measurement); both are stated in the doc.Test Evidence
scripts/resource-costs/measure-shade.shrun end to end; all 3 harness tests pass on the snapshotmarkdownlint-cli2clean on the docmake test/make lintcannot run forshadebecause of the pre-existing compile failure onmain; the harness file is rustfmt-cleantest_snapshots/file is staged in this PRDocumentation Updates
docs/pageChangelog