From 827599e1aa5d0da8cdc7f22ec7f445f490b7421d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 16:39:02 +0000 Subject: [PATCH 1/6] build(deps): bump the devops group across 1 directory with 6 updates (#8545) Bumps the devops group with 6 updates in the / directory: | Package | From | To | | --- | --- | --- | | [actions/checkout](https://github.com/actions/checkout) | `4.1.4` | `4.1.6` | | [google-github-actions/auth](https://github.com/google-github-actions/auth) | `2.1.2` | `2.1.3` | | [r7kamura/rust-problem-matchers](https://github.com/r7kamura/rust-problem-matchers) | `1.4.0` | `1.5.0` | | [codecov/codecov-action](https://github.com/codecov/codecov-action) | `4.3.0` | `4.4.0` | | [tj-actions/changed-files](https://github.com/tj-actions/changed-files) | `44.3.0` | `44.4.0` | | [reviewdog/action-actionlint](https://github.com/reviewdog/action-actionlint) | `1.44.0` | `1.46.0` | Updates `actions/checkout` from 4.1.4 to 4.1.6 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4.1.4...v4.1.6) Updates `google-github-actions/auth` from 2.1.2 to 2.1.3 - [Release notes](https://github.com/google-github-actions/auth/releases) - [Changelog](https://github.com/google-github-actions/auth/blob/main/CHANGELOG.md) - [Commits](https://github.com/google-github-actions/auth/compare/v2.1.2...v2.1.3) Updates `r7kamura/rust-problem-matchers` from 1.4.0 to 1.5.0 - [Release notes](https://github.com/r7kamura/rust-problem-matchers/releases) - [Commits](https://github.com/r7kamura/rust-problem-matchers/compare/v1.4.0...v1.5.0) Updates `codecov/codecov-action` from 4.3.0 to 4.4.0 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.3.0...v4.4.0) Updates `tj-actions/changed-files` from 44.3.0 to 44.4.0 - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/v44.3.0...v44.4.0) Updates `reviewdog/action-actionlint` from 1.44.0 to 1.46.0 - [Release notes](https://github.com/reviewdog/action-actionlint/releases) - [Commits](https://github.com/reviewdog/action-actionlint/compare/v1.44.0...v1.46.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: google-github-actions/auth dependency-type: direct:production update-type: version-update:semver-patch dependency-group: devops - dependency-name: r7kamura/rust-problem-matchers dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: tj-actions/changed-files dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops - dependency-name: reviewdog/action-actionlint dependency-type: direct:production update-type: version-update:semver-minor dependency-group: devops ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/cd-deploy-nodes-gcp.yml | 8 ++++---- .../workflows/chore-delete-gcp-resources.yml | 8 ++++---- .github/workflows/ci-build-crates.patch.yml | 2 +- .github/workflows/ci-build-crates.yml | 8 ++++---- .github/workflows/ci-coverage.yml | 4 ++-- .github/workflows/ci-lint.yml | 18 ++++++++--------- .github/workflows/ci-unit-tests-docker.yml | 8 ++++---- .github/workflows/ci-unit-tests-os.yml | 20 +++++++++---------- .github/workflows/docs-deploy-firebase.yml | 12 +++++------ .../workflows/docs-dockerhub-description.yml | 2 +- .github/workflows/manual-zcashd-deploy.yml | 4 ++-- .github/workflows/release-crates-io.yml | 4 ++-- .github/workflows/sub-build-docker-image.yml | 6 +++--- .../sub-deploy-integration-tests-gcp.yml | 18 ++++++++--------- .github/workflows/sub-find-cached-disks.yml | 4 ++-- .github/workflows/sub-test-zebra-config.yml | 4 ++-- 16 files changed, 65 insertions(+), 65 deletions(-) diff --git a/.github/workflows/cd-deploy-nodes-gcp.yml b/.github/workflows/cd-deploy-nodes-gcp.yml index fd2c4ee97..a43901977 100644 --- a/.github/workflows/cd-deploy-nodes-gcp.yml +++ b/.github/workflows/cd-deploy-nodes-gcp.yml @@ -203,7 +203,7 @@ jobs: if: ${{ !cancelled() && !failure() && ((github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'release') }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false @@ -226,7 +226,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' @@ -305,7 +305,7 @@ jobs: if: github.event_name == 'workflow_dispatch' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false @@ -328,7 +328,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' diff --git a/.github/workflows/chore-delete-gcp-resources.yml b/.github/workflows/chore-delete-gcp-resources.yml index 75eb376f6..bfaac7685 100644 --- a/.github/workflows/chore-delete-gcp-resources.yml +++ b/.github/workflows/chore-delete-gcp-resources.yml @@ -39,14 +39,14 @@ jobs: contents: 'read' id-token: 'write' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' @@ -107,14 +107,14 @@ jobs: contents: 'read' id-token: 'write' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' diff --git a/.github/workflows/ci-build-crates.patch.yml b/.github/workflows/ci-build-crates.patch.yml index 7712a4f92..eb6a347ff 100644 --- a/.github/workflows/ci-build-crates.patch.yml +++ b/.github/workflows/ci-build-crates.patch.yml @@ -23,7 +23,7 @@ jobs: outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 # Setup Rust with stable toolchain and minimal profile - name: Setup Rust diff --git a/.github/workflows/ci-build-crates.yml b/.github/workflows/ci-build-crates.yml index 6a5e1df9a..24b90e801 100644 --- a/.github/workflows/ci-build-crates.yml +++ b/.github/workflows/ci-build-crates.yml @@ -60,8 +60,8 @@ jobs: outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - uses: actions/checkout@v4.1.4 - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: actions/checkout@v4.1.6 + - uses: r7kamura/rust-problem-matchers@v1.5.0 # Setup Rust with stable toolchain and minimal profile - name: Setup Rust @@ -122,10 +122,10 @@ jobs: matrix: ${{ fromJson(needs.matrix.outputs.matrix) }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Install last version of Protoc uses: arduino/setup-protoc@v3.0.0 diff --git a/.github/workflows/ci-coverage.yml b/.github/workflows/ci-coverage.yml index d80ce9b86..49cc02601 100644 --- a/.github/workflows/ci-coverage.yml +++ b/.github/workflows/ci-coverage.yml @@ -69,7 +69,7 @@ jobs: runs-on: ubuntu-latest-xl steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false @@ -103,4 +103,4 @@ jobs: run: cargo llvm-cov --lcov --no-run --output-path lcov.info - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4.4.0 diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index d3cf44043..bcc9aae6c 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -37,14 +37,14 @@ jobs: rust: ${{ steps.changed-files-rust.outputs.any_changed == 'true' }} workflows: ${{ steps.changed-files-workflows.outputs.any_changed == 'true' }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false fetch-depth: 0 - name: Rust files id: changed-files-rust - uses: tj-actions/changed-files@v44.3.0 + uses: tj-actions/changed-files@v44.4.0 with: files: | **/*.rs @@ -56,7 +56,7 @@ jobs: - name: Workflow files id: changed-files-workflows - uses: tj-actions/changed-files@v44.3.0 + uses: tj-actions/changed-files@v44.4.0 with: files: | .github/workflows/*.yml @@ -69,7 +69,7 @@ jobs: if: ${{ needs.changed-files.outputs.rust == 'true' }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false @@ -119,10 +119,10 @@ jobs: if: ${{ needs.changed-files.outputs.rust == 'true' }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Install last version of Protoc uses: arduino/setup-protoc@v3.0.0 @@ -149,9 +149,9 @@ jobs: needs: changed-files if: ${{ needs.changed-files.outputs.workflows == 'true' }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - name: actionlint - uses: reviewdog/action-actionlint@v1.44.0 + uses: reviewdog/action-actionlint@v1.46.0 with: level: warning fail_on_error: false @@ -166,7 +166,7 @@ jobs: runs-on: ubuntu-latest needs: changed-files steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 - uses: codespell-project/actions-codespell@v2.0 with: only_warn: 1 diff --git a/.github/workflows/ci-unit-tests-docker.yml b/.github/workflows/ci-unit-tests-docker.yml index 9bed872f1..3b44aa455 100644 --- a/.github/workflows/ci-unit-tests-docker.yml +++ b/.github/workflows/ci-unit-tests-docker.yml @@ -121,7 +121,7 @@ jobs: runs-on: ubuntu-latest-xl needs: build steps: - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 @@ -163,7 +163,7 @@ jobs: runs-on: ubuntu-latest needs: build steps: - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 @@ -184,7 +184,7 @@ jobs: runs-on: ubuntu-latest needs: build steps: - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 @@ -205,7 +205,7 @@ jobs: runs-on: ubuntu-latest needs: build steps: - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 diff --git a/.github/workflows/ci-unit-tests-os.yml b/.github/workflows/ci-unit-tests-os.yml index d3f4b369a..8489ee5ef 100644 --- a/.github/workflows/ci-unit-tests-os.yml +++ b/.github/workflows/ci-unit-tests-os.yml @@ -94,10 +94,10 @@ jobs: rust: beta steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Install last version of Protoc uses: arduino/setup-protoc@v3.0.0 @@ -183,10 +183,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 # Setup Rust with stable toolchain and minimal profile - name: Setup Rust @@ -205,10 +205,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Install last version of Protoc uses: arduino/setup-protoc@v3.0.0 @@ -248,10 +248,10 @@ jobs: continue-on-error: ${{ matrix.checks == 'advisories' }} steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Check ${{ matrix.checks }} with features ${{ matrix.features }} uses: EmbarkStudios/cargo-deny-action@v1 @@ -269,10 +269,10 @@ jobs: steps: - name: Checkout git repository - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 # Setup Rust with stable toolchain and minimal profile - name: Setup Rust diff --git a/.github/workflows/docs-deploy-firebase.yml b/.github/workflows/docs-deploy-firebase.yml index 30dbf9e0e..6b0731bef 100644 --- a/.github/workflows/docs-deploy-firebase.yml +++ b/.github/workflows/docs-deploy-firebase.yml @@ -85,11 +85,11 @@ jobs: pull-requests: write steps: - name: Checkout the source code - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Setup mdBook uses: jontze/action-mdbook@v3.0.0 @@ -106,7 +106,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' @@ -139,11 +139,11 @@ jobs: pull-requests: write steps: - name: Checkout the source code - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Install last version of Protoc uses: arduino/setup-protoc@v3.0.0 @@ -165,7 +165,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' diff --git a/.github/workflows/docs-dockerhub-description.yml b/.github/workflows/docs-dockerhub-description.yml index 12cbb94c7..99db7e60f 100644 --- a/.github/workflows/docs-dockerhub-description.yml +++ b/.github/workflows/docs-dockerhub-description.yml @@ -17,7 +17,7 @@ jobs: dockerHubDescription: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false diff --git a/.github/workflows/manual-zcashd-deploy.yml b/.github/workflows/manual-zcashd-deploy.yml index 86340f29d..993ffbe5f 100644 --- a/.github/workflows/manual-zcashd-deploy.yml +++ b/.github/workflows/manual-zcashd-deploy.yml @@ -29,7 +29,7 @@ jobs: id-token: 'write' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false @@ -52,7 +52,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' diff --git a/.github/workflows/release-crates-io.yml b/.github/workflows/release-crates-io.yml index b8136a391..e971b774d 100644 --- a/.github/workflows/release-crates-io.yml +++ b/.github/workflows/release-crates-io.yml @@ -67,10 +67,10 @@ jobs: timeout-minutes: 15 runs-on: ubuntu-latest steps: - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Checkout git repository - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4.1.6 with: persist-credentials: false diff --git a/.github/workflows/sub-build-docker-image.yml b/.github/workflows/sub-build-docker-image.yml index 4a4da58f7..dbf5ef10e 100644 --- a/.github/workflows/sub-build-docker-image.yml +++ b/.github/workflows/sub-build-docker-image.yml @@ -76,10 +76,10 @@ jobs: contents: 'read' id-token: 'write' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 @@ -125,7 +125,7 @@ jobs: - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' diff --git a/.github/workflows/sub-deploy-integration-tests-gcp.yml b/.github/workflows/sub-deploy-integration-tests-gcp.yml index 40ad72fe8..e914ecae9 100644 --- a/.github/workflows/sub-deploy-integration-tests-gcp.yml +++ b/.github/workflows/sub-deploy-integration-tests-gcp.yml @@ -118,11 +118,11 @@ jobs: contents: 'read' id-token: 'write' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false fetch-depth: '2' - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 @@ -150,7 +150,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' @@ -406,11 +406,11 @@ jobs: contents: 'read' id-token: 'write' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false fetch-depth: '2' - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 @@ -450,7 +450,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: workload_identity_provider: '${{ vars.GCP_WIF }}' service_account: '${{ vars.GCP_DEPLOYMENTS_SA }}' @@ -713,11 +713,11 @@ jobs: contents: 'read' id-token: 'write' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false fetch-depth: '2' - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4 @@ -727,7 +727,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: workload_identity_provider: '${{ vars.GCP_WIF }}' service_account: '${{ vars.GCP_DEPLOYMENTS_SA }}' diff --git a/.github/workflows/sub-find-cached-disks.yml b/.github/workflows/sub-find-cached-disks.yml index dca08ddb4..ee0327fea 100644 --- a/.github/workflows/sub-find-cached-disks.yml +++ b/.github/workflows/sub-find-cached-disks.yml @@ -37,7 +37,7 @@ jobs: contents: 'read' id-token: 'write' steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false fetch-depth: 0 @@ -45,7 +45,7 @@ jobs: # Setup gcloud CLI - name: Authenticate to Google Cloud id: auth - uses: google-github-actions/auth@v2.1.2 + uses: google-github-actions/auth@v2.1.3 with: retries: '3' workload_identity_provider: '${{ vars.GCP_WIF }}' diff --git a/.github/workflows/sub-test-zebra-config.yml b/.github/workflows/sub-test-zebra-config.yml index 7cc7982c9..bd7159007 100644 --- a/.github/workflows/sub-test-zebra-config.yml +++ b/.github/workflows/sub-test-zebra-config.yml @@ -38,7 +38,7 @@ jobs: timeout-minutes: 30 runs-on: ubuntu-latest-m steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4.1.6 with: persist-credentials: false @@ -47,7 +47,7 @@ jobs: with: short-length: 7 - - uses: r7kamura/rust-problem-matchers@v1.4.0 + - uses: r7kamura/rust-problem-matchers@v1.5.0 - name: Run ${{ inputs.test_id }} test run: | From 99b017e2a460ec2f6d0227e58ae2a8c9fde93aa1 Mon Sep 17 00:00:00 2001 From: Arya Date: Fri, 17 May 2024 19:06:08 -0400 Subject: [PATCH 2/6] add(consensus): Add a `target_difficulty_limit` field on `testnet::Parameters` (#8518) * Adds a `target_difficulty_limit` field on `testnet::Parameters` * updates test to increment block nonce until finding a block that's below the difficulty threshold * increment the nonce while the difficulty is invalid instead of while the difficulty threshold is invalid * Adds comments --- zebra-chain/src/parameters/network/testnet.rs | 43 ++++++++++++++++++- zebra-chain/src/work/difficulty.rs | 10 ++--- zebra-consensus/src/block.rs | 22 +++++----- zebra-consensus/src/checkpoint.rs | 9 +++- zebra-consensus/src/lib.rs | 3 ++ zebrad/tests/common/regtest.rs | 27 ++++++++---- 6 files changed, 86 insertions(+), 28 deletions(-) diff --git a/zebra-chain/src/parameters/network/testnet.rs b/zebra-chain/src/parameters/network/testnet.rs index 76e7bba2a..58d810e58 100644 --- a/zebra-chain/src/parameters/network/testnet.rs +++ b/zebra-chain/src/parameters/network/testnet.rs @@ -10,6 +10,7 @@ use crate::{ network_upgrade::TESTNET_ACTIVATION_HEIGHTS, Network, NetworkUpgrade, NETWORK_UPGRADES_IN_ORDER, }, + work::difficulty::{ExpandedDifficulty, U256}, }; /// The Regtest NU5 activation height in tests @@ -63,7 +64,7 @@ pub struct ConfiguredActivationHeights { } /// Builder for the [`Parameters`] struct. -#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct ParametersBuilder { /// The name of this network to be used by the `Display` trait impl. network_name: String, @@ -79,6 +80,8 @@ pub struct ParametersBuilder { hrp_sapling_payment_address: String, /// Slow start interval for this network slow_start_interval: Height, + /// Target difficulty limit for this network + target_difficulty_limit: ExpandedDifficulty, /// A flag for disabling proof-of-work checks when Zebra is validating blocks disable_pow: bool, } @@ -102,6 +105,19 @@ impl Default for ParametersBuilder { .parse() .expect("hard-coded hash parses"), slow_start_interval: SLOW_START_INTERVAL, + // Testnet PoWLimit is defined as `2^251 - 1` on page 73 of the protocol specification: + // + // + // `zcashd` converts the PoWLimit into a compact representation before + // using it to perform difficulty filter checks. + // + // The Zcash specification converts to compact for the default difficulty + // filter, but not for testnet minimum difficulty blocks. (ZIP 205 and + // ZIP 208 don't specify this conversion either.) See #1277 for details. + target_difficulty_limit: ExpandedDifficulty::from((U256::one() << 251) - 1) + .to_compact() + .to_expanded() + .expect("difficulty limits are valid expanded values"), disable_pow: false, } } @@ -247,6 +263,16 @@ impl ParametersBuilder { self } + /// Sets the target difficulty limit to be used in the [`Parameters`] being built. + // TODO: Accept a hex-encoded String instead? + pub fn with_target_difficulty_limit(mut self, target_difficulty_limit: U256) -> Self { + self.target_difficulty_limit = ExpandedDifficulty::from(target_difficulty_limit) + .to_compact() + .to_expanded() + .expect("difficulty limits are valid expanded values"); + self + } + /// Sets the `disable_pow` flag to be used in the [`Parameters`] being built. pub fn with_disable_pow(mut self, disable_pow: bool) -> Self { self.disable_pow = disable_pow; @@ -263,6 +289,7 @@ impl ParametersBuilder { hrp_sapling_extended_full_viewing_key, hrp_sapling_payment_address, slow_start_interval, + target_difficulty_limit, disable_pow, } = self; Parameters { @@ -274,6 +301,7 @@ impl ParametersBuilder { hrp_sapling_payment_address, slow_start_interval, slow_start_shift: Height(slow_start_interval.0 / 2), + target_difficulty_limit, disable_pow, } } @@ -285,7 +313,7 @@ impl ParametersBuilder { } /// Network consensus parameters for test networks such as Regtest and the default Testnet. -#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Parameters { /// The name of this network to be used by the `Display` trait impl. network_name: String, @@ -307,6 +335,8 @@ pub struct Parameters { slow_start_interval: Height, /// Slow start shift for this network, always half the slow start interval slow_start_shift: Height, + /// Target difficulty limit for this network + target_difficulty_limit: ExpandedDifficulty, /// A flag for disabling proof-of-work checks when Zebra is validating blocks disable_pow: bool, } @@ -338,6 +368,8 @@ impl Parameters { network_name: "Regtest".to_string(), ..Self::build() .with_genesis_hash(REGTEST_GENESIS_HASH) + // This value is chosen to match zcashd, see: + .with_target_difficulty_limit(U256::from_big_endian(&[0x0f; 32])) .with_disable_pow(true) .with_slow_start_interval(Height::MIN) .with_sapling_hrps( @@ -373,6 +405,7 @@ impl Parameters { hrp_sapling_payment_address, slow_start_interval, slow_start_shift, + target_difficulty_limit, disable_pow, } = Self::new_regtest(None); @@ -383,6 +416,7 @@ impl Parameters { && self.hrp_sapling_payment_address == hrp_sapling_payment_address && self.slow_start_interval == slow_start_interval && self.slow_start_shift == slow_start_shift + && self.target_difficulty_limit == target_difficulty_limit && self.disable_pow == disable_pow } @@ -426,6 +460,11 @@ impl Parameters { self.slow_start_shift } + /// Returns the target difficulty limit for this network + pub fn target_difficulty_limit(&self) -> ExpandedDifficulty { + self.target_difficulty_limit + } + /// Returns true if proof-of-work validation should be disabled for this network pub fn disable_pow(&self) -> bool { self.disable_pow diff --git a/zebra-chain/src/work/difficulty.rs b/zebra-chain/src/work/difficulty.rs index 8c9908b04..8388cd7fb 100644 --- a/zebra-chain/src/work/difficulty.rs +++ b/zebra-chain/src/work/difficulty.rs @@ -100,7 +100,7 @@ pub const INVALID_COMPACT_DIFFICULTY: CompactDifficulty = CompactDifficulty(u32: /// [section 7.7.2]: https://zips.z.cash/protocol/protocol.pdf#difficulty // // TODO: Use NonZeroU256, when available -#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct ExpandedDifficulty(U256); /// A 128-bit unsigned "Work" value. @@ -696,11 +696,11 @@ impl ParameterDifficulty for Network { /// See [`ParameterDifficulty::target_difficulty_limit`] fn target_difficulty_limit(&self) -> ExpandedDifficulty { let limit: U256 = match self { - /* 2^243 - 1 */ + // Mainnet PoWLimit is defined as `2^243 - 1` on page 73 of the protocol specification: + // Network::Mainnet => (U256::one() << 243) - 1, - /* 2^251 - 1 */ - // TODO: Add a `target_difficulty_limit` field to `testnet::Parameters` to return here. (`U256::from_big_endian(&[0x0f].repeat(8))` for Regtest) - Network::Testnet(_params) => (U256::one() << 251) - 1, + // 2^251 - 1 for the default testnet, see `testnet::ParametersBuilder::default`() + Network::Testnet(params) => return params.target_difficulty_limit(), }; // `zcashd` converts the PoWLimit into a compact representation before diff --git a/zebra-consensus/src/block.rs b/zebra-consensus/src/block.rs index ac71542d6..b888e8822 100644 --- a/zebra-consensus/src/block.rs +++ b/zebra-consensus/src/block.rs @@ -176,18 +176,16 @@ where Err(BlockError::MaxHeight(height, hash, block::Height::MAX))?; } - if !network.disable_pow() { - // > The block data MUST be validated and checked against the server's usual - // > acceptance rules (excluding the check for a valid proof-of-work). - // - if request.is_proposal() { - check::difficulty_threshold_is_valid(&block.header, &network, &height, &hash)?; - } else { - // Do the difficulty checks first, to raise the threshold for - // attacks that use any other fields. - check::difficulty_is_valid(&block.header, &network, &height, &hash)?; - check::equihash_solution_is_valid(&block.header)?; - } + // > The block data MUST be validated and checked against the server's usual + // > acceptance rules (excluding the check for a valid proof-of-work). + // + if request.is_proposal() || network.disable_pow() { + check::difficulty_threshold_is_valid(&block.header, &network, &height, &hash)?; + } else { + // Do the difficulty checks first, to raise the threshold for + // attacks that use any other fields. + check::difficulty_is_valid(&block.header, &network, &height, &hash)?; + check::equihash_solution_is_valid(&block.header)?; } // Next, check the Merkle root validity, to ensure that diff --git a/zebra-consensus/src/checkpoint.rs b/zebra-consensus/src/checkpoint.rs index 78527dae7..53432bb1c 100644 --- a/zebra-consensus/src/checkpoint.rs +++ b/zebra-consensus/src/checkpoint.rs @@ -595,7 +595,14 @@ where .ok_or(VerifyCheckpointError::CoinbaseHeight { hash })?; self.check_height(height)?; - if !self.network.disable_pow() { + if self.network.disable_pow() { + crate::block::check::difficulty_threshold_is_valid( + &block.header, + &self.network, + &height, + &hash, + )?; + } else { crate::block::check::difficulty_is_valid(&block.header, &self.network, &height, &hash)?; crate::block::check::equihash_solution_is_valid(&block.header)?; } diff --git a/zebra-consensus/src/lib.rs b/zebra-consensus/src/lib.rs index 97fab5150..8ba8fa3a2 100644 --- a/zebra-consensus/src/lib.rs +++ b/zebra-consensus/src/lib.rs @@ -45,6 +45,9 @@ pub mod error; pub mod router; pub mod transaction; +#[cfg(any(test, feature = "proptest-impl"))] +pub use block::check::difficulty_is_valid; + pub use block::{ subsidy::{ funding_streams::{ diff --git a/zebrad/tests/common/regtest.rs b/zebrad/tests/common/regtest.rs index a14d51b28..b089cb8e8 100644 --- a/zebrad/tests/common/regtest.rs +++ b/zebrad/tests/common/regtest.rs @@ -3,13 +3,14 @@ //! This test will get block templates via the `getblocktemplate` RPC method and submit them as new blocks //! via the `submitblock` RPC method on Regtest. -use std::{net::SocketAddr, time::Duration}; +use std::{net::SocketAddr, sync::Arc, time::Duration}; use color_eyre::eyre::{Context, Result}; use tracing::*; use zebra_chain::{ parameters::{testnet::REGTEST_NU5_ACTIVATION_HEIGHT, Network, NetworkUpgrade}, + primitives::byte_array::increment_big_endian, serialization::ZcashSerialize, }; use zebra_node_services::rpc_client::RpcRequestClient; @@ -44,7 +45,7 @@ pub(crate) async fn submit_blocks_test() -> Result<()> { tokio::time::sleep(Duration::from_secs(30)).await; info!("attempting to submit blocks"); - submit_blocks(rpc_address).await?; + submit_blocks(network, rpc_address).await?; zebrad.kill(false)?; @@ -58,7 +59,7 @@ pub(crate) async fn submit_blocks_test() -> Result<()> { } /// Get block templates and submit blocks -async fn submit_blocks(rpc_address: SocketAddr) -> Result<()> { +async fn submit_blocks(network: Network, rpc_address: SocketAddr) -> Result<()> { let client = RpcRequestClient::new(rpc_address); for height in 1..=NUM_BLOCKS_TO_SUBMIT { @@ -73,10 +74,20 @@ async fn submit_blocks(rpc_address: SocketAddr) -> Result<()> { NetworkUpgrade::Nu5 }; - let block_data = hex::encode( - proposal_block_from_template(&block_template, TimeSource::default(), network_upgrade)? - .zcash_serialize_to_vec()?, - ); + let mut block = + proposal_block_from_template(&block_template, TimeSource::default(), network_upgrade)?; + let height = block + .coinbase_height() + .expect("should have a coinbase height"); + + while !network.disable_pow() + && zebra_consensus::difficulty_is_valid(&block.header, &network, &height, &block.hash()) + .is_err() + { + increment_big_endian(Arc::make_mut(&mut block.header).nonce.as_mut()); + } + + let block_data = hex::encode(block.zcash_serialize_to_vec()?); let submit_block_response = client .text_from_call("submitblock", format!(r#"["{block_data}"]"#)) @@ -84,7 +95,7 @@ async fn submit_blocks(rpc_address: SocketAddr) -> Result<()> { let was_submission_successful = submit_block_response.contains(r#""result":null"#); - if height % 40 == 0 { + if height.0 % 40 == 0 { info!( was_submission_successful, ?block_template, From 1484d3de70e4ca43471842d34fb29c7c3b1ec631 Mon Sep 17 00:00:00 2001 From: Arya Date: Sat, 18 May 2024 08:54:23 -0400 Subject: [PATCH 3/6] Disables several tests on Windows to avoid port conflicts (#8551) --- zebra-grpc/src/tests/snapshot.rs | 1 + zebra-grpc/src/tests/vectors.rs | 1 + .../src/peer_set/initialize/tests/vectors.rs | 2 ++ zebra-rpc/src/server/tests/vectors.rs | 1 + zebrad/tests/acceptance.rs | 14 +++++++++----- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/zebra-grpc/src/tests/snapshot.rs b/zebra-grpc/src/tests/snapshot.rs index 6b81a3c70..4fb589d7a 100644 --- a/zebra-grpc/src/tests/snapshot.rs +++ b/zebra-grpc/src/tests/snapshot.rs @@ -29,6 +29,7 @@ use crate::{ pub const ZECPAGES_SAPLING_VIEWING_KEY: &str = "zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz"; #[tokio::test(flavor = "multi_thread")] +#[cfg(not(target_os = "windows"))] async fn test_grpc_response_data() { let _init_guard = zebra_test::init(); diff --git a/zebra-grpc/src/tests/vectors.rs b/zebra-grpc/src/tests/vectors.rs index b34a8ec8b..9a1bf089d 100644 --- a/zebra-grpc/src/tests/vectors.rs +++ b/zebra-grpc/src/tests/vectors.rs @@ -26,6 +26,7 @@ pub const ZECPAGES_SAPLING_VIEWING_KEY: &str = "zxviews1q0duytgcqqqqpqre26wkl45g /// Test the gRPC methods with mocked responses #[tokio::test(flavor = "multi_thread")] +#[cfg(not(target_os = "windows"))] async fn test_grpc_methods_mocked() { let _init_guard = zebra_test::init(); diff --git a/zebra-network/src/peer_set/initialize/tests/vectors.rs b/zebra-network/src/peer_set/initialize/tests/vectors.rs index c9e0c26fb..57b8f4e89 100644 --- a/zebra-network/src/peer_set/initialize/tests/vectors.rs +++ b/zebra-network/src/peer_set/initialize/tests/vectors.rs @@ -145,6 +145,7 @@ async fn local_listener_unspecified_port_localhost_addr_v6() { /// Test that zebra-network propagates fixed localhost listener ports to the `AddressBook`. #[tokio::test] +#[cfg(not(target_os = "windows"))] async fn local_listener_fixed_port_localhost_addr_v4() { let _init_guard = zebra_test::init(); @@ -161,6 +162,7 @@ async fn local_listener_fixed_port_localhost_addr_v4() { /// Test that zebra-network propagates fixed localhost listener ports to the `AddressBook`. #[tokio::test] +#[cfg(not(target_os = "windows"))] async fn local_listener_fixed_port_localhost_addr_v6() { let _init_guard = zebra_test::init(); diff --git a/zebra-rpc/src/server/tests/vectors.rs b/zebra-rpc/src/server/tests/vectors.rs index 0f4aca010..26e058477 100644 --- a/zebra-rpc/src/server/tests/vectors.rs +++ b/zebra-rpc/src/server/tests/vectors.rs @@ -30,6 +30,7 @@ fn rpc_server_spawn_single_thread() { /// Test that the JSON-RPC server spawns when configured with multiple threads. #[test] +#[cfg(not(target_os = "windows"))] fn rpc_server_spawn_parallel_threads() { rpc_server_spawn(true) } diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index 4993e27b9..2c8c692d4 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -1395,7 +1395,7 @@ fn full_sync_testnet() -> Result<()> { ) } -#[cfg(feature = "prometheus")] +#[cfg(all(feature = "prometheus", not(target_os = "windows")))] #[tokio::test] async fn metrics_endpoint() -> Result<()> { use hyper::Client; @@ -1451,7 +1451,7 @@ async fn metrics_endpoint() -> Result<()> { Ok(()) } -#[cfg(feature = "filter-reload")] +#[cfg(all(feature = "filter-reload", not(target_os = "windows")))] #[tokio::test] async fn tracing_endpoint() -> Result<()> { use hyper::{Body, Client, Request}; @@ -1549,6 +1549,7 @@ async fn tracing_endpoint() -> Result<()> { /// Test that the JSON-RPC endpoint responds to a request, /// when configured with a single thread. #[tokio::test] +#[cfg(not(target_os = "windows"))] async fn rpc_endpoint_single_thread() -> Result<()> { rpc_endpoint(false).await } @@ -1556,6 +1557,7 @@ async fn rpc_endpoint_single_thread() -> Result<()> { /// Test that the JSON-RPC endpoint responds to a request, /// when configured with multiple threads. #[tokio::test] +#[cfg(not(target_os = "windows"))] async fn rpc_endpoint_parallel_threads() -> Result<()> { rpc_endpoint(true).await } @@ -1623,6 +1625,7 @@ async fn rpc_endpoint(parallel_cpu_threads: bool) -> Result<()> { /// /// https://zcash.github.io/rpc/getblockchaininfo.html #[tokio::test] +#[cfg(not(target_os = "windows"))] async fn rpc_endpoint_client_content_type() -> Result<()> { let _init_guard = zebra_test::init(); if zebra_test::net::zebra_skip_network_tests() { @@ -2148,6 +2151,7 @@ fn lightwalletd_integration_test(test_type: TestType) -> Result<()> { /// It is expected that the first node spawned will get exclusive use of the port. /// The second node will panic with the Zcash listener conflict hint added in #1535. #[test] +#[cfg(not(target_os = "windows"))] fn zebra_zcash_listener_conflict() -> Result<()> { let _init_guard = zebra_test::init(); @@ -2176,7 +2180,7 @@ fn zebra_zcash_listener_conflict() -> Result<()> { /// exclusive use of the port. The second node will panic with the Zcash metrics /// conflict hint added in #1535. #[test] -#[cfg(feature = "prometheus")] +#[cfg(all(feature = "prometheus", not(target_os = "windows")))] fn zebra_metrics_conflict() -> Result<()> { let _init_guard = zebra_test::init(); @@ -2205,7 +2209,7 @@ fn zebra_metrics_conflict() -> Result<()> { /// exclusive use of the port. The second node will panic with the Zcash tracing /// conflict hint added in #1535. #[test] -#[cfg(feature = "filter-reload")] +#[cfg(all(feature = "filter-reload", not(target_os = "windows")))] fn zebra_tracing_conflict() -> Result<()> { let _init_guard = zebra_test::init(); @@ -2944,7 +2948,7 @@ fn scan_task_starts() -> Result<()> { /// Test that the scanner gRPC server starts when the node starts. #[tokio::test] -#[cfg(feature = "shielded-scan")] +#[cfg(all(feature = "shielded-scan", not(target_os = "windows")))] async fn scan_rpc_server_starts() -> Result<()> { use zebra_grpc::scanner::{scanner_client::ScannerClient, Empty}; From e0da45bc1bfdc980d9caf9ffcd3b52d89530162c Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Sat, 18 May 2024 16:59:08 -0300 Subject: [PATCH 4/6] update orchard for zebra-consensus (#8529) --- Cargo.lock | 2 +- zebra-consensus/Cargo.toml | 2 +- zebra-consensus/src/primitives/halo2/tests.rs | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e393f2aad..cd7c77a96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6067,7 +6067,7 @@ dependencies = [ "metrics 0.22.3", "num-integer", "once_cell", - "orchard 0.6.0", + "orchard 0.7.1", "proptest", "proptest-derive", "rand 0.8.5", diff --git a/zebra-consensus/Cargo.toml b/zebra-consensus/Cargo.toml index b2931f1f2..0c869f30d 100644 --- a/zebra-consensus/Cargo.toml +++ b/zebra-consensus/Cargo.toml @@ -58,7 +58,7 @@ tower = { version = "0.4.13", features = ["timeout", "util", "buffer"] } tracing = "0.1.39" tracing-futures = "0.2.5" -orchard = "0.6.0" +orchard = "0.7.0" zcash_proofs = { version = "0.13.0-rc.1", features = ["multicore" ] } wagyu-zcash-parameters = "0.2.0" diff --git a/zebra-consensus/src/primitives/halo2/tests.rs b/zebra-consensus/src/primitives/halo2/tests.rs index 2c2da9c2a..e654adcc5 100644 --- a/zebra-consensus/src/primitives/halo2/tests.rs +++ b/zebra-consensus/src/primitives/halo2/tests.rs @@ -7,7 +7,7 @@ use tower::ServiceExt; use halo2::pasta::{group::ff::PrimeField, pallas}; use orchard::{ - builder::Builder, + builder::{Builder, BundleType}, bundle::Flags, circuit::ProvingKey, keys::{FullViewingKey, Scope, SpendingKey}, @@ -32,8 +32,6 @@ fn generate_test_vectors() { let sk = SpendingKey::from_bytes([7; 32]).unwrap(); let recipient = FullViewingKey::from(&sk).address_at(0u32, Scope::External); - let enable_spends = true; - let enable_outputs = true; let flags = zebra_chain::orchard::Flags::ENABLE_SPENDS | zebra_chain::orchard::Flags::ENABLE_OUTPUTS; @@ -43,17 +41,20 @@ fn generate_test_vectors() { let shielded_data: Vec = (1..=4) .map(|num_recipients| { let mut builder = Builder::new( - Flags::from_parts(enable_spends, enable_outputs), + BundleType::Transactional { + flags: Flags::from_byte(flags.bits()).unwrap(), + bundle_required: true, + }, Anchor::from_bytes(anchor_bytes).unwrap(), ); for _ in 0..num_recipients { builder - .add_recipient(None, recipient, NoteValue::from_raw(note_value), None) + .add_output(None, recipient, NoteValue::from_raw(note_value), None) .unwrap(); } - let bundle: Bundle<_, i64> = builder.build(rng).unwrap(); + let bundle: Bundle<_, i64> = builder.build(rng).unwrap().unwrap().0; let bundle = bundle .create_proof(&proving_key, rng) From 5ca40aa58b9aff32632a59d27de75147836860ec Mon Sep 17 00:00:00 2001 From: Arya Date: Sat, 18 May 2024 16:30:59 -0400 Subject: [PATCH 5/6] add(network): Adds a network magic field to `testnet::Parameters` and the config (#8524) * Adds a `target_difficulty_limit` field on `testnet::Parameters` * updates test to increment block nonce until finding a block that's below the difficulty threshold * increment the nonce while the difficulty is invalid instead of while the difficulty threshold is invalid * Adds comments * moves network Magic type from zebra-network to zebra-chain * Adds `network_magic` field to `testnet::Parameters` and uses the regtest network magic from zcashd * Add a network magic config field for custom testnets * Adds/updates tests * Update zebra-chain/src/parameters/network/testnet.rs * Adds a link to the Regtest network magic in zcashd --------- Co-authored-by: Alfredo Garcia --- zebra-chain/src/parameters.rs | 2 +- zebra-chain/src/parameters/constants.rs | 12 +++ zebra-chain/src/parameters/network.rs | 3 +- zebra-chain/src/parameters/network/magic.rs | 56 ++++++++++++ zebra-chain/src/parameters/network/testnet.rs | 37 +++++++- zebra-network/src/config.rs | 29 ++++-- zebra-network/src/constants.rs | 9 -- zebra-network/src/protocol/external/codec.rs | 6 +- .../protocol/external/codec/tests/vectors.rs | 20 ++++ zebra-network/src/protocol/external/types.rs | 54 +---------- zebra-state/src/service/read/address/utxo.rs | 2 +- zebrad/tests/common/configs/v1.8.0.toml | 91 +++++++++++++++++++ 12 files changed, 240 insertions(+), 81 deletions(-) create mode 100644 zebra-chain/src/parameters/network/magic.rs create mode 100644 zebrad/tests/common/configs/v1.8.0.toml diff --git a/zebra-chain/src/parameters.rs b/zebra-chain/src/parameters.rs index acae466fc..bfe806556 100644 --- a/zebra-chain/src/parameters.rs +++ b/zebra-chain/src/parameters.rs @@ -22,7 +22,7 @@ mod transaction; pub mod arbitrary; pub use genesis::*; -pub use network::{testnet, Network, NetworkKind}; +pub use network::{magic::Magic, testnet, Network, NetworkKind}; pub use network_upgrade::*; pub use transaction::*; diff --git a/zebra-chain/src/parameters/constants.rs b/zebra-chain/src/parameters/constants.rs index cb988c36c..548ad496e 100644 --- a/zebra-chain/src/parameters/constants.rs +++ b/zebra-chain/src/parameters/constants.rs @@ -15,3 +15,15 @@ pub const SLOW_START_INTERVAL: Height = Height(20_000); /// /// This calculation is exact, because `SLOW_START_INTERVAL` is divisible by 2. pub const SLOW_START_SHIFT: Height = Height(SLOW_START_INTERVAL.0 / 2); + +/// Magic numbers used to identify different Zcash networks. +pub mod magics { + use crate::parameters::network::magic::Magic; + + /// The production mainnet. + pub const MAINNET: Magic = Magic([0x24, 0xe9, 0x27, 0x64]); + /// The testnet. + pub const TESTNET: Magic = Magic([0xfa, 0x1a, 0xf9, 0xbf]); + /// The regtest, see + pub const REGTEST: Magic = Magic([0xaa, 0xe8, 0x3f, 0x5f]); +} diff --git a/zebra-chain/src/parameters/network.rs b/zebra-chain/src/parameters/network.rs index b9631e627..dd5801244 100644 --- a/zebra-chain/src/parameters/network.rs +++ b/zebra-chain/src/parameters/network.rs @@ -9,6 +9,7 @@ use crate::{ parameters::NetworkUpgrade, }; +pub mod magic; pub mod testnet; #[cfg(test)] @@ -75,7 +76,7 @@ impl From for NetworkKind { } /// An enum describing the possible network choices. -#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, Serialize)] +#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)] #[serde(into = "NetworkKind")] pub enum Network { /// The production mainnet. diff --git a/zebra-chain/src/parameters/network/magic.rs b/zebra-chain/src/parameters/network/magic.rs new file mode 100644 index 000000000..692a1b8d1 --- /dev/null +++ b/zebra-chain/src/parameters/network/magic.rs @@ -0,0 +1,56 @@ +//! Network `Magic` type and implementation. + +use std::fmt; + +use crate::parameters::{constants::magics, Network}; + +#[cfg(any(test, feature = "proptest-impl"))] +use proptest_derive::Arbitrary; + +/// A magic number identifying the network. +#[derive(Copy, Clone, Eq, PartialEq)] +#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))] +pub struct Magic(pub [u8; 4]); + +impl fmt::Debug for Magic { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_tuple("Magic").field(&hex::encode(self.0)).finish() + } +} + +impl Network { + /// Get the magic value associated to this `Network`. + pub fn magic(&self) -> Magic { + match self { + Network::Mainnet => magics::MAINNET, + Network::Testnet(params) => params.network_magic(), + } + } +} + +#[cfg(test)] +mod proptest { + + use proptest::prelude::*; + + use super::{magics, Magic}; + + #[test] + fn magic_debug() { + let _init_guard = zebra_test::init(); + + assert_eq!(format!("{:?}", magics::MAINNET), "Magic(\"24e92764\")"); + assert_eq!(format!("{:?}", magics::TESTNET), "Magic(\"fa1af9bf\")"); + assert_eq!(format!("{:?}", magics::REGTEST), "Magic(\"aae83f5f\")"); + } + + proptest! { + + #[test] + fn proptest_magic_from_array(data in any::<[u8; 4]>()) { + let _init_guard = zebra_test::init(); + + assert_eq!(format!("{:?}", Magic(data)), format!("Magic({:x?})", hex::encode(data))); + } + } +} diff --git a/zebra-chain/src/parameters/network/testnet.rs b/zebra-chain/src/parameters/network/testnet.rs index 58d810e58..e4f69d4fe 100644 --- a/zebra-chain/src/parameters/network/testnet.rs +++ b/zebra-chain/src/parameters/network/testnet.rs @@ -6,13 +6,15 @@ use zcash_primitives::constants as zp_constants; use crate::{ block::{self, Height}, parameters::{ - constants::{SLOW_START_INTERVAL, SLOW_START_SHIFT}, + constants::{magics, SLOW_START_INTERVAL, SLOW_START_SHIFT}, network_upgrade::TESTNET_ACTIVATION_HEIGHTS, Network, NetworkUpgrade, NETWORK_UPGRADES_IN_ORDER, }, work::difficulty::{ExpandedDifficulty, U256}, }; +use super::magic::Magic; + /// The Regtest NU5 activation height in tests // TODO: Serialize testnet parameters in Config then remove this and use a configured NU5 activation height. #[cfg(any(test, feature = "proptest-impl"))] @@ -64,10 +66,12 @@ pub struct ConfiguredActivationHeights { } /// Builder for the [`Parameters`] struct. -#[derive(Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct ParametersBuilder { /// The name of this network to be used by the `Display` trait impl. network_name: String, + /// The network magic, acts as an identifier for the network. + network_magic: Magic, /// The genesis block hash genesis_hash: block::Hash, /// The network upgrade activation heights for this network, see [`Parameters::activation_heights`] for more details. @@ -91,6 +95,7 @@ impl Default for ParametersBuilder { fn default() -> Self { Self { network_name: "UnknownTestnet".to_string(), + network_magic: magics::TESTNET, // # Correctness // // `Genesis` network upgrade activation height must always be 0 @@ -148,6 +153,20 @@ impl ParametersBuilder { self } + /// Sets the network name to be used in the [`Parameters`] being built. + pub fn with_network_magic(mut self, network_magic: Magic) -> Self { + assert!( + [magics::MAINNET, magics::REGTEST] + .into_iter() + .all(|reserved_magic| network_magic != reserved_magic), + "network magic should be distinct from reserved network magics" + ); + + self.network_magic = network_magic; + + self + } + /// Checks that the provided Sapling human-readable prefixes (HRPs) are valid and unique, then /// sets the Sapling HRPs to be used in the [`Parameters`] being built. pub fn with_sapling_hrps( @@ -283,6 +302,7 @@ impl ParametersBuilder { pub fn finish(self) -> Parameters { let Self { network_name, + network_magic, genesis_hash, activation_heights, hrp_sapling_extended_spending_key, @@ -294,6 +314,7 @@ impl ParametersBuilder { } = self; Parameters { network_name, + network_magic, genesis_hash, activation_heights, hrp_sapling_extended_spending_key, @@ -313,10 +334,12 @@ impl ParametersBuilder { } /// Network consensus parameters for test networks such as Regtest and the default Testnet. -#[derive(Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct Parameters { /// The name of this network to be used by the `Display` trait impl. network_name: String, + /// The network magic, acts as an identifier for the network. + network_magic: Magic, /// The genesis block hash genesis_hash: block::Hash, /// The network upgrade activation heights for this network. @@ -366,6 +389,7 @@ impl Parameters { Self { network_name: "Regtest".to_string(), + network_magic: magics::REGTEST, ..Self::build() .with_genesis_hash(REGTEST_GENESIS_HASH) // This value is chosen to match zcashd, see: @@ -397,6 +421,7 @@ impl Parameters { pub fn is_regtest(&self) -> bool { let Self { network_name, + network_magic, genesis_hash, // Activation heights are configurable on Regtest activation_heights: _, @@ -410,6 +435,7 @@ impl Parameters { } = Self::new_regtest(None); self.network_name == network_name + && self.network_magic == network_magic && self.genesis_hash == genesis_hash && self.hrp_sapling_extended_spending_key == hrp_sapling_extended_spending_key && self.hrp_sapling_extended_full_viewing_key == hrp_sapling_extended_full_viewing_key @@ -425,6 +451,11 @@ impl Parameters { &self.network_name } + /// Returns the network magic + pub fn network_magic(&self) -> Magic { + self.network_magic + } + /// Returns the genesis hash pub fn genesis_hash(&self) -> block::Hash { self.genesis_hash diff --git a/zebra-network/src/config.rs b/zebra-network/src/config.rs index 4c7956887..9ab27cc96 100644 --- a/zebra-network/src/config.rs +++ b/zebra-network/src/config.rs @@ -16,7 +16,7 @@ use tracing::Span; use zebra_chain::parameters::{ testnet::{self, ConfiguredActivationHeights}, - Network, NetworkKind, + Magic, Network, NetworkKind, }; use crate::{ @@ -636,6 +636,7 @@ impl<'de> Deserialize<'de> for Config { { #[derive(Deserialize)] struct DTestnetParameters { + network_magic: Option<[u8; 4]>, network_name: Option, activation_heights: Option, } @@ -718,26 +719,34 @@ impl<'de> Deserialize<'de> for Config { NetworkKind::Testnet, Some(DTestnetParameters { network_name, + network_magic, activation_heights, }), ) => { let mut params_builder = testnet::Parameters::build(); + let should_avoid_default_peers = + network_magic.is_some() || activation_heights.is_some(); + + // Return an error if the initial testnet peers includes any of the default initial Mainnet or Testnet + // peers while activation heights or a custom network magic is configured. + if should_avoid_default_peers + && contains_default_initial_peers(&initial_testnet_peers) + { + return Err(de::Error::custom( + "cannot use default initials peers with incompatible testnet", + )); + } if let Some(network_name) = network_name { params_builder = params_builder.with_network_name(network_name) } + if let Some(network_magic) = network_magic { + params_builder = params_builder.with_network_magic(Magic(network_magic)); + } + // Retain default Testnet activation heights unless there's an empty [testnet_parameters.activation_heights] section. if let Some(activation_heights) = activation_heights { - // Return an error if the initial testnet peers includes any of the default initial Mainnet or Testnet - // peers while activation heights are configured. - // TODO: Check that the network magic is different from the default Mainnet/Testnet network magic too? - if contains_default_initial_peers(&initial_testnet_peers) { - return Err(de::Error::custom( - "cannot use default initial testnet peers with configured activation heights", - )); - } - params_builder = params_builder.with_activation_heights(activation_heights) } diff --git a/zebra-network/src/constants.rs b/zebra-network/src/constants.rs index 4e49698b7..12b18b254 100644 --- a/zebra-network/src/constants.rs +++ b/zebra-network/src/constants.rs @@ -422,15 +422,6 @@ lazy_static! { /// [6.1.3.3 Efficient Resource Usage] pub const DNS_LOOKUP_TIMEOUT: Duration = Duration::from_secs(5); -/// Magic numbers used to identify different Zcash networks. -pub mod magics { - use super::*; - /// The production mainnet. - pub const MAINNET: Magic = Magic([0x24, 0xe9, 0x27, 0x64]); - /// The testnet. - pub const TESTNET: Magic = Magic([0xfa, 0x1a, 0xf9, 0xbf]); -} - #[cfg(test)] mod tests { use zebra_chain::parameters::POST_BLOSSOM_POW_TARGET_SPACING; diff --git a/zebra-network/src/protocol/external/codec.rs b/zebra-network/src/protocol/external/codec.rs index a2a267b23..1c99b3362 100644 --- a/zebra-network/src/protocol/external/codec.rs +++ b/zebra-network/src/protocol/external/codec.rs @@ -13,7 +13,7 @@ use tokio_util::codec::{Decoder, Encoder}; use zebra_chain::{ block::{self, Block}, - parameters::Network, + parameters::{Magic, Network}, serialization::{ sha256d, zcash_deserialize_bytes_external_count, zcash_deserialize_string_external_count, CompactSizeMessage, FakeWriter, ReadZcashExt, SerializationError as Error, @@ -163,7 +163,7 @@ impl Encoder for Codec { let start_len = dst.len(); { let dst = &mut dst.writer(); - dst.write_all(&self.builder.network.magic_value().0[..])?; + dst.write_all(&self.builder.network.magic().0[..])?; dst.write_all(command)?; dst.write_u32::(body_length as u32)?; @@ -389,7 +389,7 @@ impl Decoder for Codec { "read header from src buffer" ); - if magic != self.builder.network.magic_value() { + if magic != self.builder.network.magic() { return Err(Parse("supplied magic did not meet expectations")); } if body_len > self.builder.max_len { diff --git a/zebra-network/src/protocol/external/codec/tests/vectors.rs b/zebra-network/src/protocol/external/codec/tests/vectors.rs index 74f46ec7f..da6b3ce58 100644 --- a/zebra-network/src/protocol/external/codec/tests/vectors.rs +++ b/zebra-network/src/protocol/external/codec/tests/vectors.rs @@ -587,3 +587,23 @@ fn reject_command_and_reason_size_limits() { }; } } + +/// Check that the version test vector deserialization fails when there's a network magic mismatch. +#[test] +fn message_with_wrong_network_magic_returns_error() { + let _init_guard = zebra_test::init(); + let mut codec = Codec::builder().finish(); + let mut bytes = BytesMut::new(); + + codec + .encode(VERSION_TEST_VECTOR.clone(), &mut bytes) + .expect("encoding should succeed"); + + let mut codec = Codec::builder() + .for_network(&Network::new_default_testnet()) + .finish(); + + codec + .decode(&mut bytes) + .expect_err("decoding message with mismatching network magic should return an error"); +} diff --git a/zebra-network/src/protocol/external/types.rs b/zebra-network/src/protocol/external/types.rs index 0e35698a7..f15275d3b 100644 --- a/zebra-network/src/protocol/external/types.rs +++ b/zebra-network/src/protocol/external/types.rs @@ -8,35 +8,11 @@ use zebra_chain::{ }, }; -use crate::constants::{self, magics, CURRENT_NETWORK_PROTOCOL_VERSION}; +use crate::constants::{self, CURRENT_NETWORK_PROTOCOL_VERSION}; #[cfg(any(test, feature = "proptest-impl"))] use proptest_derive::Arbitrary; -/// A magic number identifying the network. -#[derive(Copy, Clone, Eq, PartialEq)] -#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))] -pub struct Magic(pub [u8; 4]); - -impl fmt::Debug for Magic { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_tuple("Magic").field(&hex::encode(self.0)).finish() - } -} -pub(crate) trait ParameterMagic { - fn magic_value(&self) -> Magic; -} -impl ParameterMagic for Network { - /// Get the magic value associated to this `Network`. - fn magic_value(&self) -> Magic { - match self { - Network::Mainnet => magics::MAINNET, - // TODO: Move `Magic` struct definition to `zebra-chain`, add it as a field in `testnet::Parameters`, and return it here. - Network::Testnet(_params) => magics::TESTNET, - } - } -} - /// A protocol version number. #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct Version(pub u32); @@ -168,34 +144,6 @@ impl Default for Tweak { #[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))] pub struct Filter(pub Vec); -#[cfg(test)] -mod proptest { - - use proptest::prelude::*; - - use super::Magic; - - use crate::constants::magics; - - #[test] - fn magic_debug() { - let _init_guard = zebra_test::init(); - - assert_eq!(format!("{:?}", magics::MAINNET), "Magic(\"24e92764\")"); - assert_eq!(format!("{:?}", magics::TESTNET), "Magic(\"fa1af9bf\")"); - } - - proptest! { - - #[test] - fn proptest_magic_from_array(data in any::<[u8; 4]>()) { - let _init_guard = zebra_test::init(); - - assert_eq!(format!("{:?}", Magic(data)), format!("Magic({:x?})", hex::encode(data))); - } - } -} - #[cfg(test)] mod test { use super::*; diff --git a/zebra-state/src/service/read/address/utxo.rs b/zebra-state/src/service/read/address/utxo.rs index d045bd4d3..76a42ac83 100644 --- a/zebra-state/src/service/read/address/utxo.rs +++ b/zebra-state/src/service/read/address/utxo.rs @@ -33,7 +33,7 @@ pub const ADDRESS_HEIGHTS_FULL_RANGE: RangeInclusive = Height(1)..=Heigh /// A convenience wrapper that efficiently stores unspent transparent outputs, /// and the corresponding transaction IDs. -#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct AddressUtxos { /// A set of unspent transparent outputs. utxos: BTreeMap, diff --git a/zebrad/tests/common/configs/v1.8.0.toml b/zebrad/tests/common/configs/v1.8.0.toml new file mode 100644 index 000000000..6c7028371 --- /dev/null +++ b/zebrad/tests/common/configs/v1.8.0.toml @@ -0,0 +1,91 @@ +# Default configuration for zebrad. +# +# This file can be used as a skeleton for custom configs. +# +# Unspecified fields use default values. Optional fields are Some(field) if the +# field is present and None if it is absent. +# +# This file is generated as an example using zebrad's current defaults. +# You should set only the config options you want to keep, and delete the rest. +# Only a subset of fields are present in the skeleton, since optional values +# whose default is None are omitted. +# +# The config format (including a complete list of sections and fields) is +# documented here: +# https://docs.rs/zebrad/latest/zebrad/config/struct.ZebradConfig.html +# +# zebrad attempts to load configs in the following order: +# +# 1. The -c flag on the command line, e.g., `zebrad -c myconfig.toml start`; +# 2. The file `zebrad.toml` in the users's preference directory (platform-dependent); +# 3. The default config. +# +# The user's preference directory and the default path to the `zebrad` config are platform dependent, +# based on `dirs::preference_dir`, see https://docs.rs/dirs/latest/dirs/fn.preference_dir.html : +# +# | Platform | Value | Example | +# | -------- | ------------------------------------- | ---------------------------------------------- | +# | Linux | `$XDG_CONFIG_HOME` or `$HOME/.config` | `/home/alice/.config/zebrad.toml` | +# | macOS | `$HOME/Library/Preferences` | `/Users/Alice/Library/Preferences/zebrad.toml` | +# | Windows | `{FOLDERID_RoamingAppData}` | `C:\Users\Alice\AppData\Local\zebrad.toml` | + +[consensus] +checkpoint_sync = true + +[mempool] +eviction_memory_time = "1h" +tx_cost_limit = 80000000 + +[metrics] + +[mining] +debug_like_zcashd = true + +[network] +cache_dir = true +crawl_new_peer_interval = "1m 1s" +initial_mainnet_peers = [ + "dnsseed.z.cash:8233", + "dnsseed.str4d.xyz:8233", + "mainnet.seeder.zfnd.org:8233", + "mainnet.is.yolo.money:8233", +] +initial_testnet_peers = [] +listen_addr = "0.0.0.0:8233" +max_connections_per_ip = 1 +network = "Testnet" +peerset_initial_target_size = 25 + +[network.testnet_parameters] +network_name = "ConfiguredTestnet_1" +network_magic = [0, 0, 0, 0] + +[network.testnet_parameters.activation_heights] +BeforeOverwinter = 1 +Overwinter = 207_500 +Sapling = 280_000 +Blossom = 584_000 +Heartwood = 903_800 +Canopy = 1_028_500 +NU5 = 1_842_420 + +[rpc] +debug_force_finished_sync = false +parallel_cpu_threads = 0 + +[state] +cache_dir = "cache_dir" +delete_old_database = true +ephemeral = false + +[sync] +checkpoint_verify_concurrency_limit = 1000 +download_concurrency_limit = 50 +full_verify_concurrency_limit = 20 +parallel_cpu_threads = 0 + +[tracing] +buffer_limit = 128000 +force_use_color = false +use_color = true +use_journald = false From ba8def67088774db4cab2f74ad611d7c1fea8547 Mon Sep 17 00:00:00 2001 From: Marek Date: Mon, 20 May 2024 13:59:57 +0200 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Arya --- zebra-rpc/src/methods.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zebra-rpc/src/methods.rs b/zebra-rpc/src/methods.rs index ab120e364..80e2b034c 100644 --- a/zebra-rpc/src/methods.rs +++ b/zebra-rpc/src/methods.rs @@ -1041,8 +1041,7 @@ where // For consistency, this lookup must be performed first, then all the other lookups must // be based on the hash. // - // TODO: If this RPC is called a lot, just get the block header, rather than the whole - // block. + // TODO: If this RPC is called a lot, just get the block header, rather than the whole block. let block = match state .ready() .and_then(|service| service.call(zebra_state::ReadRequest::Block(hash_or_height))) @@ -1066,7 +1065,7 @@ where let height = hash_or_height .height_or_else(|_| block.coinbase_height()) - .expect("block height"); + .expect("verified blocks have a coinbase height"); let time = u32::try_from(block.header.time.timestamp()) .expect("Timestamps of valid blocks always fit into u32.");