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

Update cosmossdk.io/math to v1.4.0 #2588

Merged
merged 3 commits into from
Nov 20, 2024
Merged

Conversation

vincentwschau
Copy link
Contributor

@vincentwschau vincentwschau commented Nov 20, 2024

Changelist

Rationale

Test Plan

N/A

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 mathematical library for enhanced performance and potential bug fixes.
    • Introduced tailored dependency management with specific library versions to align with project requirements.
  • Bug Fixes

    • Improved compatibility and stability through updated dependencies.

@vincentwschau vincentwschau requested a review from a team as a code owner November 20, 2024 18:40
Copy link
Contributor

coderabbitai bot commented Nov 20, 2024

Walkthrough

The changes in this pull request focus on updating the go.mod file for the github.com/dydxprotocol/v4-chain/protocol module. Key modifications include upgrading the cosmossdk.io/math dependency from version v1.3.0 to v1.4.0 and adjusting several replace directives to point to specific commits or forks of various dependencies. This reflects a focused effort on dependency management and ensuring compatibility with newer library versions.

Changes

File Change Summary
protocol/go.mod - Updated cosmossdk.io/math from v1.3.0 to v1.4.0
- Updated github.com/cometbft/cometbft to v0.38.6-0.20241120221529-56316dc17261
- Updated github.com/cosmos/cosmos-sdk to v0.50.6-0.20241120185835-38650041ec4d
- Replaced cosmossdk.io/core with v0.11.0

Possibly related PRs

  • Bump Cosmos SDK version  #2064: This PR updates the github.com/dydxprotocol/cosmos-sdk dependency in go.mod, which is directly related to the changes made in the main PR regarding dependency management for the Cosmos SDK.
  • Bump SDK - Always Reset OE #2531: This PR updates the github.com/cosmos/cosmos-sdk dependency, reflecting changes in the go.mod file that align with the updates made in the main PR.
  • Bump Comet version #2556: This PR updates the github.com/cometbft/cometbft dependency, which is also modified in the main PR, indicating a direct connection in the dependency management changes.

Suggested reviewers

  • jonfung-dydx

🐰 In the meadow, changes bloom bright,
Dependencies dancing, a joyful sight.
From v1.3.0 to v1.4.0 we leap,
Forks and replaces, our promises we keep.
With each update, our code takes flight,
Hopping along, everything feels right! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ec438e5 and bd97d26.

⛔ Files ignored due to path filters (1)
  • protocol/go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • protocol/go.mod (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • protocol/go.mod

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: 0

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

Line range hint 171-177: Documentation update may be needed

The replace directives are well organized into logical blocks with clear TODO comments. However, consider adding a comment about the math version update and its security implications for future reference.

Add a comment before the replace blocks:

+// Updated cosmossdk.io/math to v1.4.0 to address security advisory GHSA-7225-m954-23v7
 replace (
   // Block for dep upgrades that would have been pulled in via Slinky
   ...
 )

Also applies to: 178-189, 190-197

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 80414ac and c67a73e.

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

7-7: Verify the security fix for GHSA-7225-m954-23v7

The update to cosmossdk.io/math v1.4.0 aligns with the PR objective to address the security advisory. Let's verify this version contains the fix.

✅ Verification successful

✅ Security fix confirmed in cosmossdk.io/math v1.4.0

The GitHub Security Advisory data confirms that v1.4.0 properly addresses the high-severity vulnerability (ASA-2024-010) related to mismatched bit-length validation. The vulnerability affects versions <= 1.3.0, and v1.4.0 is explicitly listed as the first patched version.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if v1.4.0 of cosmossdk.io/math addresses the security advisory

# Check the changelog or release notes for v1.4.0
gh api repos/cosmos/cosmos-sdk/releases | jq -r '.[] | select(.tag_name | contains("math/v1.4.0")) | .body'

# Check if there are any known vulnerabilities for this version
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: GO, package: "cosmossdk.io/math") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

Length of output: 728


Line range hint 171-177: Verify dependency compatibility with replaced modules

The replace directives show that several core Cosmos SDK components are using dYdX forks. We should verify that math v1.4.0 is compatible with these forked versions.

✅ Verification successful

Math v1.4.0 dependency is compatible with the codebase

The verification shows that:

  • The codebase is using cosmossdk.io/math v1.4.0 directly
  • The replace directives don't override the math package version
  • The math package is widely used across the codebase in various modules (assets, sending, vault, etc.)
  • No conflicting versions or compatibility issues are found in the replace directives
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential compatibility issues between math v1.4.0 and forked dependencies

# Check go.mod files in forked repos for their math dependency version
for repo in "cosmos-sdk" "cometbft" "iavl"; do
  echo "Checking $repo..."
  gh api repos/dydxprotocol/$repo/contents/go.mod | jq -r '.content' | base64 -d | grep -A 5 "cosmossdk.io/math"
done

Length of output: 818


Script:

#!/bin/bash
# Let's try a different approach to check dependency compatibility
# First, let's check the current go.mod for any replace directives and math version

echo "Checking current go.mod file..."
cat go.mod | grep -A 1 "cosmossdk.io/math"
echo -e "\nChecking replace directives..."
cat go.mod | grep "replace"

# Let's also check if math is used in any critical parts
echo -e "\nChecking usage of math package..."
rg "cosmossdk.io/math" --type go

Length of output: 5173


Script:

#!/bin/bash
# Let's check the protocol/go.mod file specifically since we can see it exists from the imports
echo "Checking protocol/go.mod for math version and replace directives..."
cat protocol/go.mod | grep -A 1 "cosmossdk.io/math"
echo -e "\nChecking replace directives in protocol/go.mod..."
cat protocol/go.mod | grep -A 1 "replace"

Length of output: 910

@@ -470,7 +470,7 @@ replace (
// Use dYdX fork of CometBFT
github.com/cometbft/cometbft => github.com/dydxprotocol/cometbft v0.38.6-0.20241106081823-31609289f401
// Use dYdX fork of Cosmos SDK
github.com/cosmos/cosmos-sdk => github.com/dydxprotocol/cosmos-sdk v0.50.6-0.20241022180223-cc8c850952c5
github.com/cosmos/cosmos-sdk => github.com/dydxprotocol/cosmos-sdk v0.50.6-0.20241120185835-38650041ec4d
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maps to this commit.

@@ -468,9 +468,9 @@ replace (
// Use dYdX fork of Cosmos SDK/store
cosmossdk.io/store => github.com/dydxprotocol/cosmos-sdk/store v1.0.3-0.20240326192503-dd116391188d
// Use dYdX fork of CometBFT
github.com/cometbft/cometbft => github.com/dydxprotocol/cometbft v0.38.6-0.20241106081823-31609289f401
github.com/cometbft/cometbft => github.com/dydxprotocol/cometbft v0.38.6-0.20241120221529-56316dc17261
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maps to this commit.

@vincentwschau vincentwschau merged commit aa9ff70 into main Nov 20, 2024
21 checks passed
@vincentwschau vincentwschau deleted the vincentc/update-cosmos-math branch November 20, 2024 23:02
mergify bot pushed a commit that referenced this pull request Nov 20, 2024
(cherry picked from commit aa9ff70)

# Conflicts:
#	protocol/go.mod
#	protocol/go.sum
vincentwschau added a commit that referenced this pull request Nov 21, 2024
Co-authored-by: vincentwschau <99756290+vincentwschau@users.noreply.github.com>
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.

3 participants