Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

chore(distribution): Test calling query view methods in distribution precompile #1341

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

calbera
Copy link
Contributor

@calbera calbera commented Dec 6, 2023

  • Related to issue of calling view functions which have underlying cosmos behavior that makes state changes
  • Add query method for delegator-validator rewards

Summary by CodeRabbit

  • New Features

    • Introduced new events for reward withdrawal and address setting, enhancing user interaction with the distribution module.
    • Added new methods for retrieving delegator validator rewards and setting withdrawal addresses, providing users with more control over their rewards.
  • Improvements

    • Updated method signatures to include additional parameters and return types, improving the clarity and functionality of the distribution module.
  • Documentation

    • Clarified the use of CacheContext in comments to better explain its role in view methods within the distribution module.

@calbera calbera requested review from itsdevbear and ocnc December 6, 2023 16:12
Copy link

coderabbitai bot commented Dec 6, 2023

Walkthrough

The changes involve updates to a Solidity smart contract and corresponding Go files in a Cosmos SDK module. New functions and events have been added to the contract to enhance interactions with the distribution module, and comments in the Go files have been clarified regarding the use of CacheContext. Additionally, a test file has been refactored for better readability.

Changes

File Path Change Summary
.../precompile/testing/DistributionQuerier.sol Added SPDX, import, and new functions to interact with distributionModule.
.../precompile/distribution/distribution.go Clarified comments on CacheContext usage in view methods.
.../precompile/Distribution.sol Added events, modified event descriptions, and updated method signatures.
.../distribution/distribution_test.go Improved test readability with new variable for assertions.

🐇✨
In the realm of code where smart contracts thrive,
A rabbit hopped through, making updates come alive.
With SPDX tags and functions anew,
It refined the tests and comments too. 🌟📝


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

Copy link

@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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 43774ce and fe882f4.
Files ignored due to filter (3)
  • e2e/localnet/go.mod
  • e2e/localnet/go.sum
  • e2e/precompile/go.mod
Files selected for processing (2)
  • contracts/src/cosmos/precompile/testing/DistributionQuerier.sol (1 hunks)
  • cosmos/precompile/distribution/distribution.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • cosmos/precompile/distribution/distribution.go

@itsdevbear
Copy link

Is this just adding a test?

@calbera
Copy link
Contributor Author

calbera commented Dec 6, 2023

yeah @itsdevbear. confirmed it works as intended

@calbera calbera added merge me daddy Trigger Beradozer to bulldoze the PR backport/v0.0.2-alpha labels Dec 6, 2023
@mergify mergify bot merged commit 3294140 into main Dec 6, 2023
10 checks passed
@mergify mergify bot deleted the cal/test-distr-queries branch December 6, 2023 17:01
mergify bot pushed a commit that referenced this pull request Dec 6, 2023
…precompile (#1341)

- Related to issue of calling view functions which have underlying cosmos behavior that makes state changes
- Add query method for delegator-validator rewards

## Summary by CodeRabbit

- **New Features**
  - Introduced new functions for retrieving delegator rewards within the smart contract.

- **Documentation**
  - Updated comments to clarify the use of `CacheContext` in view methods due to writes performed by the Cosmos SDK distribution module's querier.

(cherry picked from commit 3294140)
Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fe882f4 and 2ade264.
Files selected for processing (3)
  • contracts/src/cosmos/precompile/Distribution.sol (3 hunks)
  • cosmos/precompile/distribution/distribution.go (4 hunks)
  • cosmos/precompile/distribution/distribution_test.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • cosmos/precompile/distribution/distribution.go
  • cosmos/precompile/distribution/distribution_test.go
Additional comments: 3
contracts/src/cosmos/precompile/Distribution.sol (3)
  • 82-93: The summary indicates that the setWithdrawAddress and withdrawDelegatorReward methods have been modified to include new parameters and return types, but the hunks do not reflect these changes. Please verify if these modifications were part of the intended changes and ensure they are correctly implemented if so.

  • 30-43: The addition of the WithdrawRewards and SetWithdrawAddress events aligns with the PR objectives and summary. These events are correctly implemented in the hunks.

  • 58-66: The new method getDelegatorValidatorReward has been added as described in the summary and aligns with the PR objectives.

itsdevbear pushed a commit that referenced this pull request Dec 6, 2023
…precompile (backport #1341) (#1342)

This is an automatic backport of pull request #1341 done by
[Mergify](https://mergify.com).


---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the
[documentation](https://docs.mergify.com/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on
`<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.com) you
can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com
</details>

Co-authored-by: Cal Bera <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/v0.0.2-alpha merge me daddy Trigger Beradozer to bulldoze the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants