From e34b5ba0aec41ba6c864c7bece350455e26c73cc Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Wed, 25 Sep 2024 14:47:26 +0200 Subject: [PATCH 1/9] deny_unknown_fields:false --- Cargo.lock | 54 +----- Cargo.toml | 20 +- core/bin/block_reverter/src/main.rs | 43 ++--- core/bin/external_node/src/config/mod.rs | 16 +- core/bin/genesis_generator/src/main.rs | 12 +- core/bin/zksync_server/src/config.rs | 8 +- core/bin/zksync_server/src/main.rs | 38 +--- ...31867b3c0bff34bbacbc31ff4cd786c97ca90.json | 12 -- ...5bf6d0bc603a83cbd5b88a537cbbedee36e32.json | 12 ++ ...29bf769829991c7d732b13f96bcd1293263ea.json | 12 -- ...5663d11c17165a387056bfb48923a35d3909d.json | 12 ++ core/lib/dal/src/consensus_dal.rs | 129 ++++++++----- core/lib/protobuf_config/src/lib.rs | 5 +- .../src/temp_config_store/mod.rs | 24 ++- .../node/api_server/src/web3/namespaces/en.rs | 12 +- core/node/consensus/src/en.rs | 18 +- core/node/consensus/src/tests/attestation.rs | 7 +- prover/Cargo.lock | 54 ++---- .../crates/lib/prover_dal/src/cli_test_dal.rs | 99 +++++----- .../lib/prover_dal/src/fri_prover_dal.rs | 10 +- .../src/fri_witness_generator_dal.rs | 15 +- zk_toolbox/Cargo.lock | 181 +++++++----------- zk_toolbox/Cargo.toml | 6 +- 23 files changed, 366 insertions(+), 433 deletions(-) delete mode 100644 core/lib/dal/.sqlx/query-3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90.json create mode 100644 core/lib/dal/.sqlx/query-7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32.json delete mode 100644 core/lib/dal/.sqlx/query-7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea.json create mode 100644 core/lib/dal/.sqlx/query-bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d.json diff --git a/Cargo.lock b/Cargo.lock index 50f0784d9fa2..0f8fd55bd6a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2319,18 +2319,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ff_ce" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b538e4231443a5b9c507caee3356f016d832cf7393d2d90f03ea3180d4e3fbc" -dependencies = [ - "byteorder", - "hex", - "rand 0.4.6", - "serde", -] - [[package]] name = "fiat-crypto" version = "0.2.3" @@ -9316,9 +9304,7 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c8cf6c689ab5922b52d81b775cd2d9cffbfc8fb8da65985e11b06546dfb3bf" +version = "0.2.0" dependencies = [ "anyhow", "once_cell", @@ -9353,9 +9339,7 @@ dependencies = [ [[package]] name = "zksync_consensus_bft" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c409ae915056cf9cadd9304dbc8718fa38edfcb346d06e5b3582dcd2489ef9" +version = "0.2.0" dependencies = [ "anyhow", "async-trait", @@ -9375,20 +9359,16 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7baced4e811015038322dad10239f2d631d9e339e8d6b7b6e6b146bee30f41" +version = "0.2.0" dependencies = [ "anyhow", "blst", "ed25519-dalek", "elliptic-curve 0.13.8", - "ff_ce", "hex", "k256 0.13.3", "num-bigint 0.4.6", "num-traits", - "rand 0.4.6", "rand 0.8.5", "sha3 0.10.8", "thiserror", @@ -9398,9 +9378,7 @@ dependencies = [ [[package]] name = "zksync_consensus_executor" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b018b8a76fc2cbecb51683ce97532501c45d44cbc8bb856d1956e5998259335" +version = "0.2.0" dependencies = [ "anyhow", "async-trait", @@ -9420,9 +9398,7 @@ dependencies = [ [[package]] name = "zksync_consensus_network" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5bb2988e41af3083cebfc11f47f2615adae8d829bf9237aa084dede9629a687" +version = "0.2.0" dependencies = [ "anyhow", "async-trait", @@ -9456,9 +9432,7 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aab4ddf62f6001903c5fe9f65afb1bdc42464928c9d1c6ce52e4d7e9944f5dc" +version = "0.2.0" dependencies = [ "anyhow", "bit-vec", @@ -9478,9 +9452,7 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b9dbcb923fa201af03f49f70c11a923b416915d2ddf8b2de3a2e861f22898a4" +version = "0.2.0" dependencies = [ "anyhow", "async-trait", @@ -9498,9 +9470,7 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e69dffc0fbc7c096548c997f5ca157a490b34b3d49fd524fa3d51840f7fb22" +version = "0.2.0" dependencies = [ "anyhow", "rand 0.8.5", @@ -10528,9 +10498,7 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5467dfe2f845ca1fd6ceec623bbd32187589793d3c4023dcd2f5172369d198" +version = "0.2.0" dependencies = [ "anyhow", "bit-vec", @@ -10549,9 +10517,7 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d35280660b11be2a4ebdf531184eb729acebfdc3368d27176ec104f8bf9c5f" +version = "0.2.0" dependencies = [ "anyhow", "heck 0.5.0", diff --git a/Cargo.toml b/Cargo.toml index 5a8a507b0340..d1e02092ec5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -230,16 +230,16 @@ zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.5" } zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "74577d9be13b1bff9d1a712389731f669b179e47" } # Consensus dependencies. -zksync_concurrency = "=0.1.1" -zksync_consensus_bft = "=0.1.1" -zksync_consensus_crypto = "=0.1.1" -zksync_consensus_executor = "=0.1.1" -zksync_consensus_network = "=0.1.1" -zksync_consensus_roles = "=0.1.1" -zksync_consensus_storage = "=0.1.1" -zksync_consensus_utils = "=0.1.1" -zksync_protobuf = "=0.1.1" -zksync_protobuf_build = "=0.1.1" +zksync_concurrency = "=0.2.0" +zksync_consensus_bft = "=0.2.0" +zksync_consensus_crypto = "=0.2.0" +zksync_consensus_executor = "=0.2.0" +zksync_consensus_network = "=0.2.0" +zksync_consensus_roles = "=0.2.0" +zksync_consensus_storage = "=0.2.0" +zksync_consensus_utils = "=0.2.0" +zksync_protobuf = "=0.2.0" +zksync_protobuf_build = "=0.2.0" # "Local" dependencies zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" } diff --git a/core/bin/block_reverter/src/main.rs b/core/bin/block_reverter/src/main.rs index 65810a6e9b67..64f3a4825e80 100644 --- a/core/bin/block_reverter/src/main.rs +++ b/core/bin/block_reverter/src/main.rs @@ -20,7 +20,7 @@ use zksync_config::{ }, ContractsConfig, DBConfig, EthConfig, GenesisConfig, PostgresConfig, }; -use zksync_core_leftovers::temp_config_store::decode_yaml_repr; +use zksync_core_leftovers::temp_config_store::read_yaml_repr; use zksync_dal::{ConnectionPool, Core}; use zksync_env_config::{object_store::SnapshotsObjectStoreConfig, FromEnv}; use zksync_object_store::ObjectStoreFactory; @@ -127,27 +127,26 @@ async fn main() -> anyhow::Result<()> { .build(); let general_config: Option = if let Some(path) = opts.config_path { - let yaml = std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - let config = - decode_yaml_repr::(&yaml) - .context("failed decoding general YAML config")?; - Some(config) + Some( + read_yaml_repr::(&path) + .context("failed decoding general YAML config")?, + ) } else { None }; let wallets_config: Option = if let Some(path) = opts.wallets_path { - let yaml = std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - let config = decode_yaml_repr::(&yaml) - .context("failed decoding wallets YAML config")?; - Some(config) + Some( + read_yaml_repr::(&path) + .context("failed decoding wallets YAML config")?, + ) } else { None }; let genesis_config: Option = if let Some(path) = opts.genesis_path { - let yaml = std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - let config = decode_yaml_repr::(&yaml) - .context("failed decoding genesis YAML config")?; - Some(config) + Some( + read_yaml_repr::(&path) + .context("failed decoding genesis YAML config")?, + ) } else { None }; @@ -183,19 +182,15 @@ async fn main() -> anyhow::Result<()> { .context("BasicWitnessInputProducerConfig::from_env()")?, }; let contracts = match opts.contracts_config_path { - Some(path) => { - let yaml = - std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - decode_yaml_repr::(&yaml) - .context("failed decoding contracts YAML config")? - } + Some(path) => read_yaml_repr::(&path) + .context("failed decoding contracts YAML config")?, None => ContractsConfig::from_env().context("ContractsConfig::from_env()")?, }; let secrets_config = if let Some(path) = opts.secrets_path { - let yaml = std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - let config = decode_yaml_repr::(&yaml) - .context("failed decoding secrets YAML config")?; - Some(config) + Some( + read_yaml_repr::(&path) + .context("failed decoding secrets YAML config")?, + ) } else { None }; diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs index f8241deae26c..8b7f127d77d8 100644 --- a/core/bin/external_node/src/config/mod.rs +++ b/core/bin/external_node/src/config/mod.rs @@ -19,7 +19,7 @@ use zksync_config::{ }; use zksync_consensus_crypto::TextFmt; use zksync_consensus_roles as roles; -use zksync_core_leftovers::temp_config_store::{decode_yaml_repr, read_yaml_repr}; +use zksync_core_leftovers::temp_config_store::read_yaml_repr; #[cfg(test)] use zksync_dal::{ConnectionPool, Core}; use zksync_metadata_calculator::MetadataCalculatorRecoveryConfig; @@ -1149,9 +1149,8 @@ pub(crate) fn read_consensus_secrets() -> anyhow::Result(&cfg) + read_yaml_repr::(&path.into()) .context("failed decoding YAML")?, )) } @@ -1160,9 +1159,8 @@ pub(crate) fn read_consensus_config() -> anyhow::Result> let Ok(path) = env::var("EN_CONSENSUS_CONFIG_PATH") else { return Ok(None); }; - let cfg = std::fs::read_to_string(&path).context(path)?; Ok(Some( - decode_yaml_repr::(&cfg).context("failed decoding YAML")?, + read_yaml_repr::(&path.into()).context("failed decoding YAML")?, )) } @@ -1253,16 +1251,16 @@ impl ExternalNodeConfig<()> { secrets_configs_path: PathBuf, consensus_config_path: Option, ) -> anyhow::Result { - let general_config = read_yaml_repr::(general_config_path) + let general_config = read_yaml_repr::(&general_config_path) .context("failed decoding general YAML config")?; let external_node_config = - read_yaml_repr::(external_node_config_path) + read_yaml_repr::(&external_node_config_path) .context("failed decoding external node YAML config")?; - let secrets_config = read_yaml_repr::(secrets_configs_path) + let secrets_config = read_yaml_repr::(&secrets_configs_path) .context("failed decoding secrets YAML config")?; let consensus = consensus_config_path - .map(read_yaml_repr::) + .map(|path| read_yaml_repr::(&path.into())) .transpose() .context("failed decoding consensus YAML config")?; let consensus_secrets = secrets_config.consensus.clone(); diff --git a/core/bin/genesis_generator/src/main.rs b/core/bin/genesis_generator/src/main.rs index abdd6091ed73..4f8200b3af78 100644 --- a/core/bin/genesis_generator/src/main.rs +++ b/core/bin/genesis_generator/src/main.rs @@ -9,7 +9,7 @@ use clap::Parser; use serde_yaml::Serializer; use zksync_config::{configs::DatabaseSecrets, GenesisConfig}; use zksync_contracts::BaseSystemContracts; -use zksync_core_leftovers::temp_config_store::decode_yaml_repr; +use zksync_core_leftovers::temp_config_store::read_yaml_repr; use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_env_config::FromEnv; use zksync_node_genesis::{insert_genesis_batch, GenesisParams}; @@ -40,17 +40,13 @@ async fn main() -> anyhow::Result<()> { let database_secrets = match opt.config_path { None => DatabaseSecrets::from_env()?, Some(path) => { - let yaml = - std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - let config = decode_yaml_repr::(&yaml) - .context("failed decoding general YAML config")?; + let config = read_yaml_repr::(&path) + .context("failed decoding secrets YAML")?; config.database.context("Database secrets must exist")? } }; - let yaml = std::fs::read_to_string(DEFAULT_GENESIS_FILE_PATH) - .with_context(|| DEFAULT_GENESIS_FILE_PATH.to_string())?; - let original_genesis = decode_yaml_repr::(&yaml)?; + let original_genesis = read_yaml_repr::(&DEFAULT_GENESIS_FILE_PATH.into())?; let db_url = database_secrets.master_url()?; let new_genesis = generate_new_config(db_url, original_genesis.clone()).await?; if opt.check { diff --git a/core/bin/zksync_server/src/config.rs b/core/bin/zksync_server/src/config.rs index 8c865b61d5be..c55cc7796348 100644 --- a/core/bin/zksync_server/src/config.rs +++ b/core/bin/zksync_server/src/config.rs @@ -1,6 +1,6 @@ use anyhow::Context as _; use zksync_config::configs::consensus::{ConsensusConfig, ConsensusSecrets}; -use zksync_core_leftovers::temp_config_store::decode_yaml_repr; +use zksync_core_leftovers::temp_config_store::read_yaml_repr; use zksync_protobuf_config::proto; pub(crate) fn read_consensus_secrets() -> anyhow::Result> { @@ -8,9 +8,8 @@ pub(crate) fn read_consensus_secrets() -> anyhow::Result(&secrets) + read_yaml_repr::(&path.into()) .context("failed decoding YAML")?, )) } @@ -20,8 +19,7 @@ pub(crate) fn read_consensus_config() -> anyhow::Result> let Ok(path) = std::env::var("CONSENSUS_CONFIG_PATH") else { return Ok(None); }; - let cfg = std::fs::read_to_string(&path).context(path)?; Ok(Some( - decode_yaml_repr::(&cfg).context("failed decoding YAML")?, + read_yaml_repr::(&path.into()).context("failed decoding YAML")?, )) } diff --git a/core/bin/zksync_server/src/main.rs b/core/bin/zksync_server/src/main.rs index 84898d6da067..d15c8265215e 100644 --- a/core/bin/zksync_server/src/main.rs +++ b/core/bin/zksync_server/src/main.rs @@ -22,7 +22,7 @@ use zksync_config::{ GenesisConfig, ObjectStoreConfig, PostgresConfig, SnapshotsCreatorConfig, }; use zksync_core_leftovers::{ - temp_config_store::{decode_yaml_repr, TempConfigStore}, + temp_config_store::{read_yaml_repr, TempConfigStore}, Component, Components, }; use zksync_env_config::FromEnv; @@ -98,30 +98,20 @@ fn main() -> anyhow::Result<()> { configs } Some(path) => { - let yaml = - std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - decode_yaml_repr::(&yaml) + read_yaml_repr::(&path) .context("failed decoding general YAML config")? } }; let wallets = match opt.wallets_path { None => tmp_config.wallets(), - Some(path) => { - let yaml = - std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - decode_yaml_repr::(&yaml) - .context("failed decoding wallets YAML config")? - } + Some(path) => read_yaml_repr::(&path) + .context("failed decoding wallets YAML config")?, }; let secrets: Secrets = match opt.secrets_path { - Some(path) => { - let yaml = - std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - decode_yaml_repr::(&yaml) - .context("failed decoding secrets YAML config")? - } + Some(path) => read_yaml_repr::(&path) + .context("failed decoding secrets YAML config")?, None => Secrets { consensus: config::read_consensus_secrets().context("read_consensus_secrets()")?, database: DatabaseSecrets::from_env().ok(), @@ -131,22 +121,14 @@ fn main() -> anyhow::Result<()> { let contracts_config = match opt.contracts_config_path { None => ContractsConfig::from_env().context("contracts_config")?, - Some(path) => { - let yaml = - std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - decode_yaml_repr::(&yaml) - .context("failed decoding contracts YAML config")? - } + Some(path) => read_yaml_repr::(&path) + .context("failed decoding contracts YAML config")?, }; let genesis = match opt.genesis_path { None => GenesisConfig::from_env().context("Genesis config")?, - Some(path) => { - let yaml = - std::fs::read_to_string(&path).with_context(|| path.display().to_string())?; - decode_yaml_repr::(&yaml) - .context("failed decoding genesis YAML config")? - } + Some(path) => read_yaml_repr::(&path) + .context("failed decoding genesis YAML config")?, }; let observability_config = configs .observability diff --git a/core/lib/dal/.sqlx/query-3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90.json b/core/lib/dal/.sqlx/query-3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90.json deleted file mode 100644 index 72d008c11475..000000000000 --- a/core/lib/dal/.sqlx/query-3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n DELETE FROM l1_batches_consensus\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [] - }, - "nullable": [] - }, - "hash": "3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90" -} diff --git a/core/lib/dal/.sqlx/query-7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32.json b/core/lib/dal/.sqlx/query-7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32.json new file mode 100644 index 000000000000..5414d71c5257 --- /dev/null +++ b/core/lib/dal/.sqlx/query-7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE FROM miniblocks_consensus\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32" +} diff --git a/core/lib/dal/.sqlx/query-7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea.json b/core/lib/dal/.sqlx/query-7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea.json deleted file mode 100644 index 80d855d8d21a..000000000000 --- a/core/lib/dal/.sqlx/query-7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n DELETE FROM miniblocks_consensus\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [] - }, - "nullable": [] - }, - "hash": "7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea" -} diff --git a/core/lib/dal/.sqlx/query-bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d.json b/core/lib/dal/.sqlx/query-bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d.json new file mode 100644 index 000000000000..759189a26d74 --- /dev/null +++ b/core/lib/dal/.sqlx/query-bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE FROM l1_batches_consensus\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d" +} diff --git a/core/lib/dal/src/consensus_dal.rs b/core/lib/dal/src/consensus_dal.rs index 711ce3ddf392..0526be133b14 100644 --- a/core/lib/dal/src/consensus_dal.rs +++ b/core/lib/dal/src/consensus_dal.rs @@ -6,7 +6,6 @@ use zksync_db_connection::{ error::{DalError, DalResult, SqlxContext}, instrument::{InstrumentExt, Instrumented}, }; -use zksync_protobuf::ProtoRepr as _; use zksync_types::L2BlockNumber; pub use crate::consensus::{proto, AttestationStatus, GlobalConfig, Payload}; @@ -55,14 +54,14 @@ impl ConsensusDal<'_, '_> { else { return Ok(None); }; + let d = zksync_protobuf::serde::Deserialize { + deny_unknown_fields: true, + }; if let Some(global_config) = row.global_config { - return Ok(Some( - zksync_protobuf::serde::deserialize(&global_config).context("global_config")?, - )); + return Ok(Some(d.proto_fmt(&global_config).context("global_config")?)); } if let Some(genesis) = row.genesis { - let genesis: validator::Genesis = - zksync_protobuf::serde::deserialize(&genesis).context("genesis")?; + let genesis: validator::Genesis = d.proto_fmt(&genesis).context("genesis")?; return Ok(Some(GlobalConfig { genesis, registry_address: None, @@ -80,9 +79,10 @@ impl ConsensusDal<'_, '_> { /// Resets the stored consensus state otherwise and purges all certificates. pub async fn try_update_global_config(&mut self, want: &GlobalConfig) -> anyhow::Result<()> { let mut txn = self.storage.start_transaction().await?; - if let Some(got) = txn.consensus_dal().global_config().await? { - // Exit if the genesis didn't change. - if &got == want { + let got = txn.consensus_dal().global_config().await?; + if let Some(got) = &got { + // Exit if the global config didn't change. + if got == want { return Ok(()); } anyhow::ensure!( @@ -92,39 +92,40 @@ impl ConsensusDal<'_, '_> { want.genesis.chain_id, ); anyhow::ensure!( - got.genesis.fork_number < want.genesis.fork_number, + got.genesis.fork_number <= want.genesis.fork_number, "transition to a past fork is not allowed: old = {:?}, new = {:?}", got.genesis.fork_number, want.genesis.fork_number, ); want.genesis.verify().context("genesis.verify()")?; } - let genesis = - zksync_protobuf::serde::serialize(&want.genesis, serde_json::value::Serializer) - .unwrap(); - let global_config = - zksync_protobuf::serde::serialize(want, serde_json::value::Serializer).unwrap(); - let state = zksync_protobuf::serde::serialize( - &ReplicaState::default(), - serde_json::value::Serializer, - ) - .unwrap(); - sqlx::query!( - r#" - DELETE FROM l1_batches_consensus - "# - ) - .instrument("try_update_genesis#DELETE FROM l1_batches_consensus") - .execute(&mut txn) - .await?; - sqlx::query!( - r#" - DELETE FROM miniblocks_consensus - "# - ) - .instrument("try_update_genesis#DELETE FROM miniblock_consensus") - .execute(&mut txn) - .await?; + let s = zksync_protobuf::serde::Serialize; + let genesis = s + .proto_fmt(&want.genesis, serde_json::value::Serializer) + .unwrap(); + let global_config = s.proto_fmt(want, serde_json::value::Serializer).unwrap(); + let state = s + .proto_fmt(&ReplicaState::default(), serde_json::value::Serializer) + .unwrap(); + if got.as_ref().map(|c| &c.genesis) != Some(&want.genesis) { + tracing::info!("consensus genesis changed, wiping consensus certificates"); + sqlx::query!( + r#" + DELETE FROM l1_batches_consensus + "# + ) + .instrument("try_update_genesis#DELETE FROM l1_batches_consensus") + .execute(&mut txn) + .await?; + sqlx::query!( + r#" + DELETE FROM miniblocks_consensus + "# + ) + .instrument("try_update_genesis#DELETE FROM miniblock_consensus") + .execute(&mut txn) + .await?; + } sqlx::query!( r#" DELETE FROM consensus_replica_state @@ -204,7 +205,13 @@ impl ConsensusDal<'_, '_> { fake_key "# ) - .try_map(|row| zksync_protobuf::serde::deserialize(row.state).decode_column("state")) + .try_map(|row| { + zksync_protobuf::serde::Deserialize { + deny_unknown_fields: true, + } + .proto_fmt(row.state) + .decode_column("state") + }) .instrument("replica_state") .fetch_one(self.storage) .await @@ -212,8 +219,9 @@ impl ConsensusDal<'_, '_> { /// Sets the current BFT replica state. pub async fn set_replica_state(&mut self, state: &ReplicaState) -> DalResult<()> { - let state_json = - zksync_protobuf::serde::serialize(state, serde_json::value::Serializer).unwrap(); + let state_json = zksync_protobuf::serde::Serialize + .proto_fmt(state, serde_json::value::Serializer) + .unwrap(); sqlx::query!( r#" UPDATE consensus_replica_state @@ -303,7 +311,12 @@ impl ConsensusDal<'_, '_> { Ok(BlockStoreState { first: start, last: row - .map(|row| zksync_protobuf::serde::deserialize(row.certificate)) + .map(|row| { + zksync_protobuf::serde::Deserialize { + deny_unknown_fields: true, + } + .proto_fmt(row.certificate) + }) .transpose()?, }) } @@ -331,7 +344,12 @@ impl ConsensusDal<'_, '_> { else { return Ok(None); }; - Ok(Some(zksync_protobuf::serde::deserialize(row.certificate)?)) + Ok(Some( + zksync_protobuf::serde::Deserialize { + deny_unknown_fields: true, + } + .proto_fmt(row.certificate)?, + )) } /// Fetches the attester certificate for the L1 batch with the given `batch_number`. @@ -357,7 +375,12 @@ impl ConsensusDal<'_, '_> { else { return Ok(None); }; - Ok(Some(zksync_protobuf::serde::deserialize(row.certificate)?)) + Ok(Some( + zksync_protobuf::serde::Deserialize { + deny_unknown_fields: true, + } + .proto_fmt(row.certificate)?, + )) } /// Fetches a range of L2 blocks from storage and converts them to `Payload`s. @@ -433,7 +456,9 @@ impl ConsensusDal<'_, '_> { ($1, $2) "#, i64::try_from(header.number.0).context("overflow")?, - zksync_protobuf::serde::serialize(cert, serde_json::value::Serializer).unwrap(), + zksync_protobuf::serde::Serialize + .proto_fmt(cert, serde_json::value::Serializer) + .unwrap(), ) .instrument("insert_block_certificate") .report_latency() @@ -448,10 +473,9 @@ impl ConsensusDal<'_, '_> { number: attester::BatchNumber, committee: &attester::Committee, ) -> anyhow::Result<()> { - let committee = proto::AttesterCommittee::build(committee); - let committee = - zksync_protobuf::serde::serialize_proto(&committee, serde_json::value::Serializer) - .unwrap(); + let committee = zksync_protobuf::serde::Serialize + .proto_repr::(&committee, serde_json::value::Serializer) + .unwrap(); sqlx::query!( r#" INSERT INTO @@ -498,10 +522,11 @@ impl ConsensusDal<'_, '_> { else { return Ok(None); }; - let raw = zksync_protobuf::serde::deserialize_proto(&row.attesters) - .context("deserialize_proto()")?; Ok(Some( - proto::AttesterCommittee::read(&raw).context("read()")?, + zksync_protobuf::serde::Deserialize { + deny_unknown_fields: true, + } + .proto_repr::(row.attesters)?, )) } @@ -535,7 +560,9 @@ impl ConsensusDal<'_, '_> { "#, i64::try_from(cert.message.number.0).context("overflow")?, // Unwrap is ok, because serialization should always succeed. - zksync_protobuf::serde::serialize(cert, serde_json::value::Serializer).unwrap(), + zksync_protobuf::serde::Serialize + .proto_fmt(cert, serde_json::value::Serializer) + .unwrap(), ) .instrument("insert_batch_certificate") .report_latency() diff --git a/core/lib/protobuf_config/src/lib.rs b/core/lib/protobuf_config/src/lib.rs index a4822edbe8e4..a0f4d45214f6 100644 --- a/core/lib/protobuf_config/src/lib.rs +++ b/core/lib/protobuf_config/src/lib.rs @@ -77,7 +77,10 @@ pub fn decode_yaml_repr( ) -> anyhow::Result { let yaml = std::fs::read_to_string(path).with_context(|| path.display().to_string())?; let d = serde_yaml::Deserializer::from_str(&yaml); - let this: T = zksync_protobuf::serde::deserialize_proto_with_options(d, deny_unknown_fields)?; + let this: T = zksync_protobuf::serde::Deserialize { + deny_unknown_fields, + } + .proto(d)?; this.read() } diff --git a/core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs b/core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs index 2d6af705f482..9aeb9c02af64 100644 --- a/core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs +++ b/core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs @@ -26,15 +26,15 @@ use zksync_env_config::FromEnv; use zksync_protobuf::repr::ProtoRepr; use zksync_protobuf_config::proto::secrets::Secrets; -pub fn decode_yaml_repr(yaml: &str) -> anyhow::Result { - let d = serde_yaml::Deserializer::from_str(yaml); - let this: T = zksync_protobuf::serde::deserialize_proto_with_options(d, false)?; - this.read() -} - -pub fn read_yaml_repr(path_buf: PathBuf) -> anyhow::Result { - let yaml = std::fs::read_to_string(path_buf).context("failed reading YAML config")?; - decode_yaml_repr::(&yaml) +pub fn read_yaml_repr(path: &PathBuf) -> anyhow::Result { + (|| { + let yaml = std::fs::read_to_string(&path)?; + zksync_protobuf::serde::Deserialize { + deny_unknown_fields: false, + } + .proto_repr_from_yaml::(&yaml) + })() + .with_context(|| format!("failed to read {}", path.display())) } // TODO (QIT-22): This structure is going to be removed when components will be responsible for their own configs. @@ -209,8 +209,7 @@ fn load_env_config() -> anyhow::Result { pub fn load_general_config(path: Option) -> anyhow::Result { match path { Some(path) => { - let yaml = std::fs::read_to_string(path).context("Failed to read general config")?; - decode_yaml_repr::(&yaml) + read_yaml_repr::(&path) } None => Ok(load_env_config() .context("general config from env")? @@ -221,8 +220,7 @@ pub fn load_general_config(path: Option) -> anyhow::Result) -> anyhow::Result { match path { Some(path) => { - let yaml = std::fs::read_to_string(path).context("Failed to read secrets")?; - let secrets = decode_yaml_repr::(&yaml).context("Failed to parse secrets")?; + let secrets = read_yaml_repr::(&path)?; Ok(secrets .database .context("failed to parse database secrets")?) diff --git a/core/node/api_server/src/web3/namespaces/en.rs b/core/node/api_server/src/web3/namespaces/en.rs index 26f4aa2b0b5f..a412c064fac7 100644 --- a/core/node/api_server/src/web3/namespaces/en.rs +++ b/core/node/api_server/src/web3/namespaces/en.rs @@ -34,7 +34,9 @@ impl EnNamespace { return Ok(None); }; Ok(Some(en::ConsensusGlobalConfig( - zksync_protobuf::serde::serialize(&cfg, serde_json::value::Serializer).unwrap(), + zksync_protobuf::serde::Serialize + .proto_fmt(&cfg, serde_json::value::Serializer) + .unwrap(), ))) } @@ -49,7 +51,9 @@ impl EnNamespace { return Ok(None); }; Ok(Some(en::ConsensusGenesis( - zksync_protobuf::serde::serialize(&cfg.genesis, serde_json::value::Serializer).unwrap(), + zksync_protobuf::serde::Serialize + .proto_fmt(&cfg.genesis, serde_json::value::Serializer) + .unwrap(), ))) } @@ -76,7 +80,9 @@ impl EnNamespace { return Ok(None); }; Ok(Some(en::AttestationStatus( - zksync_protobuf::serde::serialize(&status, serde_json::value::Serializer).unwrap(), + zksync_protobuf::serde::Serialize + .proto_fmt(&status, serde_json::value::Serializer) + .unwrap(), ))) } diff --git a/core/node/consensus/src/en.rs b/core/node/consensus/src/en.rs index 0b78662f8c25..e4be8d9d6876 100644 --- a/core/node/consensus/src/en.rs +++ b/core/node/consensus/src/en.rs @@ -282,7 +282,11 @@ impl EN { match ctx.wait(self.client.consensus_global_config()).await? { Ok(cfg) => { let cfg = cfg.context("main node is not running consensus component")?; - return Ok(zksync_protobuf::serde::deserialize(&cfg.0).context("deserialize()")?); + return Ok(zksync_protobuf::serde::Deserialize { + deny_unknown_fields: false, + } + .proto_fmt(&cfg.0) + .context("deserialize()")?); } // For non-whitelisted methods, proxyd returns HTTP 403 with MethodNotFound in the body. // For some stupid reason ClientError doesn't expose HTTP error codes. @@ -302,7 +306,11 @@ impl EN { .context("consensus_genesis()")? .context("main node is not running consensus component")?; Ok(consensus_dal::GlobalConfig { - genesis: zksync_protobuf::serde::deserialize(&genesis.0).context("deserialize()")?, + genesis: zksync_protobuf::serde::Deserialize { + deny_unknown_fields: false, + } + .proto_fmt(&genesis.0) + .context("deserialize()")?, registry_address: None, seed_peers: [].into(), }) @@ -318,7 +326,11 @@ impl EN { .await? .context("attestation_status()")? .context("main node is not runnign consensus component")?; - Ok(zksync_protobuf::serde::deserialize(&status.0).context("deserialize()")?) + Ok(zksync_protobuf::serde::Deserialize { + deny_unknown_fields: false, + } + .proto_fmt(&status.0) + .context("deserialize()")?) } /// Fetches (with retries) the given block from the main node. diff --git a/core/node/consensus/src/tests/attestation.rs b/core/node/consensus/src/tests/attestation.rs index e783dbecdc35..35d849ae6169 100644 --- a/core/node/consensus/src/tests/attestation.rs +++ b/core/node/consensus/src/tests/attestation.rs @@ -63,8 +63,11 @@ async fn test_attestation_status_api(version: ProtocolVersionId) { .wait(api.attestation_status()) .await?? .context("no attestation_status")?; - let s: consensus_dal::AttestationStatus = - zksync_protobuf::serde::deserialize(&s.0).context("deserialize()")?; + let s: consensus_dal::AttestationStatus = zksync_protobuf::serde::Deserialize { + deny_unknown_fields: true, + } + .proto_fmt(&s.0) + .context("deserialize()")?; anyhow::ensure!(s.genesis == setup.genesis.hash(), "genesis hash mismatch"); Ok(s) }; diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 1abec8d0c1a8..2fe2f4404544 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -1810,18 +1810,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ff_ce" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b538e4231443a5b9c507caee3356f016d832cf7393d2d90f03ea3180d4e3fbc" -dependencies = [ - "byteorder", - "hex", - "rand 0.4.6", - "serde", -] - [[package]] name = "fiat-crypto" version = "0.2.9" @@ -7391,9 +7379,7 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c8cf6c689ab5922b52d81b775cd2d9cffbfc8fb8da65985e11b06546dfb3bf" +version = "0.2.0" dependencies = [ "anyhow", "once_cell", @@ -7427,20 +7413,16 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7baced4e811015038322dad10239f2d631d9e339e8d6b7b6e6b146bee30f41" +version = "0.2.0" dependencies = [ "anyhow", "blst", "ed25519-dalek", "elliptic-curve 0.13.8", - "ff_ce", "hex", "k256 0.13.3", "num-bigint 0.4.5", "num-traits", - "rand 0.4.6", "rand 0.8.5", "sha3 0.10.8", "thiserror", @@ -7450,9 +7432,7 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aab4ddf62f6001903c5fe9f65afb1bdc42464928c9d1c6ce52e4d7e9944f5dc" +version = "0.2.0" dependencies = [ "anyhow", "bit-vec", @@ -7472,9 +7452,7 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b9dbcb923fa201af03f49f70c11a923b416915d2ddf8b2de3a2e861f22898a4" +version = "0.2.0" dependencies = [ "anyhow", "async-trait", @@ -7492,9 +7470,7 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e69dffc0fbc7c096548c997f5ca157a490b34b3d49fd524fa3d51840f7fb22" +version = "0.2.0" dependencies = [ "anyhow", "rand 0.8.5", @@ -7800,9 +7776,7 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5467dfe2f845ca1fd6ceec623bbd32187589793d3c4023dcd2f5172369d198" +version = "0.2.0" dependencies = [ "anyhow", "bit-vec", @@ -7821,9 +7795,7 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d35280660b11be2a4ebdf531184eb729acebfdc3368d27176ec104f8bf9c5f" +version = "0.2.0" dependencies = [ "anyhow", "heck 0.5.0", @@ -8253,3 +8225,15 @@ dependencies = [ "zksync_utils", "zksync_vlog", ] + +[[patch.unused]] +name = "zksync_consensus_bft" +version = "0.2.0" + +[[patch.unused]] +name = "zksync_consensus_executor" +version = "0.2.0" + +[[patch.unused]] +name = "zksync_consensus_network" +version = "0.2.0" diff --git a/prover/crates/lib/prover_dal/src/cli_test_dal.rs b/prover/crates/lib/prover_dal/src/cli_test_dal.rs index 19fe0e4f57b0..d08418203378 100644 --- a/prover/crates/lib/prover_dal/src/cli_test_dal.rs +++ b/prover/crates/lib/prover_dal/src/cli_test_dal.rs @@ -21,11 +21,16 @@ impl CliTestDal<'_, '_> { sequence_number: usize, ) { sqlx::query!( - "UPDATE prover_jobs_fri SET status = $1 - WHERE l1_batch_number = $2 + r#" + UPDATE prover_jobs_fri + SET + status = $1 + WHERE + l1_batch_number = $2 AND sequence_number = $3 AND aggregation_round = $4 - AND circuit_id = $5", + AND circuit_id = $5 + "#, status.to_string(), batch_number.0 as i64, sequence_number as i64, @@ -44,7 +49,7 @@ impl CliTestDal<'_, '_> { circuit_id: u8, ) { sqlx::query!( - " + r#" INSERT INTO leaf_aggregation_witness_jobs_fri ( l1_batch_number, @@ -58,8 +63,9 @@ impl CliTestDal<'_, '_> { ($1, $2, 'waiting_for_proofs', 2, NOW(), NOW()) ON CONFLICT (l1_batch_number, circuit_id) DO UPDATE - SET status = $3 - ", + SET + status = $3 + "#, batch_number.0 as i64, circuit_id as i16, status.to_string() @@ -76,21 +82,16 @@ impl CliTestDal<'_, '_> { circuit_id: u8, ) { sqlx::query!( - " + r#" INSERT INTO - node_aggregation_witness_jobs_fri ( - l1_batch_number, - circuit_id, - status, - created_at, - updated_at - ) + node_aggregation_witness_jobs_fri (l1_batch_number, circuit_id, status, created_at, updated_at) VALUES ($1, $2, 'waiting_for_proofs', NOW(), NOW()) ON CONFLICT (l1_batch_number, circuit_id, depth) DO UPDATE - SET status = $3 - ", + SET + status = $3 + "#, batch_number.0 as i64, circuit_id as i16, status.to_string(), @@ -102,21 +103,16 @@ impl CliTestDal<'_, '_> { pub async fn insert_rt_job(&mut self, status: WitnessJobStatus, batch_number: L1BatchNumber) { sqlx::query!( - " + r#" INSERT INTO - recursion_tip_witness_jobs_fri ( - l1_batch_number, - status, - number_of_final_node_jobs, - created_at, - updated_at - ) + recursion_tip_witness_jobs_fri (l1_batch_number, status, number_of_final_node_jobs, created_at, updated_at) VALUES - ($1, 'waiting_for_proofs',1, NOW(), NOW()) + ($1, 'waiting_for_proofs', 1, NOW(), NOW()) ON CONFLICT (l1_batch_number) DO UPDATE - SET status = $2 - ", + SET + status = $2 + "#, batch_number.0 as i64, status.to_string(), ) @@ -131,7 +127,7 @@ impl CliTestDal<'_, '_> { batch_number: L1BatchNumber, ) { sqlx::query!( - " + r#" INSERT INTO scheduler_witness_jobs_fri ( l1_batch_number, @@ -144,8 +140,9 @@ impl CliTestDal<'_, '_> { ($1, '', 'waiting_for_proofs', NOW(), NOW()) ON CONFLICT (l1_batch_number) DO UPDATE - SET status = $2 - ", + SET + status = $2 + "#, batch_number.0 as i64, status.to_string(), ) @@ -160,20 +157,16 @@ impl CliTestDal<'_, '_> { batch_number: L1BatchNumber, ) { sqlx::query!( - " + r#" INSERT INTO - proof_compression_jobs_fri ( - l1_batch_number, - status, - created_at, - updated_at - ) + proof_compression_jobs_fri (l1_batch_number, status, created_at, updated_at) VALUES ($1, $2, NOW(), NOW()) ON CONFLICT (l1_batch_number) DO UPDATE - SET status = $2 - ", + SET + status = $2 + "#, batch_number.0 as i64, status.to_string(), ) @@ -192,12 +185,17 @@ impl CliTestDal<'_, '_> { sequence_number: usize, ) { sqlx::query!( - "UPDATE prover_jobs_fri - SET status = $1, attempts = $2 - WHERE l1_batch_number = $3 - AND sequence_number =$4 + r#" + UPDATE prover_jobs_fri + SET + status = $1, + attempts = $2 + WHERE + l1_batch_number = $3 + AND sequence_number = $4 AND aggregation_round = $5 - AND circuit_id = $6", + AND circuit_id = $6 + "#, status.to_string(), attempts as i64, batch_number.0 as i64, @@ -218,10 +216,15 @@ impl CliTestDal<'_, '_> { batch_number: L1BatchNumber, ) { sqlx::query!( - "UPDATE leaf_aggregation_witness_jobs_fri - SET status = $1, attempts = $2 - WHERE l1_batch_number = $3 - AND circuit_id = $4", + r#" + UPDATE leaf_aggregation_witness_jobs_fri + SET + status = $1, + attempts = $2 + WHERE + l1_batch_number = $3 + AND circuit_id = $4 + "#, status.to_string(), attempts as i64, batch_number.0 as i64, diff --git a/prover/crates/lib/prover_dal/src/fri_prover_dal.rs b/prover/crates/lib/prover_dal/src/fri_prover_dal.rs index 1a3b8de0ce4b..71d0c11728b1 100644 --- a/prover/crates/lib/prover_dal/src/fri_prover_dal.rs +++ b/prover/crates/lib/prover_dal/src/fri_prover_dal.rs @@ -528,8 +528,14 @@ impl FriProverDal<'_, '_> { SELECT protocol_version AS "protocol_version!", protocol_version_patch AS "protocol_version_patch!", - COUNT(*) FILTER (WHERE status = 'queued') as queued, - COUNT(*) FILTER (WHERE status = 'in_progress') as in_progress + COUNT(*) FILTER ( + WHERE + status = 'queued' + ) AS queued, + COUNT(*) FILTER ( + WHERE + status = 'in_progress' + ) AS in_progress FROM prover_jobs_fri WHERE diff --git a/prover/crates/lib/prover_dal/src/fri_witness_generator_dal.rs b/prover/crates/lib/prover_dal/src/fri_witness_generator_dal.rs index 66e34f7f8e75..c7ba0f60ef3f 100644 --- a/prover/crates/lib/prover_dal/src/fri_witness_generator_dal.rs +++ b/prover/crates/lib/prover_dal/src/fri_witness_generator_dal.rs @@ -1719,7 +1719,10 @@ impl FriWitnessGeneratorDal<'_, '_> { WHERE l1_batch_number = $1 AND attempts >= $2 - AND (status = 'in_progress' OR status = 'failed') + AND ( + status = 'in_progress' + OR status = 'failed' + ) RETURNING l1_batch_number, status, @@ -1786,7 +1789,10 @@ impl FriWitnessGeneratorDal<'_, '_> { WHERE l1_batch_number = $1 AND attempts >= $2 - AND (status = 'in_progress' OR status = 'failed') + AND ( + status = 'in_progress' + OR status = 'failed' + ) RETURNING l1_batch_number, status, @@ -1827,7 +1833,10 @@ impl FriWitnessGeneratorDal<'_, '_> { WHERE l1_batch_number = $1 AND attempts >= $2 - AND (status = 'in_progress' OR status = 'failed') + AND ( + status = 'in_progress' + OR status = 'failed' + ) RETURNING l1_batch_number, status, diff --git a/zk_toolbox/Cargo.lock b/zk_toolbox/Cargo.lock index 296037094529..99c47b28abcc 100644 --- a/zk_toolbox/Cargo.lock +++ b/zk_toolbox/Cargo.lock @@ -643,7 +643,7 @@ dependencies = [ "hmac", "once_cell", "pbkdf2 0.12.2", - "rand 0.8.5", + "rand", "sha2", "thiserror", ] @@ -722,7 +722,7 @@ dependencies = [ "clap", "common", "ethers", - "rand 0.8.5", + "rand", "serde", "serde_json", "serde_yaml", @@ -871,7 +871,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -883,7 +883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -1179,7 +1179,7 @@ checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", - "rand_core 0.6.4", + "rand_core", "serde", "sha2", "subtle", @@ -1209,7 +1209,7 @@ dependencies = [ "generic-array", "group 0.12.1", "pkcs8 0.9.0", - "rand_core 0.6.4", + "rand_core", "sec1 0.3.0", "subtle", "zeroize", @@ -1228,7 +1228,7 @@ dependencies = [ "generic-array", "group 0.13.0", "pkcs8 0.10.2", - "rand_core 0.6.4", + "rand_core", "sec1 0.7.3", "subtle", "zeroize", @@ -1278,7 +1278,7 @@ dependencies = [ "hex", "k256 0.13.3", "log", - "rand 0.8.5", + "rand", "rlp", "serde", "sha3", @@ -1333,7 +1333,7 @@ dependencies = [ "hex", "hmac", "pbkdf2 0.11.0", - "rand 0.8.5", + "rand", "scrypt", "serde", "serde_json", @@ -1496,7 +1496,7 @@ dependencies = [ "num_enum 0.7.2", "once_cell", "open-fastrlp", - "rand 0.8.5", + "rand", "rlp", "serde", "serde_json", @@ -1601,7 +1601,7 @@ dependencies = [ "elliptic-curve 0.13.8", "eth-keystore", "ethers-core", - "rand 0.8.5", + "rand", "sha2", "thiserror", "tracing", @@ -1672,7 +1672,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1682,22 +1682,10 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] -[[package]] -name = "ff_ce" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b538e4231443a5b9c507caee3356f016d832cf7393d2d90f03ea3180d4e3fbc" -dependencies = [ - "byteorder", - "hex", - "rand 0.4.6", - "serde", -] - [[package]] name = "fiat-crypto" version = "0.2.9" @@ -1723,7 +1711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", - "rand 0.8.5", + "rand", "rustc-hex", "static_assertions", ] @@ -1795,12 +1783,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "funty" version = "2.0.0" @@ -1996,7 +1978,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff 0.12.1", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -2007,7 +1989,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff 0.13.0", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -2837,7 +2819,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" dependencies = [ - "rand 0.8.5", + "rand", ] [[package]] @@ -2920,7 +2902,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand 0.8.5", + "rand", "smallvec", "zeroize", ] @@ -3216,7 +3198,7 @@ dependencies = [ "once_cell", "opentelemetry", "percent-encoding", - "rand 0.8.5", + "rand", "serde_json", "thiserror", "tokio", @@ -3317,7 +3299,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" dependencies = [ "base64ct", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -3416,7 +3398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared 0.11.2", - "rand 0.8.5", + "rand", ] [[package]] @@ -3627,7 +3609,7 @@ dependencies = [ "bitflags 2.6.0", "lazy_static", "num-traits", - "rand 0.8.5", + "rand", "rand_chacha", "rand_xorshift", "regex-syntax 0.8.4", @@ -3777,19 +3759,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - [[package]] name = "rand" version = "0.8.5" @@ -3798,7 +3767,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -3808,24 +3777,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.4" @@ -3841,7 +3795,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -3864,15 +3818,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -4129,7 +4074,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8 0.10.2", - "rand_core 0.6.4", + "rand_core", "signature 2.2.0", "spki 0.7.3", "subtle", @@ -4483,7 +4428,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "901f761681f97db3db836ef9e094acdd8756c40215326c194201941947164ef1" dependencies = [ "once_cell", - "rand 0.8.5", + "rand", "sentry-types", "serde", "serde_json", @@ -4530,7 +4475,7 @@ checksum = "da956cca56e0101998c8688bc65ce1a96f00673a0e58e663664023d4c7911e82" dependencies = [ "debugid", "hex", - "rand 0.8.5", + "rand", "serde", "serde_json", "thiserror", @@ -4721,7 +4666,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ "digest", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -4731,7 +4676,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -4975,7 +4920,7 @@ dependencies = [ "memchr", "once_cell", "percent-encoding", - "rand 0.8.5", + "rand", "rsa", "serde", "sha1", @@ -5014,7 +4959,7 @@ dependencies = [ "md-5", "memchr", "once_cell", - "rand 0.8.5", + "rand", "serde", "serde_json", "sha2", @@ -5541,7 +5486,7 @@ dependencies = [ "indexmap 1.9.3", "pin-project", "pin-project-lite", - "rand 0.8.5", + "rand", "slab", "tokio", "tokio-util", @@ -5684,7 +5629,7 @@ dependencies = [ "http 0.2.12", "httparse", "log", - "rand 0.8.5", + "rand", "rustls 0.21.12", "sha1", "thiserror", @@ -6498,14 +6443,12 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c8cf6c689ab5922b52d81b775cd2d9cffbfc8fb8da65985e11b06546dfb3bf" +version = "0.2.0" dependencies = [ "anyhow", "once_cell", "pin-project", - "rand 0.8.5", + "rand", "sha3", "thiserror", "time", @@ -6520,7 +6463,7 @@ name = "zksync_config" version = "0.1.0" dependencies = [ "anyhow", - "rand 0.8.5", + "rand", "secrecy", "serde", "url", @@ -6532,21 +6475,17 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7baced4e811015038322dad10239f2d631d9e339e8d6b7b6e6b146bee30f41" +version = "0.2.0" dependencies = [ "anyhow", "blst", "ed25519-dalek", "elliptic-curve 0.13.8", - "ff_ce", "hex", "k256 0.13.3", "num-bigint", "num-traits", - "rand 0.4.6", - "rand 0.8.5", + "rand", "sha3", "thiserror", "tracing", @@ -6555,16 +6494,14 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aab4ddf62f6001903c5fe9f65afb1bdc42464928c9d1c6ce52e4d7e9944f5dc" +version = "0.2.0" dependencies = [ "anyhow", "bit-vec", "hex", "num-bigint", "prost 0.12.6", - "rand 0.8.5", + "rand", "serde", "thiserror", "tracing", @@ -6577,12 +6514,10 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e69dffc0fbc7c096548c997f5ca157a490b34b3d49fd524fa3d51840f7fb22" +version = "0.2.0" dependencies = [ "anyhow", - "rand 0.8.5", + "rand", "thiserror", "zksync_concurrency", ] @@ -6607,7 +6542,7 @@ dependencies = [ "anyhow", "blake2", "hex", - "rand 0.8.5", + "rand", "secp256k1", "serde", "serde_json", @@ -6628,9 +6563,7 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5467dfe2f845ca1fd6ceec623bbd32187589793d3c4023dcd2f5172369d198" +version = "0.2.0" dependencies = [ "anyhow", "bit-vec", @@ -6638,7 +6571,7 @@ dependencies = [ "prost 0.12.6", "prost-reflect", "quick-protobuf", - "rand 0.8.5", + "rand", "serde", "serde_json", "serde_yaml", @@ -6649,9 +6582,7 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d35280660b11be2a4ebdf531184eb729acebfdc3368d27176ec104f8bf9c5f" +version = "0.2.0" dependencies = [ "anyhow", "heck", @@ -6671,7 +6602,7 @@ dependencies = [ "anyhow", "hex", "prost 0.12.6", - "rand 0.8.5", + "rand", "secrecy", "serde_json", "serde_yaml", @@ -6800,3 +6731,19 @@ dependencies = [ "cc", "pkg-config", ] + +[[patch.unused]] +name = "zksync_consensus_bft" +version = "0.2.0" + +[[patch.unused]] +name = "zksync_consensus_executor" +version = "0.2.0" + +[[patch.unused]] +name = "zksync_consensus_network" +version = "0.2.0" + +[[patch.unused]] +name = "zksync_consensus_storage" +version = "0.2.0" diff --git a/zk_toolbox/Cargo.toml b/zk_toolbox/Cargo.toml index d8b84f93adde..eccb1657a50f 100644 --- a/zk_toolbox/Cargo.toml +++ b/zk_toolbox/Cargo.toml @@ -32,9 +32,9 @@ git_version_macro = { path = "crates/git_version_macro" } zksync_config = { path = "../core/lib/config" } zksync_protobuf_config = { path = "../core/lib/protobuf_config" } zksync_basic_types = { path = "../core/lib/basic_types" } -zksync_consensus_roles = "=0.1.1" -zksync_consensus_crypto = "=0.1.1" -zksync_protobuf = "=0.1.1" +zksync_consensus_roles = "=0.2.0" +zksync_consensus_crypto = "=0.2.0" +zksync_protobuf = "=0.2.0" # External dependencies anyhow = "1.0.82" From 5163163c55b4de637606f22eb20c151789befc07 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Thu, 26 Sep 2024 08:44:20 +0200 Subject: [PATCH 2/9] adjusted the genesis updating logic --- ...31867b3c0bff34bbacbc31ff4cd786c97ca90.json | 12 ++++ ...7445aa3148d8abdd4e5fb50947ce512f53690.json | 14 ++++ ...5bf6d0bc603a83cbd5b88a537cbbedee36e32.json | 12 ---- ...29bf769829991c7d732b13f96bcd1293263ea.json | 12 ++++ ...5663d11c17165a387056bfb48923a35d3909d.json | 12 ---- core/lib/dal/src/consensus_dal.rs | 66 +++++++++++++------ ...f1cdac8b194f09926c133985479c533a651f2.json | 18 +++++ ...0d001cdf5bc7ba988b742571ec90a938434e3.json | 17 ----- ...0cd5c6b1122c35d7ffdbbba30327ca3fb5a8.json} | 4 +- ...cf8c93630d529ec96e67aac078f18196f61a5.json | 19 ++++++ ...adefab0bf3abf6853a6d36123c8adcaf813b.json} | 4 +- ...d48c95ca5b4520dde415a2b5ff32ece47c86.json} | 4 +- ...8d4cc59246dda91b19526e73f27a17c8e3da.json} | 4 +- ...a468057599be1e6c6c96a947c33df53a68224.json | 15 ----- ...2e61157bf58aec70903623afc9da24d46a336.json | 16 ----- ...1b931c0d8dbc6835dfac20107ea7412ce9fbb.json | 15 ----- ...9a67936d572f8046d3a1c7a4f100ff209d81d.json | 18 ----- ...41976a264759c4060c1a38e466ee2052fc17d.json | 15 +++++ ...2a4a98ec63eb942c73ce4448d0957346047cd.json | 17 +++++ ...08a01b63ae4aa03c983c3a52c802d585e5a80.json | 15 +++++ ...700302981be0afef31a8864613484f8521f9e.json | 19 ------ ...b5a4672ad50a9de92c84d939ac4c69842e355.json | 16 +++++ ...d005d8760c4809b7aef902155196873da66e.json} | 4 +- ...8e1010d7389457b3c97e9b238a3a0291a54e.json} | 4 +- 24 files changed, 197 insertions(+), 155 deletions(-) create mode 100644 core/lib/dal/.sqlx/query-3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90.json create mode 100644 core/lib/dal/.sqlx/query-44ec5b4d2218099da30aa8d654f7445aa3148d8abdd4e5fb50947ce512f53690.json delete mode 100644 core/lib/dal/.sqlx/query-7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32.json create mode 100644 core/lib/dal/.sqlx/query-7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea.json delete mode 100644 core/lib/dal/.sqlx/query-bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d.json create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-1297f0977132185d6bd4501f490f1cdac8b194f09926c133985479c533a651f2.json delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-1926cf432237684de2383179a6d0d001cdf5bc7ba988b742571ec90a938434e3.json rename prover/crates/lib/prover_dal/.sqlx/{query-97adb49780c9edde6a3cfda09dadbd694e1781e013247d090a280a1f894de464.json => query-29f7a564a8373f7e44840e8e9e7d0cd5c6b1122c35d7ffdbbba30327ca3fb5a8.json} (53%) create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-2d1461e068e43fd16714610b383cf8c93630d529ec96e67aac078f18196f61a5.json rename prover/crates/lib/prover_dal/.sqlx/{query-75c1affbca0901edd5d0e2f12ef4d935674a5aff2f34421d753b4d1a9dea5b12.json => query-35a76415cb746d03da31481edc65adefab0bf3abf6853a6d36123c8adcaf813b.json} (70%) rename prover/crates/lib/prover_dal/.sqlx/{query-548414f8148740c991c345e5fd46ea738d209eb07e7a6bcbdb33e25b3347a08c.json => query-3727d5614d2fe2a4d96f880eb72cd48c95ca5b4520dde415a2b5ff32ece47c86.json} (70%) rename prover/crates/lib/prover_dal/.sqlx/{query-c19fc4c8e4b3a3ef4f9c0f4c22ed68c598eada8e60938a8e4b5cd32b53f5a574.json => query-37ad15f54f4a6f4f79c71a857f3a8d4cc59246dda91b19526e73f27a17c8e3da.json} (69%) delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-39f60c638d445c5dbf23e01fd89a468057599be1e6c6c96a947c33df53a68224.json delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-3a9ffd4d88f2cfac22835aac2512e61157bf58aec70903623afc9da24d46a336.json delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-3bb8fbd9e83703887e0a3c196031b931c0d8dbc6835dfac20107ea7412ce9fbb.json delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-434f7cb51a7d22948cd26e962679a67936d572f8046d3a1c7a4f100ff209d81d.json create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-73266a8526c6adc315900e2e95441976a264759c4060c1a38e466ee2052fc17d.json create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-9730c8225ff2cf3111185e81f602a4a98ec63eb942c73ce4448d0957346047cd.json create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-a817f0fec85388b3e2510ce259208a01b63ae4aa03c983c3a52c802d585e5a80.json delete mode 100644 prover/crates/lib/prover_dal/.sqlx/query-aabcfa9005b8e1d84cfa083a47a700302981be0afef31a8864613484f8521f9e.json create mode 100644 prover/crates/lib/prover_dal/.sqlx/query-c8daa62b3835c15fafb3f83deabb5a4672ad50a9de92c84d939ac4c69842e355.json rename prover/crates/lib/prover_dal/.sqlx/{query-63cf7038e6c48af8ed9afc7d6ea07edd87cb16a79c13e7d4291d99736e51d3b9.json => query-e875dcbbdaed6998dbea45d4eab5d005d8760c4809b7aef902155196873da66e.json} (82%) rename prover/crates/lib/prover_dal/.sqlx/{query-0eac6f7b2d799059328584029b437891598dc79b5ed11258b2c90c3f282929ad.json => query-eec29cbff034818f4fb5ec1e6ad38e1010d7389457b3c97e9b238a3a0291a54e.json} (78%) diff --git a/core/lib/dal/.sqlx/query-3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90.json b/core/lib/dal/.sqlx/query-3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90.json new file mode 100644 index 000000000000..72d008c11475 --- /dev/null +++ b/core/lib/dal/.sqlx/query-3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE FROM l1_batches_consensus\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "3f9543c622a3877dd8612f3fc5f31867b3c0bff34bbacbc31ff4cd786c97ca90" +} diff --git a/core/lib/dal/.sqlx/query-44ec5b4d2218099da30aa8d654f7445aa3148d8abdd4e5fb50947ce512f53690.json b/core/lib/dal/.sqlx/query-44ec5b4d2218099da30aa8d654f7445aa3148d8abdd4e5fb50947ce512f53690.json new file mode 100644 index 000000000000..43b00071bd4c --- /dev/null +++ b/core/lib/dal/.sqlx/query-44ec5b4d2218099da30aa8d654f7445aa3148d8abdd4e5fb50947ce512f53690.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE consensus_replica_state\n SET\n global_config = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "44ec5b4d2218099da30aa8d654f7445aa3148d8abdd4e5fb50947ce512f53690" +} diff --git a/core/lib/dal/.sqlx/query-7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32.json b/core/lib/dal/.sqlx/query-7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32.json deleted file mode 100644 index 5414d71c5257..000000000000 --- a/core/lib/dal/.sqlx/query-7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n DELETE FROM miniblocks_consensus\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [] - }, - "nullable": [] - }, - "hash": "7035e258bb048962336b20230915bf6d0bc603a83cbd5b88a537cbbedee36e32" -} diff --git a/core/lib/dal/.sqlx/query-7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea.json b/core/lib/dal/.sqlx/query-7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea.json new file mode 100644 index 000000000000..80d855d8d21a --- /dev/null +++ b/core/lib/dal/.sqlx/query-7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE FROM miniblocks_consensus\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "7af52a220958d790bd8b5b06a6e29bf769829991c7d732b13f96bcd1293263ea" +} diff --git a/core/lib/dal/.sqlx/query-bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d.json b/core/lib/dal/.sqlx/query-bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d.json deleted file mode 100644 index 759189a26d74..000000000000 --- a/core/lib/dal/.sqlx/query-bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n DELETE FROM l1_batches_consensus\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [] - }, - "nullable": [] - }, - "hash": "bf0a0afb7eba7b873f42cd470aa5663d11c17165a387056bfb48923a35d3909d" -} diff --git a/core/lib/dal/src/consensus_dal.rs b/core/lib/dal/src/consensus_dal.rs index 0526be133b14..3e85fb4419d0 100644 --- a/core/lib/dal/src/consensus_dal.rs +++ b/core/lib/dal/src/consensus_dal.rs @@ -85,12 +85,41 @@ impl ConsensusDal<'_, '_> { if got == want { return Ok(()); } + // If genesis didn't change, just update the config. + if got.genesis == want.genesis { + let s = zksync_protobuf::serde::Serialize; + let global_config = s.proto_fmt(want, serde_json::value::Serializer).unwrap(); + sqlx::query!( + r#" + UPDATE consensus_replica_state + SET + global_config = $1 + "#, + global_config, + ) + .instrument("try_update_global_config#UPDATE consensus_replica_state") + .execute(&mut txn) + .await?; + txn.commit().await?; + return Ok(()); + } + + // Verify the genesis change. anyhow::ensure!( got.genesis.chain_id == want.genesis.chain_id, "changing chain_id is not allowed: old = {:?}, new = {:?}", got.genesis.chain_id, want.genesis.chain_id, ); + // Note that it may happen that the fork number didn't change, + // in case the binary was updated to support more fields in genesis struct. + // In such a case, the old binary was not able to connect to the consensus network, + // because of the genesis hash mismatch. + // TODO: Perhaps it would be better to deny unknown fields in the genesis instead. + // It would require embedding the genesis either as a json string or protobuf bytes within + // the global config, so that the global config can be parsed with + // `deny_unknown_fields:false` while genesis would be parsed with + // `deny_unknown_fields:true`. anyhow::ensure!( got.genesis.fork_number <= want.genesis.fork_number, "transition to a past fork is not allowed: old = {:?}, new = {:?}", @@ -99,6 +128,8 @@ impl ConsensusDal<'_, '_> { ); want.genesis.verify().context("genesis.verify()")?; } + + // Reset the consensus state. let s = zksync_protobuf::serde::Serialize; let genesis = s .proto_fmt(&want.genesis, serde_json::value::Serializer) @@ -107,25 +138,22 @@ impl ConsensusDal<'_, '_> { let state = s .proto_fmt(&ReplicaState::default(), serde_json::value::Serializer) .unwrap(); - if got.as_ref().map(|c| &c.genesis) != Some(&want.genesis) { - tracing::info!("consensus genesis changed, wiping consensus certificates"); - sqlx::query!( - r#" - DELETE FROM l1_batches_consensus - "# - ) - .instrument("try_update_genesis#DELETE FROM l1_batches_consensus") - .execute(&mut txn) - .await?; - sqlx::query!( - r#" - DELETE FROM miniblocks_consensus - "# - ) - .instrument("try_update_genesis#DELETE FROM miniblock_consensus") - .execute(&mut txn) - .await?; - } + sqlx::query!( + r#" + DELETE FROM l1_batches_consensus + "# + ) + .instrument("try_update_genesis#DELETE FROM l1_batches_consensus") + .execute(&mut txn) + .await?; + sqlx::query!( + r#" + DELETE FROM miniblocks_consensus + "# + ) + .instrument("try_update_genesis#DELETE FROM miniblock_consensus") + .execute(&mut txn) + .await?; sqlx::query!( r#" DELETE FROM consensus_replica_state diff --git a/prover/crates/lib/prover_dal/.sqlx/query-1297f0977132185d6bd4501f490f1cdac8b194f09926c133985479c533a651f2.json b/prover/crates/lib/prover_dal/.sqlx/query-1297f0977132185d6bd4501f490f1cdac8b194f09926c133985479c533a651f2.json new file mode 100644 index 000000000000..c99572bcc8e5 --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-1297f0977132185d6bd4501f490f1cdac8b194f09926c133985479c533a651f2.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE prover_jobs_fri\n SET\n status = $1\n WHERE\n l1_batch_number = $2\n AND sequence_number = $3\n AND aggregation_round = $4\n AND circuit_id = $5\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int8", + "Int4", + "Int2", + "Int2" + ] + }, + "nullable": [] + }, + "hash": "1297f0977132185d6bd4501f490f1cdac8b194f09926c133985479c533a651f2" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-1926cf432237684de2383179a6d0d001cdf5bc7ba988b742571ec90a938434e3.json b/prover/crates/lib/prover_dal/.sqlx/query-1926cf432237684de2383179a6d0d001cdf5bc7ba988b742571ec90a938434e3.json deleted file mode 100644 index 4015a22ff3fd..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-1926cf432237684de2383179a6d0d001cdf5bc7ba988b742571ec90a938434e3.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE leaf_aggregation_witness_jobs_fri \n SET status = $1, attempts = $2\n WHERE l1_batch_number = $3\n AND circuit_id = $4", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Text", - "Int2", - "Int8", - "Int2" - ] - }, - "nullable": [] - }, - "hash": "1926cf432237684de2383179a6d0d001cdf5bc7ba988b742571ec90a938434e3" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-97adb49780c9edde6a3cfda09dadbd694e1781e013247d090a280a1f894de464.json b/prover/crates/lib/prover_dal/.sqlx/query-29f7a564a8373f7e44840e8e9e7d0cd5c6b1122c35d7ffdbbba30327ca3fb5a8.json similarity index 53% rename from prover/crates/lib/prover_dal/.sqlx/query-97adb49780c9edde6a3cfda09dadbd694e1781e013247d090a280a1f894de464.json rename to prover/crates/lib/prover_dal/.sqlx/query-29f7a564a8373f7e44840e8e9e7d0cd5c6b1122c35d7ffdbbba30327ca3fb5a8.json index ce9e492a7d4a..05163dcfa2e6 100644 --- a/prover/crates/lib/prover_dal/.sqlx/query-97adb49780c9edde6a3cfda09dadbd694e1781e013247d090a280a1f894de464.json +++ b/prover/crates/lib/prover_dal/.sqlx/query-29f7a564a8373f7e44840e8e9e7d0cd5c6b1122c35d7ffdbbba30327ca3fb5a8.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n protocol_version AS \"protocol_version!\",\n protocol_version_patch AS \"protocol_version_patch!\",\n COUNT(*) FILTER (WHERE status = 'queued') as queued,\n COUNT(*) FILTER (WHERE status = 'in_progress') as in_progress\n FROM\n prover_jobs_fri\n WHERE\n status IN ('queued', 'in_progress')\n AND protocol_version IS NOT NULL\n GROUP BY\n protocol_version,\n protocol_version_patch\n ", + "query": "\n SELECT\n protocol_version AS \"protocol_version!\",\n protocol_version_patch AS \"protocol_version_patch!\",\n COUNT(*) FILTER (\n WHERE\n status = 'queued'\n ) AS queued,\n COUNT(*) FILTER (\n WHERE\n status = 'in_progress'\n ) AS in_progress\n FROM\n prover_jobs_fri\n WHERE\n status IN ('queued', 'in_progress')\n AND protocol_version IS NOT NULL\n GROUP BY\n protocol_version,\n protocol_version_patch\n ", "describe": { "columns": [ { @@ -34,5 +34,5 @@ null ] }, - "hash": "97adb49780c9edde6a3cfda09dadbd694e1781e013247d090a280a1f894de464" + "hash": "29f7a564a8373f7e44840e8e9e7d0cd5c6b1122c35d7ffdbbba30327ca3fb5a8" } diff --git a/prover/crates/lib/prover_dal/.sqlx/query-2d1461e068e43fd16714610b383cf8c93630d529ec96e67aac078f18196f61a5.json b/prover/crates/lib/prover_dal/.sqlx/query-2d1461e068e43fd16714610b383cf8c93630d529ec96e67aac078f18196f61a5.json new file mode 100644 index 000000000000..50d121213fb9 --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-2d1461e068e43fd16714610b383cf8c93630d529ec96e67aac078f18196f61a5.json @@ -0,0 +1,19 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE prover_jobs_fri\n SET\n status = $1,\n attempts = $2\n WHERE\n l1_batch_number = $3\n AND sequence_number = $4\n AND aggregation_round = $5\n AND circuit_id = $6\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int2", + "Int8", + "Int4", + "Int2", + "Int2" + ] + }, + "nullable": [] + }, + "hash": "2d1461e068e43fd16714610b383cf8c93630d529ec96e67aac078f18196f61a5" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-75c1affbca0901edd5d0e2f12ef4d935674a5aff2f34421d753b4d1a9dea5b12.json b/prover/crates/lib/prover_dal/.sqlx/query-35a76415cb746d03da31481edc65adefab0bf3abf6853a6d36123c8adcaf813b.json similarity index 70% rename from prover/crates/lib/prover_dal/.sqlx/query-75c1affbca0901edd5d0e2f12ef4d935674a5aff2f34421d753b4d1a9dea5b12.json rename to prover/crates/lib/prover_dal/.sqlx/query-35a76415cb746d03da31481edc65adefab0bf3abf6853a6d36123c8adcaf813b.json index 14463ecbe426..bf8db798e7d4 100644 --- a/prover/crates/lib/prover_dal/.sqlx/query-75c1affbca0901edd5d0e2f12ef4d935674a5aff2f34421d753b4d1a9dea5b12.json +++ b/prover/crates/lib/prover_dal/.sqlx/query-35a76415cb746d03da31481edc65adefab0bf3abf6853a6d36123c8adcaf813b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n UPDATE scheduler_witness_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n l1_batch_number = $1\n AND attempts >= $2\n AND (status = 'in_progress' OR status = 'failed')\n RETURNING\n l1_batch_number,\n status,\n attempts,\n error,\n picked_by\n ", + "query": "\n UPDATE scheduler_witness_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n l1_batch_number = $1\n AND attempts >= $2\n AND (\n status = 'in_progress'\n OR status = 'failed'\n )\n RETURNING\n l1_batch_number,\n status,\n attempts,\n error,\n picked_by\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ true ] }, - "hash": "75c1affbca0901edd5d0e2f12ef4d935674a5aff2f34421d753b4d1a9dea5b12" + "hash": "35a76415cb746d03da31481edc65adefab0bf3abf6853a6d36123c8adcaf813b" } diff --git a/prover/crates/lib/prover_dal/.sqlx/query-548414f8148740c991c345e5fd46ea738d209eb07e7a6bcbdb33e25b3347a08c.json b/prover/crates/lib/prover_dal/.sqlx/query-3727d5614d2fe2a4d96f880eb72cd48c95ca5b4520dde415a2b5ff32ece47c86.json similarity index 70% rename from prover/crates/lib/prover_dal/.sqlx/query-548414f8148740c991c345e5fd46ea738d209eb07e7a6bcbdb33e25b3347a08c.json rename to prover/crates/lib/prover_dal/.sqlx/query-3727d5614d2fe2a4d96f880eb72cd48c95ca5b4520dde415a2b5ff32ece47c86.json index 8f5b046b974f..d7eb6a32b421 100644 --- a/prover/crates/lib/prover_dal/.sqlx/query-548414f8148740c991c345e5fd46ea738d209eb07e7a6bcbdb33e25b3347a08c.json +++ b/prover/crates/lib/prover_dal/.sqlx/query-3727d5614d2fe2a4d96f880eb72cd48c95ca5b4520dde415a2b5ff32ece47c86.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n UPDATE witness_inputs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n l1_batch_number = $1\n AND attempts >= $2\n AND (status = 'in_progress' OR status = 'failed')\n RETURNING\n l1_batch_number,\n status,\n attempts,\n error,\n picked_by\n ", + "query": "\n UPDATE witness_inputs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n l1_batch_number = $1\n AND attempts >= $2\n AND (\n status = 'in_progress'\n OR status = 'failed'\n )\n RETURNING\n l1_batch_number,\n status,\n attempts,\n error,\n picked_by\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ true ] }, - "hash": "548414f8148740c991c345e5fd46ea738d209eb07e7a6bcbdb33e25b3347a08c" + "hash": "3727d5614d2fe2a4d96f880eb72cd48c95ca5b4520dde415a2b5ff32ece47c86" } diff --git a/prover/crates/lib/prover_dal/.sqlx/query-c19fc4c8e4b3a3ef4f9c0f4c22ed68c598eada8e60938a8e4b5cd32b53f5a574.json b/prover/crates/lib/prover_dal/.sqlx/query-37ad15f54f4a6f4f79c71a857f3a8d4cc59246dda91b19526e73f27a17c8e3da.json similarity index 69% rename from prover/crates/lib/prover_dal/.sqlx/query-c19fc4c8e4b3a3ef4f9c0f4c22ed68c598eada8e60938a8e4b5cd32b53f5a574.json rename to prover/crates/lib/prover_dal/.sqlx/query-37ad15f54f4a6f4f79c71a857f3a8d4cc59246dda91b19526e73f27a17c8e3da.json index 3c4c8d7a29f3..c97fe7f4042b 100644 --- a/prover/crates/lib/prover_dal/.sqlx/query-c19fc4c8e4b3a3ef4f9c0f4c22ed68c598eada8e60938a8e4b5cd32b53f5a574.json +++ b/prover/crates/lib/prover_dal/.sqlx/query-37ad15f54f4a6f4f79c71a857f3a8d4cc59246dda91b19526e73f27a17c8e3da.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n UPDATE recursion_tip_witness_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n l1_batch_number = $1\n AND attempts >= $2\n AND (status = 'in_progress' OR status = 'failed')\n RETURNING\n l1_batch_number,\n status,\n attempts,\n error,\n picked_by\n ", + "query": "\n UPDATE recursion_tip_witness_jobs_fri\n SET\n status = 'queued',\n updated_at = NOW(),\n processing_started_at = NOW()\n WHERE\n l1_batch_number = $1\n AND attempts >= $2\n AND (\n status = 'in_progress'\n OR status = 'failed'\n )\n RETURNING\n l1_batch_number,\n status,\n attempts,\n error,\n picked_by\n ", "describe": { "columns": [ { @@ -43,5 +43,5 @@ true ] }, - "hash": "c19fc4c8e4b3a3ef4f9c0f4c22ed68c598eada8e60938a8e4b5cd32b53f5a574" + "hash": "37ad15f54f4a6f4f79c71a857f3a8d4cc59246dda91b19526e73f27a17c8e3da" } diff --git a/prover/crates/lib/prover_dal/.sqlx/query-39f60c638d445c5dbf23e01fd89a468057599be1e6c6c96a947c33df53a68224.json b/prover/crates/lib/prover_dal/.sqlx/query-39f60c638d445c5dbf23e01fd89a468057599be1e6c6c96a947c33df53a68224.json deleted file mode 100644 index 5cec4d7d7d03..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-39f60c638d445c5dbf23e01fd89a468057599be1e6c6c96a947c33df53a68224.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n recursion_tip_witness_jobs_fri (\n l1_batch_number,\n status,\n number_of_final_node_jobs,\n created_at,\n updated_at\n )\n VALUES\n ($1, 'waiting_for_proofs',1, NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO\n UPDATE\n SET status = $2\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Text" - ] - }, - "nullable": [] - }, - "hash": "39f60c638d445c5dbf23e01fd89a468057599be1e6c6c96a947c33df53a68224" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-3a9ffd4d88f2cfac22835aac2512e61157bf58aec70903623afc9da24d46a336.json b/prover/crates/lib/prover_dal/.sqlx/query-3a9ffd4d88f2cfac22835aac2512e61157bf58aec70903623afc9da24d46a336.json deleted file mode 100644 index 063ae8fc90a3..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-3a9ffd4d88f2cfac22835aac2512e61157bf58aec70903623afc9da24d46a336.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n node_aggregation_witness_jobs_fri (\n l1_batch_number,\n circuit_id,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, 'waiting_for_proofs', NOW(), NOW())\n ON CONFLICT (l1_batch_number, circuit_id, depth) DO\n UPDATE\n SET status = $3\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Int2", - "Text" - ] - }, - "nullable": [] - }, - "hash": "3a9ffd4d88f2cfac22835aac2512e61157bf58aec70903623afc9da24d46a336" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-3bb8fbd9e83703887e0a3c196031b931c0d8dbc6835dfac20107ea7412ce9fbb.json b/prover/crates/lib/prover_dal/.sqlx/query-3bb8fbd9e83703887e0a3c196031b931c0d8dbc6835dfac20107ea7412ce9fbb.json deleted file mode 100644 index 693905084151..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-3bb8fbd9e83703887e0a3c196031b931c0d8dbc6835dfac20107ea7412ce9fbb.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n proof_compression_jobs_fri (\n l1_batch_number,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO\n UPDATE\n SET status = $2\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Text" - ] - }, - "nullable": [] - }, - "hash": "3bb8fbd9e83703887e0a3c196031b931c0d8dbc6835dfac20107ea7412ce9fbb" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-434f7cb51a7d22948cd26e962679a67936d572f8046d3a1c7a4f100ff209d81d.json b/prover/crates/lib/prover_dal/.sqlx/query-434f7cb51a7d22948cd26e962679a67936d572f8046d3a1c7a4f100ff209d81d.json deleted file mode 100644 index 7615523f92f1..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-434f7cb51a7d22948cd26e962679a67936d572f8046d3a1c7a4f100ff209d81d.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE prover_jobs_fri SET status = $1\n WHERE l1_batch_number = $2\n AND sequence_number = $3\n AND aggregation_round = $4\n AND circuit_id = $5", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Text", - "Int8", - "Int4", - "Int2", - "Int2" - ] - }, - "nullable": [] - }, - "hash": "434f7cb51a7d22948cd26e962679a67936d572f8046d3a1c7a4f100ff209d81d" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-73266a8526c6adc315900e2e95441976a264759c4060c1a38e466ee2052fc17d.json b/prover/crates/lib/prover_dal/.sqlx/query-73266a8526c6adc315900e2e95441976a264759c4060c1a38e466ee2052fc17d.json new file mode 100644 index 000000000000..f8b141a8dac9 --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-73266a8526c6adc315900e2e95441976a264759c4060c1a38e466ee2052fc17d.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n recursion_tip_witness_jobs_fri (l1_batch_number, status, number_of_final_node_jobs, created_at, updated_at)\n VALUES\n ($1, 'waiting_for_proofs', 1, NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO\n UPDATE\n SET\n status = $2\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Text" + ] + }, + "nullable": [] + }, + "hash": "73266a8526c6adc315900e2e95441976a264759c4060c1a38e466ee2052fc17d" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-9730c8225ff2cf3111185e81f602a4a98ec63eb942c73ce4448d0957346047cd.json b/prover/crates/lib/prover_dal/.sqlx/query-9730c8225ff2cf3111185e81f602a4a98ec63eb942c73ce4448d0957346047cd.json new file mode 100644 index 000000000000..d23ed8d9fc8a --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-9730c8225ff2cf3111185e81f602a4a98ec63eb942c73ce4448d0957346047cd.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE leaf_aggregation_witness_jobs_fri\n SET\n status = $1,\n attempts = $2\n WHERE\n l1_batch_number = $3\n AND circuit_id = $4\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int2", + "Int8", + "Int2" + ] + }, + "nullable": [] + }, + "hash": "9730c8225ff2cf3111185e81f602a4a98ec63eb942c73ce4448d0957346047cd" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-a817f0fec85388b3e2510ce259208a01b63ae4aa03c983c3a52c802d585e5a80.json b/prover/crates/lib/prover_dal/.sqlx/query-a817f0fec85388b3e2510ce259208a01b63ae4aa03c983c3a52c802d585e5a80.json new file mode 100644 index 000000000000..93532150f7f8 --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-a817f0fec85388b3e2510ce259208a01b63ae4aa03c983c3a52c802d585e5a80.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n proof_compression_jobs_fri (l1_batch_number, status, created_at, updated_at)\n VALUES\n ($1, $2, NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO\n UPDATE\n SET\n status = $2\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Text" + ] + }, + "nullable": [] + }, + "hash": "a817f0fec85388b3e2510ce259208a01b63ae4aa03c983c3a52c802d585e5a80" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-aabcfa9005b8e1d84cfa083a47a700302981be0afef31a8864613484f8521f9e.json b/prover/crates/lib/prover_dal/.sqlx/query-aabcfa9005b8e1d84cfa083a47a700302981be0afef31a8864613484f8521f9e.json deleted file mode 100644 index 3d60050c92ed..000000000000 --- a/prover/crates/lib/prover_dal/.sqlx/query-aabcfa9005b8e1d84cfa083a47a700302981be0afef31a8864613484f8521f9e.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE prover_jobs_fri \n SET status = $1, attempts = $2\n WHERE l1_batch_number = $3\n AND sequence_number =$4\n AND aggregation_round = $5\n AND circuit_id = $6", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Text", - "Int2", - "Int8", - "Int4", - "Int2", - "Int2" - ] - }, - "nullable": [] - }, - "hash": "aabcfa9005b8e1d84cfa083a47a700302981be0afef31a8864613484f8521f9e" -} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-c8daa62b3835c15fafb3f83deabb5a4672ad50a9de92c84d939ac4c69842e355.json b/prover/crates/lib/prover_dal/.sqlx/query-c8daa62b3835c15fafb3f83deabb5a4672ad50a9de92c84d939ac4c69842e355.json new file mode 100644 index 000000000000..cadc931fa1ca --- /dev/null +++ b/prover/crates/lib/prover_dal/.sqlx/query-c8daa62b3835c15fafb3f83deabb5a4672ad50a9de92c84d939ac4c69842e355.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO\n node_aggregation_witness_jobs_fri (l1_batch_number, circuit_id, status, created_at, updated_at)\n VALUES\n ($1, $2, 'waiting_for_proofs', NOW(), NOW())\n ON CONFLICT (l1_batch_number, circuit_id, depth) DO\n UPDATE\n SET\n status = $3\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Int2", + "Text" + ] + }, + "nullable": [] + }, + "hash": "c8daa62b3835c15fafb3f83deabb5a4672ad50a9de92c84d939ac4c69842e355" +} diff --git a/prover/crates/lib/prover_dal/.sqlx/query-63cf7038e6c48af8ed9afc7d6ea07edd87cb16a79c13e7d4291d99736e51d3b9.json b/prover/crates/lib/prover_dal/.sqlx/query-e875dcbbdaed6998dbea45d4eab5d005d8760c4809b7aef902155196873da66e.json similarity index 82% rename from prover/crates/lib/prover_dal/.sqlx/query-63cf7038e6c48af8ed9afc7d6ea07edd87cb16a79c13e7d4291d99736e51d3b9.json rename to prover/crates/lib/prover_dal/.sqlx/query-e875dcbbdaed6998dbea45d4eab5d005d8760c4809b7aef902155196873da66e.json index 208b23d939f8..4ee9278fe42a 100644 --- a/prover/crates/lib/prover_dal/.sqlx/query-63cf7038e6c48af8ed9afc7d6ea07edd87cb16a79c13e7d4291d99736e51d3b9.json +++ b/prover/crates/lib/prover_dal/.sqlx/query-e875dcbbdaed6998dbea45d4eab5d005d8760c4809b7aef902155196873da66e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n scheduler_witness_jobs_fri (\n l1_batch_number,\n scheduler_partial_input_blob_url,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, '', 'waiting_for_proofs', NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO\n UPDATE\n SET status = $2\n ", + "query": "\n INSERT INTO\n scheduler_witness_jobs_fri (\n l1_batch_number,\n scheduler_partial_input_blob_url,\n status,\n created_at,\n updated_at\n )\n VALUES\n ($1, '', 'waiting_for_proofs', NOW(), NOW())\n ON CONFLICT (l1_batch_number) DO\n UPDATE\n SET\n status = $2\n ", "describe": { "columns": [], "parameters": { @@ -11,5 +11,5 @@ }, "nullable": [] }, - "hash": "63cf7038e6c48af8ed9afc7d6ea07edd87cb16a79c13e7d4291d99736e51d3b9" + "hash": "e875dcbbdaed6998dbea45d4eab5d005d8760c4809b7aef902155196873da66e" } diff --git a/prover/crates/lib/prover_dal/.sqlx/query-0eac6f7b2d799059328584029b437891598dc79b5ed11258b2c90c3f282929ad.json b/prover/crates/lib/prover_dal/.sqlx/query-eec29cbff034818f4fb5ec1e6ad38e1010d7389457b3c97e9b238a3a0291a54e.json similarity index 78% rename from prover/crates/lib/prover_dal/.sqlx/query-0eac6f7b2d799059328584029b437891598dc79b5ed11258b2c90c3f282929ad.json rename to prover/crates/lib/prover_dal/.sqlx/query-eec29cbff034818f4fb5ec1e6ad38e1010d7389457b3c97e9b238a3a0291a54e.json index 61518273b4d3..f8e92b1ad666 100644 --- a/prover/crates/lib/prover_dal/.sqlx/query-0eac6f7b2d799059328584029b437891598dc79b5ed11258b2c90c3f282929ad.json +++ b/prover/crates/lib/prover_dal/.sqlx/query-eec29cbff034818f4fb5ec1e6ad38e1010d7389457b3c97e9b238a3a0291a54e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n leaf_aggregation_witness_jobs_fri (\n l1_batch_number,\n circuit_id,\n status,\n number_of_basic_circuits,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, 'waiting_for_proofs', 2, NOW(), NOW())\n ON CONFLICT (l1_batch_number, circuit_id) DO\n UPDATE\n SET status = $3\n ", + "query": "\n INSERT INTO\n leaf_aggregation_witness_jobs_fri (\n l1_batch_number,\n circuit_id,\n status,\n number_of_basic_circuits,\n created_at,\n updated_at\n )\n VALUES\n ($1, $2, 'waiting_for_proofs', 2, NOW(), NOW())\n ON CONFLICT (l1_batch_number, circuit_id) DO\n UPDATE\n SET\n status = $3\n ", "describe": { "columns": [], "parameters": { @@ -12,5 +12,5 @@ }, "nullable": [] }, - "hash": "0eac6f7b2d799059328584029b437891598dc79b5ed11258b2c90c3f282929ad" + "hash": "eec29cbff034818f4fb5ec1e6ad38e1010d7389457b3c97e9b238a3a0291a54e" } From 9290db86d2a7202f9eb3f41e1f51fa3566e3492c Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Thu, 26 Sep 2024 10:49:35 +0200 Subject: [PATCH 3/9] bumped consensus deps --- Cargo.lock | 40 ++++++++++++++++++++++++++++++---------- Cargo.toml | 20 ++++++++++---------- prover/Cargo.lock | 40 +++++++++++++++++++++------------------- zk_toolbox/Cargo.lock | 40 ++++++++++++++++++---------------------- zk_toolbox/Cargo.toml | 6 +++--- 5 files changed, 82 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f8fd55bd6a2..c04c4269a4e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9304,7 +9304,9 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4724d51934e475c846ba9e6ed169e25587385188b928a9ecfbbf616092a1c17" dependencies = [ "anyhow", "once_cell", @@ -9339,7 +9341,9 @@ dependencies = [ [[package]] name = "zksync_consensus_bft" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e7199c07aa14d9c3319839b98ad0496aac6e72327e70ded77ddb66329766db" dependencies = [ "anyhow", "async-trait", @@ -9359,7 +9363,9 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7760e7a140f16f0435fbf2ad9a4b09feaad74568d05b553751d222f4803a42e" dependencies = [ "anyhow", "blst", @@ -9378,7 +9384,9 @@ dependencies = [ [[package]] name = "zksync_consensus_executor" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db07f7329b29737d8fd6860b350c809ae1b56ad53e26a7d0eddf3664ccb9dacb" dependencies = [ "anyhow", "async-trait", @@ -9398,7 +9406,9 @@ dependencies = [ [[package]] name = "zksync_consensus_network" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89a2d60db1ccd41438d29724a8d0d57fcf9506eb4443ea4b9205fd78c9c8e59" dependencies = [ "anyhow", "async-trait", @@ -9432,7 +9442,9 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96f903187836210602beba27655e111e22efb229ef90bd2a95a3d6799b31685c" dependencies = [ "anyhow", "bit-vec", @@ -9452,7 +9464,9 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff43cfd03ea205c763e74362dc6ec5a4d74b6b1baef0fb134dde92a8880397f7" dependencies = [ "anyhow", "async-trait", @@ -9470,7 +9484,9 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1020308512c01ab80327fb874b5b61c6fd513a6b26c8a5fce3e077600da04e4b" dependencies = [ "anyhow", "rand 0.8.5", @@ -10498,7 +10514,9 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2d9ce9b9697daae6023c8da5cfe8764690a9d9c91ff32b8e1e54a7c8301fb3" dependencies = [ "anyhow", "bit-vec", @@ -10517,7 +10535,9 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903c23a12e160a703f9b68d0dd961daa24156af912ca1bc9efb74969f3acc645" dependencies = [ "anyhow", "heck 0.5.0", diff --git a/Cargo.toml b/Cargo.toml index d1e02092ec5f..297565a0fe05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -230,16 +230,16 @@ zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.5" } zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "74577d9be13b1bff9d1a712389731f669b179e47" } # Consensus dependencies. -zksync_concurrency = "=0.2.0" -zksync_consensus_bft = "=0.2.0" -zksync_consensus_crypto = "=0.2.0" -zksync_consensus_executor = "=0.2.0" -zksync_consensus_network = "=0.2.0" -zksync_consensus_roles = "=0.2.0" -zksync_consensus_storage = "=0.2.0" -zksync_consensus_utils = "=0.2.0" -zksync_protobuf = "=0.2.0" -zksync_protobuf_build = "=0.2.0" +zksync_concurrency = "=0.3.0" +zksync_consensus_bft = "=0.3.0" +zksync_consensus_crypto = "=0.3.0" +zksync_consensus_executor = "=0.3.0" +zksync_consensus_network = "=0.3.0" +zksync_consensus_roles = "=0.3.0" +zksync_consensus_storage = "=0.3.0" +zksync_consensus_utils = "=0.3.0" +zksync_protobuf = "=0.3.0" +zksync_protobuf_build = "=0.3.0" # "Local" dependencies zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" } diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 2fe2f4404544..4ef02a2f2d88 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -7379,7 +7379,9 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4724d51934e475c846ba9e6ed169e25587385188b928a9ecfbbf616092a1c17" dependencies = [ "anyhow", "once_cell", @@ -7413,7 +7415,9 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7760e7a140f16f0435fbf2ad9a4b09feaad74568d05b553751d222f4803a42e" dependencies = [ "anyhow", "blst", @@ -7432,7 +7436,9 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96f903187836210602beba27655e111e22efb229ef90bd2a95a3d6799b31685c" dependencies = [ "anyhow", "bit-vec", @@ -7452,7 +7458,9 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff43cfd03ea205c763e74362dc6ec5a4d74b6b1baef0fb134dde92a8880397f7" dependencies = [ "anyhow", "async-trait", @@ -7470,7 +7478,9 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1020308512c01ab80327fb874b5b61c6fd513a6b26c8a5fce3e077600da04e4b" dependencies = [ "anyhow", "rand 0.8.5", @@ -7776,7 +7786,9 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2d9ce9b9697daae6023c8da5cfe8764690a9d9c91ff32b8e1e54a7c8301fb3" dependencies = [ "anyhow", "bit-vec", @@ -7795,7 +7807,9 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903c23a12e160a703f9b68d0dd961daa24156af912ca1bc9efb74969f3acc645" dependencies = [ "anyhow", "heck 0.5.0", @@ -8225,15 +8239,3 @@ dependencies = [ "zksync_utils", "zksync_vlog", ] - -[[patch.unused]] -name = "zksync_consensus_bft" -version = "0.2.0" - -[[patch.unused]] -name = "zksync_consensus_executor" -version = "0.2.0" - -[[patch.unused]] -name = "zksync_consensus_network" -version = "0.2.0" diff --git a/zk_toolbox/Cargo.lock b/zk_toolbox/Cargo.lock index 99c47b28abcc..963eb93d6e5a 100644 --- a/zk_toolbox/Cargo.lock +++ b/zk_toolbox/Cargo.lock @@ -6443,7 +6443,9 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4724d51934e475c846ba9e6ed169e25587385188b928a9ecfbbf616092a1c17" dependencies = [ "anyhow", "once_cell", @@ -6475,7 +6477,9 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7760e7a140f16f0435fbf2ad9a4b09feaad74568d05b553751d222f4803a42e" dependencies = [ "anyhow", "blst", @@ -6494,7 +6498,9 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96f903187836210602beba27655e111e22efb229ef90bd2a95a3d6799b31685c" dependencies = [ "anyhow", "bit-vec", @@ -6514,7 +6520,9 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1020308512c01ab80327fb874b5b61c6fd513a6b26c8a5fce3e077600da04e4b" dependencies = [ "anyhow", "rand", @@ -6563,7 +6571,9 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2d9ce9b9697daae6023c8da5cfe8764690a9d9c91ff32b8e1e54a7c8301fb3" dependencies = [ "anyhow", "bit-vec", @@ -6582,7 +6592,9 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903c23a12e160a703f9b68d0dd961daa24156af912ca1bc9efb74969f3acc645" dependencies = [ "anyhow", "heck", @@ -6731,19 +6743,3 @@ dependencies = [ "cc", "pkg-config", ] - -[[patch.unused]] -name = "zksync_consensus_bft" -version = "0.2.0" - -[[patch.unused]] -name = "zksync_consensus_executor" -version = "0.2.0" - -[[patch.unused]] -name = "zksync_consensus_network" -version = "0.2.0" - -[[patch.unused]] -name = "zksync_consensus_storage" -version = "0.2.0" diff --git a/zk_toolbox/Cargo.toml b/zk_toolbox/Cargo.toml index eccb1657a50f..b6a8f509b019 100644 --- a/zk_toolbox/Cargo.toml +++ b/zk_toolbox/Cargo.toml @@ -32,9 +32,9 @@ git_version_macro = { path = "crates/git_version_macro" } zksync_config = { path = "../core/lib/config" } zksync_protobuf_config = { path = "../core/lib/protobuf_config" } zksync_basic_types = { path = "../core/lib/basic_types" } -zksync_consensus_roles = "=0.2.0" -zksync_consensus_crypto = "=0.2.0" -zksync_protobuf = "=0.2.0" +zksync_consensus_roles = "=0.3.0" +zksync_consensus_crypto = "=0.3.0" +zksync_protobuf = "=0.3.0" # External dependencies anyhow = "1.0.82" From c4b2ebc84b88451ee1f2e9f9e6f74b6856d13e29 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Thu, 26 Sep 2024 11:46:33 +0200 Subject: [PATCH 4/9] test for reconfiguration --- core/lib/dal/src/consensus_dal.rs | 2 +- core/node/consensus/src/tests/mod.rs | 81 +++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/core/lib/dal/src/consensus_dal.rs b/core/lib/dal/src/consensus_dal.rs index 3e85fb4419d0..f2e499ce562e 100644 --- a/core/lib/dal/src/consensus_dal.rs +++ b/core/lib/dal/src/consensus_dal.rs @@ -502,7 +502,7 @@ impl ConsensusDal<'_, '_> { committee: &attester::Committee, ) -> anyhow::Result<()> { let committee = zksync_protobuf::serde::Serialize - .proto_repr::(&committee, serde_json::value::Serializer) + .proto_repr::(committee, serde_json::value::Serializer) .unwrap(); sqlx::query!( r#" diff --git a/core/node/consensus/src/tests/mod.rs b/core/node/consensus/src/tests/mod.rs index aabfff462a81..262d990cd84f 100644 --- a/core/node/consensus/src/tests/mod.rs +++ b/core/node/consensus/src/tests/mod.rs @@ -1,9 +1,12 @@ use anyhow::Context as _; +use rand::Rng as _; use test_casing::{test_casing, Product}; use tracing::Instrument as _; -use zksync_concurrency::{ctx, error::Wrap, scope}; +use zksync_concurrency::{ctx, error::Wrap as _, scope}; +use zksync_config::configs::consensus as config; +use zksync_consensus_crypto::TextFmt as _; use zksync_consensus_roles::{ - validator, + node, validator, validator::testonly::{Setup, SetupSpec}, }; use zksync_consensus_storage::BlockStore; @@ -242,6 +245,80 @@ async fn test_nodes_from_various_snapshots(version: ProtocolVersionId) { .unwrap(); } +#[test_casing(4, Product((FROM_SNAPSHOT,VERSIONS)))] +#[tokio::test] +async fn test_config_change(from_snapshot: bool, version: ProtocolVersionId) { + zksync_concurrency::testonly::abort_on_panic(); + let ctx = &ctx::test_root(&ctx::AffineClock::new(10.)); + let rng = &mut ctx.rng(); + let setup = Setup::new(rng, 1); + let mut validator_cfg = testonly::new_configs(rng, &setup, 0)[0].clone(); + let node_cfg = validator_cfg.new_fullnode(rng); + let account = &mut Account::random(); + + let validator_pool = ConnectionPool::test(from_snapshot, version).await; + let node_pool = ConnectionPool::test(from_snapshot, version).await; + + for i in 0..3 { + tracing::info!("iteration {i}"); + tracing::info!("apply an arbitrary change to configuration"); + validator_cfg + .config + .genesis_spec + .as_mut() + .unwrap() + .seed_peers + .insert( + config::NodePublicKey(rng.gen::().encode()), + config::Host("43.54.22.88:7634".to_string()), + ); + scope::run!(ctx, |ctx, s| async { + let (mut validator, runner) = + testonly::StateKeeper::new(ctx, validator_pool.clone()).await?; + s.spawn_bg(async { + runner + .run(ctx) + .instrument(tracing::info_span!("validator")) + .await + .context("validator") + }); + // API server needs at least 1 L1 batch to start. + validator.seal_batch().await; + validator_pool + .wait_for_payload(ctx, validator.last_block()) + .await?; + + tracing::info!("Run validator."); + s.spawn_bg(run_main_node( + ctx, + validator_cfg.config.clone(), + validator_cfg.secrets.clone(), + validator_pool.clone(), + )); + + tracing::info!("Run node."); + let (node, runner) = testonly::StateKeeper::new(ctx, node_pool.clone()).await?; + s.spawn_bg(runner.run(ctx).instrument(tracing::info_span!("node"))); + s.spawn_bg(node.run_consensus(ctx, validator.connect(ctx).await?, node_cfg.clone())); + + validator.push_random_blocks(rng, account, 5).await; + let want_last = validator.last_block(); + let want = validator_pool + .wait_for_block_certificates_and_verify(ctx, want_last) + .await?; + assert_eq!( + want, + node_pool + .wait_for_block_certificates_and_verify(ctx, want_last) + .await? + ); + Ok(()) + }) + .await + .unwrap(); + } +} + // Test running a validator node and a couple of full nodes. // Validator is producing signed blocks and fetchers are expected to fetch // them directly or indirectly. From e0766211ea4c241a6bdb6fb35115e11e9e5c7f20 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Thu, 26 Sep 2024 12:05:00 +0200 Subject: [PATCH 5/9] zk lint --- core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs b/core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs index 9aeb9c02af64..eb2170bcc848 100644 --- a/core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs +++ b/core/lib/zksync_core_leftovers/src/temp_config_store/mod.rs @@ -28,7 +28,7 @@ use zksync_protobuf_config::proto::secrets::Secrets; pub fn read_yaml_repr(path: &PathBuf) -> anyhow::Result { (|| { - let yaml = std::fs::read_to_string(&path)?; + let yaml = std::fs::read_to_string(path)?; zksync_protobuf::serde::Deserialize { deny_unknown_fields: false, } From be325d0f0ded08298a4d83594cbbc5e04368ff05 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Thu, 26 Sep 2024 12:21:34 +0200 Subject: [PATCH 6/9] zk lint --- core/bin/external_node/src/config/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs index 8b7f127d77d8..78d045f211ed 100644 --- a/core/bin/external_node/src/config/mod.rs +++ b/core/bin/external_node/src/config/mod.rs @@ -1260,7 +1260,7 @@ impl ExternalNodeConfig<()> { .context("failed decoding secrets YAML config")?; let consensus = consensus_config_path - .map(|path| read_yaml_repr::(&path.into())) + .map(|path| read_yaml_repr::(&path)) .transpose() .context("failed decoding consensus YAML config")?; let consensus_secrets = secrets_config.consensus.clone(); From 61f50d346bc6b4dfa9a31577980bb12081f9249d Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Thu, 26 Sep 2024 15:11:20 +0200 Subject: [PATCH 7/9] fixed waiting for the global config to be set --- core/node/consensus/src/tests/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/node/consensus/src/tests/mod.rs b/core/node/consensus/src/tests/mod.rs index 262d990cd84f..52abe3c810c5 100644 --- a/core/node/consensus/src/tests/mod.rs +++ b/core/node/consensus/src/tests/mod.rs @@ -282,12 +282,6 @@ async fn test_config_change(from_snapshot: bool, version: ProtocolVersionId) { .await .context("validator") }); - // API server needs at least 1 L1 batch to start. - validator.seal_batch().await; - validator_pool - .wait_for_payload(ctx, validator.last_block()) - .await?; - tracing::info!("Run validator."); s.spawn_bg(run_main_node( ctx, @@ -296,6 +290,12 @@ async fn test_config_change(from_snapshot: bool, version: ProtocolVersionId) { validator_pool.clone(), )); + // Wait for the main node to start and to update the global config. + validator.seal_batch().await; + validator_pool + .wait_for_block_certificate(ctx, validator.last_block()) + .await?; + tracing::info!("Run node."); let (node, runner) = testonly::StateKeeper::new(ctx, node_pool.clone()).await?; s.spawn_bg(runner.run(ctx).instrument(tracing::info_span!("node"))); From a97ca305eabd41fa69533bb854b91cbb6f215e43 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Thu, 26 Sep 2024 15:47:25 +0200 Subject: [PATCH 8/9] removed yanked crates --- Cargo.lock | 8 ++++---- prover/Cargo.lock | 4 ++-- zk_toolbox/Cargo.lock | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd79e22f7a38..4993bc6a8d0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -987,9 +987,9 @@ dependencies = [ [[package]] name = "bytecount" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1a12477b7237a01c11a80a51278165f9ba0edd28fa6db00a65ab230320dc58c" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" [[package]] name = "byteorder" @@ -999,9 +999,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "bytesize" diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 4ef02a2f2d88..c48a6ce848a3 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -739,9 +739,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cc" diff --git a/zk_toolbox/Cargo.lock b/zk_toolbox/Cargo.lock index 963eb93d6e5a..eee728182ccb 100644 --- a/zk_toolbox/Cargo.lock +++ b/zk_toolbox/Cargo.lock @@ -451,9 +451,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] From 29512aa5c4f01073948d4eef95aa4ce354d9c07c Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Thu, 26 Sep 2024 16:21:33 +0200 Subject: [PATCH 9/9] atty --- deny.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/deny.toml b/deny.toml index c2775fc057c8..2542a7df6b94 100644 --- a/deny.toml +++ b/deny.toml @@ -12,6 +12,7 @@ ignore = [ "RUSTSEC-2020-0168", # mach dependency being unmaintained, dependency in consensus, we should consider moving to mach2 fork "RUSTSEC-2024-0370", # `cs_derive` needs to be updated to not rely on `proc-macro-error` # all below caused by StructOpt which we still use and we should move to clap v3 instead + "RUSTSEC-2024-0375", "RUSTSEC-2021-0145", "RUSTSEC-2021-0139", ]