-
Notifications
You must be signed in to change notification settings - Fork 289
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
Improve Consensus logic for Multi-BLS Validators with quorum #4799
base: dev
Are you sure you want to change the base?
Conversation
@GheisMohammadi i am good with that PR. Can you do run the same logic with Line 124 in 3b6fde4
return when the leader node already has quorum on the first onPrepare. Goal is to run didReachPrepareQuorum Line 188 in 3b6fde4
|
3b6fde4
to
c6518ec
Compare
done |
consensus/leader.go
Outdated
quorumPreExisting := consensus.decider.IsQuorumAchieved(quorum.Prepare) | ||
//// Read - End | ||
|
||
if quorumPreExisting { | ||
// already have enough signatures | ||
consensus.getLogger().Debug(). | ||
Interface("validatorPubKeys", recvMsg.SenderPubkeys). | ||
Msg("[OnPrepare] Received Additional Prepare Message") | ||
return |
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.
when leader node with multi bls key has quorum, we hit that return
code and will never hit consensus.didReachPrepareQuorum()
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.
if !isFirstReceivedSignature && quorumPreExisting
first time with quorum we don't return so we can hit consensus.didReachPrepareQuorum();
then subsequently we return
quorumFromInitialSignature := hasMultiBlsKeys && isFirstReceivedSignature && quorumPreExisting | ||
quorumPostNewSignatures := consensus.decider.IsQuorumAchieved(quorum.Prepare) | ||
quorumFromNewSignatures := !quorumPreExisting && quorumPostNewSignatures | ||
|
||
if quorumFromInitialSignature || quorumFromNewSignatures { |
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.
old code was fine, as we just need consensus.didReachPrepareQuorum()
to hit once
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 removed return
. So, it allows adding new signatures in Prepare Phase despite existing quorum. I think this would fix the issue
could you add PR description, and is this something we can write unit test (for onPrepare and onCommit) here as well ? |
@Frozen please review/approve |
@GheisMohammadi please update PR description |
done |
Issue
This PR improves the consensus logic to handle cases where validators with multiple BLS keys achieve quorum on their initial signatures or commits. Currently, such scenarios can block phase transitions because the condition
if !quorumWasMet && quorumIsMet
doesn't account for quorum being achieved immediately.To fix this, a new function,
checkFirstReceivedSignature
, is introduced. It checks whether quorum is reached on the first batch of signatures or commits. The PR also updates the logic forPrepare
andCommit
phases to properly handle these edge cases. The PR helps to better handling of multi-BLS key validators while maintaining compatibility with single-key setups.