-
Notifications
You must be signed in to change notification settings - Fork 117
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
Fix upgrade rate limit config logic, add helpful logs #1212
Conversation
jonfung-dydx
commented
Mar 20, 2024
•
edited
Loading
edited
WalkthroughThe recent upgrade focuses on refining the process of managing block rate limits by enhancing the computation of short-term order activities and incorporating more detailed logging around configuration adjustments. This version also streamlines the upgrade mechanism for the block rate limit settings, ensuring smoother transitions and more precise control over transaction flow. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 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 as PR comments)
Additionally, you can add CodeRabbit Configration 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.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (1)
- protocol/app/upgrades/v5.0.0/upgrade.go (3 hunks)
Additional comments: 3
protocol/app/upgrades/v5.0.0/upgrade.go (3)
- 53-53: The loop that calculates
numAllowedShortTermOrderPlacementsInOneBlock
breaks after finding the first limit withNumBlocks == 1
. This logic assumes there's only one such limit, which might be correct given the context. However, if the configuration could potentially include multiple entries withNumBlocks == 1
, this logic would only consider the first one found. Ensure this assumption is valid to prevent potential logic errors.- 64-64: Similar to the previous comment, the loop for calculating
numAllowedShortTermOrderCancellationsInOneBlock
also breaks after finding the first matching entry. Verify that it's safe to assume there will only be one entry withNumBlocks == 1
for cancellations, to avoid overlooking additional configuration entries.- 95-98: The final log message confirms the successful upgrade of the block rate limit configuration. This is crucial for verifying that the changes have been applied as expected. The logging practice throughout this function is commendable for its role in improving system transparency and debuggability.
ctx.Logger().Info( | ||
fmt.Sprintf( | ||
"Combining the short term order placement and cancellation limits of previous config: %+v\n", | ||
oldBlockRateLimitConfig, | ||
), |
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.
The changes from lines 42 to 46 introduce enhanced logging before the configuration update process begins. This is a positive change as it improves visibility into the system's behavior and aids in debugging. However, consider including more context in the log message, such as the function name or specific action being taken, to make it easier to trace logs back to their source.
- "Combining the short term order placement and cancellation limits of previous config: %+v\n",
+ "blockRateLimitConfigUpdate: Combining the short term order placement and cancellation limits of previous config: %+v\n",
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
ctx.Logger().Info( | |
fmt.Sprintf( | |
"Combining the short term order placement and cancellation limits of previous config: %+v\n", | |
oldBlockRateLimitConfig, | |
), | |
ctx.Logger().Info( | |
fmt.Sprintf( | |
"blockRateLimitConfigUpdate: Combining the short term order placement and cancellation limits of previous config: %+v\n", | |
oldBlockRateLimitConfig, | |
), |
ctx.Logger().Info( | ||
fmt.Sprintf( | ||
"Attempting to set rate limiting config to newly combined config: %+v\n\n", | ||
blockRateLimitConfig, | ||
), | ||
) |
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.
The changes from lines 86 to 91 add logging before attempting to set the new rate limiting configuration. This is another good practice for enhancing observability. As with the earlier logging enhancement, consider adding more specific context to the log message.
- "Attempting to set rate limiting config to newly combined config: %+v\n\n",
+ "blockRateLimitConfigUpdate: Attempting to set rate limiting config to newly combined config: %+v\n\n",
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
ctx.Logger().Info( | |
fmt.Sprintf( | |
"Attempting to set rate limiting config to newly combined config: %+v\n\n", | |
blockRateLimitConfig, | |
), | |
) | |
ctx.Logger().Info( | |
fmt.Sprintf( | |
"blockRateLimitConfigUpdate: Attempting to set rate limiting config to newly combined config: %+v\n\n", | |
blockRateLimitConfig, | |
), | |
) |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- protocol/app/upgrades/v5.0.0/upgrade.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- protocol/app/upgrades/v5.0.0/upgrade.go