We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 0cd0460 + 534c7f9 commit 138fbf9Copy full SHA for 138fbf9
1 file changed
crates/consensus/src/stake_weighted_pbft.rs
@@ -118,7 +118,8 @@ impl StakeWeightedRoundState {
118
}
119
let approve_stake = self.approve_stake();
120
// Require strictly more than 50% to prevent ties
121
- approve_stake * 2 > total_stake
+ // Use division instead of multiplication to avoid overflow with large stake values
122
+ approve_stake > total_stake / 2
123
124
125
/// Check if rejection is certain (>50% reject stake)
@@ -127,7 +128,8 @@ impl StakeWeightedRoundState {
127
128
return false;
129
130
let reject_stake = self.reject_stake();
- reject_stake * 2 > total_stake
131
132
+ reject_stake > total_stake / 2
133
134
135
/// Get vote count (for logging)
0 commit comments