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

Port "light-client: Optimize voting power calculation by breaking the loop when we have enough voting power" (tendermint-rs#1395) #25

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `[cometbft-light-client-verifer]` Optimizing voting power calculation by breaking the loop when we have enough voting power ([#19](https://github.com/cometbft/cometbft-rs/issues/19)).
9 changes: 6 additions & 3 deletions light-client-verifier/src/operations/voting_power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl<V: signature::Verifier> VotingPowerCalculator for ProvidedVotingPowerCalcul
trust_threshold: TrustThreshold,
) -> Result<VotingPowerTally, VerificationError> {
let signatures = &signed_header.commit.signatures;
let total_voting_power = self.total_power_of(validator_set);

let mut tallied_voting_power = 0_u64;
let mut seen_validators = HashSet::new();
Expand Down Expand Up @@ -185,12 +186,14 @@ impl<V: signature::Verifier> VotingPowerCalculator for ProvidedVotingPowerCalcul
// to measure validator availability.
}

// TODO: Break out of the loop when we have enough voting power.
// See https://github.com/informalsystems/tendermint-rs/issues/235
// Break out of the loop when we have enough voting power.
if trust_threshold.is_enough_power(tallied_voting_power, total_voting_power) {
break;
}
}

let voting_power = VotingPowerTally {
total: self.total_power_of(validator_set),
total: total_voting_power,
tallied: tallied_voting_power,
trust_threshold,
};
Expand Down
Loading