Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/cargo/serde-1.0.145
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 26, 2022
2 parents 0c6635d + ec115e9 commit b8d9436
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continous-integration-os.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
# TODO: Windows was removed for now, see https://github.com/ZcashFoundation/zebra/issues/3801
os: [ubuntu-latest, macos-latest]
rust: [stable, beta]
rust: [1.63, beta]
exclude:
- os: macos-latest
rust: beta
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/continous-integration-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ jobs:
matrix:
# TODO: Windows was removed for now, see https://github.com/ZcashFoundation/zebra/issues/3801
os: [ubuntu-latest, macos-latest]
rust: [stable, beta]
# Rust 1.64 hangs when downloading the Zcash Parameters on GitHub Actions runners
rust: [1.63, beta]
exclude:
# TODO: re-enable beta Rust tests on ubuntu (#4929)
- os: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ jobs:

- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
# Rust 1.64 hangs when downloading the Zcash Parameters on GitHub Actions runners
toolchain: 1.63
override: true
profile: minimal
components: llvm-tools-preview
Expand Down
9 changes: 9 additions & 0 deletions book/src/user/supported-platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ ensures that each tier 1 platform builds and passes tests after each change.

For the full requirements, see [Tier 1 platform policy](platform-tier-policy.md#tier-1-platform-policy) in the Platform Tier Policy.

| platform | os | notes | rust | artifacts
| -------|-------|-------|-------|-------
| `x86_64-unknown-linux-gnu` | [Debian 11](https://www.debian.org/releases/bullseye/) | 64-bit | [1.63](https://github.com/rust-lang/rust/releases) | Docker

### Temporarily Unsupported

Zcash parameter downloads currently [hang when built with Rust 1.64 and later](https://github.com/ZcashFoundation/zebra/issues/5091).
Those Rust versions are unsupported until that bug is fixed.

| platform | os | notes | rust | artifacts
| -------|-------|-------|-------|-------
| `x86_64-unknown-linux-gnu` | [Debian 11](https://www.debian.org/releases/bullseye/) | 64-bit | [latest stable release](https://github.com/rust-lang/rust/releases) | Docker
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# - runtime: is our runtime environment
#
# This stage implements cargo-chef for docker layer caching
FROM rust:bullseye as chef
FROM rust:1.63-bullseye as chef
RUN cargo install cargo-chef --locked
WORKDIR /opt/zebrad

Expand Down
2 changes: 1 addition & 1 deletion docker/zcash-params/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This steps implement cargo-chef for docker layer caching
# This image is for caching Zcash Sprout and Sapling parameters
FROM rust:bullseye as chef
FROM rust:1.63-bullseye as chef
RUN cargo install cargo-chef --locked
WORKDIR /opt/zebrad

Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub use request::{FinalizedBlock, HashOrHeight, PreparedBlock, ReadRequest, Requ
pub use response::{ReadResponse, Response};
pub use service::{
chain_tip::{ChainTipChange, LatestChainTip, TipAction},
init, OutputIndex, OutputLocation, TransactionLocation,
init, spawn_init, OutputIndex, OutputLocation, TransactionLocation,
};

#[cfg(any(test, feature = "proptest-impl"))]
Expand Down
15 changes: 15 additions & 0 deletions zebra-state/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,21 @@ pub fn init(
)
}

/// Calls [`init`] with the provided [`Config`] and [`Network`] from a blocking task.
/// Returns a [`tokio::task::JoinHandle`] with a boxed state service,
/// a read state service, and receivers for state chain tip updates.
pub fn spawn_init(
config: Config,
network: Network,
) -> tokio::task::JoinHandle<(
BoxService<Request, Response, BoxError>,
ReadStateService,
LatestChainTip,
ChainTipChange,
)> {
tokio::task::spawn_blocking(move || init(config, network))
}

/// Returns a [`StateService`] with an ephemeral [`Config`] and a buffer with a single slot.
///
/// This can be used to create a state service for testing.
Expand Down
4 changes: 2 additions & 2 deletions zebrad/src/commands/copy_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl CopyStateCmd {
_source_read_only_state_service,
_source_latest_chain_tip,
_source_chain_tip_change,
) = old_zs::init(source_config.clone(), network);
) = old_zs::spawn_init(source_config.clone(), network).await?;

let elapsed = source_start_time.elapsed();
info!(?elapsed, "finished initializing source state service");
Expand All @@ -136,7 +136,7 @@ impl CopyStateCmd {
_target_read_only_state_service,
_target_latest_chain_tip,
_target_chain_tip_change,
) = new_zs::init(target_config.clone(), network);
) = new_zs::spawn_init(target_config.clone(), network).await?;

let elapsed = target_start_time.elapsed();
info!(?elapsed, "finished initializing target state service");
Expand Down
5 changes: 4 additions & 1 deletion zebrad/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ impl StartCmd {
info!(?config);

info!("initializing node state");
info!("opening database, this may take a couple minutes");

let (state_service, read_only_state_service, latest_chain_tip, chain_tip_change) =
zebra_state::init(config.state.clone(), config.network.network);
zebra_state::spawn_init(config.state.clone(), config.network.network).await?;

let state = ServiceBuilder::new()
.buffer(Self::state_buffer_bound())
.service(state_service);
Expand Down
25 changes: 25 additions & 0 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,31 @@ fn start_args() -> Result<()> {
Ok(())
}

#[tokio::test]
async fn db_init_outside_future_executor() -> Result<()> {
use std::time::{Duration, Instant};

let _init_guard = zebra_test::init();
let config = default_test_config()?;

let start = Instant::now();

let db_init_handle = zebra_state::spawn_init(config.state.clone(), config.network.network);

// it's faster to panic if it takes longer than expected, since the executor
// will wait indefinitely for blocking operation to finish once started
let block_duration = start.elapsed();
assert!(
block_duration < Duration::from_millis(5),
"futures executor was blocked longer than expected ({:?})",
block_duration,
);

db_init_handle.await?;

Ok(())
}

#[test]
fn persistent_mode() -> Result<()> {
let _init_guard = zebra_test::init();
Expand Down

0 comments on commit b8d9436

Please sign in to comment.