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: Remove unused VKs, add docs for BWG #2468

Merged
merged 16 commits into from
Jul 30, 2024
Merged
1 change: 0 additions & 1 deletion core/lib/basic_types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ impl Detokenize for VerifierParams {

#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct L1VerifierConfig {
pub params: VerifierParams,
Artemka374 marked this conversation as resolved.
Show resolved Hide resolved
pub recursion_scheduler_level_vk_hash: H256,
}

Expand Down
6 changes: 0 additions & 6 deletions core/lib/config/src/configs/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ pub struct GenesisConfig {
pub default_aa_hash: Option<H256>,
pub l1_chain_id: L1ChainId,
pub l2_chain_id: L2ChainId,
pub recursion_node_level_vk_hash: H256,
pub recursion_leaf_level_vk_hash: H256,
pub recursion_circuits_set_vks_hash: H256,
pub recursion_scheduler_level_vk_hash: H256,
pub fee_account: Address,
pub dummy_verifier: bool,
Expand All @@ -35,9 +32,6 @@ impl GenesisConfig {
rollup_last_leaf_index: Some(26),
recursion_scheduler_level_vk_hash: H256::repeat_byte(0x02),
fee_account: Default::default(),
recursion_node_level_vk_hash: H256::repeat_byte(0x03),
recursion_leaf_level_vk_hash: H256::repeat_byte(0x04),
recursion_circuits_set_vks_hash: H256::repeat_byte(0x05),
genesis_commitment: Some(H256::repeat_byte(0x17)),
bootloader_hash: Default::default(),
default_aa_hash: Default::default(),
Expand Down
3 changes: 0 additions & 3 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,7 @@ impl Distribution<configs::GenesisConfig> for EncodeDist {
fee_account: rng.gen(),
l1_chain_id: L1ChainId(self.sample(rng)),
l2_chain_id: L2ChainId::default(),
recursion_node_level_vk_hash: rng.gen(),
recursion_leaf_level_vk_hash: rng.gen(),
recursion_scheduler_level_vk_hash: rng.gen(),
recursion_circuits_set_vks_hash: rng.gen(),
dummy_verifier: rng.gen(),
l1_batch_commit_data_generator_mode: match rng.gen_range(0..2) {
0 => L1BatchCommitmentMode::Rollup,
Expand Down

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.

This file was deleted.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE protocol_versions ALTER COLUMN recursion_node_level_vk_hash SET NOT NULL;
ALTER TABLE protocol_versions ALTER COLUMN recursion_leaf_level_vk_hash SET NOT NULL;
ALTER TABLE protocol_versions ALTER COLUMN recursion_circuits_set_vks_hash SET NOT NULL;

ALTER TABLE protocol_patches ALTER COLUMN recursion_node_level_vk_hash SET NOT NULL;
ALTER TABLE protocol_patches ALTER COLUMN recursion_leaf_level_vk_hash SET NOT NULL;
ALTER TABLE protocol_patches ALTER COLUMN recursion_circuits_set_vks_hash SET NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE protocol_versions ALTER COLUMN recursion_node_level_vk_hash DROP NOT NULL;
ALTER TABLE protocol_versions ALTER COLUMN recursion_leaf_level_vk_hash DROP NOT NULL;
ALTER TABLE protocol_versions ALTER COLUMN recursion_circuits_set_vks_hash DROP NOT NULL;

ALTER TABLE protocol_patches ALTER COLUMN recursion_node_level_vk_hash DROP NOT NULL;
ALTER TABLE protocol_patches ALTER COLUMN recursion_leaf_level_vk_hash DROP NOT NULL;
ALTER TABLE protocol_patches ALTER COLUMN recursion_circuits_set_vks_hash DROP NOT NULL;
16 changes: 1 addition & 15 deletions core/lib/dal/src/models/storage_protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use zksync_contracts::BaseSystemContractsHashes;
use zksync_types::{
api,
protocol_upgrade::{self, ProtocolUpgradeTx},
protocol_version::{L1VerifierConfig, ProtocolSemanticVersion, VerifierParams, VersionPatch},
protocol_version::{L1VerifierConfig, ProtocolSemanticVersion, VersionPatch},
H256,
};

Expand All @@ -14,9 +14,6 @@ pub struct StorageProtocolVersion {
pub patch: i32,
pub timestamp: i64,
pub recursion_scheduler_level_vk_hash: Vec<u8>,
pub recursion_node_level_vk_hash: Vec<u8>,
pub recursion_leaf_level_vk_hash: Vec<u8>,
pub recursion_circuits_set_vks_hash: Vec<u8>,
pub bootloader_code_hash: Vec<u8>,
pub default_account_code_hash: Vec<u8>,
}
Expand All @@ -32,17 +29,6 @@ pub(crate) fn protocol_version_from_storage(
},
timestamp: storage_version.timestamp as u64,
l1_verifier_config: L1VerifierConfig {
params: VerifierParams {
recursion_node_level_vk_hash: H256::from_slice(
&storage_version.recursion_node_level_vk_hash,
),
recursion_leaf_level_vk_hash: H256::from_slice(
&storage_version.recursion_leaf_level_vk_hash,
),
recursion_circuits_set_vks_hash: H256::from_slice(
&storage_version.recursion_circuits_set_vks_hash,
),
},
recursion_scheduler_level_vk_hash: H256::from_slice(
&storage_version.recursion_scheduler_level_vk_hash,
),
Expand Down
43 changes: 5 additions & 38 deletions core/lib/dal/src/protocol_versions_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use zksync_db_connection::{
};
use zksync_types::{
protocol_upgrade::{ProtocolUpgradeTx, ProtocolVersion},
protocol_version::{L1VerifierConfig, ProtocolSemanticVersion, VerifierParams, VersionPatch},
protocol_version::{L1VerifierConfig, ProtocolSemanticVersion, VersionPatch},
ProtocolVersionId, H256,
};

Expand Down Expand Up @@ -71,36 +71,16 @@ impl ProtocolVersionsDal<'_, '_> {
sqlx::query!(
r#"
INSERT INTO
protocol_patches (
minor,
patch,
recursion_scheduler_level_vk_hash,
recursion_node_level_vk_hash,
recursion_leaf_level_vk_hash,
recursion_circuits_set_vks_hash,
created_at
)
protocol_patches (minor, patch, recursion_scheduler_level_vk_hash, created_at)
VALUES
($1, $2, $3, $4, $5, $6, NOW())
($1, $2, $3, NOW())
ON CONFLICT DO NOTHING
"#,
version.minor as i32,
version.patch.0 as i32,
l1_verifier_config
.recursion_scheduler_level_vk_hash
.as_bytes(),
l1_verifier_config
.params
.recursion_node_level_vk_hash
.as_bytes(),
l1_verifier_config
.params
.recursion_leaf_level_vk_hash
.as_bytes(),
l1_verifier_config
.params
.recursion_circuits_set_vks_hash
.as_bytes(),
)
.instrument("save_protocol_version#patch")
.with_arg("version", &version)
Expand Down Expand Up @@ -255,10 +235,7 @@ impl ProtocolVersionsDal<'_, '_> {
protocol_versions.bootloader_code_hash,
protocol_versions.default_account_code_hash,
protocol_patches.patch,
protocol_patches.recursion_scheduler_level_vk_hash,
protocol_patches.recursion_node_level_vk_hash,
protocol_patches.recursion_leaf_level_vk_hash,
protocol_patches.recursion_circuits_set_vks_hash
protocol_patches.recursion_scheduler_level_vk_hash
FROM
protocol_versions
JOIN protocol_patches ON protocol_patches.minor = protocol_versions.id
Expand Down Expand Up @@ -291,10 +268,7 @@ impl ProtocolVersionsDal<'_, '_> {
let row = sqlx::query!(
r#"
SELECT
recursion_scheduler_level_vk_hash,
recursion_node_level_vk_hash,
recursion_leaf_level_vk_hash,
recursion_circuits_set_vks_hash
recursion_scheduler_level_vk_hash
FROM
protocol_patches
WHERE
Expand All @@ -308,13 +282,6 @@ impl ProtocolVersionsDal<'_, '_> {
.await
.unwrap()?;
Some(L1VerifierConfig {
params: VerifierParams {
recursion_node_level_vk_hash: H256::from_slice(&row.recursion_node_level_vk_hash),
recursion_leaf_level_vk_hash: H256::from_slice(&row.recursion_leaf_level_vk_hash),
recursion_circuits_set_vks_hash: H256::from_slice(
&row.recursion_circuits_set_vks_hash,
),
},
recursion_scheduler_level_vk_hash: H256::from_slice(
&row.recursion_scheduler_level_vk_hash,
),
Expand Down
3 changes: 0 additions & 3 deletions core/lib/env_config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ impl FromEnv for GenesisConfig {
default_aa_hash: state_keeper.default_aa_hash,
l1_chain_id: network_config.network.chain_id(),
l2_chain_id: network_config.zksync_network_id,
recursion_node_level_vk_hash: contracts_config.fri_recursion_node_level_vk_hash,
recursion_leaf_level_vk_hash: contracts_config.fri_recursion_leaf_level_vk_hash,
recursion_circuits_set_vks_hash: H256::zero(),
recursion_scheduler_level_vk_hash: contracts_config.snark_wrapper_vk_hash,
fee_account: state_keeper
.fee_account_addr
Expand Down
25 changes: 0 additions & 25 deletions core/lib/protobuf_config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,6 @@ impl ProtoRepr for proto::Genesis {
l2_chain_id: required(&self.l2_chain_id)
.and_then(|x| L2ChainId::try_from(*x).map_err(|a| anyhow::anyhow!(a)))
.context("l2_chain_id")?,
recursion_node_level_vk_hash: required(&prover.recursion_node_level_vk_hash)
.and_then(|x| parse_h256(x))
.context("recursion_node_level_vk_hash")?,
recursion_leaf_level_vk_hash: required(&prover.recursion_leaf_level_vk_hash)
.and_then(|x| parse_h256(x))
.context("recursion_leaf_level_vk_hash")?,
recursion_circuits_set_vks_hash: prover
.recursion_circuits_set_vks_hash
.as_ref()
.map(|x| parse_h256(x))
.transpose()
.context("recursion_circuits_set_vks_hash")?
.unwrap_or_default(),
recursion_scheduler_level_vk_hash: required(&prover.recursion_scheduler_level_vk_hash)
.and_then(|x| parse_h256(x))
.context("recursion_scheduler_level_vk_hash")?,
Expand Down Expand Up @@ -120,18 +107,6 @@ impl ProtoRepr for proto::Genesis {
"{:?}",
this.recursion_scheduler_level_vk_hash
)),
recursion_node_level_vk_hash: Some(format!(
"{:?}",
this.recursion_node_level_vk_hash
)),
recursion_leaf_level_vk_hash: Some(format!(
"{:?}",
this.recursion_leaf_level_vk_hash
)),
recursion_circuits_set_vks_hash: Some(format!(
"{:?}",
this.recursion_circuits_set_vks_hash
)),
dummy_verifier: Some(this.dummy_verifier),
}),
l1_batch_commit_data_generator_mode: Some(
Expand Down
4 changes: 1 addition & 3 deletions core/lib/protobuf_config/src/proto/config/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ enum L1BatchCommitDataGeneratorMode {

message Prover {
optional string recursion_scheduler_level_vk_hash = 1; // required; H256
optional string recursion_node_level_vk_hash = 2; // required; H256
optional string recursion_leaf_level_vk_hash = 3; // required; H256
optional string recursion_circuits_set_vks_hash = 4; // required; H256
optional bool dummy_verifier = 5;
reserved 2, 3, 4; reserved "recursion_node_level_vk_hash", "recursion_leaf_level_vk_hash", "recursion_circuits_set_vks_hash";
}


Expand Down
3 changes: 0 additions & 3 deletions core/lib/types/src/protocol_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ impl ProtocolVersion {
version: upgrade.version,
timestamp: upgrade.timestamp,
l1_verifier_config: L1VerifierConfig {
params: upgrade
.verifier_params
.unwrap_or(self.l1_verifier_config.params),
recursion_scheduler_level_vk_hash: new_scheduler_vk_hash
.unwrap_or(self.l1_verifier_config.recursion_scheduler_level_vk_hash),
},
Expand Down
Loading
Loading