Feat: --optimize flag for contract build#2045
Conversation
leighmcculloch
left a comment
There was a problem hiding this comment.
Great idea to expose optimize functionality on the build command.
This change as is results in different behaviour between the build and optimize commands. The optimize command doesn't rewrite the file, instead creates a new file. While the build command with the optimize option rewrites the existing file. Can you make it so that they operate the same, and build results in a .optimized.wasm file? The build summary can then output the build info as is, then output an additional couple lines about the optimized file and its size.
|
I altered the PR to add the optimized wasm file just like with the |
leighmcculloch
left a comment
There was a problem hiding this comment.
Nice. Small asks inline.
Suggestion for some small modifications to the output:
ℹ️ Build Summary:
Wasm File: target/wasm32v1-none/release/stellar_example.wasm (574 bytes)
Wasm Hash: c30e7244eb261b2204f446d15c46b8efd364e9befb5c52921454774dc9edeed3
Exported Functions: 2 found
• _
• hello
Optimized: reduced by 37 bytes
Wasm File: target/wasm32v1-none/release/stellar_example.optimized.wasm (537 bytes)
Wasm Hash: 98f44b624d792833e498b4ca33cdf2a8cebc0b84a0e402d35d17634a45969f20
✅ Build Complete
|
@leighmcculloch in stellar scaffold we place the resulting binary in |
Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
|
@fnando wdyt about this command outputting the optimized file as a separate file? I suggested it to @BlaineHeffron (sorry!) because that would make this command more consistent with the But, with optimize being added here, we maybe want to deprecate the And, when I think about most compilers, never do compilers output an unoptimized and optimized version. They output whatever the version is that was requested and only that version. So my earlier ask was probably misguided. We could flip it back after merging this, so that @BlaineHeffron can get this merged. |
|
Closing in favor of #2241 |
What
Adds an --optimize flag to
contract build. This uses the same logic fromcontract optimize; the optimized wasm is output with the usual name.Example output:
Why
Saves an extra CLI call to
optimize.Known limitations
N/A