No code size check for uncompressed runtime wasm
dimitrovmaksim opened this issue · comments
Injecting 60MB NOPs into validate_block
function using wasm-injector
, the produced wasm is hexified, but not compressed
Kagome Version: 0.9.0-127
Polkadot 0.9.43-ba42b9ce51d
extracted genesis wasm for rococo-staging using polkadot-parachain 1.0.0-2306bfb7565
Zombienet 1.3.65
The Issue:
While implementing our code-size
tests, we noticed that the pvf size is only checked if the wasm is compressed, but uncompressed wasm will fail with memory allocation error instead. This issue is present in both Polkadot and Kagom. While the node execution does not terminate, the logs do not provide meaningful information about the error:
Polkadot:
2023-09-05 05:57:36.210 DEBUG tokio-runtime-worker parachain::candidate-validation: Runtime API request internal error relay_parent=0x3c63fece7b8d1a840bdb01bd10010b3bf8e341b4acba892f0e383f51a242ec6e err=Execution { runtime_api_name: "validation_code", source: Application(Execution(AbortedDueToTrap(MessageWithBacktrace { message: "Requested allocation size is too large", backtrace: Some(Backtrace { backtrace_string: "error while executing at wasm backtrace:\n 0: 0x138c4 - <unknown>!sp_io::storage::get::hfeae4d344b09d75c\n 1: 0x3ba50b - <unknown>!frame_support::storage::unhashed::get::h997de3dd45e45dce\n 2: 0x3ba3d2 - <unknown>!polkadot_runtime_parachains::runtime_api_impl::v4::validation_code::{{closure}}::h632a6d6d12d2adda\n 3: 0x3f2043 - <unknown>!ParachainHost_validation_code" }) }))) }
2023-09-05 05:57:36.210 ERROR tokio-runtime-worker parachain::candidate-backing: Failed to validate and make available: ValidationFailed(ValidationFailed("Assumption Check: Bad request"))
Full logs:
polkadot-uncompressed-wasm.log
Kagome:
23.09.05 06:06:54.788394 worker.2 Error RuntimeExternalInterface Trap: final > memory: 68468104 > 67108864
23.09.05 06:06:54.788807 worker.2 Warning ParachainProcessorImpl Candidate 0x8ac6…c929 on relay_parent 0x622d…bdc9, para_id 2000 validation failed with error: An error occurred during an export call execution
23.09.05 06:06:54.788896 worker.2 Info ParachainProcessorImpl Parachain validation lasted for 588 ms
23.09.05 06:06:54.788915 worker.2 Warning ParachainProcessorImpl Validation task failed.(error=Validate and make available failed)