SubstrateChess / pallet-chess

The Unlicense
11 stars 6 forks source link

WASM exceed issue: Insufficient resources: memory minimum size of 2092 pages exceeds memory limits #27

Open hbulgarini opened 1 year ago

hbulgarini commented 1 year ago

When the pallet is added in Trappist, the chain gets stalled and it stops producing blocks. Apparently, the error starts when the validators wants to run PoV function for the parachain:

2023-05-04 17:25:58 Failed to validate candidate para_id=Id(1836) error=InvalidCandidate(WorkerReportedError("execute: execute error: RuntimeConstruction(Other(\"failed to instantiate a new WASM module instance: Insufficient resources: memory minimum size of 2092 pages exceeds memory limits\"))"))

Tests were done running release 0.9.37 during the preparations for Trappist deployment on Rococo.

CC: @kalaninja

bernardoaraujor commented 1 year ago

it seems a runtime wasm including pallet-chess is a few Mb, which is indeed a lot.

this is likely cozy-chess bloating the size.

we are only using a fraction of the crate's functionality, so I wonder if there's a way to strip down all the unused code from the runtime wasm?

There's a few interesting resources here: https://rustwasm.github.io/docs/book/reference/code-size.html

Also dropping this on SE: https://substrate.stackexchange.com/questions/8443/prevent-unused-imports-from-bloating-up-runtime-wasm

Moliholy commented 1 year ago

As discussed with @hbulgarini, he is able to reproduce the problem, but I am not. Instead, everything works fine and all parachains produce blocks without any issue. These are the wasm sizes I get when compiling trappist:

$ ls -liash target/release/wbuild/trappist-runtime/trappist_runtime.*
1787634  2704 -rw-r--r--@ 1 molina  staff   1.3M May 30 17:08 target/release/wbuild/trappist-runtime/trappist_runtime.compact.compressed.wasm
1787600 16232 -rw-r--r--@ 1 molina  staff   7.9M May 30 17:09 target/release/wbuild/trappist-runtime/trappist_runtime.compact.wasm
1787635 15944 -rwxr-xr-x@ 1 molina  staff   7.8M May 30 18:06 target/release/wbuild/trappist-runtime/trappist_runtime.wasm

I don't really know which of the three is causing the issue, to be honest. Do you guys have any clue?

bernardoaraujor commented 1 year ago

what's the size of the trappist runtime without the chess pallet?

AlexD10S commented 1 year ago

Any updates with this issue? I want to help with it. I have been building a front end app to interact with the Chess pallet, and it would be great to deploy it if we have the chess pallet live.

hbulgarini commented 1 year ago

Any updates with this issue? I want to help with it. I have been building a front end app to interact with the Chess pallet, and it would be great to deploy it if we have the chess pallet live.

Not really, since it was removed from trappist runtime we are not much diving into this project anymore.