Description
packages/stellar/src/soroban.ts enforces MAX_WASM_SIZE_BYTES but does not report optimization opportunities. Implement a validation pipeline that analyzes WASM binaries for size optimization: unused imports, dead code, and unoptimized sections.
Requirements and Context
- Detect: unused host function imports, unoptimized data segments, redundant type definitions
- Report size breakdown: code section, data section, import section, custom sections
- Suggest optimization actions: strip debug info, enable wasm-opt, remove unused imports
- Pipeline must run in <2 seconds for a 64KB WASM binary
Suggested Execution
Branch: feat/soroban-wasm-size-optimization-pipeline
Implement Changes
- Create
wasm-analyzer.ts in packages/stellar/src/
- Parse WASM binary structure using a lightweight WASM section parser
- Compute per-section size contributions and identify largest sections
- Add tests for section parsing, unused import detection, and optimization suggestions
Test and Commit
Run pnpm test --filter=stellar -- wasm-analyzer and confirm section analysis tests produce expected breakdowns.
Example Commit Message
feat(soroban): add WASM binary size analysis pipeline with optimization suggestions
Co-authored-by: <your-name>
Guidelines
- Branch off
main, keep PRs focused on one issue
- All new code must include unit or integration tests
- Ensure
pnpm lint and pnpm typecheck pass before review
- Link this issue in your PR description
- Request review from at least one maintainer before merging
Description
packages/stellar/src/soroban.tsenforces MAX_WASM_SIZE_BYTES but does not report optimization opportunities. Implement a validation pipeline that analyzes WASM binaries for size optimization: unused imports, dead code, and unoptimized sections.Requirements and Context
Suggested Execution
Branch:
feat/soroban-wasm-size-optimization-pipelineImplement Changes
wasm-analyzer.tsinpackages/stellar/src/Test and Commit
Run
pnpm test --filter=stellar -- wasm-analyzerand confirm section analysis tests produce expected breakdowns.Example Commit Message
Guidelines
main, keep PRs focused on one issuepnpm lintandpnpm typecheckpass before review