-
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 panic when getting quantums from zero position #1964
Conversation
WalkthroughThe recent changes enhance error handling in 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 Configuration 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 (2)
- protocol/x/subaccounts/types/position_size.go (3 hunks)
- protocol/x/subaccounts/types/position_size_test.go (3 hunks)
Additional comments not posted (17)
protocol/x/subaccounts/types/position_size_test.go (5)
Line range hint
10-20
:
LGTM!The
TestGetBigQuantums
function covers positive, negative, and nil positions effectively.
45-46
: LGTM!The changes to
TestPerpetualPosition_GetIsLong
align with the updated behavior of theGetIsLong
method, ensuring it returnsFalse
forzeroPosition
instead of panicking.
71-72
: LGTM!The changes to
TestAssetPosition_GetIsLong
align with the updated behavior of theGetIsLong
method, ensuring it returnsFalse
forzeroPosition
instead of panicking.
Line range hint
78-87
:
LGTM!The
TestAssetUpdate_GetIsLong
function is well-written and covers edge cases effectively.
Line range hint
92-101
:
LGTM!The
TestPerpetualUpdate_GetIsLong
function is well-written and covers edge cases effectively.protocol/x/subaccounts/types/position_size.go (12)
42-44
: LGTM!The
GetId
function forAssetPosition
is straightforward and correct.
44-48
: LGTM!The changes to
GetBigQuantums
forAssetPosition
enhance robustness by handling nil positions and nil quantums gracefully.
Line range hint
50-54
:
LGTM!The
GetIsLong
function forAssetPosition
is straightforward and correct.
Line range hint
56-58
:
LGTM!The
GetId
function forPerpetualPosition
is straightforward and correct.
Line range hint
60-62
:
LGTM!The
SetQuantums
function forPerpetualPosition
is straightforward and correct.
68-72
: LGTM!The changes to
GetBigQuantums
forPerpetualPosition
enhance robustness by handling nil positions and nil quantums gracefully.
Line range hint
74-78
:
LGTM!The
GetQuoteBalance
function forPerpetualPosition
is straightforward and correct.
Line range hint
80-84
:
LGTM!The
GetIsLong
function forPerpetualPosition
is straightforward and correct.
Line range hint
86-88
:
LGTM!The
GetIsLong
function forAssetUpdate
is straightforward and correct.
Line range hint
90-92
:
LGTM!The
GetBigQuantums
function forAssetUpdate
is straightforward and correct.
Line range hint
94-98
:
LGTM!The
GetBigQuoteBalance
function forPerpetualUpdate
is straightforward and correct.
Line range hint
106-108
:
LGTM!The
GetIsLong
function forPerpetualUpdate
is straightforward and correct.
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 (1)
- protocol/x/subaccounts/lib/updates.go (1 hunks)
Additional comments not posted (1)
protocol/x/subaccounts/lib/updates.go (1)
61-61
: Ensure theQuoteBalance
field is correctly handled.The new
QuoteBalance
field has been added to thePerpetualPosition
struct. Ensure that this field is correctly populated and used in downstream logic.
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 (1)
- protocol/x/subaccounts/types/genesis_test.go (3 hunks)
Additional comments not posted (2)
protocol/x/subaccounts/types/genesis_test.go (2)
174-175
: LGTM! The change aligns with the PR objective.The
shouldPanic
flag is correctly set tofalse
for the test case "invalid: asset position quantum == 0", indicating that the function should handle this case without panicking.
223-224
: LGTM! The change aligns with the PR objective.The
shouldPanic
flag is correctly set tofalse
for the test case "invalid: perpetual position quantum == 0", indicating that the function should handle this case without panicking.
Changelist
[Describe or list the changes made in this PR]
Test Plan
[Describe how this PR was tested (if applicable)]
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit
New Features
QuoteBalance
attribute.Bug Fixes
GetBigQuantums
method to prevent abrupt terminations, enhancing system robustness.GetIsLong
method to provide a boolean return value for zero quantum positions instead of causing a panic.