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

[TRA-416] Set market mapper revenue share on market creation #1755

Merged
merged 6 commits into from
Jun 24, 2024
Merged

Conversation

shrenujb
Copy link
Contributor

@shrenujb shrenujb commented Jun 24, 2024

Changelist

Test Plan

Added tests

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Integration with the new RevShare module for improved revenue sharing capabilities.
  • Bug Fixes

    • Enhanced test setups to properly initialize all required dependencies for accurate test results.
  • Tests

    • Updated tests to include additional parameters ensuring comprehensive test coverage.
  • Chores

    • Adjusted various initialization functions to include new dependencies for better modularity and code maintainability.

Copy link

linear bot commented Jun 24, 2024

Copy link
Contributor

coderabbitai bot commented Jun 24, 2024

Walkthrough

The changes primarily focus on updating various files across the protocol package to include additional parameters and arguments in function calls. These modifications ensure the integration of new dependencies, such as RevShareKeeper, into different components, adjusting tests, initialization, and creation functions accordingly.

Changes

Files Change Summaries
protocol/app/app.go, .../keeper/assets.go, .../keeper/clob.go, .../keeper/perpetuals.go Added arguments to function calls for creating and initializing PricesKeeper. Specifically, included nil and app.RevShareKeeper parameters.
.../keeper/prices.go, .../keeper/rewards.go, .../keeper/sending.go, .../keeper/subaccounts.go Adding revShareKeeper parameter to the createPricesKeeper function and other related initialization functions.
protocol/app/prepare/prepare_proposal_test.go, .../process/full_node_process_proposal_test.go Modified test setup by adding an extra underscore _ parameter in keepertest.PricesKeepers(t) function calls.
protocol/app/process/market_prices_test.go, .../process/process_proposal_test.go Added an additional parameter to function calls in tests, updating the returned variables by including an extra underscore _.
.../transactions_test.go, protocol/x/prices/genesis_test.go Updated multiple test functions to include an additional variable assignment, primarily adding _ in the keepertest.PricesKeepers(t) function calls.
protocol/x/prices/keeper/grpc_query_market_test.go, .../keeper/keeper_test.go, .../market_param_test.go Included an additional variable assignment in test functions, adding _ in relevant PricesKeepers(t) function calls.
protocol/x/prices/keeper/keeper.go, .../keeper/market.go Added revShareKeeper field to Keeper struct and updated NewKeeper function to accept and initialize it. Also, integrated revShareKeeper in CreateMarket function by invoking CreateNewMarketRevShare.
protocol/testutil/keeper/revshare.go Introduced a new file to create and initialize RevShareKeeper for testing, setting up necessary dependencies like the mock time provider and updating the return type.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant PricesKeeper as PricesKeeper
    participant RevShareKeeper as RevShareKeeper
    participant Test as Test Functions

    App ->> PricesKeeper: Initialize with new arguments
    App ->> RevShareKeeper: Initialize and pass as argument
    PricesKeeper ->> RevShareKeeper: CreateNewMarketRevShare
    Test ->> PricesKeeper: Call PricesKeepers with additional parameters
Loading

Poem

In the code, we made a tweak,
Added nil, new args to speak.
RevShareKeeper joins the crew,
With test setups fresh and new.
Functions dance in perfect time,
A codebase tune, so sublime. 🐰🎵


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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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

@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: 10

Outside diff range and nitpick comments (1)
protocol/testutil/keeper/prices.go (1)

[!TIP]
Codebase Verification

Missing definition for createRevShareKeeper

The function createRevShareKeeper referenced in protocol/testutil/keeper/prices.go is not defined or imported anywhere in the codebase. This will likely cause runtime errors.

  • protocol/testutil/keeper/prices.go: Line 41 - Reference to createRevShareKeeper without a corresponding definition.

Please ensure that createRevShareKeeper is properly defined and imported to avoid runtime issues.

Analysis chain

Line range hint 62-94: Ensure initialization of all components in createPricesKeeper.

The function now accepts a revShareKeeper, which should be properly initialized to ensure it does not cause runtime errors during tests. Consider verifying if all dependencies are correctly set up before use.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check initialization of revShareKeeper in test setups.
rg --type go 'createRevShareKeeper' protocol/testutil/keeper/

Length of output: 163



Script:

#!/bin/bash
# Locate the implementation of createRevShareKeeper function
rg --type go 'func createRevShareKeeper' 

Length of output: 42



Script:

#!/bin/bash
# Search for the term createRevShareKeeper in the entire codebase to locate its definition or related information
rg 'createRevShareKeeper'

Length of output: 127



Script:

#!/bin/bash
# Search for any import statements or dynamic definitions related to createRevShareKeeper
rg 'createRevShareKeeper' --glob '!protocol/testutil/keeper/prices.go'

Length of output: 70

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 502d937 and 0598e85.

Files selected for processing (30)
  • protocol/app/app.go (1 hunks)
  • protocol/app/prepare/prepare_proposal_test.go (2 hunks)
  • protocol/app/process/full_node_process_proposal_test.go (1 hunks)
  • protocol/app/process/market_prices_test.go (3 hunks)
  • protocol/app/process/process_proposal_test.go (1 hunks)
  • protocol/app/process/transactions_test.go (4 hunks)
  • protocol/testutil/keeper/assets.go (2 hunks)
  • protocol/testutil/keeper/clob.go (1 hunks)
  • protocol/testutil/keeper/perpetuals.go (1 hunks)
  • protocol/testutil/keeper/prices.go (4 hunks)
  • protocol/testutil/keeper/rewards.go (2 hunks)
  • protocol/testutil/keeper/sending.go (1 hunks)
  • protocol/testutil/keeper/subaccounts.go (2 hunks)
  • protocol/x/prices/genesis_test.go (5 hunks)
  • protocol/x/prices/keeper/grpc_query_market_test.go (5 hunks)
  • protocol/x/prices/keeper/keeper.go (3 hunks)
  • protocol/x/prices/keeper/keeper_test.go (1 hunks)
  • protocol/x/prices/keeper/market.go (1 hunks)
  • protocol/x/prices/keeper/market_param_test.go (5 hunks)
  • protocol/x/prices/keeper/market_price_test.go (5 hunks)
  • protocol/x/prices/keeper/market_test.go (5 hunks)
  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go (2 hunks)
  • protocol/x/prices/keeper/msg_server_update_market_param_test.go (2 hunks)
  • protocol/x/prices/keeper/msg_server_update_market_prices_test.go (4 hunks)
  • protocol/x/prices/keeper/slinky_adapter_test.go (5 hunks)
  • protocol/x/prices/keeper/update_price_test.go (1 hunks)
  • protocol/x/prices/keeper/validate_market_price_updates_test.go (4 hunks)
  • protocol/x/prices/module.go (1 hunks)
  • protocol/x/prices/module_test.go (3 hunks)
  • protocol/x/prices/types/expected_keepers.go (2 hunks)
Files not reviewed due to errors (3)
  • protocol/x/prices/keeper/keeper.go (no review received)
  • protocol/app/process/full_node_process_proposal_test.go (no review received)
  • protocol/app/prepare/prepare_proposal_test.go (no review received)
Files skipped from review due to trivial changes (4)
  • protocol/x/prices/keeper/grpc_query_market_test.go
  • protocol/x/prices/keeper/market_param_test.go
  • protocol/x/prices/keeper/slinky_adapter_test.go
  • protocol/x/prices/keeper/validate_market_price_updates_test.go
Additional comments not posted (27)
protocol/x/prices/keeper/keeper_test.go (1)

11-11: Ensure the new parameter is properly documented and utilized.

The change in the keepertest.PricesKeepers(t) function call now includes additional parameters to accommodate the new revShareKeeper. Ensure that this change is reflected in the documentation and that the revShareKeeper is properly utilized within the test setup.

protocol/x/prices/genesis_test.go (3)

54-54: Approve the addition of the underscore parameter in PricesKeepers.

The inclusion of an underscore parameter in the PricesKeepers function call correctly reflects the updated function signature with the new revShareKeeper parameter. Adding a comment to explain the use of the underscore as a placeholder would enhance clarity.


98-98: Approve the addition of the underscore parameter in PricesKeepers.

The inclusion of an underscore parameter in the PricesKeepers function call correctly reflects the updated function signature with the new revShareKeeper parameter. Adding a comment to explain the use of the underscore as a placeholder would enhance clarity.


108-108: Approve the addition of the underscore parameter in PricesKeepers.

The inclusion of an underscore parameter in the PricesKeepers function call correctly reflects the updated function signature with the new revShareKeeper parameter. Adding a comment to explain the use of the underscore as a placeholder would enhance clarity.

protocol/testutil/keeper/sending.go (1)

60-60: Confirm the use of nil for revShareKeeper in test setup.

The addition of nil as the revShareKeeper argument in createPricesKeeper might be intended for testing. Confirm if this is a temporary placeholder or part of the final implementation.

Verification successful

Confirmed: Consistent use of nil for revShareKeeper in test setups.

The usage of nil as the revShareKeeper argument in the createPricesKeeper function is consistent across multiple test setup files. This suggests that it is an intentional placeholder or not required for these tests.

  • protocol/testutil/keeper/assets.go
  • protocol/testutil/keeper/rewards.go
  • protocol/testutil/keeper/subaccounts.go
  • protocol/testutil/keeper/sending.go
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Confirm the usage of `nil` for `revShareKeeper` in test setups across the codebase.

