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 all 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
20 changes: 19 additions & 1 deletion core/lib/basic_types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ use crate::{
pub const PACKED_SEMVER_MINOR_OFFSET: u32 = 32;
pub const PACKED_SEMVER_MINOR_MASK: u32 = 0xFFFF;

// These values should be manually updated for every protocol upgrade
// Otherwise, the prover will not be able to work with new versions.
// TODO(PLA-954): Move to prover workspace
pub const PROVER_PROTOCOL_VERSION: ProtocolVersionId = ProtocolVersionId::Version24;
pub const PROVER_PROTOCOL_PATCH: VersionPatch = VersionPatch(0);
pub const PROVER_PROTOCOL_SEMANTIC_VERSION: ProtocolSemanticVersion = ProtocolSemanticVersion {
minor: PROVER_PROTOCOL_VERSION,
patch: PROVER_PROTOCOL_PATCH,
};

/// `ProtocolVersionId` is a unique identifier of the protocol version.
/// Note, that it is an identifier of the `minor` semver version of the protocol, with
/// the `major` version being `0`. Also, the protocol version on the contracts may contain
Expand Down Expand Up @@ -76,7 +86,7 @@ impl ProtocolVersionId {
}

pub fn current_prover_version() -> Self {
Self::Version24
PROVER_PROTOCOL_VERSION
}

pub fn next() -> Self {
Expand Down Expand Up @@ -297,6 +307,14 @@ pub struct ProtocolSemanticVersion {
impl ProtocolSemanticVersion {
const MAJOR_VERSION: u8 = 0;

pub fn new(minor: ProtocolVersionId, patch: VersionPatch) -> Self {
Self { minor, patch }
}

pub fn current_prover_version() -> Self {
PROVER_PROTOCOL_SEMANTIC_VERSION
}

pub fn try_from_packed(packed: U256) -> Result<Self, String> {
let minor = ((packed >> U256::from(PACKED_SEMVER_MINOR_OFFSET))
& U256::from(PACKED_SEMVER_MINOR_MASK))
Expand Down
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