Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmwasm v 0.11 - broken wasm files (deserialization error) #288

Closed
BlockscapeLab opened this issue Oct 11, 2020 · 9 comments
Closed

Cosmwasm v 0.11 - broken wasm files (deserialization error) #288

BlockscapeLab opened this issue Oct 11, 2020 · 9 comments
Labels
duplicate This issue or pull request already exists

Comments

@BlockscapeLab
Copy link

After I upgraded my toolchain to cosmwasm v 0.11. I can't upload contracts any longer to wasmd with 'wasmcli tx wasm store 'contractv11.wasm'

Following error encountered:

ERROR: create wasm contract failed: Error calling the VM: Error during static Wasm validation: Wasm bytecode could not be deserialized. Deserialization error: "I/O Error: UnexpectedEof": failed to execute message; message index: 0: failed to simulate tx

Of course I recompiled my existing contract with cargo clean/build/schema/wasm before.

Here are more details:

ls -l contractv11.wasm
-rwxr-xr-x 1 changed staff 1640608 Oct 10 20:35 contractv11.wasm

file contractv11.wasm
contractv11.wasm: WebAssembly (wasm) binary module version 0x1 (MVP)

$uname -a
Darwin MacBook-Pro-16-inch-2019 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64

docker version
Client: Docker Engine - Community
Cloud integration 0.1.18
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 16:58:31 2020
OS/Arch: darwin/amd64
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:07:04 2020
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: v1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683

Here is the repo with the contract: https://github.com/BlockscapeLab/contractv11/tree/master

@webmaster128
Copy link
Member

Thank you for the report. Could you upload contractv11.wasm? Then we can check with other tools if the Wasm bytecode is valid. Maybe our deserializer cannot handle certain inputs.

@webmaster128
Copy link
Member

Could you upload contractv11.wasm?

Nevermind, it is in your repo.

@webmaster128
Copy link
Member

I tested contractv11.wasm (1.6M; 30d724b2cc84fb30ee11083b698966a449cfb6294d9644aafd98d89fc9b58b35) with the VM directly and can deserialize it. So I assume it is corrupted somewhere in between.

@ethanfrey is it possible the contract is silently corrupted in the wasmd CLI or the chain because it is 1.6 MB in size?

@ethanfrey
Copy link
Member

I don't see how 1.6MB fits in wasmd block limit. I have tried to upload similarly large files and gotten rejected by tendermint rpc.

In any case, somewhere along the line in the tx processing (abci), this steps over some limit. I can look more where it is and how it gets that far.

However, I wonder why this is so large. I usually get around 200kb when I compile with rust-optimizer. Was this optimized and stripped already?

@ethanfrey
Copy link
Member

Hmmm..... wasmcli does compress (gzip) to about 1/3 of the size and we unzip on the other side. Maybe there is a limit there that is being silently enforced rather than throwing and error (I know we added protection against zip bombs). @alpe maybe you remember? Or I will investigate that Monday

@BlockscapeLab
Copy link
Author

@ethanfrey, in folder artifacts there is a downsized (production) ready version of the contract with a size of 105kB, this version can be uploaded. So, it looks like that there is a limit (like you mentioned) somewhere in the ABCI interface.

@ethanfrey
Copy link
Member

It looks like we have a 400kb limit hard coded (could raise it a bit) https://github.com/CosmWasm/wasmd/blob/master/x/wasm/internal/keeper/ioutil.go#L16

But the main issue is that we cut off at the end and don't return n error https://github.com/CosmWasm/wasmd/blob/master/x/wasm/internal/keeper/ioutil.go#L32

We'll fix it. Thank you for reporting

@webmaster128
Copy link
Member

Thank you Ethan. Yes, the missing error is the biggest problem for UX and security. The constant limit should probably be turned into a config of the application using x/wasm.

Moving this ticket to wasmd.

@webmaster128 webmaster128 transferred this issue from CosmWasm/cosmwasm Oct 11, 2020
@webmaster128
Copy link
Member

This issue is now tracked in #287 and #289. For the 0.11 release series, we need to keep in mind that deserialization errors can be a caused by too large Wasm files. Thank you.

@alpe alpe added the duplicate This issue or pull request already exists label Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants