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

Update justification verification #727

Merged
merged 10 commits into from
Feb 3, 2025
Merged

Conversation

Grigorov-Georgi
Copy link
Collaborator

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

Description

  • JustificationVerifier.verify() method now has Justification as an input parameter and also executes block ancestry validation
  • JustificationVerifier.verify() method checks if there are more than 3 votes cast by single authority. The vote with the smaller block number is considered as the valid vote, other two are counted as equivocations.
  • Replace PreCommit with SignedVote in all places and delete PreCommit object

Fixes: #655 & #648

@Grigorov-Georgi Grigorov-Georgi self-assigned this Jan 28, 2025
@nistanimirov nistanimirov linked an issue Jan 29, 2025 that may be closed by this pull request
@Grigorov-Georgi Grigorov-Georgi requested review from Zurcusa, osrib, hMitov and georg-getz and removed request for osrib January 29, 2025 14:20
@Grigorov-Georgi Grigorov-Georgi marked this pull request as ready for review January 29, 2025 14:20
@Grigorov-Georgi Grigorov-Georgi marked this pull request as draft January 30, 2025 07:57
@Grigorov-Georgi Grigorov-Georgi marked this pull request as ready for review January 30, 2025 10:06
@@ -26,14 +30,23 @@
@Log
@NoArgsConstructor(access = AccessLevel.PRIVATE)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@UtilityClass

And then we can remove the static from flag from the methods.

log.log(Level.WARNING, "Duplicated signature");
return false;
}
seenPublicKeys.add(preCommit.getAuthorityPublicKey());
seenPublicKeys.add(signedVote.getAuthorityPublicKey());
Copy link
Collaborator

Choose a reason for hiding this comment

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

As per Spec:

A valid justification must only contain up to one valid vote from each voter and must not contain more than two equivocatory votes from each voter.

We can group them up beforehand using https://www.baeldung.com/java-groupingby-collector. Then check if any of the keys have > 3 votes and return false directly instead of checking a seen list.

@Grigorov-Georgi Grigorov-Georgi merged commit e686679 into dev Feb 3, 2025
3 checks passed
@Grigorov-Georgi Grigorov-Georgi deleted the 655-refactor-justification branch February 3, 2025 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants