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

399 Attempt to finalize at round #703

Merged
merged 17 commits into from
Jan 23, 2025
Merged

Conversation

Grigorov-Georgi
Copy link
Collaborator

@Grigorov-Georgi Grigorov-Georgi commented Jan 21, 2025

Description

  • Implement Attempt-To-Finalize-At-Round by the polkadot spec definition -> https://spec.polkadot.network/sect-finality#algo-attempt-to%E2%80%93finalize
  • Rename getBestFinalCandidate, getGrandpaGhost and getBestPreVoteCandidate to findBestFinalCandidate, findGrandpaGhost and findBestPreVoteCandidate in the GrandpaService in order not to have different names from the GrandpaRound getters
  • The GrandpaGhost and BestFinalCandidate fields of the GrandpaRound object are now being set directly in the methods findGrandpaGhost() and findBestFinalCandidate(), rather than in isFinalizable()
  • Add commitMessagesArchive, a map of SetId as a key, and a list of commit messages as value. On every new set start the commit messages for (setId - 2) are deleted because they will probably never be used again.
  • Updating the last finalized block from commit messages is now executed only when we (as a node) aren't part of the voters set.
  • Make all methods in GrandpaService private

Fixes: #399

);

long totalVoters = grandpaSetState.getAuthorities().size();
long threshold = (2 * totalVoters) / 3;
Copy link
Member

Choose a reason for hiding this comment

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

Can you put a comment with a link showing how these numbers were chosen or explain them in he comment, because they look like magic numbers right now.

}

public void cleanCommitMessagesArchive() {
commitMessagesArchive.remove(setId.subtract(BigInteger.TWO));
Copy link
Member

Choose a reason for hiding this comment

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

Why are we subtracting 2 here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only reason is that we will only need the commit messages for the current set and in the edge case also the commit messages from the previous set. By subtracting 2 I delete commit messages for older sets. I will add a comment about the reason behind that action because this is not defined in the spec.

@Grigorov-Georgi Grigorov-Georgi marked this pull request as ready for review January 23, 2025 07:56
@Grigorov-Georgi Grigorov-Georgi merged commit c3de79c into dev Jan 23, 2025
3 checks passed
@Grigorov-Georgi Grigorov-Georgi deleted the 399-attempt-to-finalize-at-round branch January 23, 2025 15:11
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.

Attempt to Finalize At Round
3 participants