-
Notifications
You must be signed in to change notification settings - Fork 198
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: withdrawal bugfix #219
Conversation
WalkthroughWalkthroughThe recent updates primarily focus on simplifying code within the distribution keeper of the project. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Keeper
participant ValidatorHistoricalRewards
participant ValidatorOutstandingRewards
User->>Keeper: withdrawDelegationRewards(valAddr, ... )
Keeper->>+ValidatorOutstandingRewards: Update(valAddr, rewards)
ValidatorOutstandingRewards-->>-Keeper: Acknowledgment
Keeper-->>User: Rewards Withdrawn
User->>Keeper: incrementValidatorPeriod(valAddr, rewards)
Keeper->>+ValidatorHistoricalRewards: Get(valAddr, rewards.Period-1)
ValidatorHistoricalRewards-->>Keeper: Historical Rewards
Keeper->>+ValidatorHistoricalRewards: Set(valAddr, rewards.Period)
ValidatorHistoricalRewards-->>Keeper: Acknowledgment
Keeper-->>User: Period Incremented
Poem
Tip AI model upgrade
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #219 +/- ##
=======================================
Coverage 40.22% 40.22%
=======================================
Files 258 258
Lines 24617 24617
=======================================
Hits 9903 9903
Misses 13183 13183
Partials 1531 1531
|
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)
- x/distribution/keeper/delegation.go (2 hunks)
- x/distribution/keeper/validator.go (7 hunks)
Additional comments not posted (12)
x/distribution/keeper/validator.go (9)
146-146
: LGTM! Verify the usage ofcollections.Join
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr.Bytes()
are correct and consistent.
158-158
: LGTM! Verify the usage ofcollections.Join
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr.Bytes()
are correct and consistent.Verification successful
Verified the usage of
collections.Join
withvalAddr.Bytes()
.The broader search confirmed that all occurrences of
collections.Join(valAddr.Bytes(), period)
are consistent and correct withinx/distribution/keeper/validator.go
.
x/distribution/keeper/validator.go
:
- Line 158:
return k.ValidatorHistoricalRewards.Set(ctx, collections.Join(valAddr.Bytes(), period), historical)
- Other instances in the same file follow the same pattern.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go $'collections.Join(valAddr.Bytes()'Length of output: 149
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Corrected regex pattern to search for function usage. rg --type go 'collections\.Join\(valAddr\.Bytes\(\)\)'Length of output: 56
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()` in various forms. # Broader search pattern to include possible variations. rg --type go 'collections\.Join\(.*valAddr\.Bytes\(\).*\)'Length of output: 733
115-115
: LGTM! Verify the usage ofcollections.Join
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr.Bytes()
are correct and consistent.Verification successful
LGTM! Verify the usage of
collections.Join
withvalAddr.Bytes()
.The code changes are approved.
x/distribution/keeper/validator.go
: Verified instances ofcollections.Join(valAddr.Bytes(), period)
andcollections.Join(valAddr.Bytes(), height, newPeriod)
are correct and consistent.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go $'collections.Join(valAddr.Bytes()'Length of output: 149
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go 'collections.Join\(valAddr\.Bytes\(\)\)'Length of output: 55
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join`. # Test: Search for the function usage. Expect: Review all instances of the usage. rg --type go 'collections.Join'Length of output: 12953
191-191
: LGTM! Verify the usage ofcollections.Join3
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join3
withvalAddr.Bytes()
are correct and consistent.Verification successful
The usage of
collections.Join3
withvalAddr.Bytes()
is consistent and correct.
- The codebase shows consistent patterns of using
collections.Join3
with various address and byte slice combinations.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join3` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go $'collections.Join3(valAddr.Bytes()'Length of output: 152
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join3` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go 'collections.Join3(valAddr.Bytes())'Length of output: 51
Script:
#!/bin/bash # Description: Search for all calls to `collections.Join3` in the codebase. # Test: Search for the function usage. Expect: Occurrences of the function usage to verify consistency. rg --type go 'collections.Join3'Length of output: 2279
141-141
: LGTM! Verify the usage ofcollections.Join
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr.Bytes()
are correct and consistent.Verification successful
Verification Successful: Consistent Usage of
collections.Join
withvalAddr.Bytes()
The usage of
collections.Join
withvalAddr.Bytes()
inx/distribution/keeper/validator.go
is correct and consistent. There are no other occurrences in the codebase that conflict with this usage.
x/distribution/keeper/validator.go
: Verified instances ofcollections.Join(valAddr.Bytes(), period)
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go $'collections.Join(valAddr.Bytes()'Length of output: 149
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go 'collections.Join(valAddr.Bytes())'Length of output: 50
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` in the codebase. # Test: Search for all occurrences of `collections.Join`. rg --type go 'collections.Join'Length of output: 12953
25-25
: LGTM! Verify the usage ofcollections.Join
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr.Bytes()
are correct and consistent.
131-131
: LGTM! Verify the usage ofcollections.Join
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr.Bytes()
are correct and consistent.Verification successful
LGTM! The usage of
collections.Join
withvalAddr.Bytes()
is correct and consistent.
- Verified the specific pattern
collections.Join(valAddr.Bytes(), period)
in the filex/distribution/keeper/validator.go
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go $'collections.Join(valAddr.Bytes()'Length of output: 149
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go 'collections.Join\(valAddr\.Bytes\(\)\)'Length of output: 55
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join`. # Test: Search for the function usage. Expect: Occurrences of `collections.Join`. rg --type go 'collections.Join'Length of output: 12953
156-156
: LGTM! Verify the usage ofcollections.Join
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr.Bytes()
are correct and consistent.Verification successful
Usage of
collections.Join
withvalAddr.Bytes()
is consistent and correct.The search results show multiple instances of
collections.Join
used withvalAddr.Bytes()
inx/distribution/keeper/validator.go
. This confirms that the usage in the provided snippet is consistent with other parts of the codebase.
x/distribution/keeper/validator.go
: Multiple occurrences found usingcollections.Join(valAddr.Bytes(), period)
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go $'collections.Join(valAddr.Bytes()'Length of output: 149
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go 'collections.Join(valAddr.Bytes()'Length of output: 149
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go 'collections\.Join\(valAddr\.Bytes\(\)\)'Length of output: 56
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` and manually inspect for usage with `valAddr.Bytes()`. # Test: Search for the function usage. Expect: Occurrences of `collections.Join` to manually check for `valAddr.Bytes()`. rg --type go 'collections\.Join'Length of output: 12956
103-103
: LGTM! Verify the usage ofcollections.Join
withvalAddr.Bytes()
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr.Bytes()
are correct and consistent.x/distribution/keeper/delegation.go (3)
70-70
: LGTM! Verify the usage ofcollections.Join
withvalAddr
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr
are correct and consistent.Verification successful
Verification Successful!
The usage of
collections.Join
withvalAddr
has been verified across the codebase and is consistent and correct.
x/distribution/keeper/delegation.go
x/distribution/keeper/validator.go
x/distribution/keeper/genesis.go
x/mstaking/keeper/delegation.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr`. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go $'collections.Join(valAddr'Length of output: 133
Script:
#!/bin/bash # Description: Verify all calls to `collections.Join` with `valAddr`. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go 'collections.Join\(valAddr'Length of output: 2700
74-74
: LGTM! Verify the usage ofcollections.Join
withvalAddr
.The code changes are approved.
Ensure that all calls to
collections.Join
withvalAddr
are correct and consistent.
281-281
: Bugfix LGTM! Verify the usage of the correct key for setting outstanding rewards.The code changes are approved.
Ensure that the correct key
valAddr
is used consistently for setting outstanding rewards.Verification successful
Bugfix LGTM! Verified the usage of the correct key for setting outstanding rewards.
The code changes are approved.
x/distribution/keeper/validator.go
x/distribution/keeper/keeper.go
x/distribution/keeper/keeper_test.go
x/distribution/keeper/genesis.go
x/distribution/keeper/delegation.go
x/distribution/keeper/allocation.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the correct key `valAddr` for setting outstanding rewards. # Test: Search for the function usage. Expect: Only occurances of the new usage. rg --type go $'ValidatorOutstandingRewards.Set(ctx, valAddr'Length of output: 188
Script:
#!/bin/bash # Description: Verify the usage of the correct key `valAddr` for setting outstanding rewards. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go 'ValidatorOutstandingRewards.Set(ctx, valAddr'Length of output: 188
Script:
#!/bin/bash # Description: Verify the usage of the correct key `valAddr` for setting outstanding rewards. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go "ValidatorOutstandingRewards.Set(ctx, valAddr"Length of output: 188
Script:
#!/bin/bash # Description: Verify the usage of the correct key `valAddr` for setting outstanding rewards. # Test: Search for the function usage. Expect: Only occurrences of the new usage. rg --type go 'ValidatorOutstandingRewards.Set(ctx, valAddr)'Length of output: 62
Script:
#!/bin/bash # Description: Verify the usage of the correct key for setting outstanding rewards. # Test: Search for all occurrences of ValidatorOutstandingRewards.Set rg --type go 'ValidatorOutstandingRewards.Set'Length of output: 1503
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)
- x/distribution/keeper/delegation.go (2 hunks)
- x/distribution/keeper/validator.go (7 hunks)
Additional comments not posted (12)
x/distribution/keeper/validator.go (9)
25-25
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
103-103
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
115-115
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
131-131
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
141-141
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
146-146
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
156-156
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
158-158
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
191-191
: LGTM! The usage ofcollections.Join3
simplifies the key concatenation.The modification enhances readability and consistency.
x/distribution/keeper/delegation.go (3)
70-70
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
74-74
: LGTM! The usage ofcollections.Join
simplifies the key concatenation.The modification enhances readability and consistency.
281-281
: Bugfix approved! Correct key used forValidatorOutstandingRewards
.The modification fixes the bug by using
valAddr
instead ofdelAddr
.
The bug comes from the setting the outstanding rewards with wrong key.