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

add(Docker): Docs for mining with Docker #7179

Merged
merged 3 commits into from
Jul 25, 2023
Merged

add(Docker): Docs for mining with Docker #7179

merged 3 commits into from
Jul 25, 2023

Conversation

upbqdn
Copy link
Member

@upbqdn upbqdn commented Jul 9, 2023

Motivation

Close #6611.

Depends-On: #7200 and #7231.

Solution

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

Follow Up Work

#7008.

@upbqdn upbqdn added A-docs Area: Documentation A-devops Area: Pipelines, CI/CD and Dockerfiles C-enhancement Category: This is an improvement P-Medium ⚡ labels Jul 9, 2023
@upbqdn upbqdn requested a review from a team as a code owner July 9, 2023 18:07
@upbqdn upbqdn self-assigned this Jul 9, 2023
@upbqdn upbqdn requested review from dconnolly and removed request for a team July 9, 2023 18:07
@github-actions github-actions bot added the C-feature Category: New features label Jul 9, 2023
@upbqdn upbqdn changed the title Add docs for mining with Docker add(Docker): Docs for mining with Docker Jul 9, 2023
@upbqdn
Copy link
Member Author

upbqdn commented Jul 9, 2023

We'll need to test the commands in the docs when we do the next release. It would be good if we could test them before the release, but I don't know how.

@teor2345
Copy link
Contributor

teor2345 commented Jul 9, 2023

We'll need to test the commands in the docs when we do the next release. It would be good if we could test them before the release, but I don't know how.

You can test the commands on the release image in the CD builds, they use the runtime target:

dockerfile_target: runtime

