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

Upgrade connect dependency to allow market authorities to remove markets #2615

Merged
merged 4 commits into from
Nov 26, 2024

Conversation

chenyaoy
Copy link
Contributor

@chenyaoy chenyaoy commented Nov 26, 2024

Changelist

  • Upgrade connect dependency to allow market authorities to remove markets
  • Marketmap module has validation hook on delete to disallow deletion of enabled markets, so there doesn't need to be this check in the antehandler

Test Plan

Tested on localnet that:

  • non-market authorities cannot delete markets
  • market authority cannot delete enabled market
  • market authority can delete disabled market

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

    • Updated Go version to 1.23.1 for improved performance and compatibility.
    • Enhanced dependency management with multiple libraries updated to their latest versions.
  • Bug Fixes

    • General updates to dependencies to ensure better stability and security.
    • Improved test assertions for more accurate validation of market configurations and parameters.
  • Documentation

    • Updated module files to reflect the latest changes in dependencies and Go version.

@chenyaoy chenyaoy requested a review from a team as a code owner November 26, 2024 15:11
Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

Walkthrough

The changes in this pull request involve updates to the Dockerfile and go.mod file for the project. The Dockerfile has been modified to use a newer Golang base image version, specifically updating from golang:1.22.2-alpine to golang:1.23.1-alpine. In the go.mod file, the Go version and several dependencies have been upgraded to their latest versions, ensuring compatibility and security. Additionally, various test files have been adjusted to improve pointer comparisons in assertions.

Changes

File Change Summary
protocol/Dockerfile Updated base image from golang:1.22.2-alpine to golang:1.23.1-alpine, modified ARG and FROM statements accordingly.
protocol/go.mod Updated Go version from 1.22.2 to 1.23.1, added toolchain version go1.23.3, and upgraded multiple dependencies.
protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go Added and removed duplicate import of testing, modified assertions to compare pointers instead of values.
protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go Updated assertions to compare pointers, expanded test cases for market parameter validation.
protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go Adjusted import order, modified assertions to compare pointers for mutableExchangeConfig.
protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go Adjusted import statement, refined pointer comparison in TestMutableExchangeMarketConfig_Copy.
protocol/daemons/pricefeed/client/types/mutable_market_config_test.go Corrected import order, updated assertion in TestCopy to compare pointers.

Suggested reviewers

  • vincentwschau
  • teddyding

🐰 In the garden of code, we hop and play,
With Docker and Go, we brighten the day.
Versions updated, dependencies aligned,
A leap into progress, with joy intertwined!
Let's build and create, with a spring in our feet,
For every new change, makes our project complete! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0eb35c8 and 3726ba7.

📒 Files selected for processing (5)
  • protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go (3 hunks)
  • protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go (1 hunks)
  • protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go (1 hunks)
  • protocol/daemons/pricefeed/client/types/mutable_market_config_test.go (1 hunks)
  • protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go
  • protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go
  • protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go
  • protocol/daemons/pricefeed/client/types/mutable_market_config_test.go
  • protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
protocol/go.mod (1)

Line range hint 466-474: Track TODO items for future cleanup

There are several TODO comments indicating temporary replacements that need to be addressed:

Would you like me to create GitHub issues to track these TODOs?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7454ced and 92a279a.

⛔ Files ignored due to path filters (1)
  • protocol/go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • protocol/Dockerfile (3 hunks)
  • protocol/go.mod (21 hunks)
🔇 Additional comments (2)
protocol/Dockerfile (1)

3-3: Verify the Docker image digest

Let's verify the authenticity of the Docker image digest.

protocol/go.mod (1)

72-72: Dependency upgrade aligns with PR objectives

The upgrade of skip-mev/connect/v2 to v2.2.1 supports the PR's objective of allowing market authorities to remove markets.

Comment on lines +2 to +3
# `docker buildx imagetools inspect golang:1.23.1-alpine`
ARG GOLANG_1_23_ALPINE_DIGEST="ac67716dd016429be8d4c2c53a248d7bcdf06d34127d3dc451bda6aa5a87bc06"
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

Critical: Invalid Go version specified

The Dockerfile references golang:1.23.1-alpine, but this is an invalid Go version. Go follows semantic versioning, and version 1.23 does not exist. The latest stable version is in the 1.22.x series.

Apply this diff to use the correct Go version:

-# `docker buildx imagetools inspect golang:1.23.1-alpine`
-ARG GOLANG_1_23_ALPINE_DIGEST="ac67716dd016429be8d4c2c53a248d7bcdf06d34127d3dc451bda6aa5a87bc06"
+# `docker buildx imagetools inspect golang:1.22.2-alpine`
+ARG GOLANG_1_22_ALPINE_DIGEST="0da8b5a5f9e5c0403c67b259a0e3d19b0cb3f8dd8a1e7fa2a1692d3ddb18e3da"

And update the corresponding FROM statements accordingly.

Also applies to: 12-12, 49-49

Comment on lines +3 to +5
go 1.23.1

