zebra/zebrad/src/commands/download.rs

36 lines
1.2 KiB
Rust
Raw Normal View History

Download Zcash Sapling parameters and load them from cached files (#3057) * Replace Zcash parameters crates with pre-downloaded local parameter files * Download Zcash parameters using the `zcashd` script in CI and Docker * Add a zcash_proofs dependency to zebra-consensus * Download Sapling parameters using zcash_proofs, rather than fetch-params.sh * Add a new `zebrad download` subcommand This command isn't required for nomrmal usage. But it's useful when testing, or launching multiple Zebra instances. * Use `zebrad download` in CI to pre-download parameters * Log a helpful hint if downloading fails * Allow some duplicate dependencies currently hidden by orchard * Spawn a separate task to download Groth16 parameters * Run the parameter download with code coverage This avoids re-compining Zebra with and without coverage. * Update Cargo.lock after rebase * Try to pass `download` as an argument to `zebrad` in coverage CI * Fix copy and paste comment typos * Add path and download examples, like zcash_proofs * Download params in CI just like zcash_proofs does * Delete a redundant build step * Implement graceful shutdown for zebrad start * Send coverage summary to /dev/null when getting the params path * Use the correct parameters path and download commands in CI * Explain pre-downloads * Avoid calling params_folder twice * Rename parameter types and methods for consistency ```sh fastmod SaplingParams SaplingParameters zebra* fastmod Groth16Params Groth16Parameters zebra* fastmod PARAMS GROTH16_PARAMETERS zebra* fastmod params_folder directory zebra* ``` And a manual variable name tweak. * rustfmt * Remove a redundant coverage step Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
2021-11-19 15:02:56 -08:00
//! `download` subcommand - pre-download required parameter files
//!
//! `zebrad download` automatically downloads required paramter files the first time it is run.
//!
//! This command should be used if you're launching lots of `zebrad start` instances for testing,
//! or you want to include the parameter files in a distribution package.
use abscissa_core::{Command, Options, Runnable};
/// `download` subcommand
#[derive(Command, Debug, Default, Options)]
pub struct DownloadCmd {}
impl DownloadCmd {
/// Download the Sapling and Sprout Groth16 parameters if needed,
/// check they were downloaded correctly, and load them into Zebra.
///
/// # Panics
///
/// If the downloaded or pre-existing parameter files are invalid.
fn download_and_check(&self) {
// The lazy static initializer does the download, if needed,
// and the file hash checks.
lazy_static::initialize(&zebra_consensus::groth16::GROTH16_PARAMETERS);
}
}
impl Runnable for DownloadCmd {
/// Run the download command.
fn run(&self) {
info!("checking if Zcash Sapling and Sprout parameters have been downloaded");
self.download_and_check();
}
}