-
Notifications
You must be signed in to change notification settings - Fork 51
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
ForbiddenSlotType when syncing Kusama from genesis #738
Comments
Hi, I would lean towards a bug in smoldot. While the code of smoldot is generally in good shape, the lack of unit tests means that there are probably many small mistakes. Given that plain slots aren't used anymore on any chain, it's likely that this went undetected.
Note that you have to do the runtime call against block 0, as this configuration has changed over time. PolkadotJS unfortunately doesn't give you the possibility to choose which block to execute the call against. From the top of my head (I haven't checked), the Kusama genesis block should be configured as |
My suspicion would be that this is wrong:
It is the code that decodes the BABE configuration when the version of the BABE API was still version 1, a long time ago. |
I think it is indeed wrong. The Substrate code that turns a |
True, I'd hoped that this configuration would be something that doesn't change in the runtime, given that it is supposed to only be executed at the genesis block. But this of course also means that nothing breaks if it is changed afterwards since all nodes use the genesis runtime (though that makes this call in PolkadotJS rather useless). |
Thanks for finding and reporting this! |
Hello,
I'm trying to sync Kusama from the genesis block using
NonFinalizedTree<T>
(see the code below) but I'm getting the following error:It works when trying to sync from genesis on Polkadot (same code, just replacing chain specification, hash and header)
Chain specification used: https://github.com/paritytech/polkadot/blob/master/node/service/chain-specs/kusama.json
Block 1 1: I've requested this block through the JsonRPC api, json decoded and scale encoded it. Since the hash calculated from the scale encoded header still matches this should be correct.
BabeApi_configuration
runtime call (executed via polkadot.js.org and when debugging the result of the wasm call in smoldot), theSecondarySlot
2 is set toPrimaryAndSecondaryVRFSlots
for both Polkadot and Kusama.What I do not understand is why the PreDigest of Kusama block 1 1 is apparently part of the canonical chain but is not allowed to be the first block on said chain according to smoldot and what I understood from the
BabeApi_configuration
runtime call.Kusama block 1 PreDigest:
Polkadot block 1 PreDigest:
(decoded according to 4)
Smoldot first checks for the parent hash 5 before checking Babe related information 6, so the parent_hash must match the genesis block in the chain configuration. So if we have a wrong/bad chain specification smoldot probably complain somewhere that the wasm code did not match the code in the genesis block, otherwise I don't know how we'd get into this situation unless this header is invalid and polkadot.js.org gives me bad Information.
So here is my conclusion so far on what the reason could be (I hope you can confirm or deny some of these):
PrimaryAndSecondaryVRFSlots
when using polkadot.js.org (unless that just executes smoldot code in the background, which could be the case).I hope someone can help me with that. While I could sync from a later checkpoint (and will probably end up doing so anyways), I'd still like to get a sync from genesis to work.
Thank you in advance (and sorry for the long text).
PS: Yes, I know about the possibility of long-range attacks.
Minimal example
Footnotes
https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fksm-rpc.stakeworld.io#/explorer/query/0xcd9b8e2fc2f57c4570a86319b005832080e0c478ab41ae5d44e23705872f5ad3 ↩ ↩2
https://spec.polkadot.network/sect-block-production#defn-consensus-message-babe ↩
https://github.com/smol-dot/smoldot/blob/main/lib/src/verify/babe.rs#L239 ↩
https://spec.polkadot.network/sect-block-production#defn-babe-header ↩
https://github.com/smol-dot/smoldot/blob/main/lib/src/chain/blocks_tree/verify.rs#L156 ↩
https://github.com/smol-dot/smoldot/blob/main/lib/src/chain/blocks_tree/verify.rs#L246 ↩
The text was updated successfully, but these errors were encountered: