fix(consensus): fix amnesia recovery boot run #4768
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of change
(Source)
Currently if someone recovers their node within epoch
R
with a snapshot that's from epoch< R-1
, consensus will not start in amnesia recovery mode in epoch R as the boot counter will have already been incremented as node is trying to catch up from earlier epochs. This is problematic as it defies the whole point of the automatic amnesia recovery.Instead on this PR we track consensus participation activity from earlier epochs/run and only then we increment the boot counter. Otherwise we keep the boot counter to
0
so we effectively enforce amnesia recovery until we get to an epoch where the node is able to participate. In this case participate means "able to have performed at least one commit".Links to any relevant issues
fixes #4676
Type of change
How the change has been tested
Ran the local network with
RUST_LOG=info cargo run --release --bin iota start --force-regenesis --with-faucet
Change checklist
Tick the boxes that are relevant to your changes, and delete any items that are not.