feat(build): compile WASM templates with size-optimizing cargo profile#163
Conversation
Inject size-optimizing release profile settings into the WASM template build via `cargo build --config`, so templates get small binaries without having to declare a `[profile.release]` themselves. The overrides take precedence over a template's own manifest profile: opt-level = 's' # Optimize for size lto = true # Link Time Optimization codegen-units = 1 # More optimization panic = 'abort' # Abort on panic strip = true # Strip symbols These are applied by default. Pass `--no-cargo-opts` to `tari build` / `tari publish` to skip them. Also pin curve25519-dalek to =5.0.0-pre.6: 5.0.0-rc.1 switched to the upstream `ff` 0.14 crate which breaks tari_bulletproofs_plus 0.5.0. See tari-project/bulletproofs-plus#148 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces size-optimizing release profile overrides (such as opt-level='s', lto=true, codegen-units=1, panic='abort', and strip=true) to the WASM template build process via cargo build --config. It adds a --no-cargo-opts CLI flag to the build, publish, and template publish commands to allow skipping these optimizations. Additionally, it pins the curve25519-dalek dependency to version =5.0.0-pre.6 to prevent compatibility issues with tari_bulletproofs_plus, and bumps the workspace package version to 0.20.1. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
Compile WASM templates with size-optimizing release profile settings, injected on the
cargo buildcommand line via--configso a template doesn't need to declare them in its ownCargo.toml. Because--configtakes precedence over the manifest, the overrides apply even when a template defines its own[profile.release]:These are on by default. Pass
--no-cargo-optstotari build/tari publish(andtari template publish) to skip them and build with the template's plain release profile.Changes
build_project/build_templatetake anoptimizeflag; the overrides live in aCARGO_OPT_CONFIGSconst and are only added when enabled.--no-cargo-optsadded totari build,tari publish, andtari template publish.inspect,metadata publish) use the default opts so the cargo build cache stays consistent with a normal build.Dependency fix
Pins
curve25519-dalekto=5.0.0-pre.6.5.0.0-rc.1switched to the upstreamff0.14 crate, which breakstari_bulletproofs_plus0.5.0 (Scalarno longer exposespow_vartime). Follows the repo's existinghickory-protopinning idiom (direct dep +cargo-macheteignore). See tari-project/bulletproofs-plus#148.Testing
cargo check -p tari-ootle-cli --lockedcompiles the whole workspace clean.cargo build --config "profile.release.opt-level='s'"overrides a manifest's own[profile.release], and that all five--configflags are accepted together.🤖 Generated with Claude Code