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-508] Require that market exists in market map when creating new oracle market #1960

Merged
merged 26 commits into from
Jul 25, 2024

Conversation

chenyaoy
Copy link
Contributor

@chenyaoy chenyaoy commented Jul 23, 2024

Changelist

[Describe or list the changes made in this PR]

Test Plan

[Describe how this PR was tested (if applicable)]

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

    • Enhanced integration of market map functionality within the application, improving interaction with prices and assets modules.
    • Expanded configurations for cryptocurrency markets in the sample pregenesis file, allowing for better integration with trading platforms.
    • Improved simulation of market parameters with dynamically generated configurations.
    • Integrated new keeper for market map management and expanded testing capabilities.
  • Bug Fixes

    • Adjusted initialization processes to ensure accurate market state management within tests.
  • Tests

    • Expanded test cases to include additional checks, updated function signatures, and improved robustness in handling market data.
    • Enhanced testing framework by incorporating comprehensive market condition simulations.
  • Refactor

    • Modified function signatures and internal logic across multiple modules to accommodate new dependencies and enhance maintainability.
    • Standardized command syntax in the Makefile for consistency with current Docker practices.
    • Updated tests for market creation to include checks against the market map, enhancing validation of expected behavior.

Copy link

linear bot commented Jul 23, 2024

Copy link
Contributor

coderabbitai bot commented Jul 23, 2024

Walkthrough

The recent updates significantly enhance the integration and functionality of the market map module within the application. Key changes include the introduction of a MarketMapKeeper, adjustments to initialization sequences across various modules, expanded test cases for validating these enhancements, and detailed configurations for cryptocurrency markets. Collectively, these modifications aim to refine functionality, improve error handling, and bolster the maintainability and extensibility of the trading application.

Changes

Files Change Summary
protocol/app/app.go Refactored New and NewAppModule functions to include MarketMapKeeper. Adjusted module initialization order for dependencies.
protocol/go.mod Updated versions of several dependencies, including Cosmos SDK and related libraries for improved compatibility and functionality.
protocol/x/prices/module_test.go, protocol/x/prices/keeper/msg_server_create_oracle_market_test.go, protocol/x/prices/keeper/market_test.go Expanded context variable unpacking in tests to include MarketMapKeeper for enhanced market management and validation.
protocol/x/prices/keeper/slinky_adapter_test.go, protocol/x/clob/module_test.go, protocol/x/perpetuals/module_test.go Modified test functions to integrate new context setups and enhance market creation processes.
protocol/testing/e2e/gov/perpetuals_test.go, protocol/testing/e2e/gov/add_new_market_test.go Enhanced tests to include market definitions in the genesis state, improving simulation capabilities and validating state transitions.
protocol/testutil/sim_helpers/genesis_parameters.go Adjusted genesis parameters related to market exchanges, refining constraints for market behavior.
protocol/scripts/genesis/sample_pregenesis.json Removed dydxaccountplus, expanded marketmap configurations, and updated order_expiration_seconds and versioning details.
protocol/Makefile Updated Docker command syntax from docker-compose to docker compose for consistency with current practices.
protocol/lib/marketmap/utils.go, protocol/lib/marketmap/utils_test.go Introduced ConstructMarketMapFromParams function for converting market parameters into a market map; added unit tests for validation.

Poem

🐰 In the meadow where markets play,
A keeper hops, brightening the day.
With maps of trade, oh what a sight,
Each function sings with pure delight.
Let prices dance and markets cheer,
For joyful code brings us near!
🌸


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 Configuration 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: 3

Outside diff range, codebase verification and nitpick comments (17)
protocol/x/prices/types/errors.go (2)

28-32: Add a comment to describe the new error.

Adding a brief comment to describe the ErrMarketPairConversionFailed error can enhance readability and maintainability.

+ // ErrMarketPairConversionFailed indicates a failure in converting a market pair to a currency pair.
	ErrMarketPairConversionFailed     = errorsmod.Register(
		ModuleName,
		206,
		"Market pair conversion to currency pair failed",
	)

33-33: Add a comment to describe the new error.

Adding a brief comment to describe the ErrTickerNotFoundInMarketMap error can enhance readability and maintainability.

+ // ErrTickerNotFoundInMarketMap indicates that a ticker could not be located within the market map.
	ErrTickerNotFoundInMarketMap = errorsmod.Register(ModuleName, 207, "Ticker not found in market map")
protocol/x/clob/keeper/msg_server_update_liquidations_config_test.go (1)

6-6: Revert unnecessary import movement.

The movement of the import statement for the lib package is unnecessary and does not alter any functionality. It is better to keep the imports grouped logically.

-	"github.com/dydxprotocol/v4-chain/protocol/lib"
	govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
	"github.com/dydxprotocol/v4-chain/protocol/mocks"
	"github.com/dydxprotocol/v4-chain/protocol/testutil/constants"
	keepertest "github.com/dydxprotocol/v4-chain/protocol/testutil/keeper"
	"github.com/dydxprotocol/v4-chain/protocol/x/clob/keeper"
	"github.com/dydxprotocol/v4-chain/protocol/x/clob/memclob"
	"github.com/dydxprotocol/v4-chain/protocol/x/clob/types"
	"github.com/dydxprotocol/v4-chain/protocol/x/perpetuals"
	"github.com/dydxprotocol/v4-chain/protocol/x/prices"
	"github.com/stretchr/testify/require"
+	"github.com/dydxprotocol/v4-chain/protocol/lib"
protocol/x/prices/keeper/keeper.go (2)

29-29: Add a comment to describe the new field.

Adding a brief comment to describe the MarketMapKeeper field can enhance readability and maintainability.

		RevShareKeeper                 types.RevShareKeeper
+		// MarketMapKeeper manages the market map data.
		MarketMapKeeper                types.MarketMapKeeper

43-43: Add a comment to describe the new parameter.

Adding a brief comment to describe the marketMapKeeper parameter can enhance readability and maintainability.

	revShareKeeper types.RevShareKeeper,
+	// marketMapKeeper manages the market map data.
	marketMapKeeper types.MarketMapKeeper,
protocol/x/prices/genesis_test.go (3)

37-40: Ensure all instances of PricesKeepers match the new signature.

The following locations still use the old signature for PricesKeepers and need to be updated to include marketMapKeeper:

  • protocol/x/prices/module_test.go
  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go
  • protocol/x/prices/keeper/msg_server_update_market_param_test.go
  • protocol/x/prices/keeper/slinky_adapter_test.go
  • protocol/x/prices/keeper/market_price_test.go
  • protocol/x/prices/keeper/market_test.go
  • protocol/x/prices/keeper/update_price_test.go
  • protocol/x/prices/keeper/validate_market_price_updates_test.go
  • protocol/x/prices/keeper/grpc_query_market_test.go
  • protocol/x/prices/keeper/market_param_test.go
  • protocol/x/prices/keeper/keeper_test.go
  • protocol/x/prices/keeper/msg_server_update_market_prices_test.go
  • protocol/testutil/keeper/prices.go
  • protocol/app/process/transactions_test.go
  • protocol/app/process/process_proposal_test.go
  • protocol/app/prepare/prepare_proposal_test.go
  • protocol/app/process/full_node_process_proposal_test.go
  • protocol/app/process/market_prices_test.go

Please update these instances to ensure consistency with the new function signature.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PricesKeepers match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PricesKeepers` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'PricesKeepers'

Length of output: 28890


55-58: Ensure all function calls to PricesKeepers match the new signature.

The following files contain calls to PricesKeepers that do not match the new signature and need to be updated:

  • protocol/x/prices/module_test.go: Line 1
  • protocol/x/prices/keeper/keeper_test.go: Line 1
  • protocol/x/prices/keeper/msg_server_update_market_prices_test.go: Lines 1, 2, 3, 4
  • protocol/x/prices/keeper/market_test.go: Lines 1, 2, 3, 4
  • protocol/x/prices/keeper/market_price_test.go: Lines 1, 2, 3, 4, 5
  • protocol/x/prices/keeper/validate_market_price_updates_test.go: Lines 1, 2, 3, 4, 5
  • protocol/x/prices/keeper/market_param_test.go: Lines 1, 2, 3, 4, 5
  • protocol/x/prices/keeper/grpc_query_market_test.go: Lines 1, 2, 3, 4, 5
  • protocol/x/prices/keeper/update_price_test.go: Line 1
  • protocol/x/prices/keeper/msg_server_update_market_param_test.go: Line 1
  • protocol/x/prices/keeper/slinky_adapter_test.go: Lines 1, 2, 3, 4, 5
  • protocol/app/process/transactions_test.go: Lines 1, 2, 3, 4, 5
  • protocol/app/process/market_prices_test.go: Lines 1, 2, 3
  • protocol/app/process/process_proposal_test.go: Line 1
  • protocol/app/process/full_node_process_proposal_test.go: Line 1
  • protocol/app/prepare/prepare_proposal_test.go: Line 1

Please update these instances to match the new signature, ensuring the marketMapKeeper is included as the last parameter.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PricesKeepers match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PricesKeepers` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'PricesKeepers'

Length of output: 28890


111-114: Ensure all PricesKeepers function calls match the new signature.

The following occurrences of PricesKeepers do not match the new signature and need to be updated:

  • File: protocol/x/prices/module_test.go

    • Line: 1
    • Current: ctx, keeper, _, _, mockTimeProvider, _, _ := keeper.PricesKeepers(t)
    • Expected: ctx, keeper, _, _, mockTimeProvider, _, marketMapKeeper := keeper.PricesKeepers(t)
  • File: protocol/x/prices/keeper/grpc_query_market_test.go

    • Line: 1
    • Current: ctx, keeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, keeper, _, _, mockTimeProvider, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/x/prices/keeper/market_test.go

    • Line: 1
    • Current: ctx, keeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, keeper, _, _, mockTimeProvider, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/x/prices/keeper/market_price_test.go

    • Line: 1
    • Current: ctx, keeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, keeper, _, _, mockTimeProvider, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/x/prices/keeper/market_param_test.go

    • Line: 1
    • Current: ctx, keeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, keeper, _, _, mockTimeProvider, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/x/prices/keeper/msg_server_update_market_prices_test.go

    • Line: 1
    • Current: ctx, k, _, _, mockTimeKeeper, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, k, _, _, mockTimeKeeper, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/x/prices/keeper/validate_market_price_updates_test.go

    • Line: 1
    • Current: ctx, k, _, indexPriceCache, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, k, _, indexPriceCache, mockTimeProvider, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/app/prepare/prepare_proposal_test.go

    • Line: 1
    • Current: ctx, _, _, _, _, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, _, _, _, _, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/app/process/process_proposal_test.go

    • Line: 1
    • Current: ctx, pricesKeeper, _, indexPriceCache, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, pricesKeeper, _, indexPriceCache, mockTimeProvider, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/app/process/transactions_test.go

    • Line: 1
    • Current: ctx, pricesKeeper, _, _, _, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, pricesKeeper, _, _, _, _, marketMapKeeper := keepertest.PricesKeepers(t)
  • File: protocol/app/process/market_prices_test.go

    • Line: 1
    • Current: ctx, k, _, _, _, _, _ := keepertest.PricesKeepers(t)
    • Expected: ctx, k, _, _, _, _, marketMapKeeper := keepertest.PricesKeepers(t)

Please update these occurrences to ensure consistency with the new function signature.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PricesKeepers match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PricesKeepers` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'PricesKeepers'

Length of output: 28890

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

171-171: Ensure all instances of PricesKeepers include marketMapKeeper

The code changes are approved. However, some calls to PricesKeepers do not include marketMapKeeper. Please update the following instances to match the new signature:

  • protocol/x/prices/module_test.go
  • protocol/x/prices/genesis_test.go
  • protocol/x/prices/keeper/grpc_query_market_test.go
  • protocol/x/prices/keeper/market_param_test.go
  • protocol/x/prices/keeper/market_price_test.go
  • protocol/x/prices/keeper/keeper_test.go
  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go
  • protocol/x/prices/keeper/msg_server_update_market_param_test.go
  • protocol/x/prices/keeper/msg_server_update_market_prices_test.go
  • protocol/app/process/process_proposal_test.go
  • protocol/app/process/transactions_test.go
  • protocol/app/prepare/prepare_proposal_test.go
  • protocol/app/process/market_prices_test.go
  • protocol/app/process/full_node_process_proposal_test.go
Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PricesKeepers match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PricesKeepers` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'PricesKeepers'

Length of output: 28890


18-18: Update PricesKeepers function calls to match the new signature.

The following files contain calls to PricesKeepers that need to be updated to include marketMapKeeper:

  • protocol/x/prices/module_test.go
  • protocol/x/prices/genesis_test.go
  • protocol/x/prices/keeper/grpc_query_market_test.go
  • protocol/x/prices/keeper/market_price_test.go
  • protocol/x/prices/keeper/msg_server_update_market_prices_test.go
  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go
  • protocol/x/prices/keeper/validate_market_price_updates_test.go
  • protocol/x/prices/keeper/slinky_adapter_test.go
  • protocol/x/prices/keeper/keeper_test.go
  • protocol/x/prices/keeper/market_test.go
  • protocol/x/prices/keeper/msg_server_update_market_param_test.go
  • protocol/x/prices/keeper/market_param_test.go
  • protocol/app/process/transactions_test.go
  • protocol/app/process/market_prices_test.go
  • protocol/app/process/process_proposal_test.go
  • protocol/app/process/full_node_process_proposal_test.go
  • protocol/app/prepare/prepare_proposal_test.go
Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PricesKeepers match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PricesKeepers` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'PricesKeepers'

Length of output: 28890


220-220: Ensure all PricesKeepers function calls match the new signature.

The following files contain calls to PricesKeepers that do not match the new signature and need to be updated:

  • protocol/x/prices/module_test.go
  • protocol/x/prices/keeper/keeper_test.go
  • protocol/x/prices/keeper/market_param_test.go
  • protocol/x/prices/keeper/validate_market_price_updates_test.go
  • protocol/x/prices/keeper/update_price_test.go
  • protocol/x/prices/keeper/slinky_adapter_test.go
  • protocol/x/prices/keeper/msg_server_update_market_param_test.go
  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go
  • protocol/x/prices/keeper/market_test.go
  • protocol/x/prices/keeper/market_price_test.go
  • protocol/x/prices/keeper/grpc_query_market_test.go
  • protocol/x/prices/keeper/msg_server_update_market_prices_test.go
  • protocol/app/prepare/prepare_proposal_test.go
  • protocol/app/process/transactions_test.go
  • protocol/app/process/process_proposal_test.go
  • protocol/app/process/full_node_process_proposal_test.go
  • protocol/app/process/market_prices_test.go

Please ensure these files are updated to match the new PricesKeepers function signature.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PricesKeepers match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `PricesKeepers` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'PricesKeepers'

Length of output: 28890

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

111-111: Unused unpacked variable in TestDecodeProcessProposalTxs_Error.

The additional variable unpacked from the keepertest.PricesKeepers function call is not used in the TestDecodeProcessProposalTxs_Error function. This should be corrected to either use the variable or modify the function call to only unpack the necessary variables.

  • protocol/app/process/transactions_test.go line 111
Analysis chain

Ensure correct unpacking of additional variable.

Verify that the additional variable unpacked from the keepertest.PricesKeepers function call is correctly handled.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestDecodeProcessProposalTxs_Error` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestDecodeProcessProposalTxs_Error' -A 20

Length of output: 1570


Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `transactions_test.go` file. Expect: Proper unpacking of the additional variable.
rg --type go 'PricesKeepers' -A 20 protocol/app/process/transactions_test.go

Length of output: 3386


191-191: Ensure correct unpacking of additional variable.

The marketMapKeeper variable is unpacked from the keepertest.PricesKeepers function call but is not utilized within the TestDecodeProcessProposalTxs_Valid function. This indicates that the additional variable is not correctly handled.

  • protocol/app/process/transactions_test.go line 191
Analysis chain

Ensure correct unpacking of additional variable.

Verify that the additional variable unpacked from the keepertest.PricesKeepers function call is correctly handled.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestDecodeProcessProposalTxs_Valid` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestDecodeProcessProposalTxs_Valid' -A 20

Length of output: 1613


Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestDecodeProcessProposalTxs_Valid` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestDecodeProcessProposalTxs_Valid' -A 50

Length of output: 3577


Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestDecodeProcessProposalTxs_Valid` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestDecodeProcessProposalTxs_Valid' -A 100

Length of output: 7383


Script:

#!/bin/bash
# Description: Verify the definition of the `PricesKeepers` function to understand what variables it returns.

# Test: Search for the definition of the `PricesKeepers` function. Expect: Proper unpacking of the additional variable.
rg --type go 'func PricesKeepers' -A 20

Length of output: 1511


Script:

#!/bin/bash
# Description: Verify the usage of `marketMapKeeper` within the `TestDecodeProcessProposalTxs_Valid` function to ensure it is correctly handled.

# Test: Search for the usage of `marketMapKeeper` within the `TestDecodeProcessProposalTxs_Valid` function. Expect: Proper handling of the additional variable.
rg --type go 'marketMapKeeper' -A 20

Length of output: 28469

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

207-208: Update required: Handle new type in UpdateGenesisDocWithAppStateForModule.

The UpdateGenesisDocWithAppStateForModule function does not currently handle the new type marketmapmoduletypes.GenesisState. Please update the switch statement in this function to include a case for marketmapmoduletypes.GenesisState.

  • protocol/testutil/app/app.go: Update the switch statement in UpdateGenesisDocWithAppStateForModule to handle marketmapmoduletypes.GenesisState.
Analysis chain

LGTM! But verify the usage of the updated interface.

The addition of marketmapmoduletypes.GenesisState to the GenesisStates interface is appropriate and aligns with the PR objectives.

However, ensure that all implementations and usages of the GenesisStates interface are updated accordingly to handle the new type.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of the updated GenesisStates interface.

# Test: Search for the interface usage. Expect: Implementations and usages should handle the new type.
rg --type go -A 5 $'type GenesisStates interface'

Length of output: 392


Script:

#!/bin/bash
# Description: Verify all implementations and usages of the updated GenesisStates interface.

# Search for all implementations of the GenesisStates interface.
rg --type go 'GenesisStates' -A 10

# Search for all usages of the GenesisStates interface.
rg --type go 'GenesisStates'

Length of output: 2794


Script:

#!/bin/bash
# Description: Verify handling of the new type in UpdateGenesisDocWithAppStateForModule function and other relevant places.

# Search for the UpdateGenesisDocWithAppStateForModule function implementation.
rg --type go 'func UpdateGenesisDocWithAppStateForModule' -A 20

# Search for any other functions that use GenesisStates.
rg --type go 'GenesisStates' -A 5

Length of output: 2823

protocol/x/perpetuals/keeper/perpetual_test.go (3)

427-433: Use consistent indentation and spacing.

Ensure consistent indentation and spacing for better readability and maintainability.

-  _, err := keepertest.CreateTestMarket(
-    t,
-    pc.Ctx,
-    pc.PricesKeeper,
-    pricestypes.MarketParam{
-      Id:                 0,
-      Pair:               "base-quote",
-      Exponent:           -10,
-      MinExchanges:       uint32(1),
-      MinPriceChangePpm:  uint32(50),
-      ExchangeConfigJson: "{}",
-    },
-    pricestypes.MarketPrice{
-      Id:       0,
-      Exponent: -10,
-      Price:    1_000, // leave this as a placeholder b/c we cannot set the price to 0
-    },
+	_, err := keepertest.CreateTestMarket(
+		t,
+		pc.Ctx,
+		pc.PricesKeeper,
+		pricestypes.MarketParam{
+			Id:                 0,
+			Pair:               "base-quote",
+			Exponent:           -10,
+			MinExchanges:       uint32(1),
+			MinPriceChangePpm:  uint32(50),
+			ExchangeConfigJson: "{}",
+		},
+		pricestypes.MarketPrice{
+			Id:       0,
+			Exponent: -10,
+			Price:    1_000, // leave this as a placeholder b/c we cannot set the price to 0
+		},
	)

507-515: Use consistent indentation and spacing.

Ensure consistent indentation and spacing for better readability and maintainability.

-  _, err := keepertest.CreateTestMarket(
-    t,
-    pc.Ctx,
-    pc.PricesKeeper,
-    pricestypes.MarketParam{
-      Id:                 0,
-      Pair:               "base-quote",
-      Exponent:           -10,
-      MinExchanges:       uint32(1),
-      MinPriceChangePpm:  uint32(50),
-      ExchangeConfigJson: "{}",
-    },
-    pricestypes.MarketPrice{
-      Id:       0,
-      Exponent: -10,
-      Price:    1_000, // leave this as a placeholder b/c we cannot set the price to 0
-    },
+	_, err := keepertest.CreateTestMarket(
+		t,
+		pc.Ctx,
+		pc.PricesKeeper,
+		pricestypes.MarketParam{
+			Id:                 0,
+			Pair:               "base-quote",
+			Exponent:           -10,
+			MinExchanges:       uint32(1),
+			MinPriceChangePpm:  uint32(50),
+			ExchangeConfigJson: "{}",
+		},
+		pricestypes.MarketPrice{
+			Id:       0,
+			Exponent: -10,
+			Price:    1_000, // leave this as a placeholder b/c we cannot set the price to 0
+		},
	)

1072-1080: Use consistent indentation and spacing.

Ensure consistent indentation and spacing for better readability and maintainability.

-  _, err := keepertest.CreateTestMarket(
-    t,
-    pc.Ctx,
-    pc.PricesKeeper,
-    pricestypes.MarketParam{
-      Id:                 marketId,
-      Pair:               "base-quote",
-      Exponent:           tc.exponent,
-      MinExchanges:       uint32(1),
-      MinPriceChangePpm:  uint32(50),
-      ExchangeConfigJson: "{}",
-    },
-    pricestypes.MarketPrice{
-      Id:       marketId,
-      Exponent: tc.exponent,
-      Price:    tc.price,
-    },
+	_, err := keepertest.CreateTestMarket(
+		t,
+		pc.Ctx,
+		pc.PricesKeeper,
+		pricestypes.MarketParam{
+			Id:                 marketId,
+			Pair:               "base-quote",
+			Exponent:           tc.exponent,
+			MinExchanges:       uint32(1),
+			MinPriceChangePpm:  uint32(50),
+			ExchangeConfigJson: "{}",
+		},
+		pricestypes.MarketPrice{
+			Id:       marketId,
+			Exponent: tc.exponent,
+			Price:    tc.price,
+		},
	)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0076245 and 8e28bea.

Files selected for processing (53)
  • protocol/app/app.go (5 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/testing/e2e/gov/add_new_market_test.go (6 hunks)
  • protocol/testing/e2e/gov/perpetuals_test.go (2 hunks)
  • protocol/testing/e2e/gov/prices_test.go (2 hunks)
  • protocol/testutil/app/app.go (1 hunks)
  • protocol/testutil/constants/marketmap.go (1 hunks)
  • protocol/testutil/keeper/assets.go (1 hunks)
  • protocol/testutil/keeper/clob.go (3 hunks)
  • protocol/testutil/keeper/marketmap.go (1 hunks)
  • protocol/testutil/keeper/perpetuals.go (4 hunks)
  • protocol/testutil/keeper/prices.go (8 hunks)
  • protocol/testutil/keeper/rewards.go (1 hunks)
  • protocol/testutil/keeper/sending.go (1 hunks)
  • protocol/testutil/keeper/subaccounts.go (1 hunks)
  • protocol/testutil/prices/market_param_price.go (1 hunks)
  • protocol/x/clob/genesis_test.go (1 hunks)
  • protocol/x/clob/keeper/clob_pair_test.go (7 hunks)
  • protocol/x/clob/keeper/get_price_premium_test.go (1 hunks)
  • protocol/x/clob/keeper/grpc_query_mev_node_to_node_test.go (1 hunks)
  • protocol/x/clob/keeper/liquidations_test.go (1 hunks)
  • protocol/x/clob/keeper/msg_server_update_clob_pair_test.go (2 hunks)
  • protocol/x/clob/keeper/msg_server_update_liquidations_config_test.go (2 hunks)
  • protocol/x/clob/keeper/orders_test.go (8 hunks)
  • protocol/x/clob/module_test.go (8 hunks)
  • protocol/x/perpetuals/genesis_test.go (2 hunks)
  • protocol/x/perpetuals/keeper/perpetual_test.go (9 hunks)
  • protocol/x/perpetuals/lib/lib_test.go (12 hunks)
  • protocol/x/perpetuals/module_test.go (2 hunks)
  • protocol/x/prices/genesis_test.go (4 hunks)
  • protocol/x/prices/keeper/grpc_query_market_test.go (4 hunks)
  • protocol/x/prices/keeper/keeper.go (3 hunks)
  • protocol/x/prices/keeper/keeper_test.go (1 hunks)
  • protocol/x/prices/keeper/market.go (3 hunks)
  • protocol/x/prices/keeper/market_param_test.go (8 hunks)
  • protocol/x/prices/keeper/market_price_test.go (5 hunks)
  • protocol/x/prices/keeper/market_test.go (6 hunks)
  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go (4 hunks)
  • protocol/x/prices/keeper/msg_server_update_market_param_test.go (1 hunks)
  • protocol/x/prices/keeper/msg_server_update_market_prices_test.go (4 hunks)
  • protocol/x/prices/keeper/slinky_adapter_test.go (4 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 (2 hunks)
  • protocol/x/prices/module_test.go (5 hunks)
  • protocol/x/prices/types/errors.go (1 hunks)
  • protocol/x/prices/types/expected_keepers.go (2 hunks)
  • protocol/x/rewards/keeper/keeper_test.go (2 hunks)
  • protocol/x/subaccounts/keeper/subaccount_test.go (4 hunks)
Files skipped from review due to trivial changes (2)
  • protocol/app/process/full_node_process_proposal_test.go
  • protocol/x/prices/keeper/grpc_query_market_test.go
Additional comments not posted (149)
protocol/x/prices/keeper/keeper_test.go (1)

11-11: LGTM!

The addition of the extra underscore to handle the new return value from PricesKeepers is correct and does not affect the test logic.

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

14-30: LGTM!

The function createMarketMapKeeper correctly initializes and returns a market map keeper along with the store key.

protocol/x/prices/types/expected_keepers.go (1)

33-38: LGTM!

The MarketMapKeeper interface is well-defined with methods for interacting with market data, and it aligns with the requirements.

protocol/x/clob/keeper/msg_server_update_liquidations_config_test.go (1)

59-59: LGTM!

The addition of the MarketMapKeeper initialization line is appropriate and ensures that the necessary state is set up before the test runs.

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

55-55: LGTM!

The addition of the MarketMapKeeper field and the update to the NewKeeper function are appropriate and ensure that the Keeper can manage market data effectively.

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

15-15: Verify the necessity of the additional return value.

The additional return value from PricesKeepers is not used in this test function. Ensure it is needed for future modifications or remove it to keep the code clean.


32-32: Verify the necessity of the additional return value.

The additional return value from PricesKeepers is not used in this test function. Ensure it is needed for future modifications or remove it to keep the code clean.


56-56: Verify the necessity of the additional return value.

The additional return value from PricesKeepers is not used in this test function. Ensure it is needed for future modifications or remove it to keep the code clean.


79-79: Verify the necessity of the additional return value.

The additional return value from PricesKeepers is not used in this test function. Ensure it is needed for future modifications or remove it to keep the code clean.

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

70-77: Verify the correctness of the new JSON structure.

The new ExchangeConfigJson structure enhances functionality by including detailed exchange parameters. Ensure the JSON structure is correctly formatted and aligns with the expected schema.

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

61-68: Verify the necessity of the new marketMapKeeper.

The new marketMapKeeper is integrated into the AssetsKeepers function. Ensure it is necessary for the intended functionality and does not introduce errors.

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

101-101: LGTM!

The code changes are approved.

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

61-68: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to SendingKeepersWithSubaccountsKeeper match the new signature.

Verification successful

Verify the function signature of SendingKeepersWithSubaccountsKeeper matches the new usage.

The function SendingKeepersWithSubaccountsKeeper is used in protocol/x/sending/keeper/transfer_test.go and defined in protocol/testutil/keeper/sending.go. Ensure that the function calls and definition match the new signature.

  • protocol/x/sending/keeper/transfer_test.go:

    • Line 1: ks := keepertest.SendingKeepersWithSubaccountsKeeper(t, mockSubaccountsKeeper)
    • Line 2: ks := keepertest.SendingKeepersWithSubaccountsKeeper(t, mockSubaccountsKeeper)
  • protocol/testutil/keeper/sending.go:

    • Line 1: return SendingKeepersWithSubaccountsKeeper(t, nil)
    • Line 2: func SendingKeepersWithSubaccountsKeeper(t testing.TB, saKeeper types.SubaccountsKeeper)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `SendingKeepersWithSubaccountsKeeper` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'SendingKeepersWithSubaccountsKeeper'

Length of output: 1643

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

47-48: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to RewardsKeepers match the new signature.

Verification successful

The function call to RewardsKeepers in protocol/x/rewards/module_test.go matches the new signature.

  • The function definition in protocol/testutil/keeper/rewards.go includes multiple return values, including pricesKeeper.
  • The call in protocol/x/rewards/module_test.go correctly captures these return values.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `RewardsKeepers` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'RewardsKeepers'

Length of output: 726


Script:

#!/bin/bash
# Description: Extract more lines around the call to `keepertest.RewardsKeepers(t)` to verify it matches the new signature.

# Extract 10 lines before and after the call to `keepertest.RewardsKeepers(t)`.
rg --type go -B 10 -A 10 $'keepertest.RewardsKeepers(t)' protocol/x/rewards/module_test.go

Length of output: 91


Script:

#!/bin/bash
# Description: Extract more lines around the term `RewardsKeepers` to verify it matches the new signature.

# Extract 20 lines before and after the term `RewardsKeepers`.
rg --type go -B 20 -A 20 $'RewardsKeepers' protocol/x/rewards/module_test.go

Length of output: 1427


Script:

#!/bin/bash
# Description: Search for the `keepertest.RewardsKeepers` function definition to verify its parameters.

# Search for the function definition of `RewardsKeepers`.
rg --type go -A 10 'func RewardsKeepers' 

Length of output: 766

protocol/x/clob/keeper/grpc_query_mev_node_to_node_test.go (1)

22-23: LGTM! Ensure consistent initialization in other tests.

The initialization of the market map using InitGenesis is a good addition to ensure the market map is in a defined state before executing the test cases.

Verify if other test files also require this initialization step for consistency.

Verification successful

LGTM! Ensure consistent initialization in other tests.

The initialization of the market map using InitGenesis is a good addition to ensure the market map is in a defined state before executing the test cases. This step is consistently applied across various test files in the codebase.

  • The InitGenesis method is used in multiple test files, including those in the clob module.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `InitGenesis` in other test files.

# Test: Search for the usage of `InitGenesis`. Expect: Consistent initialization across test files.
rg --type go 'InitGenesis'

Length of output: 24515

protocol/x/prices/keeper/msg_server_create_oracle_market_test.go (2)

118-126: LGTM! Ensure the validation of market state in other tests.

The validation step that checks if the market is enabled in the MarketMap is a good addition to ensure the market's state is correctly reflected.

Verify if other test files also require this validation step for consistency.

Verification successful

Validation of market state is consistently applied in other test files.

The validation step that checks if the market is enabled in the MarketMap is present in multiple test files, ensuring consistency.

  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go
  • protocol/x/prices/keeper/market_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the validation of market state in other test files.

# Test: Search for the validation of market state. Expect: Consistent validation across test files.
rg --type go 'MarketPairToCurrencyPair'

Length of output: 1995


Script:

#!/bin/bash
# Description: Verify the validation of market state in other test files.

# Test: Search for the validation of market state. Expect: Consistent validation across test files.
rg --type go 'mmMarket.Ticker.Enabled'

Length of output: 314


33-39: LGTM! Ensure consistent market initialization in other tests.

The initialization of the market in the MarketMap using CreateMarketInMarketMapFromParams is a good addition to ensure the market is created before executing the test cases.

Verify if other test files also require this initialization step for consistency.

Verification successful

LGTM! Ensure consistent market initialization in other tests.

The initialization of the market in the MarketMap using CreateMarketInMarketMapFromParams is consistently applied across the test files. This ensures that the market is created before executing the test cases, enhancing the accuracy and robustness of the tests.

  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go
  • protocol/x/prices/keeper/market_test.go
  • protocol/x/prices/module_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `CreateMarketInMarketMapFromParams` in other test files.

# Test: Search for the usage of `CreateMarketInMarketMapFromParams`. Expect: Consistent initialization across test files.
rg --type go 'CreateMarketInMarketMapFromParams'

Length of output: 627


Script:

#!/bin/bash
# Extract relevant portions of market_test.go and module_test.go to verify the initialization step.

# Extract lines around the usage of CreateMarketInMarketMapFromParams in market_test.go
rg --type go --context 10 'CreateMarketInMarketMapFromParams' protocol/x/prices/keeper/market_test.go

# Extract lines around the usage of CreateMarketInMarketMapFromParams in module_test.go
rg --type go --context 10 'CreateMarketInMarketMapFromParams' protocol/x/prices/module_test.go

Length of output: 1510

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

126-126: LGTM! Ensure consistent usage of the updated PricesKeepers function.

The changes to the PricesKeepers function call are approved.

Verify if other test files also use the updated PricesKeepers function for consistency.

Verification successful

LGTM! Ensure consistent usage of the updated PricesKeepers function.

The changes to the PricesKeepers function call are approved. The usage of the updated function is consistent across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the updated `PricesKeepers` function in other test files.

# Test: Search for the usage of `PricesKeepers`. Expect: Consistent usage across test files.
rg --type go 'PricesKeepers'

Length of output: 6539


Script:

#!/bin/bash
# Description: Verify the usage of the updated `PricesKeepers` function in all test files with context.

# Search for the usage of `PricesKeepers` and include surrounding lines for context.
rg --type go 'PricesKeepers' -A 3 -B 3

Length of output: 31767

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

54-54: Initialization of marketMapKeeper looks good.

The marketMapKeeper is initialized correctly following the existing pattern.


61-61: Integration of marketMapKeeper into createPricesKeeper looks good.

The marketMapKeeper is correctly passed as an argument to the createPricesKeeper function.

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

28-28: Addition of extra underscore in TestUpdateMarketPrices looks good.

The change suggests that the keepertest.PricesKeepers(t) function now returns an additional value that is not used in this test function.


63-63: Addition of extra underscore in TestUpdateMarketPrices_NotFound looks good.

The change suggests that the keepertest.PricesKeepers(t) function now returns an additional value that is not used in this test function.


92-92: Addition of extra underscore in TestGetMarketPrice looks good.

The change suggests that the keepertest.PricesKeepers(t) function now returns an additional value that is not used in this test function.


107-107: Addition of extra underscore in TestGetMarketPrice_NotFound looks good.

The change suggests that the keepertest.PricesKeepers(t) function now returns an additional value that is not used in this test function.


113-113: Addition of extra underscore in TestGetAllMarketPrices looks good.

The change suggests that the keepertest.PricesKeepers(t) function now returns an additional value that is not used in this test function.


129-129: Addition of extra underscore in TestGetMarketIdToValidIndexPrice looks good.

The change suggests that the keepertest.PricesKeepers(t) function now returns an additional value that is not used in this test function.

protocol/x/prices/keeper/market.go (3)

51-66: Validation for market existence in market map looks good.

The validation ensures that the market exists in the market map before proceeding with the creation process, maintaining the integrity of the market data.


78-78: Addition of currency pair to currencyPairIDCache looks good.

The currency pair is added to the cache following the existing pattern.


100-110: Enabling the market in the market map looks good.

Enabling the market after creation ensures that the market is active and can be used. The error handling is crucial for logging any issues.

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

68-68: Verify the handling of the additional return value.

The additional return value from keepertest.PricesKeepers(t) is currently unused. Ensure that this value is correctly handled or explicitly ignored if not needed.


123-123: Verify the handling of the additional return value.

The additional return value from keepertest.PricesKeepers(t) is currently unused. Ensure that this value is correctly handled or explicitly ignored if not needed.


165-165: Verify the handling of the additional return value.

The additional return value from keepertest.PricesKeepers(t) is currently unused. Ensure that this value is correctly handled or explicitly ignored if not needed.

protocol/testutil/constants/marketmap.go (4)

1-9: LGTM!

The package declaration and imports are appropriate and necessary for the file's functionality.


11-17: LGTM!

The global variables are correctly defined and initialized.


19-106: LGTM!

The MarketMap_DefaultGenesisState is correctly defined and initialized with various market configurations.


107-107: LGTM!

The file ends correctly with the closing brace of the MarketMap_DefaultGenesisState definition.

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

104-108: LGTM!

The AppModule structure has been correctly updated to include the new marketMapKeeper field.


117-125: LGTM!

The NewAppModule constructor function has been correctly updated to accept the new marketMapKeeper parameter and initialize the corresponding field.

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

147-147: Update variable unpacking to match the new function signature.

The PricesKeepers function now returns an additional value, which is currently unused. Ensure that this change is consistent with the updated function signature.


150-150: Use of dedicated test utility function for market creation.

The use of keepertest.CreateTestMarket improves the clarity and maintainability of the test code by encapsulating the market creation logic.

protocol/x/perpetuals/genesis_test.go (4)

21-21: Initialize marketMapGenesisState for test setup.

The initialization of marketMapGenesisState ensures that the market map's genesis state is properly set up before running the tests, improving the test environment's fidelity.


26-26: Initialize marketMapGenesisState in MarketMapKeeper.

The InitGenesis method of the MarketMapKeeper is now called with marketMapGenesisState, ensuring that the market map's genesis state is properly initialized.


126-126: Initialize marketMapGenesisState for test setup.

The initialization of marketMapGenesisState ensures that the market map's genesis state is properly set up before running the tests, improving the test environment's fidelity.


127-127: Initialize marketMapGenesisState in MarketMapKeeper.

The InitGenesis method of the MarketMapKeeper is now called with marketMapGenesisState, ensuring that the market map's genesis state is properly initialized.

protocol/x/prices/keeper/market_param_test.go (10)

19-19: Update variable unpacking to match the new function signature.

The PricesKeepers function now returns an additional value, which is currently unused. Ensure that this change is consistent with the updated function signature.


50-50: Update variable unpacking to match the new function signature.

The PricesKeepers function now returns an additional value, which is currently unused. Ensure that this change is consistent with the updated function signature.


59-59: Adjust Exponent field to -8.

The Exponent field has been adjusted to -8, which may impact the logic governing market behavior. Ensure that this change is consistent with the intended functionality.


63-63: Use of dedicated test utility function for market creation.

The use of keepertest.CreateTestMarket improves the clarity and maintainability of the test code by encapsulating the market creation logic.


65-65: Adjust Exponent field to -8.

The Exponent field has been adjusted to -8, which may impact the logic governing market behavior. Ensure that this change is consistent with the intended functionality.


183-183: Update variable unpacking to match the new function signature.

The PricesKeepers function now returns an additional value, which is currently unused. Ensure that this change is consistent with the updated function signature.


192-192: Adjust Exponent field dynamically.

The Exponent field is now dynamically calculated based on the targetId, ensuring consistency with the creation of market parameters.


204-204: Update variable unpacking to match the new function signature.

The PricesKeepers function now returns an additional value, which is currently unused. Ensure that this change is consistent with the updated function signature.


219-219: Update variable unpacking to match the new function signature.

The PricesKeepers function now returns an additional value, which is currently unused. Ensure that this change is consistent with the updated function signature.


225-225: Update variable unpacking to match the new function signature.

The PricesKeepers function now returns an additional value, which is currently unused. Ensure that this change is consistent with the updated function signature.

protocol/x/clob/keeper/get_price_premium_test.go (1)

162-162: Initialize MarketMapKeeper before other keepers.

The initialization of MarketMapKeeper with a default genesis state ensures that the market map is correctly set up before running the tests. This change is crucial for the integrity of the test environment.

protocol/testing/e2e/gov/prices_test.go (1)

145-171: Initialize marketmap module with genesis market data.

The initialization of the marketmap module with genesis market data ensures that the market map is correctly set up before running the tests. This change enhances the robustness of the test environment.

protocol/testutil/keeper/perpetuals.go (2)

39-39: Add MarketMapKeeper to PerpKeepersTestContext.

The addition of MarketMapKeeper to the PerpKeepersTestContext structure is necessary for managing market map data in testing scenarios. This change expands the capabilities of the testing context.


Line range hint 70-90: Initialize MarketMapKeeper in PerpetualsKeepersWithClobHelpers.

The initialization of MarketMapKeeper in the PerpetualsKeepersWithClobHelpers function ensures that the market map is correctly set up alongside other necessary keepers. This change is crucial for the integrity of the testing environment.

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

38-40: Verify the correctness of the new exponent values.

The exponent values for market_params and market_prices have been changed from 0 to -1. Ensure this change aligns with the new conventions or requirements in the system's handling of price data.


Line range hint 55-65:
Verify the handling of the additional return value.

The createAppModuleWithKeeper function now accommodates an additional return value from the keeper.PricesKeepers(t) function, which returns an extra nil value. Ensure this additional return value is handled correctly and does not introduce any issues.


255-264: Verify the correctness and completeness of the new block of code.

A new block of code has been added to create a market in the market map using the parameters defined in genState.MarketParams. Ensure this addition is correct and enhances the robustness of the testing framework.

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

42-42: Verify the integration of the new MarketMapKeeper field.

The MarketMapKeeper has been added as a new field in the ClobKeepersTestContext structure. Ensure this new field is integrated correctly and does not introduce any issues.


87-94: Verify the initialization and usage of the new MarketMapKeeper.

The NewClobKeepersTestContextWithUninitializedMemStore function has been modified to include the initialization of MarketMapKeeper. Ensure this new keeper is initialized correctly and used appropriately.

Also applies to: 177-177

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

261-261: Verify the handling of the additional return values.

The TestProcessProposalHandler_Error function now accommodates additional return values from the keepertest.PricesKeepers(t) function. Ensure these additional return values are handled correctly and do not affect the test logic.

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

234-234: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PricesKeepers match the new signature.

protocol/x/perpetuals/module_test.go (1)

Line range hint 252-259:
LGTM!

The changes improve the test infrastructure by leveraging a dedicated test market creation function.

protocol/x/clob/keeper/msg_server_update_clob_pair_test.go (1)

257-258: LGTM!

The changes ensure that the MarketMapKeeper is properly initialized before proceeding with the test logic.

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

64-64: LGTM!

The changes to the PricesKeepers function look good.


106-106: LGTM!

The changes to the createPricesKeeper function look good.


119-119: LGTM!

The changes to the CreateMarketInMarketMapFromParams function look good.


159-159: LGTM!

The changes to the ConstructMarketMapFromParams function look good.


178-183: LGTM!

The changes to the CreateTestMarket function look good.


126-159: Ensure error handling for ConvertMarketParamsToMarketMap.

The call to h.ConvertMarketParamsToMarketMap should include error handling to manage potential failures.

-  mm, err := h.ConvertMarketParamsToMarketMap(mpr)
+  mm, err := h.ConvertMarketParamsToMarketMap(mpr)
+  require.NoError(t, err)

Likely invalid or redundant comment.


59-59: Ensure proper parameter passing.

Verify that the marketMapKeeper parameter is correctly passed to the createPricesKeeper function.

Verification successful

The marketMapKeeper parameter is correctly passed to the createPricesKeeper function.

The createPricesKeeper function definition includes marketMapKeeper as a parameter, and it is passed correctly in the function call within protocol/testutil/keeper/prices.go.

  • Function Definition:

    func createPricesKeeper(
      stateStore storetypes.CommitMultiStore,
      db *dbm.MemDB,
      cdc *codec.ProtoCodec,
      transientStoreKey storetypes.StoreKey,
      revShareKeeper *revsharekeeper.Keeper,
      marketMapKeeper *marketmapkeeper.Keeper,
    ) (
      *keeper.Keeper,
      storetypes.StoreKey,
      *pricefeedserver_types.MarketToExchangePrices,
      *mocks.TimeProvider,
    ) {
  • Function Call:

    createPricesKeeper(stateStore, db, cdc, transientStoreKey, revShareKeeper, marketMapKeeper)

The marketMapKeeper parameter is indeed part of the function signature and is passed correctly in the call.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct passing of `marketMapKeeper` parameter to the `createPricesKeeper` function.

# Test: Search for the `createPricesKeeper` function call within the `PricesKeepers` function. Expect: Proper passing of `marketMapKeeper`.
rg --type go 'createPricesKeeper' -A 5

Length of output: 3219


Script:

#!/bin/bash
# Description: Retrieve the complete definition of the `createPricesKeeper` function to verify its parameters.

# Search for the `createPricesKeeper` function definition in Go files
ast-grep --lang go --pattern 'func createPricesKeeper($$_) {
  $$$
}'

Length of output: 71


Script:

#!/bin/bash
# Description: Retrieve the complete definition of the `createPricesKeeper` function to verify its parameters.

# Search for the `createPricesKeeper` function definition in Go files and include 20 lines of context to capture the parameters
rg --type go 'func createPricesKeeper' -A 20

Length of output: 1393


73-73: Verify the integration of marketMapKeeper.

Ensure that the new marketMapKeeper parameter is correctly integrated and utilized within the createPricesKeeper function.

Verification successful

The marketMapKeeper parameter is correctly integrated within the createPricesKeeper function.

The parameter is properly utilized and passed to the keeper.NewKeeper function, ensuring its correct initialization and usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct integration of `marketMapKeeper` parameter within the `createPricesKeeper` function.

# Test: Search for the usage of `marketMapKeeper` within the `createPricesKeeper` function. Expect: Proper usage and initialization.
rg --type go 'createPricesKeeper' -A 20

Length of output: 10039


Script:

#!/bin/bash
# Description: Extract the full implementation of the `createPricesKeeper` function to verify the integration of `marketMapKeeper`.

# Test: Use `ast-grep` to retrieve the complete implementation of the `createPricesKeeper` function.
ast-grep --lang go --pattern 'func createPricesKeeper($_, $_, $_, $_, $_, $_) { $$$ }' protocol/testutil/keeper/prices.go

Length of output: 123


Script:

#!/bin/bash
# Description: Extract the full implementation of the `createPricesKeeper` function to verify the integration of `marketMapKeeper`.

# Test: Use `rg` to search for the `createPricesKeeper` function definition and include 50 lines of context to capture the complete implementation.
rg 'func createPricesKeeper' -A 50 protocol/testutil/keeper/prices.go

Length of output: 1542


44-44: Verify the integration of marketMapKeeper.

Ensure that the new marketMapKeeper parameter is correctly integrated and utilized within the PricesKeepers function.

Verification successful

Verify the integration of marketMapKeeper.

Ensure that the new marketMapKeeper parameter is correctly integrated and utilized within the PricesKeepers function.


Verify the integration of marketMapKeeper.

Ensure that the new marketMapKeeper parameter is correctly integrated and utilized within the PricesKeepers function.


Verified the integration of marketMapKeeper.

The marketMapKeeper parameter is correctly integrated and utilized within the PricesKeepers function.

  • marketMapKeeper is initialized using createMarketMapKeeper.
  • It is passed to createPricesKeeper.
  • It is returned from the PricesKeepers function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct integration of `marketMapKeeper` parameter within the `PricesKeepers` function.

# Test: Search for the usage of `marketMapKeeper` within the `PricesKeepers` function. Expect: Proper usage and initialization.
rg --type go 'PricesKeepers' -A 20

Length of output: 80522


Script:

#!/bin/bash
# Description: Verify the complete implementation of `PricesKeepers` function and the usage of `marketMapKeeper`.

# Test: Retrieve the complete implementation of `PricesKeepers` function to verify initialization and usage of `marketMapKeeper`.
ast-grep --lang go --pattern 'func PricesKeepers($_) { $$$ }'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify the complete implementation of `PricesKeepers` function and the usage of `marketMapKeeper`.

# Test: Retrieve the complete implementation of `PricesKeepers` function to verify initialization and usage of `marketMapKeeper`.
rg 'func PricesKeepers' -A 50

Length of output: 3459

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

111-111: LGTM!

The changes to the TestDecodeProcessProposalTxs_Error function look good.


191-191: LGTM!

The changes to the TestDecodeProcessProposalTxs_Valid function look good.


321-321: LGTM!

The changes to the TestProcessProposalTxs_Validate_Error function look good.


428-428: LGTM!

The changes to the TestProcessProposalTxs_Validate_Valid function look good.


321-321: Ensure correct unpacking of additional variable.

Verify that the additional variable unpacked from the keepertest.PricesKeepers function call is correctly handled.


428-428: Ensure correct unpacking of additional variable.

Verify that the additional variable unpacked from the keepertest.PricesKeepers function call is correctly handled.

Verification successful

Ensure correct unpacking of additional variable.

The PricesKeepers function call within the TestProcessProposalTxs_Validate_Valid function correctly unpacks the additional variable indexPriceCache. This confirms that the additional variable is handled appropriately.

  • protocol/app/process/transactions_test.go:
    • Line 428: ctx, pricesKeeper, _, indexPriceCache, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestProcessProposalTxs_Validate_Valid` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestProcessProposalTxs_Validate_Valid' -A 20

Length of output: 1726


Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestProcessProposalTxs_Validate_Valid` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestProcessProposalTxs_Validate_Valid' -A 50

Length of output: 3619


Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call directly and include sufficient context lines to determine if it is within the `TestProcessProposalTxs_Validate_Valid` function.
rg --type go 'PricesKeepers' -A 10 -B 10

Length of output: 83826


Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `TestProcessProposalTxs_Validate_Valid` function and include more context lines to capture the `PricesKeepers` function call within it.
rg --type go 'func TestProcessProposalTxs_Validate_Valid' -A 100

Length of output: 7406

protocol/x/prices/keeper/validate_market_price_updates_test.go (5)

125-125: LGTM!

The changes to the TestPerformStatefulPriceUpdateValidation_Valid function look good.


210-210: LGTM!

The changes to the TestPerformStatefulPriceUpdateValidation_SkipNonDeterministicCheck_Valid function look good.


210-210: Ensure correct unpacking of additional variable.

Verify that the additional variable unpacked from the keepertest.PricesKeepers function call is correctly handled.

Verification successful

Ensure correct unpacking of additional variable.

The additional variable indexPriceCache unpacked from the keepertest.PricesKeepers function call is correctly handled in the TestPerformStatefulPriceUpdateValidation_SkipNonDeterministicCheck_Valid function.

  • The variable indexPriceCache is used to update prices within the function, confirming its correct handling.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestPerformStatefulPriceUpdateValidation_SkipNonDeterministicCheck_Valid` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestPerformStatefulPriceUpdateValidation_SkipNonDeterministicCheck_Valid' -A 20

