mandrean / cw-optimizoor Goto Github PK
View Code? Open in Web Editor NEWA blazingly fast compiling & optimization tool for CosmWasm smart contracts.
License: MIT License
A blazingly fast compiling & optimization tool for CosmWasm smart contracts.
License: MIT License
Running cargo build --feature x
or cargo build --all-features
works well, but trying to specify it on cw-optimizoor:
โฏ cargo cw-optimizoor -- --all-features
exits with no output and empty artifacts/
Awesome project!
I ran into an issue trying to use it with this workspace: https://github.com/DA0-DA0/dao-contracts
It produced nearly empty optimized wasm binaries for cw20_stake
and cw_core
contracts.
When I tried to use them, I got this error:
Error calling the VM: Error during static Wasm validation: Wasm contract doesn't have required export: "instantiate". Exports required by VM: ["allocate", "deallocate", "instantiate"].: create wasm contract failed: invalid request
Im wondering if optimizoor
is compiling them with the library feature enabled?
To further improve speed, the optimizations can be cached such that they only run if a change is detected and an optimized artifact with the expected checksum doesn't already exist.
With Rust 1.70, unsupported op codes appear when uploading the wasms on-chain. (See : CosmWasm/cosmwasm#1727)
One fix is available on that issue. Would it be possible to implement that ?
Thanks
You can reproduce it by running cw-optimizoor
against the head of cw-plus
.
The solution is likely to make sure any invocation of cargo build
includes the --lib
parameter.
I noticed that the cw-optimizoor optimized binaries are a bit larger than the rust workspace-optimizer for the DAO DAO contracts.
cw-optimizoor:
$ ls -lh artifacts | grep wasm | awk '{print $5,$9}'
293K cw20_stake-x86_64.wasm
295K cw20_staked_balance_voting-x86_64.wasm
196K cw4_voting-x86_64.wasm
278K cw721_stake-x86_64.wasm
161K cw_admin_factory-x86_64.wasm
404K cw_core-x86_64.wasm
175K cw_named_groups-x86_64.wasm
209K cw_names_registry-x86_64.wasm
219K cw_native_staked_balance_voting-x86_64.wasm
495K cw_proposal_multiple-x86_64.wasm
501K cw_proposal_single-x86_64.wasm
178K cw_token_swap-x86_64.wasm
244K stake_cw20_external_rewards-x86_64.wasm
190K stake_cw20_reward_distributor-x86_64.wasm
cosmwasm workspace optimizer:
$ ls -lh artifacts | grep wasm | awk '{print $5,$9}'
257K cw20_stake.wasm
261K cw20_staked_balance_voting.wasm
193K cw4_voting.wasm
276K cw721_stake.wasm
143K cw_admin_factory.wasm
407K cw_core.wasm
173K cw_named_groups.wasm
188K cw_names_registry.wasm
216K cw_native_staked_balance_voting.wasm
455K cw_proposal_multiple.wasm
460K cw_proposal_single.wasm
171K cw_token_swap.wasm
226K stake_cw20_external_rewards.wasm
171K stake_cw20_reward_distributor.wasm
You can see the % difference here: DA0-DA0/dao-contracts#474 (comment)
I wonder if there is a different optimization flag being used?
If you compile two contracts A and B where the B one imports the A, then A one will be built both as a contract and as a library.
As a consequence, the .wasm artifact for the A being built as a contract will be overwritten by the .wasm of A being built as a library. This means that there is no way to obtain A as a contract. This can be seen in the following workspace: https://github.com/osmosis-labs/osmosis/tree/main/x/ibc-hooks.
I think I know how to fix this, so I'll try to submit a PR when I have time, but leaving the issue here in case someone gets to it before me.
In case it doesn't have permission to write binaries to directory (created by the docker, for ex.) after finishing it simply prints:
๐ค Intermediate checksums:
But it didn't create any binaries, so IMO it should throw an error
Still not sure the root of the problem but when optimizing my contract I was getting schemas that were very old (like not even on in my repo old). Problem was solved by using the normal docker optimizer.
One should be able to run any of these as well:
$ cargo cw-optimizoor
$ cargo cw-optimizoor .
$ cargo cw-optimizoor <some_repo>
Something like:
There is a newer version (v0.6.0) of cw-optimizoor available!
Current version is 0.5.1. To update, run: cargo install cw-optimizoor
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.