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

feat(consensus): HeaviestSubtreeForkChoice #505

Merged
merged 104 commits into from
Feb 24, 2025
Merged

feat(consensus): HeaviestSubtreeForkChoice #505

merged 104 commits into from
Feb 24, 2025

Conversation

dadepo
Copy link
Contributor

@dadepo dadepo commented Jan 19, 2025

This PR implements part of the HeaviestSubtreeForkChoice. Specifically part that has been identified as being used in the ReplayStage and does not depend on components not implemented yet (ie Bank, BankFork etc)

The main method identified as being used in the ReplayStage and implemented in this PR are

  • HeaviestSubtreeForkChoice.bestOverallSlot
  • HeaviestSubtreeForkChoice.setTreeRoot
    • Used in ReplayStage::handle_new_root
    • When a vote is recorded for a bank, there is a possibility it leads to a new root. When that is the case, the new root is also set in the HeaviestSubtreeForkChoice structure. See
  • HeaviestSubtreeForkChoice.addNewLeafSlot
  • HeaviestSubtreeForkChoice.containsBlock
  • HeaviestSubtreeForkChoice.markForkInvalidCandidate
    • Used ReplayStage::initialize_progress_and_fork_choice
    • Used in the instantiation process of the replay stage. When instantiating forkchoice from blockstore and banks, it also loads duplicate slots from the blockstore and mark them as invalid in the heaviest subtree fork choice. See

Apart from the above the following public methods were implemented, either because they were needed as part of the above listed methods or needed for testing.

  • HeaviestSubtreeForkChoice.latestInvalidAncestor
  • HeaviestSubtreeForkChoice.bestOverallSlot
  • HeaviestSubtreeForkChoice.bestSlot
  • HeaviestSubtreeForkChoice.deepestSlot
  • HeaviestSubtreeForkChoice.deepestOverallSlot
  • HeaviestSubtreeForkChoice.stakeVotedSubtree
  • HeaviestSubtreeForkChoice.getHeight
  • HeaviestSubtreeForkChoice.setTreeRoot
  • HeaviestSubtreeForkChoice.isDuplicateConfirmed
  • HeaviestSubtreeForkChoice.markForkInvalidCandidate

The PR also contains various private methods which were implemented either because they are needed in the above public methods or needed in tests

@0xNineteen 0xNineteen changed the title feat(consensus): Implementing HeaviestSubtreeForkChoice feat(consensus): HeaviestSubtreeForkChoice Jan 21, 2025
@dadepo dadepo requested review from yewman and 0xNineteen February 23, 2025 00:06
Copy link
Contributor

@yewman yewman left a comment

Choose a reason for hiding this comment

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

A couple of discards from funcs that return void. Also do you think we could add agave permalinks on analogous methods and key logic?

@yewman yewman self-requested a review February 24, 2025 18:06
yewman
yewman previously approved these changes Feb 24, 2025
Copy link
Contributor

@yewman yewman left a comment

Choose a reason for hiding this comment

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

Looks good the me :)

Copy link
Contributor

@0xNineteen 0xNineteen left a comment

Choose a reason for hiding this comment

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

nice :shipit:

@0xNineteen 0xNineteen added this pull request to the merge queue Feb 24, 2025
Merged via the queue into main with commit 27e8613 Feb 24, 2025
17 checks passed
@0xNineteen 0xNineteen deleted the dade/fork-choice branch February 24, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants