Default generated rust project errors

If your building the generated rust project, you might get the message when you try to deploy to prod.

Message bytes 2162089 is bigger than the max allowed 2097152

as glinuxdev pointed out in dfinity-dev discord rust channel, you need to use this ic-cdk-optimizer to deploy to prod.

Installing optimizer


#!/usr/bin/env bash

cargo build --target wasm32-unknown-unknown --release --package society_rs && \
 ic-cdk-optimizer ./target/wasm32-unknown-unknown/release/rusthelloworld_rs.wasm -o ./target/wasm32-unknown-unknown/release/rusthelloworld-rs-opt.wasm


"rusthelloworld": {
      "candid": "src/rusthelloworld/rusthelloworld.did",
      "package": "rusthelloworld",
      "type": "rust",
      "build": "./"

Root Cargo.toml

members = [

lto = true
opt-level = 'z'
codegen-units = 1

These are the settings I use, if anyone has better settings, please let me know.