Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update provers to use SemVer #2045

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions core/lib/basic_types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,28 @@ pub struct ProtocolSemanticVersion {

impl ProtocolSemanticVersion {
const MAJOR_VERSION: u8 = 0;

pub fn new(minor: u16, patch: u16) -> Self {
Self {
minor: ProtocolVersionId::try_from(minor).unwrap(),
patch: VkPatch(patch),
}
}

pub fn patch_raw(&self) -> u16 {
self.patch.0
}

pub fn minor_raw(&self) -> u16 {
self.minor as u16
}

pub fn current_prover_version() -> Self {
Self {
minor: ProtocolVersionId::current_prover_version(),
patch: VkPatch(0),
}
}
}

impl fmt::Display for ProtocolSemanticVersion {
Expand Down
4 changes: 2 additions & 2 deletions core/lib/prover_interface/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use serde::{Deserialize, Serialize};
use zksync_types::{
basic_fri_types::Eip4844Blobs,
protocol_version::{L1VerifierConfig, ProtocolVersionId},
protocol_version::{L1VerifierConfig, ProtocolSemanticVersion, ProtocolVersionId},
L1BatchNumber,
};

Expand All @@ -14,7 +14,7 @@ use crate::{inputs::PrepareBasicCircuitsJob, outputs::L1BatchProofForL1};
pub struct ProofGenerationData {
pub l1_batch_number: L1BatchNumber,
pub data: PrepareBasicCircuitsJob,
pub protocol_version_id: ProtocolVersionId,
pub protocol_version: ProtocolSemanticVersion,
pub l1_verifier_config: L1VerifierConfig,
pub eip_4844_blobs: Eip4844Blobs,
}
Expand Down
9 changes: 6 additions & 3 deletions core/lib/prover_interface/src/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ use core::fmt;
use circuit_sequencer_api_1_5_0::proof::FinalProof;
use serde::{Deserialize, Serialize};
use zksync_object_store::{serialize_using_bincode, Bucket, StoredObject};
use zksync_types::L1BatchNumber;
use zksync_types::{protocol_version::ProtocolSemanticVersion, L1BatchNumber};

/// The only type of proof utilized by the core subsystem: a "final" proof that can be sent
/// to the L1 contract.
#[derive(Clone, Serialize, Deserialize)]
pub struct L1BatchProofForL1 {
pub aggregation_result_coords: [[u8; 32]; 4],
pub scheduler_proof: FinalProof,
pub protocol_version: ProtocolSemanticVersion,
}

impl fmt::Debug for L1BatchProofForL1 {
Expand All @@ -24,10 +25,12 @@ impl fmt::Debug for L1BatchProofForL1 {

impl StoredObject for L1BatchProofForL1 {
const BUCKET: Bucket = Bucket::ProofsFri;
type Key<'a> = L1BatchNumber;
type Key<'a> = (L1BatchNumber, ProtocolSemanticVersion);

fn encode_key(key: Self::Key<'_>) -> String {
format!("l1_batch_proof_{key}.bin")
let (l1_batch_number, protocol_version) = key;
let semver_suffix = protocol_version.to_string().replace(".", "_");
format!("l1_batch_proof_{l1_batch_number}_{semver_suffix}.bin")
}

serialize_using_bincode!();
Expand Down
1 change: 1 addition & 0 deletions prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions prover/proof_fri_compressor/src/compressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use zksync_prover_fri_types::{
};
use zksync_prover_interface::outputs::L1BatchProofForL1;
use zksync_queued_job_processor::JobProcessor;
use zksync_types::{L1BatchNumber, ProtocolVersionId};
use zksync_types::{protocol_version::ProtocolSemanticVersion, L1BatchNumber};
use zksync_vk_setup_data_server_fri::keystore::Keystore;

use crate::metrics::METRICS;
Expand All @@ -46,7 +46,7 @@ pub struct ProofCompressor {
compression_mode: u8,
verify_wrapper_proof: bool,
max_attempts: u32,
protocol_version: ProtocolVersionId,
protocol_version: ProtocolSemanticVersion,
}

impl ProofCompressor {
Expand All @@ -56,7 +56,7 @@ impl ProofCompressor {
compression_mode: u8,
verify_wrapper_proof: bool,
max_attempts: u32,
protocol_version: ProtocolVersionId,
protocol_version: ProtocolSemanticVersion,
) -> Self {
Self {
blob_store,
Expand Down Expand Up @@ -166,7 +166,7 @@ impl JobProcessor for ProofCompressor {
let pod_name = get_current_pod_name();
let Some(l1_batch_number) = conn
.fri_proof_compressor_dal()
.get_next_proof_compression_job(&pod_name, &self.protocol_version)
.get_next_proof_compression_job(&pod_name, self.protocol_version)
.await
else {
return Ok(None);
Expand Down Expand Up @@ -243,11 +243,12 @@ impl JobProcessor for ProofCompressor {
let l1_batch_proof = L1BatchProofForL1 {
aggregation_result_coords,
scheduler_proof: artifacts,
protocol_version: self.protocol_version,
};
let blob_save_started_at = Instant::now();
let blob_url = self
.blob_store
.put(job_id, &l1_batch_proof)
.put((job_id, self.protocol_version), &l1_batch_proof)
.await
.context("Failed to save converted l1_batch_proof")?;
METRICS
Expand Down
4 changes: 2 additions & 2 deletions prover/proof_fri_compressor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use zksync_config::configs::{DatabaseSecrets, FriProofCompressorConfig, Observab
use zksync_env_config::{object_store::ProverObjectStoreConfig, FromEnv};
use zksync_object_store::ObjectStoreFactory;
use zksync_queued_job_processor::JobProcessor;
use zksync_types::ProtocolVersionId;
use zksync_types::protocol_version::ProtocolSemanticVersion;
use zksync_utils::wait_for_tasks::ManagedTasks;

use crate::{
Expand Down Expand Up @@ -73,7 +73,7 @@ async fn main() -> anyhow::Result<()> {
.create_store()
.await;

let protocol_version = ProtocolVersionId::current_prover_version();
let protocol_version = ProtocolSemanticVersion::current_prover_version();

let proof_compressor = ProofCompressor::new(
blob_store,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading