Deploying a zipped wasm

It was discussed on the tooling call that it was possible to deploy a zipped wasm and the replica would take care of decompressing it. I was trying to do this with dfx 10 by zipping my wasm and creating a different dfx project that referenced the compressed file. When I try to install I get

Error: The Replica returned an error: code 5, message: “Wasm module of canister a4lpi-tiaaa-aaaaa-aadka-cai is not valid: Wasmtime failed to validate wasm module wasmtime::Module::validate() failed with Bad magic number (at offset 0)”

Is it possible to do this with the local replica? Or is it just a mainnet feature?

Hi @skilesare !

What program do you use to compress the module? The replica currently supports only GZip-compressed modules:

  • If the wasm_module starts with byte sequence [0x1f, 0x8b, 0x08] , the system decompresses the contents of wasm_module as a gzip stream according to RFC-1952 and then parses the output as a WebAssembly binary.
    Smart Contracts on the Internet Computer

You can use either gzip or pigz to compress the module.

1 Like

Ok. I was right clicking compress on Mac and I’m guessing that won’t work. I’ll try gzip which will work better from the command line anyway.

This still isn’t working for me. I get

Error: The Replica returned an error: code 5, message: “Wasm module of canister rrkah-fqaaa-aaaaa-aaaaq-cai is not valid: Wasmtime failed to validate wasm module wasmtime::Module::validate() failed with Bad magic number (at offset 0)”

config is:
“ledger”: {
“wasm”: “./ledger-canister.wasmr-min20220527ledgerfix.wasm”,
“type”: “custom”,
“candid”: “…/…/modules/ogy_ledger_canister/ledger_dfx_v2.did”
},

This file was gzipped and I took the .gz off the end(because it didnt’ work with that.