-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Provide easy prover setup (#2683)
## What ❔ Allow to run `zk_inception prover init` without `chain init` Add docs for running provers and proving the batch. ## Why ❔ To provide easy way to spin up prover subsystem locally. ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`.
- Loading branch information
1 parent
8776875
commit 30edda4
Showing
32 changed files
with
589 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use anyhow::Context as _; | ||
use clap::Args as ClapArgs; | ||
use zksync_basic_types::{ | ||
protocol_version::{ProtocolSemanticVersion, ProtocolVersionId, VersionPatch}, | ||
L1BatchNumber, | ||
}; | ||
use zksync_db_connection::connection_pool::ConnectionPool; | ||
use zksync_prover_dal::{Prover, ProverDal}; | ||
|
||
use crate::cli::ProverCLIConfig; | ||
|
||
#[derive(ClapArgs)] | ||
pub struct Args { | ||
#[clap(short, long)] | ||
pub number: L1BatchNumber, | ||
#[clap(short, long)] | ||
pub version: u16, | ||
#[clap(short, long)] | ||
pub patch: u32, | ||
} | ||
|
||
pub async fn run(args: Args, config: ProverCLIConfig) -> anyhow::Result<()> { | ||
let connection = ConnectionPool::<Prover>::singleton(config.db_url) | ||
.build() | ||
.await | ||
.context("failed to build a prover_connection_pool")?; | ||
let mut conn = connection.connection().await.unwrap(); | ||
|
||
let protocol_version = ProtocolVersionId::try_from(args.version) | ||
.map_err(|_| anyhow::anyhow!("Invalid protocol version"))?; | ||
|
||
let protocol_version_patch = VersionPatch(args.patch); | ||
|
||
conn.fri_witness_generator_dal() | ||
.save_witness_inputs( | ||
args.number, | ||
&format!("witness_inputs_{}", args.number.0), | ||
ProtocolSemanticVersion::new(protocol_version, protocol_version_patch), | ||
) | ||
.await; | ||
|
||
Ok(()) | ||
} |
52 changes: 52 additions & 0 deletions
52
prover/crates/bin/prover_cli/src/commands/insert_version.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use std::str::FromStr; | ||
|
||
use anyhow::Context as _; | ||
use clap::Args as ClapArgs; | ||
use zksync_basic_types::{ | ||
protocol_version::{ | ||
L1VerifierConfig, ProtocolSemanticVersion, ProtocolVersionId, VersionPatch, | ||
}, | ||
H256, | ||
}; | ||
use zksync_db_connection::connection_pool::ConnectionPool; | ||
use zksync_prover_dal::{Prover, ProverDal}; | ||
|
||
use crate::cli::ProverCLIConfig; | ||
|
||
#[derive(ClapArgs)] | ||
pub struct Args { | ||
#[clap(short, long)] | ||
pub version: u16, | ||
#[clap(short, long)] | ||
pub patch: u32, | ||
#[clap(short, long)] | ||
pub snark_wrapper: String, | ||
} | ||
|
||
pub async fn run(args: Args, config: ProverCLIConfig) -> anyhow::Result<()> { | ||
let connection = ConnectionPool::<Prover>::singleton(config.db_url) | ||
.build() | ||
.await | ||
.context("failed to build a prover_connection_pool")?; | ||
let mut conn = connection.connection().await.unwrap(); | ||
|
||
let protocol_version = ProtocolVersionId::try_from(args.version) | ||
.map_err(|_| anyhow::anyhow!("Invalid protocol version"))?; | ||
|
||
let protocol_version_patch = VersionPatch(args.patch); | ||
|
||
let snark_wrapper = H256::from_str(&args.snark_wrapper).unwrap_or_else(|_| { | ||
panic!("Invalid snark wrapper hash"); | ||
}); | ||
|
||
conn.fri_protocol_versions_dal() | ||
.save_prover_protocol_version( | ||
ProtocolSemanticVersion::new(protocol_version, protocol_version_patch), | ||
L1VerifierConfig { | ||
recursion_scheduler_level_vk_hash: snark_wrapper, | ||
}, | ||
) | ||
.await; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.