Skip to content

Commit

Permalink
Merge branch 'main' into pili-6281
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 authored May 23, 2023
2 parents f4dcdc0 + f2be848 commit 32d37c7
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 81 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-crates-individually.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

jobs:
matrix:
name: Crates matrix
name: Generate crates matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
Expand Down Expand Up @@ -54,6 +54,7 @@ jobs:
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
check-matrix:
name: Check crates matrix
runs-on: ubuntu-latest
needs: [ matrix ]
steps:
Expand All @@ -67,4 +68,4 @@ jobs:
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}

steps:
- run: 'echo "No job required"'
- run: 'echo "No job required"'
4 changes: 2 additions & 2 deletions .github/workflows/continous-integration-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=${{ matrix.rust }} --profile=minimal
- uses: Swatinem/rust-cache@v2.3.0
- uses: Swatinem/rust-cache@v2.4.0
# TODO: change Rust cache target directory on Windows,
# or remove this workaround once the build is more efficient (#3005).
#with:
Expand Down Expand Up @@ -236,7 +236,7 @@ jobs:
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=minimal
- uses: Swatinem/rust-cache@v2.3.0
- uses: Swatinem/rust-cache@v2.4.0
with:
shared-key: "clippy-cargo-lock"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=beta --profile=default
- uses: Swatinem/rust-cache@v2.3.0
- uses: Swatinem/rust-cache@v2.4.0

- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1.2.0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=default
- uses: Swatinem/rust-cache@v2.3.0
- uses: Swatinem/rust-cache@v2.4.0
with:
shared-key: "clippy-cargo-lock"

Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
# We don't cache `fmt` outputs because the job is quick,
# and we want to use the limited GitHub actions cache space for slower jobs.
#- uses: Swatinem/rust-cache@v2.3.0
#- uses: Swatinem/rust-cache@v2.4.0

- run: |
cargo fmt --all -- --check
Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3982,9 +3982,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"

[[package]]
name = "sentry"
version = "0.31.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c3d7f8bf7373e75222452fcdd9347d857452a92d0eec738f941bc4656c5b5df"
checksum = "37dd6c0cdca6b1d1ca44cde7fff289f2592a97965afec870faa7b81b9fc87745"
dependencies = [
"httpdate",
"reqwest",
Expand All @@ -4000,9 +4000,9 @@ dependencies = [

[[package]]
name = "sentry-backtrace"
version = "0.31.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03b7cdefbdca51f1146f0f24a3cb4ecb6428951f030ff5c720cfb5c60bd174c0"
checksum = "c029fe8317cdd75cb2b52c600bab4e2ef64c552198e669ba874340447f330962"
dependencies = [
"backtrace",
"once_cell",
Expand All @@ -4012,9 +4012,9 @@ dependencies = [

[[package]]
name = "sentry-contexts"
version = "0.31.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af4cb29066e0e8df0cc3111211eb93543ccb09e1ccbe71de6d88b4bb459a2b1"
checksum = "bc575098d73c8b942b589ab453b06e4c43527556dd8f95532220d1b54d7c6b4b"
dependencies = [
"hostname",
"libc",
Expand All @@ -4026,9 +4026,9 @@ dependencies = [

[[package]]
name = "sentry-core"
version = "0.31.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e781b55761e47a60d1ff326ae8059de22b0e6b0cee68eab1c5912e4fb199a76"
checksum = "20216140001bbf05895f013abd0dae4df58faee24e016d54cbf107f070bac56b"
dependencies = [
"once_cell",
"rand 0.8.5",
Expand All @@ -4039,9 +4039,9 @@ dependencies = [

[[package]]
name = "sentry-tracing"
version = "0.31.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4692bfc5bf69a8a41ccb0ce96612686eddb2406e32f7113f536efa15949af8"
checksum = "0ef4111647923c797687094bc792b8da938c4b0d64fab331d5b7a7de41964de8"
dependencies = [
"sentry-core",
"tracing-core",
Expand All @@ -4050,9 +4050,9 @@ dependencies = [

[[package]]
name = "sentry-types"
version = "0.31.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d642a04657cc77d8de52ae7c6d93a15cb02284eb219344a89c1e2b26bbaf578c"
checksum = "d7f6959d8cb3a77be27e588eef6ce9a2a469651a556d9de662e4d07e5ace4232"
dependencies = [
"debugid",
"getrandom 0.2.9",
Expand Down Expand Up @@ -5180,9 +5180,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"

[[package]]
name = "vergen"
version = "8.1.3"
version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e03272e388fb78fc79481a493424f78d77be1d55f21bcd314b5a6716e195afe"
checksum = "3e884903ddba094df9bcdeb43b41170658bb4c2001ca8c47df7368244f4210ee"
dependencies = [
"anyhow",
"git2",
Expand Down
34 changes: 12 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

---

[![CI Docker](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-integration-docker.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-integration-docker.yml) [![CI OSes](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-integration-os.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-integration-os.yml) [![Continuous Delivery](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-delivery.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-delivery.yml) [![Coverage](https://github.com/ZcashFoundation/zebra/actions/workflows/coverage.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/coverage.yml) [![codecov](https://codecov.io/gh/ZcashFoundation/zebra/branch/main/graph/badge.svg)](https://codecov.io/gh/ZcashFoundation/zebra) [![Build docs](https://github.com/ZcashFoundation/zebra/actions/workflows/docs.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/docs.yml) [![Build lightwalletd](https://github.com/ZcashFoundation/zebra/actions/workflows/zcash-lightwalletd.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/zcash-lightwalletd.yml) [![Build Zcash Params](https://github.com/ZcashFoundation/zebra/actions/workflows/zcash-params.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/zcash-params.yml)

[![CI Docker](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-integration-docker.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-integration-docker.yml) [![CI OSes](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-integration-os.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-integration-os.yml) [![Continuous Delivery](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-delivery.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/continous-delivery.yml) [![codecov](https://codecov.io/gh/ZcashFoundation/zebra/branch/main/graph/badge.svg)](https://codecov.io/gh/ZcashFoundation/zebra) [![Build docs](https://github.com/ZcashFoundation/zebra/actions/workflows/docs.yml/badge.svg)](https://github.com/ZcashFoundation/zebra/actions/workflows/docs.yml)
![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)

## Contents
Expand Down Expand Up @@ -135,24 +134,22 @@ book for more details.

#### Optional Features

You can also build Zebra with the following [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options):

- `sentry` for [Sentry monitoring](https://zebra.zfnd.org/user/requirements.html#sentry-production-monitoring);
- `filter-reload` for [dynamic tracing](https://zebra.zfnd.org/user/tracing.html#dynamic-tracing)
- `journald` for [`journald` logging](https://zebra.zfnd.org/user/tracing.html#journald-logging).
- `flamegraph` for [generating flamegraphs](https://zebra.zfnd.org/user/tracing.html#flamegraphs).
- `prometheus` for [Prometheus metrics](https://doc.zebra.zfnd.org/zebrad/#metrics).
- `getblocktemplate-rpcs` for [mining support](https://zebra.zfnd.org/user/mining.html).
You can also build Zebra with additional [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options):
- `sentry` for [Sentry monitoring](https://zebra.zfnd.org/user/requirements.html#sentry-production-monitoring)
- `journald` for [`journald` logging](https://zebra.zfnd.org/user/tracing.html#journald-logging)
- `prometheus` for [Prometheus metrics](https://doc.zebra.zfnd.org/zebrad/#metrics)
- `getblocktemplate-rpcs` for [mining support](https://zebra.zfnd.org/user/mining.html)

You can arbitrarily combine the features by listing them as parameters of the `--features` flag:
You can combine multiple features by listing them as parameters of the `--features` flag:

```sh
cargo install --features="<feature1> <feature2> ..." ...
```

The features are also described in [the API
Our full list of experimental and developer features is in [the API
documentation](https://doc.zebra.zfnd.org/zebrad/index.html#zebra-feature-flags).
The debugging and monitoring features are disabled in release builds to increase

Some debugging and monitoring features are disabled in release builds to increase
performance.

### Configuring JSON-RPC for lightwalletd
Expand Down Expand Up @@ -203,16 +200,9 @@ There are a few bugs in Zebra that we're still working on fixing:

## Future Work

Performance and Reliability:

- Reliable syncing under poor network conditions
- Additional batch verification
- Performance tuning

Currently, the following features are out of scope:
The Zebra team is currently working towards an audited stable release.

- Optional Zcash network protocol messages
- Consensus rules removed before Canopy activation (Zebra checkpoints on Canopy activation)
We will continue to add new features as part of future network upgrades, and in response to community feedback.

## Documentation

Expand Down
19 changes: 4 additions & 15 deletions book/src/user/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We've embraced Docker in Zebra for most of the solution lifecycle, from developm

## Quick usage

You can deploy Zebra for a daily use with the images available in [Docker Hub](https://hub.docker.com/repository/docker/zfnd/zebra) or build it locally for testing
You can deploy Zebra for a daily use with the images available in [Docker Hub](https://hub.docker.com/r/zfnd/zebra) or build it locally for testing

### Ready to use image

Expand All @@ -18,27 +18,16 @@ docker run --detach zfnd/zebra:1.0.0-rc.8

```shell
git clone --depth 1 --branch v1.0.0-rc.8 https://github.com/ZcashFoundation/zebra.git
docker build --file docker/Dockerfile --target runtime --tag zebra:local
docker build --file docker/Dockerfile --target runtime --tag zebra:local .
docker run --detach zebra:local
```

### Alternatives

See the Zebra [build instructions](https://github.com/ZcashFoundation/zebra#build-instructions).

## Images

The Zebra team builds multiple images with a single [Dockerfile](https://github.com/ZcashFoundation/zebra/blob/main/docker/Dockerfile) using [multistage builds](https://docs.docker.com/build/building/multi-stage/). The `test` stage adds needed features and tools (like [lightwalletd](https://github.com/adityapk00/lightwalletd)) and the `runtime` stage just adds the _zebrad_ binary and required _zcash-params_ for Zebra to run correctly.

As a result the Zebra team builds four images:

- [zcash-params](us-docker.pkg.dev/zealous-zebra/zebra/zcash-params): built Zcash network parameters
- [lightwalletd](us-docker.pkg.dev/zealous-zebra/zebra/lightwalletd): a backend service that provides an interface to the Zcash blockchain
- [zebrad-test](us-docker.pkg.dev/zealous-zebra/zebra/zebrad-test): a zebrad binary with lightwalletd included, and test suites enabled
- [zebra](https://hub.docker.com/repository/docker/zfnd/zebra): a streamlined version with the zebrad binary and just the needed features needed to run _as-is_
See [Building Zebra](https://github.com/ZcashFoundation/zebra#building-zebra) for more information.

## Registries

The images built by the Zebra team are all publicly hosted. Old image versions meant to be used by our [CI pipeline](https://github.com/ZcashFoundation/zebra/blob/main/.github/workflows/continous-integration-docker.yml) (`zebrad-test`, `lighwalletd`) might be deleted on a scheduled basis.

We use [Docker Hub](https://hub.docker.com/repository/docker/zfnd/zebra) for end-user images and [Google Artifact Registry](https://console.cloud.google.com/artifacts/docker/zealous-zebra/us/zebra) to build external tools and test images
We use [Docker Hub](https://hub.docker.com/r/zfnd/zebra) for end-user images and [Google Artifact Registry](https://console.cloud.google.com/artifacts/docker/zealous-zebra/us/zebra) to build external tools and test images
6 changes: 2 additions & 4 deletions zebra-consensus/src/transaction/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,7 @@ async fn v5_transaction_is_rejected_before_nu5_activation() {
let verifier = Verifier::new(network, state_service);

let transaction = fake_v5_transactions_for_network(network, blocks)
.rev()
.next()
.next_back()
.expect("At least one fake V5 transaction in the test vectors");

let result = verifier
Expand Down Expand Up @@ -918,8 +917,7 @@ fn v5_transaction_is_accepted_after_nu5_activation_for_network(network: Network)
let verifier = Verifier::new(network, state_service);

let mut transaction = fake_v5_transactions_for_network(network, blocks)
.rev()
.next()
.next_back()
.expect("At least one fake V5 transaction in the test vectors");
if transaction
.expiry_height()
Expand Down
6 changes: 2 additions & 4 deletions zebra-network/src/peer_set/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,12 @@ where
/// Checks if the minimum peer version has changed, and disconnects from outdated peers.
fn disconnect_from_outdated_peers(&mut self) {
if let Some(minimum_version) = self.minimum_peer_version.changed() {
let preselected_p2c_peer = &mut self.preselected_p2c_peer;

self.ready_services.retain(|address, peer| {
if peer.remote_version() >= minimum_version {
true
} else {
if *preselected_p2c_peer == Some(*address) {
*preselected_p2c_peer = None;
if self.preselected_p2c_peer == Some(*address) {
self.preselected_p2c_peer = None;
}

false
Expand Down
3 changes: 3 additions & 0 deletions zebra-rpc/src/server/tests/vectors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Fixed test vectors for the RPC server.
// These tests call functions which can take unit arguments if some features aren't enabled.
#![allow(clippy::unit_arg)]

use std::{
net::{Ipv4Addr, SocketAddrV4},
time::Duration,
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/service/non_finalized_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ impl NonFinalizedState {

/// Return the non-finalized portion of the current best chain.
pub fn best_chain(&self) -> Option<&Arc<Chain>> {
self.chain_set.iter().rev().next()
self.chain_iter().next()
}

/// Return the number of chains.
Expand Down
4 changes: 2 additions & 2 deletions zebrad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ num-integer = "0.1.45"
rand = { version = "0.8.5", package = "rand" }

# prod feature sentry
sentry = { version = "0.31.0", default-features = false, features = ["backtrace", "contexts", "reqwest", "rustls", "tracing"], optional = true }
sentry = { version = "0.31.1", default-features = false, features = ["backtrace", "contexts", "reqwest", "rustls", "tracing"], optional = true }

# prod feature flamegraph
tracing-flame = { version = "0.2.0", optional = true }
Expand Down Expand Up @@ -185,7 +185,7 @@ proptest-derive = { version = "0.3.0", optional = true }
console-subscriber = { version = "0.1.8", optional = true }

[build-dependencies]
vergen = { version = "8.1.3", default-features = false, features = ["cargo", "git", "git2", "rustc"] }
vergen = { version = "8.2.0", default-features = false, features = ["cargo", "git", "git2", "rustc"] }

# test feature lightwalletd-grpc-tests
tonic-build = { version = "0.9.2", optional = true }
Expand Down
10 changes: 5 additions & 5 deletions zebrad/src/components/inbound/tests/fake_peer_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::{
gossip_mempool_transaction_id, unmined_transactions_in_blocks, Config as MempoolConfig,
Mempool, MempoolError, SameEffectsChainRejectionError, UnboxMempoolError,
},
sync::{self, BlockGossipError, SyncStatus, TIPS_RESPONSE_TIMEOUT},
sync::{self, BlockGossipError, SyncStatus, PEER_GOSSIP_DELAY},
},
BoxError,
};
Expand Down Expand Up @@ -421,7 +421,7 @@ async fn mempool_transaction_expiration() -> Result<(), crate::BoxError> {
hs.insert(tx1_id);

// Transaction and Block IDs are gossipped, in any order, after waiting for the gossip delay
tokio::time::sleep(TIPS_RESPONSE_TIMEOUT).await;
tokio::time::sleep(PEER_GOSSIP_DELAY).await;
let possible_requests = &mut [
Request::AdvertiseTransactionIds(hs),
Request::AdvertiseBlock(block_two.hash()),
Expand Down Expand Up @@ -490,7 +490,7 @@ async fn mempool_transaction_expiration() -> Result<(), crate::BoxError> {
.unwrap();

// Test the block is gossiped, after waiting for the multi-gossip delay
tokio::time::sleep(TIPS_RESPONSE_TIMEOUT).await;
tokio::time::sleep(PEER_GOSSIP_DELAY).await;
peer_set
.expect_request(Request::AdvertiseBlock(block_three.hash()))
.await
Expand Down Expand Up @@ -567,7 +567,7 @@ async fn mempool_transaction_expiration() -> Result<(), crate::BoxError> {
);

// Test transaction 2 is gossiped, after waiting for the multi-gossip delay
tokio::time::sleep(TIPS_RESPONSE_TIMEOUT).await;
tokio::time::sleep(PEER_GOSSIP_DELAY).await;

let mut hs = HashSet::new();
hs.insert(tx2_id);
Expand Down Expand Up @@ -598,7 +598,7 @@ async fn mempool_transaction_expiration() -> Result<(), crate::BoxError> {
.unwrap();

// Test the block is gossiped, after waiting for the multi-gossip delay
tokio::time::sleep(TIPS_RESPONSE_TIMEOUT).await;
tokio::time::sleep(PEER_GOSSIP_DELAY).await;
peer_set
.expect_request(Request::AdvertiseBlock(block.hash()))
.await
Expand Down
7 changes: 5 additions & 2 deletions zebrad/src/components/mempool/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use zebra_network::MAX_TX_INV_IN_SENT_MESSAGE;

use zebra_network as zn;

use crate::{components::sync::TIPS_RESPONSE_TIMEOUT, BoxError};
use crate::{
components::sync::{PEER_GOSSIP_DELAY, TIPS_RESPONSE_TIMEOUT},
BoxError,
};

/// The maximum number of channel messages we will combine into a single peer broadcast.
pub const MAX_CHANGES_BEFORE_SEND: usize = 10;
Expand Down Expand Up @@ -96,6 +99,6 @@ where
//
// in practice, transactions arrive every 1-20 seconds,
// so waiting 6 seconds can delay transaction propagation, in order to reduce peer load
tokio::time::sleep(TIPS_RESPONSE_TIMEOUT).await;
tokio::time::sleep(PEER_GOSSIP_DELAY).await;
}
}
Loading

0 comments on commit 32d37c7

Please sign in to comment.