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-513] Deprecate exchange config json and min exchanges #2524

Merged
merged 8 commits into from
Oct 28, 2024

Conversation

chenyaoy
Copy link
Contributor

@chenyaoy chenyaoy commented Oct 21, 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

Release Notes

  • New Features

    • Enhanced market configuration capabilities, including detailed management for affiliate tiers, assets, and price parameters.
    • Improved handling of market update transactions with comprehensive validation checks.
  • Bug Fixes

    • Updated deprecation notes for properties in market parameters to reflect changes since version 8.x.
    • Streamlined validation logic for market parameters by removing checks for MinExchanges and ExchangeConfigJson.
  • Tests

    • Expanded test coverage for market update transactions and validation logic.
    • Removed outdated test cases related to deprecated fields, focusing on relevant parameters.
  • Chores

    • General cleanup and reorganization of test files for improved clarity and maintainability.

@chenyaoy chenyaoy requested a review from a team as a code owner October 21, 2024 18:48
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The pull request updates various files related to market parameters and their validation within the protocol. Key changes include the modification of deprecation notes for specific properties in interfaces and messages, the removal of certain test cases that check for the validity of the ExchangeConfigJson field, and enhancements to the test suite for market updates. Additionally, the genesis configuration and script have been significantly restructured to include new parameters and improve functionality.

Changes

File Change Summary
indexer/packages/v4-protos/src/codegen/dydxprotocol/prices/market_param.ts Updated deprecation notes for exponent, minExchanges, and exchangeConfigJson properties in MarketParam and MarketParamSDKType interfaces to indicate deprecation since v8.x.
proto/dydxprotocol/prices/market_param.proto Modified deprecation notes for exponent, min_exchanges, and exchange_config_json fields in MarketParam message to reflect deprecation since v8.x.
protocol/app/ante/market_update_test.go Enhanced test suite for market updates, adding scenarios and modifying existing tests for validation of market update messages. Added CreateTestTx function.
protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go Removed specific test cases related to exchangeConfigJson and reorganized import statements.
protocol/scripts/genesis/sample_pregenesis.json Comprehensive updates to the genesis file, adding new parameters across multiple sections including affiliate tiers, assets, and price configurations.
protocol/testing/genesis.sh Extensive modifications to the genesis configuration script, adding market configurations, liquidity tiers, and enhancing functionality.
protocol/x/prices/keeper/market_param_test.go Removed specific test cases from TestModifyMarketParam_Errors, focusing on critical error scenarios.
protocol/x/prices/keeper/market_test.go Removed test case for validating minimum exchanges parameter from TestCreateMarket_Errors.
protocol/x/prices/keeper/slinky_adapter_test.go Removed MinExchanges from parameters in CreateMarket function call, affecting market creation validation.
protocol/x/prices/module_test.go Simplified structure of genesisJson strings in ValidateGenesisErr test case.
protocol/x/prices/types/genesis_test.go Removed ExchangeConfigJson field from various test cases, streamlining validation tests.
protocol/x/prices/types/market_param.go Removed checks for mp.MinExchanges being zero and JSON validity from the Validate method.
protocol/x/prices/types/market_param_test.go Removed test cases validating the ExchangeConfigJson field, focusing on Pair and MinPriceChangePpm.
protocol/x/prices/types/message_create_oracle_market_test.go Removed tests related to ExchangeConfigJson, adjusting MarketParam structure in test cases.
protocol/x/prices/types/message_update_market_param_test.go Removed test case for "Failure: 0 MinExchanges" and adjusted MarketParam structure in tests.

Possibly related PRs

Suggested labels

pml

Suggested reviewers

  • vincentwschau

🐇 In the fields where markets grow,
Changes made, as we all know.
With parameters set just right,
Our protocol shines, a true delight!
From genesis to tests, all refined,
A hop towards progress, perfectly aligned! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 756af23 and 7c31337.

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

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@chenyaoy chenyaoy changed the title Chenyao/deprecate exchange config json and min exchanges Deprecate exchange config json and min exchanges Oct 21, 2024
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 and nitpick comments (15)
protocol/x/prices/types/market_param_test.go (1)

