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

consensus: Start from saved iteration on restart #2229

Merged

Conversation

fed-franz
Copy link
Contributor

@fed-franz fed-franz commented Aug 31, 2024

Implements #1908

  • move the committee generation code from phase run function to the new generate_committee in IterationCtx
  • move get_sortition_config to IterationCtx
  • remove save_committee
  • if starting from saved_iteration != 0, generate all committees from iteration 0 to saved_iteration before running the step loop. This is needed in order to ensure we don't panic due to a missing committee when processing a message from a past iteration1.
  • extract next generator on Validation/Ratification step instead of Proposal
  • fix 'iteration < CONSENSUS_MAX_ITER' bug: last iteration is actually CONSENSUS_MAX_ITER-1, so when iteration = CONSENSUS_MAX_ITER-1 we should NOT extract the next generator

Footnotes

  1. This is a naive approach just to be on the safe side and not waste too much time. A future refactor should actually allow creating a committee on the fly, as needed (if we receive a message from the past and we don't have the committee, than generate it).

@fed-franz fed-franz linked an issue Aug 31, 2024 that may be closed by this pull request
@fed-franz fed-franz force-pushed the 1908-do-not-start-from-iteration-0-when-the-node-restarts branch from 4aac4dc to 290d7ad Compare August 31, 2024 10:39
@fed-franz fed-franz marked this pull request as ready for review September 2, 2024 08:51
@fed-franz fed-franz force-pushed the 1908-do-not-start-from-iteration-0-when-the-node-restarts branch 2 times, most recently from 64845df to 1f79d2f Compare September 2, 2024 13:48
herr-seppia
herr-seppia previously approved these changes Sep 5, 2024
Copy link
Member

@herr-seppia herr-seppia left a comment

Choose a reason for hiding this comment

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

LGTM

@fed-franz fed-franz requested a review from goshawk-3 September 5, 2024 08:07
@fed-franz fed-franz force-pushed the 1908-do-not-start-from-iteration-0-when-the-node-restarts branch 4 times, most recently from 149362d to de57bec Compare September 5, 2024 15:04
- add generate_committee to IterationCtx
- move committee generation code from phase `run` function
- remove save_committee
- move get_sortition_config to IterationCtx
- fix a bug of not extracting the next generator due to skipping
  the already done Proposal step
- extract next generator on Validation/Ratification step instead
  of Proposal
- fix 'iteration < CONSENSUS_MAX_ITER' wrong check (last iteration
  is actually CONSENSUS_MAX_ITER-1)
@fed-franz fed-franz force-pushed the 1908-do-not-start-from-iteration-0-when-the-node-restarts branch from de57bec to 69c2165 Compare September 6, 2024 16:17
@fed-franz
Copy link
Contributor Author

fed-franz commented Sep 6, 2024

Tested Successfully:

{"timestamp":"2024-09-06T16:53:17.612069Z","level":"DEBUG","event":"init","name":"sel","round":18,"iter":0,"target":"dusk_consensus::proposal::step"}
{"timestamp":"2024-09-06T16:53:24.630874Z","level":"DEBUG","event":"init","name":"validation","round":18,"iter":0,"hash":"7e3f3e72f5a0ac69...e8c557aaaf46704b","target":"dusk_consensus::validation::step"}
{"timestamp":"2024-09-06T16:53:25.291213Z","level":"DEBUG","event":"init","name":"ratification","round":18,"iter":0,"vote":"Vote: Valid(7e3f3e72f5a0ac69...e8c557aaaf46704b)","fsv_bitset":102064123,"quorum_type":"Valid","target":"dusk_consensus::ratification::step"}


{"timestamp":"2024-09-06T16:53:38.218518Z","level":"INFO","event":"VM accepted state loaded","state_root":"8ad73ffe48cecdbd3984578ddb31db83a8132a8a397b83b32feb19e4e62f94d7","target":"node::chain::acceptor"}
{"timestamp":"2024-09-06T16:53:38.226778Z","level":"DEBUG","event":"restored iteration","ru.round":18,"iter":1,"target":"dusk_consensus::consensus"}
{"timestamp":"2024-09-06T16:53:38.227156Z","level":"DEBUG","event":"init","name":"sel","round":18,"iter":1,"target":"dusk_consensus::proposal::step"}
{"timestamp":"2024-09-06T16:53:38.831083Z","level":"INFO","event":"block accepted","height":18,"iter":0,"hash":"7e3f3e72f5a0ac69...e8c557aaaf46704b","txs":0,"state_hash":"860c9b4f6b8ab66c...056f5ea97f59791e","fsv_bitset":102080507,"ssv_bitset":55187455,"block_time":10,"generator":"nvdsjA8biVgXQc7f","dur_ms":"78","label":"Attested(1)","target":"node::chain::acceptor"}

Copy link
Member

@herr-seppia herr-seppia left a comment

Choose a reason for hiding this comment

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

LGTM

@fed-franz fed-franz merged commit 9825441 into master Sep 6, 2024
15 checks passed
@fed-franz fed-franz deleted the 1908-do-not-start-from-iteration-0-when-the-node-restarts branch September 6, 2024 19:12
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.

Do not start from Iteration 0 when the node restarts
2 participants