Optimize wasm by default on contract build#2581
Conversation
|
Claude finished @fnando's task in 2m 53s —— View job Claude Code Review
Overall this is a solid, well-scoped change. The intent is clear, the help text is updated, and the feature-gating cleanup is consistent across Suggestions / potential issues1. #[arg(
long,
default_value_t = true,
default_missing_value = "true",
num_args = 0..=1,
action = clap::ArgAction::Set,
)]
pub optimize: bool,With 2. The new manual
3. Moving 4. fn check_optional_features(print: &Print) {
print.checkln("Wasm optimization");
...
}This line now unconditionally prints a green check regardless of build configuration, because wasm-opt is always compiled in. It's not wrong, but it's not really a "check" either — it conveys no information. Two options:
5. Removed error variant This is a public enum variant of 6. Minor: missing regression test A small unit test asserting Things I like
Nothing blockingThe changes are coherent and the user-facing behavior is a strict improvement. The clap |
There was a problem hiding this comment.
Pull request overview
Makes wasm-opt always compiled in and turns --optimize on by default for stellar contract build (and deploy/upload which share BuildArgs). The additional-libs cargo feature continues to gate the OS keyring and Ledger hardware-wallet integrations only.
Changes:
BuildArgs::optimizebecomes aboolflag defaulting totrue(overridable via--optimize=false); related cfg gating, error variants, and theDefaultimpl are updated accordingly.wasm-optis moved out of theadditional-libsfeature inCargo.toml, andoptimize.rsdrops allcfg(feature = "additional-libs")gating and theInstallerror.- Doctor output unconditionally reports "Wasm optimization" as available; FULL_HELP_DOCS.md is regenerated to document the new
--optimize <bool>flag.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| FULL_HELP_DOCS.md | Regenerated help to reflect --optimize <OPTIMIZE> with true default. |
| cmd/soroban-cli/Cargo.toml | Removes wasm-opt from additional-libs and makes it a non-optional dep. |
| cmd/soroban-cli/src/commands/contract/build.rs | Unconditionally imports optimize, makes --optimize default to true, drops cfg-gated error paths, adds explicit Default impl. |
| cmd/soroban-cli/src/commands/contract/optimize.rs | Removes all additional-libs cfg gating and the Install error since wasm-opt is always present. |
| cmd/soroban-cli/src/commands/doctor.rs | Always reports Wasm optimization as available; removes it from the disabled-features list. |
|
Claude finished @fnando's task in 2m 8s —— View job Claude Code Review (update)
What changed since the previous reviewCommit
Still open from prior review
Re: Copilot's deprecation comment on
|
|
Thanks for the review. Replies to each item:
|
I expect this breaks something. I think we should keep the additional lib inside additional libs. For the binary releases leaving it there will have no impact so no impact for most people. |
leighmcculloch
left a comment
There was a problem hiding this comment.
One comment otherwise lgtm 🎉
|
Claude finished @fnando's task in 3m 8s —— View job Claude Code Review (update)
What changed since the previous review
This is the right shape: binary releases (which bundle Items worth a look before merge1. Warning is printed once per package, not once per run — #[cfg(not(feature = "additional-libs"))]
if self.build_args.optimize {
print.warnln("Optimization skipped: ...");
}
// then drop the per-iteration printThis also gives the user the warning before any compile work starts, so they can Ctrl-C and reinstall if they want optimization. Fix this → 2. Asymmetry between 3. 4. Help text doesn't acknowledge feature-gated availability — The Items I previously raised and now consider resolved
SummaryThe pivot from "make wasm-opt unconditional" to "keep wasm-opt gated, warn instead of fail" is a clean fix that lands the user-visible win (optimize-by-default) without forcing · Branch: |
|
Claude finished @fnando's task in 1m 2s —— View job Claude Code Review (update)
What changed since my last reviewOnly one new commit: Items I previously raised and now consider resolved
Still open from the prior review1. Per-package warning duplication — 2. Items the author has explicitly declined and I won't keep raising
Summary
· Branch: |
What
stellar contract buildnow runswasm-opton the generated wasm by default. The previous behaviour required passing--optimize. To skip optimization, pass--optimize=false.When
stellar-cliis built without theadditional-libsfeature (which gateswasm-opt, OS keyring, and Ledger hardware-wallet support), the build still succeeds with an un-optimized wasm and prints a warning suggesting reinstalling with--features additional-libs.Why
Optimized wasm is what users almost always want to ship, and forgetting
--optimizeproduced larger artifacts than necessary. Making it the default removes a footgun and matches whatstellar contract optimize(already deprecated in favour ofbuild --optimize) was encouraging.Close #2565
Close #2284
Known limitations
N/A