35-36: LGTM. Consider adding edge case tests.

The "Invalid MinPriceChangePpm" test case has been updated correctly, aligning with the deprecation of ExchangeConfigJson and MinExchanges fields.

Consider adding edge case tests for MinPriceChangePpm, such as testing the maximum allowed value or boundary conditions, to ensure robust validation.

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

ValidateFromParam method does not handle removed ExchangeConfigJson field

The ValidateFromParam method in MarketPrice has not been updated to reflect the removal of the ExchangeConfigJson field from MarketParam. This oversight may lead to inconsistencies or unexpected behavior.

  • File: protocol/x/prices/types/market_price.go
  • Function: ValidateFromParam
🔗 Analysis chain

Line range hint 41-69: Verify ValidateFromParam method in MarketPrice

The Validate method remains unchanged, which is correct as it doesn't explicitly check the removed ExchangeConfigJson field. However, please ensure that the ValidateFromParam method of MarketPrice (called on line 66) has been updated to reflect the changes in the MarketParam struct.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if ValidateFromParam method has been updated

# Test: Search for ValidateFromParam method definition
rg -A 10 'func \(.*\) ValidateFromParam\(.*MarketParam.*\)'

Length of output: 760

proto/dydxprotocol/prices/market_param.proto (4)

22-22: LGTM. Consider adding a link to the marketmap documentation.

The deprecation note and explanation for the exponent field are clear and informative. To further assist developers, consider adding a link to the marketmap documentation where they can find more information about how this value is now determined.


27-28: LGTM. Consider consistent comment formatting.

The deprecation note and explanation for the min_exchanges field are clear and informative. For consistency, consider removing the extra newline before the deprecation note to match the formatting of the exponent field.


37-38: LGTM. Consider consistent comment formatting and adding a link to the marketmap documentation.

The deprecation note and explanation for the exchange_config_json field are clear and informative. For consistency:

  1. Consider removing the extra newline before the deprecation note to match the formatting of the exponent field.
  2. Consider adding a link to the marketmap documentation where developers can find more information about how the exchange config is now determined.

Line range hint 22-38: Summary: Deprecation of market parameter fields aligns with PR objectives.

The changes to the MarketParam message effectively deprecate the exponent, min_exchanges, and exchange_config_json fields, indicating that their values are now determined from the marketmap starting from version 8.x. These updates align with the PR objective of deprecating certain configurations related to exchanges.

The deprecation notes and explanations are clear and informative, which will help developers understand the changes and adapt their code accordingly. The consistency in formatting could be improved slightly, and adding links to the marketmap documentation would further assist developers in finding the new source of these values.

Overall, these changes represent a significant shift in how market parameters are handled, moving towards a more centralized configuration through the marketmap.

Consider updating any related documentation or guides to reflect these changes and provide instructions on how to use the marketmap for these configurations in v8.x and later.

protocol/x/prices/types/message_create_oracle_market_test.go (3)

39-40: LGTM: Updated MarketParam structure

The test case has been correctly updated to reflect the changes in the MarketParam structure. The removal of MinExchanges and ExchangeConfigJson fields aligns with the broader changes in the codebase.

Consider adding a comment explaining why these fields were removed to provide context for future developers.


61-62: LGTM: Consistent update in "Invalid MinPriceChangePpm" test case

The MarketParam structure in this test case has been correctly updated to match the changes in the other test cases. The test still effectively checks for an invalid MinPriceChangePpm value.

Consider adding more test cases with different invalid MinPriceChangePpm values to ensure robust validation.


Incomplete Removal of ExchangeConfigJson and MinExchanges Fields

The fields ExchangeConfigJson and MinExchanges are still present in multiple files across the codebase, indicating that their removal has not been fully implemented.

🔗 Analysis chain

Line range hint 1-80: Overall changes look good, consider adding more test cases

The modifications to this test file are consistent with the broader changes in the codebase, particularly the deprecation of ExchangeConfigJson and MinExchanges fields. The MarketParam structure has been updated consistently across all test cases, and the remaining tests still cover the essential scenarios for Pair and MinPriceChangePpm.

To further improve the test coverage:

  1. Consider adding more test cases for edge cases of MinPriceChangePpm.
  2. Add tests for any new validation logic that may have been introduced as part of these changes.
  3. Ensure that the removal of ExchangeConfigJson and MinExchanges fields doesn't introduce any unintended side effects in the actual implementation.

To verify the consistency of these changes across the codebase, please run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of ExchangeConfigJson and MinExchanges fields across the codebase

# Test: Search for any remaining usage of ExchangeConfigJson and MinExchanges
echo "Searching for ExchangeConfigJson usage:"
rg "ExchangeConfigJson" --type go

echo "Searching for MinExchanges usage:"
rg "MinExchanges" --type go

# Test: Verify MarketParam structure in other files
echo "Checking MarketParam structure in other files:"
rg "type MarketParam struct" -A 10 --type go

Length of output: 40504

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

71-72: LGTM: Consistent removal of ExchangeConfigJson field.

The ExchangeConfigJson field has been consistently removed from the MarketParam struct in the "invalid: market param invalid (pair unset)" test case. The test case still effectively checks for an invalid market param with an unset pair.

Consider initializing the MinPriceChangePpm field to ensure all non-tested fields have valid values:

 {
   Id:   0,
   Pair: "",
+  MinPriceChangePpm: 1,
 },
protocol/x/prices/keeper/slinky_adapter_test.go (1)

112-114: LGTM. Consider adding a test for Exponent and ExchangeConfigJson.

The removal of the MinExchanges field from the MarketParam struct is consistent with its deprecation. The test still effectively checks for the creation of a market with invalid data.

To maintain comprehensive test coverage, consider adding test cases for the Exponent and ExchangeConfigJson fields, which were also mentioned as deprecated in the AI-generated summary. This would ensure that all deprecated fields are properly handled.

indexer/packages/v4-protos/src/codegen/dydxprotocol/prices/market_param.ts (2)

22-22: LGTM. Consider adding a link to the marketmap documentation.

The updated deprecation comment clearly indicates that the exponent value is now determined from the marketmap starting from v8.x. This aligns with the PR objectives.

To further improve the documentation, consider adding a link to the marketmap documentation or specification, if available. This would help developers understand where to find the new source of this value.


45-46: LGTM. Consider rephrasing for consistency.

The updated deprecation comment for exchangeConfigJson aligns with the PR objectives and is consistent with the changes made to the exponent and minExchanges properties.

For consistency with the other deprecation comments, consider rephrasing to:

/** Deprecated since v8.x. This value is now determined from the marketmap. */

This would maintain a uniform style across all deprecated properties.

protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go (1)

Line range hint 1-445: LGTM: Overall changes align well with the pull request objectives.

The remaining tests still provide good coverage for market parameter validation. To further improve code clarity, consider adding a comment explaining the reason for removing the exchangeConfigJson-related test cases, referencing the deprecation of this field.

Consider adding a comment like this at the beginning of the TestValidateAndTransformParams_Mixed function:

// Note: Test cases for invalid exchangeConfigJson have been removed due to the deprecation of this field.
protocol/app/ante/market_update_test.go (1)

Line range hint 922-954: Avoid using panic when setting messages in CreateTestTx

In the CreateTestTx function, using panic(err) when txBuilder.SetMsgs(msgs...) fails may cause the test suite to exit unexpectedly. Instead, return the error to allow for proper error handling and reporting.

Apply this diff to handle the error appropriately:

 func CreateTestTx(
     ctx sdk.Context,
     msgs []sdk.Msg,
     privs []cryptotypes.PrivKey,
     accNums, accSeqs []uint64,
     chainID string, signMode signing.SignMode, txConfig client.TxConfig,
 ) (xauthsigning.Tx, error) {
     txBuilder := txConfig.NewTxBuilder()
     err := txBuilder.SetMsgs(msgs...)
     if err != nil {
-        panic(err)
+        return nil, err
     }
     // Rest of the code
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0eff57c and 391c4e7.

⛔ Files ignored due to path filters (1)
  • protocol/x/prices/types/market_param.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (18)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/prices/market_param.ts (6 hunks)
  • proto/dydxprotocol/prices/market_param.proto (2 hunks)
  • protocol/app/ante/market_update_test.go (1 hunks)
  • protocol/app/testdata/default_genesis_state.json (0 hunks)
  • protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go (1 hunks)
  • protocol/scripts/genesis/sample_pregenesis.json (0 hunks)
  • protocol/testing/genesis.sh (0 hunks)
  • protocol/x/prices/keeper/market_param_test.go (0 hunks)
  • protocol/x/prices/keeper/market_test.go (0 hunks)
  • protocol/x/prices/keeper/slinky_adapter_test.go (1 hunks)
  • protocol/x/prices/module_test.go (2 hunks)
  • protocol/x/prices/types/genesis.go (1 hunks)
  • protocol/x/prices/types/genesis_test.go (5 hunks)
  • protocol/x/prices/types/market_param.go (0 hunks)
  • protocol/x/prices/types/market_param_test.go (1 hunks)
  • protocol/x/prices/types/message_create_oracle_market_test.go (4 hunks)
  • protocol/x/prices/types/message_update_market_param_test.go (2 hunks)
  • protocol/x/rewards/keeper/keeper_test.go (1 hunks)
💤 Files with no reviewable changes (6)
  • protocol/app/testdata/default_genesis_state.json
  • protocol/scripts/genesis/sample_pregenesis.json
  • protocol/testing/genesis.sh
  • protocol/x/prices/keeper/market_param_test.go
  • protocol/x/prices/keeper/market_test.go
  • protocol/x/prices/types/market_param.go
🧰 Additional context used
🔇 Additional comments (19)
protocol/x/prices/types/market_param_test.go (2)

27-28: LGTM. Consistent with field deprecation.

The "Empty pair" test case has been updated correctly, removing the deprecated fields while maintaining the essential validation for the Pair field.


Line range hint 1-52: Summary: Test suite updated to reflect field deprecations.

The changes in this file consistently remove references to the deprecated ExchangeConfigJson and MinExchanges fields from all test cases. The remaining tests still cover the essential validations for Pair and MinPriceChangePpm, maintaining the integrity of the MarketParam validation test suite.

These modifications align well with the broader changes mentioned in the PR summary, particularly the deprecation of certain fields in the MarketParam struct starting from version 8.x.

To ensure comprehensive test coverage after these changes, consider running the following commands:

protocol/x/prices/types/genesis.go (2)

13-16: LGTM: Removal of ExchangeConfigJson field from MarketParam entries.

The changes align with the deprecation of the ExchangeConfigJson field. This simplification of the MarketParam struct in the default genesis state is a positive change, removing potentially sensitive or frequently changing data from the hardcoded defaults.

Also applies to: 19-22


Line range hint 1-69: Summary of changes and their implications

The removal of the ExchangeConfigJson field from the MarketParam entries in the DefaultGenesis function aligns with the broader changes across the codebase to deprecate this field. This change simplifies the default genesis state and removes potentially sensitive or frequently changing data from hardcoded defaults.

While the Validate method in this file doesn't require changes, it's crucial to ensure that related validation methods (like ValidateFromParam) and any code that depends on the ExchangeConfigJson field have been updated accordingly in other files.

These changes contribute to a more streamlined and maintainable codebase, but careful testing should be conducted to ensure that the removal of this field doesn't introduce any unexpected behavior in the system.

protocol/x/prices/types/message_create_oracle_market_test.go (2)

6-7: LGTM: Import statement cleanup

The uncommented import of testutil and its relocation improve code organization and indicate its usage in the tests.


50-51: LGTM: Consistent update in "Empty pair" test case

The MarketParam structure in this test case has been correctly updated to match the changes in the valid test case. The test still effectively checks for an empty pair scenario.

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

6-7: LGTM: New import and improved formatting.

The addition of the testutil package import and the empty line for separation improves code organization and readability.

protocol/x/prices/types/genesis_test.go (4)

54-56: LGTM: Consistent removal of ExchangeConfigJson field.

The ExchangeConfigJson field has been consistently removed from the MarketParam structs in the "invalid: duplicate market param ids" test case. The test case still effectively checks for duplicate market param ids with the remaining fields.

Also applies to: 59-61


82-84: LGTM: Consistent removal of ExchangeConfigJson field.

The ExchangeConfigJson field has been consistently removed from the MarketParam structs in the "invalid: mismatched number of market params and prices" test case. The test case still effectively checks for mismatched numbers of market params and prices with the remaining fields properly initialized.

Also applies to: 87-89


105-107: LGTM: Consistent removal of ExchangeConfigJson field and maintained test integrity.

The ExchangeConfigJson field has been consistently removed from the MarketParam structs in the "invalid: market prices don't correspond to params" test case. The test case still effectively checks for non-corresponding market prices and params with the remaining fields properly initialized.

Overall, the changes in this file consistently remove the ExchangeConfigJson field from all test cases while maintaining the integrity and purpose of each test. This aligns with the broader goal of deprecating the ExchangeConfigJson field as mentioned in the PR summary.

Also applies to: 110-112


27-29: LGTM: Removal of ExchangeConfigJson field is consistent with deprecation.

The removal of the ExchangeConfigJson field from the MarketParam struct in the "valid" test case is in line with the deprecation of this field. The remaining fields are correctly initialized.

To ensure consistency across the codebase, let's verify that ExchangeConfigJson has been removed from all MarketParam structs:

✅ Verification successful

Verification Successful: ExchangeConfigJson field fully removed

No instances of ExchangeConfigJson found in any MarketParam structs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of ExchangeConfigJson in MarketParam structs

# Test: Search for ExchangeConfigJson in MarketParam structs
rg -p 'MarketParam\s*{[^}]*ExchangeConfigJson' --type go

Length of output: 194


Script:

#!/bin/bash
# Description: Check for any remaining instances of ExchangeConfigJson in MarketParam structs

# Test: Search for ExchangeConfigJson in MarketParam structs with corrected regex
rg -p 'MarketParam\s*\{[^}]*ExchangeConfigJson' --type go

Length of output: 59

indexer/packages/v4-protos/src/codegen/dydxprotocol/prices/market_param.ts (2)

31-32: LGTM. Consistent with previous property update.

The updated deprecation comment for minExchanges is consistent with the changes made to the exponent property. It clearly indicates that the value is now determined from the marketmap starting from v8.x, aligning with the PR objectives.


Line range hint 1-194: Summary: Consistent deprecation of market parameters

The changes in this file consistently update the deprecation comments for exponent, minExchanges, and exchangeConfigJson properties in both MarketParam and MarketParamSDKType interfaces. These updates align with the PR objectives to deprecate certain configurations related to exchanges.

Key points:

  1. All deprecated properties now indicate that their values are determined from the marketmap starting from v8.x.
  2. The changes maintain consistency across the file.
  3. The updates do not affect the encoding and decoding functions, ensuring backward compatibility.

These changes effectively communicate the deprecation of these properties and their new source, which should help developers adapt to the new configuration approach using the marketmap.

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

131-132: LGTM: Test case updated to reflect simplified market parameters.

The changes in this test case align with the broader modifications to simplify the market parameter structure across the codebase. The test still effectively checks for duplicate market param ids while removing the deprecated fields minExchanges and exchangeConfigJson.


141-141: LGTM: Test case updated to remove deprecated field.

The removal of the minExchanges field from the test JSON is consistent with the deprecation of this field in the market parameters. The test case continues to effectively check for mismatches between market params and prices.


Line range hint 1-341: LGTM: Changes appropriately scoped to affected test cases.

The modifications in this file are correctly limited to the test cases directly affected by the simplification of the market parameter structure. Other test cases and module functionality remain unchanged, which is appropriate given the nature of the changes.

protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go (2)

8-9: LGTM: Import statement reorganization.

The reorganization of import statements improves code readability by grouping related imports together.


Line range hint 1-445: Verify test coverage after removal of exchangeConfigJson test cases.

The removal of test cases for invalid exchangeConfigJson inputs aligns with the deprecation of this field. However, please ensure that the remaining tests still provide adequate coverage for the current functionality of market parameter validation.

To verify the test coverage, you can run the following command:

protocol/app/ante/market_update_test.go (1)

268-271: LGTM

The initialization of testMarketParams appears correct and consistent with the test setup.

Comment on lines +19 to +20
Pair: "BTC-USD",
MinPriceChangePpm: 1_000,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Incomplete Removal of Deprecated Fields

The deprecated fields ExchangeConfigJson and MinExchanges are still referenced in multiple files. Please ensure their complete removal across the codebase:

  • protocol/x/prices/types/market_param.pb.go
  • protocol/x/prices/keeper/msg_server_update_market_param_test.go
  • protocol/x/perpetuals/keeper/perpetual_test.go
  • protocol/x/listing/keeper/listing_test.go
  • (additional files as identified)
🔗 Analysis chain

LGTM. Verify removal of deprecated fields.

The changes correctly reflect the deprecation of ExchangeConfigJson and MinExchanges fields. The test case now focuses on the essential Pair and MinPriceChangePpm fields.

To ensure consistency across the codebase, let's verify the removal of these deprecated fields:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify removal of deprecated fields from MarketParam struct and related code.

# Test 1: Check for any remaining references to ExchangeConfigJson
echo "Checking for ExchangeConfigJson references:"
rg "ExchangeConfigJson" --type go

# Test 2: Check for any remaining references to MinExchanges
echo "Checking for MinExchanges references:"
rg "MinExchanges" --type go

# Test 3: Verify MarketParam struct definition
echo "Checking MarketParam struct definition:"
rg "type MarketParam struct" -A 10 --type go

Length of output: 40506

Comment on lines +21 to +22
Pair: "test",
MinPriceChangePpm: 1_000,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

MinExchanges Still Referenced in Test File

The MinExchanges field has been removed from the MarketParam structure, but references to it are still present in message_update_market_param_test.go. Please update the test cases to remove or adjust these references accordingly.

🔗 Analysis chain

Verify test coverage after removing MinExchanges.

The removal of the MinExchanges field from the MarketParam structure aligns with its deprecation. However, please ensure that this change doesn't reduce the test coverage for the MsgUpdateMarketParam message.

To verify the test coverage, please run the following command:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check test coverage for MsgUpdateMarketParam

# Test: Verify that all fields of MarketParam are still being tested
rg -A 10 "MarketParam{" protocol/x/prices/types/message_update_market_param_test.go

# Test: Check if there are any remaining references to MinExchanges in the test file
rg "MinExchanges" protocol/x/prices/types/message_update_market_param_test.go

# Test: Verify that all fields of MsgUpdateMarketParam are being validated
ast-grep --pattern 'func TestMsgUpdateMarketParam_ValidateBasic(t *testing.T) {
  $$$
}'

