Skip to content
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

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

jonfung-dydx
Copy link
Contributor

@jonfung-dydx jonfung-dydx commented Mar 20, 2024

8:18PM INF Combining the short term order placement and cancellation limits of previous config: {MaxShortTermOrdersPerNBlocks:[{NumBlocks:1 Limit:200}] MaxStatefulOrdersPerNBlocks:[{NumBlocks:1 Limit:2} {NumBlocks:100 Limit:20}] MaxShortTermOrderCancellationsPerNBlocks:[{NumBlocks:1 Limit:200}] MaxShortTermOrdersAndCancelsPerNBlocks:[]}
 module=x/app/upgrades request_id=482b618d61d19ca567a7
8:18PM INF Attempting to set rate limiting config to newly combined config: {MaxShortTermOrdersPerNBlocks:[] MaxStatefulOrdersPerNBlocks:[{NumBlocks:1 Limit:2} {NumBlocks:100 Limit:20}] MaxShortTermOrderCancellationsPerNBlocks:[] MaxShortTermOrdersAndCancelsPerNBlocks:[{NumBlocks:5 Limit:2000}]}

Copy link
Contributor

coderabbitai bot commented Mar 20, 2024

Walkthrough

The 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

File(s) Change Summary
protocol/app/upgrades/v5.0.0/upgrade.go Updated calculation for short-term orders, improved logging around config updates, and refined block rate limit configuration upgrade process.

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@jonfung-dydx jonfung-dydx changed the title Fix upgrade rate limit config logic Fix upgrade rate limit config logic, add helpful logs Mar 20, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 1249edf and 121f0a0.
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 with NumBlocks == 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 with NumBlocks == 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 with NumBlocks == 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.

Comment on lines +42 to +46
ctx.Logger().Info(
fmt.Sprintf(
"Combining the short term order placement and cancellation limits of previous config: %+v\n",
oldBlockRateLimitConfig,
),
Copy link
Contributor

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.

Suggested change
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,
),

Comment on lines 86 to 91
ctx.Logger().Info(
fmt.Sprintf(
"Attempting to set rate limiting config to newly combined config: %+v\n\n",
blockRateLimitConfig,
),
)
Copy link
Contributor

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.

Suggested change
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,
),
)

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 121f0a0 and f984af1.
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

@jonfung-dydx jonfung-dydx requested a review from jayy04 March 20, 2024 20:19
@jonfung-dydx jonfung-dydx merged commit 9310bb2 into main Mar 20, 2024
16 checks passed
@jonfung-dydx jonfung-dydx deleted the jonfung/batchCancelupgrade branch March 20, 2024 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants