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

chore!: clean up tx sim docker usage #3902

Merged
merged 6 commits into from
Sep 25, 2024
Merged

chore!: clean up tx sim docker usage #3902

merged 6 commits into from
Sep 25, 2024

Conversation

cmwaters
Copy link
Contributor

This PR tidies up our docker usage. Namely, it puts our two Dockerfiles in the docker directory, and the txsim one separately in the docker/txsim folder. It also cleans up the indirection with the flags so our e2e tests can pass them directly.

@cmwaters cmwaters marked this pull request as ready for review September 25, 2024 19:25
@cmwaters cmwaters requested a review from a team as a code owner September 25, 2024 19:25
@cmwaters cmwaters requested review from rootulp and ninabarbakadze and removed request for a team September 25, 2024 19:25
Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several changes across multiple files, primarily focusing on the restructuring of Dockerfile paths and the introduction of a new entry point script for the txsim application. It updates the Dockerfile paths in workflow files and the Makefile, adds a new input parameter for linting, modifies the Dockerfile for txsim, and changes command-line argument formatting in the CreateTxClient function.

Changes

Files Change Summary
.github/workflows/docker-build-publish.yml, .github/workflows/lint.yml, Makefile Updated Dockerfile paths to reflect a new directory structure; added input parameter for linting.
docker/txsim/Dockerfile, docker/txsim/entrypoint.sh Modified Dockerfile to build txsim instead of celestia-appd; introduced new entry point script.
test/e2e/testnet/txsimNode.go Updated command-line argument formatting in CreateTxClient for improved clarity.

Possibly related PRs

Suggested labels

external

Suggested reviewers

  • staheri14
  • evan-forbes
  • rootulp

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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.

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.

@celestia-bot celestia-bot requested a review from a team September 25, 2024 19:32
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 (2)
docker/txsim/Dockerfile (1)

Line range hint 1-22: LGTM! Good updates to focus on txsim and improve dependencies.

The changes in this segment align well with the PR objectives. The shift from 'celestia-appd' to 'txsim' is consistent, and the updates to Go (1.22.6) and Alpine (3.19) versions are good practices for security and performance.

Consider adding a comment explaining the purpose of the txsim binary for better documentation. For example:

 # Stage 1: generate txsim binary
+# txsim is used for transaction simulation in the Celestia network
 FROM --platform=$BUILDPLATFORM docker.io/golang:1.22.6-alpine3.19 as builder
test/e2e/testnet/txsimNode.go (1)

69-74: Improved clarity with descriptive flag names

The changes to the argument formatting are a significant improvement. The use of long, descriptive flag names (-grpc-endpoint, -poll-time, -blob, -blob-amounts, -blob-sizes) enhances code readability and maintainability. This aligns well with the PR objective of cleaning up flag usage and addressing indirection.

Minor formatting suggestion for consistency

For consistency, consider removing the space after the value in the -seed flag argument:

-		fmt.Sprintf("-seed %d ", seed),
+		fmt.Sprintf("-seed %d", seed),

This would make it consistent with the formatting of the other flag arguments.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 10711c5 and 29ade51.

