Skip to content

Commit 88fc329

Browse files
committed
use expiration config
1 parent 11d742c commit 88fc329

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

signer/cosigner_nonce_cache.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ func (cnc *CosignerNonceCache) getUuids(n int) []uuid.UUID {
199199
}
200200

201201
func (cnc *CosignerNonceCache) target(noncesPerMinute float64) int {
202-
// Calculate for 10s window (nonce expiration period)
203-
activeBlocksPer10s := 20 // (10 seconds / 0.5 second blocks)
202+
// Calculate for nonce expiration window
203+
blocksPerExpirationWindow := int(cnc.nonceExpiration.Seconds() / 0.5) // 0.5 second blocks
204204

205205
// Nonces needed per block:
206206
// - 1 for proposal
@@ -209,17 +209,16 @@ func (cnc *CosignerNonceCache) target(noncesPerMinute float64) int {
209209
// - 1 for vote extension (if enabled)
210210
noncesPerBlock := 4 // proposal + prevote + precommit + extension
211211

212-
// Total nonces needed for 10s window with overallocation
213-
activeNoncesPer10s := int(float64(activeBlocksPer10s) *
212+
// Total nonces needed for expiration window with overallocation
213+
activeNoncesPerWindow := int(float64(blocksPerExpirationWindow) *
214214
float64(noncesPerBlock) *
215-
nonceOverallocation) // Using the standard 1.5 overallocation
215+
nonceOverallocation)
216216

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()))
217+
// Calculate based on current usage with buffer
218+
currentUsageTarget := int((noncesPerMinute / 60) *
219+
((cnc.getNoncesInterval.Seconds() * nonceOverallocation) + cnc.getNoncesTimeout.Seconds()))
221220

222-
return max(currentUsageTarget, activeNoncesPer10s)
221+
return max(currentUsageTarget, activeNoncesPerWindow)
223222
}
224223

225224
func (cnc *CosignerNonceCache) reconcile(ctx context.Context) {

0 commit comments

Comments
 (0)