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

Improve Consensus logic for Multi-BLS Validators with quorum #4799

Merged
merged 5 commits into from
Dec 5, 2024
Merged

Conversation

GheisMohammadi
Copy link
Contributor

@GheisMohammadi GheisMohammadi commented Nov 12, 2024

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 for Prepare and Commit 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.

@GheisMohammadi GheisMohammadi self-assigned this Nov 12, 2024
@GheisMohammadi GheisMohammadi marked this pull request as draft November 12, 2024 15:12
@GheisMohammadi GheisMohammadi changed the title Fix Consensus Quorum Calculation Fix Consensus Quorum Calculation for Multi-BLS Key Validators Nov 12, 2024
@sophoah
Copy link
Contributor

sophoah commented Nov 20, 2024

@GheisMohammadi i am good with that PR. Can you do run the same logic with isFirstReceivedSignature for onPrepare ? and use it here

if consensus.decider.IsQuorumAchieved(quorum.Prepare) {
? It prevent doing the return when the leader node already has quorum on the first onPrepare. Goal is to run didReachPrepareQuorum
if err := consensus.didReachPrepareQuorum(); err != nil {

@GheisMohammadi
Copy link
Contributor Author

@GheisMohammadi i am good with that PR. Can you do run the same logic with isFirstReceivedSignature for onPrepare ? and use it here

if consensus.decider.IsQuorumAchieved(quorum.Prepare) {

? It prevent doing the return when the leader node already has quorum on the first onPrepare. Goal is to run didReachPrepareQuorum

if err := consensus.didReachPrepareQuorum(); err != nil {

done

consensus/leader.go Outdated Show resolved Hide resolved
@sophoah sophoah changed the title Fix Consensus Quorum Calculation for Multi-BLS Key Validators Improve Consensus logic for Multi-BLS Validators with quorum Nov 20, 2024
@sophoah
Copy link
Contributor

sophoah commented Nov 21, 2024

could you add PR description, and is this something we can write unit test (for onPrepare and onCommit) here as well ?

@sophoah
Copy link
Contributor

sophoah commented Nov 22, 2024

@Frozen please review/approve

@sophoah sophoah requested a review from Frozen November 22, 2024 06:51
@sophoah
Copy link
Contributor

sophoah commented Nov 22, 2024

@GheisMohammadi please update PR description

@sophoah sophoah mentioned this pull request Nov 22, 2024
@GheisMohammadi
Copy link
Contributor Author

@GheisMohammadi please update PR description

done

@sophoah sophoah marked this pull request as ready for review November 27, 2024 04:33
@sophoah
Copy link
Contributor

sophoah commented Nov 27, 2024

updated this PR to "ready for review"
@Frozen please review/approve

@Frozen
Copy link
Contributor

Frozen commented Nov 30, 2024

should i run it with make debug-multi-bls or debug-ext or debug?

@sophoah
Copy link
Contributor

sophoah commented Dec 2, 2024

@Frozen you should run it with debug-multi-bls as it fixes a bug that only happens when using multi-bls and when the harmony node have quorum

@Frozen
Copy link
Contributor

Frozen commented Dec 2, 2024

rebase pls branch on dev

@sophoah sophoah merged commit 3580e89 into dev Dec 5, 2024
4 checks passed
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.

3 participants