Skip to content

sp-io: report runtime panic messages to the host by default#12684

Open
hitchho wants to merge 2 commits into
paritytech:masterfrom
hitchho:feat/panic-message-by-default
Open

sp-io: report runtime panic messages to the host by default#12684
hitchho wants to merge 2 commits into
paritytech:masterfrom
hitchho:feat/panic-message-by-default

Conversation

@hitchho

@hitchho hitchho commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Description

Makes improved_panic_error_reporting the default behavior of sp-io's runtime panic handler: panics (and OOM aborts) now marshal their message to the host via the PanicHandler::abort_on_panic host function instead of logging and executing unreachable. Callers get Runtime panicked: <message> (sc_executor_common::Error::AbortedDueToPanic) instead of the opaque:

Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed

The old behavior remains available behind a new opt-out feature, legacy_panic_error_reporting, for runtimes that must target a host without the PanicHandler host functions. improved_panic_error_reporting is kept as a deprecated no-op so existing Cargo.tomls don't break.

Motivation

The abort_on_panic mechanism has existed for years, yet outside sc-executor's own test runtime it appears to have virtually no production adoption — chains ship with the opaque-trap default and users pay for it at debugging time. Concrete example from galacticcouncil/hydration-node#1491: a SCALE decode failure of a runtime-API parameter (Bad input data provided to dry_run_call: Codec error…) surfaced over public RPC as a bare wasm trap, was misdiagnosed as a runtime execution bug, and took a chopsticks fork to root-cause — the actual panic message only ever reached the node's local logs. With this change the message reaches the RPC caller directly.

Compatibility

  • sc-executor has captured the panic message (HostState::panic_messageAbortedDueToPanic) since 2022.
  • smoldot implements ext_panic_handler_abort_on_panic_version_1.
  • Polkadot PVF validation: the PVF executor's host function list does not include PanicHandler, but it instantiates with allow_missing_func_imports: true, so PVFs built with the new default still prepare and execute; a panic during validation traps just as it does today (outcome-identical: candidate invalid).
  • Hosts predating the host function (or custom embedders without it) can build the runtime with legacy_panic_error_reporting.

Review notes

  • substrate/client/executor/runtime-test already enables improved_panic_error_reporting, so executor tests exercise the new-default path today; trap-asserting tests (call_not_existing_function, unreachable_intrinsic, host-allocator failure) cover genuine traps and are unaffected.
  • The deprecated no-op feature can be removed in a follow-up major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant