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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions protocol/app/upgrades/v5.0.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ func blockRateLimitConfigUpdate(
clobKeeper clobtypes.ClobKeeper,
) {
oldBlockRateLimitConfig := clobKeeper.GetBlockRateLimitConfiguration(ctx)
ctx.Logger().Info(
fmt.Sprintf(
"Combining the short term order placement and cancellation limits of previous config: %+v\n",
oldBlockRateLimitConfig,
),
Comment on lines +42 to +46
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,
),

)
numAllowedShortTermOrderPlacementsInOneBlock := 0
numAllowedShortTermOrderCancellationsInOneBlock := 0
oldShortTermOrderRateLimits := oldBlockRateLimitConfig.MaxShortTermOrdersPerNBlocks
for _, limit := range oldShortTermOrderRateLimits {
if limit.NumBlocks == 1 {
numAllowedShortTermOrderPlacementsInOneBlock += int(limit.NumBlocks)
numAllowedShortTermOrderPlacementsInOneBlock += int(limit.Limit)
break
}
}
Expand All @@ -55,7 +61,7 @@ func blockRateLimitConfigUpdate(
oldShortTermOrderCancellationRateLimits := oldBlockRateLimitConfig.MaxShortTermOrderCancellationsPerNBlocks
for _, limit := range oldShortTermOrderCancellationRateLimits {
if limit.NumBlocks == 1 {
numAllowedShortTermOrderCancellationsInOneBlock += int(limit.NumBlocks)
numAllowedShortTermOrderCancellationsInOneBlock += int(limit.Limit)
break
}
}
Expand All @@ -77,10 +83,19 @@ func blockRateLimitConfigUpdate(
},
},
}

ctx.Logger().Info(
fmt.Sprintf(
"Attempting to set rate limiting config to newly combined config: %+v\n",
blockRateLimitConfig,
),
)
if err := clobKeeper.InitializeBlockRateLimit(ctx, blockRateLimitConfig); err != nil {
panic(fmt.Sprintf("failed to update the block rate limit configuration: %s", err))
}
ctx.Logger().Info(
"Successfully upgraded block rate limit configuration to: %+v\n",
clobKeeper.GetBlockRateLimitConfiguration(ctx),
)
}

func CreateUpgradeHandler(
Expand Down
Loading