From 2fa6bf0ffa5d7a5ff62d595a0efeff9dcd9e5a1a Mon Sep 17 00:00:00 2001 From: Artem Fomiuk <88630083+Artemka374@users.noreply.github.com> Date: Tue, 30 Jul 2024 12:14:28 +0300 Subject: [PATCH] feat: Remove unused VKs, add docs for BWG (#2468) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ ## Why ❔ ## Checklist - [ ] 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`. --------- Co-authored-by: EmilLuta --- core/lib/basic_types/src/protocol_version.rs | 1 - core/lib/config/src/configs/genesis.rs | 6 -- core/lib/config/src/testonly.rs | 3 - ...24b83027a8e050598b0cd4cfeb75e7fe89fdd.json | 16 ++++ ...9edd4367018ed40c77d9866899ab15d2abe05.json | 19 ----- ...d36e6c9d9e70dc52677c6b335b3ed4025db85.json | 23 ++++++ ...745d6bb2b76dbd3b366a177ddfc705500fa31.json | 41 ----------- ...d9773d45ef6d548f03d643007d3bc1072526.json} | 22 +----- ...40723143707_remove_redundant_keys.down.sql | 7 ++ ...0240723143707_remove_redundant_keys.up.sql | 7 ++ .../src/models/storage_protocol_version.rs | 16 +--- core/lib/dal/src/protocol_versions_dal.rs | 43 ++--------- core/lib/env_config/src/genesis.rs | 3 - core/lib/protobuf_config/src/genesis.rs | 25 ------- .../src/proto/config/genesis.proto | 4 +- core/lib/types/src/protocol_upgrade.rs | 3 - .../node/api_server/src/web3/namespaces/en.rs | 3 - core/node/eth_sender/src/eth_tx_aggregator.rs | 28 +------ core/node/genesis/src/lib.rs | 12 +-- .../ts-integration/tests/api/web3.test.ts | 5 -- etc/env/file_based/genesis.yaml | 3 - .../bin/prover_cli/src/commands/status/l1.rs | 31 +------- .../src/commitment_utils.rs | 22 +----- prover/crates/bin/witness_generator/README.md | 73 +++++++++++++++++++ ...1fc79400930dddc84e042c5a4dc8a2e8508a5.json | 23 ++++++ ...592895215e22fd4cf0dfe69b83277f8d05db3.json | 38 ---------- ...52e85f85202637916cfcf4b34c6780536f105.json | 16 ++++ ...6997fcfbc7ad688f2eee3dfab1029344d2382.json | 41 ----------- ...f029e262be45614404159908af1624349700b.json | 19 ----- ...7999388451886a3eb9b4481b55404b16b89ac.json | 20 +++++ ...40723153338_remove_redundant_keys.down.sql | 3 + ...0240723153338_remove_redundant_keys.up.sql | 3 + .../src/fri_protocol_versions_dal.rs | 52 ++----------- 33 files changed, 211 insertions(+), 420 deletions(-) create mode 100644 core/lib/dal/.sqlx/query-0d421637db03b83aa33468b7d3424b83027a8e050598b0cd4cfeb75e7fe89fdd.json delete mode 100644 core/lib/dal/.sqlx/query-11eaf115b7409feaf15aaee50839edd4367018ed40c77d9866899ab15d2abe05.json create mode 100644 core/lib/dal/.sqlx/query-d93ebd47a227a6086a5eb963c7ed36e6c9d9e70dc52677c6b335b3ed4025db85.json delete mode 100644 core/lib/dal/.sqlx/query-daed1021023a37f01ba5a1207b1745d6bb2b76dbd3b366a177ddfc705500fa31.json rename core/lib/dal/.sqlx/{query-33b1fbb1e80c3815d30da5854c866d2fe2908a22e933b2f25ce6b4357e51ed9b.json => query-e89e8cc58a2078157d06f3064ccad9773d45ef6d548f03d643007d3bc1072526.json} (54%) create mode 100644 core/lib/dal/migrations/20240723143707_remove_redundant_keys.down.sql create mode 100644 core/lib/dal/migrations/20240723143707_remove_redundant_keys.up.sql create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-4f26bae35dd959448d9728ef7321fc79400930dddc84e042c5a4dc8a2e8508a5.json delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-542af2ff4259182310363ac0213592895215e22fd4cf0dfe69b83277f8d05db3.json create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-5da848354a84b20ae3f0240f6a352e85f85202637916cfcf4b34c6780536f105.json delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-c173743af526d8150b6091ea52e6997fcfbc7ad688f2eee3dfab1029344d2382.json delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-d16278c6025eb3a205266fb5273f029e262be45614404159908af1624349700b.json create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-ed0f22d3d2c8b0d9bd1b4360a0f7999388451886a3eb9b4481b55404b16b89ac.json create mode 100644 prover/crates/lib/prover_dal/migrations/20240723153338_remove_redundant_keys.down.sql create mode 100644 prover/crates/lib/prover_dal/migrations/20240723153338_remove_redundant_keys.up.sql diff --git a/core/lib/basic_types/src/protocol_version.rs b/core/lib/basic_types/src/protocol_version.rs index f0d12436e3b8..d4300fba3f80 100644 --- a/core/lib/basic_types/src/protocol_version.rs +++ b/core/lib/basic_types/src/protocol_version.rs @@ -238,7 +238,6 @@ impl Detokenize for VerifierParams { #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct L1VerifierConfig { - pub params: VerifierParams, pub recursion_scheduler_level_vk_hash: H256, } diff --git a/core/lib/config/src/configs/genesis.rs b/core/lib/config/src/configs/genesis.rs index 0f4d39732f9c..ba3839d66eea 100644 --- a/core/lib/config/src/configs/genesis.rs +++ b/core/lib/config/src/configs/genesis.rs @@ -19,9 +19,6 @@ pub struct GenesisConfig { pub default_aa_hash: Option, 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, @@ -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(), diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs index f3d6b98491be..d21b1ca64387 100644 --- a/core/lib/config/src/testonly.rs +++ b/core/lib/config/src/testonly.rs @@ -704,10 +704,7 @@ impl Distribution 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, diff --git a/core/lib/dal/.sqlx/query-0d421637db03b83aa33468b7d3424b83027a8e050598b0cd4cfeb75e7fe89fdd.json b/core/lib/dal/.sqlx/query-0d421637db03b83aa33468b7d3424b83027a8e050598b0cd4cfeb75e7fe89fdd.json new file mode 100644 index 000000000000..5e10786c7e3f --- /dev/null +++ b/core/lib/dal/.sqlx/query-0d421637db03b83aa33468b7d3424b83027a8e050598b0cd4cfeb75e7fe89fdd.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n protocol_patches (minor, patch, recursion_scheduler_level_vk_hash, created_at)\n VALUES\n ($1, $2, $3, NOW())\n ON CONFLICT DO NOTHING\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Int4", + "Bytea" + ] + }, + "nullable": [] + }, + "hash": "0d421637db03b83aa33468b7d3424b83027a8e050598b0cd4cfeb75e7fe89fdd" +} diff --git a/core/lib/dal/.sqlx/query-11eaf115b7409feaf15aaee50839edd4367018ed40c77d9866899ab15d2abe05.json b/core/lib/dal/.sqlx/query-11eaf115b7409feaf15aaee50839edd4367018ed40c77d9866899ab15d2abe05.json deleted file mode 100644 index fb1be26d15c4..000000000000 --- a/core/lib/dal/.sqlx/query-11eaf115b7409feaf15aaee50839edd4367018ed40c77d9866899ab15d2abe05.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n protocol_patches (\n minor,\n patch,\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash,\n created_at\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, NOW())\n ON CONFLICT DO NOTHING\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int4", - "Int4", - "Bytea", - "Bytea", - "Bytea", - "Bytea" - ] - }, - "nullable": [] - }, - "hash": "11eaf115b7409feaf15aaee50839edd4367018ed40c77d9866899ab15d2abe05" -} diff --git a/core/lib/dal/.sqlx/query-d93ebd47a227a6086a5eb963c7ed36e6c9d9e70dc52677c6b335b3ed4025db85.json b/core/lib/dal/.sqlx/query-d93ebd47a227a6086a5eb963c7ed36e6c9d9e70dc52677c6b335b3ed4025db85.json new file mode 100644 index 000000000000..0fd16adc474d --- /dev/null +++ b/core/lib/dal/.sqlx/query-d93ebd47a227a6086a5eb963c7ed36e6c9d9e70dc52677c6b335b3ed4025db85.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n recursion_scheduler_level_vk_hash\n FROM\n protocol_patches\n WHERE\n minor = $1\n AND patch = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recursion_scheduler_level_vk_hash", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [ + "Int4", + "Int4" + ] + }, + "nullable": [ + false + ] + }, + "hash": "d93ebd47a227a6086a5eb963c7ed36e6c9d9e70dc52677c6b335b3ed4025db85" +} diff --git a/core/lib/dal/.sqlx/query-daed1021023a37f01ba5a1207b1745d6bb2b76dbd3b366a177ddfc705500fa31.json b/core/lib/dal/.sqlx/query-daed1021023a37f01ba5a1207b1745d6bb2b76dbd3b366a177ddfc705500fa31.json deleted file mode 100644 index 00152a612cd9..000000000000 --- a/core/lib/dal/.sqlx/query-daed1021023a37f01ba5a1207b1745d6bb2b76dbd3b366a177ddfc705500fa31.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash\n FROM\n protocol_patches\n WHERE\n minor = $1\n AND patch = $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "recursion_scheduler_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 1, - "name": "recursion_node_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 2, - "name": "recursion_leaf_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 3, - "name": "recursion_circuits_set_vks_hash", - "type_info": "Bytea" - } - ], - "parameters": { - "Left": [ - "Int4", - "Int4" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "daed1021023a37f01ba5a1207b1745d6bb2b76dbd3b366a177ddfc705500fa31" -} diff --git a/core/lib/dal/.sqlx/query-33b1fbb1e80c3815d30da5854c866d2fe2908a22e933b2f25ce6b4357e51ed9b.json b/core/lib/dal/.sqlx/query-e89e8cc58a2078157d06f3064ccad9773d45ef6d548f03d643007d3bc1072526.json similarity index 54% rename from core/lib/dal/.sqlx/query-33b1fbb1e80c3815d30da5854c866d2fe2908a22e933b2f25ce6b4357e51ed9b.json rename to core/lib/dal/.sqlx/query-e89e8cc58a2078157d06f3064ccad9773d45ef6d548f03d643007d3bc1072526.json index bb38503cc353..68b595b50274 100644 --- a/core/lib/dal/.sqlx/query-33b1fbb1e80c3815d30da5854c866d2fe2908a22e933b2f25ce6b4357e51ed9b.json +++ b/core/lib/dal/.sqlx/query-e89e8cc58a2078157d06f3064ccad9773d45ef6d548f03d643007d3bc1072526.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n protocol_versions.id AS \"minor!\",\n protocol_versions.timestamp,\n protocol_versions.bootloader_code_hash,\n protocol_versions.default_account_code_hash,\n protocol_patches.patch,\n protocol_patches.recursion_scheduler_level_vk_hash,\n protocol_patches.recursion_node_level_vk_hash,\n protocol_patches.recursion_leaf_level_vk_hash,\n protocol_patches.recursion_circuits_set_vks_hash\n FROM\n protocol_versions\n JOIN protocol_patches ON protocol_patches.minor = protocol_versions.id\n WHERE\n id = $1\n ORDER BY\n protocol_patches.patch DESC\n LIMIT\n 1\n ", + "query": "\n SELECT\n protocol_versions.id AS \"minor!\",\n protocol_versions.timestamp,\n protocol_versions.bootloader_code_hash,\n protocol_versions.default_account_code_hash,\n protocol_patches.patch,\n protocol_patches.recursion_scheduler_level_vk_hash\n FROM\n protocol_versions\n JOIN protocol_patches ON protocol_patches.minor = protocol_versions.id\n WHERE\n id = $1\n ORDER BY\n protocol_patches.patch DESC\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -32,21 +32,6 @@ "ordinal": 5, "name": "recursion_scheduler_level_vk_hash", "type_info": "Bytea" - }, - { - "ordinal": 6, - "name": "recursion_node_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 7, - "name": "recursion_leaf_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 8, - "name": "recursion_circuits_set_vks_hash", - "type_info": "Bytea" } ], "parameters": { @@ -60,11 +45,8 @@ false, false, false, - false, - false, - false, false ] }, - "hash": "33b1fbb1e80c3815d30da5854c866d2fe2908a22e933b2f25ce6b4357e51ed9b" + "hash": "e89e8cc58a2078157d06f3064ccad9773d45ef6d548f03d643007d3bc1072526" } diff --git a/core/lib/dal/migrations/20240723143707_remove_redundant_keys.down.sql b/core/lib/dal/migrations/20240723143707_remove_redundant_keys.down.sql new file mode 100644 index 000000000000..7e4d329b5c16 --- /dev/null +++ b/core/lib/dal/migrations/20240723143707_remove_redundant_keys.down.sql @@ -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; diff --git a/core/lib/dal/migrations/20240723143707_remove_redundant_keys.up.sql b/core/lib/dal/migrations/20240723143707_remove_redundant_keys.up.sql new file mode 100644 index 000000000000..a0bcb3a65789 --- /dev/null +++ b/core/lib/dal/migrations/20240723143707_remove_redundant_keys.up.sql @@ -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; diff --git a/core/lib/dal/src/models/storage_protocol_version.rs b/core/lib/dal/src/models/storage_protocol_version.rs index 7ac6d70f38c9..c19fa560b67c 100644 --- a/core/lib/dal/src/models/storage_protocol_version.rs +++ b/core/lib/dal/src/models/storage_protocol_version.rs @@ -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, }; @@ -14,9 +14,6 @@ pub struct StorageProtocolVersion { pub patch: i32, pub timestamp: i64, pub recursion_scheduler_level_vk_hash: Vec, - pub recursion_node_level_vk_hash: Vec, - pub recursion_leaf_level_vk_hash: Vec, - pub recursion_circuits_set_vks_hash: Vec, pub bootloader_code_hash: Vec, pub default_account_code_hash: Vec, } @@ -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, ), diff --git a/core/lib/dal/src/protocol_versions_dal.rs b/core/lib/dal/src/protocol_versions_dal.rs index 212be734f0b3..0d17044e6c51 100644 --- a/core/lib/dal/src/protocol_versions_dal.rs +++ b/core/lib/dal/src/protocol_versions_dal.rs @@ -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, }; @@ -71,17 +71,9 @@ 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, @@ -89,18 +81,6 @@ impl ProtocolVersionsDal<'_, '_> { 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) @@ -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 @@ -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 @@ -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, ), diff --git a/core/lib/env_config/src/genesis.rs b/core/lib/env_config/src/genesis.rs index 646ad0dba757..77953c59e9ac 100644 --- a/core/lib/env_config/src/genesis.rs +++ b/core/lib/env_config/src/genesis.rs @@ -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 diff --git a/core/lib/protobuf_config/src/genesis.rs b/core/lib/protobuf_config/src/genesis.rs index 52045ed9dbed..13872d1ab95a 100644 --- a/core/lib/protobuf_config/src/genesis.rs +++ b/core/lib/protobuf_config/src/genesis.rs @@ -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")?, @@ -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( diff --git a/core/lib/protobuf_config/src/proto/config/genesis.proto b/core/lib/protobuf_config/src/proto/config/genesis.proto index be3c420b6ab1..6e679d865d92 100644 --- a/core/lib/protobuf_config/src/proto/config/genesis.proto +++ b/core/lib/protobuf_config/src/proto/config/genesis.proto @@ -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"; } diff --git a/core/lib/types/src/protocol_upgrade.rs b/core/lib/types/src/protocol_upgrade.rs index 674996260204..bc9bd7667e82 100644 --- a/core/lib/types/src/protocol_upgrade.rs +++ b/core/lib/types/src/protocol_upgrade.rs @@ -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), }, diff --git a/core/node/api_server/src/web3/namespaces/en.rs b/core/node/api_server/src/web3/namespaces/en.rs index 5f635b527b9d..17175affa0f6 100644 --- a/core/node/api_server/src/web3/namespaces/en.rs +++ b/core/node/api_server/src/web3/namespaces/en.rs @@ -151,9 +151,6 @@ impl EnNamespace { default_aa_hash: Some(genesis_batch.header.base_system_contracts_hashes.default_aa), l1_chain_id: self.state.api_config.l1_chain_id, l2_chain_id: self.state.api_config.l2_chain_id, - recursion_node_level_vk_hash: verifier_config.params.recursion_node_level_vk_hash, - recursion_leaf_level_vk_hash: verifier_config.params.recursion_leaf_level_vk_hash, - recursion_circuits_set_vks_hash: Default::default(), recursion_scheduler_level_vk_hash: verifier_config.recursion_scheduler_level_vk_hash, fee_account, dummy_verifier: self.state.api_config.dummy_verifier, diff --git a/core/node/eth_sender/src/eth_tx_aggregator.rs b/core/node/eth_sender/src/eth_tx_aggregator.rs index 25d57b8cee39..89533432ef83 100644 --- a/core/node/eth_sender/src/eth_tx_aggregator.rs +++ b/core/node/eth_sender/src/eth_tx_aggregator.rs @@ -18,7 +18,7 @@ use zksync_types::{ eth_sender::{EthTx, EthTxBlobSidecar, EthTxBlobSidecarV1, SidecarBlobV1}, ethabi::{Function, Token}, l2_to_l1_log::UserL2ToL1Log, - protocol_version::{L1VerifierConfig, VerifierParams, PACKED_SEMVER_MINOR_MASK}, + protocol_version::{L1VerifierConfig, PACKED_SEMVER_MINOR_MASK}, pubdata_da::PubdataDA, web3::{contract::Error as Web3ContractError, BlockNumber}, Address, L2ChainId, ProtocolVersionId, H256, U256, @@ -34,9 +34,9 @@ use crate::{ /// Data queried from L1 using multicall contract. #[derive(Debug)] +#[allow(dead_code)] pub struct MulticallData { pub base_system_contracts_hashes: BaseSystemContractsHashes, - pub verifier_params: VerifierParams, pub verifier_address: Address, pub protocol_version_id: ProtocolVersionId, } @@ -264,26 +264,7 @@ impl EthTxAggregator { default_aa, }; - let multicall3_verifier_params = - Multicall3Result::from_token(call_results_iterator.next().unwrap())?.return_data; - if multicall3_verifier_params.len() != 96 { - return Err(EthSenderError::Parse(Web3ContractError::InvalidOutputType( - format!( - "multicall3 verifier params data is not of the len of 96: {:?}", - multicall3_default_aa - ), - ))); - } - let recursion_node_level_vk_hash = H256::from_slice(&multicall3_verifier_params[..32]); - let recursion_leaf_level_vk_hash = - H256::from_slice(&multicall3_verifier_params[32..64]); - let recursion_circuits_set_vks_hash = - H256::from_slice(&multicall3_verifier_params[64..]); - let verifier_params = VerifierParams { - recursion_node_level_vk_hash, - recursion_leaf_level_vk_hash, - recursion_circuits_set_vks_hash, - }; + call_results_iterator.next().unwrap(); let multicall3_verifier_address = Multicall3Result::from_token(call_results_iterator.next().unwrap())?.return_data; @@ -319,7 +300,6 @@ impl EthTxAggregator { return Ok(MulticallData { base_system_contracts_hashes, - verifier_params, verifier_address, protocol_version_id, }); @@ -347,7 +327,6 @@ impl EthTxAggregator { ) -> Result<(), EthSenderError> { let MulticallData { base_system_contracts_hashes, - verifier_params, verifier_address, protocol_version_id, } = self.get_multicall_data().await.map_err(|err| { @@ -364,7 +343,6 @@ impl EthTxAggregator { err })?; let l1_verifier_config = L1VerifierConfig { - params: verifier_params, recursion_scheduler_level_vk_hash, }; if let Some(agg_op) = self diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index a04153a63fc6..7ff811f85343 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -17,7 +17,7 @@ use zksync_types::{ commitment::{CommitmentInput, L1BatchCommitment}, fee_model::BatchFeeInput, protocol_upgrade::decode_set_chain_id_event, - protocol_version::{L1VerifierConfig, ProtocolSemanticVersion, VerifierParams}, + protocol_version::{L1VerifierConfig, ProtocolSemanticVersion}, system_contracts::get_system_smart_contracts, web3::{BlockNumber, FilterBuilder}, AccountTreeId, Address, L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersion, @@ -176,11 +176,6 @@ pub fn mock_genesis_config() -> GenesisConfig { default_aa_hash: Some(base_system_contracts_hashes.default_aa), l1_chain_id: L1ChainId(9), l2_chain_id: L2ChainId::default(), - recursion_node_level_vk_hash: first_l1_verifier_config.params.recursion_node_level_vk_hash, - recursion_leaf_level_vk_hash: first_l1_verifier_config.params.recursion_leaf_level_vk_hash, - recursion_circuits_set_vks_hash: first_l1_verifier_config - .params - .recursion_circuits_set_vks_hash, recursion_scheduler_level_vk_hash: first_l1_verifier_config .recursion_scheduler_level_vk_hash, fee_account: Default::default(), @@ -196,11 +191,6 @@ pub async fn insert_genesis_batch( ) -> Result { let mut transaction = storage.start_transaction().await?; let verifier_config = L1VerifierConfig { - params: VerifierParams { - recursion_node_level_vk_hash: genesis_params.config.recursion_node_level_vk_hash, - recursion_leaf_level_vk_hash: genesis_params.config.recursion_leaf_level_vk_hash, - recursion_circuits_set_vks_hash: H256::zero(), - }, recursion_scheduler_level_vk_hash: genesis_params.config.recursion_scheduler_level_vk_hash, }; diff --git a/core/tests/ts-integration/tests/api/web3.test.ts b/core/tests/ts-integration/tests/api/web3.test.ts index e78ec452b2f5..569321d548ce 100644 --- a/core/tests/ts-integration/tests/api/web3.test.ts +++ b/core/tests/ts-integration/tests/api/web3.test.ts @@ -881,11 +881,6 @@ describe('web3 API compatibility tests', () => { bootloaderCodeHash: expect.stringMatching(HEX_VALUE_REGEX), defaultAccountCodeHash: expect.stringMatching(HEX_VALUE_REGEX), verification_keys_hashes: { - params: { - recursion_circuits_set_vks_hash: expect.stringMatching(HEX_VALUE_REGEX), - recursion_leaf_level_vk_hash: expect.stringMatching(HEX_VALUE_REGEX), - recursion_node_level_vk_hash: expect.stringMatching(HEX_VALUE_REGEX) - }, recursion_scheduler_level_vk_hash: expect.stringMatching(HEX_VALUE_REGEX) }, timestamp: expect.any(Number) diff --git a/etc/env/file_based/genesis.yaml b/etc/env/file_based/genesis.yaml index 4f084648c7ca..6d7a6ba3c338 100644 --- a/etc/env/file_based/genesis.yaml +++ b/etc/env/file_based/genesis.yaml @@ -11,8 +11,5 @@ l2_chain_id: 270 fee_account: '0x0000000000000000000000000000000000000001' prover: recursion_scheduler_level_vk_hash: 0x14f97b81e54b35fe673d8708cc1a19e1ea5b5e348e12d31e39824ed4f42bbca2 - recursion_node_level_vk_hash: 0xf520cd5b37e74e19fdb369c8d676a04dce8a19457497ac6686d2bb95d94109c8 - recursion_leaf_level_vk_hash: 0xf9664f4324c1400fa5c3822d667f30e873f53f1b8033180cd15fe41c1e2355c6 - recursion_circuits_set_vks_hash: '0x0000000000000000000000000000000000000000000000000000000000000000' dummy_verifier: true l1_batch_commit_data_generator_mode: Rollup diff --git a/prover/crates/bin/prover_cli/src/commands/status/l1.rs b/prover/crates/bin/prover_cli/src/commands/status/l1.rs index 128005c309c6..16cecc103828 100644 --- a/prover/crates/bin/prover_cli/src/commands/status/l1.rs +++ b/prover/crates/bin/prover_cli/src/commands/status/l1.rs @@ -1,8 +1,5 @@ use anyhow::Context; -use zksync_basic_types::{ - protocol_version::{L1VerifierConfig, VerifierParams}, - L1BatchNumber, H256, U256, -}; +use zksync_basic_types::{protocol_version::L1VerifierConfig, L1BatchNumber, H256, U256}; use zksync_config::{ configs::{DatabaseSecrets, L1Secrets}, ContractsConfig, PostgresConfig, @@ -80,16 +77,7 @@ pub(crate) async fn run() -> anyhow::Result<()> { .call(&query_client) .await?; - let node_verifier_params: VerifierParams = CallFunctionArgs::new("getVerifierParams", ()) - .for_contract( - contracts_config.diamond_proxy_addr, - &helper::hyperchain_contract(), - ) - .call(&query_client) - .await?; - let node_l1_verifier_config = L1VerifierConfig { - params: node_verifier_params, recursion_scheduler_level_vk_hash: node_verification_key_hash, }; @@ -164,21 +152,4 @@ fn pretty_print_l1_verifier_config( node_l1_verifier_config.recursion_scheduler_level_vk_hash, db_l1_verifier_config.recursion_scheduler_level_vk_hash, ); - print_hash_comparison( - "Verification node", - node_l1_verifier_config.params.recursion_node_level_vk_hash, - db_l1_verifier_config.params.recursion_node_level_vk_hash, - ); - print_hash_comparison( - "Verification leaf", - node_l1_verifier_config.params.recursion_leaf_level_vk_hash, - db_l1_verifier_config.params.recursion_leaf_level_vk_hash, - ); - print_hash_comparison( - "Verification circuits", - node_l1_verifier_config - .params - .recursion_circuits_set_vks_hash, - db_l1_verifier_config.params.recursion_circuits_set_vks_hash, - ); } diff --git a/prover/crates/bin/vk_setup_data_generator_server_fri/src/commitment_utils.rs b/prover/crates/bin/vk_setup_data_generator_server_fri/src/commitment_utils.rs index 471e76e1a680..792efba35adc 100644 --- a/prover/crates/bin/vk_setup_data_generator_server_fri/src/commitment_utils.rs +++ b/prover/crates/bin/vk_setup_data_generator_server_fri/src/commitment_utils.rs @@ -10,10 +10,7 @@ use zksync_prover_fri_types::circuit_definitions::{ boojum::field::goldilocks::GoldilocksField, circuit_definitions::recursion_layer::ZkSyncRecursionLayerStorageType, }; -use zksync_types::{ - protocol_version::{L1VerifierConfig, VerifierParams}, - H256, -}; +use zksync_types::{protocol_version::L1VerifierConfig, H256}; use crate::{ keystore::Keystore, @@ -26,14 +23,6 @@ static KEYSTORE: Lazy>> = Lazy::new(|| Mutex::new(None)); fn circuit_commitments(keystore: &Keystore) -> anyhow::Result { let commitments = generate_commitments(keystore).context("generate_commitments()")?; Ok(L1VerifierConfig { - params: VerifierParams { - recursion_node_level_vk_hash: H256::from_str(&commitments.node) - .context("invalid node commitment")?, - recursion_leaf_level_vk_hash: H256::from_str(&commitments.leaf) - .context("invalid leaf commitment")?, - // The base layer commitment is not used in the FRI prover verification. - recursion_circuits_set_vks_hash: H256::zero(), - }, // Instead of loading the FRI scheduler verification key here, // we load the SNARK-wrapper verification key. // This is due to the fact that these keys are used only for picking the @@ -106,12 +95,3 @@ pub fn get_cached_commitments(setup_data_path: Option) -> L1VerifierConf tracing::info!("Using cached commitments {:?}", commitments); commitments } - -#[test] -fn test_get_cached_commitments() { - let commitments = get_cached_commitments(None); - assert_eq!( - H256::zero(), - commitments.params.recursion_circuits_set_vks_hash - ) -} diff --git a/prover/crates/bin/witness_generator/README.md b/prover/crates/bin/witness_generator/README.md index dc476ca44fc3..a318a4612069 100644 --- a/prover/crates/bin/witness_generator/README.md +++ b/prover/crates/bin/witness_generator/README.md @@ -50,3 +50,76 @@ One round of prover generation consists of: Note that the very first input table (`witness_inputs`) is populated by the tree (as the input artifact for the `WitnessGeneratorJobType::BasicCircuits` is the merkle proofs) + +## Running BWG for custom batch + +After releases `prover-v15.1.0` and `core-v24.9.0` basic witness generator doesn't need access to core database anymore. +Database information now lives in input file, called `witness_inputs_.bin` generated by different core +components). + +This file is stored by prover gateway in GCS (or your choice of object storage -- check config). To access it from GCS +(assuming you have access to the bucket), run: + +```shell +gsutil cp gs://your_bucket/witness_inputs/witness_inputs_.bin +``` + +Note, that you need to have `gsutil` installed, and you need to have access to the bucket. + +Now, database needs to know about the batch and the protocol version it should use. Check the latest protocol version in +the codebase by checking const `PROVER_PROTOCOL_SEMANTIC_VERSION` or run the binary in `prover` workspace: + +```console +cargo run --bin prover_version +``` + +It will give you the latest prover protocol version in a semver format, like `0.24.2`, you need to know only minor and +patch versions. Now, go to the `prover/crates/bin/vk_setup_data_generator_server_fri/data/commitments.json` and get +`snark_wrapper` value from it. Then, you need to insert the info about protocol version into the database. First, +connect to the database, e.g. locally you can do it like that: + +```shell +psql postgres://postgres:notsecurepassword@localhost/prover_local +``` + +And run the following query: + +```shell +INSERT INTO +prover_fri_protocol_versions ( +id, +recursion_scheduler_level_vk_hash, +created_at, +protocol_version_patch +) +VALUES +(, ''::bytea, NOW(), ) +ON CONFLICT (id, protocol_version_patch) DO NOTHING + +``` + +Now, you need to insert the batch into the database. Run the following query: + +```shell +INSERT INTO +witness_inputs_fri ( +l1_batch_number, +witness_inputs_blob_url, +protocol_version, +status, +created_at, +updated_at, +protocol_version_patch +) +VALUES +(, 'witness_inputs_.bin', , 'queued', NOW(), NOW(), ) +ON CONFLICT (l1_batch_number) DO NOTHING +``` + +Finally, run the basic witness generator itself: + +```shell +API_PROMETHEUS_LISTENER_PORT=3116 zk f cargo run --release --bin zksync_witness_generator -- --round=basic_circuits +``` + +And you are good to go! diff --git a/prover/crates/lib/prover_dal/.sqlx/query-4f26bae35dd959448d9728ef7321fc79400930dddc84e042c5a4dc8a2e8508a5.json b/prover/crates/lib/prover_dal/.sqlx/query-4f26bae35dd959448d9728ef7321fc79400930dddc84e042c5a4dc8a2e8508a5.json new file mode 100644 index 000000000000..73cd88457cd1 --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-4f26bae35dd959448d9728ef7321fc79400930dddc84e042c5a4dc8a2e8508a5.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n recursion_scheduler_level_vk_hash\n FROM\n prover_fri_protocol_versions\n WHERE\n id = $1\n AND protocol_version_patch = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recursion_scheduler_level_vk_hash", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [ + "Int4", + "Int4" + ] + }, + "nullable": [ + false + ] + }, + "hash": "4f26bae35dd959448d9728ef7321fc79400930dddc84e042c5a4dc8a2e8508a5" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-542af2ff4259182310363ac0213592895215e22fd4cf0dfe69b83277f8d05db3.json b/prover/crates/lib/prover_dal/.sqlx/query-542af2ff4259182310363ac0213592895215e22fd4cf0dfe69b83277f8d05db3.json deleted file mode 100644 index 4b3c28b9ab71..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-542af2ff4259182310363ac0213592895215e22fd4cf0dfe69b83277f8d05db3.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash\n FROM\n prover_fri_protocol_versions\n ORDER BY\n id DESC\n LIMIT\n 1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "recursion_scheduler_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 1, - "name": "recursion_node_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 2, - "name": "recursion_leaf_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 3, - "name": "recursion_circuits_set_vks_hash", - "type_info": "Bytea" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "542af2ff4259182310363ac0213592895215e22fd4cf0dfe69b83277f8d05db3" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-5da848354a84b20ae3f0240f6a352e85f85202637916cfcf4b34c6780536f105.json b/prover/crates/lib/prover_dal/.sqlx/query-5da848354a84b20ae3f0240f6a352e85f85202637916cfcf4b34c6780536f105.json new file mode 100644 index 000000000000..c985254f247e --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-5da848354a84b20ae3f0240f6a352e85f85202637916cfcf4b34c6780536f105.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n prover_fri_protocol_versions (id, recursion_scheduler_level_vk_hash, created_at, protocol_version_patch)\n VALUES\n ($1, $2, NOW(), $3)\n ON CONFLICT (id, protocol_version_patch) DO NOTHING\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Bytea", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "5da848354a84b20ae3f0240f6a352e85f85202637916cfcf4b34c6780536f105" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-c173743af526d8150b6091ea52e6997fcfbc7ad688f2eee3dfab1029344d2382.json b/prover/crates/lib/prover_dal/.sqlx/query-c173743af526d8150b6091ea52e6997fcfbc7ad688f2eee3dfab1029344d2382.json deleted file mode 100644 index 4f0e7a0062c0..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-c173743af526d8150b6091ea52e6997fcfbc7ad688f2eee3dfab1029344d2382.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash\n FROM\n prover_fri_protocol_versions\n WHERE\n id = $1\n AND protocol_version_patch = $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "recursion_scheduler_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 1, - "name": "recursion_node_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 2, - "name": "recursion_leaf_level_vk_hash", - "type_info": "Bytea" - }, - { - "ordinal": 3, - "name": "recursion_circuits_set_vks_hash", - "type_info": "Bytea" - } - ], - "parameters": { - "Left": [ - "Int4", - "Int4" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "c173743af526d8150b6091ea52e6997fcfbc7ad688f2eee3dfab1029344d2382" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-d16278c6025eb3a205266fb5273f029e262be45614404159908af1624349700b.json b/prover/crates/lib/prover_dal/.sqlx/query-d16278c6025eb3a205266fb5273f029e262be45614404159908af1624349700b.json deleted file mode 100644 index a8158a9defee..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-d16278c6025eb3a205266fb5273f029e262be45614404159908af1624349700b.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n prover_fri_protocol_versions (\n id,\n recursion_scheduler_level_vk_hash,\n recursion_node_level_vk_hash,\n recursion_leaf_level_vk_hash,\n recursion_circuits_set_vks_hash,\n created_at,\n protocol_version_patch\n )\n VALUES\n ($1, $2, $3, $4, $5, NOW(), $6)\n ON CONFLICT (id, protocol_version_patch) DO NOTHING\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int4", - "Bytea", - "Bytea", - "Bytea", - "Bytea", - "Int4" - ] - }, - "nullable": [] - }, - "hash": "d16278c6025eb3a205266fb5273f029e262be45614404159908af1624349700b" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-ed0f22d3d2c8b0d9bd1b4360a0f7999388451886a3eb9b4481b55404b16b89ac.json b/prover/crates/lib/prover_dal/.sqlx/query-ed0f22d3d2c8b0d9bd1b4360a0f7999388451886a3eb9b4481b55404b16b89ac.json new file mode 100644 index 000000000000..d699aae174c7 --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-ed0f22d3d2c8b0d9bd1b4360a0f7999388451886a3eb9b4481b55404b16b89ac.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n recursion_scheduler_level_vk_hash\n FROM\n prover_fri_protocol_versions\n ORDER BY\n id DESC\n LIMIT\n 1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recursion_scheduler_level_vk_hash", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false + ] + }, + "hash": "ed0f22d3d2c8b0d9bd1b4360a0f7999388451886a3eb9b4481b55404b16b89ac" +} diff --git a/prover/crates/lib/prover_dal/migrations/20240723153338_remove_redundant_keys.down.sql b/prover/crates/lib/prover_dal/migrations/20240723153338_remove_redundant_keys.down.sql new file mode 100644 index 000000000000..7895cd2d99c0 --- /dev/null +++ b/prover/crates/lib/prover_dal/migrations/20240723153338_remove_redundant_keys.down.sql @@ -0,0 +1,3 @@ +ALTER TABLE prover_fri_protocol_versions ALTER COLUMN recursion_node_level_vk_hash SET NOT NULL; +ALTER TABLE prover_fri_protocol_versions ALTER COLUMN recursion_leaf_level_vk_hash SET NOT NULL; +ALTER TABLE prover_fri_protocol_versions ALTER COLUMN recursion_circuits_set_vks_hash SET NOT NULL; diff --git a/prover/crates/lib/prover_dal/migrations/20240723153338_remove_redundant_keys.up.sql b/prover/crates/lib/prover_dal/migrations/20240723153338_remove_redundant_keys.up.sql new file mode 100644 index 000000000000..3eccf0b6178c --- /dev/null +++ b/prover/crates/lib/prover_dal/migrations/20240723153338_remove_redundant_keys.up.sql @@ -0,0 +1,3 @@ +ALTER TABLE prover_fri_protocol_versions ALTER COLUMN recursion_node_level_vk_hash DROP NOT NULL; +ALTER TABLE prover_fri_protocol_versions ALTER COLUMN recursion_leaf_level_vk_hash DROP NOT NULL; +ALTER TABLE prover_fri_protocol_versions ALTER COLUMN recursion_circuits_set_vks_hash DROP NOT NULL; diff --git a/prover/crates/lib/prover_dal/src/fri_protocol_versions_dal.rs b/prover/crates/lib/prover_dal/src/fri_protocol_versions_dal.rs index e69d36d1c26c..caf620882bc2 100644 --- a/prover/crates/lib/prover_dal/src/fri_protocol_versions_dal.rs +++ b/prover/crates/lib/prover_dal/src/fri_protocol_versions_dal.rs @@ -1,5 +1,5 @@ use zksync_basic_types::{ - protocol_version::{L1VerifierConfig, ProtocolSemanticVersion, VerifierParams}, + protocol_version::{L1VerifierConfig, ProtocolSemanticVersion}, H256, }; use zksync_db_connection::connection::Connection; @@ -20,35 +20,15 @@ impl FriProtocolVersionsDal<'_, '_> { sqlx::query!( r#" INSERT INTO - prover_fri_protocol_versions ( - id, - recursion_scheduler_level_vk_hash, - recursion_node_level_vk_hash, - recursion_leaf_level_vk_hash, - recursion_circuits_set_vks_hash, - created_at, - protocol_version_patch - ) + prover_fri_protocol_versions (id, recursion_scheduler_level_vk_hash, created_at, protocol_version_patch) VALUES - ($1, $2, $3, $4, $5, NOW(), $6) + ($1, $2, NOW(), $3) ON CONFLICT (id, protocol_version_patch) DO NOTHING "#, id.minor 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(), id.patch.0 as i32 ) .execute(self.storage.conn()) @@ -63,10 +43,7 @@ impl FriProtocolVersionsDal<'_, '_> { 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 prover_fri_protocol_versions WHERE @@ -80,13 +57,6 @@ impl FriProtocolVersionsDal<'_, '_> { .await .unwrap() .map(|row| 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, ), @@ -97,10 +67,7 @@ impl FriProtocolVersionsDal<'_, '_> { let result = 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 prover_fri_protocol_versions ORDER BY @@ -112,16 +79,7 @@ impl FriProtocolVersionsDal<'_, '_> { .fetch_one(self.storage.conn()) .await?; - let params = VerifierParams { - recursion_node_level_vk_hash: H256::from_slice(&result.recursion_node_level_vk_hash), - recursion_leaf_level_vk_hash: H256::from_slice(&result.recursion_leaf_level_vk_hash), - recursion_circuits_set_vks_hash: H256::from_slice( - &result.recursion_circuits_set_vks_hash, - ), - }; - Ok(L1VerifierConfig { - params, recursion_scheduler_level_vk_hash: H256::from_slice( &result.recursion_scheduler_level_vk_hash, ),