Length of output: 2287


Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Search for the `keepertest.PricesKeepers` function call within the `validate_market_price_updates_test.go` file and include more context lines.
rg --type go 'keepertest.PricesKeepers' -A 30

Length of output: 101224


125-125: Ensure correct unpacking of additional variable.

Verify that the additional variable unpacked from the keepertest.PricesKeepers function call is correctly handled.

Verification successful

Ensure correct unpacking of additional variable.

The additional variable mockTimeProvider unpacked from the keepertest.PricesKeepers function call is correctly handled in the test cases.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestPerformStatefulPriceUpdateValidation_Valid` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestPerformStatefulPriceUpdateValidation_Valid' -A 20

Length of output: 2249


Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Search for the `keepertest.PricesKeepers` function call in the entire file to capture the relevant context.
rg --type go 'keepertest.PricesKeepers' protocol/x/prices/keeper/validate_market_price_updates_test.go -A 10

Length of output: 1778


Script:

#!/bin/bash
# Description: Verify the definition of `keepertest.PricesKeepers` to confirm the expected return values and their correct handling.

# Search for the definition of `PricesKeepers` in the keepertest package.
rg --type go 'func PricesKeepers' --files-with-matches | xargs rg 'func PricesKeepers' -A 10

Length of output: 436


343-343: Ensure correct unpacking of additional variable.

Verify that the additional variable unpacked from the keepertest.PricesKeepers function call is correctly handled.

Ensure correct unpacking of additional variable.

The additional variable mockTimeProvider is correctly unpacked from the keepertest.PricesKeepers function call and is used appropriately in the test setup.

  • The variable mockTimeProvider is used to mock the current time with mockTimeProvider.On("Now").Return(constants.TimeT).
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct unpacking of the additional variable from the `keepertest.PricesKeepers` function call.

# Test: Search for the `PricesKeepers` function call within the `TestPerformStatefulPriceUpdateValidation_Error` function. Expect: Proper unpacking of the additional variable.
rg --type go 'TestPerformStatefulPriceUpdateValidation_Error' -A 20

Length of output: 2163


Script:

#!/bin/bash
# Description: Search for the `PricesKeepers` function call within the `validate_market_price_updates_test.go` file to verify the correct unpacking of the additional variable.

# Locate the `PricesKeepers` function call and capture surrounding lines for context.
rg --type go 'PricesKeepers' -A 10 validate_market_price_updates_test.go

Length of output: 150


Script:

#!/bin/bash
# Description: Locate the correct file path for the test file containing the `TestPerformStatefulPriceUpdateValidation_Error` function.

# Search for the file containing the `TestPerformStatefulPriceUpdateValidation_Error` function.
rg --files-with-matches 'TestPerformStatefulPriceUpdateValidation_Error'

Length of output: 135


Script:

#!/bin/bash
# Description: Search for the `PricesKeepers` function call within the `protocol/x/prices/keeper/validate_market_price_updates_test.go` file to verify the correct unpacking of the additional variable.

# Locate the `PricesKeepers` function call and capture surrounding lines for context.
rg --type go 'PricesKeepers' -A 10 protocol/x/prices/keeper/validate_market_price_updates_test.go

Length of output: 1767

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

189-189: Verify the impact of the additional return value.

The additional return value from keepertest.PricesKeepers(t) should be verified to ensure it does not affect the test logic.

Verification successful

Verify the usage of PricesKeepers in the test file.

The PricesKeepers function does not have an additional return value. Ensure that the current return values are correctly used in the test file.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the additional return value from `keepertest.PricesKeepers(t)`.

# Test: Search for the function definition. Expect: The function should return the additional value.
rg --type go 'func PricesKeepers' -A 5

Length of output: 461


402-402: Verify the impact of the additional return value.

The additional return value from keepertest.PricesKeepers(t) should be verified to ensure it does not affect the test logic.


379-379: Verify the impact of the additional return value.

The additional return value from keepertest.PricesKeepers(t) should be verified to ensure it does not affect the test logic.

Verification successful

The additional return value from keepertest.PricesKeepers(t) does not negatively impact the test logic.

The usage of mockTimeProvider in the test file is appropriate and ensures the tests are deterministic by mocking the current time.

  • protocol/x/prices/keeper/msg_server_update_market_prices_test.go:
    • The additional return value mockTimeProvider is used to mock the current time, which is a standard practice in testing.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the additional return value from `keepertest.PricesKeepers(t)`.

# Test: Search for the function definition. Expect: The function should return the additional value.
rg --type go 'func PricesKeepers' -A 5

Length of output: 461


Script:

#!/bin/bash
# Description: Verify the usage of the additional return value `mockTimeProvider` in the test file.

# Test: Search for the usage of `mockTimeProvider` in the `msg_server_update_market_prices_test.go` file.
rg 'mockTimeProvider' protocol/x/prices/keeper/msg_server_update_market_prices_test.go -A 5

Length of output: 644


315-315: Verify the impact of the additional return value.

The additional return value from keepertest.PricesKeepers(t) should be verified to ensure it does not affect the test logic.

Verification successful

The additional return values from keepertest.PricesKeepers(t) do not affect the test logic as they are not used in the test function.

  • The additional return values revShareKeeper and marketMapKeeper are not utilized in the test file msg_server_update_market_prices_test.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the additional return value from `keepertest.PricesKeepers(t)`.

# Test: Search for the function definition. Expect: The function should return the additional value.
rg --type go 'func PricesKeepers' -A 5

Length of output: 461


Script:

#!/bin/bash
# Description: Retrieve the complete function signature of `PricesKeepers` from `protocol/testutil/keeper/prices.go`.

# Display the complete function signature for PricesKeepers
rg --type go 'func PricesKeepers' -A 10 protocol/testutil/keeper/prices.go

Length of output: 418


Script:

#!/bin/bash
# Description: Search for the usage of `revShareKeeper` and `marketMapKeeper` in `msg_server_update_market_prices_test.go`.

# Search for `revShareKeeper` usage
rg 'revShareKeeper' protocol/x/prices/keeper/msg_server_update_market_prices_test.go

# Search for `marketMapKeeper` usage
rg 'marketMapKeeper' protocol/x/prices/keeper/msg_server_update_market_prices_test.go

Length of output: 170

protocol/testing/e2e/gov/add_new_market_test.go (5)

8-9: LGTM! New imports are correctly integrated.

The new imports from the slinky and marketmaptypes packages are necessary for the added functionality.


357-359: LGTM! Ensure the function works as expected.

The changes to check the state of the market after a failed proposal are correctly integrated.

Verify the function works as expected.

Verification successful

LGTM! Ensure the function works as expected.

The changes to check the state of the market after a failed proposal are correctly integrated. The TestAddNewMarketProposal function comprehensively covers various scenarios, including the verification that the market remains disabled if the proposal fails.

  • protocol/testing/e2e/gov/add_new_market_test.go lines 357-359
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the function `TestAddNewMarketProposal` works as expected.

# Test: Run the test function. Expect: The test should pass.
go test -run TestAddNewMarketProposal

Length of output: 109


Script:

#!/bin/bash
# Search for the implementation of the `TestAddNewMarketProposal` function in the codebase.
ast-grep --lang go --pattern 'func TestAddNewMarketProposal($_) { $$$ }'

Length of output: 34834


321-324: LGTM! Ensure the function works as expected.

The changes to check the state of the market after initialization are correctly integrated.

Verify the function works as expected.

Verification successful

LGTM! Ensure the function works as expected.

The function TestAddNewMarketProposal is well-implemented and covers various scenarios to validate the behavior of adding a new market proposal. The changes to check the state of the market after initialization are correctly integrated.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the function `TestAddNewMarketProposal` works as expected.

# Test: Run the test function. Expect: The test should pass.
go test -run TestAddNewMarketProposal

Length of output: 109


Script:

#!/bin/bash
# Locate the implementation of the `TestAddNewMarketProposal` function.
ast-grep --lang go --pattern 'func TestAddNewMarketProposal($_) $_' 

Length of output: 34829


400-402: LGTM! Ensure the function works as expected.

The changes to check the state of the market after a successful proposal are correctly integrated.

Verify the function works as expected.

Verification successful

LGTM! Ensure the function works as expected.

The changes to check the state of the market after a successful proposal are correctly integrated. The TestAddNewMarketProposal function is comprehensive and covers multiple scenarios, ensuring the proposal mechanism works as expected.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the function `TestAddNewMarketProposal` works as expected.

# Test: Run the test function. Expect: The test should pass.
go test -run TestAddNewMarketProposal

Length of output: 109


Script:

#!/bin/bash
# Search for the implementation of the `TestAddNewMarketProposal` function in the codebase.
ast-grep --lang go --pattern 'func TestAddNewMarketProposal($_) $_' 

Length of output: 34829


305-315: LGTM! Ensure the function works as expected.

The changes to include additional checks and updates related to market parameters and their state are correctly integrated.

Verify the function works as expected.

protocol/x/clob/genesis_test.go (1)

429-429: LGTM! Ensure the function works as expected.

The new initialization step for MarketMapKeeper is correctly integrated.

Verify the function works as expected.

Verification successful

LGTM! Ensure the function works as expected.

The new initialization step for MarketMapKeeper is correctly integrated.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the function `TestGenesis` works as expected.

# Test: Run the test function. Expect: The test should pass.
go test -run TestGenesis

Length of output: 96


Script:

#!/bin/bash
# Search for the TestGenesis function implementation in the codebase and display its context
rg -A 20 'func TestGenesis' --glob '*.go'

Length of output: 31001

protocol/x/clob/module_test.go (4)

36-36: Import statement approved.

The import statement for marketmap_keeper is correctly added.


63-64: Function changes approved.

The function createAppModule correctly calls createAppModuleWithKeeper and returns the AppModule.


Line range hint 75-104: Function changes approved.

The function createAppModuleWithKeeper correctly initializes and returns the new keeper *marketmap_keeper.Keeper along with other keepers and context.


Line range hint 289-317: Function changes approved.

The function TestAppModule_InitExportGenesis correctly initializes the genesis state for the new keeper marketMapKeeper and integrates it with the existing logic.

protocol/testing/e2e/gov/perpetuals_test.go (2)

18-19: Import statements approved.

The import statements for slinkytypes and marketmaptypes are correctly added.


279-306: Function changes approved.

The function TestUpdatePerpetualsParams correctly initializes the marketmap module with genesis markets and integrates it with the existing logic.

protocol/x/rewards/keeper/keeper_test.go (2)

15-15: Import statement approved.

The import statement for keepertest is correctly added.


696-699: Function changes approved.

The function TestProcessRewardsForBlock correctly uses the CreateTestMarket function from keepertest to set up the test market.

protocol/x/perpetuals/lib/lib_test.go (13)

425-426: Verify the updated price and exponent values.

The price value has been increased from 5_555 to 55_550, and the exponent has been changed from a non-negative integer to -1. Ensure these changes align with the expected business logic.


445-446: Verify the updated price and exponent values.

The price value has been updated to 55_550, and the exponent has been changed to -1. Ensure these changes are consistent with the expected calculations.


455-456: Verify the updated price and exponent values.

The price value has been updated to 55_550, and the exponent has been changed to -1. Ensure these changes align with the expected business logic.


465-466: Verify the updated price and exponent values.

The price value has been updated to 55_550, and the exponent has been changed to -1. Ensure these changes are consistent with the expected calculations.


476-476: Verify the updated exponent value.

The exponent has been changed to -1. Ensure this change aligns with the expected business logic.


486-486: Verify the updated exponent value.

The exponent has been changed to -1. Ensure this change is consistent with the expected calculations.


499-500: Verify the updated price and exponent values.

The price value has been updated to 55_550, and the exponent has been changed to -1. Ensure these changes align with the expected business logic.


511-512: Verify the updated price and exponent values.

The price value has been updated to 367_500, and the exponent has been changed to -1. Ensure these changes are consistent with the expected calculations.


524-525: Verify the updated price and exponent values.

The price value has been updated to 1_234_560, and the exponent has been changed to -1. Ensure these changes align with the expected business logic.


537-538: Verify the updated price and exponent values.

The price value has been updated to 1_234_560, and the exponent has been changed to -1. Ensure these changes are consistent with the expected calculations.


548-549: Verify the updated price and exponent values.

The price value has been updated to 367_500, and the exponent has been changed to -1. Ensure these changes align with the expected business logic.


565-566: Verify the updated price and exponent values.

The price value has been updated to 367_500, and the exponent has been changed to -1. Ensure these changes are consistent with the expected calculations.


581-582: Verify the updated price and exponent values.

The price value has been updated to 367_500, and the exponent has been changed to -1. Ensure these changes align with the expected business logic.

protocol/app/prepare/prepare_proposal_test.go (2)

364-364: Verify the updated context variable unpacking.

The context variable unpacking from the keepertest.PricesKeepers(t) function has been expanded to include an additional variable. Ensure this change aligns with the updated return signature of the PricesKeepers function.


443-443: Verify the updated context variable unpacking.

The context variable unpacking from the keepertest.PricesKeepers(t) function has been expanded to include an additional variable. Ensure this change aligns with the updated return signature of the PricesKeepers function.

protocol/x/clob/keeper/clob_pair_test.go (7)

44-44: Initialization of MarketMapKeeper's genesis state looks good.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the MarketMapKeeper is properly initialized before the test execution.


159-159: Initialization of MarketMapKeeper's genesis state looks good.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the MarketMapKeeper is properly initialized before the test execution.


262-262: Initialization of MarketMapKeeper's genesis state looks good.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the MarketMapKeeper is properly initialized before the test execution.


415-415: Initialization of MarketMapKeeper's genesis state looks good.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the MarketMapKeeper is properly initialized before the test execution.


613-613: Initialization of MarketMapKeeper's genesis state looks good.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the MarketMapKeeper is properly initialized before the test execution.


874-874: Initialization of MarketMapKeeper's genesis state looks good.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the MarketMapKeeper is properly initialized before the test execution.


1055-1055: Initialization of MarketMapKeeper's genesis state looks good.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the MarketMapKeeper is properly initialized before the test execution.

protocol/app/app.go (4)

927-927: Ensure MarketMapKeeper is correctly initialized.

The addition of &app.MarketMapKeeper to app.PricesKeeper should be verified to ensure that MarketMapKeeper is correctly initialized before usage.

Verification successful

Ensure MarketMapKeeper is correctly initialized.

The addition of &app.MarketMapKeeper to app.PricesKeeper should be verified to ensure that MarketMapKeeper is correctly initialized before usage. The initialization of MarketMapKeeper is confirmed in protocol/app/app.go.

  • protocol/app/app.go: MarketMapKeeper is initialized correctly before being used.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that MarketMapKeeper is initialized before usage in PricesKeeper.

# Test: Search for the initialization of MarketMapKeeper. Expect: Initialization before usage.
rg --type go 'MarketMapKeeper'

Length of output: 6484


935-935: Ensure MarketMapKeeper is correctly initialized.

The addition of &app.MarketMapKeeper to pricesModule should be verified to ensure that MarketMapKeeper is correctly initialized before usage.


1351-1351: Ensure MarketMapKeeper is correctly initialized before pricesModule.

The addition of marketmapmoduletypes.ModuleName before pricesmoduletypes.ModuleName in SetOrderInitGenesis should be verified to ensure that MarketMapKeeper is correctly initialized before pricesModule.

Verification successful

Verified: MarketMapKeeper is correctly initialized before pricesModule in SetOrderInitGenesis.

The order of initialization in SetOrderInitGenesis correctly places marketmapmoduletypes.ModuleName before pricesmoduletypes.ModuleName.

  • protocol/app/app.go, lines 1351-1351
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that MarketMapKeeper is initialized before pricesModule in SetOrderInitGenesis.

# Test: Search for the initialization order in SetOrderInitGenesis. Expect: MarketMapKeeper before pricesModule.
rg --type go 'SetOrderInitGenesis'

Length of output: 94


Script:

#!/bin/bash
# Description: Extract the arguments of SetOrderInitGenesis in protocol/app/app.go to verify the initialization order.

# Extract lines where SetOrderInitGenesis is called and the subsequent lines to capture the arguments.
rg --type go -A 10 'SetOrderInitGenesis' protocol/app/app.go

Length of output: 365


Script:

#!/bin/bash
# Description: Extract more lines following the SetOrderInitGenesis call in protocol/app/app.go to capture the complete list of arguments.

# Extract lines where SetOrderInitGenesis is called and the subsequent 50 lines to capture the full list of arguments.
rg --type go -A 50 'SetOrderInitGenesis' protocol/app/app.go

Length of output: 1655


1394-1394: Ensure MarketMapKeeper is correctly initialized before pricesModule.

The addition of marketmapmoduletypes.ModuleName before pricesmoduletypes.ModuleName in SetOrderMigrations should be verified to ensure that MarketMapKeeper is correctly initialized before pricesModule.

Verification successful

Initialization order is correct.

The MarketMapKeeper is correctly initialized before pricesModule in the SetOrderMigrations call.

  • marketmapmoduletypes.ModuleName is listed before pricesmoduletypes.ModuleName.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that MarketMapKeeper is initialized before pricesModule in SetOrderMigrations.

# Test: Search for the initialization order in SetOrderMigrations. Expect: MarketMapKeeper before pricesModule.
rg --type go 'SetOrderMigrations'

Length of output: 92


Script:

#!/bin/bash
# Description: Find and inspect the definition of SetOrderMigrations to verify the initialization order.

# Locate the definition of SetOrderMigrations
rg --type go 'func SetOrderMigrations' -A 10

Length of output: 46


Script:

#!/bin/bash
# Description: Search for SetOrderMigrations method calls and include more surrounding lines to capture its definition and usage context.

# Locate the SetOrderMigrations method calls and include surrounding lines for context
rg --type go 'SetOrderMigrations' -A 20 -B 10

Length of output: 1624

protocol/x/clob/keeper/orders_test.go (8)

939-939: LGTM! The MarketMapKeeper initialization ensures consistent state.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the market map is properly initialized before the test runs.


998-998: LGTM! The MarketMapKeeper initialization ensures consistent state.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the market map is properly initialized before the test runs.


1754-1754: LGTM! The MarketMapKeeper initialization ensures consistent state.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the market map is properly initialized before the test runs.


1807-1807: LGTM! The MarketMapKeeper initialization ensures consistent state.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the market map is properly initialized before the test runs.


1974-1974: LGTM! The MarketMapKeeper initialization ensures consistent state.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the market map is properly initialized before the test runs.


2108-2108: LGTM! The MarketMapKeeper initialization ensures consistent state.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the market map is properly initialized before the test runs.


2278-2278: LGTM! The MarketMapKeeper initialization ensures consistent state.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the market map is properly initialized before the test runs.


2408-2408: LGTM! The MarketMapKeeper initialization ensures consistent state.

The addition of ks.MarketMapKeeper.InitGenesis(ks.Ctx, constants.MarketMap_DefaultGenesisState) ensures that the market map is properly initialized before the test runs.

protocol/x/perpetuals/keeper/perpetual_test.go (3)

902-927: Ensure proper test coverage for negative exponents and atomic resolutions.

The test cases for TestGetNotionalInBaseQuantums_Success now include negative exponents and atomic resolutions. Make sure these scenarios are well-documented and covered in other related tests.

Verification successful

Test coverage for negative exponents and atomic resolutions is comprehensive.

The test cases for negative exponents and atomic resolutions are well-documented and covered across multiple related test files:

  • protocol/x/perpetuals/lib/lib_test.go
  • protocol/x/perpetuals/keeper/perpetual_test.go
  • protocol/lib/prices/utils_test.go
  • protocol/daemons/pricefeed/client/price_function/util_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that negative exponents and atomic resolutions are covered in related tests.

# Test: Search for test cases with negative exponents and atomic resolutions. Expect: Multiple occurrences.
rg --type go -A 5 'exponent:\s*-'

Length of output: 23172


Line range hint 758-784:
Ensure proper test coverage for negative exponents and atomic resolutions.

The test cases for TestGetNetNotional_Success now include negative exponents and atomic resolutions. Make sure these scenarios are well-documented and covered in other related tests.

Verification successful

Negative exponents and atomic resolutions are properly covered in related tests.

The test cases for TestGetNetNotional_Success and other related tests include scenarios with negative exponents and atomic resolutions across multiple files:

  • protocol/x/perpetuals/lib/lib_test.go
  • protocol/x/perpetuals/keeper/perpetual_test.go
  • protocol/lib/prices/utils_test.go
  • protocol/daemons/pricefeed/client/price_function/util_test.go

These scenarios are well-documented and tested throughout the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that negative exponents and atomic resolutions are covered in related tests.

# Test: Search for test cases with negative exponents and atomic resolutions. Expect: Multiple occurrences.
rg --type go -A 5 'exponent:\s*-'

Length of output: 23172


1054-1058: Ensure proper test coverage for maximum uint values.

The test case for TestGetNetCollateral_Success includes maximum uint values. Ensure similar edge cases are covered in other related tests.

Verification successful

Test coverage for maximum uint values is already ensured.

The test cases across multiple files already include maximum uint values (math.MaxUint64), ensuring that such edge cases are covered.

  • protocol/x/subaccounts/keeper/transfer_test.go
  • protocol/x/subaccounts/keeper/subaccount_test.go
  • protocol/x/vault/types/msg_deposit_to_vault_test.go
  • protocol/x/clob/memclob/memclob_cancel_order_test.go
  • protocol/x/clob/keeper/liquidations_test.go
  • protocol/lib/math_test.go
  • protocol/app/ante/types/free_gas_meter_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that maximum uint values are covered in related tests.

# Test: Search for test cases with maximum uint values. Expect: Multiple occurrences.
rg --type go -A 5 'math.MaxUint64'

Length of output: 64436

protocol/x/clob/keeper/liquidations_test.go (1)

2270-2270: LGTM! Ensure the initialization of the genesis state for MarketMapKeeper.

The code changes are approved. Initializing the genesis state for MarketMapKeeper is crucial for ensuring the MarketMapKeeper is in a defined state before the test logic proceeds.

However, ensure that the initialization of the genesis state for MarketMapKeeper is correctly implemented in other relevant tests if necessary.

Verification successful

Initialization of MarketMapKeeper Genesis State Verified

The initialization of the genesis state for MarketMapKeeper is consistently implemented across various test files. This ensures that the MarketMapKeeper is in a defined state before the test logic proceeds, enhancing test reliability.

  • protocol/x/perpetuals/genesis_test.go
  • protocol/x/clob/genesis_test.go
  • protocol/x/clob/keeper/msg_server_update_clob_pair_test.go
  • protocol/x/clob/keeper/msg_server_update_liquidations_config_test.go
  • protocol/x/clob/keeper/get_price_premium_test.go
  • protocol/x/clob/keeper/orders_test.go
  • protocol/x/clob/keeper/liquidations_test.go
  • protocol/x/clob/keeper/grpc_query_mev_node_to_node_test.go
  • protocol/x/clob/keeper/clob_pair_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization of the genesis state for `MarketMapKeeper` in other relevant tests.

# Test: Search for the initialization of `MarketMapKeeper`. Expect: Consistent initialization across tests.
rg --type go --pattern 'MarketMapKeeper.InitGenesis'

Length of output: 464


Script:

#!/bin/bash
# Description: Verify the initialization of the genesis state for `MarketMapKeeper` in other relevant tests.

# Test: Search for the initialization of `MarketMapKeeper`. Expect: Consistent initialization across tests.
rg 'MarketMapKeeper.InitGenesis' --type go

Length of output: 2874

protocol/x/subaccounts/keeper/subaccount_test.go (6)

2134-2134: Update the market pair format in GenerateMarketParamPrice.

The WithPair argument has been updated to "0-0", which likely reflects a new expected format for market pairs.


2138-2138: Update the market pair format in GenerateMarketParamPrice.

The WithPair argument has been updated to "1-1", which likely reflects a new expected format for market pairs.


2926-2929: Replace pricesKeeper.CreateMarket with keepertest.CreateTestMarket.

The new function introduces a t parameter and modifies the context in which the market is created, likely to enhance test control and reliability.


5323-5323: Update the market pair format in GenerateMarketParamPrice.

The WithPair argument has been updated to "0-0", which likely reflects a new expected format for market pairs.


5327-5327: Update the market pair format in GenerateMarketParamPrice.

The WithPair argument has been updated to "1-1", which likely reflects a new expected format for market pairs.


5513-5516: Replace pricesKeeper.CreateMarket with keepertest.CreateTestMarket.

The new function introduces a t parameter and modifies the context in which the market is created, likely to enhance test control and reliability.

@@ -45,15 +52,16 @@ func PricesKeepers(t testing.TB) (
) []GenesisInitializer {
// Necessary keeper for testing
revShareKeeper, _, _ = createRevShareKeeper(stateStore, db, cdc)
marketMapKeeper, _ = createMarketMapKeeper(stateStore, db, cdc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure error handling for createMarketMapKeeper.

The call to createMarketMapKeeper should include error handling to manage potential failures.

-  marketMapKeeper, _ = createMarketMapKeeper(stateStore, db, cdc)
+  var err error
+  marketMapKeeper, err = createMarketMapKeeper(stateStore, db, cdc)
+  if err != nil {
+    t.Fatalf("Failed to create marketMapKeeper: %v", err)
+  }
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
marketMapKeeper, _ = createMarketMapKeeper(stateStore, db, cdc)
var err error
marketMapKeeper, err = createMarketMapKeeper(stateStore, db, cdc)
if err != nil {
t.Fatalf("Failed to create marketMapKeeper: %v", err)
}

Comment on lines 113 to 124
func CreateMarketInMarketMapFromParams(
t testing.TB,
ctx sdk.Context,
mmk *marketmapkeeper.Keeper,
allMarketParams []types.MarketParam,
) {
marketMap := ConstructMarketMapFromParams(t, allMarketParams)
for _, market := range marketMap.Markets {
market.Ticker.Enabled = false
require.NoError(t, mmk.CreateMarket(ctx, market))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure error handling for CreateMarket.

The call to mmk.CreateMarket should include error handling to manage potential failures.

-  require.NoError(t, mmk.CreateMarket(ctx, market))
+  err := mmk.CreateMarket(ctx, market)
+  require.NoError(t, err)
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func CreateMarketInMarketMapFromParams(
t testing.TB,
ctx sdk.Context,
mmk *marketmapkeeper.Keeper,
allMarketParams []types.MarketParam,
) {
marketMap := ConstructMarketMapFromParams(t, allMarketParams)
for _, market := range marketMap.Markets {
market.Ticker.Enabled = false
require.NoError(t, mmk.CreateMarket(ctx, market))
}
}
func CreateMarketInMarketMapFromParams(
t testing.TB,
ctx sdk.Context,
mmk *marketmapkeeper.Keeper,
allMarketParams []types.MarketParam,
) {
marketMap := ConstructMarketMapFromParams(t, allMarketParams)
for _, market := range marketMap.Markets {
market.Ticker.Enabled = false
err := mmk.CreateMarket(ctx, market)
require.NoError(t, err)
}
}

Comment on lines 165 to 183
t testing.TB,
ctx sdk.Context,
k *keeper.Keeper,
marketParam types.MarketParam,
marketPrice types.MarketPrice,
) (types.MarketParam, error) {
CreateMarketInMarketMapFromParams(
t,
ctx,
k.MarketMapKeeper.(*marketmapkeeper.Keeper),
[]types.MarketParam{marketParam},
)

return k.CreateMarket(
ctx,
marketParam,
marketPrice,
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure error handling for CreateMarketInMarketMapFromParams.

The call to CreateMarketInMarketMapFromParams should include error handling to manage potential failures.

-  CreateMarketInMarketMapFromParams(
+  err := CreateMarketInMarketMapFromParams(
+    t,
+    ctx,
+    k.MarketMapKeeper.(*marketmapkeeper.Keeper),
+    []types.MarketParam{marketParam},
+  )
+  require.NoError(t, err)
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
t testing.TB,
ctx sdk.Context,
k *keeper.Keeper,
marketParam types.MarketParam,
marketPrice types.MarketPrice,
) (types.MarketParam, error) {
CreateMarketInMarketMapFromParams(
t,
ctx,
k.MarketMapKeeper.(*marketmapkeeper.Keeper),
[]types.MarketParam{marketParam},
)
return k.CreateMarket(
ctx,
marketParam,
marketPrice,
)
}
t testing.TB,
ctx sdk.Context,
k *keeper.Keeper,
marketParam types.MarketParam,
marketPrice types.MarketPrice,
) (types.MarketParam, error) {
err := CreateMarketInMarketMapFromParams(
t,
ctx,
k.MarketMapKeeper.(*marketmapkeeper.Keeper),
[]types.MarketParam{marketParam},
)
require.NoError(t, err)
return k.CreateMarket(
ctx,
marketParam,
marketPrice,
)
}

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

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

63-63: Ensure the function usage is updated.

The function PricesKeepers has been updated to return seven values. However, there are multiple instances in the codebase where this function is called, but the return values do not match the new signature. These instances need to be updated to handle seven return values.

  • Files and lines to update:
    • protocol/x/prices/module_test.go: ctx, keeper, _, _, mockTimeProvider, _, _ := keeper.PricesKeepers(t)
    • protocol/x/prices/keeper/keeper_test.go: ctx, keeper, _, _, _, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/update_price_test.go: ctx, k, _, indexPriceCache, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/genesis_test.go: ctx, k, _, _, mockTimeProvider, _, marketMapKeeper := keepertest.PricesKeepers(t)
    • protocol/x/prices/genesis_test.go: ctx, k, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/validate_market_price_updates_test.go: ctx, k, _, indexPriceCache, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/msg_server_update_market_prices_test.go: ctx, k, _, indexPriceCache, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/msg_server_update_market_param_test.go: ctx, pricesKeeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/market_price_test.go: ctx, keeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/slinky_adapter_test.go: ctx, keeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/market_test.go: ctx, keeper, _, _, mockTimeProvider, revShareKeeper, marketMapKeeper := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/market_param_test.go: ctx, keeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/x/prices/keeper/grpc_query_market_test.go: ctx, keeper, _, _, mockTimeProvider, _, _ := keepertest.PricesKeepers(t)
    • protocol/app/process/transactions_test.go: ctx, pricesKeeper, _, _, _, _, _ := keepertest.PricesKeepers(t)
    • protocol/app/process/market_prices_test.go: ctx, k, _, _, _, _, _ := keepertest.PricesKeepers(t)
    • protocol/app/prepare/prepare_proposal_test.go: ctx, _, _, _, _, _, _ := keepertest.PricesKeepers(t)

Please update these instances to match the new function signature.

Analysis chain

Ensure the function usage is updated.

The function signature of PricesKeepers has been updated. Ensure that all calls to this function are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the function usage of `PricesKeepers` in the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go $'PricesKeepers'

Length of output: 6661


Script:

#!/bin/bash
# Description: Verify each occurrence of the `PricesKeepers` function to ensure it matches the new signature.

# Test: Check if each call to `PricesKeepers` handles seven return values.
rg --type go 'PricesKeepers' -A 1 | grep -E 'ctx, [^,]+, [^,]+, [^,]+, [^,]+, [^,]+, [^,]+ := keepertest.PricesKeepers\(t\)|ctx, [^,]+, [^,]+, [^,]+, [^,]+, [^,]+, [^,]+ := keeper.PricesKeepers\(t\)'

Length of output: 6762

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e28bea and 064122c.

Files selected for processing (7)
  • protocol/app/app.go (4 hunks)
  • protocol/testutil/keeper/prices.go (6 hunks)
  • protocol/x/prices/keeper/market_test.go (7 hunks)
  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go (1 hunks)
  • protocol/x/prices/keeper/slinky_adapter_test.go (5 hunks)
  • protocol/x/prices/module_test.go (4 hunks)
  • protocol/x/subaccounts/keeper/transfer_test.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • protocol/x/subaccounts/keeper/transfer_test.go
Files skipped from review as they are similar to previous changes (5)
  • protocol/app/app.go
  • protocol/x/prices/keeper/market_test.go
  • protocol/x/prices/keeper/msg_server_create_oracle_market_test.go
  • protocol/x/prices/keeper/slinky_adapter_test.go
  • protocol/x/prices/module_test.go
Additional comments not posted (8)
protocol/testutil/keeper/prices.go (8)

44-44: Ensure error handling for createMarketMapKeeper.

The call to createMarketMapKeeper should include error handling to manage potential failures.


118-123: Ensure error handling for CreateMarket.

The call to mmk.CreateMarket should include error handling to manage potential failures.


Line range hint 125-158:
Ensure error handling for NewAPIHandler and ConvertMarketParamsToMarketMap.

The calls to dydx.NewAPIHandler and h.ConvertMarketParamsToMarketMap should include error handling to manage potential failures.


Line range hint 160-169:
Ensure error handling for CreateMarketInMarketMapFromParams.

The call to CreateMarketInMarketMapFromParams should include error handling to manage potential failures.


221-230: Ensure error handling for CreateTestMarket.

The call to CreateTestMarket should include error handling to manage potential failures.


Line range hint 278-285:
Ensure error handling for CreateTestMarket.

The call to CreateTestMarket should include error handling to manage potential failures.


32-32: Ensure the new import is necessary.

The import statement for marketmapmoduletypes should be verified to ensure it's used in the code.

Verification successful

The import statement for marketmapmoduletypes is necessary and correctly used.

  • protocol/testutil/keeper/prices.go: Usage of marketmapmoduletypes confirms the necessity of the import.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `marketmapmoduletypes` in the code.

# Test: Search for the usage. Expect: At least one occurrence.
rg --type go $'marketmapmoduletypes'

Length of output: 11507


Line range hint 78-78:
Ensure the function usage is updated.

The function signature of createPricesKeeper has been updated. Ensure that all calls to this function are updated accordingly.

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 064122c and 094aa9f.

Files ignored due to path filters (1)
  • protocol/go.sum is excluded by !**/*.sum
Files selected for processing (6)
  • protocol/go.mod (3 hunks)
  • protocol/mocks/OracleClient.go (1 hunks)
  • protocol/testing/e2e/gov/perpetuals_test.go (2 hunks)
  • protocol/x/clob/module_test.go (8 hunks)
  • protocol/x/perpetuals/module_test.go (3 hunks)
  • protocol/x/prices/module_test.go (4 hunks)
Files skipped from review as they are similar to previous changes (4)
  • protocol/testing/e2e/gov/perpetuals_test.go
  • protocol/x/clob/module_test.go
  • protocol/x/perpetuals/module_test.go
  • protocol/x/prices/module_test.go
Additional comments not posted (5)
protocol/mocks/OracleClient.go (1)

130-165: LGTM! The new mock method Version is well-implemented.

The method correctly handles variadic gRPC call options and manages mock behavior using the Called function. It also includes proper error handling and type assertions.

protocol/go.mod (4)

434-434: Verify compatibility with the new golang.org/x/tools version.

The golang.org/x/tools dependency version has been updated from v0.22.0 to v0.23.0. Ensure that the new version is compatible with the rest of the codebase.

Verification successful

No direct compatibility issues found with the new golang.org/x/tools version.

The golang.org/x/tools dependency version has been updated from v0.22.0 to v0.23.0. There are no direct references to this dependency in the Go source files, suggesting that the update should not cause any immediate compatibility issues.

  • protocol/go.mod
  • protocol/go.sum
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility with the new `golang.org/x/tools` version.

# Test: Check for any breaking changes or incompatibilities.
rg --type go 'golang.org/x/tools'

Length of output: 33


Script:

#!/bin/bash
# Description: Verify compatibility with the new `golang.org/x/tools` version.

# Test: Check for any indirect usage or related files impacted by the version update.

# Search for any references to `golang.org/x/tools` in the Go module files.
rg 'golang.org/x/tools' --glob 'go.mod' --glob 'go.sum'

# Search for any references to `golang.org/x/tools` in all Go files.
rg 'golang.org/x/tools' --type go

Length of output: 9917


14-14: Verify compatibility with the new Cosmos SDK version.

The Cosmos SDK version has been updated from v0.50.7 to v0.50.8. Ensure that the new version is compatible with the rest of the codebase.


70-70: Verify compatibility with the new slinky version.

The slinky dependency version has been updated from v1.0.4-0.20240715165738-8218f83b6eb1 to v1.0.5-0.20240723200102-e4ba512cc7cc. Ensure that the new version is compatible with the rest of the codebase.


426-426: Verify compatibility with the new golang.org/x/mod version.

The golang.org/x/mod dependency version has been updated from v0.18.0 to v0.19.0. Ensure that the new version is compatible with the rest of the codebase.

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 094aa9f and 03f4a21.

Files selected for processing (2)
  • protocol/testutil/sim_helpers/genesis_parameters.go (1 hunks)
  • protocol/x/prices/simulation/genesis.go (3 hunks)
Additional comments not posted (6)
protocol/testutil/sim_helpers/genesis_parameters.go (3)

88-88: Verify the impact of the tightened constraint for MinMinExchangesPerMarket.

The Reasonable value has been decreased from 3 to 2. Ensure this change aligns with the overall market behavior and system requirements.


92-93: Verify the impact of the tightened constraints for MaxMinExchangesPerMarket.

The Reasonable value has been reduced from 5 to 3, and the Valid value has been significantly lowered from 100 to 6. Ensure this change aligns with the overall market validation and system requirements.


101-102: Verify the impact of the shifted range for MaxMarketExponent.

The Reasonable value has been adjusted from 0 to -5, and the Valid value has been changed from 10 to -1. Ensure this change aligns with the overall market calculations and system requirements.

protocol/x/prices/simulation/genesis.go (3)

91-101: LGTM! The dynamically generated ExchangeConfigJson enhances simulation realism.

The change from hardcoded empty JSON to a dynamically generated JSON string that includes multiple exchanges improves the flexibility and realism of the market simulation.


118-132: LGTM! The construction of marketmapGenesis from market parameters improves simulation accuracy.

The change ensures that the market map is constructed from the market parameters using the ConstructMarketMapFromParams function, improving the accuracy and consistency of the simulation.


136-172: LGTM! The ConstructMarketMapFromParams function enhances simulation functionality.

The new function converts market parameters into a market map using an API handler from the dydx package, improving the functionality and realism of the simulation.

func(genesisState *marketmaptypes.GenesisState) {
markets := make(map[string]marketmaptypes.Market)
cp, _ := slinky.MarketPairToCurrencyPair(GENESIS_MARKET_PARAM.Pair)
ticker := marketmaptypes.Ticker{
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Add a constant to testutil/constants for this market map market?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is derived from the GENESIS_MARKET_PARAM var defined in this file, so I think it makes sense to leave it like this

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 03f4a21 and b6f7be9.

Files selected for processing (7)
  • protocol/Makefile (2 hunks)
  • protocol/testing/e2e/gov/add_new_market_test.go (6 hunks)
  • protocol/testing/genesis.sh (1 hunks)
  • protocol/x/perpetuals/keeper/perpetual_test.go (9 hunks)
  • protocol/x/perpetuals/lib/lib_test.go (12 hunks)
  • protocol/x/prices/keeper/market_test.go (8 hunks)
  • protocol/x/prices/simulation/genesis.go (3 hunks)
Files skipped from review due to trivial changes (1)
  • protocol/Makefile
Files skipped from review as they are similar to previous changes (4)
  • protocol/testing/e2e/gov/add_new_market_test.go
  • protocol/x/perpetuals/keeper/perpetual_test.go
  • protocol/x/perpetuals/lib/lib_test.go
  • protocol/x/prices/keeper/market_test.go
Additional comments not posted (8)
protocol/x/prices/simulation/genesis.go (4)

91-101: Verify the correctness of exchangeJson construction.

The dynamically generated exchangeJson string improves flexibility. Ensure that the marketName is correctly formatted and used in the JSON string.

Verification successful

Verify the correctness of exchangeJson construction.

The dynamically generated exchangeJson string improves flexibility. The marketName is correctly formatted and used in the JSON string. The exchangeJson is appropriately used in the ExchangeConfigJson field of the MarketParam struct.

  • protocol/x/prices/simulation/genesis.go: exchangeJson is constructed and used correctly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `exchangeJson` construction.

# Test: Search for the usage of `exchangeJson`. Expect: Correct formatting and usage.
rg --type go -A 5 $'exchangeJson'

Length of output: 1453


136-154: Verify the initialization of the API handler.

The API handler is initialized with dummy variables to pass validation. Ensure that the initialization parameters are correct and appropriate for the simulation context.

Verification successful

Verified the initialization of the API handler.

The API handler is initialized with dummy variables to pass validation, and the parameters used are consistent and appropriate for the simulation context.

  • protocol/x/prices/simulation/genesis.go
  • protocol/testutil/keeper/prices.go
  • protocol/app/upgrades/v6.0.0/upgrade.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization of the API handler.

# Test: Search for the initialization of `dydx.NewAPIHandler`. Expect: Correct initialization parameters.
rg --type go -A 5 $'dydx.NewAPIHandler'

Length of output: 1274


Script:

#!/bin/bash
# Description: Verify the usage context of the API handler.

# Test: Search for the usage of `dydx.NewAPIHandler` in the codebase to understand its context.
rg --type go 'dydx.NewAPIHandler' -A 10

Length of output: 2276


118-132: Verify the integration of ConstructMarketMapFromParams.

The integration of the new function ConstructMarketMapFromParams looks good. Ensure that the function is correctly used and the market map is properly constructed.

Verification successful

The integration of ConstructMarketMapFromParams is verified.

The function ConstructMarketMapFromParams is correctly defined and used in protocol/x/prices/simulation/genesis.go. Additionally, it is thoroughly tested in protocol/testutil/keeper/prices.go and protocol/testing/e2e/gov/add_new_market_test.go.

  • protocol/x/prices/simulation/genesis.go: Properly constructs the market map and integrates it into the genesis state.
  • protocol/testutil/keeper/prices.go: Includes test cases that validate the function's behavior.
  • protocol/testing/e2e/gov/add_new_market_test.go: Further tests the function in an end-to-end scenario.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `ConstructMarketMapFromParams`.

# Test: Search for the usage of `ConstructMarketMapFromParams`. Expect: Correct usage and integration.
rg --type go -A 5 $'ConstructMarketMapFromParams'

Length of output: 2553


Script:

#!/bin/bash
# Extract the full definition of `ConstructMarketMapFromParams` in `genesis.go`
ast-grep --lang go --pattern $'func ConstructMarketMapFromParams($_, $_) $_' protocol/x/prices/simulation/genesis.go

# Extract the context around the usage of `ConstructMarketMapFromParams` in `genesis.go`
rg --type go -C 5 'ConstructMarketMapFromParams' protocol/x/prices/simulation/genesis.go

# Verify the test cases in `prices.go`
rg --type go -A 10 'ConstructMarketMapFromParams' protocol/testutil/keeper/prices.go

# Verify the test cases in `add_new_market_test.go`
rg --type go -A 10 'ConstructMarketMapFromParams' protocol/testing/e2e/gov/add_new_market_test.go

Length of output: 2281


156-172: Verify the construction and conversion of market parameters.

The function constructs a response structure from market parameters and converts it into a market map. Ensure that the construction and conversion logic is correct and handles all edge cases.

protocol/testing/genesis.sh (4)

517-540: Verify the correctness of the MarketMap configuration for "BTC/USD".

The configuration includes detailed parameters and multiple provider configurations. Ensure that all values, especially the normalization settings, are correct and consistent with the intended market setup.


541-547: Verify the correctness of the MarketMap configuration for "USDT/USD".

The configuration includes detailed parameters and multiple provider configurations. Ensure that all values, especially the inversion settings for some providers, are correct and consistent with the intended market setup.


548-548: Verify the correctness of the prices module configurations.

The configurations include detailed parameters for multiple markets. Ensure that all values, especially the price and exchange configurations, are correct and consistent with the intended market setup.


517-547: Verify the correctness of the MarketMap configurations for "BTC/USD" and "USDT/USD".

The configurations include detailed parameters and multiple provider configurations. Ensure that all values, especially the normalization and inversion settings, are correct and consistent with the intended market setup.

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 e69b352 and 98803f6.

Files selected for processing (2)
  • .github/workflows/indexer-build-and-push-dev-staging.yml (1 hunks)
  • protocol/scripts/genesis/sample_pregenesis.json (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • protocol/scripts/genesis/sample_pregenesis.json
Additional comments not posted (1)
.github/workflows/indexer-build-and-push-dev-staging.yml (1)

9-9: LGTM!

The addition of the branch pattern chenyao/tra-508 to the on section is correct.

@@ -6,6 +6,7 @@ on: # yamllint disable-line rule:truthy
- main
- 'release/indexer/v[0-9]+.[0-9]+.x' # e.g. release/indexer/v0.1.x
- 'release/indexer/v[0-9]+.x' # e.g. release/indexer/v1.x
- 'chenyao/tra-508'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Remove before merging.

@@ -6,6 +6,7 @@ on: # yamllint disable-line rule:truthy
- main
- 'release/protocol/v[0-9]+.[0-9]+.x' # e.g. release/protocol/v0.1.x
- 'release/protocol/v[0-9]+.x' # e.g. release/protocol/v1.x
- 'chenyao/tra-508'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Remove before merging.

Price: constants.FiveBillion,
},
)
require.Error(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Check the error against the expected error type.

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 98803f6 and 4f59e03.

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

@chenyaoy chenyaoy merged commit 37f74d0 into main Jul 25, 2024
18 checks passed
@chenyaoy chenyaoy deleted the chenyao/tra-508 branch July 25, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants