-
Notifications
You must be signed in to change notification settings - Fork 105
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 use of BigIntMulSignedPpm
in favor of BigMulPpm
#1589
Conversation
WalkthroughThe changes across the files involve replacing the function Changes
Sequence Diagram(s) (Beta)The changes are primarily focused on internal fee calculation logic and do not introduce new features or significantly alter control flows, so no sequence diagrams are necessary. 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 (5)
- protocol/lib/big_math.go (1 hunks)
- protocol/x/clob/keeper/mev.go (1 hunks)
- protocol/x/clob/keeper/process_single_match.go (1 hunks)
- protocol/x/clob/types/pending_updates.go (1 hunks)
- protocol/x/rewards/keeper/keeper.go (1 hunks)
Additional Context Used
Path-based Instructions (5)
protocol/x/clob/types/pending_updates.go (1)
Pattern
**/**
: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.protocol/lib/big_math.go (1)
Pattern
**/**
: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.protocol/x/rewards/keeper/keeper.go (1)
Pattern
**/**
: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.protocol/x/clob/keeper/process_single_match.go (1)
Pattern
**/**
: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.protocol/x/clob/keeper/mev.go (1)
Pattern
**/**
: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.
Additional comments not posted (5)
protocol/x/clob/types/pending_updates.go (1)
172-172
: The replacement ofBigIntMulSignedPpm
withBigMulPpm
aligns with the PR's objectives. EnsureBigMulPpm
handles signed values correctly as this affects fee calculations.Verification successful
To ensure
BigMulPpm
handles signed values correctly, let's review its implementation and test cases.
To ensure
BigMulPpm
handles signed values correctly, let's review the remaining test cases inprotocol/lib/big_math_test.go
.
To ensure
BigMulPpm
handles signed values correctly, let's retrieve the complete test cases forTestBigMulPpm
.
The test cases for
BigMulPpm
inprotocol/lib/big_math_test.go
do include scenarios with signed values, such as "Negative round down" and "Negative round up". This confirms thatBigMulPpm
correctly handles signed values, ensuring the correctness of fee calculations.
protocol/lib/big_math_test.go
: Test cases forBigMulPpm
include handling of signed values.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `BigMulPpm` correctly handles signed values. # Test: Search for the function usage with signed values. Expect: Correct handling of signed values. rg --type go $'BigMulPpm'Length of output: 1392
Script:
#!/bin/bash # Description: Retrieve the implementation and test cases of `BigMulPpm`. # Retrieve the implementation of `BigMulPpm`. rg --type go --context 10 'func BigMulPpm' protocol/lib/big_math.go # Retrieve the test cases for `BigMulPpm`. rg --type go --context 10 'TestBigMulPpm' protocol/lib/big_math_test.goLength of output: 1346
Script:
#!/bin/bash # Description: Retrieve the remaining test cases for `BigMulPpm` to verify handling of signed values. # Retrieve the remaining test cases for `BigMulPpm`. rg --type go --context 10 'TestBigMulPpm' protocol/lib/big_math_test.goLength of output: 619
Script:
#!/bin/bash # Description: Retrieve the complete test cases for `TestBigMulPpm` to verify handling of signed values. # Retrieve the complete test cases for `TestBigMulPpm`. rg --type go --context 50 'TestBigMulPpm' protocol/lib/big_math_test.goLength of output: 2850
protocol/lib/big_math.go (1)
Line range hint
28-34
: The implementation ofBigMulPpm
correctly performs multiplication followed by division, with an option to round up. This rounding feature is crucial for accurate fee calculations.protocol/x/rewards/keeper/keeper.go (1)
139-139
: The replacement ofBigIntMulSignedPpm
withBigMulPpm
in reward calculations is consistent with the PR's objectives. Verify thatBigMulPpm
is used correctly in this context.Verification successful
The
BigMulPpm
function is used in multiple files, includingkeeper.go
. To ensure its correct usage in the context of reward calculations, we need to review its implementation and test cases.
Let's re-verify the implementation and test cases of
BigMulPpm
with adjusted search patterns.
The implementation and test cases for
BigMulPpm
have been successfully retrieved. The functionBigMulPpm
correctly handles the multiplication and rounding as specified, and the test cases cover various scenarios, including rounding up and down, and handling large values.The replacement of
BigIntMulSignedPpm
withBigMulPpm
inkeeper.go
is consistent with the intended usage and the function's implementation.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correct usage of `BigMulPpm` in reward calculations. # Test: Search for the function usage in reward calculations. Expect: Correct usage in the context. rg --type go $'BigMulPpm'Length of output: 1392
Script:
#!/bin/bash # Description: Review the implementation and test cases of `BigMulPpm`. # Retrieve the implementation of `BigMulPpm` from `big_math.go`. ast-grep --lang go --pattern $'func BigMulPpm(val *big.Int, ppm *big.Int, roundUp bool) *big.Int { $$$ }' > big_mul_ppm_impl.txt # Retrieve the test cases for `BigMulPpm` from `big_math_test.go`. ast-grep --lang go --pattern $'func TestBigMulPpm(t *testing.T) { $$$ }' > big_mul_ppm_tests.txtLength of output: 184
Script:
#!/bin/bash # Description: Review the implementation and test cases of `BigMulPpm`. # Retrieve the implementation of `BigMulPpm` from `big_math.go`. rg --type go --context 10 'func BigMulPpm' protocol/lib/big_math.go # Retrieve the test cases for `BigMulPpm` from `big_math_test.go`. rg --type go --context 10 'BigMulPpm' protocol/lib/big_math_test.goLength of output: 2566
protocol/x/clob/keeper/process_single_match.go (1)
320-321
: The replacement ofBigIntMulSignedPpm
withBigMulPpm
in fee calculations during order matching is consistent with the PR's objectives. Verify thatBigMulPpm
is used correctly in this context.protocol/x/clob/keeper/mev.go (1)
877-877
: ReplaceBigIntMulSignedPpm
withBigMulPpm
to align with updated practices.Verification successful
The
BigMulPpm
function is used in multiple places across the codebase, and its implementation and tests are located inprotocol/lib/big_math.go
andprotocol/lib/big_math_test.go
, respectively. The tests cover various scenarios, including rounding up and down.
protocol/lib/big_math.go
: Implementation ofBigMulPpm
.protocol/lib/big_math_test.go
: Tests forBigMulPpm
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `BigMulPpm` behaves as expected in all scenarios where it's used. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type go $'BigMulPpm'Length of output: 1392
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 (4)
- protocol/x/clob/keeper/mev.go (1 hunks)
- protocol/x/clob/keeper/process_single_match.go (1 hunks)
- protocol/x/clob/types/pending_updates.go (1 hunks)
- protocol/x/rewards/keeper/keeper.go (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- protocol/x/clob/keeper/mev.go
- protocol/x/clob/keeper/process_single_match.go
- protocol/x/clob/types/pending_updates.go
- protocol/x/rewards/keeper/keeper.go
Changelist
Remove deprecated function
Test Plan
Existing unit tests