toolchain go1.23.3
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

Invalid Go version specified

The Go version 1.23.1 and toolchain version 1.23.3 are invalid. Go uses semantic versioning, and the latest stable version is in the 1.22.x series.

Apply this diff to fix the Go version:

-go 1.23.1
+go 1.22.2
-toolchain go1.23.3
+toolchain go1.22.2
📝 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
go 1.23.1
toolchain go1.23.3
go 1.22.2
toolchain go1.22.2

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

🧹 Outside diff range and nitpick comments (1)
protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go (1)

74-74: Improved pointer comparison for better state isolation

The change from value comparison to pointer comparison (&marketExponents, &pf.mutableState.marketExponents) provides stronger guarantees that the returned market exponents are completely independent copies. This is crucial for preventing shared mutable state, especially important in the context of market management operations.

This pattern of strict state isolation through deep copies should be maintained consistently across the codebase, particularly for market-related operations to prevent potential data corruption during market deletions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 92a279a and c9dd185.

📒 Files selected for processing (2)
  • protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go (2 hunks)
  • protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go (1 hunks)
🔇 Additional comments (1)
protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go (1)

4-5: LGTM: Clean import addition

The testing package import is properly formatted and positioned.

@@ -155,7 +155,7 @@ func TestGetMarketConfigCopies(t *testing.T) {
require.Error(t, err, tc.ExpectedError.Error())
} else {
// Validate that this method returns a copy and not the original.
require.NotSame(t, tc.Expected, actual)
require.NotSame(t, &tc.Expected, &actual)
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

Fix incorrect pointer comparison in slice copy test.

The current assertion require.NotSame(t, &tc.Expected, &actual) only verifies that the slice headers have different addresses, which is always true for different slices. This doesn't guarantee that the individual market configs within the slice are actually copies.

To properly test that each market config is a copy, replace the assertion with:

-				require.NotSame(t, &tc.Expected, &actual)
+				require.Equal(t, len(tc.Expected), len(actual))
+				for i := range tc.Expected {
+					require.NotSame(t, tc.Expected[i], actual[i])
+					require.Equal(t, tc.Expected[i], actual[i])
+				}

This change will:

  1. Verify that both slices have the same length
  2. Check that each market config in the slice is a different instance (NotSame)
  3. Verify that the copied market configs have the same values (Equal)
📝 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
require.NotSame(t, &tc.Expected, &actual)
require.Equal(t, len(tc.Expected), len(actual))
for i := range tc.Expected {
require.NotSame(t, tc.Expected[i], actual[i])
require.Equal(t, tc.Expected[i], actual[i])
}

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

Reviewing files that changed from the base of the PR and between c9dd185 and 0eb35c8.

📒 Files selected for processing (5)
  • protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go (4 hunks)
  • protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go (4 hunks)
  • protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go (2 hunks)
  • protocol/daemons/pricefeed/client/types/mutable_market_config_test.go (2 hunks)
  • protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go
  • protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go
🔇 Additional comments (5)
protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go (2)

5-6: LGTM: Clean import organization

The removal of duplicate import and proper spacing follows Go style conventions.


39-41: LGTM: Improved deep copy verification

The use of NotSame to compare pointer addresses, combined with Equal to verify content, provides a more accurate test of deep copy behavior. This ensures that:

  1. The copy is a distinct object in memory (different pointer)
  2. The copied content is identical (equal values)
protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go (3)

7-8: LGTM! Import organization looks good.

The reorganization of imports improves readability by properly grouping the daemon types import.


214-214: LGTM! Improved pointer comparison assertions.

The changes correctly test that getTaskLoopDefinition returns a new copy of the mutable config rather than the same instance, which is crucial for thread safety in concurrent operations.

Also applies to: 224-224


252-252: LGTM! Consistent pointer comparison assertion.

The change aligns with the previous test function's assertions, ensuring proper pointer comparison for thread safety validation in the multi-market exchange scenario.

@@ -18,7 +19,7 @@ func TestCopy(t *testing.T) {

mmcCopy := mmc.Copy()

require.NotSame(t, mmc, mmcCopy)
require.NotSame(t, &mmc, &mmcCopy)
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

Fix incorrect pointer comparison in TestCopy

The current change introduces a bug in the pointer comparison. Since mmc is already a pointer (*types.MutableMarketConfig), taking its address with & is incorrect and will compare the addresses of the pointer variables rather than the actual object addresses.

Apply this fix:

-	require.NotSame(t, &mmc, &mmcCopy)
+	require.NotSame(t, mmc, mmcCopy)

This ensures we're correctly verifying that the Copy() method creates a new object with different memory address while maintaining the same values.

📝 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
require.NotSame(t, &mmc, &mmcCopy)
require.NotSame(t, mmc, mmcCopy)

@chenyaoy chenyaoy merged commit 5553dc8 into main Nov 26, 2024
23 checks passed
@chenyaoy chenyaoy deleted the chenyao/allow-market-authority-to-remove-markets branch November 26, 2024 19:07
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