Skip to content
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

Updating proposer calculator on restart #1915

Conversation

stana-miric
Copy link
Contributor

Description

This PR fixes the inconsistent state of the proposer calculator on node restart. The inconsistent state occurs when the proposer calculator's height is less than or equal to the current block number. It can occur when the node is stopped at a moment when a block is inserted into the blockchain, but the post-block function for the proposer calculator doesn't update the snapshot database. Later, when the node is started again, if the majority of valid nodes have a consistent state, everything will be okay, as the bad node will receive the new block from the syncer, which will fix the problem. However, if the majority of validators have an inconsistent state, consensus for the new block cannot be reached, and new blocks won't be produced. The solution for this is to align the proposer calculator on node startup by updating the proposer calculator's height based on the height of the current block (the last inserted block).

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

Manual tests

I've tested this scenario by changing the code by adding additional time. Sleep in order to be able to reproduce the bug and thus confirm that the scenario is for sure the one described above. This code that reproduces problematic scenario each time cannot be used as an official test and it was only used to confirm the problem and verify the fix. Also the test for a bulk drop is adapted and it probably can cause this scenario on rare occasions.

@stana-miric stana-miric added the bug fix Functionality that fixes a bug label Sep 18, 2023
@stana-miric stana-miric requested a review from a team September 18, 2023 13:37
@stana-miric stana-miric self-assigned this Sep 18, 2023
Copy link
Contributor

@igorcrevar igorcrevar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, we should also do exactly the same thing for each component that saves its internal state OnBlockInsert

@Stefan-Ethernal Stefan-Ethernal force-pushed the EVM-828-sol-eng-midnight-society-restarting-the-chain-after-blocktime-change branch from 6d81c2b to 628182e Compare September 19, 2023 10:12
@Stefan-Ethernal Stefan-Ethernal merged commit 38efd92 into develop Sep 19, 2023
7 checks passed
@Stefan-Ethernal Stefan-Ethernal deleted the EVM-828-sol-eng-midnight-society-restarting-the-chain-after-blocktime-change branch September 19, 2023 12:18
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix Functionality that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants