diff --git a/.github/workflows/contracts-ci.yml b/.github/workflows/contracts-ci.yml index 5b9d75d..59a0b49 100644 --- a/.github/workflows/contracts-ci.yml +++ b/.github/workflows/contracts-ci.yml @@ -110,6 +110,27 @@ jobs: stellar contract build --manifest-path contracts/oracle-adapter/Cargo.toml stellar contract build --manifest-path contracts/vault/Cargo.toml + - name: Check WASM size budgets + run: | + node -e ' + const fs = require("fs"); + const path = require("path"); + const budgets = JSON.parse(fs.readFileSync("contracts/size-budget.json", "utf8")); + let failed = false; + for (const [name, budget] of Object.entries(budgets)) { + const file = path.join("target/wasm32v1-none/release", `${name}.wasm`); + if (fs.existsSync(file)) { + const size = fs.statSync(file).size; + console.log(`[SIZE] ${name}: ${size} bytes (budget: ${budget} bytes)`); + if (size > budget) { + console.error(`[ERROR] ${name} exceeds budget (${size} > ${budget})`); + failed = true; + } + } + } + if (failed) process.exit(1); + ' + # Published with the artifacts, so the hash of a deployed contract's wasm # can be checked against the commit that built it. - name: Record wasm checksums diff --git a/CHANGELOG.md b/CHANGELOG.md index 7053e87..c59d3d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- `ci`: Add `contracts/size-budget.json` establishing tracked byte thresholds for each contract, enforced in `.github/workflows/contracts-ci.yml` (#94). - `ci`: Add `deny.toml` and `cargo-deny` check in `.github/workflows/security.yml` to enforce license compliance (Apache-2.0, MIT, BSD) and deny unknown registries (#91). - Stage 1 developer-experience tooling: - `.gitattributes` normalizing all tracked text to LF (`*.sh`, `*.rs`, `*.ts`, `*.md`, and the other text formats in the tree) and marking `Cargo.lock` and `package-lock.json` as generated. The tree was re-normalized once, and a new **Line Endings** workflow fails any pull request that reintroduces CRLF into the index (#85). diff --git a/contracts/size-budget.json b/contracts/size-budget.json new file mode 100644 index 0000000..13ba851 --- /dev/null +++ b/contracts/size-budget.json @@ -0,0 +1,7 @@ +{ + "rwa_asset": 65536, + "registry": 65536, + "compliance": 65536, + "governance": 65536, + "oracle_adapter": 65536 +}