It seems like you'll want to test against us-docker.pkg.dev/zfnd-dev-zebra/zebra/zebrad:pr-7178, which is from:
https://github.com/ZcashFoundation/zebra/actions/runs/5501189414/jobs/10024596480?pr=7178#step:10:1985
(the CD build job on PR #7178).

But it doesn't use the getblocktemplate-rpcs feature, so I guess we could add a features list to the manual deployment and build arguments?

on:
workflow_dispatch:
inputs:
network:
default: 'Mainnet'
description: 'Network to deploy: Mainnet or Testnet'
required: true

build:
name: Build CD Docker
uses: ./.github/workflows/build-docker-image.yml
with:
dockerfile_path: ./docker/Dockerfile
dockerfile_target: runtime
image_name: zebrad

Or we could add a manual release trigger and tag it with the branch name. But that seems riskier, we could accidentally publish something that looks like a real release, and users would use it. (It might also update the latest tag and get used automatically by Docker.)

Copy link
Member

@gustavovalverde gustavovalverde left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Have these commands been tested against the Docker image changes yet?

You can build Docker images locally if that helps?

@gustavovalverde
Copy link
Member

I tested this locally, as a result of executing the commands in this PR I got these configurations:

Running docker run -e MINER_ADDRESS="t27eWDgjFYJGVXmzrXeVjnb5J3uXDM9xH9v" -p 18232:18232 zfnd/<local_rpc_image>

Creates this zebrad.toml:

[network]
network = "Testnet"
listen_addr = "0.0.0.0"
[state]
cache_dir = "/var/cache/zebrad-cache"
[tracing]
use_color = false
[mining]
miner_address = "t27eWDgjFYJGVXmzrXeVjnb5J3uXDM9xH9v"

Running docker run -e NETWORK="Mainnet" -e RPC_PORT="8232" -e MINER_ADDRESS="t1XhG6pT9xRqRQn3BHP7heUou1RuYrbcrCc" -p 8232:8232 zfnd/zebra:<local_rpc_image>

Creates this zebrad.toml:

[network]
network = "Mainnet"
listen_addr = "0.0.0.0"
[state]
cache_dir = "/var/cache/zebrad-cache"
[rpc]
listen_addr = "0.0.0.0:8232"
[tracing]
use_color = false
[mining]
miner_address = "t1XhG6pT9xRqRQn3BHP7heUou1RuYrbcrCc"

@teor2345
Copy link
Contributor

I tested this locally, as a result of executing the commands in this PR I got these configurations:

It looks like a RPC address is missing from this config, maybe it needs some parts of PR #7175? Or the getblocktemplate-rpcs feature?

Copy link
Contributor

@mpguerra mpguerra left a comment

Choose a reason for hiding this comment

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

Content looks good to me. I appreciate the clear examples.

I have not run any of the commands so I don't know whether they work or not which is why I'm not explicitly approving this PR.

@upbqdn
Copy link
Member Author

upbqdn commented Jul 11, 2023

I tested this locally, ...

I think testing the commands locally doesn't suffice. We need to test them against the images we publish.

It looks like a RPC address is missing from this config, maybe it needs some parts of PR #7175? Or the getblocktemplate-rpcs feature?

Yes, this is also true for the currently published images. #7175 attempts to fix it. I tried describing what the issue is and why the port doesn't propagate to Zebra's config in the PR description.

I don't see how we could leverage the getblocktemplate-rpcs for published images.

@upbqdn
Copy link
Member Author

upbqdn commented Jul 11, 2023

I set #7175 as a blocker for this PR. Let's figure out a proper config for the images, and then test this PR?

@mpguerra
Copy link
Contributor

After speaking with Marek, these instructions won't work until we publish the next release so I'm blocking this on #7136

@arya2 arya2 added do-not-merge Tells Mergify not to merge this PR and removed do-not-merge Tells Mergify not to merge this PR labels Jul 21, 2023
Copy link
Member

@gustavovalverde gustavovalverde left a comment

Choose a reason for hiding this comment

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

Minimum changes to get it in

book/src/user/mining-docker.md Outdated Show resolved Hide resolved
book/src/user/mining-docker.md Outdated Show resolved Hide resolved
@mpguerra
Copy link
Contributor

Did we do the required tests to ensure that these instructions will work?

@gustavovalverde
Copy link
Member

gustavovalverde commented Jul 24, 2023

Did we do the required tests to ensure that these instructions will work?

@mpguerra With the required changes from my review, it's working.

@upbqdn
Copy link
Member Author

upbqdn commented Jul 25, 2023

Did we do the required tests to ensure that these instructions will work?

I didn't, and we ended up with images with Mainnet enabled by default which isn't what we intended. However, after thinking about it, I think this change is actually suitable because there will be no API change when we start officially supporting mining, and I don't really see how having Testnet enabled by default protects from wasting the miner's resources, which is the risk we wanted to avoid. The reason is that to waste resources, the miner has to use a significant mining power for an extended period of time, and by that time, they must know whether they're on Mainnet or Testnet.

@gustavovalverde
Copy link
Member

The reason is that to waste resources, the miner has to use a significant mining power for an extended period of time, and by that time, they must know whether they're on Mainnet or Testnet.

@upbqdn when I tested this the first time I used this command, which defaults to Mainnet:

docker run -e MINER_ADDRESS="t27eWDgjFYJGVXmzrXeVjnb5J3uXDM9xH9v" -p 18232:18232 zfnd/zebra:v1.1.0.experimental

And the application panicked with the following error:

The application panicked (crashed).
Message:  assertion failed: `(left == right)`
  left: `Testnet`,
 right: `Mainnet`: incorrect miner address config: t27eWDgjFYJGVXmzrXeVjnb5J3uXDM9xH9v network.network Mainnet and miner address network Testnet must match
Location: /opt/zebrad/zebra-rpc/src/server.rs:158

From my perspective, I doubt the user will be able to use the wrong Network, but I might not be considering other use-cases.

@upbqdn
Copy link
Member Author

upbqdn commented Jul 25, 2023

From my perspective, I doubt the user will be able to use the wrong Network, but I might not be considering other use-cases.

The issue isn't related to using an incompatible address; Zebra will always catch that. Our concern was that since we didn't have the means to test some of the mining functionality on Mainnet, users might run into bugs when running the image on Mainnet out of the box. However, as you pointed out, the image won't even start out of the box. Users have to first provide an address, which is either for Mainnet or Testnet, so they have to implicitly pick the network anyway. It's just a bit less of a hassle to start on Mainnet now, which I think is good.

Copy link
Member

@gustavovalverde gustavovalverde left a comment

Choose a reason for hiding this comment

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

Tested and LGTM!

@upbqdn
Copy link
Member Author

upbqdn commented Jul 25, 2023

I refactored almost all of the docs.

@upbqdn
Copy link
Member Author

upbqdn commented Jul 25, 2023

The examples work for me as well.

@upbqdn upbqdn dismissed teor2345’s stale review July 25, 2023 19:23

The issues raised in the review were addressed.

mergify bot added a commit that referenced this pull request Jul 25, 2023
@mergify mergify bot merged commit d725d29 into main Jul 25, 2023
67 checks passed
@mergify mergify bot deleted the docker-mining-docs branch July 25, 2023 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devops Area: Pipelines, CI/CD and Dockerfiles A-docs Area: Documentation C-enhancement Category: This is an improvement C-feature Category: New features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document how to switch from Testnet to Mainnet in Docker images
5 participants