-
Notifications
You must be signed in to change notification settings - Fork 146
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
chore!: fix PSS mem-tests (SDK v50 upgrade) #1933
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -76,25 +76,18 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Iterate over all registered consumer chains | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for _, consumer := range k.GetAllConsumerChains(ctx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// transfer the consumer rewards to the distribution module account | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// note that the rewards transferred are only consumer whitelisted denoms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Get coins of the consumer rewards allocation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
allocation := k.GetConsumerRewardsAllocation(ctx, consumer.ChainId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if allocation.Rewards.IsZero() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rewardsCollected, err := k.TransferConsumerRewardsToDistributionModule(ctx, consumer.ChainId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bermuell marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
k.Logger(ctx).Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"fail to transfer rewards to distribution module for chain %s: %s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
consumer.ChainId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
err, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+79
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider refining the error handling in - k.Logger(ctx).Error(
- "fail to transfer rewards to distribution module for chain %s: %s",
- consumer.ChainId,
- err,
- )
+ if errors.Is(err, ExpectedErrorType) {
+ k.Logger(ctx).Error(
+ "expected error occurred while transferring rewards for chain %s: %s",
+ consumer.ChainId,
+ err,
+ )
+ } else {
+ k.Logger(ctx).Error(
+ "unexpected error occurred while transferring rewards for chain %s: %s",
+ consumer.ChainId,
+ err,
+ )
+ } Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
continue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Truncate coin rewards | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rewardsCollected := sdk.Coins{} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rewardsCollected, _ = allocation.Rewards.TruncateDecimal() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// NOTE the consumer rewards allocation isn't a module account, however its coins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// are held in the consumer reward pool module account. Thus the consumer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// rewards allocation must be reduced separately from the FundCommunityPool call. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Update consumer rewards allocation with the remaining decimal coins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
allocation.Rewards = allocation.Rewards.Sub(sdk.NewDecCoinsFromCoins(rewardsCollected...)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
k.SetConsumerRewardsAllocation(ctx, consumer.ChainId, allocation) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// note that it's possible that no rewards are collected even though the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// reward pool isn't empty. This can happen if the reward pool holds some tokens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// of non-whitelisted denominations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -192,8 +185,9 @@ func (k Keeper) AllocateTokensToConsumerValidators( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return allocated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// GetConsumerRewardsCollected get the consumer rewards pool to a the distribution module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (k Keeper) GetConsumerRewardsCollected( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// TransferConsumerRewardsToDistributionModule transfers the rewards allocation of the given consumer chain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// from the consumer rewards pool to the distribution module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (k Keeper) TransferConsumerRewardsToDistributionModule( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sainoe marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The
Analysis chainEnsure that the Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that all edge cases and potential errors are handled in the `TransferConsumerRewardsToDistributionModule` function.
# Test: Search for error handling patterns in the function implementation.
ast-grep --lang go --pattern $'func (k Keeper) TransferConsumerRewardsToDistributionModule($_, $_) {
$$$
if $_ {
$$$
}
$$$
}'
Length of output: 138 Script: #!/bin/bash
# Locate the `TransferConsumerRewardsToDistributionModule` function definition and print its implementation.
ast-grep --lang go --pattern 'func (k Keeper) TransferConsumerRewardsToDistributionModule($_, $_) { $$$ }'
Length of output: 108 Script: #!/bin/bash
# Search for the `TransferConsumerRewardsToDistributionModule` function definition in the codebase.
rg 'func (k Keeper) TransferConsumerRewardsToDistributionModule'
Length of output: 66 Script: #!/bin/bash
# List all Go files and search for the `TransferConsumerRewardsToDistributionModule` function definition within those files.
fd -e go -x rg 'func (k Keeper) TransferConsumerRewardsToDistributionModule' {}
Length of output: 83 Script: #!/bin/bash
# Search for the `TransferConsumerRewardsToDistributionModule` function definition within the specified file.
rg 'func (k Keeper) TransferConsumerRewardsToDistributionModule' x/ccv/provider/keeper/distribution.go
Length of output: 104 Script: #!/bin/bash
# List all functions in the specified file to confirm the presence of the `TransferConsumerRewardsToDistributionModule` function.
ast-grep --lang go --pattern 'func $_($_, $_) { $$$ }' x/ccv/provider/keeper/distribution.go
Length of output: 94 Script: #!/bin/bash
# Search for the `TransferConsumerRewardsToDistributionModule` function definition within the specified file using a more general pattern.
rg 'TransferConsumerRewardsToDistributionModule' x/ccv/provider/keeper/distribution.go
Length of output: 351 Script: #!/bin/bash
# Extract the full implementation of the `TransferConsumerRewardsToDistributionModule` function.
rg -A 20 'func (k Keeper) TransferConsumerRewardsToDistributionModule' x/ccv/provider/keeper/distribution.go
Length of output: 110 Script: #!/bin/bash
# Extract the full implementation of the `TransferConsumerRewardsToDistributionModule` function using a larger context window.
rg -A 50 'func (k Keeper) TransferConsumerRewardsToDistributionModule' x/ccv/provider/keeper/distribution.go
Length of output: 110 Script: #!/bin/bash
# Display the contents of the specified file to manually locate and inspect the function.
cat x/ccv/provider/keeper/distribution.go
Length of output: 10788 Toolsgolangci-lint
Comment on lines
+188
to
+190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure comprehensive error handling in The function handles the scenario where Toolsgolangci-lint
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ctx sdk.Context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chainID string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) (sdk.Coins, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Remove if not needed