-
Notifications
You must be signed in to change notification settings - Fork 1
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: Implement Finalize stage in Play-Grandpa-Round. #750
Conversation
|
||
private boolean isRoundReadyToEnd(GrandpaRound round) { | ||
BlockHeader finalized = round.getFinalizedBlock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use try-catch instead of null check for this one.
public BlockHeader getFinalizedBlock() {
if (finalizedBlock == null) throw new GrandpaGenericException("Finalized block has not been set.");
return finalizedBlock;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is that if finalized is null, it means that round is not ready to be finalized. The method should return false(we are in waiting for preCommits as not eligible to finalize) and then the callback should be passed to the GrandpaRound handler. Then on each preCommit message, we attemptToFinalize the round and execute the logic from the callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return false in the catch if getter throws an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably didn't describe well what I meant, but I guess after @Zurcusa's clarification you get the point.
return; | ||
} | ||
|
||
Runnable onFinalizeHandler = () -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have this inline when we invoke setOnFinalizeHandler
try { | ||
finalized = round.getFinalizedBlock(); | ||
} catch (GrandpaGenericException e) { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a warning log here.
|
Description
Fixes #729