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

Constructing with a given height #98

Merged
merged 1 commit into from
Jun 15, 2021
Merged

Conversation

ross-pure
Copy link
Member

This PR adds the feature of being able to construct a replica that will start at a given height. Using this feature also fixes a problem that can occur when trying to start a replica at a later height (for instance if blocks are being stored to disk, and consensus is restarted after a crash, you would want to start from the height after the latest stored block). The problem is as follows. The usage code will usually take the form

replica := replica.New(...)

...

go replica.Run(ctx)
replica.ResetHeight(latestHeight + 1)

The call to ResetHeight will simply add a message to the message queue, to be eventually processed by the event loop in replica.Run. However, replica.Run before entering the event loop will call process.Start which will run proposal logic and hence if the process is the current proposer for height 1 round 0 it will send out a proposal, which we want to avoid but cannot, as this will always happen before the reset height message can be processed. This can cause consensus to halt in some situations. Using a constructor that allows the process to start at the desired height resolves this issue.

@ross-pure ross-pure requested a review from jazg June 15, 2021 03:44
@ross-pure ross-pure self-assigned this Jun 15, 2021
Copy link
Member

@jazg jazg left a comment

Choose a reason for hiding this comment

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

LGTM!

@jazg jazg merged commit a465673 into release/0.4.0 Jun 15, 2021
@jazg jazg deleted the feat/with-height-constructor branch June 15, 2021 03:56
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.

2 participants