# Test: Search for the usage of `nil` for `revShareKeeper` in test setups. Expect: Consistent usage of `nil` or a valid object across similar setups.
rg --type go $'createPricesKeeper(.+nil)'

Length of output: 597

protocol/x/prices/keeper/update_price_test.go (1)

126-126: LGTM!

The addition of an extra underscore parameter in PricesKeepers aligns with the updated function signatures across the codebase.

protocol/testutil/keeper/subaccounts.go (1)

56-56: Confirm the use of nil for revShareKeeper in test setup.

The addition of nil as the revShareKeeper argument in createPricesKeeper might be intended for testing. Confirm if this is a temporary placeholder or part of the final implementation.

protocol/x/prices/keeper/market_price_test.go (6)

28-28: Approved the addition of the revShareKeeper parameter in the test setup.

This change aligns with the PR's objective to integrate revenue sharing logic into the market creation process.


63-63: Approved the addition of the revShareKeeper parameter in the test setup.

This change is necessary to ensure the new functionality is covered in the tests.


92-92: Approved the addition of the revShareKeeper parameter in the test setup.

Ensures that the tests are consistent with the new architecture.


107-107: Approved the addition of the revShareKeeper parameter in the test setup.

This update is crucial for maintaining the integrity of the test environment with the new system architecture.


113-113: Approved the addition of the revShareKeeper parameter in the test setup.

This ensures that the test setup reflects the changes in the main codebase.


129-129: Approved the addition of the revShareKeeper parameter in the test setup.

This change is consistent with the PR's goal to integrate revenue sharing logic, ensuring that the test environment matches the production code.

protocol/x/prices/module.go (1)

104-122: Approved the integration of the RevShareKeeper into the AppModule structure.

The addition of RevShareKeeper to the AppModule structure and its constructor function NewAppModule is well-aligned with the PR's objectives to handle revenue sharing. This change is necessary for the new functionality to be effectively integrated into the module.

protocol/app/process/market_prices_test.go (3)

68-68: Approved the addition of the revShareKeeper parameter in the test setup.

This update is essential for ensuring that the test environment accurately reflects the changes made to the main codebase regarding the integration of revenue sharing logic.


123-123: Approved the addition of the revShareKeeper parameter in the test setup.

This ensures that the test setup is consistent with the new system architecture, which includes the revenue sharing logic.


165-165: Approved the addition of the revShareKeeper parameter in the test setup.

This change is crucial for maintaining the integrity of the test environment with the new system architecture.

protocol/x/prices/keeper/msg_server_update_market_param_test.go (1)

147-147: Approved the addition of the revShareKeeper parameter in the test setup.

This change ensures that the test setup reflects the new architecture and is crucial for testing the updated functionality related to market parameter management.

protocol/x/prices/keeper/market_test.go (1)

61-64: Approve new functionality testing for market revenue share creation.

The test checks the retrieval of market revenue share details, which is a direct reflection of the new functionality introduced. This is a crucial test to ensure the revShareKeeper integration works as expected.

protocol/testutil/keeper/prices.go (1)

Line range hint 29-54: Enhancement: Improved test setup with revShareKeeper.

The function PricesKeepers has been extended to include revShareKeeper, which is consistent with the modifications in the keeper's structure. This ensures that all tests will have access to the required keepers, reflecting the new architectural changes.

protocol/testutil/keeper/clob.go (1)

82-88: Approved Change: Addition of nil parameter to createPricesKeeper function call.

The added nil parameter aligns with the introduction of the revShareKeeper in the broader system, ensuring consistency across the codebase.

protocol/app/process/process_proposal_test.go (1)

261-261: Approved Change: Updated function call to include an additional underscore parameter.

This change is necessary to accommodate the new revShareKeeper parameter, ensuring that the function signature is consistent across the codebase.

protocol/app/process/transactions_test.go (1)

111-111: Approved Changes: Updated function calls to include an additional underscore parameter.

These changes are necessary to accommodate the new revShareKeeper parameter, ensuring that the function signature remains consistent across the codebase, including in test setups.

Also applies to: 191-191

protocol/x/prices/keeper/msg_server_update_market_prices_test.go (4)

189-189: Approved the addition of the new keeper parameter.

The addition of an additional return value _ from PricesKeepers aligns with the PR's changes. It's good practice to use a placeholder for unused variables to maintain clarity.


315-315: Approved the addition of the new keeper parameter.

The addition of an additional return value _ from PricesKeepers is consistent with the integration of the new revShareKeeper functionality. Using a placeholder for unused variables is a clean approach to handle changes in function signatures.


379-379: Approved the addition of the new keeper parameter.

The addition of an additional return value _ from PricesKeepers is consistent with the integration of the new revShareKeeper functionality. Using a placeholder for unused variables is a clean approach to handle changes in function signatures.


402-402: Approved the addition of the new keeper parameter.

The addition of an additional return value _ from PricesKeepers is consistent with the integration of the new revShareKeeper functionality. Using a placeholder for unused variables is a clean approach to handle changes in function signatures.

protocol/app/app.go Outdated Show resolved Hide resolved
protocol/x/prices/keeper/market.go Show resolved Hide resolved
protocol/x/prices/keeper/market_test.go Show resolved Hide resolved
protocol/testutil/keeper/assets.go Outdated Show resolved Hide resolved
protocol/x/prices/genesis_test.go Show resolved Hide resolved
protocol/x/prices/keeper/market_test.go Show resolved Hide resolved
protocol/x/prices/module_test.go Show resolved Hide resolved
protocol/testutil/keeper/rewards.go Outdated Show resolved Hide resolved
protocol/testutil/keeper/perpetuals.go Outdated Show resolved Hide resolved
Signed-off-by: Shrenuj Bansal <[email protected]>
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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0598e85 and 783f791.

Files selected for processing (1)
  • protocol/x/prices/types/expected_keepers.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • protocol/x/prices/types/expected_keepers.go

shrenujb added 2 commits June 24, 2024 13:47
Signed-off-by: Shrenuj Bansal <[email protected]>
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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 783f791 and 8e150bf.

Files selected for processing (10)
  • protocol/app/app.go (2 hunks)
  • protocol/app/simulation_test.go (2 hunks)
  • protocol/testutil/app/app.go (3 hunks)
  • protocol/testutil/keeper/assets.go (2 hunks)
  • protocol/testutil/keeper/clob.go (1 hunks)
  • protocol/testutil/keeper/perpetuals.go (1 hunks)
  • protocol/testutil/keeper/revshare.go (1 hunks)
  • protocol/testutil/keeper/rewards.go (2 hunks)
  • protocol/testutil/keeper/sending.go (1 hunks)
  • protocol/testutil/keeper/subaccounts.go (2 hunks)
Files skipped from review as they are similar to previous changes (7)
  • protocol/app/app.go
  • protocol/testutil/keeper/assets.go
  • protocol/testutil/keeper/clob.go
  • protocol/testutil/keeper/perpetuals.go
  • protocol/testutil/keeper/rewards.go
  • protocol/testutil/keeper/sending.go
  • protocol/testutil/keeper/subaccounts.go
Additional comments not posted (4)
protocol/app/simulation_test.go (1)

138-138: Addition of revsharetypes.ModuleName to Genesis Modules

The inclusion of revsharetypes.ModuleName in the genesis module order is a crucial update for ensuring that the new revenue sharing functionality is integrated into the simulation tests. This change is appropriate and aligns with the broader updates made across the system to support revenue sharing features.

protocol/testutil/app/app.go (3)

18-19: Added import for revshare types.

The addition of revsharetypes from github.com/dydxprotocol/v4-chain/protocol/x/revshare/types is aligned with the PR's focus on integrating revenue sharing features. This change is necessary to support the types used in the modifications related to revenue sharing.


207-208: Updated GenesisStates type to include revsharetypes.GenesisState.

This change integrates the revsharetypes.GenesisState into the GenesisStates type, which is crucial for ensuring that the revsharetypes module can participate in genesis state handling. This modification is necessary for initializing and updating the genesis state with revenue sharing data, aligning with the PR's objectives to enhance market creation features with revenue sharing capabilities.


264-265: Added case for revsharetypes.GenesisState in UpdateGenesisDocWithAppStateForModule.

Adding a case for revsharetypes.GenesisState in the UpdateGenesisDocWithAppStateForModule function is essential for handling the initialization and updates of the revenue sharing module's genesis state. This ensures that any modifications or initializations specific to the revenue sharing features are processed correctly during the app's genesis state setup.

protocol/testutil/keeper/revshare.go Show resolved Hide resolved
protocol/testutil/keeper/revshare.go Show resolved Hide resolved
protocol/app/app.go Outdated Show resolved Hide resolved
shrenujb added 2 commits June 24, 2024 16:25
Signed-off-by: Shrenuj Bansal <[email protected]>
Signed-off-by: Shrenuj Bansal <[email protected]>
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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e150bf and 7291167.

Files selected for processing (2)
  • protocol/app/app.go (3 hunks)
  • protocol/x/prices/keeper/market_test.go (5 hunks)
Files skipped from review as they are similar to previous changes (2)
  • protocol/app/app.go
  • protocol/x/prices/keeper/market_test.go

@coderabbitai coderabbitai bot mentioned this pull request Dec 13, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants