Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Different WASM VM behavior #7540

Closed
akru opened this issue Nov 14, 2020 · 4 comments
Closed

Different WASM VM behavior #7540

akru opened this issue Nov 14, 2020 · 4 comments

Comments

@akru
Copy link
Contributor

akru commented Nov 14, 2020

  • Node1: substrate 2.0-alpha.6 based, link
  • Node2: substrate 2.0 based, link

Description

During the upgrade Plasm node up to a stable substrate version, the different WASM runtime interpreter behavior was reached.

Node1 (based on substrate 2.0-alpha.6) is able to import block 656514 without any issues. But node2 based on substrate 2.0 throw excheption in WASM mode:

ERROR panicked at 'Storage root must match that calculated.', <::core::macros::panic macros>:2:2    
WARN Block prepare storage changes error: Execution(Wasmi(Trap(Trap { kind: Unreachable })))    
WARN 💔 Error importing block 0xcd55d35b7d61d6da93d9f10628d0a72bbe6f4b43bb5821b9d9df25a952678540: Err(Other(ClientImport("Import failed: Execution: Trap: Trap { kind: Unreachable }")))

As I can see, the reason is Sudo-extrinsic 656514-2. This extrinsic upgrades runtime code. Unfortunately, the runtime WASM block was so large to be applied. It returns just false in alpha.6 VM, but throw an exception in later versions.

Request

I will be glad to get some suggestions about a better solution for it. Technically we have two options:

  • Fix VM behavior - it recovers synchronization process in WASM mode;
  • Make hardfork - it could be a workaround for sync issues.

PS: If VM behavior fixes impossible or illegal, please suggest a better way for chain hardfork: source code injections, changes, etc.

@bkchr
Copy link
Member

bkchr commented Nov 14, 2020

Yeah there was a bug at some point in the host interface which could lead to this. It probably means that you tried to apply a runtime upgrade that used host functions that were not available on the nodes at this point in time.

I will need to think about it, I don't have a good idea right now.

@akru
Copy link
Contributor Author

akru commented Dec 10, 2020

Hello @bkchr, any ideas? May be some block import hook could be used here?

@liuchengxu
Copy link
Contributor

liuchengxu commented Dec 17, 2020

Might be related, several nodes(about 10/90) of ChainX CC1 also encountered this issue, they can not import block 0x822ad79194b344baaa2f331c97a2e05321e4955785b9f3302beeea672d3333fe, we are using this commit of Substrate 11ace4e .

2020-12-17 10:07:49:229 WARN tokio-runtime-worker sync  💔 Error importing block 0x822ad79194b344baaa2f331c97a2e05321e4955785b9f3302beeea672d3333fe: Err(Other(ClientImport("Import failed: Execution failed: Wasmi(Trap(Trap { kind: Unreachable }))")))
2020-12-17 10:07:49:760 INFO tokio-runtime-worker substrate  ⚙️  Syncing  0.0 bps, target=#315189 (2 peers), best: #304854 (0xc10e…b3b3), finalized #304850 (0xc362…4587), ⬇ 198.0kiB/s ⬆ 5.9kiB/s
2020-12-17 10:07:50:533 ERROR tokio-runtime-worker runtime  panicked at 'Storage root must match that calculated.', /cargo-home/git/checkouts/substrate-7e08433d4c370a21/11ace4e/frame/executive/src/lib.rs:416:9
2020-12-17 10:07:50:533 WARN tokio-runtime-worker sc_service::client::client  Block prepare storage changes error:
Execution(Wasmi(Trap(Trap { kind: Unreachable })))
2020-12-17 10:07:50:533 WARN tokio-runtime-worker sync  💔 Error importing block 0x822ad79194b344baaa2f331c97a2e05321e4955785b9f3302beeea672d3333fe: Err(Other(ClientImport("Import failed: Execution failed: Wasmi(Trap(Trap { kind: Unreachable }))")))
2020-12-17 10:07:51:751 ERROR tokio-runtime-worker runtime  panicked at 'Storage root must match that calculated.', /cargo-home/git/checkouts/substrate-7e08433d4c370a21/11ace4e/frame/executive/src/lib.rs:416:9
2020-12-17 10:07:51:751 WARN tokio-runtime-worker sc_service::client::client  Block prepare storage changes error:
Execution(Wasmi(Trap(Trap { kind: Unreachable })))
2020-12-17 10:07:51:756 WARN tokio-runtime-worker sync  💔 Error importing block 0x822ad79194b344baaa2f331c97a2e05321e4955785b9f3302beeea672d3333fe: Err(Other(ClientImport("Import failed: Execution failed: Wasmi(Trap(Trap { kind: Unreachable }))")))

@bkchr
Copy link
Member

bkchr commented Jul 1, 2021

@akru I assume this is not relevant anymore? 🙈

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants