-
Notifications
You must be signed in to change notification settings - Fork 607
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
perf: isSmartAccountActive param cache #8189
Conversation
Warning Rate Limit Exceeded@czarcas7ic has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 50 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe recent updates focus on optimizing the handling of the 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.
Actionable comments posted: 1
Out of diff range and nitpick comments (9)
CHANGELOG.md (9)
Line range hint
1015-1015
: Ensure heading levels increment by one level at a time.
Line range hint
1027-1027
: Ensure heading levels increment by one level at a time.
Line range hint
1036-1036
: Ensure heading levels increment by one level at a time.
Line range hint
1041-1041
: Ensure heading levels increment by one level at a time.
Line range hint
1093-1093
: Ensure heading levels increment by one level at a time.
Line range hint
354-354
: Remove trailing punctuation in heading.-## v6.4.0. +## v6.4.0
Line range hint
617-617
: Avoid using bare URLs. Provide descriptive text for hyperlinks.-https://github.com/osmosis-labs/osmosis/releases/tag/v6.4.0 +[v6.4.0](https://github.com/osmosis-labs/osmosis/releases/tag/v6.4.0)
Line range hint
675-675
: Avoid using bare URLs. Provide descriptive text for hyperlinks.-https://github.com/osmosis-labs/osmosis/releases/tag/v6.3.1 +[v6.3.1](https://github.com/osmosis-labs/osmosis/releases/tag/v6.3.1)
Line range hint
1256-1256
: Ensure there are no empty links in the document.-[]() +[Link description](#)
x/smart-account/keeper/params.go
Outdated
func (k Keeper) GetIsSmartAccountActive(ctx sdk.Context) bool { | ||
isSmartAccountActiveBz := k.paramSpace.GetRaw(ctx, types.KeyIsSmartAccountActive) | ||
if !bytes.Equal(isSmartAccountActiveBz, k.isSmartAccountActiveBz) { | ||
var isSmartAccountActiveValue bool | ||
err := json.Unmarshal(isSmartAccountActiveBz, &isSmartAccountActiveValue) | ||
if err != nil { | ||
isSmartAccountActiveValue = false | ||
} | ||
k.isSmartAccountActiveVal = isSmartAccountActiveValue | ||
} | ||
return k.isSmartAccountActiveVal |
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.
Consider adding error logging in GetIsSmartAccountActive
.
+ k.Logger(ctx).Error("failed to unmarshal isSmartAccountActive", "error", err)
This would help in debugging issues related to parameter unmarshalling failures.
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.
func (k Keeper) GetIsSmartAccountActive(ctx sdk.Context) bool { | |
isSmartAccountActiveBz := k.paramSpace.GetRaw(ctx, types.KeyIsSmartAccountActive) | |
if !bytes.Equal(isSmartAccountActiveBz, k.isSmartAccountActiveBz) { | |
var isSmartAccountActiveValue bool | |
err := json.Unmarshal(isSmartAccountActiveBz, &isSmartAccountActiveValue) | |
if err != nil { | |
isSmartAccountActiveValue = false | |
} | |
k.isSmartAccountActiveVal = isSmartAccountActiveValue | |
} | |
return k.isSmartAccountActiveVal | |
func (k Keeper) GetIsSmartAccountActive(ctx sdk.Context) bool { | |
isSmartAccountActiveBz := k.paramSpace.GetRaw(ctx, types.KeyIsSmartAccountActive) | |
if !bytes.Equal(isSmartAccountActiveBz, k.isSmartAccountActiveBz) { | |
var isSmartAccountActiveValue bool | |
err := json.Unmarshal(isSmartAccountActiveBz, &isSmartAccountActiveValue) | |
if err != nil { | |
k.Logger(ctx).Error("failed to unmarshal isSmartAccountActive", "error", err) | |
isSmartAccountActiveValue = false | |
} | |
k.isSmartAccountActiveVal = isSmartAccountActiveValue | |
} | |
return k.isSmartAccountActiveVal |
Blocked on #8148 (comment) |
This looks good. To make this easier in the future, I think we should have a global |
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.
Nice, good catch
* isSmartAccountActive param cache * changelog * lint * add comment * logger * assign bz * use pointer (cherry picked from commit d1076da)
* isSmartAccountActive param cache * changelog * lint * add comment * logger * assign bz * use pointer (cherry picked from commit d1076da) Co-authored-by: Adam Tucker <[email protected]>
Closes: #XXX
What is the purpose of the change
Inspired by #8148
This param retrieval currently gets called 6 times for each tx. This requires unmarshalling all the params from the module, which is very wasteful.
Testing and Verifying
All currently existing tests that test the circuit breaker should behave the same. I will also be setting breakpoints in my QA for v25 on this feature to ensure the behavior is as expected.
Documentation and Release Note
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)