New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable wasm builds #148
base: main
Are you sure you want to change the base?
Conversation
@webmaster128 Any chance you have time to review and merge this? Would be very helpful for us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. This is great stuff, thanks a lot.
Some comments and an improvement PR here: https://github.com/CyberHoward/optimizer/pull/1/files
I will do another round looking into the caching and ask a collegue to give it another round. But happy to get this finally moving.
Deserialize features into BTreeSet
Applied feedback, thanks! @apollo-sturdy for the |
Not directly related but FYI I think we should get rid of the aarch64 suffixes at some point. I don't think they have value anymore. #151 |
The need for featured contract compilation has been thoroughly discussed in issue #80. This PR upstreams the ability to optimize smart-contracts with different features, without hurting reproducibility.
Example
As an example let's say you have some functionality that should only be enabled on some specific chain. Currently it's extremely hard to do this without creating different contracts.
Our solution uses cargo's support for custom metadata fields to allow you to specify features that you want your contract to be built with.
I.e. if I want different logic when deploying to the
cw-sdk
then I add a feature in the contract'sCargo.toml
like so:To trigger the optimizer into building the contract with this feature add the following to the same
Cargo.toml
:After running the optimizer image as usual you will be left with:
my_contract.wasm
my_contract-cw-sdk.wasm
When using the ARM image:
my_contract-aarch64.wasm
my_contract-cw-sdk-aarch64.wasm
Extra features
default
features. This is solved by thedefault-build
boolean. (defaults totrue
)optimize.sh
script which is not under control of the Rust code. This could be changed in a future PR.Discussion
Some questions were raised about the additional caching layer that prevents re-build if the build settings are identical. I left this caching layer in place because we (Abstract) make extensive use of it. See here. However as mentioned re-building a previously built package shouldn't take much time.
Edit: We decided to remove this layer.