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: use bitcoin core wallet script #3294

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Dec 13, 2024

Use the /opt/wallet.sh script from bitcoin-core-docker. This ensure that the rpc whitelist and credential generation is fully covered by node CI.

We use the admin user in zetae2e since it needs to setup the wallet and mine blocks. We use the smoketest user in zetaclient which is limited to specific RPCs.

Related to zeta-chain/bitcoin-core-docker#16

Summary by CodeRabbit

  • Configuration Updates
    • Updated authentication credentials for Bitcoin RPC in local.yml and localnet.yml.
    • Modified the docker-compose.yml to change the Bitcoin service image and command, and added new environment variables.
  • Bug Fixes
    • Removed outdated command parameters for the Bitcoin service to streamline configuration.

@gartnera gartnera added the no-changelog Skip changelog CI check label Dec 13, 2024
@gartnera gartnera requested a review from a team as a code owner December 13, 2024 17:44
Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

📝 Walkthrough

Walkthrough

This pull request introduces updates to configuration files related to the Zeta application and its local network setup. Specifically, the local.yml and localnet.yml files have modified authentication credentials for the Bitcoin RPC service, changing the user and pass fields to "admin". Additionally, the docker-compose.yml file has been altered to update the Bitcoin service image and command, while also introducing new environment variables for the service. These changes collectively enhance the configuration for accessing the Bitcoin RPC.

Changes

File Change Summary
cmd/zetae2e/config/local.yml Updated rpcs.bitcoin user from "smoketest" to "admin" and pass from "123" to "admin".
cmd/zetae2e/config/localnet.yml Updated rpcs.bitcoin user from "smoketest" to "admin" and pass from "123" to "admin".
contrib/localnet/docker-compose.yml Updated bitcoin service image from ghcr.io/zeta-chain/bitcoin-core-docker:28.0 to ghcr.io/zeta-chain/bitcoin-core-docker:a94b52f. Removed previous command configuration and added new command /opt/wallet.sh. Added environment variables: CHAIN, RPC_USER, RPC_PASSWORD, ADMIN_RPC_USER, ADMIN_RPC_PASSWORD set to regtest, smoketest, 123, admin, admin. Modified eth2 service to include a build context pointing to ./anvil.

Possibly related PRs

Suggested reviewers

  • fbac
  • kingpinXD
  • lumtis
  • skosito
  • brewmaster012
  • swift1337

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. (Experiment)
  • @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.

@gartnera gartnera enabled auto-merge December 13, 2024 17:44
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)
cmd/zetae2e/config/local.yml (1)

96-97: Document the Bitcoin RPC authentication strategy.

The implementation establishes a dual-user authentication system:

  • Admin user (admin:admin) for privileged operations
  • Smoketest user (smoketest:123) for restricted access

Consider adding documentation that explains:

  1. The purpose and scope of each user
  2. Which components should use which credentials
  3. The RPC method restrictions for each user

Also applies to: 98-99, 209-215

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 462fcea and b0c86ea.

📒 Files selected for processing (3)
  • cmd/zetae2e/config/local.yml (1 hunks)
  • cmd/zetae2e/config/localnet.yml (1 hunks)
  • contrib/localnet/docker-compose.yml (1 hunks)
🔇 Additional comments (4)
contrib/localnet/docker-compose.yml (2)

209-215: Review the dual-user RPC authentication setup.

The configuration establishes two sets of credentials:

  1. Admin user (admin:admin) for wallet management and mining
  2. Smoketest user (smoketest:123) for restricted RPC access

This aligns with the PR objectives for separating privileges between wallet setup and client operations.


201-201: Verify the bitcoin-core-docker image tag.

The image tag a94b52f appears to be a commit hash. While this ensures reproducibility, we should verify that this is the intended version.

✅ Verification successful

Bitcoin Core Docker image tag is valid and contains required components

The image tag a94b52f is confirmed to be a valid commit hash (a94b52f0c7b09824da227a4966cf30632f2b8688) in the bitcoin-core-docker repository, and the required wallet.sh script is present at this commit. The image configuration appears to be properly set up for the intended functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the bitcoin-core-docker image tag exists and contains wallet.sh
gh api repos/zeta-chain/bitcoin-core-docker/commits/a94b52f --jq '.sha'

Length of output: 112


Script:

#!/bin/bash
# Check if wallet.sh exists in the repository
gh api repos/zeta-chain/bitcoin-core-docker/contents/wallet.sh?ref=a94b52f --jq '.name'

# Get the commit message to understand the changes
gh api repos/zeta-chain/bitcoin-core-docker/commits/a94b52f --jq '.commit.message'

Length of output: 275

cmd/zetae2e/config/localnet.yml (1)

96-97: Verify the RPC credential usage scope.

The configuration uses the admin credentials (admin:admin). Since this grants full access, verify that this configuration file is only used by components requiring administrative privileges (e.g., wallet setup, mining).

✅ Verification successful

Let me check the usage context in these Dockerfiles to understand if they're related to components requiring administrative access.


Let me check the orchestrator scripts to understand how the config is used.


Let me check the e2e test implementation to understand how these credentials are used.


RPC credentials are appropriately scoped for E2E testing environment

The admin credentials in localnet.yml are used exclusively in the E2E testing environment where:

  • The configuration is only referenced in Dockerfiles for E2E test containers
  • The credentials are used to facilitate automated testing scenarios including wallet setup and blockchain operations
  • The context is isolated to local development and testing environments, not production deployments
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check where localnet.yml is used
rg -l "localnet.yml" | grep -v "test"

Length of output: 106


Script:

#!/bin/bash
# Check contents of the Dockerfiles
echo "=== Dockerfile-localnet ==="
cat Dockerfile-localnet
echo -e "\n=== contrib/localnet/orchestrator/Dockerfile.fastbuild ==="
cat contrib/localnet/orchestrator/Dockerfile.fastbuild

Length of output: 4192


Script:

#!/bin/bash
# Check the orchestrator start script and any related e2e configurations
echo "=== contrib/localnet/orchestrator/start-zetae2e.sh ==="
cat contrib/localnet/orchestrator/start-zetae2e.sh

echo -e "\n=== Looking for zetae2e references ==="
rg -l "zetae2e" --type go

Length of output: 11401


Script:

#!/bin/bash
# Check e2e test implementation
echo "=== cmd/zetae2e/local/test_runner.go ==="
cat cmd/zetae2e/local/test_runner.go

echo -e "\n=== Looking for Bitcoin RPC usage in e2e tests ==="
rg -A 5 "bitcoin.*rpc" cmd/zetae2e/

Length of output: 2340

cmd/zetae2e/config/local.yml (1)

98-99: Verify the RPC credential usage scope.

The configuration uses the admin credentials (admin:admin). Similar to localnet.yml, we should verify that this configuration file is only used by components requiring administrative privileges.

✅ Verification successful

Let me check the usage context of local.yml in these files to understand if it's used appropriately.


Based on the analysis of the files, I can now generate the final response:

RPC credential usage scope is appropriate for local testing environment

The local.yml configuration is exclusively used in development and testing contexts:

  • Used by zetae2e CLI tool for local development testing
  • Referenced in debug and test execution scripts
  • Only used in documentation related to local development
  • The credentials are specifically for a local Bitcoin node in a development environment

The admin credentials are appropriate in this context as they are:

  1. Only used in local development/testing environments
  2. Not used in any production configurations
  3. Part of the standard local testing setup documented in LOCAL_TESTING.md
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check where local.yml is used
rg -l "local.yml" | grep -v "test"

Length of output: 128


Script:

#!/bin/bash
# Check content of files that reference local.yml
echo "=== cmd/zetae2e/README.md ==="
cat cmd/zetae2e/README.md

echo -e "\n=== docs/development/LOCAL_TESTING.md ==="
cat docs/development/LOCAL_TESTING.md

echo -e "\n=== e2e/scripts/debug.sh ==="
cat e2e/scripts/debug.sh

echo -e "\n=== e2e/scripts/run.sh ==="
cat e2e/scripts/run.sh

Length of output: 14797

@gartnera gartnera added this pull request to the merge queue Dec 17, 2024
Merged via the queue into develop with commit 6730285 Dec 17, 2024
49 checks passed
@gartnera gartnera deleted the use-bitcoin-core-wallet-script branch December 17, 2024 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants