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

fix: avoid simd not exist error when make localnet-build-env #23164

Merged
merged 2 commits into from
Jan 3, 2025

Conversation

mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Jan 3, 2025

Description

Closes: #23163


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Chores
    • Updated Docker configuration to use a new binary version in the container build process.

@mmsqe mmsqe requested a review from a team as a code owner January 3, 2025 03:02
Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

Warning

Rate limit exceeded

@mmsqe has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 42 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between bcc8b6b and 986449c.

📒 Files selected for processing (1)
  • contrib/images/simd-dlv/Dockerfile (2 hunks)
📝 Walkthrough

Walkthrough

The pull request modifies multiple Dockerfiles to update the binary being copied from the build environment. Specifically, the COPY instruction has been changed to copy simdv2 instead of simd when placing the binary into the appropriate locations in the final images. This change ensures that the correct binary is used in the final Docker images, addressing a potential issue with binary selection in the build process.

Changes

File Change Summary
Dockerfile Updated binary copy command from /build/simd to /build/simdv2
contrib/images/simd-dlv/Dockerfile Updated binary copy command from /work/build/simd to /work/build/simdv2
contrib/images/simd-env/Dockerfile Updated binary copy command from /work/build/simd to /work/build/simdv2

Assessment against linked issues

Objective Addressed Explanation
Copy simdv2 binary instead of simd [#23163]

Possibly related PRs

  • fix(crypto): bls compilation #22717: The changes in this PR also involve updating the Dockerfile to copy the simdv2 binary instead of simd, indicating a direct relation to the main PR's modifications in the Dockerfile.

Suggested Labels

backport/v0.52.x

Suggested Reviewers

  • auricom
  • julienrbrt
  • kocubinski
  • tac0turtle

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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 comments (1)
Dockerfile (1)

Line range hint 1-13: Update documentation to reflect binary name change

The comments at the top of the Dockerfile still reference simd in the usage examples, but the binary being copied is now simdv2. This inconsistency should be addressed.

Apply this diff to update the documentation:

# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simapp:/root/.simapp simapp simd init test-chain
-# TODO: need to set validator in genesis so start runs
-# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simapp:/root/.simapp simapp simd start
+# TODO: need to set validator in genesis so start runs (using simdv2 binary)
+# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simapp:/root/.simapp simapp simd start
🧹 Nitpick comments (1)
Dockerfile (1)

71-71: Consider using ARG/ENV for binary name

To improve maintainability and reduce the risk of inconsistencies, consider parameterizing the binary name.

Apply this diff to make the binary name configurable:

+# Define binary name as build argument with default value
+ARG BINARY_NAME=simdv2
+
-COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/simdv2 /usr/bin/simd
+COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/${BINARY_NAME} /usr/bin/simd
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d544c1 and cce12bc.

📒 Files selected for processing (1)
  • Dockerfile (1 hunks)
🔇 Additional comments (1)
Dockerfile (1)

71-71: Verify the build output binary name

The change from simd to simdv2 addresses the SIMD not exist error, but we should verify that the build process actually produces this binary name.

✅ Verification successful

Binary name change is correct and consistent with build configuration

The change from simd to simdv2 in the Dockerfile is verified to be correct based on the following evidence:

  1. The build configuration in scripts/build/build.mk explicitly sets APPNAME = simdv2 when the v2 build option is enabled:
ifeq (v2,$(findstring v2,$(COSMOS_BUILD_OPTIONS)))
  SIMAPP = simapp/v2
  APPNAME = simdv2
endif
  1. The build options include v2 by default:
COSMOS_BUILD_OPTIONS += ' v2'
  1. The binary is correctly copied to /usr/bin/simd in the Dockerfile, maintaining backward compatibility while using the v2 build output.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the binary name in the build process
# Check if Makefile or build configurations specify the binary name

# Search for binary name in build configurations
rg -A 5 'simdv2' 

# Check Makefile for build targets and binary names
fd -t f "Makefile" --exec cat {} \; | grep -A 5 "build:"

Length of output: 8002


Script:

#!/bin/bash
# Let's verify the build configuration and binary name in more detail

# Check the build configuration in scripts/build/build.mk
cat scripts/build/build.mk

# Check if there are any make targets or configurations that set the binary name
rg -A 5 "APPNAME.*=.*simd"

# Check the Dockerfile build stage to understand the binary build process
cat Dockerfile

Length of output: 7908

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 comments (2)
contrib/images/simd-dlv/Dockerfile (1)

Line range hint 1-1: Fix invalid Go version in base image

The base image golang:1.23-alpine doesn't exist as Go 1.23 hasn't been released yet. The latest stable version is Go 1.21.

-FROM golang:1.23-alpine AS build
+FROM golang:1.21-alpine AS build
contrib/images/simd-env/Dockerfile (1)

Line range hint 1-1: Fix invalid Go version in base image

The base image golang:1.23-alpine doesn't exist as Go 1.23 hasn't been released yet. The latest stable version is Go 1.21.

-FROM golang:1.23-alpine AS build
+FROM golang:1.21-alpine AS build
🧹 Nitpick comments (1)
contrib/images/simd-env/Dockerfile (1)

Line range hint 4-24: Consider optimizing module copying steps

The current approach copies each module's go.mod and go.sum files individually. This could be optimized to reduce the number of layers and improve build time.

-COPY go.mod go.sum /work/
-COPY math/go.mod math/go.sum /work/math/
-COPY api/go.mod api/go.sum /work/api/
-# ... (other module copies)
+COPY go.* /work/
+COPY */go.* /work/
+COPY */*/go.* /work/
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cce12bc and bcc8b6b.

📒 Files selected for processing (3)
  • Dockerfile (1 hunks)
  • contrib/images/simd-dlv/Dockerfile (1 hunks)
  • contrib/images/simd-env/Dockerfile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Dockerfile
🔇 Additional comments (3)
contrib/images/simd-dlv/Dockerfile (1)

30-30: Verify binary name handling in wrapper script

While the binary name has been updated to simdv2, we need to ensure the wrapper script at /usr/bin/wrapper.sh correctly handles this new binary name.

✅ Verification successful

The wrapper script correctly handles the binary name change

The wrapper script is designed to be flexible with binary names through the BINARY environment variable. Specifically:

  • It uses BINARY=/simd/${BINARY:-simd} which means it will use the environment variable if set, or default to simd
  • It includes a helpful error message that explicitly mentions using the BINARY environment variable for custom binary names
  • The script will work with simdv2 when the environment variable is set accordingly
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if wrapper.sh references the binary name
cat contrib/images/simd-dlv/wrapper.sh | grep -A 5 "simd"

Length of output: 782

contrib/images/simd-env/Dockerfile (2)

48-48: Verify binary name handling in wrapper script

While the binary name has been updated to simdv2, we need to ensure the wrapper script at /usr/bin/wrapper.sh correctly handles this new binary name.

✅ Verification successful

Binary name handling in wrapper script is flexible and compatible

The wrapper script is designed to handle different binary names through the BINARY environment variable. The script:

  • Uses a default path of /simd/simd if no specific binary name is provided
  • Allows overriding the binary name through the BINARY environment variable
  • Includes clear error messages if the specified binary is not found

This means the script will work correctly with the new simdv2 binary when:

  • The BINARY environment variable is set to simdv2, or
  • The binary is copied to /simd/simd instead of /simd/simdv2
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if wrapper.sh references the binary name
cat contrib/images/simd-env/wrapper.sh | grep -A 5 "simd"

Length of output: 553


48-48: Verify binary name consistency across codebase

Let's ensure the binary name change is consistent across the entire codebase to prevent any mismatches.

✅ Verification successful

Binary name change is consistent across codebase

Based on the search results, the binary name change from simd to simdv2 is consistently reflected across the codebase, particularly in:

  • Main Dockerfile: COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/simdv2 /usr/bin/simd
  • simd-env Dockerfile: COPY --from=build /work/build/simdv2 /simd/
  • simd-dlv Dockerfile: COPY --from=build /work/build/simdv2 /simd/
  • Build scripts and configurations reference simdv2 appropriately
  • Documentation and test files have been updated to reference simdv2 where needed

The change appears to be part of a v2 upgrade where the binary is built as simdv2 but still installed as simd in the final container images for backward compatibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to both old and new binary names
echo "Searching for 'simd' references:"
rg --type make --type dockerfile 'simd[^v]'

echo -e "\nSearching for 'simdv2' references:"
rg --type make --type dockerfile 'simdv2'

Length of output: 329


Script:

#!/bin/bash
# Search for references to both old and new binary names without file type restrictions
echo "Searching for 'simd' references:"
rg 'simd[^v]'

echo -e "\nSearching for 'simdv2' references:"
rg 'simdv2'

# Also check Dockerfile specifically
echo -e "\nChecking Dockerfiles:"
fd Dockerfile --exec cat {}

Length of output: 64910

@tac0turtle tac0turtle added this pull request to the merge queue Jan 3, 2025
Merged via the queue into cosmos:main with commit 76169e7 Jan 3, 2025
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants