I usually use scheduler to upgrade my runtime and it was working fine until now.

I have Transaction exhaust block limits trying to upgrade live chain. I build the wasm using srtool v0.9.19, and the compact wasm size is around 4.3Mb. Then, I checked out my previous release commit and the wasm build at that commit is about 3.1Mb, so maybe the size difference is the problem?

I also use sudo.sudoUncheckedWeight but the transaction is stuck at broadcast status on the Polkadot UI.


  • Block Limits: 5Mb
  • Block Weights: 1 seconds, since we're using 3 seconds block time

Please, any suggestion would be very helpful.

  • 4MB might get tight. The default length limit in the node template is 5MiB: github.com/substrate-developer-hub/substrate-node-template/blob/…
    – apopiak
    Feb 21, 2022 at 17:04
  • So basically we need to upscale the block limit to 10Mib for example. But to do that we need to upgrade runtime. Now its kinda a loop
    – Daniel Lam
    Feb 21, 2022 at 18:19
  • Hey @apopiak, I wonder whether we can upgrade the runtime using the .compact.compressed.wasm file?. I've seen the forkless runtime upgrade tutorials, it seems they all use the .compact.wasm file only.
    – Daniel Lam
    Feb 21, 2022 at 18:35
  • 6
    @DanielLam, Yes you can and should use the compact.compressed.wasm and any tutorial that says to use a different file is just out of date.
    – Shawn Tabrizi
    Feb 22, 2022 at 4:16
  • 1
    @DanielLam was this issue resolved with the smaller Wasm file? if so please post that as an answer so others in the future can also learn from it
    – Shawn Tabrizi
    Feb 23, 2022 at 22:33

2 Answers 2


The issue is resolved by using .compact.compressed.wasm produced by srtool. I believe using plain cargo build should also produce the .compact.compressed.wasm.

Thanks for the support


You could

  1. turn on lto to reduce the size of the wasm blob.

In Cargo.toml, add lto = true in the [profile.release] section:

lto = true

This gives LLVM many more opportunities to inline and prune functions. Not only will it make the .wasm smaller, but it will also make it faster at runtime! The downside is that compilation will take longer.

  1. tell LLVM to optimize for size instead of speed.

LLVM's optimization passes are tuned to improve speed, not size, by default. We can change the goal to code size by modifying the [profile.release] section in Cargo.toml to this:

opt-level = 's'

Or, to even more aggressively optimize for size, at further potential speed costs:

opt-level = 'z'

Note that, surprisingly enough, opt-level = "s" can sometimes result in smaller binaries than opt-level = "z". Always measure!

  1. Use the wasm-opt tool.

The Binaryen toolkit is a collection of WebAssembly-specific compiler tools. It goes much further than LLVM's WebAssembly backend does, and using its wasm-opt tool to post-process a .wasm binary generated by LLVM can often get another 15-20% savings on code size. It will often produce runtime speed ups at the same time!

# Optimize for size.

wasm-opt -Os -o output.wasm input.wasm

# Optimize aggressively for size.
wasm-opt -Oz -o output.wasm input.wasm

# Optimize for speed.
wasm-opt -O -o output.wasm input.wasm

# Optimize aggressively for speed.
wasm-opt -O3 -o output.wasm input.wasm

From my experience wasm-opt is able to reduce a node_runtime.compact.wasm from 4.3MB to 3.8 MB. Your mileage may vary.

$ du -sh ./target/release/wbuild/node-runtime/node_runtime.compact.wasm
4.3M    ./target/release/wbuild/node-runtime/node_runtime.compact.wasm
$ wasm-opt -Oz -o output.wasm ./target/release/wbuild/node-runtime/node_runtime.compact.wasm
$ du -sh output.wasm 
3.8M    output.wasm


Edit: Sorry for lack of details on my first post attempt. I've added all the steps for you to follow and hope it works for you too.

  • substrate-wasm-builder seems already enable lto for wasm binary. Feb 24, 2022 at 7:59
  • Tks for support @navigaid. However, I just use the compressed wasm for simplicity
    – Daniel Lam
    Mar 1, 2022 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.