Merge branch 'main' into feature/log-database-size
This commit is contained in:
commit
d3af910028
|
@ -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.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
@ -305,7 +305,7 @@ jobs:
|
|||
if: github.event_name == 'workflow_dispatch'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
contents: 'read'
|
||||
id-token: 'write'
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
@ -107,7 +107,7 @@ jobs:
|
|||
contents: 'read'
|
||||
id-token: 'write'
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
@ -122,7 +122,7 @@ jobs:
|
|||
token_format: 'access_token'
|
||||
|
||||
- name: Login to Google Artifact Registry
|
||||
uses: docker/login-action@v3.0.0
|
||||
uses: docker/login-action@v3.1.0
|
||||
with:
|
||||
registry: us-docker.pkg.dev
|
||||
username: oauth2accesstoken
|
||||
|
|
|
@ -23,7 +23,7 @@ jobs:
|
|||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
|
||||
# Setup Rust with stable toolchain and minimal profile
|
||||
- name: Setup Rust
|
||||
|
|
|
@ -60,7 +60,7 @@ jobs:
|
|||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
||||
# Setup Rust with stable toolchain and minimal profile
|
||||
|
@ -122,7 +122,7 @@ jobs:
|
|||
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
|
|
@ -69,7 +69,7 @@ jobs:
|
|||
runs-on: ubuntu-latest-xl
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
|
|
@ -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.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Rust files
|
||||
id: changed-files-rust
|
||||
uses: tj-actions/changed-files@v42.0.5
|
||||
uses: tj-actions/changed-files@v43.0.0
|
||||
with:
|
||||
files: |
|
||||
**/*.rs
|
||||
|
@ -56,7 +56,7 @@ jobs:
|
|||
|
||||
- name: Workflow files
|
||||
id: changed-files-workflows
|
||||
uses: tj-actions/changed-files@v42.0.5
|
||||
uses: tj-actions/changed-files@v43.0.0
|
||||
with:
|
||||
files: |
|
||||
.github/workflows/*.yml
|
||||
|
@ -69,7 +69,7 @@ jobs:
|
|||
if: ${{ needs.changed-files.outputs.rust == 'true' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
@ -119,7 +119,7 @@ jobs:
|
|||
if: ${{ needs.changed-files.outputs.rust == 'true' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
@ -149,9 +149,9 @@ jobs:
|
|||
needs: changed-files
|
||||
if: ${{ needs.changed-files.outputs.workflows == 'true' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
- name: actionlint
|
||||
uses: reviewdog/action-actionlint@v1.42.0
|
||||
uses: reviewdog/action-actionlint@v1.43.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.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
- uses: codespell-project/actions-codespell@v2.0
|
||||
with:
|
||||
only_warn: 1
|
||||
|
|
|
@ -95,7 +95,7 @@ jobs:
|
|||
rust: beta
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
@ -184,7 +184,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
@ -206,7 +206,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
@ -249,7 +249,7 @@ jobs:
|
|||
continue-on-error: ${{ matrix.checks == 'advisories' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
@ -270,7 +270,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout git repository
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
@ -281,7 +281,7 @@ jobs:
|
|||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=minimal
|
||||
|
||||
- name: Install cargo-machete
|
||||
uses: baptiste0928/cargo-install@v3.0.0
|
||||
uses: baptiste0928/cargo-install@v3.0.1
|
||||
with:
|
||||
crate: cargo-machete
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ jobs:
|
|||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout the source code
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
@ -139,7 +139,7 @@ jobs:
|
|||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout the source code
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
dockerHubDescription:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ jobs:
|
|||
id-token: 'write'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ jobs:
|
|||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
||||
- name: Checkout git repository
|
||||
uses: actions/checkout@v4.1.1
|
||||
uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
@ -85,7 +85,7 @@ jobs:
|
|||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=minimal
|
||||
|
||||
- name: Install cargo-release
|
||||
uses: baptiste0928/cargo-install@v3.0.0
|
||||
uses: baptiste0928/cargo-install@v3.0.1
|
||||
with:
|
||||
crate: cargo-release
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ jobs:
|
|||
contents: 'read'
|
||||
id-token: 'write'
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
||||
|
@ -137,7 +137,7 @@ jobs:
|
|||
access_token_lifetime: 10800s
|
||||
|
||||
- name: Login to Google Artifact Registry
|
||||
uses: docker/login-action@v3.0.0
|
||||
uses: docker/login-action@v3.1.0
|
||||
with:
|
||||
registry: us-docker.pkg.dev
|
||||
username: oauth2accesstoken
|
||||
|
@ -147,7 +147,7 @@ jobs:
|
|||
# We only publish images to DockerHub if a release is not a pre-release
|
||||
# Ref: https://github.com/orgs/community/discussions/26281#discussioncomment-3251177
|
||||
if: ${{ github.event_name == 'release' && !github.event.release.prerelease }}
|
||||
uses: docker/login-action@v3.0.0
|
||||
uses: docker/login-action@v3.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
@ -155,7 +155,7 @@ jobs:
|
|||
# Build and push image to Google Artifact Registry, and possibly DockerHub
|
||||
- name: Build & push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v5.1.0
|
||||
uses: docker/build-push-action@v5.3.0
|
||||
with:
|
||||
target: ${{ inputs.dockerfile_target }}
|
||||
context: .
|
||||
|
|
|
@ -118,7 +118,7 @@ jobs:
|
|||
contents: 'read'
|
||||
id-token: 'write'
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: '2'
|
||||
|
@ -406,7 +406,7 @@ jobs:
|
|||
contents: 'read'
|
||||
id-token: 'write'
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: '2'
|
||||
|
@ -713,7 +713,7 @@ jobs:
|
|||
contents: 'read'
|
||||
id-token: 'write'
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: '2'
|
||||
|
|
|
@ -37,7 +37,7 @@ jobs:
|
|||
contents: 'read'
|
||||
id-token: 'write'
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
|
|
@ -38,7 +38,7 @@ jobs:
|
|||
timeout-minutes: 30
|
||||
runs-on: ubuntu-latest-m
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.1
|
||||
- uses: actions/checkout@v4.1.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
|
391
Cargo.lock
391
Cargo.lock
|
@ -12,7 +12,7 @@ dependencies = [
|
|||
"arc-swap",
|
||||
"backtrace",
|
||||
"canonical-path",
|
||||
"clap 4.5.1",
|
||||
"clap 4.5.3",
|
||||
"color-eyre",
|
||||
"fs-err",
|
||||
"once_cell",
|
||||
|
@ -79,9 +79,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.7"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
|
||||
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"getrandom 0.2.12",
|
||||
|
@ -239,7 +239,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -250,7 +250,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -281,9 +281,9 @@ dependencies = [
|
|||
"bitflags 1.3.2",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"http 0.2.11",
|
||||
"http-body 0.4.6",
|
||||
"hyper 0.14.28",
|
||||
"itoa",
|
||||
"matchit",
|
||||
"memchr",
|
||||
|
@ -307,8 +307,8 @@ dependencies = [
|
|||
"async-trait",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http 0.2.11",
|
||||
"http-body 0.4.6",
|
||||
"mime",
|
||||
"rustversion",
|
||||
"tower-layer",
|
||||
|
@ -348,6 +348,12 @@ version = "0.21.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
version = "1.0.1"
|
||||
|
@ -409,7 +415,7 @@ dependencies = [
|
|||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
"which",
|
||||
]
|
||||
|
||||
|
@ -776,9 +782,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.1"
|
||||
version = "4.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da"
|
||||
checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
|
@ -786,9 +792,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.1"
|
||||
version = "4.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb"
|
||||
checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
|
@ -798,14 +804,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.0"
|
||||
version = "4.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47"
|
||||
checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f"
|
||||
dependencies = [
|
||||
"heck 0.4.1",
|
||||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -826,9 +832,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "color-eyre"
|
||||
version = "0.6.2"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204"
|
||||
checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"color-spantrace",
|
||||
|
@ -963,7 +969,7 @@ dependencies = [
|
|||
"anes",
|
||||
"cast",
|
||||
"ciborium",
|
||||
"clap 4.5.1",
|
||||
"clap 4.5.3",
|
||||
"criterion-plot",
|
||||
"is-terminal",
|
||||
"itertools 0.10.5",
|
||||
|
@ -1066,7 +1072,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1090,7 +1096,7 @@ dependencies = [
|
|||
"codespan-reporting",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1107,7 +1113,7 @@ checksum = "2fa16a70dd58129e4dfffdff535fb1bce66673f7bbeec4a5a1765a504e1ccd84"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1155,7 +1161,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim 0.10.0",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1177,7 +1183,7 @@ checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be"
|
|||
dependencies = [
|
||||
"darling_core 0.20.6",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1250,7 +1256,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1546,7 +1552,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1674,8 +1680,27 @@ dependencies = [
|
|||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"http",
|
||||
"indexmap 2.2.3",
|
||||
"http 0.2.11",
|
||||
"indexmap 2.2.5",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util 0.7.10",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"http 1.1.0",
|
||||
"indexmap 2.2.5",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util 0.7.10",
|
||||
|
@ -1789,6 +1814,12 @@ version = "0.4.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
|
@ -1870,6 +1901,17 @@ dependencies = [
|
|||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "0.4.6"
|
||||
|
@ -1877,7 +1919,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http",
|
||||
"http 0.2.11",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http 1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body-util"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"http 1.1.0",
|
||||
"http-body 1.0.0",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
|
@ -1919,9 +1984,9 @@ dependencies = [
|
|||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"h2 0.3.24",
|
||||
"http 0.2.11",
|
||||
"http-body 0.4.6",
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
|
@ -1933,6 +1998,27 @@ dependencies = [
|
|||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"h2 0.4.3",
|
||||
"http 1.1.0",
|
||||
"http-body 1.0.0",
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
"tokio",
|
||||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-rustls"
|
||||
version = "0.24.2"
|
||||
|
@ -1940,8 +2026,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"http",
|
||||
"hyper",
|
||||
"http 0.2.11",
|
||||
"hyper 0.14.28",
|
||||
"rustls",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
|
@ -1953,12 +2039,32 @@ version = "0.4.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
|
||||
dependencies = [
|
||||
"hyper",
|
||||
"hyper 0.14.28",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"tokio-io-timeout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"http 1.1.0",
|
||||
"http-body 1.0.0",
|
||||
"hyper 1.2.0",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.60"
|
||||
|
@ -2046,9 +2152,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.2.3"
|
||||
version = "2.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177"
|
||||
checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.3",
|
||||
|
@ -2096,9 +2202,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "insta"
|
||||
version = "1.35.1"
|
||||
version = "1.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c985c1bef99cf13c58fade470483d81a2bfe846ebde60ed28cc2dddec2df9e2"
|
||||
checksum = "0a7c22c4d34ef4788c351e971c52bfdfe7ea2766f8c5466bc175dd46e52ac22e"
|
||||
dependencies = [
|
||||
"console",
|
||||
"lazy_static",
|
||||
|
@ -2224,7 +2330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"hyper",
|
||||
"hyper 0.14.28",
|
||||
"jsonrpc-core",
|
||||
"jsonrpc-server-utils",
|
||||
"log",
|
||||
|
@ -2394,9 +2500,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.20"
|
||||
version = "0.4.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||
|
||||
[[package]]
|
||||
name = "lz4-sys"
|
||||
|
@ -2467,9 +2573,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "metrics"
|
||||
version = "0.22.1"
|
||||
version = "0.22.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd71d9db2e4287c3407fa04378b8c2ee570aebe0854431562cdd89ca091854f4"
|
||||
checksum = "2be3cbd384d4e955b231c895ce10685e3d8260c5ccffae898c96c723b0772835"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"portable-atomic",
|
||||
|
@ -2477,19 +2583,22 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "metrics-exporter-prometheus"
|
||||
version = "0.13.1"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bf4e7146e30ad172c42c39b3246864bd2d3c6396780711a1baf749cfe423e21"
|
||||
checksum = "5d58e362dc7206e9456ddbcdbd53c71ba441020e62104703075a69151e38d85f"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"hyper",
|
||||
"indexmap 2.2.3",
|
||||
"base64 0.22.0",
|
||||
"http-body-util",
|
||||
"hyper 1.2.0",
|
||||
"hyper-util",
|
||||
"indexmap 2.2.5",
|
||||
"ipnet",
|
||||
"metrics 0.22.1",
|
||||
"metrics 0.22.3",
|
||||
"metrics-util",
|
||||
"quanta",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2500,7 +2609,7 @@ checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2512,7 +2621,7 @@ dependencies = [
|
|||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
"hashbrown 0.14.3",
|
||||
"metrics 0.22.1",
|
||||
"metrics 0.22.3",
|
||||
"num_cpus",
|
||||
"quanta",
|
||||
"sketches-ddsketch",
|
||||
|
@ -2935,7 +3044,7 @@ dependencies = [
|
|||
"pest_meta",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2956,27 +3065,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
|
||||
dependencies = [
|
||||
"fixedbitset",
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.1.4"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0"
|
||||
checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3"
|
||||
dependencies = [
|
||||
"pin-project-internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "1.1.4"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690"
|
||||
checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3077,7 +3186,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3200,7 +3309,7 @@ dependencies = [
|
|||
"prost",
|
||||
"prost-types",
|
||||
"regex",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
"tempfile",
|
||||
"which",
|
||||
]
|
||||
|
@ -3215,7 +3324,7 @@ dependencies = [
|
|||
"itertools 0.11.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3386,9 +3495,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.8.1"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051"
|
||||
checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
|
@ -3510,9 +3619,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
|||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.24"
|
||||
version = "0.11.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251"
|
||||
checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
|
||||
dependencies = [
|
||||
"async-compression",
|
||||
"base64 0.21.7",
|
||||
|
@ -3520,10 +3629,10 @@ dependencies = [
|
|||
"encoding_rs",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"h2 0.3.24",
|
||||
"http 0.2.11",
|
||||
"http-body 0.4.6",
|
||||
"hyper 0.14.28",
|
||||
"hyper-rustls",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
|
@ -3923,7 +4032,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3932,7 +4041,7 @@ version = "1.0.114"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0"
|
||||
dependencies = [
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
|
@ -3971,19 +4080,19 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_with"
|
||||
version = "3.6.1"
|
||||
version = "3.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270"
|
||||
checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"chrono",
|
||||
"hex",
|
||||
"indexmap 1.9.3",
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"serde_with_macros 3.6.1",
|
||||
"serde_with_macros 3.7.0",
|
||||
"time",
|
||||
]
|
||||
|
||||
|
@ -4001,23 +4110,23 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_with_macros"
|
||||
version = "3.6.1"
|
||||
version = "3.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d"
|
||||
checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655"
|
||||
dependencies = [
|
||||
"darling 0.20.6",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.9.32"
|
||||
version = "0.9.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f"
|
||||
checksum = "a0623d197252096520c6f2a5e1171ee436e5af99a5d7caa2891e55e61950e6d9"
|
||||
dependencies = [
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
|
@ -4237,9 +4346,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.52"
|
||||
version = "2.0.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07"
|
||||
checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -4293,9 +4402,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
|||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.10.0"
|
||||
version = "3.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67"
|
||||
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"fastrand",
|
||||
|
@ -4323,31 +4432,31 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.57"
|
||||
version = "1.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b"
|
||||
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.57"
|
||||
version = "1.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
|
||||
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread-priority"
|
||||
version = "0.15.1"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b72cb4958060ee2d9540cef68bb3871fd1e547037772c7fe7650d5d1cbec53b3"
|
||||
checksum = "a617e9eeeb20448b01a8e2427fb80dfbc9c49d79a1de3b11f25731edbf547e3c"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags 2.4.2",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"log",
|
||||
|
@ -4461,7 +4570,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4488,9 +4597,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tokio-test"
|
||||
version = "0.4.3"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e89b3cbabd3ae862100094ae433e1def582cf86451b4e9bf83aa7ac1d8a7d719"
|
||||
checksum = "2468baabc3311435b55dd935f702f42cd1b8abb7e754fb7dfb16bd36aa88f9f7"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"bytes",
|
||||
|
@ -4538,14 +4647,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.10"
|
||||
version = "0.8.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290"
|
||||
checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit 0.22.6",
|
||||
"toml_edit 0.22.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4563,18 +4672,18 @@ version = "0.20.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
|
||||
dependencies = [
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"toml_datetime",
|
||||
"winnow 0.5.40",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.6"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6"
|
||||
checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4"
|
||||
dependencies = [
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
|
@ -4592,10 +4701,10 @@ dependencies = [
|
|||
"axum",
|
||||
"base64 0.21.7",
|
||||
"bytes",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"h2 0.3.24",
|
||||
"http 0.2.11",
|
||||
"http-body 0.4.6",
|
||||
"hyper 0.14.28",
|
||||
"hyper-timeout",
|
||||
"percent-encoding",
|
||||
"pin-project",
|
||||
|
@ -4619,10 +4728,10 @@ dependencies = [
|
|||
"axum",
|
||||
"base64 0.21.7",
|
||||
"bytes",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"h2 0.3.24",
|
||||
"http 0.2.11",
|
||||
"http-body 0.4.6",
|
||||
"hyper 0.14.28",
|
||||
"hyper-timeout",
|
||||
"percent-encoding",
|
||||
"pin-project",
|
||||
|
@ -4645,7 +4754,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"prost-build",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4658,7 +4767,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"prost-build",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4788,7 +4897,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -5011,9 +5120,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
version = "0.2.10"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b"
|
||||
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
|
@ -5226,7 +5335,7 @@ dependencies = [
|
|||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
|
@ -5260,7 +5369,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
@ -5751,7 +5860,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde-big-array",
|
||||
"serde_json",
|
||||
"serde_with 3.6.1",
|
||||
"serde_with 3.7.0",
|
||||
"sha2",
|
||||
"spandoc",
|
||||
"static_assertions",
|
||||
|
@ -5787,7 +5896,7 @@ dependencies = [
|
|||
"howudoin",
|
||||
"jubjub",
|
||||
"lazy_static",
|
||||
"metrics 0.22.1",
|
||||
"metrics 0.22.3",
|
||||
"num-integer",
|
||||
"once_cell",
|
||||
"orchard",
|
||||
|
@ -5851,10 +5960,10 @@ dependencies = [
|
|||
"hex",
|
||||
"howudoin",
|
||||
"humantime-serde",
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"itertools 0.12.1",
|
||||
"lazy_static",
|
||||
"metrics 0.22.1",
|
||||
"metrics 0.22.3",
|
||||
"num-integer",
|
||||
"ordered-map",
|
||||
"pin-project",
|
||||
|
@ -5870,7 +5979,7 @@ dependencies = [
|
|||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util 0.7.10",
|
||||
"toml 0.8.10",
|
||||
"toml 0.8.12",
|
||||
"tower",
|
||||
"tracing",
|
||||
"tracing-error",
|
||||
|
@ -5899,8 +6008,8 @@ dependencies = [
|
|||
"chrono",
|
||||
"futures",
|
||||
"hex",
|
||||
"hyper",
|
||||
"indexmap 2.2.3",
|
||||
"hyper 0.14.28",
|
||||
"indexmap 2.2.5",
|
||||
"insta",
|
||||
"jsonrpc-core",
|
||||
"jsonrpc-derive",
|
||||
|
@ -5933,7 +6042,7 @@ dependencies = [
|
|||
"ff",
|
||||
"futures",
|
||||
"group",
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"insta",
|
||||
"itertools 0.12.1",
|
||||
"jubjub",
|
||||
|
@ -5983,12 +6092,12 @@ dependencies = [
|
|||
"hex-literal",
|
||||
"howudoin",
|
||||
"humantime-serde",
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"insta",
|
||||
"itertools 0.12.1",
|
||||
"jubjub",
|
||||
"lazy_static",
|
||||
"metrics 0.22.1",
|
||||
"metrics 0.22.3",
|
||||
"mset",
|
||||
"once_cell",
|
||||
"proptest",
|
||||
|
@ -6020,7 +6129,7 @@ dependencies = [
|
|||
"futures",
|
||||
"hex",
|
||||
"humantime",
|
||||
"indexmap 2.2.3",
|
||||
"indexmap 2.2.5",
|
||||
"insta",
|
||||
"itertools 0.12.1",
|
||||
"lazy_static",
|
||||
|
@ -6055,7 +6164,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"serde_yaml",
|
||||
"structopt",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
"thiserror",
|
||||
"tinyvec",
|
||||
"tokio",
|
||||
|
@ -6076,7 +6185,7 @@ dependencies = [
|
|||
"abscissa_core",
|
||||
"atty",
|
||||
"chrono",
|
||||
"clap 4.5.1",
|
||||
"clap 4.5.3",
|
||||
"color-eyre",
|
||||
"console-subscriber",
|
||||
"dirs",
|
||||
|
@ -6085,15 +6194,15 @@ dependencies = [
|
|||
"hex-literal",
|
||||
"howudoin",
|
||||
"humantime-serde",
|
||||
"hyper",
|
||||
"indexmap 2.2.3",
|
||||
"hyper 0.14.28",
|
||||
"indexmap 2.2.5",
|
||||
"indicatif",
|
||||
"inferno",
|
||||
"insta",
|
||||
"jsonrpc-core",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"metrics 0.22.1",
|
||||
"metrics 0.22.3",
|
||||
"metrics-exporter-prometheus",
|
||||
"num-integer",
|
||||
"once_cell",
|
||||
|
@ -6114,7 +6223,7 @@ dependencies = [
|
|||
"tinyvec",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"toml 0.8.10",
|
||||
"toml 0.8.12",
|
||||
"tonic 0.11.0",
|
||||
"tonic-build 0.11.0",
|
||||
"tower",
|
||||
|
@ -6156,7 +6265,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -6176,5 +6285,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
- [Shielded Scanning gRPC Server](user/shielded-scan-grpc-server.md)
|
||||
- [Kibana blockchain explorer](user/elasticsearch.md)
|
||||
- [Forking the Zcash Testnet with Zebra](user/fork-zebra-testnet.md)
|
||||
[OpenAPI specification](user/openapi.md)
|
||||
- [OpenAPI specification](user/openapi.md)
|
||||
- [Troubleshooting](user/troubleshooting.md)
|
||||
- [Developer Documentation](dev.md)
|
||||
- [Contribution Guide](CONTRIBUTING.md)
|
||||
|
|
|
@ -24,8 +24,8 @@ categories = ["algorithms", "asynchronous"]
|
|||
[dependencies]
|
||||
futures = "0.3.30"
|
||||
futures-core = "0.3.28"
|
||||
pin-project = "1.1.4"
|
||||
rayon = "1.8.1"
|
||||
pin-project = "1.1.5"
|
||||
rayon = "1.9.0"
|
||||
tokio = { version = "1.36.0", features = ["time", "sync", "tracing", "macros"] }
|
||||
tokio-util = "0.7.10"
|
||||
tower = { version = "0.4.13", features = ["util", "buffer"] }
|
||||
|
@ -33,7 +33,7 @@ tracing = "0.1.39"
|
|||
tracing-futures = "0.2.5"
|
||||
|
||||
[dev-dependencies]
|
||||
color-eyre = "0.6.2"
|
||||
color-eyre = "0.6.3"
|
||||
# This is a transitive dependency via color-eyre.
|
||||
# Enable a feature that makes tinyvec compile much faster.
|
||||
tinyvec = { version = "1.6.0", features = ["rustc_1_55"] }
|
||||
|
@ -42,7 +42,7 @@ ed25519-zebra = "4.0.3"
|
|||
rand = "0.8.5"
|
||||
|
||||
tokio = { version = "1.36.0", features = ["full", "tracing", "test-util"] }
|
||||
tokio-test = "0.4.3"
|
||||
tokio-test = "0.4.4"
|
||||
tower-fallback = { path = "../tower-fallback/", version = "0.2.41-beta.11" }
|
||||
tower-test = "0.4.0"
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ keywords = ["tower", "batch"]
|
|||
categories = ["algorithms", "asynchronous"]
|
||||
|
||||
[dependencies]
|
||||
pin-project = "1.1.4"
|
||||
pin-project = "1.1.5"
|
||||
tower = "0.4.13"
|
||||
futures-core = "0.3.28"
|
||||
tracing = "0.1.39"
|
||||
|
|
|
@ -106,19 +106,19 @@ humantime = "2.1.0"
|
|||
# Error Handling & Formatting
|
||||
displaydoc = "0.2.4"
|
||||
static_assertions = "1.1.0"
|
||||
thiserror = "1.0.57"
|
||||
thiserror = "1.0.58"
|
||||
tracing = "0.1.39"
|
||||
|
||||
# Serialization
|
||||
hex = { version = "0.4.3", features = ["serde"] }
|
||||
serde = { version = "1.0.196", features = ["serde_derive", "rc"] }
|
||||
serde_with = "3.6.1"
|
||||
serde_with = "3.7.0"
|
||||
serde-big-array = "0.5.1"
|
||||
|
||||
# Processing
|
||||
futures = "0.3.30"
|
||||
itertools = "0.12.1"
|
||||
rayon = "1.8.1"
|
||||
rayon = "1.9.0"
|
||||
|
||||
# ZF deps
|
||||
ed25519-zebra = "4.0.3"
|
||||
|
@ -150,7 +150,7 @@ zebra-test = { path = "../zebra-test/", version = "1.0.0-beta.35", optional = tr
|
|||
criterion = { version = "0.5.1", features = ["html_reports"] }
|
||||
|
||||
# Error Handling & Formatting
|
||||
color-eyre = "0.6.2"
|
||||
color-eyre = "0.6.3"
|
||||
# This is a transitive dependency via color-eyre.
|
||||
# Enable a feature that makes tinyvec compile much faster.
|
||||
tinyvec = { version = "1.6.0", features = ["rustc_1_55"] }
|
||||
|
|
|
@ -98,7 +98,7 @@ impl Block {
|
|||
///
|
||||
/// Returns an error if this block does not have a block height,
|
||||
/// or if the commitment value is structurally invalid.
|
||||
pub fn commitment(&self, network: Network) -> Result<Commitment, CommitmentError> {
|
||||
pub fn commitment(&self, network: &Network) -> Result<Commitment, CommitmentError> {
|
||||
match self.coinbase_height() {
|
||||
None => Err(CommitmentError::MissingBlockHeight {
|
||||
block_hash: self.hash(),
|
||||
|
@ -121,7 +121,7 @@ impl Block {
|
|||
#[allow(clippy::unwrap_in_result)]
|
||||
pub fn check_transaction_network_upgrade_consistency(
|
||||
&self,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Result<(), error::BlockError> {
|
||||
let block_nu =
|
||||
NetworkUpgrade::current(network, self.coinbase_height().expect("a valid height"));
|
||||
|
|
|
@ -69,7 +69,7 @@ impl Arbitrary for Height {
|
|||
type Strategy = BoxedStrategy<Self>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[non_exhaustive]
|
||||
/// The configuration data for proptest when generating arbitrary chains
|
||||
pub struct LedgerState {
|
||||
|
@ -245,7 +245,7 @@ impl LedgerState {
|
|||
if let Some(network_upgrade_override) = self.network_upgrade_override {
|
||||
network_upgrade_override
|
||||
} else {
|
||||
NetworkUpgrade::current(self.network, self.height)
|
||||
NetworkUpgrade::current(&self.network, self.height)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,9 +268,9 @@ impl Default for LedgerState {
|
|||
let default_network = Network::default();
|
||||
let default_override = LedgerStateOverride::default();
|
||||
|
||||
let most_recent_nu = NetworkUpgrade::current(default_network, Height::MAX);
|
||||
let most_recent_nu = NetworkUpgrade::current(&default_network, Height::MAX);
|
||||
let most_recent_activation_height =
|
||||
most_recent_nu.activation_height(default_network).unwrap();
|
||||
most_recent_nu.activation_height(&default_network).unwrap();
|
||||
|
||||
LedgerState {
|
||||
height: most_recent_activation_height,
|
||||
|
@ -290,7 +290,7 @@ impl Default for LedgerStateOverride {
|
|||
let default_network = Network::default();
|
||||
|
||||
// TODO: dynamically select any future network upgrade (#1974)
|
||||
let nu5_activation_height = Nu5.activation_height(default_network);
|
||||
let nu5_activation_height = Nu5.activation_height(&default_network);
|
||||
let nu5_override = if nu5_activation_height.is_some() {
|
||||
None
|
||||
} else {
|
||||
|
@ -348,12 +348,14 @@ impl Arbitrary for Block {
|
|||
type Parameters = LedgerState;
|
||||
|
||||
fn arbitrary_with(ledger_state: Self::Parameters) -> Self::Strategy {
|
||||
let transactions_strategy =
|
||||
let transactions_strategy = {
|
||||
let ledger_state = ledger_state.clone();
|
||||
// Generate a random number transactions. A coinbase tx is always generated, so if
|
||||
// `transaction_count` is zero, the block will contain only the coinbase tx.
|
||||
(0..MAX_ARBITRARY_ITEMS).prop_flat_map(move |transaction_count| {
|
||||
Transaction::vec_strategy(ledger_state, transaction_count)
|
||||
});
|
||||
Transaction::vec_strategy(ledger_state.clone(), transaction_count)
|
||||
})
|
||||
};
|
||||
|
||||
// TODO: if needed, fixup:
|
||||
// - history and authorizing data commitments
|
||||
|
@ -411,7 +413,7 @@ impl Block {
|
|||
|
||||
// generate block strategies with the correct heights
|
||||
for _ in 0..count {
|
||||
vec.push((Just(current.height), Block::arbitrary_with(current)));
|
||||
vec.push((Just(current.height), Block::arbitrary_with(current.clone())));
|
||||
current.height.0 += 1;
|
||||
}
|
||||
|
||||
|
@ -473,9 +475,9 @@ impl Block {
|
|||
if generate_valid_commitments {
|
||||
let current_height = block.coinbase_height().unwrap();
|
||||
let heartwood_height = NetworkUpgrade::Heartwood
|
||||
.activation_height(current.network)
|
||||
.activation_height(¤t.network)
|
||||
.unwrap();
|
||||
let nu5_height = NetworkUpgrade::Nu5.activation_height(current.network);
|
||||
let nu5_height = NetworkUpgrade::Nu5.activation_height(¤t.network);
|
||||
|
||||
match current_height.cmp(&heartwood_height) {
|
||||
std::cmp::Ordering::Less => {
|
||||
|
@ -520,16 +522,16 @@ impl Block {
|
|||
if let Some(history_tree) = history_tree.as_mut() {
|
||||
history_tree
|
||||
.push(
|
||||
current.network,
|
||||
¤t.network,
|
||||
Arc::new(block.clone()),
|
||||
sapling_tree.root(),
|
||||
orchard_tree.root(),
|
||||
&sapling_tree.root(),
|
||||
&orchard_tree.root(),
|
||||
)
|
||||
.unwrap();
|
||||
} else {
|
||||
history_tree = Some(
|
||||
HistoryTree::from_block(
|
||||
current.network,
|
||||
¤t.network,
|
||||
Arc::new(block.clone()),
|
||||
&sapling_tree.root(),
|
||||
&orchard_tree.root(),
|
||||
|
@ -703,10 +705,10 @@ impl Arbitrary for Commitment {
|
|||
fn arbitrary_with(_args: ()) -> Self::Strategy {
|
||||
(any::<[u8; 32]>(), any::<Network>(), any::<Height>())
|
||||
.prop_map(|(commitment_bytes, network, block_height)| {
|
||||
if block_height == Heartwood.activation_height(network).unwrap() {
|
||||
if block_height == Heartwood.activation_height(&network).unwrap() {
|
||||
Commitment::ChainHistoryActivationReserved
|
||||
} else {
|
||||
Commitment::from_bytes(commitment_bytes, network, block_height)
|
||||
Commitment::from_bytes(commitment_bytes, &network, block_height)
|
||||
.expect("unexpected failure in from_bytes parsing")
|
||||
}
|
||||
})
|
||||
|
|
|
@ -103,7 +103,7 @@ impl Commitment {
|
|||
// TODO: rename as from_bytes_in_serialized_order()
|
||||
pub(super) fn from_bytes(
|
||||
bytes: [u8; 32],
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: block::Height,
|
||||
) -> Result<Commitment, CommitmentError> {
|
||||
use Commitment::*;
|
||||
|
|
|
@ -81,7 +81,7 @@ proptest! {
|
|||
|
||||
// just skip the test if the bytes don't parse, because there's nothing
|
||||
// to compare with
|
||||
if let Ok(commitment) = Commitment::from_bytes(bytes, network, block_height) {
|
||||
if let Ok(commitment) = Commitment::from_bytes(bytes, &network, block_height) {
|
||||
let other_bytes = commitment.to_bytes();
|
||||
|
||||
prop_assert_eq![bytes, other_bytes];
|
||||
|
@ -104,7 +104,7 @@ proptest! {
|
|||
let bytes = block.zcash_serialize_to_vec()?;
|
||||
|
||||
// Check the block commitment
|
||||
let commitment = block.commitment(network);
|
||||
let commitment = block.commitment(&network);
|
||||
if let Ok(commitment) = commitment {
|
||||
let commitment_bytes = commitment.to_bytes();
|
||||
prop_assert_eq![block.header.commitment_bytes.0, commitment_bytes];
|
||||
|
|
|
@ -222,7 +222,7 @@ fn block_test_vectors_height(network: Network) {
|
|||
|
||||
if height
|
||||
>= Sapling
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("sapling activation height is set")
|
||||
.0
|
||||
{
|
||||
|
@ -260,7 +260,7 @@ fn block_commitment(network: Network) {
|
|||
.zcash_deserialize_into::<Block>()
|
||||
.expect("block is structurally valid");
|
||||
|
||||
let commitment = block.commitment(network).unwrap_or_else(|_| {
|
||||
let commitment = block.commitment(&network).unwrap_or_else(|_| {
|
||||
panic!("unexpected structurally invalid block commitment at {network} {height}")
|
||||
});
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ pub trait ChainTip {
|
|||
/// and the height of the best tip.
|
||||
fn estimate_network_chain_tip_height(
|
||||
&self,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
now: DateTime<Utc>,
|
||||
) -> Option<block::Height> {
|
||||
let (current_height, current_block_time) = self.best_tip_height_and_block_time()?;
|
||||
|
@ -110,7 +110,7 @@ pub trait ChainTip {
|
|||
/// Returns `None` if the state is empty.
|
||||
fn estimate_distance_to_network_chain_tip(
|
||||
&self,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Option<(block::HeightDiff, block::Height)> {
|
||||
let (current_height, current_block_time) = self.best_tip_height_and_block_time()?;
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ impl ChainTip for MockChainTip {
|
|||
|
||||
fn estimate_distance_to_network_chain_tip(
|
||||
&self,
|
||||
_network: Network,
|
||||
_network: &Network,
|
||||
) -> Option<(block::HeightDiff, block::Height)> {
|
||||
self.estimated_distance_to_network_chain_tip
|
||||
.borrow()
|
||||
|
|
|
@ -43,7 +43,7 @@ impl NetworkChainTipHeightEstimator {
|
|||
pub fn new(
|
||||
current_block_time: DateTime<Utc>,
|
||||
current_height: block::Height,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Self {
|
||||
let mut target_spacings = NetworkUpgrade::target_spacings(network);
|
||||
let (_genesis_height, initial_target_spacing) =
|
||||
|
|
|
@ -24,7 +24,7 @@ proptest! {
|
|||
) {
|
||||
let (chain_tip, mock_chain_tip_sender) = MockChainTip::new();
|
||||
let blossom_activation_height = NetworkUpgrade::Blossom
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Blossom activation height is missing");
|
||||
|
||||
block_heights.sort();
|
||||
|
@ -50,13 +50,13 @@ proptest! {
|
|||
|
||||
let time_displacement = calculate_time_displacement(
|
||||
time_displacement_factor,
|
||||
NetworkUpgrade::current(network, network_height),
|
||||
NetworkUpgrade::current(&network, network_height),
|
||||
);
|
||||
|
||||
let mock_local_time = current_block_time + estimated_time_difference + time_displacement;
|
||||
|
||||
assert_eq!(
|
||||
chain_tip.estimate_network_chain_tip_height(network, mock_local_time),
|
||||
chain_tip.estimate_network_chain_tip_height(&network, mock_local_time),
|
||||
Some(network_height)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ impl NonEmptyHistoryTree {
|
|||
/// The parameters must come from the values of [`NonEmptyHistoryTree::size`],
|
||||
/// [`NonEmptyHistoryTree::peaks`] and [`NonEmptyHistoryTree::current_height`] of a HistoryTree.
|
||||
pub fn from_cache(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
size: u32,
|
||||
peaks: BTreeMap<u32, Entry>,
|
||||
current_height: Height,
|
||||
|
@ -114,7 +114,7 @@ impl NonEmptyHistoryTree {
|
|||
}
|
||||
};
|
||||
Ok(Self {
|
||||
network,
|
||||
network: network.clone(),
|
||||
network_upgrade,
|
||||
inner,
|
||||
size,
|
||||
|
@ -130,7 +130,7 @@ impl NonEmptyHistoryTree {
|
|||
/// (ignored for pre-Orchard blocks).
|
||||
#[allow(clippy::unwrap_in_result)]
|
||||
pub fn from_block(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
block: Arc<Block>,
|
||||
sapling_root: &sapling::tree::Root,
|
||||
orchard_root: &orchard::tree::Root,
|
||||
|
@ -169,7 +169,7 @@ impl NonEmptyHistoryTree {
|
|||
let mut peaks = BTreeMap::new();
|
||||
peaks.insert(0u32, entry);
|
||||
Ok(NonEmptyHistoryTree {
|
||||
network,
|
||||
network: network.clone(),
|
||||
network_upgrade,
|
||||
inner: tree,
|
||||
size: 1,
|
||||
|
@ -208,11 +208,11 @@ impl NonEmptyHistoryTree {
|
|||
self.current_height
|
||||
);
|
||||
|
||||
let network_upgrade = NetworkUpgrade::current(self.network, height);
|
||||
let network_upgrade = NetworkUpgrade::current(&self.network, height);
|
||||
if network_upgrade != self.network_upgrade {
|
||||
// This is the activation block of a network upgrade.
|
||||
// Create a new tree.
|
||||
let new_tree = Self::from_block(self.network, block, sapling_root, orchard_root)?;
|
||||
let new_tree = Self::from_block(&self.network, block, sapling_root, orchard_root)?;
|
||||
// Replaces self with the new tree
|
||||
*self = new_tree;
|
||||
assert_eq!(self.network_upgrade, network_upgrade);
|
||||
|
@ -328,7 +328,7 @@ impl NonEmptyHistoryTree {
|
|||
self.inner = match self.inner {
|
||||
InnerHistoryTree::PreOrchard(_) => {
|
||||
InnerHistoryTree::PreOrchard(Tree::<PreOrchard>::new_from_cache(
|
||||
self.network,
|
||||
&self.network,
|
||||
self.network_upgrade,
|
||||
self.size,
|
||||
&self.peaks,
|
||||
|
@ -337,7 +337,7 @@ impl NonEmptyHistoryTree {
|
|||
}
|
||||
InnerHistoryTree::OrchardOnward(_) => {
|
||||
InnerHistoryTree::OrchardOnward(Tree::<OrchardOnward>::new_from_cache(
|
||||
self.network,
|
||||
&self.network,
|
||||
self.network_upgrade,
|
||||
self.size,
|
||||
&self.peaks,
|
||||
|
@ -373,7 +373,7 @@ impl NonEmptyHistoryTree {
|
|||
|
||||
/// Return the network where this tree is used.
|
||||
pub fn network(&self) -> Network {
|
||||
self.network
|
||||
self.network.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ impl Clone for NonEmptyHistoryTree {
|
|||
let tree = match self.inner {
|
||||
InnerHistoryTree::PreOrchard(_) => InnerHistoryTree::PreOrchard(
|
||||
Tree::<PreOrchard>::new_from_cache(
|
||||
self.network,
|
||||
&self.network,
|
||||
self.network_upgrade,
|
||||
self.size,
|
||||
&self.peaks,
|
||||
|
@ -392,7 +392,7 @@ impl Clone for NonEmptyHistoryTree {
|
|||
),
|
||||
InnerHistoryTree::OrchardOnward(_) => InnerHistoryTree::OrchardOnward(
|
||||
Tree::<OrchardOnward>::new_from_cache(
|
||||
self.network,
|
||||
&self.network,
|
||||
self.network_upgrade,
|
||||
self.size,
|
||||
&self.peaks,
|
||||
|
@ -402,7 +402,7 @@ impl Clone for NonEmptyHistoryTree {
|
|||
),
|
||||
};
|
||||
NonEmptyHistoryTree {
|
||||
network: self.network,
|
||||
network: self.network.clone(),
|
||||
network_upgrade: self.network_upgrade,
|
||||
inner: tree,
|
||||
size: self.size,
|
||||
|
@ -423,7 +423,7 @@ impl HistoryTree {
|
|||
/// If the block is pre-Heartwood, it returns an empty history tree.
|
||||
#[allow(clippy::unwrap_in_result)]
|
||||
pub fn from_block(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
block: Arc<Block>,
|
||||
sapling_root: &sapling::tree::Root,
|
||||
orchard_root: &orchard::tree::Root,
|
||||
|
@ -450,10 +450,10 @@ impl HistoryTree {
|
|||
#[allow(clippy::unwrap_in_result)]
|
||||
pub fn push(
|
||||
&mut self,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
block: Arc<Block>,
|
||||
sapling_root: sapling::tree::Root,
|
||||
orchard_root: orchard::tree::Root,
|
||||
sapling_root: &sapling::tree::Root,
|
||||
orchard_root: &orchard::tree::Root,
|
||||
) -> Result<(), HistoryTreeError> {
|
||||
let heartwood_height = NetworkUpgrade::Heartwood
|
||||
.activation_height(network)
|
||||
|
@ -472,9 +472,9 @@ impl HistoryTree {
|
|||
std::cmp::Ordering::Equal => {
|
||||
let tree = Some(NonEmptyHistoryTree::from_block(
|
||||
network,
|
||||
block.clone(),
|
||||
&sapling_root,
|
||||
&orchard_root,
|
||||
block,
|
||||
sapling_root,
|
||||
orchard_root,
|
||||
)?);
|
||||
// Replace the current object with the new tree
|
||||
*self = HistoryTree(tree);
|
||||
|
@ -483,7 +483,7 @@ impl HistoryTree {
|
|||
self.0
|
||||
.as_mut()
|
||||
.expect("history tree must exist Heartwood-onward")
|
||||
.push(block.clone(), &sapling_root, &orchard_root)?;
|
||||
.push(block.clone(), sapling_root, orchard_root)?;
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
|
|
|
@ -35,7 +35,7 @@ fn push_and_prune_for_network_upgrade(
|
|||
) -> Result<()> {
|
||||
let (blocks, sapling_roots) = network.block_sapling_roots_map();
|
||||
|
||||
let height = network_upgrade.activation_height(network).unwrap().0;
|
||||
let height = network_upgrade.activation_height(&network).unwrap().0;
|
||||
|
||||
// Load first block (activation block of the given network upgrade)
|
||||
let first_block = Arc::new(
|
||||
|
@ -47,7 +47,7 @@ fn push_and_prune_for_network_upgrade(
|
|||
);
|
||||
|
||||
// Check its commitment
|
||||
let first_commitment = first_block.commitment(network)?;
|
||||
let first_commitment = first_block.commitment(&network)?;
|
||||
if network_upgrade == NetworkUpgrade::Heartwood {
|
||||
// Heartwood is the only upgrade that has a reserved value.
|
||||
// (For other upgrades we could compare with the expected commitment,
|
||||
|
@ -59,7 +59,7 @@ fn push_and_prune_for_network_upgrade(
|
|||
let first_sapling_root =
|
||||
sapling::tree::Root::try_from(**sapling_roots.get(&height).expect("test vector exists"))?;
|
||||
let mut tree = NonEmptyHistoryTree::from_block(
|
||||
network,
|
||||
&network,
|
||||
first_block,
|
||||
&first_sapling_root,
|
||||
&Default::default(),
|
||||
|
@ -82,7 +82,7 @@ fn push_and_prune_for_network_upgrade(
|
|||
);
|
||||
|
||||
// Check its commitment
|
||||
let second_commitment = second_block.commitment(network)?;
|
||||
let second_commitment = second_block.commitment(&network)?;
|
||||
assert_eq!(second_commitment, Commitment::ChainHistoryRoot(first_root));
|
||||
|
||||
// Append second block to history tree
|
||||
|
@ -117,7 +117,7 @@ fn upgrade() -> Result<()> {
|
|||
fn upgrade_for_network_upgrade(network: Network, network_upgrade: NetworkUpgrade) -> Result<()> {
|
||||
let (blocks, sapling_roots) = network.block_sapling_roots_map();
|
||||
|
||||
let height = network_upgrade.activation_height(network).unwrap().0;
|
||||
let height = network_upgrade.activation_height(&network).unwrap().0;
|
||||
|
||||
// Load previous block (the block before the activation block of the given network upgrade)
|
||||
let block_prev = Arc::new(
|
||||
|
@ -134,7 +134,7 @@ fn upgrade_for_network_upgrade(network: Network, network_upgrade: NetworkUpgrade
|
|||
let sapling_root_prev =
|
||||
sapling::tree::Root::try_from(**sapling_roots.get(&height).expect("test vector exists"))?;
|
||||
let mut tree = NonEmptyHistoryTree::from_block(
|
||||
network,
|
||||
&network,
|
||||
block_prev,
|
||||
&sapling_root_prev,
|
||||
&Default::default(),
|
||||
|
|
|
@ -52,7 +52,7 @@ mod tests;
|
|||
const ZIP_212_GRACE_PERIOD_DURATION: HeightDiff = 32_256;
|
||||
|
||||
/// An enum describing the possible network choices.
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
|
||||
pub enum Network {
|
||||
/// The production mainnet.
|
||||
|
@ -68,13 +68,13 @@ impl Network {
|
|||
/// Returns the human-readable prefix for Base58Check-encoded transparent
|
||||
/// pay-to-public-key-hash payment addresses for the network.
|
||||
pub fn b58_pubkey_address_prefix(&self) -> [u8; 2] {
|
||||
<ZcashPrimitivesNetwork>::from(*self).b58_pubkey_address_prefix()
|
||||
<ZcashPrimitivesNetwork>::from(self).b58_pubkey_address_prefix()
|
||||
}
|
||||
|
||||
/// Returns the human-readable prefix for Base58Check-encoded transparent pay-to-script-hash
|
||||
/// payment addresses for the network.
|
||||
pub fn b58_script_address_prefix(&self) -> [u8; 2] {
|
||||
<ZcashPrimitivesNetwork>::from(*self).b58_script_address_prefix()
|
||||
<ZcashPrimitivesNetwork>::from(self).b58_script_address_prefix()
|
||||
}
|
||||
/// Returns true if the maximum block time rule is active for `network` and `height`.
|
||||
///
|
||||
|
@ -84,7 +84,7 @@ impl Network {
|
|||
/// Returns false otherwise.
|
||||
///
|
||||
/// Part of the consensus rules at <https://zips.z.cash/protocol/protocol.pdf#blockheader>
|
||||
pub fn is_max_block_time_enforced(self, height: block::Height) -> bool {
|
||||
pub fn is_max_block_time_enforced(&self, height: block::Height) -> bool {
|
||||
match self {
|
||||
Network::Mainnet => true,
|
||||
Network::Testnet => height >= super::TESTNET_MAX_TIME_START_HEIGHT,
|
||||
|
@ -92,8 +92,8 @@ impl Network {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Network> for &'static str {
|
||||
fn from(network: Network) -> &'static str {
|
||||
impl From<&Network> for &'static str {
|
||||
fn from(network: &Network) -> &'static str {
|
||||
match network {
|
||||
Network::Mainnet => "Mainnet",
|
||||
Network::Testnet => "Testnet",
|
||||
|
@ -101,12 +101,6 @@ impl From<Network> for &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<&Network> for &'static str {
|
||||
fn from(network: &Network) -> &'static str {
|
||||
(*network).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Network {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(self.into())
|
||||
|
@ -139,7 +133,7 @@ impl Network {
|
|||
// See the `ZIP_212_GRACE_PERIOD_DURATION` documentation for more information.
|
||||
|
||||
let canopy_activation = Canopy
|
||||
.activation_height(*self)
|
||||
.activation_height(self)
|
||||
.expect("Canopy activation height must be present for both networks");
|
||||
|
||||
(canopy_activation + ZIP_212_GRACE_PERIOD_DURATION)
|
||||
|
@ -166,7 +160,7 @@ impl Network {
|
|||
}
|
||||
|
||||
/// Returns the Sapling activation height for this network.
|
||||
pub fn sapling_activation_height(self) -> Height {
|
||||
pub fn sapling_activation_height(&self) -> Height {
|
||||
super::NetworkUpgrade::Sapling
|
||||
.activation_height(self)
|
||||
.expect("Sapling activation height needs to be set")
|
||||
|
|
|
@ -18,7 +18,7 @@ proptest! {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
let canopy_activation = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is set");
|
||||
|
||||
let grace_period_end_height = (canopy_activation + ZIP_212_GRACE_PERIOD_DURATION)
|
||||
|
|
|
@ -280,7 +280,7 @@ impl Network {
|
|||
}
|
||||
impl NetworkUpgrade {
|
||||
/// Returns the current network upgrade for `network` and `height`.
|
||||
pub fn current(network: Network, height: block::Height) -> NetworkUpgrade {
|
||||
pub fn current(network: &Network, height: block::Height) -> NetworkUpgrade {
|
||||
network
|
||||
.activation_list()
|
||||
.range(..=height)
|
||||
|
@ -293,7 +293,7 @@ impl NetworkUpgrade {
|
|||
///
|
||||
/// Returns None if the next upgrade has not been implemented in Zebra
|
||||
/// yet.
|
||||
pub fn next(network: Network, height: block::Height) -> Option<NetworkUpgrade> {
|
||||
pub fn next(network: &Network, height: block::Height) -> Option<NetworkUpgrade> {
|
||||
network
|
||||
.activation_list()
|
||||
.range((Excluded(height), Unbounded))
|
||||
|
@ -305,7 +305,7 @@ impl NetworkUpgrade {
|
|||
///
|
||||
/// Returns None if this network upgrade is a future upgrade, and its
|
||||
/// activation height has not been set yet.
|
||||
pub fn activation_height(&self, network: Network) -> Option<block::Height> {
|
||||
pub fn activation_height(&self, network: &Network) -> Option<block::Height> {
|
||||
network
|
||||
.activation_list()
|
||||
.iter()
|
||||
|
@ -319,7 +319,7 @@ impl NetworkUpgrade {
|
|||
///
|
||||
/// Use [`NetworkUpgrade::activation_height`] to get the specific network
|
||||
/// upgrade.
|
||||
pub fn is_activation_height(network: Network, height: block::Height) -> bool {
|
||||
pub fn is_activation_height(network: &Network, height: block::Height) -> bool {
|
||||
network.activation_list().contains_key(&height)
|
||||
}
|
||||
|
||||
|
@ -358,12 +358,14 @@ impl NetworkUpgrade {
|
|||
/// Returns the target block spacing for `network` and `height`.
|
||||
///
|
||||
/// See [`NetworkUpgrade::target_spacing`] for details.
|
||||
pub fn target_spacing_for_height(network: Network, height: block::Height) -> Duration {
|
||||
pub fn target_spacing_for_height(network: &Network, height: block::Height) -> Duration {
|
||||
NetworkUpgrade::current(network, height).target_spacing()
|
||||
}
|
||||
|
||||
/// Returns all the target block spacings for `network` and the heights where they start.
|
||||
pub fn target_spacings(network: Network) -> impl Iterator<Item = (block::Height, Duration)> {
|
||||
pub fn target_spacings(
|
||||
network: &Network,
|
||||
) -> impl Iterator<Item = (block::Height, Duration)> + '_ {
|
||||
[
|
||||
(NetworkUpgrade::Genesis, PRE_BLOSSOM_POW_TARGET_SPACING),
|
||||
(
|
||||
|
@ -388,7 +390,7 @@ impl NetworkUpgrade {
|
|||
///
|
||||
/// Based on <https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-the-test-network>
|
||||
pub fn minimum_difficulty_spacing_for_height(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: block::Height,
|
||||
) -> Option<Duration> {
|
||||
match (network, height) {
|
||||
|
@ -417,7 +419,7 @@ impl NetworkUpgrade {
|
|||
/// check for the time gap. This function implements the correct "greater than"
|
||||
/// check.
|
||||
pub fn is_testnet_min_difficulty_block(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
block_height: block::Height,
|
||||
block_time: DateTime<Utc>,
|
||||
previous_block_time: DateTime<Utc>,
|
||||
|
@ -443,7 +445,7 @@ impl NetworkUpgrade {
|
|||
///
|
||||
/// See [`NetworkUpgrade::averaging_window_timespan`] for details.
|
||||
pub fn averaging_window_timespan_for_height(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: block::Height,
|
||||
) -> Duration {
|
||||
NetworkUpgrade::current(network, height).averaging_window_timespan()
|
||||
|
@ -472,7 +474,7 @@ impl ConsensusBranchId {
|
|||
/// Returns the current consensus branch id for `network` and `height`.
|
||||
///
|
||||
/// Returns None if the network has no branch id at this height.
|
||||
pub fn current(network: Network, height: block::Height) -> Option<ConsensusBranchId> {
|
||||
pub fn current(network: &Network, height: block::Height) -> Option<ConsensusBranchId> {
|
||||
NetworkUpgrade::current(network, height).branch_id()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,15 +49,15 @@ fn activation_extremes(network: Network) {
|
|||
network.activation_list().get(&block::Height(0)),
|
||||
Some(&Genesis)
|
||||
);
|
||||
assert_eq!(Genesis.activation_height(network), Some(block::Height(0)));
|
||||
assert_eq!(Genesis.activation_height(&network), Some(block::Height(0)));
|
||||
assert!(NetworkUpgrade::is_activation_height(
|
||||
network,
|
||||
&network,
|
||||
block::Height(0)
|
||||
));
|
||||
|
||||
assert_eq!(NetworkUpgrade::current(network, block::Height(0)), Genesis);
|
||||
assert_eq!(NetworkUpgrade::current(&network, block::Height(0)), Genesis);
|
||||
assert_eq!(
|
||||
NetworkUpgrade::next(network, block::Height(0)),
|
||||
NetworkUpgrade::next(&network, block::Height(0)),
|
||||
Some(BeforeOverwinter)
|
||||
);
|
||||
|
||||
|
@ -66,25 +66,25 @@ fn activation_extremes(network: Network) {
|
|||
Some(&BeforeOverwinter)
|
||||
);
|
||||
assert_eq!(
|
||||
BeforeOverwinter.activation_height(network),
|
||||
BeforeOverwinter.activation_height(&network),
|
||||
Some(block::Height(1))
|
||||
);
|
||||
assert!(NetworkUpgrade::is_activation_height(
|
||||
network,
|
||||
&network,
|
||||
block::Height(1)
|
||||
));
|
||||
|
||||
assert_eq!(
|
||||
NetworkUpgrade::current(network, block::Height(1)),
|
||||
NetworkUpgrade::current(&network, block::Height(1)),
|
||||
BeforeOverwinter
|
||||
);
|
||||
assert_eq!(
|
||||
NetworkUpgrade::next(network, block::Height(1)),
|
||||
NetworkUpgrade::next(&network, block::Height(1)),
|
||||
Some(Overwinter)
|
||||
);
|
||||
|
||||
assert!(!NetworkUpgrade::is_activation_height(
|
||||
network,
|
||||
&network,
|
||||
block::Height(2)
|
||||
));
|
||||
|
||||
|
@ -95,15 +95,15 @@ fn activation_extremes(network: Network) {
|
|||
Some(&Genesis)
|
||||
);
|
||||
assert!(!NetworkUpgrade::is_activation_height(
|
||||
network,
|
||||
&network,
|
||||
block::Height::MAX
|
||||
));
|
||||
|
||||
assert_ne!(
|
||||
NetworkUpgrade::current(network, block::Height::MAX),
|
||||
NetworkUpgrade::current(&network, block::Height::MAX),
|
||||
Genesis
|
||||
);
|
||||
assert_eq!(NetworkUpgrade::next(network, block::Height::MAX), None);
|
||||
assert_eq!(NetworkUpgrade::next(&network, block::Height::MAX), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -126,28 +126,31 @@ fn activation_consistent(network: Network) {
|
|||
|
||||
for &network_upgrade in network_upgrades {
|
||||
let height = network_upgrade
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("activations must have a height");
|
||||
assert!(NetworkUpgrade::is_activation_height(network, height));
|
||||
assert!(NetworkUpgrade::is_activation_height(&network, height));
|
||||
|
||||
if height > block::Height(0) {
|
||||
// Genesis is immediately followed by BeforeOverwinter,
|
||||
// but the other network upgrades have multiple blocks between them
|
||||
assert!(!NetworkUpgrade::is_activation_height(
|
||||
network,
|
||||
&network,
|
||||
(height + 1).unwrap()
|
||||
));
|
||||
}
|
||||
|
||||
assert_eq!(NetworkUpgrade::current(network, height), network_upgrade);
|
||||
assert_eq!(NetworkUpgrade::current(&network, height), network_upgrade);
|
||||
// Network upgrades don't repeat
|
||||
assert_ne!(NetworkUpgrade::next(network, height), Some(network_upgrade));
|
||||
assert_ne!(
|
||||
NetworkUpgrade::next(network, block::Height(height.0 + 1)),
|
||||
NetworkUpgrade::next(&network, height),
|
||||
Some(network_upgrade)
|
||||
);
|
||||
assert_ne!(
|
||||
NetworkUpgrade::next(network, block::Height::MAX),
|
||||
NetworkUpgrade::next(&network, block::Height(height.0 + 1)),
|
||||
Some(network_upgrade)
|
||||
);
|
||||
assert_ne!(
|
||||
NetworkUpgrade::next(&network, block::Height::MAX),
|
||||
Some(network_upgrade)
|
||||
);
|
||||
}
|
||||
|
@ -186,7 +189,7 @@ fn branch_id_extremes(network: Network) {
|
|||
NetworkUpgrade::branch_id_list().get(&BeforeOverwinter),
|
||||
None
|
||||
);
|
||||
assert_eq!(ConsensusBranchId::current(network, block::Height(0)), None);
|
||||
assert_eq!(ConsensusBranchId::current(&network, block::Height(0)), None);
|
||||
assert_eq!(
|
||||
NetworkUpgrade::branch_id_list().get(&Overwinter).cloned(),
|
||||
Overwinter.branch_id()
|
||||
|
@ -195,11 +198,12 @@ fn branch_id_extremes(network: Network) {
|
|||
// We assume that the last upgrade we know about continues forever
|
||||
// (even if we suspect that won't be true)
|
||||
assert_ne!(
|
||||
NetworkUpgrade::branch_id_list().get(&NetworkUpgrade::current(network, block::Height::MAX)),
|
||||
NetworkUpgrade::branch_id_list()
|
||||
.get(&NetworkUpgrade::current(&network, block::Height::MAX)),
|
||||
None
|
||||
);
|
||||
assert_ne!(
|
||||
ConsensusBranchId::current(network, block::Height::MAX),
|
||||
ConsensusBranchId::current(&network, block::Height::MAX),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
@ -222,12 +226,12 @@ fn branch_id_consistent(network: Network) {
|
|||
let network_upgrades: HashSet<&NetworkUpgrade> = branch_id_list.keys().collect();
|
||||
|
||||
for &network_upgrade in network_upgrades {
|
||||
let height = network_upgrade.activation_height(network);
|
||||
let height = network_upgrade.activation_height(&network);
|
||||
|
||||
// Skip network upgrades that don't have activation heights yet
|
||||
if let Some(height) = height {
|
||||
assert_eq!(
|
||||
ConsensusBranchId::current(network, height),
|
||||
ConsensusBranchId::current(&network, height),
|
||||
network_upgrade.branch_id()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ impl TryFrom<zcash_address::Network> for Network {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Network> for zcash_address::Network {
|
||||
fn from(network: Network) -> Self {
|
||||
impl From<&Network> for zcash_address::Network {
|
||||
fn from(network: &Network) -> Self {
|
||||
match network {
|
||||
Network::Mainnet => zcash_address::Network::Main,
|
||||
Network::Testnet => zcash_address::Network::Test,
|
||||
|
@ -71,7 +71,7 @@ impl zcash_address::TryFromAddress for Address {
|
|||
data: [u8; 20],
|
||||
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
|
||||
Ok(Self::Transparent(transparent::Address::from_pub_key_hash(
|
||||
network.try_into()?,
|
||||
&network.try_into()?,
|
||||
data,
|
||||
)))
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ impl zcash_address::TryFromAddress for Address {
|
|||
data: [u8; 20],
|
||||
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
|
||||
Ok(Self::Transparent(transparent::Address::from_script_hash(
|
||||
network.try_into()?,
|
||||
&network.try_into()?,
|
||||
data,
|
||||
)))
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl zcash_address::TryFromAddress for Address {
|
|||
network: zcash_address::Network,
|
||||
unified_address: zcash_address::unified::Address,
|
||||
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
|
||||
let network = network.try_into()?;
|
||||
let network = &network.try_into()?;
|
||||
let mut orchard = None;
|
||||
let mut sapling = None;
|
||||
let mut transparent = None;
|
||||
|
@ -144,7 +144,7 @@ impl zcash_address::TryFromAddress for Address {
|
|||
}
|
||||
|
||||
Ok(Self::Unified {
|
||||
network,
|
||||
network: network.clone(),
|
||||
unified_address,
|
||||
orchard,
|
||||
sapling,
|
||||
|
@ -158,7 +158,7 @@ impl Address {
|
|||
pub fn network(&self) -> Network {
|
||||
match &self {
|
||||
Self::Transparent(address) => address.network(),
|
||||
Self::Sapling { network, .. } | Self::Unified { network, .. } => *network,
|
||||
Self::Sapling { network, .. } | Self::Unified { network, .. } => network.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ impl Address {
|
|||
Self::Transparent(address) => Some(address.to_string()),
|
||||
Self::Sapling { address, network } => {
|
||||
let data = address.to_bytes();
|
||||
let address = ZcashAddress::from_sapling((*network).into(), data);
|
||||
let address = ZcashAddress::from_sapling(network.into(), data);
|
||||
Some(address.encode())
|
||||
}
|
||||
Self::Unified { .. } => None,
|
||||
|
|
|
@ -25,19 +25,19 @@ impl ViewingKey {
|
|||
/// Accepts an encoded Sapling viewing key to decode
|
||||
///
|
||||
/// Returns a [`ViewingKey`] if successful, or None otherwise
|
||||
fn parse_sapling(sapling_key: &str, network: Network) -> Option<Self> {
|
||||
fn parse_sapling(sapling_key: &str, network: &Network) -> Option<Self> {
|
||||
SaplingViewingKey::parse(sapling_key, network).map(Self::Sapling)
|
||||
}
|
||||
|
||||
/// Accepts an encoded Orchard viewing key to decode
|
||||
///
|
||||
/// Returns a [`ViewingKey`] if successful, or None otherwise
|
||||
fn parse_orchard(sapling_key: &str, network: Network) -> Option<Self> {
|
||||
fn parse_orchard(sapling_key: &str, network: &Network) -> Option<Self> {
|
||||
OrchardViewingKey::parse(sapling_key, network).map(Self::Orchard)
|
||||
}
|
||||
|
||||
/// Parses an encoded viewing key and returns it as a [`ViewingKey`] type.
|
||||
pub fn parse(key: &str, network: Network) -> Option<Self> {
|
||||
pub fn parse(key: &str, network: &Network) -> Option<Self> {
|
||||
Self::parse_sapling(key, network).or_else(|| Self::parse_orchard(key, network))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ impl OrchardViewingKey {
|
|||
/// Accepts an encoded Orchard viewing key to decode
|
||||
///
|
||||
/// Returns a [`OrchardViewingKey`] if successful, or None otherwise
|
||||
pub fn parse(_key: &str, _network: Network) -> Option<Self> {
|
||||
pub fn parse(_key: &str, _network: &Network) -> Option<Self> {
|
||||
// TODO: parse Orchard viewing keys
|
||||
None
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ impl SaplingViewingKey {
|
|||
/// Accepts an encoded Sapling extended full viewing key to decode
|
||||
///
|
||||
/// Returns a [`SaplingViewingKey::Dfvk`] if successful, or None otherwise
|
||||
fn parse_extended_full_viewing_key(sapling_key: &str, network: Network) -> Option<Self> {
|
||||
fn parse_extended_full_viewing_key(sapling_key: &str, network: &Network) -> Option<Self> {
|
||||
decode_extended_full_viewing_key(network.sapling_efvk_hrp(), sapling_key)
|
||||
// this should fail often, so a debug-level log is okay
|
||||
.map_err(|err| debug!(?err, "could not decode Sapling extended full viewing key"))
|
||||
|
@ -38,7 +38,10 @@ impl SaplingViewingKey {
|
|||
/// Accepts an encoded Sapling diversifiable full viewing key to decode
|
||||
///
|
||||
/// Returns a [`SaplingViewingKey::Dfvk`] if successful, or None otherwise
|
||||
fn parse_diversifiable_full_viewing_key(_sapling_key: &str, _network: Network) -> Option<Self> {
|
||||
fn parse_diversifiable_full_viewing_key(
|
||||
_sapling_key: &str,
|
||||
_network: &Network,
|
||||
) -> Option<Self> {
|
||||
// TODO: Parse Sapling diversifiable full viewing key
|
||||
None
|
||||
}
|
||||
|
@ -46,7 +49,7 @@ impl SaplingViewingKey {
|
|||
/// Accepts an encoded Sapling full viewing key to decode
|
||||
///
|
||||
/// Returns a [`SaplingViewingKey::Fvk`] if successful, or None otherwise
|
||||
fn parse_full_viewing_key(_sapling_key: &str, _network: Network) -> Option<Self> {
|
||||
fn parse_full_viewing_key(_sapling_key: &str, _network: &Network) -> Option<Self> {
|
||||
// TODO: Parse Sapling full viewing key
|
||||
None
|
||||
}
|
||||
|
@ -54,7 +57,7 @@ impl SaplingViewingKey {
|
|||
/// Accepts an encoded Sapling incoming viewing key to decode
|
||||
///
|
||||
/// Returns a [`SaplingViewingKey::Ivk`] if successful, or None otherwise
|
||||
fn parse_incoming_viewing_key(_sapling_key: &str, _network: Network) -> Option<Self> {
|
||||
fn parse_incoming_viewing_key(_sapling_key: &str, _network: &Network) -> Option<Self> {
|
||||
// TODO: Parse Sapling incoming viewing key
|
||||
None
|
||||
}
|
||||
|
@ -62,7 +65,7 @@ impl SaplingViewingKey {
|
|||
/// Accepts an encoded Sapling viewing key to decode
|
||||
///
|
||||
/// Returns a [`SaplingViewingKey`] if successful, or None otherwise
|
||||
pub(super) fn parse(key: &str, network: Network) -> Option<Self> {
|
||||
pub(super) fn parse(key: &str, network: &Network) -> Option<Self> {
|
||||
// TODO: Try types with prefixes first if some don't have prefixes?
|
||||
Self::parse_extended_full_viewing_key(key, network)
|
||||
.or_else(|| Self::parse_diversifiable_full_viewing_key(key, network))
|
||||
|
|
|
@ -10,6 +10,6 @@ pub const ZECPAGES_SAPLING_VIEWING_KEY: &str = "zxviews1q0duytgcqqqqpqre26wkl45g
|
|||
fn parses_sapling_efvk_correctly() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
ViewingKey::parse(ZECPAGES_SAPLING_VIEWING_KEY, Network::Mainnet)
|
||||
ViewingKey::parse(ZECPAGES_SAPLING_VIEWING_KEY, &Network::Mainnet)
|
||||
.expect("should parse hard-coded viewing key successfully");
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ pub trait Version: zcash_history::Version {
|
|||
/// Convert a Block into the NodeData for this version.
|
||||
fn block_to_history_node(
|
||||
block: Arc<Block>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
sapling_root: &sapling::tree::Root,
|
||||
orchard_root: &orchard::tree::Root,
|
||||
) -> Self::NodeData;
|
||||
|
@ -75,7 +75,7 @@ impl Entry {
|
|||
/// (ignored for V1 trees).
|
||||
fn new_leaf<V: Version>(
|
||||
block: Arc<Block>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
sapling_root: &sapling::tree::Root,
|
||||
orchard_root: &orchard::tree::Root,
|
||||
) -> Self {
|
||||
|
@ -106,7 +106,7 @@ impl<V: Version> Tree<V> {
|
|||
/// Will panic if `peaks` is empty.
|
||||
#[allow(clippy::unwrap_in_result)]
|
||||
pub fn new_from_cache(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
network_upgrade: NetworkUpgrade,
|
||||
length: u32,
|
||||
peaks: &BTreeMap<u32, Entry>,
|
||||
|
@ -127,7 +127,7 @@ impl<V: Version> Tree<V> {
|
|||
}
|
||||
let inner = zcash_history::Tree::new(length, peaks_vec, extra_vec);
|
||||
Ok(Tree {
|
||||
network,
|
||||
network: network.clone(),
|
||||
network_upgrade,
|
||||
inner,
|
||||
})
|
||||
|
@ -140,7 +140,7 @@ impl<V: Version> Tree<V> {
|
|||
/// (ignored for V1 trees).
|
||||
#[allow(clippy::unwrap_in_result)]
|
||||
pub fn new_from_block(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
block: Arc<Block>,
|
||||
sapling_root: &sapling::tree::Root,
|
||||
orchard_root: &orchard::tree::Root,
|
||||
|
@ -182,7 +182,7 @@ impl<V: Version> Tree<V> {
|
|||
let height = block
|
||||
.coinbase_height()
|
||||
.expect("block must have coinbase height during contextual verification");
|
||||
let network_upgrade = NetworkUpgrade::current(self.network, height);
|
||||
let network_upgrade = NetworkUpgrade::current(&self.network, height);
|
||||
|
||||
assert!(
|
||||
network_upgrade == self.network_upgrade,
|
||||
|
@ -191,7 +191,7 @@ impl<V: Version> Tree<V> {
|
|||
self.network_upgrade
|
||||
);
|
||||
|
||||
let node_data = V::block_to_history_node(block, self.network, sapling_root, orchard_root);
|
||||
let node_data = V::block_to_history_node(block, &self.network, sapling_root, orchard_root);
|
||||
let appended = self.inner.append_leaf(node_data)?;
|
||||
|
||||
let mut new_nodes = Vec::new();
|
||||
|
@ -233,7 +233,7 @@ impl Version for zcash_history::V1 {
|
|||
/// `orchard_root` is ignored.
|
||||
fn block_to_history_node(
|
||||
block: Arc<Block>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
sapling_root: &sapling::tree::Root,
|
||||
_orchard_root: &orchard::tree::Root,
|
||||
) -> Self::NodeData {
|
||||
|
@ -300,7 +300,7 @@ impl Version for V2 {
|
|||
/// `orchard_root` is the root of the Orchard note commitment tree of the block.
|
||||
fn block_to_history_node(
|
||||
block: Arc<Block>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
sapling_root: &sapling::tree::Root,
|
||||
orchard_root: &orchard::tree::Root,
|
||||
) -> Self::NodeData {
|
||||
|
|
|
@ -11,14 +11,14 @@ use eyre::Result;
|
|||
/// and its next block.
|
||||
#[test]
|
||||
fn tree() -> Result<()> {
|
||||
tree_for_network_upgrade(Network::Mainnet, NetworkUpgrade::Heartwood)?;
|
||||
tree_for_network_upgrade(Network::Testnet, NetworkUpgrade::Heartwood)?;
|
||||
tree_for_network_upgrade(Network::Mainnet, NetworkUpgrade::Canopy)?;
|
||||
tree_for_network_upgrade(Network::Testnet, NetworkUpgrade::Canopy)?;
|
||||
tree_for_network_upgrade(&Network::Mainnet, NetworkUpgrade::Heartwood)?;
|
||||
tree_for_network_upgrade(&Network::Testnet, NetworkUpgrade::Heartwood)?;
|
||||
tree_for_network_upgrade(&Network::Mainnet, NetworkUpgrade::Canopy)?;
|
||||
tree_for_network_upgrade(&Network::Testnet, NetworkUpgrade::Canopy)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn tree_for_network_upgrade(network: Network, network_upgrade: NetworkUpgrade) -> Result<()> {
|
||||
fn tree_for_network_upgrade(network: &Network, network_upgrade: NetworkUpgrade) -> Result<()> {
|
||||
let (blocks, sapling_roots) = network.block_sapling_roots_map();
|
||||
|
||||
let height = network_upgrade.activation_height(network).unwrap().0;
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
|||
///
|
||||
/// If passed a network/height without matching consensus branch ID (pre-Overwinter),
|
||||
/// since `librustzcash` won't be able to parse it.
|
||||
pub fn decrypts_successfully(transaction: &Transaction, network: Network, height: Height) -> bool {
|
||||
pub fn decrypts_successfully(transaction: &Transaction, network: &Network, height: Height) -> bool {
|
||||
let network_upgrade = NetworkUpgrade::current(network, height);
|
||||
let alt_tx = convert_tx_to_librustzcash(transaction, network_upgrade)
|
||||
.expect("zcash_primitives and Zebra transaction formats must be compatible");
|
||||
|
|
|
@ -319,7 +319,7 @@ pub(crate) fn auth_digest(trans: &Transaction) -> AuthDigest {
|
|||
/// Returns None if the address type is not valid or unrecognized.
|
||||
pub(crate) fn transparent_output_address(
|
||||
output: &transparent::Output,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Option<transparent::Address> {
|
||||
let tx_out = zp_tx::components::TxOut::try_from(output)
|
||||
.expect("zcash_primitives and Zebra transparent output formats must be compatible");
|
||||
|
@ -337,8 +337,8 @@ pub(crate) fn transparent_output_address(
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Network> for zcash_primitives::consensus::Network {
|
||||
fn from(network: Network) -> Self {
|
||||
impl From<&Network> for zcash_primitives::consensus::Network {
|
||||
fn from(network: &Network) -> Self {
|
||||
match network {
|
||||
Network::Mainnet => zcash_primitives::consensus::Network::MainNetwork,
|
||||
Network::Testnet => zcash_primitives::consensus::Network::TestNetwork,
|
||||
|
|
|
@ -60,7 +60,7 @@ fn incremental_roots_with_blocks_for_network(network: Network) -> Result<()> {
|
|||
let (blocks, sapling_roots) = network.block_sapling_roots_map();
|
||||
|
||||
let height = NetworkUpgrade::Sapling
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.unwrap()
|
||||
.0;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ fn incremental_roots_with_blocks_for_network(network: Network) -> Result<()> {
|
|||
|
||||
// Load the Genesis height.
|
||||
let genesis_height = NetworkUpgrade::Genesis
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.unwrap()
|
||||
.0;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ impl Transaction {
|
|||
/// Generate a proptest strategy for V1 Transactions
|
||||
pub fn v1_strategy(ledger_state: LedgerState) -> BoxedStrategy<Self> {
|
||||
(
|
||||
transparent::Input::vec_strategy(ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
transparent::Input::vec_strategy(&ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
vec(any::<transparent::Output>(), 0..MAX_ARBITRARY_ITEMS),
|
||||
any::<LockTime>(),
|
||||
)
|
||||
|
@ -61,7 +61,7 @@ impl Transaction {
|
|||
/// Generate a proptest strategy for V2 Transactions
|
||||
pub fn v2_strategy(ledger_state: LedgerState) -> BoxedStrategy<Self> {
|
||||
(
|
||||
transparent::Input::vec_strategy(ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
transparent::Input::vec_strategy(&ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
vec(any::<transparent::Output>(), 0..MAX_ARBITRARY_ITEMS),
|
||||
any::<LockTime>(),
|
||||
option::of(any::<JoinSplitData<Bctv14Proof>>()),
|
||||
|
@ -80,7 +80,7 @@ impl Transaction {
|
|||
/// Generate a proptest strategy for V3 Transactions
|
||||
pub fn v3_strategy(ledger_state: LedgerState) -> BoxedStrategy<Self> {
|
||||
(
|
||||
transparent::Input::vec_strategy(ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
transparent::Input::vec_strategy(&ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
vec(any::<transparent::Output>(), 0..MAX_ARBITRARY_ITEMS),
|
||||
any::<LockTime>(),
|
||||
any::<block::Height>(),
|
||||
|
@ -101,7 +101,7 @@ impl Transaction {
|
|||
/// Generate a proptest strategy for V4 Transactions
|
||||
pub fn v4_strategy(ledger_state: LedgerState) -> BoxedStrategy<Self> {
|
||||
(
|
||||
transparent::Input::vec_strategy(ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
transparent::Input::vec_strategy(&ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
vec(any::<transparent::Output>(), 0..MAX_ARBITRARY_ITEMS),
|
||||
any::<LockTime>(),
|
||||
any::<block::Height>(),
|
||||
|
@ -146,7 +146,7 @@ impl Transaction {
|
|||
NetworkUpgrade::branch_id_strategy(),
|
||||
any::<LockTime>(),
|
||||
any::<block::Height>(),
|
||||
transparent::Input::vec_strategy(ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
transparent::Input::vec_strategy(&ledger_state, MAX_ARBITRARY_ITEMS),
|
||||
vec(any::<transparent::Output>(), 0..MAX_ARBITRARY_ITEMS),
|
||||
option::of(any::<sapling::ShieldedData<sapling::SharedAnchor>>()),
|
||||
option::of(any::<orchard::ShieldedData>()),
|
||||
|
@ -196,7 +196,7 @@ impl Transaction {
|
|||
len: usize,
|
||||
) -> BoxedStrategy<Vec<Arc<Self>>> {
|
||||
// TODO: fixup coinbase miner subsidy
|
||||
let coinbase = Transaction::arbitrary_with(ledger_state).prop_map(Arc::new);
|
||||
let coinbase = Transaction::arbitrary_with(ledger_state.clone()).prop_map(Arc::new);
|
||||
ledger_state.has_coinbase = false;
|
||||
let remainder = vec(
|
||||
Transaction::arbitrary_with(ledger_state).prop_map(Arc::new),
|
||||
|
@ -787,7 +787,7 @@ impl Arbitrary for Transaction {
|
|||
Self::v4_strategy(ledger_state)
|
||||
}
|
||||
NetworkUpgrade::Nu5 => prop_oneof![
|
||||
Self::v4_strategy(ledger_state),
|
||||
Self::v4_strategy(ledger_state.clone()),
|
||||
Self::v5_strategy(ledger_state)
|
||||
]
|
||||
.boxed(),
|
||||
|
@ -859,7 +859,7 @@ impl Arbitrary for VerifiedUnminedTx {
|
|||
/// converting sapling shielded data from v4 to v5 if possible.
|
||||
pub fn transaction_to_fake_v5(
|
||||
trans: &Transaction,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: block::Height,
|
||||
) -> Transaction {
|
||||
use Transaction::*;
|
||||
|
@ -993,7 +993,7 @@ fn sapling_spend_v4_to_fake_v5(
|
|||
|
||||
/// Iterate over V4 transactions in the block test vectors for the specified `network`.
|
||||
pub fn test_transactions(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> impl DoubleEndedIterator<Item = (block::Height, Arc<Transaction>)> {
|
||||
let blocks = network.block_iter();
|
||||
|
||||
|
@ -1005,7 +1005,7 @@ pub fn test_transactions(
|
|||
/// These transactions are converted from non-V5 transactions that exist in the provided network
|
||||
/// blocks.
|
||||
pub fn fake_v5_transactions_for_network<'b>(
|
||||
network: Network,
|
||||
network: &'b Network,
|
||||
blocks: impl DoubleEndedIterator<Item = (&'b u32, &'b &'static [u8])> + 'b,
|
||||
) -> impl DoubleEndedIterator<Item = Transaction> + 'b {
|
||||
transactions_from_blocks(blocks)
|
||||
|
|
|
@ -12,7 +12,7 @@ impl Transaction {
|
|||
/// Returns a new version 5 coinbase transaction for `network` and `height`,
|
||||
/// which contains the specified `outputs`.
|
||||
pub fn new_v5_coinbase(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: Height,
|
||||
outputs: impl IntoIterator<Item = (Amount<NonNegative>, transparent::Script)>,
|
||||
extra_coinbase_data: Vec<u8>,
|
||||
|
@ -109,7 +109,7 @@ impl Transaction {
|
|||
/// If `like_zcashd` is true, try to match the coinbase transactions generated by `zcashd`
|
||||
/// in the `getblocktemplate` RPC.
|
||||
pub fn new_v4_coinbase(
|
||||
_network: Network,
|
||||
_network: &Network,
|
||||
height: Height,
|
||||
outputs: impl IntoIterator<Item = (Amount<NonNegative>, transparent::Script)>,
|
||||
like_zcashd: bool,
|
||||
|
|
|
@ -150,13 +150,13 @@ fn transaction_valid_network_upgrade_strategy() -> Result<()> {
|
|||
// Update with new transaction versions as needed
|
||||
let strategy = LedgerState::coinbase_strategy(None, 5, true).prop_flat_map(|ledger_state| {
|
||||
(
|
||||
Just(ledger_state.network),
|
||||
Just(ledger_state.network.clone()),
|
||||
Block::arbitrary_with(ledger_state),
|
||||
)
|
||||
});
|
||||
|
||||
proptest!(|((network, block) in strategy)| {
|
||||
block.check_transaction_network_upgrade_consistency(network)?;
|
||||
block.check_transaction_network_upgrade_consistency(&network)?;
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -352,7 +352,7 @@ fn fake_v5_round_trip_for_network(network: Network) {
|
|||
let block_iter = network.block_iter();
|
||||
|
||||
let overwinter_activation_height = NetworkUpgrade::Overwinter
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("a valid height")
|
||||
.0;
|
||||
|
||||
|
@ -380,7 +380,7 @@ fn fake_v5_round_trip_for_network(network: Network) {
|
|||
.transactions
|
||||
.iter()
|
||||
.map(AsRef::as_ref)
|
||||
.map(|t| arbitrary::transaction_to_fake_v5(t, network, Height(*height)))
|
||||
.map(|t| arbitrary::transaction_to_fake_v5(t, &network, Height(*height)))
|
||||
.map(Into::into)
|
||||
.collect();
|
||||
|
||||
|
@ -500,12 +500,12 @@ fn fake_v5_librustzcash_round_trip_for_network(network: Network) {
|
|||
let block_iter = network.block_iter();
|
||||
|
||||
let overwinter_activation_height = NetworkUpgrade::Overwinter
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("a valid height")
|
||||
.0;
|
||||
|
||||
let nu5_activation_height = NetworkUpgrade::Nu5
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.unwrap_or(Height::MAX_EXPIRY_HEIGHT)
|
||||
.0;
|
||||
|
||||
|
@ -525,7 +525,7 @@ fn fake_v5_librustzcash_round_trip_for_network(network: Network) {
|
|||
.transactions
|
||||
.iter()
|
||||
.map(AsRef::as_ref)
|
||||
.map(|t| arbitrary::transaction_to_fake_v5(t, network, Height(*height)))
|
||||
.map(|t| arbitrary::transaction_to_fake_v5(t, &network, Height(*height)))
|
||||
.map(Into::into)
|
||||
.collect();
|
||||
|
||||
|
@ -940,7 +940,7 @@ fn binding_signatures_for_network(network: Network) {
|
|||
let block_iter = network.block_iter();
|
||||
|
||||
for (height, bytes) in block_iter {
|
||||
let upgrade = NetworkUpgrade::current(network, Height(*height));
|
||||
let upgrade = NetworkUpgrade::current(&network, Height(*height));
|
||||
|
||||
let block = bytes
|
||||
.zcash_deserialize_into::<Block>()
|
||||
|
|
|
@ -426,7 +426,7 @@ impl Output {
|
|||
/// Return the destination address from a transparent output.
|
||||
///
|
||||
/// Returns None if the address type is not valid or unrecognized.
|
||||
pub fn address(&self, network: Network) -> Option<Address> {
|
||||
pub fn address(&self, network: &Network) -> Option<Address> {
|
||||
zcash_primitives::transparent_output_address(self, network)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ use proptest::prelude::*;
|
|||
///
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#transparentaddrencoding>
|
||||
#[derive(
|
||||
Copy, Clone, Eq, PartialEq, Hash, serde_with::SerializeDisplay, serde_with::DeserializeFromStr,
|
||||
Clone, Eq, PartialEq, Hash, serde_with::SerializeDisplay, serde_with::DeserializeFromStr,
|
||||
)]
|
||||
#[cfg_attr(
|
||||
any(test, feature = "proptest-impl"),
|
||||
|
@ -183,26 +183,26 @@ impl ToAddressWithNetwork for PublicKey {
|
|||
|
||||
impl Address {
|
||||
/// Create an address for the given public key hash and network.
|
||||
pub fn from_pub_key_hash(network: Network, pub_key_hash: [u8; 20]) -> Self {
|
||||
pub fn from_pub_key_hash(network: &Network, pub_key_hash: [u8; 20]) -> Self {
|
||||
Self::PayToPublicKeyHash {
|
||||
network,
|
||||
network: network.clone(),
|
||||
pub_key_hash,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create an address for the given script hash and network.
|
||||
pub fn from_script_hash(network: Network, script_hash: [u8; 20]) -> Self {
|
||||
pub fn from_script_hash(network: &Network, script_hash: [u8; 20]) -> Self {
|
||||
Self::PayToScriptHash {
|
||||
network,
|
||||
network: network.clone(),
|
||||
script_hash,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the network for this address.
|
||||
pub fn network(&self) -> Network {
|
||||
match *self {
|
||||
Address::PayToScriptHash { network, .. } => network,
|
||||
Address::PayToPublicKeyHash { network, .. } => network,
|
||||
match self {
|
||||
Address::PayToScriptHash { network, .. } => network.clone(),
|
||||
Address::PayToPublicKeyHash { network, .. } => network.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use super::{CoinbaseData, Input, OutPoint, Script, GENESIS_COINBASE_DATA};
|
|||
|
||||
impl Input {
|
||||
/// Construct a strategy for creating valid-ish vecs of Inputs.
|
||||
pub fn vec_strategy(ledger_state: LedgerState, max_size: usize) -> BoxedStrategy<Vec<Self>> {
|
||||
pub fn vec_strategy(ledger_state: &LedgerState, max_size: usize) -> BoxedStrategy<Vec<Self>> {
|
||||
if ledger_state.has_coinbase {
|
||||
Self::arbitrary_with(Some(ledger_state.height))
|
||||
.prop_map(|input| vec![input])
|
||||
|
|
|
@ -31,7 +31,7 @@ fn input_coinbase_vecs_only_have_coinbase_input() -> Result<()> {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
let strategy = LedgerState::coinbase_strategy(None, None, false)
|
||||
.prop_flat_map(|ledger_state| Input::vec_strategy(ledger_state, MAX_ARBITRARY_ITEMS));
|
||||
.prop_flat_map(|ledger_state| Input::vec_strategy(&ledger_state, MAX_ARBITRARY_ITEMS));
|
||||
|
||||
proptest!(|(inputs in strategy.prop_map(SummaryDebug))| {
|
||||
let len = inputs.len();
|
||||
|
|
|
@ -64,17 +64,17 @@ fn get_transparent_output_address() -> Result<()> {
|
|||
// for the prefixes.
|
||||
|
||||
// Script hash 1b8a9bda4b62cd0d0582b55455d0778c86f8628f
|
||||
let addr = transparent_output_address(&transaction.outputs()[0], Network::Mainnet)
|
||||
let addr = transparent_output_address(&transaction.outputs()[0], &Network::Mainnet)
|
||||
.expect("should return address");
|
||||
assert_eq!(addr.to_string(), "t3M5FDmPfWNRG3HRLddbicsuSCvKuk9hxzZ");
|
||||
let addr = transparent_output_address(&transaction.outputs()[0], Network::Testnet)
|
||||
let addr = transparent_output_address(&transaction.outputs()[0], &Network::Testnet)
|
||||
.expect("should return address");
|
||||
assert_eq!(addr.to_string(), "t294SGSVoNq2daz15ZNbmAW65KQZ5e3nN5G");
|
||||
// Public key hash e4ff5512ffafe9287992a1cd177ca6e408e03003
|
||||
let addr = transparent_output_address(&transaction.outputs()[1], Network::Mainnet)
|
||||
let addr = transparent_output_address(&transaction.outputs()[1], &Network::Mainnet)
|
||||
.expect("should return address");
|
||||
assert_eq!(addr.to_string(), "t1ekRwsd4LaSsd6NXgsx66q2HxQWTLCF44y");
|
||||
let addr = transparent_output_address(&transaction.outputs()[1], Network::Testnet)
|
||||
let addr = transparent_output_address(&transaction.outputs()[1], &Network::Testnet)
|
||||
.expect("should return address");
|
||||
assert_eq!(addr.to_string(), "tmWbBGi7TjExNmLZyMcFpxVh3ZPbGrpbX3H");
|
||||
|
||||
|
@ -103,7 +103,7 @@ fn get_transparent_output_address_with_blocks_for_network(network: Network) {
|
|||
|
||||
for (idx, tx) in block.transactions.iter().enumerate() {
|
||||
for output in tx.outputs() {
|
||||
let addr = output.address(network);
|
||||
let addr = output.address(&network);
|
||||
if addr.is_none() && idx == 0 && output.lock_script.as_raw_bytes()[0] == 0x21 {
|
||||
// There are a bunch of coinbase transactions with pay-to-pubkey scripts
|
||||
// which we don't support; skip them
|
||||
|
|
|
@ -454,7 +454,7 @@ fn check_testnet_minimum_difficulty_block(height: block::Height) -> Result<(), R
|
|||
// threshold, as documented in ZIP-205 and ZIP-208:
|
||||
// https://zips.z.cash/zip-0205#change-to-difficulty-adjustment-on-testnet
|
||||
// https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-testnet
|
||||
match NetworkUpgrade::minimum_difficulty_spacing_for_height(Network::Testnet, height) {
|
||||
match NetworkUpgrade::minimum_difficulty_spacing_for_height(&Network::Testnet, height) {
|
||||
None => Err(eyre!("the minimum difficulty rule is not active"))?,
|
||||
Some(spacing) if (time_gap <= spacing) => Err(eyre!(
|
||||
"minimum difficulty block times must be more than 6 target spacing intervals apart"
|
||||
|
|
|
@ -41,7 +41,7 @@ bls12_381 = "0.8.0"
|
|||
halo2 = { package = "halo2_proofs", version = "0.3.0" }
|
||||
jubjub = "0.10.0"
|
||||
rand = "0.8.5"
|
||||
rayon = "1.8.1"
|
||||
rayon = "1.9.0"
|
||||
|
||||
chrono = { version = "0.4.34", default-features = false, features = ["clock", "std"] }
|
||||
displaydoc = "0.2.4"
|
||||
|
@ -51,8 +51,8 @@ serde = { version = "1.0.196", features = ["serde_derive"] }
|
|||
|
||||
futures = "0.3.30"
|
||||
futures-util = "0.3.28"
|
||||
metrics = "0.22.1"
|
||||
thiserror = "1.0.57"
|
||||
metrics = "0.22.3"
|
||||
thiserror = "1.0.58"
|
||||
tokio = { version = "1.36.0", features = ["time", "sync", "tracing", "rt-multi-thread"] }
|
||||
tower = { version = "0.4.13", features = ["timeout", "util", "buffer"] }
|
||||
tracing = "0.1.39"
|
||||
|
@ -79,7 +79,7 @@ proptest = { version = "1.4.0", optional = true }
|
|||
proptest-derive = { version = "0.4.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
color-eyre = "0.6.2"
|
||||
color-eyre = "0.6.3"
|
||||
# This is a transitive dependency via color-eyre.
|
||||
# Enable a feature that makes tinyvec compile much faster.
|
||||
tinyvec = { version = "1.6.0", features = ["rustc_1_55"] }
|
||||
|
|
|
@ -108,9 +108,9 @@ where
|
|||
V::Future: Send + 'static,
|
||||
{
|
||||
/// Creates a new SemanticBlockVerifier
|
||||
pub fn new(network: Network, state_service: S, transaction_verifier: V) -> Self {
|
||||
pub fn new(network: &Network, state_service: S, transaction_verifier: V) -> Self {
|
||||
Self {
|
||||
network,
|
||||
network: network.clone(),
|
||||
state_service,
|
||||
transaction_verifier,
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ where
|
|||
fn call(&mut self, request: Request) -> Self::Future {
|
||||
let mut state_service = self.state_service.clone();
|
||||
let mut transaction_verifier = self.transaction_verifier.clone();
|
||||
let network = self.network;
|
||||
let network = self.network.clone();
|
||||
|
||||
let block = request.block();
|
||||
|
||||
|
@ -180,11 +180,11 @@ where
|
|||
// > acceptance rules (excluding the check for a valid proof-of-work).
|
||||
// <https://en.bitcoin.it/wiki/BIP_0023#Block_Proposal>
|
||||
if request.is_proposal() {
|
||||
check::difficulty_threshold_is_valid(&block.header, network, &height, &hash)?;
|
||||
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::difficulty_is_valid(&block.header, &network, &height, &hash)?;
|
||||
check::equihash_solution_is_valid(&block.header)?;
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ where
|
|||
let transaction_hashes: Arc<[_]> =
|
||||
block.transactions.iter().map(|t| t.hash()).collect();
|
||||
|
||||
check::merkle_root_validity(network, &block, &transaction_hashes)?;
|
||||
check::merkle_root_validity(&network, &block, &transaction_hashes)?;
|
||||
|
||||
// Since errors cause an early exit, try to do the
|
||||
// quick checks first.
|
||||
|
@ -205,12 +205,12 @@ where
|
|||
check::time_is_valid_at(&block.header, now, &height, &hash)
|
||||
.map_err(VerifyBlockError::Time)?;
|
||||
let coinbase_tx = check::coinbase_is_first(&block)?;
|
||||
check::subsidy_is_valid(&block, network)?;
|
||||
check::subsidy_is_valid(&block, &network)?;
|
||||
|
||||
// Now do the slower checks
|
||||
|
||||
// Check compatibility with ZIP-212 shielded Sapling and Orchard coinbase output decryption
|
||||
tx::check::coinbase_outputs_are_decryptable(&coinbase_tx, network, height)?;
|
||||
tx::check::coinbase_outputs_are_decryptable(&coinbase_tx, &network, height)?;
|
||||
|
||||
// Send transactions to the transaction verifier to be checked
|
||||
let mut async_checks = FuturesUnordered::new();
|
||||
|
@ -277,7 +277,7 @@ where
|
|||
hash,
|
||||
source: amount_error,
|
||||
})?;
|
||||
check::miner_fees_are_valid(&block, network, block_miner_fees)?;
|
||||
check::miner_fees_are_valid(&block, &network, block_miner_fees)?;
|
||||
|
||||
// Finally, submit the block for contextual verification.
|
||||
let new_outputs = Arc::into_inner(known_utxos)
|
||||
|
|
|
@ -67,7 +67,7 @@ pub fn coinbase_is_first(block: &Block) -> Result<Arc<transaction::Transaction>,
|
|||
/// If the header difficulty threshold is invalid, returns an error containing `height` and `hash`.
|
||||
pub fn difficulty_threshold_is_valid(
|
||||
header: &Header,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: &Height,
|
||||
hash: &Hash,
|
||||
) -> Result<ExpandedDifficulty, BlockError> {
|
||||
|
@ -86,7 +86,7 @@ pub fn difficulty_threshold_is_valid(
|
|||
*height,
|
||||
*hash,
|
||||
difficulty_threshold,
|
||||
network,
|
||||
network.clone(),
|
||||
network.target_difficulty_limit(),
|
||||
))?;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ pub fn difficulty_threshold_is_valid(
|
|||
/// If the block is invalid, returns an error containing `height` and `hash`.
|
||||
pub fn difficulty_is_valid(
|
||||
header: &Header,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: &Height,
|
||||
hash: &Hash,
|
||||
) -> Result<(), BlockError> {
|
||||
|
@ -123,7 +123,7 @@ pub fn difficulty_is_valid(
|
|||
*height,
|
||||
*hash,
|
||||
difficulty_threshold,
|
||||
network,
|
||||
network.clone(),
|
||||
))?;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ pub fn equihash_solution_is_valid(header: &Header) -> Result<(), equihash::Error
|
|||
/// Returns `Ok(())` if the block subsidy in `block` is valid for `network`
|
||||
///
|
||||
/// [3.9]: https://zips.z.cash/protocol/protocol.pdf#subsidyconcepts
|
||||
pub fn subsidy_is_valid(block: &Block, network: Network) -> Result<(), BlockError> {
|
||||
pub fn subsidy_is_valid(block: &Block, network: &Network) -> Result<(), BlockError> {
|
||||
let height = block.coinbase_height().ok_or(SubsidyError::NoCoinbase)?;
|
||||
let coinbase = block.transactions.first().ok_or(SubsidyError::NoCoinbase)?;
|
||||
|
||||
|
@ -189,7 +189,7 @@ pub fn subsidy_is_valid(block: &Block, network: Network) -> Result<(), BlockErro
|
|||
subsidy::funding_streams::funding_stream_address(height, network, receiver);
|
||||
|
||||
let has_expected_output =
|
||||
subsidy::funding_streams::filter_outputs_by_address(coinbase, address)
|
||||
subsidy::funding_streams::filter_outputs_by_address(coinbase, &address)
|
||||
.iter()
|
||||
.map(zebra_chain::transparent::Output::value)
|
||||
.any(|value| value == expected_amount);
|
||||
|
@ -210,7 +210,7 @@ pub fn subsidy_is_valid(block: &Block, network: Network) -> Result<(), BlockErro
|
|||
/// [7.1.2]: https://zips.z.cash/protocol/protocol.pdf#txnconsensus
|
||||
pub fn miner_fees_are_valid(
|
||||
block: &Block,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
block_miner_fees: Amount<NonNegative>,
|
||||
) -> Result<(), BlockError> {
|
||||
let height = block.coinbase_height().ok_or(SubsidyError::NoCoinbase)?;
|
||||
|
@ -289,7 +289,7 @@ pub fn time_is_valid_at(
|
|||
/// [7.1]: https://zips.z.cash/protocol/nu5.pdf#txnencodingandconsensus
|
||||
/// [7.6]: https://zips.z.cash/protocol/nu5.pdf#blockheader
|
||||
pub fn merkle_root_validity(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
block: &Block,
|
||||
transaction_hashes: &[transaction::Hash],
|
||||
) -> Result<(), BlockError> {
|
||||
|
|
|
@ -23,13 +23,13 @@ mod tests;
|
|||
/// [7.8]: https://zips.z.cash/protocol/protocol.pdf#subsidies
|
||||
pub fn funding_stream_values(
|
||||
height: Height,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Result<HashMap<FundingStreamReceiver, Amount<NonNegative>>, Error> {
|
||||
let canopy_height = Canopy.activation_height(network).unwrap();
|
||||
let mut results = HashMap::new();
|
||||
|
||||
if height >= canopy_height {
|
||||
let range = FUNDING_STREAM_HEIGHT_RANGES.get(&network).unwrap();
|
||||
let range = FUNDING_STREAM_HEIGHT_RANGES.get(network).unwrap();
|
||||
if range.contains(&height) {
|
||||
let block_subsidy = block_subsidy(height, network)?;
|
||||
for (&receiver, &numerator) in FUNDING_STREAM_RECEIVER_NUMERATORS.iter() {
|
||||
|
@ -52,7 +52,7 @@ pub fn funding_stream_values(
|
|||
/// as described in [protocol specification §7.10][7.10]
|
||||
///
|
||||
/// [7.10]: https://zips.z.cash/protocol/protocol.pdf#fundingstreams
|
||||
fn funding_stream_address_period(height: Height, network: Network) -> u32 {
|
||||
fn funding_stream_address_period(height: Height, network: &Network) -> u32 {
|
||||
// Spec equation: `address_period = floor((height - (height_for_halving(1) - post_blossom_halving_interval))/funding_stream_address_change_interval)`,
|
||||
// <https://zips.z.cash/protocol/protocol.pdf#fundingstreams>
|
||||
//
|
||||
|
@ -76,14 +76,14 @@ fn funding_stream_address_period(height: Height, network: Network) -> u32 {
|
|||
/// as described in [protocol specification §7.10][7.10]
|
||||
///
|
||||
/// [7.10]: https://zips.z.cash/protocol/protocol.pdf#fundingstreams
|
||||
fn funding_stream_address_index(height: Height, network: Network) -> usize {
|
||||
fn funding_stream_address_index(height: Height, network: &Network) -> usize {
|
||||
let num_addresses = network.num_funding_streams();
|
||||
|
||||
let index = 1u32
|
||||
.checked_add(funding_stream_address_period(height, network))
|
||||
.expect("no overflow should happen in this sum")
|
||||
.checked_sub(funding_stream_address_period(
|
||||
FUNDING_STREAM_HEIGHT_RANGES.get(&network).unwrap().start,
|
||||
FUNDING_STREAM_HEIGHT_RANGES.get(network).unwrap().start,
|
||||
network,
|
||||
))
|
||||
.expect("no overflow should happen in this sub") as usize;
|
||||
|
@ -100,12 +100,12 @@ fn funding_stream_address_index(height: Height, network: Network) -> usize {
|
|||
/// only use transparent addresses,
|
||||
pub fn funding_stream_address(
|
||||
height: Height,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
receiver: FundingStreamReceiver,
|
||||
) -> transparent::Address {
|
||||
let index = funding_stream_address_index(height, network);
|
||||
let address = &FUNDING_STREAM_ADDRESSES
|
||||
.get(&network)
|
||||
.get(network)
|
||||
.expect("there is always another hash map as value for a given valid network")
|
||||
.get(&receiver)
|
||||
.expect("in the inner hash map there is always a vector of strings with addresses")[index];
|
||||
|
@ -127,7 +127,7 @@ pub fn funding_stream_recipient_info(
|
|||
/// as the given lock_script as described in [protocol specification §7.10][7.10]
|
||||
///
|
||||
/// [7.10]: https://zips.z.cash/protocol/protocol.pdf#fundingstreams
|
||||
pub fn check_script_form(lock_script: &Script, address: transparent::Address) -> bool {
|
||||
pub fn check_script_form(lock_script: &Script, address: &transparent::Address) -> bool {
|
||||
assert!(
|
||||
address.is_script_hash(),
|
||||
"incorrect funding stream address constant: {address} \
|
||||
|
@ -141,7 +141,7 @@ pub fn check_script_form(lock_script: &Script, address: transparent::Address) ->
|
|||
}
|
||||
|
||||
/// Returns a new funding stream coinbase output lock script, which pays to the P2SH `address`.
|
||||
pub fn new_coinbase_script(address: transparent::Address) -> Script {
|
||||
pub fn new_coinbase_script(address: &transparent::Address) -> Script {
|
||||
assert!(
|
||||
address.is_script_hash(),
|
||||
"incorrect coinbase script address: {address} \
|
||||
|
@ -158,7 +158,7 @@ pub fn new_coinbase_script(address: transparent::Address) -> Script {
|
|||
/// Returns a list of outputs in `transaction`, which have a script address equal to `address`.
|
||||
pub fn filter_outputs_by_address(
|
||||
transaction: &Transaction,
|
||||
address: transparent::Address,
|
||||
address: &transparent::Address,
|
||||
) -> Vec<transparent::Output> {
|
||||
transaction
|
||||
.outputs()
|
||||
|
|
|
@ -8,7 +8,7 @@ use super::*;
|
|||
#[test]
|
||||
fn test_funding_stream_values() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
let network = Network::Mainnet;
|
||||
let network = &Network::Mainnet;
|
||||
|
||||
// funding streams not active
|
||||
let canopy_height_minus1 = Canopy.activation_height(network).unwrap() - 1;
|
||||
|
@ -44,7 +44,7 @@ fn test_funding_stream_values() -> Result<(), Report> {
|
|||
);
|
||||
|
||||
// funding stream period is ending
|
||||
let range = FUNDING_STREAM_HEIGHT_RANGES.get(&network).unwrap();
|
||||
let range = FUNDING_STREAM_HEIGHT_RANGES.get(network).unwrap();
|
||||
let end = range.end;
|
||||
let last = end - 1;
|
||||
|
||||
|
@ -74,7 +74,7 @@ fn test_funding_stream_addresses() -> Result<(), Report> {
|
|||
);
|
||||
|
||||
// Asserts if address is not a P2SH address.
|
||||
let _script = new_coinbase_script(address);
|
||||
let _script = new_coinbase_script(&address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::{funding_stream_values, parameters::subsidy::*};
|
|||
/// [7.8]: https://zips.z.cash/protocol/protocol.pdf#subsidies
|
||||
///
|
||||
/// Returns `None` if the divisor would overflow a `u64`.
|
||||
pub fn halving_divisor(height: Height, network: Network) -> Option<u64> {
|
||||
pub fn halving_divisor(height: Height, network: &Network) -> Option<u64> {
|
||||
let blossom_height = Blossom
|
||||
.activation_height(network)
|
||||
.expect("blossom activation height should be available");
|
||||
|
@ -64,7 +64,7 @@ pub fn halving_divisor(height: Height, network: Network) -> Option<u64> {
|
|||
/// `BlockSubsidy(height)` as described in [protocol specification §7.8][7.8]
|
||||
///
|
||||
/// [7.8]: https://zips.z.cash/protocol/protocol.pdf#subsidies
|
||||
pub fn block_subsidy(height: Height, network: Network) -> Result<Amount<NonNegative>, Error> {
|
||||
pub fn block_subsidy(height: Height, network: &Network) -> Result<Amount<NonNegative>, Error> {
|
||||
let blossom_height = Blossom
|
||||
.activation_height(network)
|
||||
.expect("blossom activation height should be available");
|
||||
|
@ -97,7 +97,7 @@ pub fn block_subsidy(height: Height, network: Network) -> Result<Amount<NonNegat
|
|||
/// `MinerSubsidy(height)` as described in [protocol specification §7.8][7.8]
|
||||
///
|
||||
/// [7.8]: https://zips.z.cash/protocol/protocol.pdf#subsidies
|
||||
pub fn miner_subsidy(height: Height, network: Network) -> Result<Amount<NonNegative>, Error> {
|
||||
pub fn miner_subsidy(height: Height, network: &Network) -> Result<Amount<NonNegative>, Error> {
|
||||
let total_funding_stream_amount: Result<Amount<NonNegative>, _> =
|
||||
funding_stream_values(height, network)?.values().sum();
|
||||
|
||||
|
@ -123,13 +123,13 @@ mod test {
|
|||
fn halving_test() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
halving_for_network(Network::Mainnet)?;
|
||||
halving_for_network(Network::Testnet)?;
|
||||
halving_for_network(&Network::Mainnet)?;
|
||||
halving_for_network(&Network::Testnet)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn halving_for_network(network: Network) -> Result<(), Report> {
|
||||
fn halving_for_network(network: &Network) -> Result<(), Report> {
|
||||
let blossom_height = Blossom.activation_height(network).unwrap();
|
||||
let first_halving_height = network.height_for_first_halving();
|
||||
|
||||
|
@ -249,13 +249,13 @@ mod test {
|
|||
fn block_subsidy_test() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
block_subsidy_for_network(Network::Mainnet)?;
|
||||
block_subsidy_for_network(Network::Testnet)?;
|
||||
block_subsidy_for_network(&Network::Mainnet)?;
|
||||
block_subsidy_for_network(&Network::Testnet)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn block_subsidy_for_network(network: Network) -> Result<(), Report> {
|
||||
fn block_subsidy_for_network(network: &Network) -> Result<(), Report> {
|
||||
let blossom_height = Blossom.activation_height(network).unwrap();
|
||||
let first_halving_height = network.height_for_first_halving();
|
||||
|
||||
|
|
|
@ -139,12 +139,12 @@ async fn check_transcripts() -> Result<(), Report> {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
let network = Network::Mainnet;
|
||||
let state_service = zebra_state::init_test(network);
|
||||
let state_service = zebra_state::init_test(&network);
|
||||
|
||||
let transaction = transaction::Verifier::new(network, state_service.clone());
|
||||
let transaction = transaction::Verifier::new(&network, state_service.clone());
|
||||
let transaction = Buffer::new(BoxService::new(transaction), 1);
|
||||
let block_verifier = Buffer::new(
|
||||
SemanticBlockVerifier::new(network, state_service.clone(), transaction),
|
||||
SemanticBlockVerifier::new(&network, state_service.clone(), transaction),
|
||||
1,
|
||||
);
|
||||
|
||||
|
@ -196,7 +196,7 @@ fn difficulty_is_valid_for_network(network: Network) -> Result<(), Report> {
|
|||
.zcash_deserialize_into::<Block>()
|
||||
.expect("block is structurally valid");
|
||||
|
||||
check::difficulty_is_valid(&block.header, network, &Height(height), &block.hash())
|
||||
check::difficulty_is_valid(&block.header, &network, &Height(height), &block.hash())
|
||||
.expect("the difficulty from a historical block should be valid");
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ fn difficulty_validation_failure() -> Result<(), Report> {
|
|||
|
||||
// Validate the block
|
||||
let result =
|
||||
check::difficulty_is_valid(&block.header, Network::Mainnet, &height, &hash).unwrap_err();
|
||||
check::difficulty_is_valid(&block.header, &Network::Mainnet, &height, &hash).unwrap_err();
|
||||
let expected = BlockError::InvalidDifficulty(height, hash);
|
||||
assert_eq!(expected, result);
|
||||
|
||||
|
@ -235,7 +235,7 @@ fn difficulty_validation_failure() -> Result<(), Report> {
|
|||
|
||||
// Validate the block as if it is a mainnet block
|
||||
let result =
|
||||
check::difficulty_is_valid(&block.header, Network::Mainnet, &height, &hash).unwrap_err();
|
||||
check::difficulty_is_valid(&block.header, &Network::Mainnet, &height, &hash).unwrap_err();
|
||||
let expected = BlockError::TargetDifficultyLimit(
|
||||
height,
|
||||
hash,
|
||||
|
@ -255,7 +255,7 @@ fn difficulty_validation_failure() -> Result<(), Report> {
|
|||
let difficulty_threshold = block.header.difficulty_threshold.to_expanded().unwrap();
|
||||
|
||||
// Validate the block
|
||||
let result = check::difficulty_is_valid(&block.header, Network::Mainnet, &height, &bad_hash)
|
||||
let result = check::difficulty_is_valid(&block.header, &Network::Mainnet, &height, &bad_hash)
|
||||
.unwrap_err();
|
||||
let expected =
|
||||
BlockError::DifficultyFilter(height, bad_hash, difficulty_threshold, Network::Mainnet);
|
||||
|
@ -301,12 +301,13 @@ fn subsidy_is_valid_for_network(network: Network) -> Result<(), Report> {
|
|||
.expect("block is structurally valid");
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is known");
|
||||
|
||||
// TODO: first halving, second halving, third halving, and very large halvings
|
||||
if block::Height(height) >= canopy_activation_height {
|
||||
check::subsidy_is_valid(&block, network).expect("subsidies should pass for this block");
|
||||
check::subsidy_is_valid(&block, &network)
|
||||
.expect("subsidies should pass for this block");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,7 +335,7 @@ fn coinbase_validation_failure() -> Result<(), Report> {
|
|||
assert_eq!(expected, result);
|
||||
|
||||
// Validate the block using subsidy_is_valid
|
||||
let result = check::subsidy_is_valid(&block, network).unwrap_err();
|
||||
let result = check::subsidy_is_valid(&block, &network).unwrap_err();
|
||||
let expected = BlockError::Transaction(TransactionError::Subsidy(SubsidyError::NoCoinbase));
|
||||
assert_eq!(expected, result);
|
||||
|
||||
|
@ -353,7 +354,7 @@ fn coinbase_validation_failure() -> Result<(), Report> {
|
|||
assert_eq!(expected, result);
|
||||
|
||||
// Validate the block using subsidy_is_valid
|
||||
let result = check::subsidy_is_valid(&block, network).unwrap_err();
|
||||
let result = check::subsidy_is_valid(&block, &network).unwrap_err();
|
||||
let expected = BlockError::Transaction(TransactionError::Subsidy(SubsidyError::NoCoinbase));
|
||||
assert_eq!(expected, result);
|
||||
|
||||
|
@ -378,7 +379,7 @@ fn coinbase_validation_failure() -> Result<(), Report> {
|
|||
assert_eq!(expected, result);
|
||||
|
||||
// Validate the block using subsidy_is_valid, which does not detect this error
|
||||
check::subsidy_is_valid(&block, network)
|
||||
check::subsidy_is_valid(&block, &network)
|
||||
.expect("subsidy does not check for extra coinbase transactions");
|
||||
|
||||
Ok(())
|
||||
|
@ -398,7 +399,7 @@ fn funding_stream_validation_for_network(network: Network) -> Result<(), Report>
|
|||
let block_iter = network.block_iter();
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is known");
|
||||
|
||||
for (&height, block) in block_iter {
|
||||
|
@ -406,7 +407,7 @@ fn funding_stream_validation_for_network(network: Network) -> Result<(), Report>
|
|||
let block = Block::zcash_deserialize(&block[..]).expect("block should deserialize");
|
||||
|
||||
// Validate
|
||||
let result = check::subsidy_is_valid(&block, network);
|
||||
let result = check::subsidy_is_valid(&block, &network);
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +451,7 @@ fn funding_stream_validation_failure() -> Result<(), Report> {
|
|||
};
|
||||
|
||||
// Validate it
|
||||
let result = check::subsidy_is_valid(&block, network);
|
||||
let result = check::subsidy_is_valid(&block, &network);
|
||||
let expected = Err(BlockError::Transaction(TransactionError::Subsidy(
|
||||
SubsidyError::FundingStreamNotFound,
|
||||
)));
|
||||
|
@ -480,7 +481,7 @@ fn miner_fees_validation_for_network(network: Network) -> Result<(), Report> {
|
|||
let miner_fees = Amount::try_from(MAX_MONEY / 2).unwrap();
|
||||
|
||||
// Validate
|
||||
let result = check::miner_fees_are_valid(&block, network, miner_fees);
|
||||
let result = check::miner_fees_are_valid(&block, &network, miner_fees);
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
}
|
||||
|
@ -501,7 +502,7 @@ fn miner_fees_validation_failure() -> Result<(), Report> {
|
|||
let miner_fees = Amount::zero();
|
||||
|
||||
// Validate
|
||||
let result = check::miner_fees_are_valid(&block, network, miner_fees);
|
||||
let result = check::miner_fees_are_valid(&block, &network, miner_fees);
|
||||
|
||||
let expected = Err(BlockError::Transaction(TransactionError::Subsidy(
|
||||
SubsidyError::InvalidMinerFees,
|
||||
|
@ -569,7 +570,7 @@ fn merkle_root_is_valid_for_network(network: Network) -> Result<(), Report> {
|
|||
.map(|tx| tx.hash())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
check::merkle_root_validity(network, &block, &transaction_hashes)
|
||||
check::merkle_root_validity(&network, &block, &transaction_hashes)
|
||||
.expect("merkle root should be valid for this block");
|
||||
}
|
||||
|
||||
|
@ -587,7 +588,7 @@ fn merkle_root_fake_v5_for_network(network: Network) -> Result<(), Report> {
|
|||
// skip blocks that are before overwinter as they will not have a valid consensus branch id
|
||||
if *height
|
||||
< NetworkUpgrade::Overwinter
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("a valid overwinter activation height")
|
||||
.0
|
||||
{
|
||||
|
@ -599,7 +600,7 @@ fn merkle_root_fake_v5_for_network(network: Network) -> Result<(), Report> {
|
|||
.transactions
|
||||
.iter()
|
||||
.map(AsRef::as_ref)
|
||||
.map(|t| transaction_to_fake_v5(t, network, Height(*height)))
|
||||
.map(|t| transaction_to_fake_v5(t, &network, Height(*height)))
|
||||
.map(Into::into)
|
||||
.collect();
|
||||
|
||||
|
@ -616,7 +617,7 @@ fn merkle_root_fake_v5_for_network(network: Network) -> Result<(), Report> {
|
|||
// but we also need to test against zcashd test vectors.
|
||||
Arc::make_mut(&mut block.header).merkle_root = transaction_hashes.iter().cloned().collect();
|
||||
|
||||
check::merkle_root_validity(network, &block, &transaction_hashes)
|
||||
check::merkle_root_validity(&network, &block, &transaction_hashes)
|
||||
.expect("merkle root should be valid for this block");
|
||||
}
|
||||
|
||||
|
@ -682,13 +683,13 @@ fn legacy_sigops_count_for_historic_blocks() {
|
|||
fn transaction_expiration_height_validation() -> Result<(), Report> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
transaction_expiration_height_for_network(Network::Mainnet)?;
|
||||
transaction_expiration_height_for_network(Network::Testnet)?;
|
||||
transaction_expiration_height_for_network(&Network::Mainnet)?;
|
||||
transaction_expiration_height_for_network(&Network::Testnet)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn transaction_expiration_height_for_network(network: Network) -> Result<(), Report> {
|
||||
fn transaction_expiration_height_for_network(network: &Network) -> Result<(), Report> {
|
||||
let block_iter = network.block_iter();
|
||||
|
||||
for (&height, block) in block_iter {
|
||||
|
|
|
@ -203,7 +203,7 @@ where
|
|||
/// `tower::Buffer` service.
|
||||
#[allow(dead_code)]
|
||||
pub fn new(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
initial_tip: Option<(block::Height, block::Hash)>,
|
||||
state_service: S,
|
||||
) -> Self {
|
||||
|
@ -232,7 +232,7 @@ where
|
|||
#[allow(dead_code)]
|
||||
pub(crate) fn from_list(
|
||||
list: impl IntoIterator<Item = (block::Height, block::Hash)>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
initial_tip: Option<(block::Height, block::Hash)>,
|
||||
state_service: S,
|
||||
) -> Result<Self, VerifyCheckpointError> {
|
||||
|
@ -253,7 +253,7 @@ where
|
|||
/// hard-coded checkpoint lists. See that function for more details.
|
||||
pub(crate) fn from_checkpoint_list(
|
||||
checkpoint_list: CheckpointList,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
initial_tip: Option<(block::Height, block::Hash)>,
|
||||
state_service: S,
|
||||
) -> Self {
|
||||
|
@ -273,7 +273,7 @@ where
|
|||
|
||||
let verifier = CheckpointVerifier {
|
||||
checkpoint_list,
|
||||
network,
|
||||
network: network.clone(),
|
||||
initial_tip_hash,
|
||||
state_service,
|
||||
queued: BTreeMap::new(),
|
||||
|
@ -595,14 +595,14 @@ where
|
|||
.ok_or(VerifyCheckpointError::CoinbaseHeight { hash })?;
|
||||
self.check_height(height)?;
|
||||
|
||||
crate::block::check::difficulty_is_valid(&block.header, self.network, &height, &hash)?;
|
||||
crate::block::check::difficulty_is_valid(&block.header, &self.network, &height, &hash)?;
|
||||
crate::block::check::equihash_solution_is_valid(&block.header)?;
|
||||
|
||||
// don't do precalculation until the block passes basic difficulty checks
|
||||
let block = CheckpointVerifiedBlock::with_hash(block, hash);
|
||||
|
||||
crate::block::check::merkle_root_validity(
|
||||
self.network,
|
||||
&self.network,
|
||||
&block.block,
|
||||
&block.transaction_hashes,
|
||||
)?;
|
||||
|
|
|
@ -45,9 +45,9 @@ async fn single_item_checkpoint_list() -> Result<(), Report> {
|
|||
.cloned()
|
||||
.collect();
|
||||
|
||||
let state_service = zebra_state::init_test(Mainnet);
|
||||
let state_service = zebra_state::init_test(&Mainnet);
|
||||
let mut checkpoint_verifier =
|
||||
CheckpointVerifier::from_list(genesis_checkpoint_list, Mainnet, None, state_service)
|
||||
CheckpointVerifier::from_list(genesis_checkpoint_list, &Mainnet, None, state_service)
|
||||
.map_err(|e| eyre!(e))?;
|
||||
|
||||
assert_eq!(
|
||||
|
@ -124,9 +124,9 @@ async fn multi_item_checkpoint_list() -> Result<(), Report> {
|
|||
.map(|(_block, height, hash)| (*height, *hash))
|
||||
.collect();
|
||||
|
||||
let state_service = zebra_state::init_test(Mainnet);
|
||||
let state_service = zebra_state::init_test(&Mainnet);
|
||||
let mut checkpoint_verifier =
|
||||
CheckpointVerifier::from_list(checkpoint_list, Mainnet, None, state_service)
|
||||
CheckpointVerifier::from_list(checkpoint_list, &Mainnet, None, state_service)
|
||||
.map_err(|e| eyre!(e))?;
|
||||
|
||||
assert_eq!(
|
||||
|
@ -268,10 +268,10 @@ async fn continuous_blockchain(
|
|||
let initial_tip = restart_height.map(|block::Height(height)| {
|
||||
(blockchain[height as usize].1, blockchain[height as usize].2)
|
||||
});
|
||||
let state_service = zebra_state::init_test(Mainnet);
|
||||
let state_service = zebra_state::init_test(&Mainnet);
|
||||
let mut checkpoint_verifier = CheckpointVerifier::from_list(
|
||||
checkpoint_list,
|
||||
network,
|
||||
&network,
|
||||
initial_tip,
|
||||
state_service.clone(),
|
||||
)
|
||||
|
@ -437,9 +437,9 @@ async fn block_higher_than_max_checkpoint_fail() -> Result<(), Report> {
|
|||
.cloned()
|
||||
.collect();
|
||||
|
||||
let state_service = zebra_state::init_test(Mainnet);
|
||||
let state_service = zebra_state::init_test(&Mainnet);
|
||||
let mut checkpoint_verifier =
|
||||
CheckpointVerifier::from_list(genesis_checkpoint_list, Mainnet, None, state_service)
|
||||
CheckpointVerifier::from_list(genesis_checkpoint_list, &Mainnet, None, state_service)
|
||||
.map_err(|e| eyre!(e))?;
|
||||
|
||||
assert_eq!(
|
||||
|
@ -511,9 +511,9 @@ async fn wrong_checkpoint_hash_fail() -> Result<(), Report> {
|
|||
.cloned()
|
||||
.collect();
|
||||
|
||||
let state_service = zebra_state::init_test(Mainnet);
|
||||
let state_service = zebra_state::init_test(&Mainnet);
|
||||
let mut checkpoint_verifier =
|
||||
CheckpointVerifier::from_list(genesis_checkpoint_list, Mainnet, None, state_service)
|
||||
CheckpointVerifier::from_list(genesis_checkpoint_list, &Mainnet, None, state_service)
|
||||
.map_err(|e| eyre!(e))?;
|
||||
|
||||
assert_eq!(
|
||||
|
@ -684,9 +684,9 @@ async fn checkpoint_drop_cancel() -> Result<(), Report> {
|
|||
.map(|(_block, height, hash)| (*height, *hash))
|
||||
.collect();
|
||||
|
||||
let state_service = zebra_state::init_test(Mainnet);
|
||||
let state_service = zebra_state::init_test(&Mainnet);
|
||||
let mut checkpoint_verifier =
|
||||
CheckpointVerifier::from_list(checkpoint_list, Mainnet, None, state_service)
|
||||
CheckpointVerifier::from_list(checkpoint_list, &Mainnet, None, state_service)
|
||||
.map_err(|e| eyre!(e))?;
|
||||
|
||||
assert_eq!(
|
||||
|
@ -767,9 +767,9 @@ async fn hard_coded_mainnet() -> Result<(), Report> {
|
|||
Arc::<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_GENESIS_BYTES[..])?;
|
||||
let hash0 = block0.hash();
|
||||
|
||||
let state_service = zebra_state::init_test(Mainnet);
|
||||
let state_service = zebra_state::init_test(&Mainnet);
|
||||
// Use the hard-coded checkpoint list
|
||||
let mut checkpoint_verifier = CheckpointVerifier::new(Network::Mainnet, None, state_service);
|
||||
let mut checkpoint_verifier = CheckpointVerifier::new(&Network::Mainnet, None, state_service);
|
||||
|
||||
assert_eq!(
|
||||
checkpoint_verifier.previous_checkpoint_height(),
|
||||
|
|
|
@ -224,7 +224,7 @@ impl ParameterSubsidy for Network {
|
|||
// <https://zips.z.cash/protocol/protocol.pdf#zip214fundingstreams>
|
||||
match self {
|
||||
Network::Mainnet => NetworkUpgrade::Canopy
|
||||
.activation_height(*self)
|
||||
.activation_height(self)
|
||||
.expect("canopy activation height should be available"),
|
||||
Network::Testnet => FIRST_HALVING_TESTNET,
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ where
|
|||
#[instrument(skip(state_service))]
|
||||
pub async fn init<S>(
|
||||
config: Config,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
mut state_service: S,
|
||||
) -> (
|
||||
Buffer<BoxService<Request, block::Hash, RouterError>, Request>,
|
||||
|
@ -240,8 +240,14 @@ where
|
|||
|
||||
// Make sure the state contains the known best chain checkpoints, in a separate thread.
|
||||
|
||||
let checkpoint_state_service = state_service.clone();
|
||||
let checkpoint_sync = config.checkpoint_sync;
|
||||
let (checkpoint_state_service, checkpoint_sync, network_clone) = {
|
||||
let checkpoint_state_service = state_service.clone();
|
||||
let checkpoint_sync = config.checkpoint_sync;
|
||||
let network_clone = network.clone();
|
||||
|
||||
(checkpoint_state_service, checkpoint_sync, network_clone)
|
||||
};
|
||||
|
||||
let state_checkpoint_verify_handle = tokio::task::spawn(
|
||||
// TODO: move this into an async function?
|
||||
async move {
|
||||
|
@ -263,7 +269,7 @@ where
|
|||
// > activation block hashes given in § 3.12 ‘Mainnet and Testnet’ on p. 20.
|
||||
//
|
||||
// <https://zips.z.cash/protocol/protocol.pdf#blockchain>
|
||||
let full_checkpoints = network.checkpoint_list();
|
||||
let full_checkpoints = network_clone.checkpoint_list();
|
||||
let mut already_warned = false;
|
||||
|
||||
for (height, checkpoint_hash) in full_checkpoints.iter() {
|
||||
|
@ -360,7 +366,7 @@ where
|
|||
|
||||
/// Parses the checkpoint list for `network` and `config`.
|
||||
/// Returns the checkpoint list and maximum checkpoint height.
|
||||
pub fn init_checkpoint_list(config: Config, network: Network) -> (CheckpointList, Height) {
|
||||
pub fn init_checkpoint_list(config: Config, network: &Network) -> (CheckpointList, Height) {
|
||||
// TODO: Zebra parses the checkpoint list three times at startup.
|
||||
// Instead, cache the checkpoint list for each `network`.
|
||||
let list = network.checkpoint_list();
|
||||
|
|
|
@ -65,13 +65,13 @@ async fn verifiers_from_network(
|
|||
+ Clone
|
||||
+ 'static,
|
||||
) {
|
||||
let state_service = zs::init_test(network);
|
||||
let state_service = zs::init_test(&network);
|
||||
let (
|
||||
block_verifier_router,
|
||||
_transaction_verifier,
|
||||
_groth16_download_handle,
|
||||
_max_checkpoint_height,
|
||||
) = crate::router::init(Config::default(), network, state_service.clone()).await;
|
||||
) = crate::router::init(Config::default(), &network, state_service.clone()).await;
|
||||
|
||||
// We can drop the download task handle here, because:
|
||||
// - if the download task fails, the tests will panic, and
|
||||
|
@ -172,7 +172,7 @@ async fn verify_checkpoint(config: Config) -> Result<(), Report> {
|
|||
_transaction_verifier,
|
||||
_groth16_download_handle,
|
||||
_max_checkpoint_height,
|
||||
) = super::init(config.clone(), network, zs::init_test(network)).await;
|
||||
) = super::init(config.clone(), &network, zs::init_test(&network)).await;
|
||||
|
||||
// Add a timeout layer
|
||||
let block_verifier_router =
|
||||
|
|
|
@ -73,9 +73,9 @@ where
|
|||
ZS::Future: Send + 'static,
|
||||
{
|
||||
/// Create a new transaction verifier.
|
||||
pub fn new(network: Network, state: ZS) -> Self {
|
||||
pub fn new(network: &Network, state: ZS) -> Self {
|
||||
Self {
|
||||
network,
|
||||
network: network.clone(),
|
||||
state: Timeout::new(state, UTXO_LOOKUP_TIMEOUT),
|
||||
script_verifier: script::Verifier,
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ impl Request {
|
|||
/// The network upgrade to consider for the verification.
|
||||
///
|
||||
/// This is based on the block height from the request, and the supplied `network`.
|
||||
pub fn upgrade(&self, network: Network) -> NetworkUpgrade {
|
||||
pub fn upgrade(&self, network: &Network) -> NetworkUpgrade {
|
||||
NetworkUpgrade::current(network, self.height())
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ where
|
|||
// TODO: break up each chunk into its own method
|
||||
fn call(&mut self, req: Request) -> Self::Future {
|
||||
let script_verifier = self.script_verifier;
|
||||
let network = self.network;
|
||||
let network = self.network.clone();
|
||||
let state = self.state.clone();
|
||||
|
||||
let tx = req.transaction();
|
||||
|
@ -321,7 +321,7 @@ where
|
|||
|
||||
// Validate `nExpiryHeight` consensus rules
|
||||
if tx.is_coinbase() {
|
||||
check::coinbase_expiry_height(&req.height(), &tx, network)?;
|
||||
check::coinbase_expiry_height(&req.height(), &tx, &network)?;
|
||||
} else {
|
||||
check::non_coinbase_expiry_height(&req.height(), &tx)?;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ where
|
|||
|
||||
// [Canopy onward]: `vpub_old` MUST be zero.
|
||||
// https://zips.z.cash/protocol/protocol.pdf#joinsplitdesc
|
||||
check::disabled_add_to_sprout_pool(&tx, req.height(), network)?;
|
||||
check::disabled_add_to_sprout_pool(&tx, req.height(), &network)?;
|
||||
|
||||
check::spend_conflicts(&tx)?;
|
||||
|
||||
|
@ -396,7 +396,7 @@ where
|
|||
..
|
||||
} => Self::verify_v4_transaction(
|
||||
&req,
|
||||
network,
|
||||
&network,
|
||||
script_verifier,
|
||||
cached_ffi_transaction.clone(),
|
||||
joinsplit_data,
|
||||
|
@ -408,7 +408,7 @@ where
|
|||
..
|
||||
} => Self::verify_v5_transaction(
|
||||
&req,
|
||||
network,
|
||||
&network,
|
||||
script_verifier,
|
||||
cached_ffi_transaction.clone(),
|
||||
sapling_shielded_data,
|
||||
|
@ -616,7 +616,7 @@ where
|
|||
/// - the `sapling_shielded_data` in the transaction
|
||||
fn verify_v4_transaction(
|
||||
request: &Request,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
script_verifier: script::Verifier,
|
||||
cached_ffi_transaction: Arc<CachedFfiTransaction>,
|
||||
joinsplit_data: &Option<transaction::JoinSplitData<Groth16Proof>>,
|
||||
|
@ -708,7 +708,7 @@ where
|
|||
/// - the orchard shielded data of the transaction, if any
|
||||
fn verify_v5_transaction(
|
||||
request: &Request,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
script_verifier: script::Verifier,
|
||||
cached_ffi_transaction: Arc<CachedFfiTransaction>,
|
||||
sapling_shielded_data: &Option<sapling::ShieldedData<sapling::SharedAnchor>>,
|
||||
|
@ -782,7 +782,7 @@ where
|
|||
/// Returns script verification responses via the `utxo_sender`.
|
||||
fn verify_transparent_inputs_and_outputs(
|
||||
request: &Request,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
script_verifier: script::Verifier,
|
||||
cached_ffi_transaction: Arc<CachedFfiTransaction>,
|
||||
) -> Result<AsyncChecks, TransactionError> {
|
||||
|
|
|
@ -212,7 +212,7 @@ pub fn joinsplit_has_vpub_zero(tx: &Transaction) -> Result<(), TransactionError>
|
|||
pub fn disabled_add_to_sprout_pool(
|
||||
tx: &Transaction,
|
||||
height: Height,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Result<(), TransactionError> {
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
|
@ -325,7 +325,7 @@ where
|
|||
/// <https://github.com/ZcashFoundation/zebra/issues/3027>
|
||||
pub fn coinbase_outputs_are_decryptable(
|
||||
transaction: &Transaction,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: Height,
|
||||
) -> Result<(), TransactionError> {
|
||||
// The consensus rule only applies to Heartwood onward.
|
||||
|
@ -352,7 +352,7 @@ pub fn coinbase_outputs_are_decryptable(
|
|||
pub fn coinbase_expiry_height(
|
||||
block_height: &Height,
|
||||
coinbase: &Transaction,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Result<(), TransactionError> {
|
||||
let expiry_height = coinbase.expiry_height();
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ fn v5_fake_transactions() -> Result<(), Report> {
|
|||
];
|
||||
|
||||
for (network, blocks) in networks {
|
||||
for transaction in fake_v5_transactions_for_network(network, blocks) {
|
||||
for transaction in fake_v5_transactions_for_network(&network, blocks) {
|
||||
match check::has_inputs_and_outputs(&transaction) {
|
||||
Ok(()) => (),
|
||||
Err(TransactionError::NoInputs) | Err(TransactionError::NoOutputs) => (),
|
||||
|
@ -67,7 +67,7 @@ fn v5_fake_transactions() -> Result<(), Report> {
|
|||
fn fake_v5_transaction_with_orchard_actions_has_inputs_and_outputs() {
|
||||
// Find a transaction with no inputs or outputs to use as base
|
||||
let mut transaction = fake_v5_transactions_for_network(
|
||||
Network::Mainnet,
|
||||
&Network::Mainnet,
|
||||
zebra_test::vectors::MAINNET_BLOCKS.iter(),
|
||||
)
|
||||
.rev()
|
||||
|
@ -121,7 +121,7 @@ fn fake_v5_transaction_with_orchard_actions_has_inputs_and_outputs() {
|
|||
fn fake_v5_transaction_with_orchard_actions_has_flags() {
|
||||
// Find a transaction with no inputs or outputs to use as base
|
||||
let mut transaction = fake_v5_transactions_for_network(
|
||||
Network::Mainnet,
|
||||
&Network::Mainnet,
|
||||
zebra_test::vectors::MAINNET_BLOCKS.iter(),
|
||||
)
|
||||
.rev()
|
||||
|
@ -164,7 +164,7 @@ fn fake_v5_transaction_with_orchard_actions_has_flags() {
|
|||
#[test]
|
||||
fn v5_transaction_with_no_inputs_fails_validation() {
|
||||
let transaction = fake_v5_transactions_for_network(
|
||||
Network::Mainnet,
|
||||
&Network::Mainnet,
|
||||
zebra_test::vectors::MAINNET_BLOCKS.iter(),
|
||||
)
|
||||
.rev()
|
||||
|
@ -186,7 +186,7 @@ fn v5_transaction_with_no_inputs_fails_validation() {
|
|||
#[tokio::test]
|
||||
async fn mempool_request_with_missing_input_is_rejected() {
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let (height, tx) = transactions_from_blocks(zebra_test::vectors::MAINNET_BLOCKS.iter())
|
||||
.find(|(_, tx)| !(tx.is_coinbase() || tx.inputs().is_empty()))
|
||||
|
@ -235,10 +235,10 @@ async fn mempool_request_with_missing_input_is_rejected() {
|
|||
#[tokio::test]
|
||||
async fn mempool_request_with_present_input_is_accepted() {
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -302,10 +302,10 @@ async fn mempool_request_with_present_input_is_accepted() {
|
|||
#[tokio::test]
|
||||
async fn mempool_request_with_invalid_lock_time_is_rejected() {
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -381,10 +381,10 @@ async fn mempool_request_with_invalid_lock_time_is_rejected() {
|
|||
#[tokio::test]
|
||||
async fn mempool_request_with_unlocked_lock_time_is_accepted() {
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -448,10 +448,10 @@ async fn mempool_request_with_unlocked_lock_time_is_accepted() {
|
|||
#[tokio::test]
|
||||
async fn mempool_request_with_lock_time_max_sequence_number_is_accepted() {
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
let (mut input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -518,10 +518,10 @@ async fn mempool_request_with_lock_time_max_sequence_number_is_accepted() {
|
|||
#[tokio::test]
|
||||
async fn mempool_request_with_past_lock_time_is_accepted() {
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -597,10 +597,10 @@ async fn mempool_request_with_immature_spend_is_rejected() {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -700,10 +700,10 @@ async fn state_error_converted_correctly() {
|
|||
use zebra_state::DuplicateNullifierError;
|
||||
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -798,7 +798,7 @@ async fn state_error_converted_correctly() {
|
|||
#[test]
|
||||
fn v5_transaction_with_no_outputs_fails_validation() {
|
||||
let transaction = fake_v5_transactions_for_network(
|
||||
Network::Mainnet,
|
||||
&Network::Mainnet,
|
||||
zebra_test::vectors::MAINNET_BLOCKS.iter(),
|
||||
)
|
||||
.rev()
|
||||
|
@ -821,7 +821,7 @@ fn v5_transaction_with_no_outputs_fails_validation() {
|
|||
#[test]
|
||||
fn v5_coinbase_transaction_without_enable_spends_flag_passes_validation() {
|
||||
let mut transaction = fake_v5_transactions_for_network(
|
||||
Network::Mainnet,
|
||||
&Network::Mainnet,
|
||||
zebra_test::vectors::MAINNET_BLOCKS.iter(),
|
||||
)
|
||||
.rev()
|
||||
|
@ -836,7 +836,7 @@ fn v5_coinbase_transaction_without_enable_spends_flag_passes_validation() {
|
|||
#[test]
|
||||
fn v5_coinbase_transaction_with_enable_spends_flag_fails_validation() {
|
||||
let mut transaction = fake_v5_transactions_for_network(
|
||||
Network::Mainnet,
|
||||
&Network::Mainnet,
|
||||
zebra_test::vectors::MAINNET_BLOCKS.iter(),
|
||||
)
|
||||
.rev()
|
||||
|
@ -865,9 +865,9 @@ async fn v5_transaction_is_rejected_before_nu5_activation() {
|
|||
|
||||
for (network, blocks) in networks {
|
||||
let state_service = service_fn(|_| async { unreachable!("Service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let transaction = fake_v5_transactions_for_network(network, blocks)
|
||||
let transaction = fake_v5_transactions_for_network(&network, blocks)
|
||||
.next_back()
|
||||
.expect("At least one fake V5 transaction in the test vectors");
|
||||
|
||||
|
@ -876,7 +876,7 @@ async fn v5_transaction_is_rejected_before_nu5_activation() {
|
|||
transaction: Arc::new(transaction),
|
||||
known_utxos: Arc::new(HashMap::new()),
|
||||
height: canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is specified"),
|
||||
time: DateTime::<Utc>::MAX_UTC,
|
||||
})
|
||||
|
@ -907,14 +907,14 @@ fn v5_transaction_is_accepted_after_nu5_activation_for_network(network: Network)
|
|||
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
|
||||
let nu5 = NetworkUpgrade::Nu5;
|
||||
let nu5_activation_height = nu5
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("NU5 activation height is specified");
|
||||
let blocks = network.block_iter();
|
||||
|
||||
let state_service = service_fn(|_| async { unreachable!("Service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let mut transaction = fake_v5_transactions_for_network(network, blocks)
|
||||
let mut transaction = fake_v5_transactions_for_network(&network, blocks)
|
||||
.next_back()
|
||||
.expect("At least one fake V5 transaction in the test vectors");
|
||||
if transaction
|
||||
|
@ -953,7 +953,7 @@ async fn v4_transaction_with_transparent_transfer_is_accepted() {
|
|||
let network = Network::Mainnet;
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -984,7 +984,7 @@ async fn v4_transaction_with_transparent_transfer_is_accepted() {
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1007,10 +1007,10 @@ async fn v4_transaction_with_transparent_transfer_is_accepted() {
|
|||
async fn v4_transaction_with_last_valid_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Mainnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Mainnet, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
let fund_height = (block_height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -1054,10 +1054,10 @@ async fn v4_transaction_with_last_valid_expiry_height() {
|
|||
async fn v4_coinbase_transaction_with_low_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Mainnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Mainnet, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let (input, output) = mock_coinbase_transparent_output(block_height);
|
||||
|
@ -1095,10 +1095,10 @@ async fn v4_coinbase_transaction_with_low_expiry_height() {
|
|||
async fn v4_transaction_with_too_low_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Mainnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Mainnet, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Canopy
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let fund_height = (block_height - 1).expect("fake source fund block height is too small");
|
||||
|
@ -1147,7 +1147,7 @@ async fn v4_transaction_with_too_low_expiry_height() {
|
|||
async fn v4_transaction_with_exceeding_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Mainnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Mainnet, state_service);
|
||||
|
||||
let block_height = block::Height::MAX;
|
||||
|
||||
|
@ -1198,14 +1198,14 @@ async fn v4_transaction_with_exceeding_expiry_height() {
|
|||
async fn v4_coinbase_transaction_with_exceeding_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Mainnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Mainnet, state_service);
|
||||
|
||||
// Use an arbitrary pre-NU5 block height.
|
||||
// It can't be NU5-onward because the expiry height limit is not enforced
|
||||
// for coinbase transactions (it needs to match the block height instead),
|
||||
// which is what is used in this test.
|
||||
let block_height = (NetworkUpgrade::Nu5
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("NU5 height must be set")
|
||||
- 1)
|
||||
.expect("will not underflow");
|
||||
|
@ -1251,7 +1251,7 @@ async fn v4_coinbase_transaction_is_accepted() {
|
|||
let network = Network::Mainnet;
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -1274,7 +1274,7 @@ async fn v4_coinbase_transaction_is_accepted() {
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1300,7 +1300,7 @@ async fn v4_transaction_with_transparent_transfer_is_rejected_by_the_script() {
|
|||
let network = Network::Mainnet;
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -1329,7 +1329,7 @@ async fn v4_transaction_with_transparent_transfer_is_rejected_by_the_script() {
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1355,7 +1355,7 @@ async fn v4_transaction_with_conflicting_transparent_spend_is_rejected() {
|
|||
let network = Network::Mainnet;
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -1384,7 +1384,7 @@ async fn v4_transaction_with_conflicting_transparent_spend_is_rejected() {
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1414,7 +1414,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_inside_joinsplit_is_rejected
|
|||
let network_upgrade = NetworkUpgrade::Canopy;
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -1450,7 +1450,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_inside_joinsplit_is_rejected
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1479,7 +1479,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_across_joinsplits_is_rejecte
|
|||
let network_upgrade = NetworkUpgrade::Canopy;
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -1521,7 +1521,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_across_joinsplits_is_rejecte
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1548,7 +1548,7 @@ async fn v5_transaction_with_transparent_transfer_is_accepted() {
|
|||
let network_upgrade = NetworkUpgrade::Nu5;
|
||||
|
||||
let nu5_activation_height = network_upgrade
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("NU5 activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -1580,7 +1580,7 @@ async fn v5_transaction_with_transparent_transfer_is_accepted() {
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1603,10 +1603,10 @@ async fn v5_transaction_with_transparent_transfer_is_accepted() {
|
|||
async fn v5_transaction_with_last_valid_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Testnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Testnet, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Nu5
|
||||
.activation_height(Network::Testnet)
|
||||
.activation_height(&Network::Testnet)
|
||||
.expect("Nu5 activation height for testnet is specified");
|
||||
let fund_height = (block_height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -1648,10 +1648,10 @@ async fn v5_transaction_with_last_valid_expiry_height() {
|
|||
async fn v5_coinbase_transaction_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Testnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Testnet, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Nu5
|
||||
.activation_height(Network::Testnet)
|
||||
.activation_height(&Network::Testnet)
|
||||
.expect("Nu5 activation height for testnet is specified");
|
||||
|
||||
let (input, output) = mock_coinbase_transparent_output(block_height);
|
||||
|
@ -1763,10 +1763,10 @@ async fn v5_coinbase_transaction_expiry_height() {
|
|||
async fn v5_transaction_with_too_low_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Testnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Testnet, state_service);
|
||||
|
||||
let block_height = NetworkUpgrade::Nu5
|
||||
.activation_height(Network::Testnet)
|
||||
.activation_height(&Network::Testnet)
|
||||
.expect("Nu5 activation height for testnet is specified");
|
||||
let fund_height = (block_height - 1).expect("fake source fund block height is too small");
|
||||
let (input, output, known_utxos) = mock_transparent_transfer(
|
||||
|
@ -1815,7 +1815,7 @@ async fn v5_transaction_with_too_low_expiry_height() {
|
|||
async fn v5_transaction_with_exceeding_expiry_height() {
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(Network::Mainnet, state_service);
|
||||
let verifier = Verifier::new(&Network::Mainnet, state_service);
|
||||
|
||||
let block_height = block::Height::MAX;
|
||||
|
||||
|
@ -1868,7 +1868,7 @@ async fn v5_coinbase_transaction_is_accepted() {
|
|||
let network_upgrade = NetworkUpgrade::Nu5;
|
||||
|
||||
let nu5_activation_height = network_upgrade
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("NU5 activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -1893,7 +1893,7 @@ async fn v5_coinbase_transaction_is_accepted() {
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1920,7 +1920,7 @@ async fn v5_transaction_with_transparent_transfer_is_rejected_by_the_script() {
|
|||
let network_upgrade = NetworkUpgrade::Nu5;
|
||||
|
||||
let nu5_activation_height = network_upgrade
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("NU5 activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -1950,7 +1950,7 @@ async fn v5_transaction_with_transparent_transfer_is_rejected_by_the_script() {
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -1977,7 +1977,7 @@ async fn v5_transaction_with_conflicting_transparent_spend_is_rejected() {
|
|||
let network_upgrade = NetworkUpgrade::Nu5;
|
||||
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Canopy activation height is specified");
|
||||
|
||||
let transaction_block_height =
|
||||
|
@ -2007,7 +2007,7 @@ async fn v5_transaction_with_conflicting_transparent_spend_is_rejected() {
|
|||
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
let result = verifier
|
||||
.oneshot(Request::Block {
|
||||
|
@ -2037,7 +2037,7 @@ fn v4_with_signed_sprout_transfer_is_accepted() {
|
|||
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
|
||||
let network = Network::Mainnet;
|
||||
|
||||
let (height, transaction) = test_transactions(network)
|
||||
let (height, transaction) = test_transactions(&network)
|
||||
.rev()
|
||||
.filter(|(_, transaction)| {
|
||||
!transaction.is_coinbase() && transaction.inputs().is_empty()
|
||||
|
@ -2050,7 +2050,7 @@ fn v4_with_signed_sprout_transfer_is_accepted() {
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier
|
||||
let result = verifier
|
||||
|
@ -2109,7 +2109,7 @@ async fn v4_with_joinsplit_is_rejected_for_modification(
|
|||
) {
|
||||
let network = Network::Mainnet;
|
||||
|
||||
let (height, mut transaction) = test_transactions(network)
|
||||
let (height, mut transaction) = test_transactions(&network)
|
||||
.rev()
|
||||
.filter(|(_, transaction)| !transaction.is_coinbase() && transaction.inputs().is_empty())
|
||||
.find(|(_, transaction)| transaction.sprout_groth16_joinsplits().next().is_some())
|
||||
|
@ -2130,7 +2130,7 @@ async fn v4_with_joinsplit_is_rejected_for_modification(
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called.") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier.
|
||||
//
|
||||
|
@ -2168,7 +2168,7 @@ fn v4_with_sapling_spends() {
|
|||
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
|
||||
let network = Network::Mainnet;
|
||||
|
||||
let (height, transaction) = test_transactions(network)
|
||||
let (height, transaction) = test_transactions(&network)
|
||||
.rev()
|
||||
.filter(|(_, transaction)| {
|
||||
!transaction.is_coinbase() && transaction.inputs().is_empty()
|
||||
|
@ -2181,7 +2181,7 @@ fn v4_with_sapling_spends() {
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier
|
||||
let result = verifier
|
||||
|
@ -2208,7 +2208,7 @@ fn v4_with_duplicate_sapling_spends() {
|
|||
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
|
||||
let network = Network::Mainnet;
|
||||
|
||||
let (height, mut transaction) = test_transactions(network)
|
||||
let (height, mut transaction) = test_transactions(&network)
|
||||
.rev()
|
||||
.filter(|(_, transaction)| {
|
||||
!transaction.is_coinbase() && transaction.inputs().is_empty()
|
||||
|
@ -2224,7 +2224,7 @@ fn v4_with_duplicate_sapling_spends() {
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier
|
||||
let result = verifier
|
||||
|
@ -2253,7 +2253,7 @@ fn v4_with_sapling_outputs_and_no_spends() {
|
|||
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
|
||||
let network = Network::Mainnet;
|
||||
|
||||
let (height, transaction) = test_transactions(network)
|
||||
let (height, transaction) = test_transactions(&network)
|
||||
.rev()
|
||||
.filter(|(_, transaction)| {
|
||||
!transaction.is_coinbase() && transaction.inputs().is_empty()
|
||||
|
@ -2269,7 +2269,7 @@ fn v4_with_sapling_outputs_and_no_spends() {
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier
|
||||
let result = verifier
|
||||
|
@ -2297,10 +2297,10 @@ fn v5_with_sapling_spends() {
|
|||
let _init_guard = zebra_test::init();
|
||||
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
|
||||
let network = Network::Mainnet;
|
||||
let nu5_activation = NetworkUpgrade::Nu5.activation_height(network);
|
||||
let nu5_activation = NetworkUpgrade::Nu5.activation_height(&network);
|
||||
|
||||
let transaction =
|
||||
fake_v5_transactions_for_network(network, zebra_test::vectors::MAINNET_BLOCKS.iter())
|
||||
fake_v5_transactions_for_network(&network, zebra_test::vectors::MAINNET_BLOCKS.iter())
|
||||
.rev()
|
||||
.filter(|transaction| {
|
||||
!transaction.is_coinbase()
|
||||
|
@ -2318,7 +2318,7 @@ fn v5_with_sapling_spends() {
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier
|
||||
let result = verifier
|
||||
|
@ -2346,7 +2346,7 @@ fn v5_with_duplicate_sapling_spends() {
|
|||
let network = Network::Mainnet;
|
||||
|
||||
let mut transaction =
|
||||
fake_v5_transactions_for_network(network, zebra_test::vectors::MAINNET_BLOCKS.iter())
|
||||
fake_v5_transactions_for_network(&network, zebra_test::vectors::MAINNET_BLOCKS.iter())
|
||||
.rev()
|
||||
.filter(|transaction| !transaction.is_coinbase() && transaction.inputs().is_empty())
|
||||
.find(|transaction| transaction.sapling_spends_per_anchor().next().is_some())
|
||||
|
@ -2362,7 +2362,7 @@ fn v5_with_duplicate_sapling_spends() {
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier
|
||||
let result = verifier
|
||||
|
@ -2393,7 +2393,7 @@ fn v5_with_duplicate_orchard_action() {
|
|||
|
||||
// Find a transaction with no inputs or outputs to use as base
|
||||
let mut transaction =
|
||||
fake_v5_transactions_for_network(network, zebra_test::vectors::MAINNET_BLOCKS.iter())
|
||||
fake_v5_transactions_for_network(&network, zebra_test::vectors::MAINNET_BLOCKS.iter())
|
||||
.rev()
|
||||
.find(|transaction| {
|
||||
transaction.inputs().is_empty()
|
||||
|
@ -2425,7 +2425,7 @@ fn v5_with_duplicate_orchard_action() {
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = Verifier::new(network, state_service);
|
||||
let verifier = Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier
|
||||
let result = verifier
|
||||
|
@ -2710,21 +2710,21 @@ fn add_to_sprout_pool_after_nu() {
|
|||
|
||||
// create a block height at canopy activation.
|
||||
let network = Network::Mainnet;
|
||||
let block_height = NetworkUpgrade::Canopy.activation_height(network).unwrap();
|
||||
let block_height = NetworkUpgrade::Canopy.activation_height(&network).unwrap();
|
||||
|
||||
// create a zero amount.
|
||||
let zero = Amount::<NonNegative>::try_from(0).expect("an amount of 0 is always valid");
|
||||
|
||||
// the coinbase transaction should pass the check.
|
||||
assert_eq!(
|
||||
check::disabled_add_to_sprout_pool(&block.transactions[0], block_height, network),
|
||||
check::disabled_add_to_sprout_pool(&block.transactions[0], block_height, &network),
|
||||
Ok(())
|
||||
);
|
||||
|
||||
// the 2nd transaction has no joinsplits, should pass the check.
|
||||
assert_eq!(block.transactions[1].joinsplit_count(), 0);
|
||||
assert_eq!(
|
||||
check::disabled_add_to_sprout_pool(&block.transactions[1], block_height, network),
|
||||
check::disabled_add_to_sprout_pool(&block.transactions[1], block_height, &network),
|
||||
Ok(())
|
||||
);
|
||||
|
||||
|
@ -2737,7 +2737,7 @@ fn add_to_sprout_pool_after_nu() {
|
|||
assert!(vpub_old > zero);
|
||||
|
||||
assert_eq!(
|
||||
check::disabled_add_to_sprout_pool(&block.transactions[3], block_height, network),
|
||||
check::disabled_add_to_sprout_pool(&block.transactions[3], block_height, &network),
|
||||
Err(TransactionError::DisabledAddToSproutPool)
|
||||
);
|
||||
|
||||
|
@ -2750,7 +2750,7 @@ fn add_to_sprout_pool_after_nu() {
|
|||
assert_eq!(vpub_old, zero);
|
||||
|
||||
assert_eq!(
|
||||
check::disabled_add_to_sprout_pool(&block.transactions[7], block_height, network),
|
||||
check::disabled_add_to_sprout_pool(&block.transactions[7], block_height, &network),
|
||||
Ok(())
|
||||
);
|
||||
}
|
||||
|
@ -2780,7 +2780,7 @@ fn coinbase_outputs_are_decryptable_for_historical_blocks_for_network(
|
|||
let height = Height(*height);
|
||||
let heartwood_onward = height
|
||||
>= NetworkUpgrade::Heartwood
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.unwrap();
|
||||
let coinbase_tx = block
|
||||
.transactions
|
||||
|
@ -2796,7 +2796,7 @@ fn coinbase_outputs_are_decryptable_for_historical_blocks_for_network(
|
|||
// and there are relevant outputs.
|
||||
tested_coinbase_txs += 1;
|
||||
}
|
||||
check::coinbase_outputs_are_decryptable(coinbase_tx, network, height)
|
||||
check::coinbase_outputs_are_decryptable(coinbase_tx, &network, height)
|
||||
.expect("coinbase outputs must be decryptable with an all-zero key");
|
||||
|
||||
// For remaining transactions, check if existing outputs are NOT decryptable
|
||||
|
@ -2805,11 +2805,11 @@ fn coinbase_outputs_are_decryptable_for_historical_blocks_for_network(
|
|||
let has_outputs = tx.sapling_outputs().count() > 0 || tx.orchard_actions().count() > 0;
|
||||
if has_outputs && heartwood_onward {
|
||||
tested_non_coinbase_txs += 1;
|
||||
check::coinbase_outputs_are_decryptable(tx, network, height).expect_err(
|
||||
check::coinbase_outputs_are_decryptable(tx, &network, height).expect_err(
|
||||
"decrypting a non-coinbase output with an all-zero key should fail",
|
||||
);
|
||||
} else {
|
||||
check::coinbase_outputs_are_decryptable(tx, network, height)
|
||||
check::coinbase_outputs_are_decryptable(tx, &network, height)
|
||||
.expect("a transaction without outputs, or pre-Heartwood, must be considered 'decryptable'");
|
||||
}
|
||||
}
|
||||
|
@ -2849,7 +2849,7 @@ fn coinbase_outputs_are_decryptable_for_fake_v5_blocks() {
|
|||
for v in zebra_test::vectors::ORCHARD_NOTE_ENCRYPTION_ZERO_VECTOR.iter() {
|
||||
// Find a transaction with no inputs or outputs to use as base
|
||||
let mut transaction =
|
||||
fake_v5_transactions_for_network(network, zebra_test::vectors::TESTNET_BLOCKS.iter())
|
||||
fake_v5_transactions_for_network(&network, zebra_test::vectors::TESTNET_BLOCKS.iter())
|
||||
.rev()
|
||||
.find(|transaction| {
|
||||
transaction.inputs().is_empty()
|
||||
|
@ -2874,8 +2874,8 @@ fn coinbase_outputs_are_decryptable_for_fake_v5_blocks() {
|
|||
assert_eq!(
|
||||
check::coinbase_outputs_are_decryptable(
|
||||
&transaction,
|
||||
network,
|
||||
NetworkUpgrade::Nu5.activation_height(network).unwrap(),
|
||||
&network,
|
||||
NetworkUpgrade::Nu5.activation_height(&network).unwrap(),
|
||||
),
|
||||
Ok(())
|
||||
);
|
||||
|
@ -2891,7 +2891,7 @@ fn shielded_outputs_are_not_decryptable_for_fake_v5_blocks() {
|
|||
for v in zebra_test::vectors::ORCHARD_NOTE_ENCRYPTION_VECTOR.iter() {
|
||||
// Find a transaction with no inputs or outputs to use as base
|
||||
let mut transaction =
|
||||
fake_v5_transactions_for_network(network, zebra_test::vectors::TESTNET_BLOCKS.iter())
|
||||
fake_v5_transactions_for_network(&network, zebra_test::vectors::TESTNET_BLOCKS.iter())
|
||||
.rev()
|
||||
.find(|transaction| {
|
||||
transaction.inputs().is_empty()
|
||||
|
@ -2916,8 +2916,8 @@ fn shielded_outputs_are_not_decryptable_for_fake_v5_blocks() {
|
|||
assert_eq!(
|
||||
check::coinbase_outputs_are_decryptable(
|
||||
&transaction,
|
||||
network,
|
||||
NetworkUpgrade::Nu5.activation_height(network).unwrap(),
|
||||
&network,
|
||||
NetworkUpgrade::Nu5.activation_height(&network).unwrap(),
|
||||
),
|
||||
Err(TransactionError::CoinbaseOutputsNotDecryptable)
|
||||
);
|
||||
|
@ -2927,10 +2927,10 @@ fn shielded_outputs_are_not_decryptable_for_fake_v5_blocks() {
|
|||
#[tokio::test]
|
||||
async fn mempool_zip317_error() {
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Nu5
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Nu5 activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
|
||||
|
@ -2999,10 +2999,10 @@ async fn mempool_zip317_error() {
|
|||
#[tokio::test]
|
||||
async fn mempool_zip317_ok() {
|
||||
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
|
||||
let verifier = Verifier::new(Network::Mainnet, state.clone());
|
||||
let verifier = Verifier::new(&Network::Mainnet, state.clone());
|
||||
|
||||
let height = NetworkUpgrade::Nu5
|
||||
.activation_height(Network::Mainnet)
|
||||
.activation_height(&Network::Mainnet)
|
||||
.expect("Nu5 activation height is specified");
|
||||
let fund_height = (height - 1).expect("fake source fund block height is too small");
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ proptest! {
|
|||
let zero_lock_time = LockTime::Height(block::Height(0));
|
||||
|
||||
let (transaction, known_utxos) = mock_transparent_transaction(
|
||||
network,
|
||||
&network,
|
||||
block_height,
|
||||
relative_source_fund_heights,
|
||||
transaction_version,
|
||||
|
@ -67,7 +67,7 @@ proptest! {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
let (mut transaction, known_utxos) = mock_transparent_transaction(
|
||||
network,
|
||||
&network,
|
||||
block_height,
|
||||
relative_source_fund_heights,
|
||||
transaction_version,
|
||||
|
@ -105,7 +105,7 @@ proptest! {
|
|||
let lock_time = LockTime::Height(unlock_height);
|
||||
|
||||
let (transaction, known_utxos) = mock_transparent_transaction(
|
||||
network,
|
||||
&network,
|
||||
block_height,
|
||||
relative_source_fund_heights,
|
||||
transaction_version,
|
||||
|
@ -138,7 +138,7 @@ proptest! {
|
|||
};
|
||||
|
||||
let (transaction, known_utxos) = mock_transparent_transaction(
|
||||
network,
|
||||
&network,
|
||||
block_height,
|
||||
relative_source_fund_heights,
|
||||
transaction_version,
|
||||
|
@ -172,7 +172,7 @@ proptest! {
|
|||
let lock_time = LockTime::Height(unlock_height);
|
||||
|
||||
let (transaction, known_utxos) = mock_transparent_transaction(
|
||||
network,
|
||||
&network,
|
||||
block_height,
|
||||
relative_source_fund_heights,
|
||||
transaction_version,
|
||||
|
@ -213,7 +213,7 @@ proptest! {
|
|||
};
|
||||
|
||||
let (transaction, known_utxos) = mock_transparent_transaction(
|
||||
network,
|
||||
&network,
|
||||
block_height,
|
||||
relative_source_fund_heights,
|
||||
transaction_version,
|
||||
|
@ -244,14 +244,14 @@ proptest! {
|
|||
fn sapling_onwards_strategy() -> impl Strategy<Value = (Network, block::Height)> {
|
||||
any::<Network>().prop_flat_map(|network| {
|
||||
let start_height_value = NetworkUpgrade::Sapling
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("Sapling to have an activation height")
|
||||
.0;
|
||||
|
||||
let end_height_value = block::Height::MAX_EXPIRY_HEIGHT.0;
|
||||
|
||||
(start_height_value..=end_height_value)
|
||||
.prop_map(move |height_value| (network, block::Height(height_value)))
|
||||
.prop_map(move |height_value| (network.clone(), block::Height(height_value)))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ fn sapling_onwards_strategy() -> impl Strategy<Value = (Network, block::Height)>
|
|||
/// - if any item of `relative_source_heights` is not in the range `0.0..1.0` (see
|
||||
/// [`scale_block_height`] for details)
|
||||
fn mock_transparent_transaction(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
block_height: block::Height,
|
||||
relative_source_heights: Vec<f64>,
|
||||
transaction_version: u8,
|
||||
|
@ -330,7 +330,7 @@ fn mock_transparent_transaction(
|
|||
/// The `transaction_version` might be reduced if it is not supported by the network upgrade active
|
||||
/// at the `block_height` of the specified `network`.
|
||||
fn sanitize_transaction_version(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
transaction_version: u8,
|
||||
block_height: block::Height,
|
||||
) -> (u8, NetworkUpgrade) {
|
||||
|
@ -450,7 +450,7 @@ fn validate(
|
|||
// Initialize the verifier
|
||||
let state_service =
|
||||
tower::service_fn(|_| async { unreachable!("State service should not be called") });
|
||||
let verifier = transaction::Verifier::new(network, state_service);
|
||||
let verifier = transaction::Verifier::new(&network, state_service);
|
||||
|
||||
// Test the transaction verifier
|
||||
verifier
|
||||
|
|
|
@ -24,7 +24,7 @@ serde = { version = "1.0.196", features = ["serde_derive"] }
|
|||
tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] }
|
||||
tokio-stream = "0.1.14"
|
||||
tower = { version = "0.4.13", features = ["util", "buffer"] }
|
||||
color-eyre = "0.6.2"
|
||||
color-eyre = "0.6.3"
|
||||
|
||||
zcash_primitives = { version = "0.13.0-rc.1" }
|
||||
|
||||
|
@ -35,7 +35,7 @@ zebra-chain = { path = "../zebra-chain" , version = "1.0.0-beta.35" }
|
|||
tonic-build = "0.11.0"
|
||||
|
||||
[dev-dependencies]
|
||||
insta = { version = "1.33.0", features = ["redactions", "json", "ron"] }
|
||||
insta = { version = "1.36.1", features = ["redactions", "json", "ron"] }
|
||||
|
||||
zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] }
|
||||
zebra-state = { path = "../zebra-state" }
|
||||
|
|
|
@ -37,11 +37,11 @@ async fn test_grpc_methods_mocked() {
|
|||
test_delete_keys_errors(client.clone()).await;
|
||||
|
||||
for network in Network::iter() {
|
||||
test_mocked_getinfo_for_network(&client, &mock_scan_service, network).await;
|
||||
test_mocked_getresults_for_network(&client, &mock_scan_service, network).await;
|
||||
test_mocked_register_keys_for_network(&client, &mock_scan_service, network).await;
|
||||
test_mocked_clear_results_for_network(&client, &mock_scan_service, network).await;
|
||||
test_mocked_delete_keys_for_network(&client, &mock_scan_service, network).await;
|
||||
test_mocked_getinfo_for_network(&client, &mock_scan_service, &network).await;
|
||||
test_mocked_getresults_for_network(&client, &mock_scan_service, &network).await;
|
||||
test_mocked_register_keys_for_network(&client, &mock_scan_service, &network).await;
|
||||
test_mocked_clear_results_for_network(&client, &mock_scan_service, &network).await;
|
||||
test_mocked_delete_keys_for_network(&client, &mock_scan_service, &network).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ async fn test_grpc_methods_mocked() {
|
|||
async fn test_mocked_getinfo_for_network(
|
||||
client: &ScannerClient<Channel>,
|
||||
mock_scan_service: &MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) {
|
||||
// create request, fake results and get response
|
||||
let get_info_response = call_get_info(client.clone(), mock_scan_service.clone(), network).await;
|
||||
|
@ -66,7 +66,7 @@ async fn test_mocked_getinfo_for_network(
|
|||
async fn test_mocked_getresults_for_network(
|
||||
client: &ScannerClient<Channel>,
|
||||
mock_scan_service: &MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) {
|
||||
// create request, fake populated results and get response
|
||||
let get_results_response =
|
||||
|
@ -114,7 +114,7 @@ async fn test_mocked_getresults_for_network(
|
|||
async fn test_mocked_register_keys_for_network(
|
||||
client: &ScannerClient<Channel>,
|
||||
mock_scan_service: &MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) {
|
||||
// create request, fake return value and get response
|
||||
let register_keys_response =
|
||||
|
@ -132,7 +132,7 @@ async fn test_mocked_register_keys_for_network(
|
|||
async fn test_mocked_clear_results_for_network(
|
||||
client: &ScannerClient<Channel>,
|
||||
mock_scan_service: &MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) {
|
||||
// create request, fake results and get response
|
||||
let get_results_response =
|
||||
|
@ -181,7 +181,7 @@ async fn test_mocked_clear_results_for_network(
|
|||
async fn test_mocked_delete_keys_for_network(
|
||||
client: &ScannerClient<Channel>,
|
||||
mock_scan_service: &MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) {
|
||||
// create request, fake results and get response
|
||||
let register_keys_response =
|
||||
|
@ -267,9 +267,10 @@ async fn start_server_and_get_client(
|
|||
/// Add fake populated results to the mock scan service
|
||||
async fn add_fake_populated_results(
|
||||
mock_scan_service: MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) {
|
||||
let mut mock_scan_service = mock_scan_service.clone();
|
||||
let network = network.clone();
|
||||
tokio::spawn(async move {
|
||||
let zec_pages_sapling_efvk = ZECPAGES_SAPLING_VIEWING_KEY.to_string();
|
||||
let mut fake_results = BTreeMap::new();
|
||||
|
@ -298,7 +299,7 @@ async fn add_fake_populated_results(
|
|||
/// Add fake empty results to the mock scan service
|
||||
async fn add_fake_empty_results(
|
||||
mock_scan_service: MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
_network: Network,
|
||||
_network: &Network,
|
||||
) {
|
||||
let mut mock_scan_service = mock_scan_service.clone();
|
||||
tokio::spawn(async move {
|
||||
|
@ -318,7 +319,7 @@ async fn add_fake_empty_results(
|
|||
async fn call_get_results(
|
||||
client: ScannerClient<Channel>,
|
||||
mock_scan_service: MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
empty_results: bool,
|
||||
) -> tonic::Response<GetResultsResponse> {
|
||||
let get_results_response_fut = {
|
||||
|
@ -380,7 +381,7 @@ async fn test_get_results_errors(mut client: ScannerClient<Channel>) {
|
|||
async fn call_get_info(
|
||||
client: ScannerClient<Channel>,
|
||||
mock_scan_service: MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> tonic::Response<InfoReply> {
|
||||
let get_info_response_fut = {
|
||||
let mut client = client.clone();
|
||||
|
@ -389,6 +390,7 @@ async fn call_get_info(
|
|||
};
|
||||
|
||||
let mut mock_scan_service = mock_scan_service.clone();
|
||||
let network = network.clone();
|
||||
tokio::spawn(async move {
|
||||
mock_scan_service
|
||||
.expect_request_that(|req| matches!(req, ScanRequest::Info))
|
||||
|
@ -408,7 +410,7 @@ async fn call_get_info(
|
|||
async fn call_register_keys(
|
||||
client: ScannerClient<Channel>,
|
||||
mock_scan_service: MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
_network: Network,
|
||||
_network: &Network,
|
||||
) -> tonic::Response<RegisterKeysResponse> {
|
||||
let key_with_height = KeyWithHeight {
|
||||
key: ZECPAGES_SAPLING_VIEWING_KEY.to_string(),
|
||||
|
@ -472,7 +474,7 @@ async fn test_register_keys_errors(client: ScannerClient<Channel>) {
|
|||
async fn call_clear_results(
|
||||
client: ScannerClient<Channel>,
|
||||
mock_scan_service: MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
_network: Network,
|
||||
_network: &Network,
|
||||
) -> tonic::Response<Empty> {
|
||||
let clear_results_response_fut = {
|
||||
let mut client = client.clone();
|
||||
|
@ -525,7 +527,7 @@ async fn test_clear_results_errors(client: ScannerClient<Channel>) {
|
|||
async fn call_delete_keys(
|
||||
client: ScannerClient<Channel>,
|
||||
mock_scan_service: MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||
_network: Network,
|
||||
_network: &Network,
|
||||
) -> tonic::Response<Empty> {
|
||||
let delete_keys_response_fut = {
|
||||
let mut client = client.clone();
|
||||
|
|
|
@ -47,18 +47,18 @@ chrono = { version = "0.4.34", default-features = false, features = ["clock", "s
|
|||
dirs = "5.0.1"
|
||||
hex = "0.4.3"
|
||||
humantime-serde = "1.1.1"
|
||||
indexmap = { version = "2.2.3", features = ["serde"] }
|
||||
indexmap = { version = "2.2.5", features = ["serde"] }
|
||||
itertools = "0.12.1"
|
||||
lazy_static = "1.4.0"
|
||||
num-integer = "0.1.46"
|
||||
ordered-map = "0.4.2"
|
||||
pin-project = "1.1.4"
|
||||
pin-project = "1.1.5"
|
||||
rand = "0.8.5"
|
||||
rayon = "1.8.1"
|
||||
rayon = "1.9.0"
|
||||
regex = "1.10.3"
|
||||
serde = { version = "1.0.196", features = ["serde_derive"] }
|
||||
tempfile = "3.10.0"
|
||||
thiserror = "1.0.57"
|
||||
tempfile = "3.10.1"
|
||||
thiserror = "1.0.58"
|
||||
|
||||
futures = "0.3.30"
|
||||
tokio = { version = "1.36.0", features = ["fs", "io-util", "net", "time", "tracing", "macros", "rt-multi-thread"] }
|
||||
|
@ -66,7 +66,7 @@ tokio-stream = { version = "0.1.14", features = ["sync", "time"] }
|
|||
tokio-util = { version = "0.7.10", features = ["codec"] }
|
||||
tower = { version = "0.4.13", features = ["retry", "discover", "load", "load-shed", "timeout", "util", "buffer"] }
|
||||
|
||||
metrics = "0.22.1"
|
||||
metrics = "0.22.3"
|
||||
tracing-futures = "0.2.5"
|
||||
tracing-error = { version = "0.2.0", features = ["traced-error"] }
|
||||
tracing = "0.1.39"
|
||||
|
@ -91,7 +91,7 @@ proptest-derive = "0.4.0"
|
|||
|
||||
static_assertions = "1.1.0"
|
||||
tokio = { version = "1.36.0", features = ["full", "tracing", "test-util"] }
|
||||
toml = "0.8.10"
|
||||
toml = "0.8.11"
|
||||
|
||||
zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] }
|
||||
zebra-test = { path = "../zebra-test/" }
|
||||
|
|
|
@ -138,7 +138,7 @@ impl AddressBook {
|
|||
/// Uses the supplied [`tracing::Span`] for address book operations.
|
||||
pub fn new(
|
||||
local_listener: SocketAddr,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
max_connections_per_ip: usize,
|
||||
span: Span,
|
||||
) -> AddressBook {
|
||||
|
@ -157,7 +157,7 @@ impl AddressBook {
|
|||
let mut new_book = AddressBook {
|
||||
by_addr: OrderedMap::new(|meta_addr| Reverse(*meta_addr)),
|
||||
local_listener: canonical_socket_addr(local_listener),
|
||||
network,
|
||||
network: network.clone(),
|
||||
addr_limit: constants::MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
span,
|
||||
address_metrics_tx,
|
||||
|
@ -183,7 +183,7 @@ impl AddressBook {
|
|||
#[cfg(any(test, feature = "proptest-impl"))]
|
||||
pub fn new_with_addrs(
|
||||
local_listener: SocketAddr,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
max_connections_per_ip: usize,
|
||||
addr_limit: usize,
|
||||
span: Span,
|
||||
|
@ -293,7 +293,7 @@ impl AddressBook {
|
|||
// Then sanitize and shuffle
|
||||
let mut peers: Vec<MetaAddr> = peers
|
||||
.descending_values()
|
||||
.filter_map(|meta_addr| meta_addr.sanitize(self.network))
|
||||
.filter_map(|meta_addr| meta_addr.sanitize(&self.network))
|
||||
// # Security
|
||||
//
|
||||
// Remove peers that:
|
||||
|
@ -431,7 +431,7 @@ impl AddressBook {
|
|||
if let Some(updated) = updated {
|
||||
// Ignore invalid outbound addresses.
|
||||
// (Inbound connections can be monitored via Zebra's metrics.)
|
||||
if !updated.address_is_valid_for_outbound(self.network) {
|
||||
if !updated.address_is_valid_for_outbound(&self.network) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -440,7 +440,7 @@ impl AddressBook {
|
|||
//
|
||||
// Otherwise, if we got the info directly from the peer,
|
||||
// store it in the address book, so we know not to reconnect.
|
||||
if !updated.last_known_info_is_valid_for_outbound(self.network)
|
||||
if !updated.last_known_info_is_valid_for_outbound(&self.network)
|
||||
&& updated.last_connection_state.is_never_attempted()
|
||||
{
|
||||
return None;
|
||||
|
@ -598,7 +598,7 @@ impl AddressBook {
|
|||
self.by_addr
|
||||
.descending_values()
|
||||
.filter(move |peer| {
|
||||
peer.is_ready_for_connection_attempt(instant_now, chrono_now, self.network)
|
||||
peer.is_ready_for_connection_attempt(instant_now, chrono_now, &self.network)
|
||||
&& self.is_ready_for_connection_attempt_with_ip(&peer.addr.ip(), chrono_now)
|
||||
})
|
||||
.cloned()
|
||||
|
@ -630,7 +630,7 @@ impl AddressBook {
|
|||
self.by_addr
|
||||
.descending_values()
|
||||
.filter(move |peer| {
|
||||
!peer.is_ready_for_connection_attempt(instant_now, chrono_now, self.network)
|
||||
!peer.is_ready_for_connection_attempt(instant_now, chrono_now, &self.network)
|
||||
})
|
||||
.cloned()
|
||||
}
|
||||
|
@ -800,7 +800,7 @@ impl Clone for AddressBook {
|
|||
AddressBook {
|
||||
by_addr: self.by_addr.clone(),
|
||||
local_listener: self.local_listener,
|
||||
network: self.network,
|
||||
network: self.network.clone(),
|
||||
addr_limit: self.addr_limit,
|
||||
span: self.span.clone(),
|
||||
address_metrics_tx,
|
||||
|
|
|
@ -32,7 +32,7 @@ proptest! {
|
|||
|
||||
let address_book = AddressBook::new_with_addrs(
|
||||
local_listener,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::none(),
|
||||
|
@ -71,7 +71,7 @@ proptest! {
|
|||
|
||||
let address_book = AddressBook::new_with_addrs(
|
||||
local_listener,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::none(),
|
||||
|
@ -110,7 +110,7 @@ proptest! {
|
|||
|
||||
let mut address_book = AddressBook::new_with_addrs(
|
||||
local_listener,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
addr_limit,
|
||||
Span::none(),
|
||||
|
@ -133,7 +133,7 @@ proptest! {
|
|||
|
||||
let mut address_book = AddressBook::new_with_addrs(
|
||||
local_listener,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
addr_limit,
|
||||
Span::none(),
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::{
|
|||
fn address_book_empty() {
|
||||
let address_book = AddressBook::new(
|
||||
"0.0.0.0:0".parse().unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
Span::current(),
|
||||
);
|
||||
|
@ -54,7 +54,7 @@ fn address_book_peer_order() {
|
|||
let addrs = vec![meta_addr1, meta_addr2];
|
||||
let address_book = AddressBook::new_with_addrs(
|
||||
"0.0.0.0:0".parse().unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::current(),
|
||||
|
@ -71,7 +71,7 @@ fn address_book_peer_order() {
|
|||
let addrs = vec![meta_addr2, meta_addr1];
|
||||
let address_book = AddressBook::new_with_addrs(
|
||||
"0.0.0.0:0".parse().unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::current(),
|
||||
|
@ -91,7 +91,7 @@ fn address_book_peer_order() {
|
|||
let addrs = vec![meta_addr1, meta_addr2];
|
||||
let address_book = AddressBook::new_with_addrs(
|
||||
"0.0.0.0:0".parse().unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::current(),
|
||||
|
@ -108,7 +108,7 @@ fn address_book_peer_order() {
|
|||
let addrs = vec![meta_addr2, meta_addr1];
|
||||
let address_book = AddressBook::new_with_addrs(
|
||||
"0.0.0.0:0".parse().unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::current(),
|
||||
|
@ -163,7 +163,7 @@ fn test_reconnection_peers_skips_recently_updated_ip<
|
|||
let addrs = vec![meta_addr1, meta_addr2];
|
||||
let address_book = AddressBook::new_with_addrs(
|
||||
"0.0.0.0:0".parse().unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::current(),
|
||||
|
|
|
@ -56,7 +56,7 @@ impl AddressBookUpdater {
|
|||
|
||||
let address_book = AddressBook::new(
|
||||
local_listener,
|
||||
config.network,
|
||||
&config.network,
|
||||
config.max_connections_per_ip,
|
||||
span!(Level::TRACE, "address book"),
|
||||
);
|
||||
|
|
|
@ -381,7 +381,7 @@ impl Config {
|
|||
|
||||
/// Returns the addresses in the peer list cache file, if available.
|
||||
pub async fn load_peer_cache(&self) -> io::Result<HashSet<PeerSocketAddr>> {
|
||||
let Some(peer_cache_file) = self.cache_dir.peer_cache_file_path(self.network) else {
|
||||
let Some(peer_cache_file) = self.cache_dir.peer_cache_file_path(&self.network) else {
|
||||
return Ok(HashSet::new());
|
||||
};
|
||||
|
||||
|
@ -457,7 +457,7 @@ impl Config {
|
|||
/// Atomic writes avoid corrupting the cache if Zebra panics or crashes, or if multiple Zebra
|
||||
/// instances try to read and write the same cache file.
|
||||
pub async fn update_peer_cache(&self, peer_list: HashSet<PeerSocketAddr>) -> io::Result<()> {
|
||||
let Some(peer_cache_file) = self.cache_dir.peer_cache_file_path(self.network) else {
|
||||
let Some(peer_cache_file) = self.cache_dir.peer_cache_file_path(&self.network) else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ impl CacheDir {
|
|||
}
|
||||
|
||||
/// Returns the peer cache file path for `network`, if enabled.
|
||||
pub fn peer_cache_file_path(&self, network: Network) -> Option<PathBuf> {
|
||||
pub fn peer_cache_file_path(&self, network: &Network) -> Option<PathBuf> {
|
||||
Some(
|
||||
self.cache_dir()?
|
||||
.join("network")
|
||||
|
|
|
@ -395,8 +395,8 @@ lazy_static! {
|
|||
pub static ref INITIAL_MIN_NETWORK_PROTOCOL_VERSION: HashMap<Network, Version> = {
|
||||
let mut hash_map = HashMap::new();
|
||||
|
||||
hash_map.insert(Mainnet, Version::min_specified_for_upgrade(Mainnet, Nu5));
|
||||
hash_map.insert(Testnet, Version::min_specified_for_upgrade(Testnet, Nu5));
|
||||
hash_map.insert(Mainnet, Version::min_specified_for_upgrade(&Mainnet, Nu5));
|
||||
hash_map.insert(Testnet, Version::min_specified_for_upgrade(&Testnet, Nu5));
|
||||
|
||||
hash_map
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ mod tests;
|
|||
///
|
||||
/// - `user_agent`: a valid BIP14 user-agent, e.g., the empty string.
|
||||
pub fn connect_isolated<PeerTransport>(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
data_stream: PeerTransport,
|
||||
user_agent: String,
|
||||
) -> impl Future<Output = Result<Client, BoxError>>
|
||||
|
@ -74,7 +74,7 @@ where
|
|||
/// This function can make the isolated connection send different responses to peers,
|
||||
/// which makes it stand out from other isolated connections from other peers.
|
||||
pub fn connect_isolated_with_inbound<PeerTransport, InboundService>(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
data_stream: PeerTransport,
|
||||
user_agent: String,
|
||||
inbound_service: InboundService,
|
||||
|
@ -86,7 +86,7 @@ where
|
|||
InboundService::Future: Send,
|
||||
{
|
||||
let config = Config {
|
||||
network,
|
||||
network: network.clone(),
|
||||
..Config::default()
|
||||
};
|
||||
|
||||
|
@ -125,7 +125,7 @@ where
|
|||
///
|
||||
/// Prefer `connect_isolated_tor` if available.
|
||||
pub fn connect_isolated_tcp_direct(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
addr: impl Into<PeerSocketAddr>,
|
||||
user_agent: String,
|
||||
) -> impl Future<Output = Result<Client, BoxError>> {
|
||||
|
@ -145,7 +145,7 @@ pub fn connect_isolated_tcp_direct(
|
|||
/// This function can make the isolated connection send different responses to peers,
|
||||
/// which makes it stand out from other isolated connections from other peers.
|
||||
pub fn connect_isolated_tcp_direct_with_inbound<InboundService>(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
addr: impl Into<PeerSocketAddr>,
|
||||
user_agent: String,
|
||||
inbound_service: InboundService,
|
||||
|
@ -156,10 +156,11 @@ where
|
|||
InboundService::Future: Send,
|
||||
{
|
||||
let addr = addr.into();
|
||||
let network = network.clone();
|
||||
|
||||
tokio::net::TcpStream::connect(*addr)
|
||||
.err_into()
|
||||
.and_then(move |tcp_stream| {
|
||||
connect_isolated_with_inbound(network, tcp_stream, user_agent, inbound_service)
|
||||
connect_isolated_with_inbound(&network, tcp_stream, user_agent, inbound_service)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -40,15 +40,17 @@ async fn connect_isolated_sends_anonymised_version_message_tcp_net(network: Netw
|
|||
// Connection errors are detected using the JoinHandle.
|
||||
// (They might also make the test hang.)
|
||||
let mut outbound_join_handle = tokio::spawn(connect_isolated_tcp_direct(
|
||||
network,
|
||||
&network,
|
||||
listen_addr,
|
||||
"".to_string(),
|
||||
));
|
||||
|
||||
let (inbound_conn, _) = listener.accept().await.unwrap();
|
||||
|
||||
let mut inbound_stream =
|
||||
Framed::new(inbound_conn, Codec::builder().for_network(network).finish());
|
||||
let mut inbound_stream = Framed::new(
|
||||
inbound_conn,
|
||||
Codec::builder().for_network(&network).finish(),
|
||||
);
|
||||
|
||||
check_version_message(network, &mut inbound_stream).await;
|
||||
|
||||
|
@ -90,11 +92,11 @@ async fn connect_isolated_sends_anonymised_version_message_mem_net(network: Netw
|
|||
let (inbound_stream, outbound_stream) = tokio::io::duplex(1024);
|
||||
|
||||
let mut outbound_join_handle =
|
||||
tokio::spawn(connect_isolated(network, outbound_stream, "".to_string()));
|
||||
tokio::spawn(connect_isolated(&network, outbound_stream, "".to_string()));
|
||||
|
||||
let mut inbound_stream = Framed::new(
|
||||
inbound_stream,
|
||||
Codec::builder().for_network(network).finish(),
|
||||
Codec::builder().for_network(&network).finish(),
|
||||
);
|
||||
|
||||
check_version_message(network, &mut inbound_stream).await;
|
||||
|
|
|
@ -559,7 +559,7 @@ impl MetaAddr {
|
|||
&self,
|
||||
instant_now: Instant,
|
||||
chrono_now: chrono::DateTime<Utc>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> bool {
|
||||
self.last_known_info_is_valid_for_outbound(network)
|
||||
&& !self.was_recently_updated(instant_now, chrono_now)
|
||||
|
@ -571,8 +571,8 @@ impl MetaAddr {
|
|||
///
|
||||
/// Since the addresses in the address book are unique, this check can be
|
||||
/// used to permanently reject entire [`MetaAddr`]s.
|
||||
pub fn address_is_valid_for_outbound(&self, network: Network) -> bool {
|
||||
address_is_valid_for_outbound_connections(self.addr, network).is_ok()
|
||||
pub fn address_is_valid_for_outbound(&self, network: &Network) -> bool {
|
||||
address_is_valid_for_outbound_connections(self.addr, network.clone()).is_ok()
|
||||
}
|
||||
|
||||
/// Is the last known information for this peer valid for outbound
|
||||
|
@ -582,7 +582,7 @@ impl MetaAddr {
|
|||
/// only be used to:
|
||||
/// - reject `NeverAttempted...` [`MetaAddrChange`]s, and
|
||||
/// - temporarily stop outbound connections to a [`MetaAddr`].
|
||||
pub fn last_known_info_is_valid_for_outbound(&self, network: Network) -> bool {
|
||||
pub fn last_known_info_is_valid_for_outbound(&self, network: &Network) -> bool {
|
||||
let is_node = match self.services {
|
||||
Some(services) => services.contains(PeerServices::NODE_NETWORK),
|
||||
None => true,
|
||||
|
@ -627,7 +627,7 @@ impl MetaAddr {
|
|||
///
|
||||
/// Returns `None` if this `MetaAddr` should not be sent to remote peers.
|
||||
#[allow(clippy::unwrap_in_result)]
|
||||
pub fn sanitize(&self, network: Network) -> Option<MetaAddr> {
|
||||
pub fn sanitize(&self, network: &Network) -> Option<MetaAddr> {
|
||||
if !self.last_known_info_is_valid_for_outbound(network) {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ impl MetaAddrChange {
|
|||
|(addr, services, local_now)| {
|
||||
let addr = MetaAddr::new_gossiped_meta_addr(addr, services, local_now);
|
||||
|
||||
if addr.last_known_info_is_valid_for_outbound(Mainnet) {
|
||||
if addr.last_known_info_is_valid_for_outbound(&Mainnet) {
|
||||
Some(addr.addr.port())
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -42,9 +42,9 @@ proptest! {
|
|||
fn sanitize_avoids_leaks(addr in MetaAddr::arbitrary()) {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
if let Some(sanitized) = addr.sanitize(Mainnet) {
|
||||
if let Some(sanitized) = addr.sanitize(&Mainnet) {
|
||||
// check that all sanitized addresses are valid for outbound
|
||||
prop_assert!(addr.last_known_info_is_valid_for_outbound(Mainnet));
|
||||
prop_assert!(addr.last_known_info_is_valid_for_outbound(&Mainnet));
|
||||
// also check the address, port, and services individually
|
||||
prop_assert!(!addr.addr.ip().is_unspecified());
|
||||
prop_assert_ne!(addr.addr.port(), 0);
|
||||
|
@ -117,7 +117,7 @@ proptest! {
|
|||
let mut attempt_count: usize = 0;
|
||||
|
||||
for change in changes {
|
||||
while addr.is_ready_for_connection_attempt(instant_now, chrono_now, Mainnet) {
|
||||
while addr.is_ready_for_connection_attempt(instant_now, chrono_now, &Mainnet) {
|
||||
// Simulate an attempt
|
||||
addr = if let Some(addr) = MetaAddr::new_reconnect(addr.addr)
|
||||
.apply_to_meta_addr(addr, instant_now, chrono_now) {
|
||||
|
@ -158,7 +158,7 @@ proptest! {
|
|||
|
||||
let address_book = AddressBook::new_with_addrs(
|
||||
local_listener,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::none(),
|
||||
|
@ -176,7 +176,7 @@ proptest! {
|
|||
// regardless of where they have come from
|
||||
prop_assert_eq!(
|
||||
book_sanitized_local_listener.cloned(),
|
||||
expected_local_listener.sanitize(Mainnet),
|
||||
expected_local_listener.sanitize(&Mainnet),
|
||||
"address book: {:?}, sanitized_addrs: {:?}, canonical_local_listener: {:?}",
|
||||
address_book,
|
||||
sanitized_addrs,
|
||||
|
@ -217,7 +217,7 @@ proptest! {
|
|||
// Check address book update - return value
|
||||
let mut address_book = AddressBook::new_with_addrs(
|
||||
local_listener,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
1,
|
||||
Span::none(),
|
||||
|
@ -229,8 +229,8 @@ proptest! {
|
|||
let book_contents: Vec<MetaAddr> = address_book.peers().collect();
|
||||
|
||||
// Ignore the same addresses that the address book ignores
|
||||
let expected_result = if !expected_result.address_is_valid_for_outbound(Mainnet)
|
||||
|| ( !expected_result.last_known_info_is_valid_for_outbound(Mainnet)
|
||||
let expected_result = if !expected_result.address_is_valid_for_outbound(&Mainnet)
|
||||
|| ( !expected_result.last_known_info_is_valid_for_outbound(&Mainnet)
|
||||
&& expected_result.last_connection_state.is_never_attempted())
|
||||
{
|
||||
None
|
||||
|
@ -323,7 +323,7 @@ proptest! {
|
|||
|
||||
// Only put valid addresses in the address book.
|
||||
// This means some tests will start with an empty address book.
|
||||
let addrs = if addr.last_known_info_is_valid_for_outbound(Mainnet) {
|
||||
let addrs = if addr.last_known_info_is_valid_for_outbound(&Mainnet) {
|
||||
Some(addr)
|
||||
} else {
|
||||
None
|
||||
|
@ -331,7 +331,7 @@ proptest! {
|
|||
|
||||
let address_book = Arc::new(std::sync::Mutex::new(AddressBook::new_with_addrs(
|
||||
SocketAddr::from_str("0.0.0.0:0").unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
MAX_ADDRS_IN_ADDRESS_BOOK,
|
||||
Span::none(),
|
||||
|
@ -371,7 +371,7 @@ proptest! {
|
|||
LIVE_PEER_INTERVALS,
|
||||
overall_test_time,
|
||||
peer_change_interval,
|
||||
addr.last_known_info_is_valid_for_outbound(Mainnet),
|
||||
addr.last_known_info_is_valid_for_outbound(&Mainnet),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -438,7 +438,7 @@ proptest! {
|
|||
let addr = addrs.entry(addr.addr).or_insert(*addr);
|
||||
let change = changes.get(change_index);
|
||||
|
||||
while addr.is_ready_for_connection_attempt(instant_now, chrono_now, Mainnet) {
|
||||
while addr.is_ready_for_connection_attempt(instant_now, chrono_now, &Mainnet) {
|
||||
// Simulate an attempt
|
||||
*addr = if let Some(addr) = MetaAddr::new_reconnect(addr.addr)
|
||||
.apply_to_meta_addr(*addr, instant_now, chrono_now) {
|
||||
|
|
|
@ -48,10 +48,10 @@ fn sanitize_extremes() {
|
|||
last_connection_state: Default::default(),
|
||||
};
|
||||
|
||||
if let Some(min_sanitized) = min_time_entry.sanitize(Mainnet) {
|
||||
if let Some(min_sanitized) = min_time_entry.sanitize(&Mainnet) {
|
||||
check::sanitize_avoids_leaks(&min_time_entry, &min_sanitized);
|
||||
}
|
||||
if let Some(max_sanitized) = max_time_entry.sanitize(Mainnet) {
|
||||
if let Some(max_sanitized) = max_time_entry.sanitize(&Mainnet) {
|
||||
check::sanitize_avoids_leaks(&max_time_entry, &max_sanitized);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -515,8 +515,8 @@ where
|
|||
let user_agent = self.user_agent.unwrap_or_default();
|
||||
let our_services = self.our_services.unwrap_or_else(PeerServices::empty);
|
||||
let relay = self.relay.unwrap_or(false);
|
||||
let network = config.network;
|
||||
let minimum_peer_version = MinimumPeerVersion::new(self.latest_chain_tip, network);
|
||||
let network = config.network.clone();
|
||||
let minimum_peer_version = MinimumPeerVersion::new(self.latest_chain_tip, &network);
|
||||
|
||||
Ok(Handshake {
|
||||
config,
|
||||
|
@ -898,7 +898,7 @@ where
|
|||
let mut peer_conn = Framed::new(
|
||||
data_stream,
|
||||
Codec::builder()
|
||||
.for_network(config.network)
|
||||
.for_network(&config.network)
|
||||
.with_metrics_addr_label(connected_addr.get_transient_addr_label())
|
||||
.finish(),
|
||||
);
|
||||
|
|
|
@ -35,9 +35,9 @@ where
|
|||
{
|
||||
/// Create a new [`MinimumPeerVersion`] to track the minimum supported peer protocol version
|
||||
/// for the current `chain_tip` on the `network`.
|
||||
pub fn new(chain_tip: C, network: Network) -> Self {
|
||||
pub fn new(chain_tip: C, network: &Network) -> Self {
|
||||
MinimumPeerVersion {
|
||||
network,
|
||||
network: network.clone(),
|
||||
chain_tip,
|
||||
current_minimum: Version::min_remote_for_height(network, None),
|
||||
has_changed: true,
|
||||
|
@ -72,7 +72,7 @@ where
|
|||
/// has changed.
|
||||
fn update(&mut self) {
|
||||
let height = self.chain_tip.best_tip_height();
|
||||
let new_minimum = Version::min_remote_for_height(self.network, height);
|
||||
let new_minimum = Version::min_remote_for_height(&self.network, height);
|
||||
|
||||
if self.current_minimum != new_minimum {
|
||||
self.current_minimum = new_minimum;
|
||||
|
@ -99,7 +99,7 @@ where
|
|||
{
|
||||
fn clone(&self) -> Self {
|
||||
MinimumPeerVersion {
|
||||
network: self.network,
|
||||
network: self.network.clone(),
|
||||
chain_tip: self.chain_tip.clone(),
|
||||
current_minimum: self.current_minimum,
|
||||
has_changed: true,
|
||||
|
|
|
@ -13,7 +13,7 @@ use super::MinimumPeerVersion;
|
|||
mod prop;
|
||||
|
||||
impl MinimumPeerVersion<MockChainTip> {
|
||||
pub fn with_mock_chain_tip(network: Network) -> (Self, MockChainTipSender) {
|
||||
pub fn with_mock_chain_tip(network: &Network) -> (Self, MockChainTipSender) {
|
||||
let (chain_tip, best_tip) = MockChainTip::new();
|
||||
let minimum_peer_version = MinimumPeerVersion::new(chain_tip, network);
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ proptest! {
|
|||
block_height in any::<Option<block::Height>>(),
|
||||
) {
|
||||
let (mut minimum_peer_version, best_tip) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(network);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&network);
|
||||
|
||||
best_tip.send_best_tip_height(block_height);
|
||||
|
||||
let expected_minimum_version = Version::min_remote_for_height(network, block_height);
|
||||
let expected_minimum_version = Version::min_remote_for_height(&network, block_height);
|
||||
|
||||
prop_assert_eq!(minimum_peer_version.current(), expected_minimum_version);
|
||||
}
|
||||
|
@ -28,12 +28,12 @@ proptest! {
|
|||
block_heights in any::<Vec<Option<block::Height>>>(),
|
||||
) {
|
||||
let (mut minimum_peer_version, best_tip) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(network);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&network);
|
||||
|
||||
for block_height in block_heights {
|
||||
best_tip.send_best_tip_height(block_height);
|
||||
|
||||
let expected_minimum_version = Version::min_remote_for_height(network, block_height);
|
||||
let expected_minimum_version = Version::min_remote_for_height(&network, block_height);
|
||||
|
||||
prop_assert_eq!(minimum_peer_version.current(), expected_minimum_version);
|
||||
}
|
||||
|
@ -46,9 +46,9 @@ proptest! {
|
|||
block_height_updates in any::<Vec<Option<Option<block::Height>>>>(),
|
||||
) {
|
||||
let (mut minimum_peer_version, best_tip) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(network);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&network);
|
||||
|
||||
let mut current_minimum_version = Version::min_remote_for_height(network, None);
|
||||
let mut current_minimum_version = Version::min_remote_for_height(&network, None);
|
||||
let mut expected_minimum_version = Some(current_minimum_version);
|
||||
|
||||
prop_assert_eq!(minimum_peer_version.changed(), expected_minimum_version);
|
||||
|
@ -57,7 +57,7 @@ proptest! {
|
|||
if let Some(new_block_height) = update {
|
||||
best_tip.send_best_tip_height(new_block_height);
|
||||
|
||||
let new_minimum_version = Version::min_remote_for_height(network, new_block_height);
|
||||
let new_minimum_version = Version::min_remote_for_height(&network, new_block_height);
|
||||
|
||||
expected_minimum_version = if new_minimum_version != current_minimum_version {
|
||||
Some(new_minimum_version)
|
||||
|
|
|
@ -71,7 +71,7 @@ proptest! {
|
|||
});
|
||||
|
||||
// Since the address book is empty, there won't be any available peers
|
||||
let address_book = AddressBook::new(SocketAddr::from_str("0.0.0.0:0").unwrap(), Mainnet, DEFAULT_MAX_CONNS_PER_IP, Span::none());
|
||||
let address_book = AddressBook::new(SocketAddr::from_str("0.0.0.0:0").unwrap(), &Mainnet, DEFAULT_MAX_CONNS_PER_IP, Span::none());
|
||||
|
||||
let mut candidate_set = CandidateSet::new(Arc::new(std::sync::Mutex::new(address_book)), peer_service);
|
||||
|
||||
|
@ -113,7 +113,7 @@ proptest! {
|
|||
unreachable!("Mock peer service is never used");
|
||||
});
|
||||
|
||||
let mut address_book = AddressBook::new(SocketAddr::from_str("0.0.0.0:0").unwrap(), Mainnet, DEFAULT_MAX_CONNS_PER_IP, Span::none());
|
||||
let mut address_book = AddressBook::new(SocketAddr::from_str("0.0.0.0:0").unwrap(), &Mainnet, DEFAULT_MAX_CONNS_PER_IP, Span::none());
|
||||
address_book.extend(peers);
|
||||
|
||||
let mut candidate_set = CandidateSet::new(Arc::new(std::sync::Mutex::new(address_book)), peer_service);
|
||||
|
|
|
@ -140,7 +140,7 @@ fn candidate_set_updates_are_rate_limited() {
|
|||
|
||||
let address_book = AddressBook::new(
|
||||
SocketAddr::from_str("0.0.0.0:0").unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
Span::none(),
|
||||
);
|
||||
|
@ -186,7 +186,7 @@ fn candidate_set_update_after_update_initial_is_rate_limited() {
|
|||
|
||||
let address_book = AddressBook::new(
|
||||
SocketAddr::from_str("0.0.0.0:0").unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
Span::none(),
|
||||
);
|
||||
|
|
|
@ -174,7 +174,7 @@ where
|
|||
handle_rx,
|
||||
inv_receiver,
|
||||
address_metrics,
|
||||
MinimumPeerVersion::new(latest_chain_tip, config.network),
|
||||
MinimumPeerVersion::new(latest_chain_tip, &config.network),
|
||||
None,
|
||||
);
|
||||
let peer_set = Buffer::new(BoxService::new(peer_set), constants::PEERSET_BUFFER_SIZE);
|
||||
|
@ -436,7 +436,7 @@ async fn limit_initial_peers(
|
|||
// Filter out invalid initial peers, and prioritise valid peers for initial connections.
|
||||
// (This treats initial peers the same way we treat gossiped peers.)
|
||||
for peer_addr in all_peers {
|
||||
let preference = PeerPreference::new(peer_addr, config.network);
|
||||
let preference = PeerPreference::new(peer_addr, config.network.clone());
|
||||
|
||||
match preference {
|
||||
Ok(preference) => preferred_peers
|
||||
|
@ -499,7 +499,7 @@ async fn limit_initial_peers(
|
|||
pub(crate) async fn open_listener(config: &Config) -> (TcpListener, SocketAddr) {
|
||||
// Warn if we're configured using the wrong network port.
|
||||
if let Err(wrong_addr) =
|
||||
address_is_valid_for_inbound_listeners(config.listen_addr, config.network)
|
||||
address_is_valid_for_inbound_listeners(config.listen_addr, config.network.clone())
|
||||
{
|
||||
warn!(
|
||||
"We are configured with address {} on {:?}, but it could cause network issues. \
|
||||
|
|
|
@ -325,7 +325,7 @@ async fn written_peer_cache_can_be_read_manually() {
|
|||
assert!(
|
||||
!cached_peers.is_empty(),
|
||||
"unexpected empty peer cache from manual load: {:?}",
|
||||
config.cache_dir.peer_cache_file_path(config.network)
|
||||
config.cache_dir.peer_cache_file_path(&config.network)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ async fn written_peer_cache_is_automatically_read_on_startup() {
|
|||
assert!(
|
||||
approximate_cached_peer_count > 0,
|
||||
"unexpected empty address book using cache from previous instance: {:?}",
|
||||
config.cache_dir.peer_cache_file_path(config.network)
|
||||
config.cache_dir.peer_cache_file_path(&config.network)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -336,7 +336,7 @@ impl PeerSetGuard {
|
|||
.expect("Invalid local listener address");
|
||||
let address_book = AddressBook::new(
|
||||
local_listener,
|
||||
Network::Mainnet,
|
||||
&Network::Mainnet,
|
||||
DEFAULT_MAX_CONNS_PER_IP,
|
||||
Span::none(),
|
||||
);
|
||||
|
@ -347,7 +347,7 @@ impl PeerSetGuard {
|
|||
|
||||
/// A pair of block height values, where one is before and the other is at or after an arbitrary
|
||||
/// network upgrade's activation height.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BlockHeightPairAcrossNetworkUpgrades {
|
||||
/// The network for which the block height values represent heights before and after an
|
||||
/// upgrade.
|
||||
|
@ -374,7 +374,7 @@ impl Arbitrary for BlockHeightPairAcrossNetworkUpgrades {
|
|||
"missing activation height for network upgrade",
|
||||
|(network, upgrade)| {
|
||||
upgrade
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.map(|height| (network, height))
|
||||
},
|
||||
)
|
||||
|
|
|
@ -31,7 +31,7 @@ proptest! {
|
|||
let (runtime, _init_guard) = zebra_test::init_async();
|
||||
|
||||
let (mut minimum_peer_version, best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(network);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&network);
|
||||
|
||||
best_tip_height.send_best_tip_height(block_height);
|
||||
|
||||
|
@ -64,7 +64,7 @@ proptest! {
|
|||
let (runtime, _init_guard) = zebra_test::init_async();
|
||||
|
||||
let (mut minimum_peer_version, best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(block_heights.network);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&block_heights.network);
|
||||
|
||||
best_tip_height.send_best_tip_height(block_heights.before_upgrade);
|
||||
|
||||
|
@ -117,7 +117,7 @@ proptest! {
|
|||
// Get peers and handles
|
||||
let (discovered_peers, mut handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
// Build a peerset
|
||||
runtime.block_on(async move {
|
||||
|
@ -193,7 +193,7 @@ proptest! {
|
|||
// Get peers and handles
|
||||
let (discovered_peers, mut handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
runtime.block_on(async move {
|
||||
// Build a peerset
|
||||
|
@ -264,7 +264,7 @@ proptest! {
|
|||
// Get peers and handles
|
||||
let (discovered_peers, mut handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
runtime.block_on(async move {
|
||||
// Build a peerset
|
||||
|
|
|
@ -25,7 +25,7 @@ fn peer_set_ready_single_connection() {
|
|||
// We are going to use just one peer version in this test
|
||||
let peer_versions = PeerVersions {
|
||||
peer_versions: vec![Version::min_specified_for_upgrade(
|
||||
Network::Mainnet,
|
||||
&Network::Mainnet,
|
||||
NetworkUpgrade::Nu5,
|
||||
)],
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ fn peer_set_ready_single_connection() {
|
|||
// Get peers and client handles of them
|
||||
let (discovered_peers, handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
// We will just use the first peer handle
|
||||
let mut client_handle = handles
|
||||
|
@ -118,7 +118,7 @@ fn peer_set_ready_single_connection() {
|
|||
#[test]
|
||||
fn peer_set_ready_multiple_connections() {
|
||||
// Use three peers with the same version
|
||||
let peer_version = Version::min_specified_for_upgrade(Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_version = Version::min_specified_for_upgrade(&Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_versions = PeerVersions {
|
||||
peer_versions: vec![peer_version, peer_version, peer_version],
|
||||
};
|
||||
|
@ -136,7 +136,7 @@ fn peer_set_ready_multiple_connections() {
|
|||
// Get peers and client handles of them
|
||||
let (discovered_peers, handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
// Make sure we have the right number of peers
|
||||
assert_eq!(handles.len(), 3);
|
||||
|
@ -182,7 +182,7 @@ fn peer_set_rejects_connections_past_per_ip_limit() {
|
|||
const NUM_PEER_VERSIONS: usize = crate::constants::DEFAULT_MAX_CONNS_PER_IP + 1;
|
||||
|
||||
// Use three peers with the same version
|
||||
let peer_version = Version::min_specified_for_upgrade(Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_version = Version::min_specified_for_upgrade(&Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_versions = PeerVersions {
|
||||
peer_versions: [peer_version; NUM_PEER_VERSIONS].into_iter().collect(),
|
||||
};
|
||||
|
@ -200,7 +200,7 @@ fn peer_set_rejects_connections_past_per_ip_limit() {
|
|||
// Get peers and client handles of them
|
||||
let (discovered_peers, handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
// Make sure we have the right number of peers
|
||||
assert_eq!(handles.len(), NUM_PEER_VERSIONS);
|
||||
|
@ -232,7 +232,7 @@ fn peer_set_route_inv_empty_registry() {
|
|||
let test_hash = block::Hash([0; 32]);
|
||||
|
||||
// Use two peers with the same version
|
||||
let peer_version = Version::min_specified_for_upgrade(Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_version = Version::min_specified_for_upgrade(&Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_versions = PeerVersions {
|
||||
peer_versions: vec![peer_version, peer_version],
|
||||
};
|
||||
|
@ -250,7 +250,7 @@ fn peer_set_route_inv_empty_registry() {
|
|||
// Get peers and client handles of them
|
||||
let (discovered_peers, handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
// Make sure we have the right number of peers
|
||||
assert_eq!(handles.len(), 2);
|
||||
|
@ -315,7 +315,7 @@ fn peer_set_route_inv_advertised_registry_order(advertised_first: bool) {
|
|||
let test_change = InventoryStatus::new_available(test_inv, test_peer);
|
||||
|
||||
// Use two peers with the same version
|
||||
let peer_version = Version::min_specified_for_upgrade(Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_version = Version::min_specified_for_upgrade(&Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_versions = PeerVersions {
|
||||
peer_versions: vec![peer_version, peer_version],
|
||||
};
|
||||
|
@ -333,7 +333,7 @@ fn peer_set_route_inv_advertised_registry_order(advertised_first: bool) {
|
|||
// Get peers and client handles of them
|
||||
let (discovered_peers, mut handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
// Make sure we have the right number of peers
|
||||
assert_eq!(handles.len(), 2);
|
||||
|
@ -423,7 +423,7 @@ fn peer_set_route_inv_missing_registry_order(missing_first: bool) {
|
|||
let test_change = InventoryStatus::new_missing(test_inv, test_peer);
|
||||
|
||||
// Use two peers with the same version
|
||||
let peer_version = Version::min_specified_for_upgrade(Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_version = Version::min_specified_for_upgrade(&Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_versions = PeerVersions {
|
||||
peer_versions: vec![peer_version, peer_version],
|
||||
};
|
||||
|
@ -441,7 +441,7 @@ fn peer_set_route_inv_missing_registry_order(missing_first: bool) {
|
|||
// Get peers and client handles of them
|
||||
let (discovered_peers, mut handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
// Make sure we have the right number of peers
|
||||
assert_eq!(handles.len(), 2);
|
||||
|
@ -525,7 +525,7 @@ fn peer_set_route_inv_all_missing_fail() {
|
|||
let test_change = InventoryStatus::new_missing(test_inv, test_peer);
|
||||
|
||||
// Use one peer
|
||||
let peer_version = Version::min_specified_for_upgrade(Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_version = Version::min_specified_for_upgrade(&Network::Mainnet, NetworkUpgrade::Nu5);
|
||||
let peer_versions = PeerVersions {
|
||||
peer_versions: vec![peer_version],
|
||||
};
|
||||
|
@ -543,7 +543,7 @@ fn peer_set_route_inv_all_missing_fail() {
|
|||
// Get the peer and its client handle
|
||||
let (discovered_peers, mut handles) = peer_versions.mock_peer_discovery();
|
||||
let (minimum_peer_version, _best_tip_height) =
|
||||
MinimumPeerVersion::with_mock_chain_tip(Network::Mainnet);
|
||||
MinimumPeerVersion::with_mock_chain_tip(&Network::Mainnet);
|
||||
|
||||
// Make sure we have the right number of peers
|
||||
assert_eq!(handles.len(), 1);
|
||||
|
|
|
@ -84,8 +84,8 @@ impl Builder {
|
|||
}
|
||||
|
||||
/// Configure the codec for the given [`Network`].
|
||||
pub fn for_network(mut self, network: Network) -> Self {
|
||||
self.network = network;
|
||||
pub fn for_network(mut self, network: &Network) -> Self {
|
||||
self.network = network.clone();
|
||||
self
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue