Skip to content

Commit

Permalink
remove(cmd): Remove zebrad download command, because it no longer d…
Browse files Browse the repository at this point in the history
…oes anything (#7819)

* Remove the `zebrad download` command

* Reorder command.rs imports

* Remove zcash-params/Dockerfile and the main Dockerfile commands that use it

* Stop building zcash-params Docker images in CI

* Update CHANGELOG for `zebrad download` removal

* Clarify why the image is smaller

Co-authored-by: Marek <[email protected]>

---------

Co-authored-by: Marek <[email protected]>
  • Loading branch information
teor2345 and upbqdn authored Oct 25, 2023
1 parent a126acb commit 71a9865
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 129 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/sub-build-zcash-params.yml

This file was deleted.

10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org).

## [Zebra 1.4.0](https://github.com/ZcashFoundation/zebra/releases/tag/v1.4.0) - TODO: DATE

Zebra's mining RPCs are now available in release builds. TODO: rest of intro
Zebra's mining RPCs are now available in release builds. Our Docker images are significantly smaller,
because the smaller Zcash verification parameters are now built into the `zebrad` binary.
TODO: rest of intro

This release contains the following changes:

Expand All @@ -21,10 +23,12 @@ read our [mining blog post](https://zfnd.org/experimental-mining-support-in-zebr
Please [let us know](https://github.com/ZcashFoundation/zebra/issues/new?assignees=&labels=C-enhancement%2CS-needs-triage&projects=&template=feature_request.yml&title=feature%3A+)
if your mining pool needs extra RPC methods or fields.

### Parameters in Binary
### Zcash Parameters in `zebrad` Binary

`zebrad` now bundles zk-SNARK parameters directly into its binary. This increases the binary size
by a few megabytes, but these parameters do not need to be downloaded or stored separately.
by a few megabytes, but reduces the size of the Docker image by around 600 MB because
the parameters don't contain the Sprout proving key anymore. The `zebrad download`
command does nothing, so it has been removed.

Previously, parameters were stored by default in these locations:

Expand Down
7 changes: 2 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ ENV CARGO_HOME="/opt/zebrad/.cargo/"
# We also download needed dependencies for tests to work, from other images.
# An entrypoint.sh is only available in this step for easier test handling with variables.
FROM deps AS tests
# TODO: do not hardcode the user /root/ even though is a safe assumption
# Pre-download Zcash Sprout, Sapling parameters and Lightwalletd binary
COPY --from=us-docker.pkg.dev/zfnd-dev-zebra/zebra/zcash-params:edge /root/.zcash-params /root/.zcash-params

COPY --from=us-docker.pkg.dev/zfnd-dev-zebra/zebra/lightwalletd:edge /opt/lightwalletd /usr/local/bin

# cargo uses timestamps for its cache, so they need to be in this order:
Expand Down Expand Up @@ -176,11 +174,10 @@ RUN chmod u+x /entrypoint.sh
# This stage is only used when deploying nodes or when only the resulting zebrad binary is needed
#
# To save space, this step starts from scratch using debian, and only adds the resulting
# binary from the `release` stage, and the Zcash Sprout & Sapling parameters from ZCash
# binary from the `release` stage
FROM debian:bullseye-slim AS runtime
COPY --from=release /opt/zebrad/target/release/zebrad /usr/local/bin
COPY --from=release /entrypoint.sh /
COPY --from=us-docker.pkg.dev/zfnd-dev-zebra/zebra/zcash-params:edge /root/.zcash-params /root/.zcash-params

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down
19 changes: 0 additions & 19 deletions docker/zcash-params/Dockerfile

This file was deleted.

37 changes: 15 additions & 22 deletions zebrad/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
//! Zebrad Subcommands

use std::path::PathBuf;

use abscissa_core::{config::Override, Command, Configurable, FrameworkError, Runnable};

use crate::config::ZebradConfig;

pub use self::{entry_point::EntryPoint, start::StartCmd};

use self::{copy_state::CopyStateCmd, generate::GenerateCmd, tip_height::TipHeightCmd};

mod copy_state;
mod download;
mod entry_point;
mod generate;
mod start;
Expand All @@ -10,18 +19,7 @@ mod tip_height;
#[cfg(test)]
mod tests;

use self::ZebradCmd::*;
use self::{
copy_state::CopyStateCmd, download::DownloadCmd, generate::GenerateCmd,
tip_height::TipHeightCmd,
};

pub use self::{entry_point::EntryPoint, start::StartCmd};

use crate::config::ZebradConfig;

use abscissa_core::{config::Override, Command, Configurable, FrameworkError, Runnable};
use std::path::PathBuf;
use ZebradCmd::*;

/// Zebrad Configuration Filename
pub const CONFIG_FILE: &str = "zebrad.toml";
Expand All @@ -33,10 +31,6 @@ pub enum ZebradCmd {
// TODO: hide this command from users in release builds (#3279)
CopyState(CopyStateCmd),

// The `download` subcommand
/// Pre-download required Zcash Sprout and Sapling parameter files
Download(DownloadCmd),

/// Generate a default `zebrad.toml` configuration
Generate(GenerateCmd),

Expand All @@ -60,7 +54,7 @@ impl ZebradCmd {
CopyState(_) | Start(_) => true,

// Utility commands that don't use server components
Download(_) | Generate(_) | TipHeight(_) => false,
Generate(_) | TipHeight(_) => false,
}
}

Expand All @@ -74,14 +68,14 @@ impl ZebradCmd {
Start(_) => true,

// Utility commands
CopyState(_) | Download(_) | Generate(_) | TipHeight(_) => false,
CopyState(_) | Generate(_) | TipHeight(_) => false,
}
}

/// Returns true if this command should ignore errors when
/// attempting to load a config file.
pub(crate) fn should_ignore_load_config_error(&self) -> bool {
matches!(self, ZebradCmd::Generate(_) | ZebradCmd::Download(_))
matches!(self, ZebradCmd::Generate(_))
}

/// Returns the default log level for this command, based on the `verbose` command line flag.
Expand All @@ -96,7 +90,7 @@ impl ZebradCmd {
Generate(_) | TipHeight(_) => true,

// Commands that generate informative logging output by default.
CopyState(_) | Download(_) | Start(_) => false,
CopyState(_) | Start(_) => false,
};

if only_show_warnings && !verbose {
Expand All @@ -113,7 +107,6 @@ impl Runnable for ZebradCmd {
fn run(&self) {
match self {
CopyState(cmd) => cmd.run(),
Download(cmd) => cmd.run(),
Generate(cmd) => cmd.run(),
Start(cmd) => cmd.run(),
TipHeight(cmd) => cmd.run(),
Expand Down
35 changes: 0 additions & 35 deletions zebrad/src/commands/download.rs

This file was deleted.

0 comments on commit 71a9865

Please sign in to comment.