-
Notifications
You must be signed in to change notification settings - Fork 381
Do not set best block when there already exists a best block with an higher number #544
Conversation
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
…higher number (#544) * Do not set best block when there already exists a best block with an higher number * Apply suggestions from code review Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
@@ -346,6 +346,18 @@ where | |||
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>, | |||
for<'a> &'a P: BlockImport<Block>, | |||
{ | |||
let best_number = parachain.usage_info().chain.best_number; | |||
if *header.number() < best_number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkchr Could there be the case where a re-org on the relay would actually create a re-org on the parachain leading to a lower block number becoming best ?
I'm thinking in the case where a re-org would happen over 2 blocks on the relay, and the parachain network would have only produced 1 block in the fork branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it will take one block more to set a new best block and you see the reorg later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is probably a rare case, but what if the node is the selected author for the new block after this re-org.
The node would not import the new fork block and so will not produce a new one ?
(This can/should be solved by other mechanism like selecting authors based on other input that just the previous block, but it still remains a possible issue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is certainly not a perfect solution and I think you are correct that it may lead to missed authorship opportunities during reorgs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will probably need changes in Substrate client to avoid this entire issue, but it is without a doubt possible to improve this and future client versions will address it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which block would not be imported?
This here has nothing to do with authorship. The best block is also not important for block authorship
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change here is entirely about which block will be set as new best block. And the bug we had seen will only happen on major sync, but never when we are syncing at the tip of the chain.
Moonbeam nodes still occasionally panic with this And also @purestakeoskar captured some logs of it happening on our own nodes. Can you please share those logs? |
That panic is no longer in the substrate code. Are they using the latest version of cumulus? |
We did not yet had a release that contains the Substrate version that removes the panic. |
Moonbeam 0.9.6 is using polkadot 0.9.8 branch? |
@bkchr yes it is |
@JoshOrndorff @crystalin the last log moonbeam-foundation/moonbeam#646 (comment) doesn't include the mentioned panic. So, this is not related. |
@bkchr You're right about the user-reported issue. He now has a different problem. I failed to notice that. I'm sorry about that. However, @purestakeoskar (please chime in) does have this same panic. He is running Moonbeam 0.9.6 (polkadot-v0.9.8 dependency branches). It happens on this block (https://moonbase.subscan.io/block/74522, https://moonbase-blockscout.testnet.moonbeam.network/blocks/74522/transactions) which is pretty simple (3 inherents, one eth transfer). |
This bug can not really occur on a specific block. Would be good to get some log. |
@bkchr There is a Moonbeam node runner having this problem consistently (even after deleting the parachain db). He's running Moonbeam v0.11.2, which is based on Polkadot v0.9.8. Interestingly, he is also getting stuck syncing on the block reported above (74522) before the error occurs.
|
Not sure how this can still happen. However, with the latest polkadot branch this is just an error and no panic anymore. So, updating should fix it. |
…higher number (#544) * Do not set best block when there already exists a best block with an higher number * Apply suggestions from code review Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Closes: #534