ci: enforce per-contract WASM size budgets#713
Merged
Conversation
- Add script/check-wasm-size.sh: checks fluxora_stream (256 KiB), fluxora_factory and fluxora_governance (128 KiB each); exits 1 on breach or missing artifact; supports --optimized flag; WASM_DIR overridable via env for testing - Add wasm-size-budget CI job: builds all three contracts to release WASM, runs stellar contract optimize (best-effort), enforces raw WASM budget as hard gate - Document budgets, headroom rationale, and update procedure in docs/gas.md - Add 10 new tests in TestCheckWasmSizeScript (111 total passing)
|
@Imole203 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
nice work adding per-contract wasm size budgets with the check-wasm-size.sh gate and the gas doc. merged everything except .github/workflows/ci.yml, which my account cannot push (it needs the workflow oauth scope) so someone with workflow permissions will need to add that ci.yml separately. the size-budget script and tests went in clean. |
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.
ci: enforce per-contract WASM size budgets
Summary
contracts/stream/src/lib.rs is 260+ KiB of source and the workspace builds
three WASM contracts, but CI had no size gate. A contract that silently grows
past Soroban's practical upload ceiling becomes un-deployable and expensive to
upgrade. This PR adds a hard CI check.
Changes
script/check-wasm-size.sh (new)
Measures each release artifact and fails if it exceeds its budget:
┌──────────┬────────┐
│ Contract │ Budget │
├────────────────┼────────┤
│ fluxora_stream │ 256 KiB (262 144 bytes) │
├─────────────────┼─────────────────────────┤
│ fluxora_factory │ 128 KiB (131 072 bytes) │
├────────────────────┼─────────────────────────┤
│ fluxora_governance │ 128 KiB (131 072 bytes) │
└────────────────────┴─────────────────────────┘
Budgets include ~25% headroom above the June 2026 baseline. Supports
--optimized for checking post-optimizer artifacts. WASM_DIR is env-overridable
for local testing.
.github/workflows/ci.yml
New wasm-size-budget job (runs parallel to build, after lint):
wasm32-unknown-unknown
docs/gas.md
New "WASM Size Budgets" section documenting: per-contract budgets, headroom
rationale, how to run the check locally, and the procedure for intentionally
raising a budget.
tests/test_gas_validation.py
10 new tests covering: all-pass, each contract independently over budget,
missing artifact, exact boundary, --optimized flag, executable bit, headroom
output, unknown flag. All 111 tests pass.
Testing
pytest tests/ -v # 111 passed
Security note
Size budgets are operational, not security-critical. A contract that cannot be
uploaded due to size is a liveness risk — the 25% headroom leaves room for
future features while keeping upload fees predictable. To raise a budget
intentionally, update the constant in check-wasm-size.sh and the table in
docs/gas.md in the same PR with justification.
closes #650