File tree 1 file changed +21
-7
lines changed
1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -199,13 +199,27 @@ func (cnc *CosignerNonceCache) getUuids(n int) []uuid.UUID {
199
199
}
200
200
201
201
func (cnc * CosignerNonceCache ) target (noncesPerMinute float64 ) int {
202
- buffer := 60
203
- t := int ((noncesPerMinute / 60 ) *
204
- ((cnc .getNoncesInterval .Seconds () * nonceOverallocation ) + cnc .getNoncesTimeout .Seconds ()))
205
- if t <= 0 {
206
- t = 0
207
- }
208
- return t + buffer
202
+ // Calculate for 10s window (nonce expiration period)
203
+ activeBlocksPer10s := 20 // (10 seconds / 0.5 second blocks)
204
+
205
+ // Nonces needed per block:
206
+ // - 1 for proposal
207
+ // - 1 for prevote
208
+ // - 1 for precommit
209
+ // - 1 for vote extension (if enabled)
210
+ noncesPerBlock := 4 // proposal + prevote + precommit + extension
211
+
212
+ // Total nonces needed for 10s window with overallocation
213
+ activeNoncesPer10s := int (float64 (activeBlocksPer10s ) *
214
+ float64 (noncesPerBlock ) *
215
+ nonceOverallocation ) // Using the standard 1.5 overallocation
216
+
217
+ // Calculate based on current usage with buffer (adjusted for 10s window)
218
+ currentUsageTarget := int ((noncesPerMinute / 6 ) * // Convert per-minute to per-10-seconds
219
+ ((cnc .getNoncesInterval .Seconds () * nonceOverallocation ) +
220
+ cnc .getNoncesTimeout .Seconds ()))
221
+
222
+ return max (currentUsageTarget , activeNoncesPer10s )
209
223
}
210
224
211
225
func (cnc * CosignerNonceCache ) reconcile (ctx context.Context ) {
You can’t perform that action at this time.
0 commit comments