Skip to content

Commit ac2b235

Browse files
Merge branch 'master' into task/resolution-authsnap
2 parents 80231b5 + 489fb5a commit ac2b235

212 files changed

Lines changed: 48541 additions & 16469 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[net]
2+
git-fetch-with-cli = true

.github/workflows/gas.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Gas Budget Regression Gate
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
gas-check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Run Gas Regression Script
19+
run: |
20+
chmod +x scripts/gas-regression.sh
21+
# Replace these with actual gas fetching commands in real usage
22+
BASELINE_GAS=1000000
23+
NEW_GAS=1040000
24+
./scripts/gas-regression.sh $BASELINE_GAS $NEW_GAS

.github/workflows/wasm-size.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: WASM Size Budget
2+
3+
# Enforces per-contract WASM size budgets so accidental bloat is caught in CI
4+
# before it reaches mainnet deployment. Budgets are intentionally conservative
5+
# and should be updated via a deliberate PR if a contract genuinely needs more
6+
# space (e.g. a new feature module).
7+
#
8+
# Budget table (release build, wasm32v1-none, opt-level=z + LTO):
9+
# hello-world : 20 KB – toy example, must stay tiny
10+
# governance-events : 24 KB – pure event types + emitters, no logic
11+
# predictify-hybrid : 900 KB – full prediction-market contract
12+
#
13+
# The governance-events crate was added in FWC26 (Stellar Wave).
14+
15+
on:
16+
push:
17+
branches: [ "master", "main" ]
18+
pull_request:
19+
branches: [ "master", "main" ]
20+
21+
jobs:
22+
check-size:
23+
runs-on: macos-latest
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Install Rust
29+
run: |
30+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
31+
source $HOME/.cargo/env
32+
rustup target add wasm32v1-none
33+
34+
- name: Install Stellar CLI
35+
run: |
36+
brew update
37+
brew install stellar-cli
38+
39+
- name: Build contracts (release, wasm32v1-none)
40+
run: |
41+
source $HOME/.cargo/env
42+
stellar contract build
43+
44+
# ── Per-contract size gates ──────────────────────────────────────────────
45+
# Each WASM is checked against its own budget. Any file that does not
46+
# match a known contract name triggers a strict 20 KB fallback so unknown
47+
# contracts cannot sneak through with unbounded size.
48+
49+
- name: Check WASM sizes
50+
run: |
51+
set -euo pipefail
52+
source $HOME/.cargo/env
53+
54+
# Budgets in bytes (release + opt-level=z + LTO)
55+
BUDGET_HELLO_WORLD=20480 # 20 KB
56+
BUDGET_GOVERNANCE_EVENTS=24576 # 24 KB (FWC26 governance-events crate)
57+
BUDGET_PREDICTIFY_HYBRID=921600 # 900 KB
58+
BUDGET_FALLBACK=20480 # 20 KB (any unknown contract)
59+
60+
FAIL=0
61+
62+
for wasm_file in target/wasm32v1-none/release/*.wasm; do
63+
[ -f "$wasm_file" ] || continue
64+
65+
SIZE=$(stat -f%z "$wasm_file")
66+
BASE=$(basename "$wasm_file" .wasm)
67+
68+
case "$BASE" in
69+
hello_world)
70+
BUDGET=$BUDGET_HELLO_WORLD ;;
71+
governance_events)
72+
BUDGET=$BUDGET_GOVERNANCE_EVENTS ;;
73+
predictify_hybrid)
74+
BUDGET=$BUDGET_PREDICTIFY_HYBRID ;;
75+
*)
76+
BUDGET=$BUDGET_FALLBACK ;;
77+
esac
78+
79+
BUDGET_KB=$(( BUDGET / 1024 ))
80+
SIZE_KB=$(echo "scale=1; $SIZE / 1024" | bc)
81+
82+
if [ "$SIZE" -gt "$BUDGET" ]; then
83+
echo "::error file=$wasm_file::WASM size budget exceeded: $BASE = ${SIZE_KB} KB (budget ${BUDGET_KB} KB)"
84+
FAIL=1
85+
else
86+
echo "OK $BASE: ${SIZE_KB} KB / ${BUDGET_KB} KB"
87+
fi
88+
done
89+
90+
if [ "$FAIL" -eq 1 ]; then
91+
echo ""
92+
echo "One or more contracts exceeded their WASM size budget."
93+
echo "If the growth is intentional, update the budget table in"
94+
echo ".github/workflows/wasm-size.yml with a justification comment."
95+
exit 1
96+
fi
97+
98+
echo ""
99+
echo "All contracts are within their WASM size budgets."
100+
101+
# ── Size report (informational, never fails the build) ───────────────────
102+
- name: Report WASM sizes
103+
if: always()
104+
run: |
105+
echo "### WASM size report" >> $GITHUB_STEP_SUMMARY
106+
echo "" >> $GITHUB_STEP_SUMMARY
107+
echo "| Contract | Size |" >> $GITHUB_STEP_SUMMARY
108+
echo "|---|---|" >> $GITHUB_STEP_SUMMARY
109+
for wasm_file in target/wasm32v1-none/release/*.wasm; do
110+
[ -f "$wasm_file" ] || continue
111+
SIZE=$(stat -f%z "$wasm_file")
112+
SIZE_KB=$(echo "scale=1; $SIZE / 1024" | bc)
113+
BASE=$(basename "$wasm_file" .wasm)
114+
echo "| \`$BASE\` | ${SIZE_KB} KB |" >> $GITHUB_STEP_SUMMARY
115+
done
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"specId": "f34fcfc8-0919-4db6-af1e-7536d95694de", "workflowType": "requirements-first", "specType": "feature"}

0 commit comments

Comments
 (0)