archway-network / cli

Develop WASM smart contracts with the Archway network developer CLI
https://docs.archway.io
Apache License 2.0
44 stars 21 forks source link

archway build --optimize support for using relative path dependencies #172

Closed drewstaylor closed 1 year ago

drewstaylor commented 1 year ago

Previously (1.2.3) we were able to use BinaryEn directly for optimizing WASM.

Once that was reverted back to using the CosmWasm Docker container for archway build --optimize we lost the ability to use relative path to dependencies in Cargo.toml.

Result: Developers with relative path dependencies need to optimize their WASM using an old version of Archway CLI (1.2.3), then use a recent version to store and deploy the contract on chain.

Note: You can still use a GitHub link to your dependencies; however, this will not work for developers with private repositories.


Suggestion:

aelesbao commented 1 year ago

This is not an issue in the Archway CLI but rather a limitation on the rust-optimizer workspace builder, which is not possible to overcome easily. You can still run the Binaryen optimizer manually to solve this problem, but if you do, I'd recommend running it on a Linux machine.

drewstaylor commented 1 year ago

@aelesbao How do I run it manually? Do you know if there's an example somewhere?

aelesbao commented 1 year ago

You can find the example in the rust-optimizer script, but it's really straight forward:

WASM="target/wasm32-unknown-unknown/release/{contract_name}.wasm"
wasm-opt -Os "$WASM" -o "artifacts/$(basename $WASM)"