-
Notifications
You must be signed in to change notification settings - Fork 0
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
add some nonce buffer #1
Conversation
WalkthroughThe change modifies the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant CosignerNonceCache
Caller->>CosignerNonceCache: Call target(noncesPerMinute, ...)
Note right of CosignerNonceCache: Calculate noncesPerBlock and blockTime
Note right of CosignerNonceCache: Calculate noncesPerSecond from actual and theoretical usage
CosignerNonceCache->>Caller: Return max(target, 1)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
signer/cosigner_nonce_cache.go (1)
201-221
: Great improvement to the target calculation logic!The implementation now accounts for both current usage patterns and anticipated future needs based on blockchain activity. The code:
- Calculates nonces needed for the expiration window based on block time
- Accounts for different message types (proposal, prevote, precommit, extension)
- Applies an overallocation factor for safety
- Returns the maximum of usage-based and block-based calculations
This approach should make the nonce cache more responsive to actual network conditions.
One minor suggestion: consider parameterizing the 0.5 second block time assumption to make the code more adaptable to different network configurations.
- blocksPerExpirationWindow := int(cnc.nonceExpiration.Seconds() / 0.5) // 0.5 second blocks + const blockTimeSeconds = 0.5 // 0.5 second blocks + blocksPerExpirationWindow := int(cnc.nonceExpiration.Seconds() / blockTimeSeconds)
Summary by CodeRabbit