Length of output: 7071

Comment on lines 989 to 992
Id: testRewardTokenMarketId,
Pair: testRewardTokenMarket,
Exponent: tc.tokenPrice.Exponent,
MinPriceChangePpm: uint32(50),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove deprecated Exponent and MinPriceChangePpm fields from MarketParam

Since the Exponent and MinPriceChangePpm fields are deprecated starting from version 8.x, consider removing them from the test setup to align with the updated market parameter definitions.

Apply the following diff to remove the deprecated fields:

    					Id:                testRewardTokenMarketId,
    					Pair:              testRewardTokenMarket,
-    					Exponent:          tc.tokenPrice.Exponent,
-    					MinPriceChangePpm: uint32(50),
📝 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
Id: testRewardTokenMarketId,
Pair: testRewardTokenMarket,
Exponent: tc.tokenPrice.Exponent,
MinPriceChangePpm: uint32(50),
Id: testRewardTokenMarketId,
Pair: testRewardTokenMarket,

@chenyaoy chenyaoy changed the title Deprecate exchange config json and min exchanges [TRA-513] Deprecate exchange config json and min exchanges Oct 21, 2024
Copy link

linear bot commented Oct 21, 2024

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 48e3d0a and 8ef78fb.

📒 Files selected for processing (3)
  • protocol/testing/e2e/gov/prices_test.go (0 hunks)
  • protocol/x/listing/keeper/listing.go (1 hunks)
  • protocol/x/listing/keeper/listing_test.go (0 hunks)
💤 Files with no reviewable changes (2)
  • protocol/testing/e2e/gov/prices_test.go
  • protocol/x/listing/keeper/listing_test.go
🧰 Additional context used
🔇 Additional comments (2)
protocol/x/listing/keeper/listing.go (2)

Line range hint 1-324: Overall, the changes look good but require careful verification.

The modifications to the CreateMarket function align with the broader goal of simplifying market parameter structures and deriving values from the market map. These changes are consistent with updates mentioned in other files of this PR.

However, given the potential impact on price calculations and exchange-related operations, it's crucial to:

  1. Thoroughly test these changes in various scenarios.
  2. Update any documentation related to market creation and parameter structures.
  3. Ensure that all parts of the system that previously relied on Exponent and MinExchanges in MarketParam have been appropriately updated.

Please run comprehensive integration tests focusing on market creation, price calculations, and any exchange-related functionalities to ensure system-wide consistency and correctness.


Line range hint 66-70: Exponent calculation updated. Verify consistency.

The Exponent is now set directly in the MarketPrice struct, derived from the market map details. This change ensures that the exponent is consistently sourced from the market map.

To ensure this change is applied consistently across the codebase, please run the following script:

#!/bin/bash
# Search for other instances where Exponent is set in MarketPrice
rg -i 'Exponent.*MarketPrice' --type go

Comment on lines +63 to +65
Id: marketId,
Pair: ticker,
MinPriceChangePpm: types.MinPriceChangePpm_LongTail,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Issues Found: Residual References to Removed Fields

Residual references to Exponent and MinExchanges were found in the following files:

  • protocol/x/prices/keeper/msg_server_update_market_param_test.go
  • protocol/x/prices/keeper/market_price.go
  • protocol/testing/e2e/gov/add_new_market_test.go
  • protocol/testutil/prices/market_param_price.go
  • protocol/testutil/app/order.go
  • protocol/testutil/constants/pricefeed.go
  • protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs.go

Please update these locations to remove or refactor the usage of Exponent and MinExchanges to ensure consistency with the recent changes.

🔗 Analysis chain

LGTM. Simplified market parameter structure.

The removal of Exponent and MinExchanges from MarketParam aligns with the deprecation notes mentioned in other files. This simplification streamlines the market creation process.

Please verify that these changes don't negatively impact price calculations or exchange-related operations elsewhere in the system. Run the following script to check for any remaining references to these removed fields:


Action Required: Correct the Verification Script

The previous script encountered a syntax error. Please run the corrected script below to search for any remaining references to Exponent or MinExchanges in MarketParam:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to Exponent or MinExchanges in MarketParam
rg -i '(Exponent|MinExchanges).*MarketParam' --type go

Length of output: 910


Script:

# Search for any remaining references to Exponent or MinExchanges in MarketParam
rg -i "(Exponent|MinExchanges).*MarketParam" --type go

Length of output: 2522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants