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

[ZKS-02] Update the set of authorized validators #3118

Merged
merged 11 commits into from
Mar 12, 2024

Conversation

mdelle1
Copy link
Contributor

@mdelle1 mdelle1 commented Feb 23, 2024

Motivation

This PR updates the set of authorized validators to include current committee members along with committee members from rounds up until the sync range tolerance, which is currently set at one block before nodes are considered out-of-sync.

Previously, the code would fetch the committee lookback at the latest ledger round, but this is not always the same as the committee lookback from the storage’s current round. For example, if the latest ledger round is ‘n’ but the current round is ‘n+2’, the committees may disagree. In some cases, this may lead to validators being disconnected who should still be considered as authorized to participate in consensus.

One of the implications of the previous logic is that if these committees differ substantially and affect (2f+1), then a validator will be unable to connect to a quorum of nodes in the current committee and halt.

Audit Finding: [zksecurity 02] Dynamic Committee Feature is Not Safe

@mdelle1 mdelle1 requested review from howardwu and raychu86 February 23, 2024 01:38
@raychu86 raychu86 changed the title Updates the set of authorized validators [ZKS-02] Update the set of authorized validators Feb 23, 2024
@howardwu howardwu requested a review from ljedrz March 3, 2024 19:46
@@ -32,35 +32,35 @@ use tracing::*;
#[derive(Debug)]
pub struct MockLedgerService<N: Network> {
committee: Committee<N>,
height_to_hash: Mutex<BTreeMap<u32, N::BlockHash>>,
height_to_round_and_hash: Mutex<BTreeMap<u32, (u64, N::BlockHash)>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

it would probably be better if this was an RwLock, as I can see several read-only operations available

.ledger
.current_committee()
.map_or(false, |committee| committee.is_committee_member(validator_address))
exists_in_previous_committee_lookback || exists_in_current_committee_lookback || exists_in_latest_committee
Copy link
Collaborator

@ljedrz ljedrz Mar 4, 2024

Choose a reason for hiding this comment

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

there's some potential for faster early returns here; once we know that exists_in_previous_committee_lookback is true, we can immediately return true;, same thing with exists_in_current_committee_lookback; we only need to proceed with further checks if the previous ones are false

Copy link
Collaborator

Choose a reason for hiding this comment

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

in addition, I'd guess that the first of the checks is the slowest and the last one is the fastest, so it would probably be a good idea to reverse their order for the purpose for potential early returns

Copy link
Collaborator

@ljedrz ljedrz left a comment

Choose a reason for hiding this comment

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

I've left some perf-relevant comments; also, 2 CI jobs seem to be failing.

@raychu86
Copy link
Contributor

Note: This PR was tested on a network where validators continuously bonded/unbonded and did not encounter block production issues.

The mainnet-staging branch as of ProvableHQ@3b47375 (without this change), still ran into halting issues with that same test scenario.

@howardwu howardwu merged commit 2a2c57f into mainnet-staging Mar 12, 2024
23 of 24 checks passed
@howardwu howardwu deleted the fix/authorized-validators branch March 12, 2024 23:31
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.

4 participants