Skip to content
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(sims): skip operations that use denoms that can't be sent #20399

Merged
merged 3 commits into from
May 15, 2024

Conversation

facundomedica
Copy link
Member

@facundomedica facundomedica commented May 15, 2024

Description

Follow up to #20343.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Added checks for withdrawable coins before sending rewards.
    • Implemented checks to ensure denominations are sendable before undelegating and redelegating in staking operations.
  • Improvements

    • Enhanced reliability of rewards and staking operations by verifying sendability of denominations.

@facundomedica facundomedica requested a review from a team as a code owner May 15, 2024 07:41
Copy link
Contributor

coderabbitai bot commented May 15, 2024

Walkthrough

Walkthrough

The recent updates enhance the system by introducing a mechanism to verify the sendability of coins before executing reward withdrawals and staking operations. This includes adding the IsSendEnabledDenom method to the BankKeeper interface to ensure specific denominations are enabled for sending. These changes improve the reliability of operations like reward withdrawals, undelegating, and redelegating by confirming the sendability of involved denominations.

Changes

Files Change Summaries
x/distribution/simulation/operations.go
x/staking/simulation/operations.go
Added checks for sendability of coins before executing certain operations.
x/distribution/types/expected_keepers.go
x/staking/types/expected_keepers.go
Added IsSendEnabledDenom method to the BankKeeper interface.
testutil/mock/types_module_module.go
x/distribution/testutil/expected_keepers_mocks.go
x/staking/testutil/expected_keepers_mocks.go
Updated mock implementations for IsSendEnabledDenom method.

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@facundomedica your pull request is missing a changelog!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 080229f and 9560be7.
Files selected for processing (4)
  • x/distribution/simulation/operations.go (1 hunks)
  • x/distribution/types/expected_keepers.go (1 hunks)
  • x/staking/simulation/operations.go (2 hunks)
  • x/staking/types/expected_keepers.go (1 hunks)
Additional Context Used
Path-based Instructions (4)
x/distribution/types/expected_keepers.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/staking/types/expected_keepers.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/distribution/simulation/operations.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/staking/simulation/operations.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (5)
x/distribution/types/expected_keepers.go (1)

34-34: Addition of IsSendEnabledDenom method to BankKeeper interface looks good. Ensure that all implementations of this interface are updated accordingly.

x/staking/types/expected_keepers.go (1)

43-43: Addition of IsSendEnabledDenom method to BankKeeper interface looks good. Ensure that all implementations of this interface are updated accordingly.

x/distribution/simulation/operations.go (1)

161-171: Good addition of checks for whether a denomination is enabled for sending before proceeding with the withdrawal operation. This ensures that only sendable denominations are processed, preventing potential errors.

x/staking/simulation/operations.go (2)

453-456: Check for send-enabled denomination before undelegating.

This check ensures that the undelegate operation does not proceed if the bond denomination is not enabled for sending. This is a good addition for robustness.


719-722: Check for send-enabled denomination before redelegating.

This check ensures that the redelegate operation does not proceed if the bond denomination is not enabled for sending. This is a good addition for robustness.

Comment on lines +167 to +171
for _, v := range outstanding {
if !bk.IsSendEnabledDenom(ctx, v.Denom) {
return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "denom send not enabled: "+v.Denom), nil, nil
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a log message or metric increment here to track how often operations are skipped due to non-sendable denominations. This can help in monitoring and debugging.

+ // Log or metric increment can be added here for monitoring

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
for _, v := range outstanding {
if !bk.IsSendEnabledDenom(ctx, v.Denom) {
return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "denom send not enabled: "+v.Denom), nil, nil
}
}
for _, v := range outstanding {
if !bk.IsSendEnabledDenom(ctx, v.Denom) {
// Log or metric increment can be added here for monitoring
return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "denom send not enabled: "+v.Denom), nil, nil
}
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9560be7 and 80f57e2.
Files selected for processing (3)
  • testutil/mock/types_module_module.go (3 hunks)
  • x/distribution/testutil/expected_keepers_mocks.go (1 hunks)
  • x/staking/testutil/expected_keepers_mocks.go (1 hunks)
Additional Context Used
Path-based Instructions (3)
testutil/mock/types_module_module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/distribution/testutil/expected_keepers_mocks.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/staking/testutil/expected_keepers_mocks.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (5)
testutil/mock/types_module_module.go (2)

70-70: The addition of the RegisterLegacyAminoCodec method in the MockAppModuleBasic struct looks good.


268-268: The addition of the RegisterLegacyAminoCodec method in the MockHasAminoCodec struct looks good.

x/distribution/testutil/expected_keepers_mocks.go (1)

159-171: The addition of the IsSendEnabledDenom method in the MockBankKeeper struct looks good.

x/staking/testutil/expected_keepers_mocks.go (2)

205-211: Correct implementation of the IsSendEnabledDenom mock method.


213-217: Correct implementation of the IsSendEnabledDenom recorder method.

Copy link
Contributor

@testinginprod testinginprod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tac0turtle tac0turtle added this pull request to the merge queue May 15, 2024
Merged via the queue into main with commit 74f44b0 May 15, 2024
69 checks passed
@tac0turtle tac0turtle deleted the facu/fix-sims branch May 15, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants