Skip to content

ci: enforce per-contract WASM size budgets#713

Merged
Jagadeeshftw merged 2 commits into
Fluxora-Org:mainfrom
Imole203:ci-wasm-size-budget
Jun 25, 2026
Merged

ci: enforce per-contract WASM size budgets#713
Jagadeeshftw merged 2 commits into
Fluxora-Org:mainfrom
Imole203:ci-wasm-size-budget

Conversation

@Imole203

Copy link
Copy Markdown
Contributor

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):

  1. Builds all three contracts — cargo build --release --workspace --target
    wasm32-unknown-unknown
  2. Runs stellar contract optimize on each artifact (best-effort, non-fatal)
  3. Hard gate on raw WASM size via check-wasm-size.sh — fails the job on breach
  4. Informational pass on optimized sizes
  5. Uploads all six artifacts for auditor download

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

- 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)
@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Jagadeeshftw Jagadeeshftw merged commit c7a7133 into Fluxora-Org:main Jun 25, 2026
@Jagadeeshftw

Copy link
Copy Markdown
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.

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.

Add WASM size-budget CI check for fluxora_stream, fluxora_factory, and fluxora_governance

3 participants