📒 Files selected for processing (7)
  • .github/workflows/docker-build-publish.yml (2 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • Makefile (3 hunks)
  • docker/txsim.sh (0 hunks)
  • docker/txsim/Dockerfile (3 hunks)
  • docker/txsim/entrypoint.sh (1 hunks)
  • test/e2e/testnet/txsimNode.go (1 hunks)
💤 Files not reviewed due to no reviewable changes (1)
  • docker/txsim.sh
🧰 Additional context used
Shellcheck
docker/txsim/entrypoint.sh

[error] 4-4: Argument mixes string and array. Use * or separate argument.

(SC2145)


[error] 7-7: Double quote array expansions to avoid re-splitting elements.

(SC2068)

🔇 Additional comments not posted (13)
docker/txsim/entrypoint.sh (2)

1-2: LGTM: Proper shebang and good use of whitespace.

The shebang is correctly set for a Bash script, and the empty line improves readability.


1-7: LGTM: Entrypoint script is well-structured.

This entrypoint script effectively logs the command being executed and then runs the txsim binary with all provided arguments. It serves its purpose well as a Docker entrypoint.

After applying the suggested fixes for argument handling, the script will be robust and handle all input scenarios correctly.

🧰 Tools
Shellcheck

[error] 4-4: Argument mixes string and array. Use * or separate argument.

(SC2145)


[error] 7-7: Double quote array expansions to avoid re-splitting elements.

(SC2068)

.github/workflows/docker-build-publish.yml (2)

36-36: LGTM! Txsim Dockerfile path updated correctly.

The change from docker/Dockerfile_txsim to docker/txsim/Dockerfile aligns with the PR objective of moving the txsim Dockerfile to a separate subdirectory. This further improves the project's organization and follows a more conventional naming pattern for Dockerfiles.

Let's verify if this change is consistent across the repository:

#!/bin/bash
# Description: Check for any remaining references to the old txsim Dockerfile path and confirm the new path

# Test: Search for references to the old txsim Dockerfile path
echo "Searching for old txsim Dockerfile references:"
rg --type yaml --type dockerfile 'Dockerfile_txsim' -l

# Test: Confirm the existence of the new txsim Dockerfile
echo "Checking if the new txsim Dockerfile exists:"
ls docker/txsim/Dockerfile

26-26: LGTM! Dockerfile path updated correctly.

The change from Dockerfile to docker/Dockerfile aligns with the PR objective of relocating Dockerfiles to a dedicated docker directory. This improves the project's organization.

Let's verify if this change is consistent across the repository:

docker/txsim/Dockerfile (4)

Line range hint 24-41: LGTM! Good security practices and environment setup.

The update to Alpine 3.20 is a good practice for security and performance. The user creation with a high UID (10001) is an excellent security measure, preventing potential UID conflicts and reducing security risks. The environment setup appears appropriate for the application.


47-48: LGTM! Correct update to copy the txsim binary.

The change from copying 'celestia-appd' to 'txsim' is consistent with the PR objectives and the changes made in the build stage. The path and destination of the copy command are correct.


50-50: LGTM! Good update to entrypoint script location and naming.

The change from 'txsim.sh' to 'entrypoint.sh' and the updated path reflecting the new docker/txsim directory structure are consistent with the PR objectives. The new naming convention is more standard and clear. The ownership is correctly set to the celestia user, maintaining proper security practices.


Line range hint 52-59: LGTM! Final configuration looks good, but clarification needed on network requirements.

The user setup, working directory, and entrypoint configuration remain correct and follow good practices.

However, I noticed that the EXPOSE instruction for ports has been removed. Could you please clarify if this is intentional and if there are any changes to the network requirements for the txsim container? If the container no longer needs to expose any ports, this change is fine. Otherwise, we might need to add back the necessary EXPOSE instructions.

To verify the network requirements, you can run the following command:

✅ Verification successful

Verified: EXPOSE instruction removal is acceptable.

The removal of the EXPOSE instruction in the docker/txsim/Dockerfile does not impact the txsim container's functionality. The shell script outputs indicate no network-related dependencies necessitating exposed ports for txsim. Therefore, this change is intentional and aligns with the current network requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any network-related configurations in the txsim code or documentation

# Search for port or network-related configurations in txsim code
rg --type go -i '(port|listen|addr|host|network)' $(fd -t f -e go . | grep -i 'txsim')

# Check if there are any mentions of network configurations in README or documentation
rg -i '(port|listen|addr|host|network)' $(fd -t f -e md . | grep -i 'readme\|doc')

Length of output: 65002

Makefile (5)

86-86: LGTM: Dockerfile path updated correctly.

The change to use docker/Dockerfile aligns with the PR objective of relocating Dockerfiles to a dedicated docker directory. This improves the project's organization.


92-92: LGTM: Consistent Dockerfile path update.

The change to use docker/Dockerfile in the build-ghcr-docker target is consistent with the previous modification and maintains uniformity across Docker-related targets.


109-110: LGTM: Dockerfile linting updated and expanded.

The changes in the lint target are appropriate:

  1. The main Dockerfile path has been correctly updated to docker/Dockerfile.
  2. The addition of linting for docker/txsim/Dockerfile is a good practice, ensuring code quality for all Docker configurations.

These modifications align well with the PR objectives and improve overall project consistency.


Line range hint 86-190: Overall assessment: Docker-related changes improve project organization.

The modifications to Dockerfile paths across various targets in the Makefile (build-docker, build-ghcr-docker, lint, and txsim-build-docker) consistently reflect the relocation of Dockerfiles to the docker directory and the docker/txsim subdirectory. These changes align well with the PR objectives and enhance the project's directory structure.

Key improvements:

  1. Consistent use of docker/Dockerfile for the main Dockerfile.
  2. Addition of linting for the txsim Dockerfile.
  3. Proper relocation of the txsim Dockerfile to docker/txsim/Dockerfile.

These changes contribute to better organization and maintainability of the project's Docker-related components.


190-190: LGTM: txsim Dockerfile path updated correctly.

The change to use docker/txsim/Dockerfile aligns with the PR objective of relocating the txsim Dockerfile to a separate subdirectory. This improves the organization of Docker-related files.

Let's verify the existence of the new Dockerfile:

✅ Verification successful

Verified: txsim Dockerfile exists at the updated path.

The Dockerfile has been successfully relocated to docker/txsim/Dockerfile, aligning with the PR objectives and improving project organization.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence of the new txsim Dockerfile
if [ -f "docker/txsim/Dockerfile" ]; then
    echo "docker/txsim/Dockerfile exists."
else
    echo "Error: docker/txsim/Dockerfile not found."
    exit 1
fi

Length of output: 109

echo "/bin/txsim $@"
echo ""

exec /bin/txsim $@
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

Quote arguments in exec command.

The current usage of $@ in the exec command may lead to unexpected behavior if arguments contain spaces or special characters.

Apply this diff to fix the argument handling:

-exec /bin/txsim $@
+exec /bin/txsim "$@"

This change ensures that all arguments are properly passed to the txsim binary, preserving spaces and special characters.

📝 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
exec /bin/txsim $@
exec /bin/txsim "$@"
🧰 Tools
Shellcheck

[error] 7-7: Double quote array expansions to avoid re-splitting elements.

(SC2068)

Comment on lines +3 to +6
echo "Starting txsim with command:"
echo "/bin/txsim $@"
echo ""

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 argument handling in echo statement.

The current usage of $@ in the echo statement may lead to unexpected behavior if arguments contain spaces or special characters.

Apply this diff to fix the argument handling:

-echo "/bin/txsim $@"
+echo "/bin/txsim $*"

This change ensures that all arguments are properly represented as a single string when echoed.

📝 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
echo "Starting txsim with command:"
echo "/bin/txsim $@"
echo ""
echo "Starting txsim with command:"
echo "/bin/txsim $*"
echo ""
🧰 Tools
Shellcheck

[error] 4-4: Argument mixes string and array. Use * or separate argument.

(SC2145)

Comment on lines +34 to +35
with:
dockerfile: "docker/Dockerfile"
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

Additional Dockerfile Detected for Linting

The workflow currently lints docker/Dockerfile. However, an additional Dockerfile docker/txsim/Dockerfile was found. To ensure comprehensive linting, please update the workflow to include this Dockerfile.

  • Update the hadolint job to include docker/txsim/Dockerfile.
  • Consider using a loop or multiple with clauses if supported by the workflow configuration.
🔗 Analysis chain

LGTM! Consider linting additional Dockerfiles.

The change correctly updates the Dockerfile path for the hadolint job, aligning with the PR objective of relocating Dockerfiles to a dedicated docker directory. This ensures that the linting process targets the correct Dockerfile after the relocation.

To ensure comprehensive linting coverage, please verify if there are other Dockerfiles (such as the one for txsim) that also need linting. If so, consider adding them to this workflow or creating separate linting jobs for them.

Run the following script to check for additional Dockerfiles:

If additional Dockerfiles are found, consider updating the workflow to lint them as well.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all Dockerfiles in the repository

# Test: Search for Dockerfiles. Expect: List of all Dockerfiles in the repository.
fd Dockerfile

Length of output: 57

@cmwaters cmwaters merged commit 32fc690 into main Sep 25, 2024
32 checks passed
@cmwaters cmwaters deleted the cal/tx-sim-docker branch September 25, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants