-
Notifications
You must be signed in to change notification settings - Fork 115
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
Remove unnecessary ProductKeeper
abstraction
#1765
Conversation
Warning Rate limit exceeded@BrendanChou has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 0 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. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe recent updates streamline and refactor several functions and interfaces related to subaccounts and position updates within the system. By integrating the Changes
Poem
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- protocol/x/subaccounts/keeper/subaccount.go (2 hunks)
- protocol/x/subaccounts/lib/updates.go (2 hunks)
- protocol/x/subaccounts/types/position_size.go (6 hunks)
Additional comments not posted (2)
protocol/x/subaccounts/lib/updates.go (1)
162-165
: Added Duplicate ID Check inApplyUpdatesToPositions
:The addition of a check for duplicate update IDs is a critical improvement for ensuring data integrity. This change prevents the application of conflicting updates, which could corrupt the state or lead to unintended behavior.
- Correctness: The implementation uses a utility function to map update IDs and check for duplicates, which is a clean and efficient approach.
- Error Handling: The function correctly returns an error if duplicates are detected, which aligns with best practices in robust error handling.
protocol/x/subaccounts/keeper/subaccount.go (1)
564-574
: Integrated Position Updatability Checks ininternalCanUpdateSubaccounts
:The integration of direct checks using
perpetualsKeeper
andassetsKeeper
for position updatability intointernalCanUpdateSubaccounts
enhances the modularity and reduces redundancy.
- Efficiency: By eliminating the
checkPositionUpdatable
function and integrating its logic directly, the code is more streamlined.- Error Handling: The function handles errors from the
IsPositionUpdatable
checks appropriately, using wrapped errors to provide more context, which aids in debugging and error resolution.Also applies to: 579-589
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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- protocol/testing/e2e/gov/add_new_market_test.go (2 hunks)
- protocol/x/subaccounts/keeper/subaccount.go (2 hunks)
- protocol/x/subaccounts/types/expected_keepers.go (2 hunks)
Files skipped from review due to trivial changes (1)
- protocol/testing/e2e/gov/add_new_market_test.go
Files skipped from review as they are similar to previous changes (1)
- protocol/x/subaccounts/keeper/subaccount.go
Additional comments not posted (4)
protocol/x/subaccounts/types/expected_keepers.go (4)
14-14
: MethodConvertAssetToCoin
approved.The consolidation of
ConvertAssetToCoin
intoAssetsKeeper
fromProductKeeper
is logical and helps streamline the interface structure.
40-40
: Detailed methods inPerpetualsKeeper
are well-defined.Methods such as
GetPerpetual
,GetPerpetualAndMarketPrice
, and others are specific and crucial for the operations within the perpetuals domain. These methods are well-defined and seem to be correctly placed within the interface.
14-14
: Ensure method calls are updated forIsPositionUpdatable
.The method signature of
IsPositionUpdatable
has been modified to use a simplerid
parameter instead of aPositionSize
object. This change should simplify interactions but requires updating all method calls.Also applies to: 34-40
Verification successful
Ensure method calls are updated for
IsPositionUpdatable
.The method signature of
IsPositionUpdatable
has been modified to use a simplerid
parameter instead of aPositionSize
object. This change should simplify interactions but requires updating all method calls.The search for the old method signature did not return any results, indicating that all instances have been updated.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `IsPositionUpdatable` are updated. # Test: Search for the function usage with old signature. Expect: No occurrences. rg --type go $'IsPositionUpdatable\\(.+PositionSize.+\\)'Length of output: 56
34-40
: Consistency maintained across keeper interfaces.The
IsPositionUpdatable
method inPerpetualsKeeper
now uses anid
parameter, aligning with the changes inAssetsKeeper
. Ensure all method calls are updated to reflect this change.
ProductKeeper
abstraction
Changelist
Remove unnecessary
ProductKeeper
abstractionSummary by CodeRabbit
checkPositionUpdatable
directly into the update validation process.ProductKeeper
interface methods intoAssetsKeeper
andPerpetualsKeeper
interfaces, streamlining the code.