Open Tarnadas opened 1 year ago
@Tarnadas, thank you for the information. To be honest, I tried the wasm-opt
util, but I didn't get the result you got. The size of the smart contract was decreased, but at the same time, gas costs were increased. But anyway, I will take a look once again and provide feedback.
thx @aleksuss,
I should also show the command that I used for compiling the engine:
cargo build --target wasm32-unknown-unknown --release --no-default-features --features=mainnet,integration-test -p aurora-engine -Z avoid-dev-deps
Not sure if the integration-test
feature could affect it. I used Rust 1.69.0
Btw only up until version 110 is working. Any newer version produces an unusable binary.
It's near-core bug: https://github.com/near/nearcore/issues/9143
Hey,
I looked through your build steps and haven't found usage of wasm-opt, which honestly surprised me. I basically use it for every contract I develop for a free bonus in runtime perf and code size.
I am currently developing a contract that uses Aurora SDK to do interactions from Aurora to the contract on Near. I have a couple of integration tests and I wanted to check what wasm-opt would change regarding gas consumption. Most of the gas is not used from Aurora contract, but from the cross contract calls and contracts on native Near, but you can clearly see a small improvement. I precompiled the Aurora contract for the integration tests like you're doing it in the
Makefile
, but for the optimized version I invokedwasm-opt -O4 res/aurora_engine.wasm -o res/aurora_engine_opt.wasm --strip-debug --vacuum
.Here are the relevant logs from my result: Unoptimized:
Optimized:
Additionally it also reduces code size:
You can also use wasm-opt for the XCC router contract.
Is there any reason why you would not want to use wasm-opt? Btw only up until version 110 is working. Any newer version produces an unusable binary. Idk what caused this, but maybe someone else knows more about this