diff --git a/.github/workflows/continous-delivery.yml b/.github/workflows/continous-delivery.yml
index 744f934f4a9..3f1bb77514f 100644
--- a/.github/workflows/continous-delivery.yml
+++ b/.github/workflows/continous-delivery.yml
@@ -120,6 +120,8 @@ jobs:
run: |
gcloud compute instance-templates create-with-container zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
--boot-disk-type=pd-ssd \
+ --image-project=cos-cloud \
+ --image-family=cos-stable \
--container-image ${{ env.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }} \
--create-disk name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }},auto-delete=yes,size=300GB,type=pd-ssd \
--container-mount-disk mount-path="/zebrad-cache",name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }} \
@@ -196,6 +198,8 @@ jobs:
gcloud compute instances create-with-container "zebrad-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
--boot-disk-size 300GB \
--boot-disk-type=pd-ssd \
+ --image-project=cos-cloud \
+ --image-family=cos-stable \
--container-stdin \
--container-tty \
--container-image ${{ env.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }} \
diff --git a/.github/workflows/continous-integration-docker.patch.yml b/.github/workflows/continous-integration-docker.patch.yml
index 06225b59b13..c0a34842233 100644
--- a/.github/workflows/continous-integration-docker.patch.yml
+++ b/.github/workflows/continous-integration-docker.patch.yml
@@ -90,6 +90,12 @@ jobs:
steps:
- run: 'echo "No build required"'
+ get-block-template-test:
+ name: get block template / Run get-block-template test
+ runs-on: ubuntu-latest
+ steps:
+ - run: 'echo "No build required"'
+
submit-block-test:
name: submit block / Run submit-block test
runs-on: ubuntu-latest
diff --git a/.github/workflows/continous-integration-docker.yml b/.github/workflows/continous-integration-docker.yml
index f5ee2d9e87b..08b77f834fa 100644
--- a/.github/workflows/continous-integration-docker.yml
+++ b/.github/workflows/continous-integration-docker.yml
@@ -581,6 +581,31 @@ jobs:
zebra_state_dir: 'zebrad-cache'
lwd_state_dir: 'lwd-cache'
+ # Test that Zebra can handle a getblocktemplate RPC call, using a cached Zebra tip state
+ #
+ # Runs:
+ # - after every PR is merged to `main`
+ # - on every PR update
+ #
+ # If the state version has changed, waits for the new cached states to be created.
+ # Otherwise, if the state rebuild was skipped, runs immediately after the build job.
+ get-block-template-test:
+ name: get block template
+ needs: test-full-sync
+ uses: ./.github/workflows/deploy-gcp-tests.yml
+ if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' && github.event.inputs.run-lwd-send-tx != 'true' }}
+ with:
+ app_name: zebrad
+ test_id: get-block-template
+ test_description: Test getblocktemplate RPC method via Zebra's rpc server
+ test_variables: '-e TEST_GET_BLOCK_TEMPLATE=1 -e ZEBRA_FORCE_USE_COLOR=1 -e ZEBRA_CACHED_STATE_DIR=/var/cache/zebrad-cache'
+ needs_zebra_state: true
+ needs_lwd_state: false
+ saves_to_disk: false
+ disk_suffix: tip
+ root_state_path: '/var/cache'
+ zebra_state_dir: 'zebrad-cache'
+
# Test that Zebra can handle a submit block RPC call, using a cached Zebra tip state
#
# Runs:
diff --git a/.github/workflows/deploy-gcp-tests.yml b/.github/workflows/deploy-gcp-tests.yml
index ecd9f10fce7..f0274ac9b60 100644
--- a/.github/workflows/deploy-gcp-tests.yml
+++ b/.github/workflows/deploy-gcp-tests.yml
@@ -144,9 +144,10 @@ jobs:
gcloud compute instances create-with-container "${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
--boot-disk-size 300GB \
--boot-disk-type pd-ssd \
+ --image-project=cos-cloud \
+ --image-family=cos-stable \
--create-disk name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",device-name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",size=300GB,type=pd-ssd \
- --container-image gcr.io/google-containers/busybox \
- --container-restart-policy=never \
+ --container-image=gcr.io/google-containers/busybox \
--machine-type ${{ env.MACHINE_TYPE }} \
--scopes cloud-platform \
--metadata=google-monitoring-enabled=TRUE,google-logging-enabled=TRUE,enable-oslogin=TRUE \
@@ -363,9 +364,10 @@ jobs:
gcloud compute instances create-with-container "${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
--boot-disk-size 300GB \
--boot-disk-type pd-ssd \
+ --image-project=cos-cloud \
+ --image-family=cos-stable \
--create-disk image=${{ env.CACHED_DISK_NAME }},name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",device-name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",size=300GB,type=pd-ssd \
- --container-image gcr.io/google-containers/busybox \
- --container-restart-policy=never \
+ --container-image=gcr.io/google-containers/busybox \
--machine-type ${{ env.MACHINE_TYPE }} \
--scopes cloud-platform \
--metadata=google-monitoring-enabled=TRUE,google-logging-enabled=TRUE,enable-oslogin=TRUE \
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 54363311b44..136c85a0bba 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -173,7 +173,7 @@ jobs:
if: ${{ needs.changed-files.outputs.workflows == 'true' }}
steps:
- uses: actions/checkout@v3.1.0
- - uses: reviewdog/action-actionlint@v1.34.0
+ - uses: reviewdog/action-actionlint@v1.34.1
with:
level: warning
fail_on_error: false
diff --git a/.github/workflows/zcashd-manual-deploy.yml b/.github/workflows/zcashd-manual-deploy.yml
index c7482935e5e..8ab7eb499ff 100644
--- a/.github/workflows/zcashd-manual-deploy.yml
+++ b/.github/workflows/zcashd-manual-deploy.yml
@@ -55,6 +55,8 @@ jobs:
gcloud compute instance-templates create-with-container zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
--boot-disk-size 10GB \
--boot-disk-type=pd-ssd \
+ --image-project=cos-cloud \
+ --image-family=cos-stable \
--container-stdin \
--container-tty \
--container-image electriccoinco/zcashd \
diff --git a/Cargo.lock b/Cargo.lock
index e68d68b8472..723f83df913 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1977,9 +1977,9 @@ dependencies = [
[[package]]
name = "insta"
-version = "1.21.0"
+version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "581d4e3314cae4536e5d22ffd23189d4a374696c5ef733eadafae0ed273fd303"
+checksum = "ba1e75aa1530e7385af7b2685478dece08dafb9db3b4225c753286decea83bef"
dependencies = [
"console",
"lazy_static",
@@ -3699,9 +3699,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "sentry"
-version = "0.28.0"
+version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a120fb5e8b7975736bf1fc57de380531e617a6a8f5a55d037bcea25a7f5e8371"
+checksum = "c6425e2a14006415449fb0a3e9a119df5032f59e7a2d9350cf8738eca290dfc5"
dependencies = [
"httpdate",
"reqwest",
@@ -3716,9 +3716,9 @@ dependencies = [
[[package]]
name = "sentry-backtrace"
-version = "0.28.0"
+version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2ac56ff9aae25b024a5aad4f0242808dfde29161c82d183adce778338c6822ef"
+checksum = "04d79c194e5c20fe602e81faf39f3cff0f275ec61283f437a892cfd6544da592"
dependencies = [
"backtrace",
"once_cell",
@@ -3728,9 +3728,9 @@ dependencies = [
[[package]]
name = "sentry-contexts"
-version = "0.28.0"
+version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "188506b08b5e64004c71b7a5edb34959083e6e1288fada3b8d18d0bc7449ce1e"
+checksum = "e1c2a57601eeb870521cc241caee27e57a012f297ece3c1b7eee87f2a531edb5"
dependencies = [
"hostname",
"libc",
@@ -3742,9 +3742,9 @@ dependencies = [
[[package]]
name = "sentry-core"
-version = "0.28.0"
+version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff58433a7ad557b586a09c42c4298d5f3ddb0c777e1a79d950e510d7b93fce0e"
+checksum = "8be90ea119c6d0664c8ab534013bc9e90355e7004d782d5d1492ca513393b929"
dependencies = [
"once_cell",
"rand 0.8.5",
@@ -3755,9 +3755,9 @@ dependencies = [
[[package]]
name = "sentry-tracing"
-version = "0.28.0"
+version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc8d5bae1e1c06d96a966efc425bf1479a90464de99757d40601ce449f91fbed"
+checksum = "073a872ab639da1bee23354025ddc9c1b9e5d70eabfe8cd6f10a81914cf6563d"
dependencies = [
"sentry-core",
"tracing-core",
@@ -3766,11 +3766,10 @@ dependencies = [
[[package]]
name = "sentry-types"
-version = "0.28.0"
+version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb30d75498a041005a774ec1b6b7d9589c5906d17ebaca338cb685dc92170f9b"
+checksum = "67ad85f0addf16310a1fbcf3facc7acb17ef5dbf6ae059d2f3c38442a471404d"
dependencies = [
- "chrono",
"debugid",
"getrandom 0.2.5",
"hex",
@@ -3837,9 +3836,9 @@ dependencies = [
[[package]]
name = "serde_with"
-version = "2.0.1"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "368f2d60d049ea019a84dcd6687b0d1e0030fe663ae105039bdf967ed5e6a9a7"
+checksum = "25bf4a5a814902cd1014dbccfa4d4560fb8432c779471e96e035602519f82eef"
dependencies = [
"base64",
"chrono",
@@ -3853,9 +3852,9 @@ dependencies = [
[[package]]
name = "serde_with_macros"
-version = "2.0.1"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1ccadfacf6cf10faad22bbadf55986bdd0856edfb5d9210aa1dcf1f516e84e93"
+checksum = "e3452b4c0f6c1e357f73fdb87cd1efabaa12acf328c7a528e252893baeb3f4aa"
dependencies = [
"darling 0.14.1",
"proc-macro2 1.0.42",
diff --git a/README.md b/README.md
index a8f28569c38..a7201605ad6 100644
--- a/README.md
+++ b/README.md
@@ -242,6 +242,8 @@ There are a few bugs in Zebra that we're still working on fixing:
- Experimental Tor support is disabled until [`arti-client` upgrades to `x25519-dalek` 2.0.0 or later](https://github.com/ZcashFoundation/zebra/issues/5492)
- This happens due to a Rust dependency conflict, which can only be resolved by changing the dependencies of `x25519-dalek`
+- Output of `help`, `--help` flag, and usage of invalid commands or options are inconsistent. Reports of these issues can be found [here](https://github.com/ZcashFoundation/zebra/issues/5502) and are planned to be fixed in the context of [upgrading Abscissa](https://github.com/ZcashFoundation/zebra/issues/5502).
+
## Future Work
Performance and Reliability:
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
index 6129f8bf32e..b7fa28f15c3 100755
--- a/docker/entrypoint.sh
+++ b/docker/entrypoint.sh
@@ -78,6 +78,10 @@ case "$1" in
ls -lh "$ZEBRA_CACHED_STATE_DIR"/*/* || (echo "No $ZEBRA_CACHED_STATE_DIR/*/*"; ls -lhR "$ZEBRA_CACHED_STATE_DIR" | head -50 || echo "No $ZEBRA_CACHED_STATE_DIR directory")
ls -lhR "$LIGHTWALLETD_DATA_DIR/db" || (echo "No $LIGHTWALLETD_DATA_DIR/db"; ls -lhR "$LIGHTWALLETD_DATA_DIR" | head -50 || echo "No $LIGHTWALLETD_DATA_DIR directory")
cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored sending_transactions_using_lightwalletd
+ elif [[ "$TEST_GET_BLOCK_TEMPLATE" -eq "1" ]]; then
+ # Starting with a cached Zebra tip, test getting a block template from Zebra's RPC server.
+ ls -lh "$ZEBRA_CACHED_STATE_DIR"/*/* || (echo "No $ZEBRA_CACHED_STATE_DIR/*/*"; ls -lhR "$ZEBRA_CACHED_STATE_DIR" | head -50 || echo "No $ZEBRA_CACHED_STATE_DIR directory")
+ cargo test --locked --release --features getblocktemplate-rpcs --package zebrad --test acceptance -- --nocapture --include-ignored get_block_template
elif [[ "$TEST_SUBMIT_BLOCK" -eq "1" ]]; then
# Starting with a cached Zebra tip, test sending a block to Zebra's RPC port.
ls -lh "$ZEBRA_CACHED_STATE_DIR"/*/* || (echo "No $ZEBRA_CACHED_STATE_DIR/*/*"; ls -lhR "$ZEBRA_CACHED_STATE_DIR" | head -50 || echo "No $ZEBRA_CACHED_STATE_DIR directory")
diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml
index 0102e7a0808..5bdbc3a5b5f 100644
--- a/zebra-chain/Cargo.toml
+++ b/zebra-chain/Cargo.toml
@@ -76,7 +76,7 @@ tracing = "0.1.37"
# Serialization
hex = { version = "0.4.3", features = ["serde"] }
serde = { version = "1.0.147", features = ["serde_derive", "rc"] }
-serde_with = "2.0.1"
+serde_with = "2.1.0"
serde-big-array = "0.4.1"
# Processing
diff --git a/zebra-chain/src/chain_tip.rs b/zebra-chain/src/chain_tip.rs
index 923302acdf9..27fa08e13eb 100644
--- a/zebra-chain/src/chain_tip.rs
+++ b/zebra-chain/src/chain_tip.rs
@@ -58,6 +58,28 @@ pub trait ChainTip {
Some(estimator.estimate_height_at(now))
}
+
+ /// Return an estimate of how many blocks there are ahead of Zebra's best chain tip
+ /// until the network chain tip, and Zebra's best chain tip height.
+ ///
+ /// The estimate is calculated based on the current local time, the block time of the best tip
+ /// and the height of the best tip.
+ ///
+ /// This estimate may be negative if the current local time is behind the chain tip block's timestamp.
+ fn estimate_distance_to_network_chain_tip(
+ &self,
+ network: Network,
+ ) -> Option<(i32, block::Height)> {
+ let (current_height, current_block_time) = self.best_tip_height_and_block_time()?;
+
+ let estimator =
+ NetworkChainTipHeightEstimator::new(current_block_time, current_height, network);
+
+ Some((
+ estimator.estimate_height_at(Utc::now()) - current_height,
+ current_height,
+ ))
+ }
}
/// A chain tip that is always empty.
diff --git a/zebra-chain/src/chain_tip/mock.rs b/zebra-chain/src/chain_tip/mock.rs
index b13231d60f5..fec056a3749 100644
--- a/zebra-chain/src/chain_tip/mock.rs
+++ b/zebra-chain/src/chain_tip/mock.rs
@@ -5,7 +5,7 @@ use std::sync::Arc;
use chrono::{DateTime, Utc};
use tokio::sync::watch;
-use crate::{block, chain_tip::ChainTip, transaction};
+use crate::{block, chain_tip::ChainTip, parameters::Network, transaction};
/// A sender to sets the values read by a [`MockChainTip`].
pub struct MockChainTipSender {
@@ -17,6 +17,9 @@ pub struct MockChainTipSender {
/// A sender that sets the `best_tip_block_time` of a [`MockChainTip`].
best_tip_block_time: watch::Sender