From cbee99d8661b38aa6b49784c3934b8070a743fb4 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Thu, 19 Dec 2024 16:58:31 +0400 Subject: [PATCH] feat: Support stable compiler for VM (and some other crates) (#3248) tbd --------- Co-authored-by: zksync-admin-bot2 <91326834+zksync-admin-bot2@users.noreply.github.com> Co-authored-by: Lech <88630083+Artemka374@users.noreply.github.com> --- Cargo.lock | 238 +++------------ Cargo.toml | 13 +- core/lib/multivm/Cargo.toml | 6 +- .../src/glue/types/vm/vm_block_result.rs | 44 +-- core/lib/multivm/src/lib.rs | 2 +- core/lib/multivm/src/utils/mod.rs | 17 +- .../src/versions/testonly/precompiles.rs | 12 +- .../src/versions/vm_1_3_2/pubdata_utils.rs | 16 +- .../versions/vm_1_3_2/vm_with_bootloader.rs | 2 +- .../vm_1_4_1/tracers/circuits_capacity.rs | 4 +- .../vm_1_4_1/tracers/pubdata_tracer.rs | 5 +- .../vm_1_4_1/types/internals/vm_state.rs | 2 +- core/lib/multivm/src/versions/vm_1_4_1/vm.rs | 12 +- .../src/versions/vm_1_4_2/constants.rs | 2 +- .../vm_1_4_2/tracers/circuits_capacity.rs | 4 +- .../vm_1_4_2/tracers/pubdata_tracer.rs | 5 +- .../vm_1_4_2/types/internals/vm_state.rs | 2 +- core/lib/multivm/src/versions/vm_1_4_2/vm.rs | 12 +- .../tracers/circuits_capacity.rs | 4 +- .../tracers/pubdata_tracer.rs | 5 +- .../types/internals/vm_state.rs | 2 +- .../src/versions/vm_boojum_integration/vm.rs | 12 +- .../src/versions/vm_fast/tracers/circuits.rs | 4 +- .../src/versions/vm_latest/constants.rs | 2 +- .../vm_latest/tracers/circuits_capacity.rs | 4 +- .../vm_latest/tracers/pubdata_tracer.rs | 4 +- .../vm_latest/types/internals/vm_state.rs | 2 +- core/lib/multivm/src/versions/vm_latest/vm.rs | 4 +- .../src/versions/vm_m5/pubdata_utils.rs | 14 +- .../src/versions/vm_m5/vm_with_bootloader.rs | 2 +- .../src/versions/vm_m6/pubdata_utils.rs | 14 +- .../src/versions/vm_m6/vm_with_bootloader.rs | 2 +- .../types/internals/vm_state.rs | 2 +- .../src/versions/vm_refunds_enhancement/vm.rs | 11 +- .../vm_virtual_blocks/tracers/refunds.rs | 10 +- .../types/internals/vm_state.rs | 2 +- .../src/versions/vm_virtual_blocks/vm.rs | 11 +- core/lib/prover_interface/Cargo.toml | 2 +- core/lib/prover_interface/src/outputs.rs | 2 +- .../tests/job_serialization.rs | 2 +- core/lib/state/src/storage_overrides.rs | 0 core/lib/utils/Cargo.toml | 1 + .../src/web3/namespaces/unstable/utils.rs | 3 +- core/node/commitment_generator/Cargo.toml | 6 +- core/node/commitment_generator/src/utils.rs | 103 +------ core/node/genesis/src/utils.rs | 2 +- prover/Cargo.lock | 287 +++++------------- prover/Cargo.toml | 11 +- .../src/gpu_prover_job_processor.rs | 4 +- prover/crates/bin/prover_fri/src/lib.rs | 2 +- prover/crates/bin/prover_fri/src/main.rs | 2 +- .../src/rounds/basic_circuits/mod.rs | 2 +- .../src/rounds/basic_circuits/utils.rs | 10 +- .../lib/circuit_prover_service/src/lib.rs | 2 +- .../src/types/circuit.rs | 6 +- prover/crates/lib/keystore/Cargo.toml | 3 +- prover/crates/lib/keystore/src/lib.rs | 13 +- .../lib/keystore/src/setup_data_generator.rs | 39 ++- prover/setup-data-gpu-keys.json | 6 +- zkstack_cli/Cargo.lock | 26 +- 60 files changed, 359 insertions(+), 684 deletions(-) delete mode 100644 core/lib/state/src/storage_overrides.rs diff --git a/Cargo.lock b/Cargo.lock index 71ca2e960995..019e2afdf334 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1289,9 +1289,9 @@ dependencies = [ [[package]] name = "boojum" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ec2f007ff8f90cc459f03e9f30ca1065440170f013c868823646e2e48d0234" +checksum = "4337dc7b196fc3e5e55e2857bc21638b7441429ee1a953201a9cd2be187b764e" dependencies = [ "arrayvec 0.7.6", "bincode", @@ -1690,117 +1690,26 @@ dependencies = [ [[package]] name = "circuit_encodings" -version = "0.140.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6b7cc842eadb4c250cdc6a8bc1dd97624d9f08bbe54db3e11fb23c3a72be07" -dependencies = [ - "derivative", - "serde", - "zk_evm 0.140.0", - "zkevm_circuits 0.140.3", -] - -[[package]] -name = "circuit_encodings" -version = "0.141.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7898ffbf3cd413576b4b674fe1545a35488c67eb16bd5a4148425e42c2a2b65b" -dependencies = [ - "derivative", - "serde", - "zk_evm 0.141.0", - "zkevm_circuits 0.141.2", -] - -[[package]] -name = "circuit_encodings" -version = "0.142.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8364ecafcc4b2c896023f8d3af952c52a500aa55f14fd268bb5d9ab07f837369" -dependencies = [ - "derivative", - "serde", - "zk_evm 0.141.0", - "zkevm_circuits 0.141.2", -] - -[[package]] -name = "circuit_encodings" -version = "0.150.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2501cc688ef391013019495ae7035cfd54f86987e36d10f73976ce4c5d413c5a" -dependencies = [ - "derivative", - "serde", - "zk_evm 0.150.7", - "zkevm_circuits 0.150.7", -] - -[[package]] -name = "circuit_sequencer_api" -version = "0.133.1" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb959b1f8c6bbd8be711994d182e85452a26a5d2213a709290b71c8262af1331" +checksum = "e3dcfcb4aaa17e6a81ebd2db688d980aff50aa643d9b506d4d11c84976dbc03f" dependencies = [ "derivative", - "rayon", "serde", - "zk_evm 0.133.0", - "zksync_bellman", + "zk_evm 0.150.18", + "zkevm_circuits", ] [[package]] name = "circuit_sequencer_api" -version = "0.140.3" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5f22311ce609d852d7d9f4943535ea4610aeb785129ae6ff83d5201c4fb387" +checksum = "d13ed70909e8390a4f2599d5a76d9ac4189e5bbbf16146d11b7999788740f291" dependencies = [ - "circuit_encodings 0.140.3", - "derivative", - "rayon", - "serde", - "zk_evm 0.140.0", - "zksync_bellman", -] - -[[package]] -name = "circuit_sequencer_api" -version = "0.141.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c47c71d6ba83a8beb0af13af70beffd627f5497caf3d44c6f96363e788b07ea" -dependencies = [ - "circuit_encodings 0.141.2", - "derivative", - "rayon", - "serde", - "zk_evm 0.141.0", - "zksync_bellman", -] - -[[package]] -name = "circuit_sequencer_api" -version = "0.142.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e264723359e6a1aad98110bdccf1ae3ad596e93e7d31da9e40f6adc07e4add54" -dependencies = [ - "circuit_encodings 0.142.2", - "derivative", - "rayon", - "serde", - "zk_evm 0.141.0", - "zksync_bellman", -] - -[[package]] -name = "circuit_sequencer_api" -version = "0.150.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917d27db531fdd98a51e42ea465bc097f48cc849e7fad68d7856087d15125be1" -dependencies = [ - "circuit_encodings 0.150.7", "derivative", "rayon", "serde", + "zk_evm 0.150.18", "zksync_bellman", ] @@ -3332,9 +3241,9 @@ dependencies = [ [[package]] name = "franklin-crypto" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "971289216ea5c91872e5e0bb6989214b537bbce375d09fabea5c3ccfe031b204" +checksum = "5c128e2cf791053b3aefdd7b07d6e5ffdc7cf5dd779ca270d727a403057dfb68" dependencies = [ "arr_macro", "bit-vec", @@ -7318,9 +7227,9 @@ dependencies = [ [[package]] name = "rescue_poseidon" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82900c877a0ba5362ac5756efbd82c5b795dc509011c1253e2389d8708f1389d" +checksum = "b62e4ce7543582ab2df1d9544674a55897e168a23afe938a57e1547d2981a7f4" dependencies = [ "addchain", "arrayvec 0.7.6", @@ -11208,9 +11117,9 @@ dependencies = [ [[package]] name = "zk_evm" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc74fbe2b45fd19e95c59ea792c795feebdb616ebaa463f0ac567f495f47387" +checksum = "3278d0f75408ab35d25998e1124124cd108b48b2a81ed8e71e892ddc5a6be0aa" dependencies = [ "anyhow", "lazy_static", @@ -11218,7 +11127,7 @@ dependencies = [ "serde", "serde_json", "static_assertions", - "zk_evm_abstractions 0.150.7", + "zk_evm_abstractions 0.150.18", ] [[package]] @@ -11249,25 +11158,24 @@ dependencies = [ [[package]] name = "zk_evm_abstractions" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37f333a3b059899df09e40deb041af881bc03e496fda5eec618ffb5e854ee7df" +checksum = "88b4e5a89cfe1594b6476be16c8c1d45f22ce12bff31c49e077b381a398edd8a" dependencies = [ "anyhow", "num_enum 0.6.1", "serde", "static_assertions", - "zkevm_opcode_defs 0.150.7", + "zkevm_opcode_defs 0.150.18", ] [[package]] name = "zkevm_circuits" -version = "0.140.3" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c365c801e0c6eda83fbd153df45575172beb406bfb663d386f9154b4325eda" +checksum = "8b94288d2e246aecd6eecd22ef27db0d1f29a91cb4f59b9e339a45237131a9ff" dependencies = [ "arrayvec 0.7.6", - "bincode", "boojum", "derivative", "hex", @@ -11276,51 +11184,8 @@ dependencies = [ "rand 0.8.5", "seq-macro", "serde", - "serde_json", "smallvec", - "zkevm_opcode_defs 0.132.0", - "zksync_cs_derive", -] - -[[package]] -name = "zkevm_circuits" -version = "0.141.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccd0352e122a4e6f0046d2163b7e692e627b23fc3264faa77331a21b65833fd" -dependencies = [ - "arrayvec 0.7.6", - "bincode", - "boojum", - "derivative", - "hex", - "itertools 0.10.5", - "rand 0.4.6", - "rand 0.8.5", - "seq-macro", - "serde", - "serde_json", - "smallvec", - "zkevm_opcode_defs 0.141.0", - "zksync_cs_derive", -] - -[[package]] -name = "zkevm_circuits" -version = "0.150.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06fb35b00699d25175a2ad447f86a9088af8b0bc698bb57086fb04c13e52eab" -dependencies = [ - "arrayvec 0.7.6", - "boojum", - "derivative", - "hex", - "itertools 0.10.5", - "rand 0.4.6", - "rand 0.8.5", - "seq-macro", - "serde", - "smallvec", - "zkevm_opcode_defs 0.150.7", + "zkevm_opcode_defs 0.150.18", "zksync_cs_derive", ] @@ -11368,9 +11233,9 @@ dependencies = [ [[package]] name = "zkevm_opcode_defs" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b83f3b279248af4ca86dec20a54127f02110b45570f3f6c1d13df49ba75c28a5" +checksum = "5bad437d4891536fdcc0054a3f04562c408817ff19d83b6c27569217692e6e74" dependencies = [ "bitflags 2.6.0", "blake2 0.10.6", @@ -11429,9 +11294,9 @@ dependencies = [ [[package]] name = "zksync_bellman" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffa03efe9bdb137a4b36b97d1a74237e18c9ae42b755163d903a9d48c1a5d80" +checksum = "6b7c0061db44757522f2d82cad02f45dc98267210ac362071234ed08e30fd4d6" dependencies = [ "arrayvec 0.7.6", "bit-vec", @@ -11493,9 +11358,7 @@ name = "zksync_commitment_generator" version = "0.1.0" dependencies = [ "anyhow", - "circuit_sequencer_api 0.140.3", - "circuit_sequencer_api 0.141.2", - "circuit_sequencer_api 0.150.7", + "circuit_encodings", "futures 0.3.31", "itertools 0.10.5", "num_cpus", @@ -11505,9 +11368,7 @@ dependencies = [ "tokio", "tracing", "vise", - "zk_evm 0.133.0", - "zk_evm 0.141.0", - "zk_evm 0.150.7", + "zk_evm 0.150.18", "zksync_contracts", "zksync_dal", "zksync_eth_client", @@ -11852,9 +11713,9 @@ dependencies = [ [[package]] name = "zksync_cs_derive" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5939e2df4288c263c706ff18ac718e984149223ad4289d6d957d767dcfc04c81" +checksum = "63296ce43c432d5d0111604173e874b2f2a856e1cb1c76378fa0bb5ac6018c27" dependencies = [ "proc-macro-error", "proc-macro2 1.0.92", @@ -12181,9 +12042,9 @@ dependencies = [ [[package]] name = "zksync_ff" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9524b06780b5e164e84b38840c7c428c739f051f35af6efc4d1285f629ceb88e" +checksum = "e6a500c97d9286f73540c26b63ae33b159bd48fec0c8bd206b4a9b4fe1217b8a" dependencies = [ "byteorder", "hex", @@ -12194,9 +12055,9 @@ dependencies = [ [[package]] name = "zksync_ff_derive" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f91e58e75d65877f09f83bc3dca8f054847ae7ec4f3e64bfa610a557edd8e8e" +checksum = "97bd48f18ebf350623093022d86be2f1ce23af332efa91890b751209aec8617a" dependencies = [ "num-bigint 0.4.6", "num-integer", @@ -12239,9 +12100,9 @@ dependencies = [ [[package]] name = "zksync_kzg" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc58af8e4e4ad1a851ffd2275e6a44ead0f15a7eaac9dc9d60a56b3b9c9b08e8" +checksum = "6384d2475e4a7e6ed4e2a703724cac1d8972d9ec40c49fdd17bf37942a81a635" dependencies = [ "boojum", "derivative", @@ -12251,7 +12112,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "zkevm_circuits 0.150.7", + "zkevm_circuits", ] [[package]] @@ -12372,11 +12233,7 @@ version = "0.1.0" dependencies = [ "anyhow", "assert_matches", - "circuit_sequencer_api 0.133.1", - "circuit_sequencer_api 0.140.3", - "circuit_sequencer_api 0.141.2", - "circuit_sequencer_api 0.142.2", - "circuit_sequencer_api 0.150.7", + "circuit_sequencer_api", "ethabi", "hex", "itertools 0.10.5", @@ -12391,7 +12248,7 @@ dependencies = [ "zk_evm 0.133.0", "zk_evm 0.140.0", "zk_evm 0.141.0", - "zk_evm 0.150.7", + "zk_evm 0.150.18", "zksync_contracts", "zksync_eth_signer", "zksync_mini_merkle_tree", @@ -12431,7 +12288,7 @@ dependencies = [ "tower-http 0.5.2", "tracing", "vise", - "zk_evm 0.150.7", + "zk_evm 0.150.18", "zksync_config", "zksync_consensus_roles", "zksync_contracts", @@ -12727,9 +12584,9 @@ dependencies = [ [[package]] name = "zksync_pairing" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8412ae5574472fa567a097e183f9a01974b99dd0b5da3bfa1bbe6c57c579aa2" +checksum = "3b91b38db3a3f0f80d8b1f2342c77751ee8d63b746268e5719abbb5dfb150a8c" dependencies = [ "byteorder", "cfg-if", @@ -12826,7 +12683,7 @@ version = "0.1.0" dependencies = [ "bincode", "chrono", - "circuit_sequencer_api 0.150.7", + "circuit_sequencer_api", "serde", "serde_json", "serde_with", @@ -12936,9 +12793,9 @@ dependencies = [ [[package]] name = "zksync_solidity_vk_codegen" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b310ab8a21681270e73f177ddf7974cabb7a96f0624ab8b008fd6ee1f9b4f687" +checksum = "6f03e137db1b29be36abfa1e1e682dd3864b0335c68282c8dab68c2d397b8cbd" dependencies = [ "ethereum-types", "franklin-crypto", @@ -13140,6 +12997,7 @@ dependencies = [ "once_cell", "reqwest 0.12.9", "serde_json", + "sha2 0.10.8", "tokio", "tracing", "zksync_vlog", @@ -13177,8 +13035,8 @@ source = "git+https://github.com/matter-labs/vm2.git?rev=457d8a7eea9093af9440662 dependencies = [ "enum_dispatch", "primitive-types", - "zk_evm_abstractions 0.150.7", - "zkevm_opcode_defs 0.150.7", + "zk_evm_abstractions 0.150.18", + "zkevm_opcode_defs 0.150.18", "zksync_vm2_interface", ] diff --git a/Cargo.toml b/Cargo.toml index 99f6abdf85e2..80e74f05c087 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -228,19 +228,16 @@ tokio-stream = "0.1.16" # We *always* pin the latest version of protocol to disallow accidental changes in the execution logic. # However, for the historical version of protocol crates, we have lax requirements. Otherwise, # Bumping a crypto dependency like `boojum` would require us to republish all the historical packages. -circuit_sequencer_api_1_3_3 = { package = "circuit_sequencer_api", version = "0.133" } -circuit_sequencer_api_1_4_0 = { package = "circuit_sequencer_api", version = "0.140" } -circuit_sequencer_api_1_4_1 = { package = "circuit_sequencer_api", version = "0.141" } -circuit_sequencer_api_1_4_2 = { package = "circuit_sequencer_api", version = "0.142" } -circuit_sequencer_api_1_5_0 = { package = "circuit_sequencer_api", version = "=0.150.7" } -crypto_codegen = { package = "zksync_solidity_vk_codegen", version = "=0.30.1" } -kzg = { package = "zksync_kzg", version = "=0.150.7" } +circuit_encodings = { package = "circuit_encodings", version = "=0.150.18" } +circuit_sequencer_api = { package = "circuit_sequencer_api", version = "=0.150.18" } +crypto_codegen = { package = "zksync_solidity_vk_codegen", version = "=0.30.11" } +kzg = { package = "zksync_kzg", version = "=0.150.18" } zk_evm = { version = "=0.133.0" } zk_evm_1_3_1 = { package = "zk_evm", version = "0.131.0-rc.2" } zk_evm_1_3_3 = { package = "zk_evm", version = "0.133" } zk_evm_1_4_0 = { package = "zk_evm", version = "0.140" } zk_evm_1_4_1 = { package = "zk_evm", version = "0.141" } -zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.7" } +zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.18" } # New VM; pinned to a specific commit because of instability zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "457d8a7eea9093af9440662e33e598c13ba41633" } diff --git a/core/lib/multivm/Cargo.toml b/core/lib/multivm/Cargo.toml index 128e6fc0c4af..107a168e305a 100644 --- a/core/lib/multivm/Cargo.toml +++ b/core/lib/multivm/Cargo.toml @@ -18,11 +18,7 @@ zk_evm_1_3_3.workspace = true zk_evm_1_3_1.workspace = true zksync_vm2.workspace = true -circuit_sequencer_api_1_3_3.workspace = true -circuit_sequencer_api_1_4_0.workspace = true -circuit_sequencer_api_1_4_1.workspace = true -circuit_sequencer_api_1_4_2.workspace = true -circuit_sequencer_api_1_5_0.workspace = true +circuit_sequencer_api.workspace = true zksync_types.workspace = true zksync_contracts.workspace = true diff --git a/core/lib/multivm/src/glue/types/vm/vm_block_result.rs b/core/lib/multivm/src/glue/types/vm/vm_block_result.rs index c4eb0b1741aa..1cbb9f261ad2 100644 --- a/core/lib/multivm/src/glue/types/vm/vm_block_result.rs +++ b/core/lib/multivm/src/glue/types/vm/vm_block_result.rs @@ -1,8 +1,6 @@ use std::collections::HashMap; -use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries as sort_storage_access_queries_1_3_3; -use itertools::Itertools; -use zk_evm_1_3_1::aux_structures::LogQuery as LogQuery_1_3_1; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zksync_types::l2_to_l1_log::UserL2ToL1Log; use crate::{ @@ -11,6 +9,7 @@ use crate::{ CurrentExecutionState, ExecutionResult, Refunds, VmExecutionLogs, VmExecutionResultAndLogs, VmExecutionStatistics, }, + utils::glue_log_query, }; // Note: In version after vm `VmVirtualBlocks` the bootloader memory knowledge is encapsulated into the VM. @@ -21,18 +20,12 @@ use crate::{ impl GlueFrom for crate::interface::FinishedL1Batch { fn glue_from(value: crate::vm_m5::vm_instance::VmBlockResult) -> Self { let storage_log_queries = value.full_result.storage_log_queries.clone(); - let deduplicated_storage_logs: Vec = sort_storage_access_queries_1_3_3( - &storage_log_queries + let deduplicated_storage_logs = sort_storage_access_queries( + storage_log_queries .iter() - .map(|log| { - GlueInto::::glue_into(log.log_query) - }) - .collect_vec(), + .map(|log| glue_log_query(log.log_query)), ) - .1 - .into_iter() - .map(GlueInto::::glue_into) - .collect(); + .1; crate::interface::FinishedL1Batch { block_tip_execution_result: VmExecutionResultAndLogs { @@ -78,18 +71,12 @@ impl GlueFrom for crate::interface::Fi impl GlueFrom for crate::interface::FinishedL1Batch { fn glue_from(value: crate::vm_m6::vm_instance::VmBlockResult) -> Self { let storage_log_queries = value.full_result.storage_log_queries.clone(); - let deduplicated_storage_logs: Vec = sort_storage_access_queries_1_3_3( - &storage_log_queries + let deduplicated_storage_logs = sort_storage_access_queries( + storage_log_queries .iter() - .map(|log| { - GlueInto::::glue_into(log.log_query) - }) - .collect_vec(), + .map(|log| glue_log_query(log.log_query)), ) - .1 - .into_iter() - .map(GlueInto::::glue_into) - .collect(); + .1; crate::interface::FinishedL1Batch { block_tip_execution_result: VmExecutionResultAndLogs { @@ -135,11 +122,12 @@ impl GlueFrom for crate::interface::Fi impl GlueFrom for crate::interface::FinishedL1Batch { fn glue_from(value: crate::vm_1_3_2::vm_instance::VmBlockResult) -> Self { let storage_log_queries = value.full_result.storage_log_queries.clone(); - let deduplicated_storage_logs = - circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries( - storage_log_queries.iter().map(|log| &log.log_query), - ) - .1; + let deduplicated_storage_logs = sort_storage_access_queries( + storage_log_queries + .iter() + .map(|log| glue_log_query(log.log_query)), + ) + .1; crate::interface::FinishedL1Batch { block_tip_execution_result: VmExecutionResultAndLogs { diff --git a/core/lib/multivm/src/lib.rs b/core/lib/multivm/src/lib.rs index fc4085d9b021..202d7ce95d14 100644 --- a/core/lib/multivm/src/lib.rs +++ b/core/lib/multivm/src/lib.rs @@ -2,7 +2,7 @@ #![warn(unused_extern_crates)] #![warn(unused_imports)] -pub use circuit_sequencer_api_1_5_0 as circuit_sequencer_api_latest; +pub use circuit_sequencer_api as circuit_sequencer_api_latest; pub use zk_evm_1_5_0 as zk_evm_latest; pub use zksync_types::vm::VmVersion; pub use zksync_vm_interface as interface; diff --git a/core/lib/multivm/src/utils/mod.rs b/core/lib/multivm/src/utils/mod.rs index 4332c0327ff1..6f350084d22a 100644 --- a/core/lib/multivm/src/utils/mod.rs +++ b/core/lib/multivm/src/utils/mod.rs @@ -5,12 +5,27 @@ use zksync_types::{ }; pub use self::deduplicator::{ModifiedSlot, StorageWritesDeduplicator}; -use crate::interface::L1BatchEnv; +use crate::{ + glue::{GlueFrom, GlueInto}, + interface::L1BatchEnv, +}; pub(crate) mod bytecode; mod deduplicator; pub(crate) mod events; +/// Allows to convert `LogQuery` between two different versions, even if they don't provide +/// direct conversion between each other. +/// It transforms the input query to the `LogQuery` from `zksync_types` (for which most of the +/// `zk_evm` versions provide conversion) and then converts it to the target version. +pub fn glue_log_query(l: L) -> R +where + L: GlueInto, + R: GlueFrom, +{ + R::glue_from(l.glue_into()) +} + /// Calculates the base fee and gas per pubdata for the given L1 gas price. pub fn derive_base_fee_and_gas_per_pubdata( batch_fee_input: BatchFeeInput, diff --git a/core/lib/multivm/src/versions/testonly/precompiles.rs b/core/lib/multivm/src/versions/testonly/precompiles.rs index e525bd627646..dee60686a4f0 100644 --- a/core/lib/multivm/src/versions/testonly/precompiles.rs +++ b/core/lib/multivm/src/versions/testonly/precompiles.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_5_0::geometry_config::get_geometry_config; +use circuit_sequencer_api::geometry_config::ProtocolGeometry; use zksync_test_contracts::TestContract; use zksync_types::{Address, Execute}; @@ -41,7 +41,9 @@ pub(crate) fn test_keccak() { assert!(!exec_result.result.is_failed(), "{exec_result:#?}"); let keccak_count = exec_result.statistics.circuit_statistic.keccak256 - * get_geometry_config().cycles_per_keccak256_circuit as f32; + * ProtocolGeometry::V1_5_0 + .config() + .cycles_per_keccak256_circuit as f32; assert!(keccak_count >= 1000.0, "{keccak_count}"); } @@ -77,7 +79,7 @@ pub(crate) fn test_sha256() { assert!(!exec_result.result.is_failed(), "{exec_result:#?}"); let sha_count = exec_result.statistics.circuit_statistic.sha256 - * get_geometry_config().cycles_per_sha256_circuit as f32; + * ProtocolGeometry::V1_5_0.config().cycles_per_sha256_circuit as f32; assert!(sha_count >= 1000.0, "{sha_count}"); } @@ -106,6 +108,8 @@ pub(crate) fn test_ecrecover() { assert!(!exec_result.result.is_failed(), "{exec_result:#?}"); let ecrecover_count = exec_result.statistics.circuit_statistic.ecrecover - * get_geometry_config().cycles_per_ecrecover_circuit as f32; + * ProtocolGeometry::V1_5_0 + .config() + .cycles_per_ecrecover_circuit as f32; assert!((ecrecover_count - 1.0).abs() < 1e-4, "{ecrecover_count}"); } diff --git a/core/lib/multivm/src/versions/vm_1_3_2/pubdata_utils.rs b/core/lib/multivm/src/versions/vm_1_3_2/pubdata_utils.rs index 3c10bd8c48be..f0be10d72077 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/pubdata_utils.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/pubdata_utils.rs @@ -1,12 +1,12 @@ use std::collections::HashMap; -use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zk_evm_1_3_3::aux_structures::Timestamp; use zksync_types::{StorageKey, PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS}; use crate::{ interface::{storage::WriteStorage, VmEvent}, - utils::bytecode::bytecode_len_in_bytes, + utils::{bytecode::bytecode_len_in_bytes, glue_log_query}, vm_1_3_2::{history_recorder::HistoryMode, oracles::storage::storage_key_of_log, VmInstance}, }; @@ -71,16 +71,20 @@ impl VmInstance { .state .storage .storage_log_queries_after_timestamp(from_timestamp); - let (_, deduplicated_logs) = - sort_storage_access_queries(storage_logs.iter().map(|log| &log.log_query)); + let (_, deduplicated_logs) = sort_storage_access_queries( + storage_logs.iter().map(|log| glue_log_query(log.log_query)), + ); deduplicated_logs .into_iter() .filter_map(|log| { if log.rw_flag { - let key = storage_key_of_log(&log); + let key = storage_key_of_log(&glue_log_query(log)); let pre_paid = pre_paid_before_tx(&key); - let to_pay_by_user = self.state.storage.base_price_for_write(&log); + let to_pay_by_user = self + .state + .storage + .base_price_for_write(&glue_log_query(log)); if to_pay_by_user > pre_paid { Some(to_pay_by_user - pre_paid) diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm_with_bootloader.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm_with_bootloader.rs index ca9ba097d472..6515228903f6 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm_with_bootloader.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm_with_bootloader.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use itertools::Itertools; use zk_evm_1_3_3::{ aux_structures::{MemoryPage, Timestamp}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/circuits_capacity.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/circuits_capacity.rs index a32328bbc18c..5ef359248b85 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/circuits_capacity.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/circuits_capacity.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_4_1::{geometry_config::get_geometry_config, toolset::GeometryConfig}; +use circuit_sequencer_api::geometry_config::{GeometryConfig, ProtocolGeometry}; use crate::{interface::CircuitStatistic, utils::CircuitCycleStatistic}; @@ -40,7 +40,7 @@ pub(crate) const UMA_READ_RAM_CYCLES: u32 = 3; pub(crate) const PRECOMPILE_RAM_CYCLES: u32 = 1; pub(crate) const PRECOMPILE_LOG_DEMUXER_CYCLES: u32 = 1; -const GEOMETRY_CONFIG: GeometryConfig = get_geometry_config(); +const GEOMETRY_CONFIG: GeometryConfig = ProtocolGeometry::V1_4_1.config(); pub(crate) fn circuit_statistic_from_cycles(cycles: CircuitCycleStatistic) -> CircuitStatistic { CircuitStatistic { diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/pubdata_tracer.rs index a51c5ce46197..344cacbd903e 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/pubdata_tracer.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use circuit_sequencer_api_1_4_1::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zk_evm_1_4_1::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, @@ -24,6 +24,7 @@ use crate::{ extract_bytecode_publication_requests_from_l1_messenger, extract_l2tol1logs_from_l1_messenger, }, + glue_log_query, }, vm_1_4_1::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, @@ -130,7 +131,7 @@ impl PubdataTracer { storage .storage_log_queries_after_timestamp(Timestamp(0)) .iter() - .map(|log| &log.log_query), + .map(|log| glue_log_query(log.log_query)), ) .1 .into_iter() diff --git a/core/lib/multivm/src/versions/vm_1_4_1/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_1_4_1/types/internals/vm_state.rs index 9c3ecd9741a3..cc1ec75d51c2 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/types/internals/vm_state.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_4_1::{ aux_structures::{MemoryPage, Timestamp}, block_properties::BlockProperties, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs index af483feedd7e..7f17f65cac07 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs @@ -1,6 +1,6 @@ use std::rc::Rc; -use circuit_sequencer_api_1_4_1::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, @@ -15,7 +15,7 @@ use crate::{ FinishedL1Batch, L1BatchEnv, L2BlockEnv, PushTransactionResult, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, }, - utils::events::extract_l2tol1logs_from_l1_messenger, + utils::{events::extract_l2tol1logs_from_l1_messenger, glue_log_query}, vm_1_4_1::{ bootloader_state::BootloaderState, old_vm::events::merge_events, @@ -60,8 +60,12 @@ impl Vm { let storage_log_queries = self.state.storage.get_final_log_queries(); - let deduped_storage_log_queries = - sort_storage_access_queries(storage_log_queries.iter().map(|log| &log.log_query)).1; + let deduped_storage_log_queries = sort_storage_access_queries( + storage_log_queries + .iter() + .map(|log| glue_log_query(log.log_query)), + ) + .1; CurrentExecutionState { events, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/constants.rs b/core/lib/multivm/src/versions/vm_1_4_2/constants.rs index 79f20660c149..35266358a742 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/constants.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/constants.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_4_2::{BLOB_CHUNK_SIZE, ELEMENTS_PER_4844_BLOCK}; +use circuit_sequencer_api::{BLOB_CHUNK_SIZE, ELEMENTS_PER_4844_BLOCK}; use zk_evm_1_4_1::aux_structures::MemoryPage; pub use zk_evm_1_4_1::zkevm_opcode_defs::system_params::{ ERGS_PER_CIRCUIT, INITIAL_STORAGE_WRITE_PUBDATA_BYTES, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/circuits_capacity.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/circuits_capacity.rs index 974e07577213..e56d57246982 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/circuits_capacity.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/circuits_capacity.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_4_2::{geometry_config::get_geometry_config, toolset::GeometryConfig}; +use circuit_sequencer_api::geometry_config::{GeometryConfig, ProtocolGeometry}; use crate::{interface::CircuitStatistic, utils::CircuitCycleStatistic}; @@ -41,7 +41,7 @@ pub(crate) const UMA_READ_RAM_CYCLES: u32 = 3; pub(crate) const PRECOMPILE_RAM_CYCLES: u32 = 1; pub(crate) const PRECOMPILE_LOG_DEMUXER_CYCLES: u32 = 1; -const GEOMETRY_CONFIG: GeometryConfig = get_geometry_config(); +const GEOMETRY_CONFIG: GeometryConfig = ProtocolGeometry::V1_4_2.config(); pub(crate) fn circuit_statistic_from_cycles(cycles: CircuitCycleStatistic) -> CircuitStatistic { CircuitStatistic { diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/pubdata_tracer.rs index 58318f5d845e..8f9bbb94b9d4 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/pubdata_tracer.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use circuit_sequencer_api_1_4_2::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zk_evm_1_4_1::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, @@ -24,6 +24,7 @@ use crate::{ extract_bytecode_publication_requests_from_l1_messenger, extract_l2tol1logs_from_l1_messenger, }, + glue_log_query, }, vm_1_4_2::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, @@ -150,7 +151,7 @@ impl PubdataTracer { storage .storage_log_queries_after_timestamp(Timestamp(0)) .iter() - .map(|log| &log.log_query), + .map(|log| glue_log_query(log.log_query)), ) .1 .into_iter() diff --git a/core/lib/multivm/src/versions/vm_1_4_2/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_1_4_2/types/internals/vm_state.rs index 52a0dc61d740..00833e4e5e89 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/types/internals/vm_state.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_4_1::{ aux_structures::{MemoryPage, Timestamp}, block_properties::BlockProperties, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs index e7c8e7acdd95..ce649c221f39 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs @@ -1,6 +1,6 @@ use std::{mem, rc::Rc}; -use circuit_sequencer_api_1_4_2::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, @@ -15,7 +15,7 @@ use crate::{ FinishedL1Batch, L1BatchEnv, L2BlockEnv, PushTransactionResult, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, }, - utils::events::extract_l2tol1logs_from_l1_messenger, + utils::{events::extract_l2tol1logs_from_l1_messenger, glue_log_query}, vm_1_4_2::{ bootloader_state::BootloaderState, old_vm::events::merge_events, @@ -60,8 +60,12 @@ impl Vm { let storage_log_queries = self.state.storage.get_final_log_queries(); - let deduped_storage_log_queries = - sort_storage_access_queries(storage_log_queries.iter().map(|log| &log.log_query)).1; + let deduped_storage_log_queries = sort_storage_access_queries( + storage_log_queries + .iter() + .map(|log| glue_log_query(log.log_query)), + ) + .1; CurrentExecutionState { events, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/circuits_capacity.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/circuits_capacity.rs index a9e5e17e7973..bcc0ec48be0a 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/circuits_capacity.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/circuits_capacity.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_4_0::{geometry_config::get_geometry_config, toolset::GeometryConfig}; +use circuit_sequencer_api::geometry_config::{GeometryConfig, ProtocolGeometry}; use crate::{interface::CircuitStatistic, utils::CircuitCycleStatistic}; @@ -40,7 +40,7 @@ pub(crate) const UMA_READ_RAM_CYCLES: u32 = 3; pub(crate) const PRECOMPILE_RAM_CYCLES: u32 = 1; pub(crate) const PRECOMPILE_LOG_DEMUXER_CYCLES: u32 = 1; -const GEOMETRY_CONFIG: GeometryConfig = get_geometry_config(); +const GEOMETRY_CONFIG: GeometryConfig = ProtocolGeometry::V1_4_0.config(); pub(crate) fn circuit_statistic_from_cycles(cycles: CircuitCycleStatistic) -> CircuitStatistic { CircuitStatistic { diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/pubdata_tracer.rs index 6396d143b401..c442f5705d2e 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/pubdata_tracer.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use circuit_sequencer_api_1_4_0::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zk_evm_1_4_0::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, @@ -24,6 +24,7 @@ use crate::{ extract_bytecode_publication_requests_from_l1_messenger, extract_l2tol1logs_from_l1_messenger, }, + glue_log_query, }, vm_boojum_integration::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, @@ -121,7 +122,7 @@ impl PubdataTracer { storage .storage_log_queries_after_timestamp(Timestamp(0)) .iter() - .map(|log| &log.log_query), + .map(|log| glue_log_query(log.log_query)), ) .1 .into_iter() diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_boojum_integration/types/internals/vm_state.rs index dc41926c4485..f225a91506ee 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/types/internals/vm_state.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_4_0::{ aux_structures::{MemoryPage, Timestamp}, block_properties::BlockProperties, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs index 43c9900486db..42129ab5a9e6 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs @@ -1,6 +1,6 @@ use std::rc::Rc; -use circuit_sequencer_api_1_4_0::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, @@ -15,7 +15,7 @@ use crate::{ FinishedL1Batch, L1BatchEnv, L2BlockEnv, PushTransactionResult, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, }, - utils::events::extract_l2tol1logs_from_l1_messenger, + utils::{events::extract_l2tol1logs_from_l1_messenger, glue_log_query}, vm_boojum_integration::{ bootloader_state::BootloaderState, old_vm::events::merge_events, @@ -60,8 +60,12 @@ impl Vm { let storage_log_queries = self.state.storage.get_final_log_queries(); - let deduped_storage_log_queries = - sort_storage_access_queries(storage_log_queries.iter().map(|log| &log.log_query)).1; + let deduped_storage_log_queries = sort_storage_access_queries( + storage_log_queries + .iter() + .map(|log| glue_log_query(log.log_query)), + ) + .1; CurrentExecutionState { events, diff --git a/core/lib/multivm/src/versions/vm_fast/tracers/circuits.rs b/core/lib/multivm/src/versions/vm_fast/tracers/circuits.rs index 9c1c0b7dfb7f..5acf6c490abf 100644 --- a/core/lib/multivm/src/versions/vm_fast/tracers/circuits.rs +++ b/core/lib/multivm/src/versions/vm_fast/tracers/circuits.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_5_0::{geometry_config::get_geometry_config, toolset::GeometryConfig}; +use circuit_sequencer_api::geometry_config::{GeometryConfig, ProtocolGeometry}; use zksync_vm2::interface::{ CycleStats, GlobalStateInterface, Opcode, OpcodeType, ShouldStop, Tracer, }; @@ -164,4 +164,4 @@ impl CircuitsTracer { } } -const GEOMETRY_CONFIG: GeometryConfig = get_geometry_config(); +const GEOMETRY_CONFIG: GeometryConfig = ProtocolGeometry::V1_5_0.config(); diff --git a/core/lib/multivm/src/versions/vm_latest/constants.rs b/core/lib/multivm/src/versions/vm_latest/constants.rs index c95771f9e849..1578965d7a66 100644 --- a/core/lib/multivm/src/versions/vm_latest/constants.rs +++ b/core/lib/multivm/src/versions/vm_latest/constants.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_5_0::{BLOB_CHUNK_SIZE, ELEMENTS_PER_4844_BLOCK}; +use circuit_sequencer_api::{BLOB_CHUNK_SIZE, ELEMENTS_PER_4844_BLOCK}; use zk_evm_1_5_0::aux_structures::MemoryPage; pub use zk_evm_1_5_0::zkevm_opcode_defs::system_params::{ ERGS_PER_CIRCUIT, INITIAL_STORAGE_WRITE_PUBDATA_BYTES, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/circuits_capacity.rs b/core/lib/multivm/src/versions/vm_latest/tracers/circuits_capacity.rs index 0977a323d191..58cbf45407d5 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/circuits_capacity.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/circuits_capacity.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_5_0::{geometry_config::get_geometry_config, toolset::GeometryConfig}; +use circuit_sequencer_api::geometry_config::{GeometryConfig, ProtocolGeometry}; use crate::{interface::CircuitStatistic, utils::CircuitCycleStatistic}; @@ -52,7 +52,7 @@ pub(crate) const PRECOMPILE_LOG_DEMUXER_CYCLES: u32 = 1; pub(crate) const LOG_DECOMMIT_RAM_CYCLES: u32 = 1; pub(crate) const LOG_DECOMMIT_DECOMMITTER_SORTER_CYCLES: u32 = 1; -const GEOMETRY_CONFIG: GeometryConfig = get_geometry_config(); +const GEOMETRY_CONFIG: GeometryConfig = ProtocolGeometry::V1_5_0.config(); pub(crate) fn circuit_statistic_from_cycles(cycles: CircuitCycleStatistic) -> CircuitStatistic { CircuitStatistic { diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs index 3698914630dd..7c55dd38561d 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs @@ -1,6 +1,6 @@ use std::{marker::PhantomData, rc::Rc}; -use circuit_sequencer_api_1_5_0::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zk_evm_1_5_0::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, @@ -162,7 +162,7 @@ impl PubdataTracer { storage .storage_log_queries_after_timestamp(Timestamp(0)) .iter() - .map(|log| &log.log_query), + .map(|log| log.log_query), ) .1 .into_iter() diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs index 03f306f36c52..63f06f4fd846 100644 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_5_0::{ aux_structures::{MemoryPage, PubdataCost, Timestamp}, block_properties::BlockProperties, diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index ada20af9fa3c..1db369d4ae20 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, rc::Rc}; -use circuit_sequencer_api_1_5_0::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zksync_types::{ h256_to_u256, l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, @@ -124,7 +124,7 @@ impl Vm { let storage_log_queries = self.state.storage.get_final_log_queries(); let deduped_storage_log_queries = - sort_storage_access_queries(storage_log_queries.iter().map(|log| &log.log_query)).1; + sort_storage_access_queries(storage_log_queries.iter().map(|log| log.log_query)).1; CurrentExecutionState { events, diff --git a/core/lib/multivm/src/versions/vm_m5/pubdata_utils.rs b/core/lib/multivm/src/versions/vm_m5/pubdata_utils.rs index 8eca2ef5cd86..0cf208e2a40e 100644 --- a/core/lib/multivm/src/versions/vm_m5/pubdata_utils.rs +++ b/core/lib/multivm/src/versions/vm_m5/pubdata_utils.rs @@ -1,14 +1,13 @@ use std::collections::HashMap; -use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; -use itertools::Itertools; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zk_evm_1_3_1::aux_structures::{LogQuery, Timestamp}; use zksync_types::{StorageKey, PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS}; use crate::{ glue::GlueInto, interface::VmEvent, - utils::bytecode::bytecode_len_in_bytes, + utils::{bytecode::bytecode_len_in_bytes, glue_log_query}, vm_m5::{ oracles::storage::storage_key_of_log, storage::Storage, utils::collect_storage_log_queries_after_timestamp, vm_instance::VmInstance, @@ -86,16 +85,11 @@ impl VmInstance { // To allow calling the `vm-1.3.3`s. method, the `v1.3.1`'s `LogQuery` has to be converted // to the `vm-1.3.3`'s `LogQuery`. Then, we need to convert it back. let deduplicated_logs: Vec = sort_storage_access_queries( - &storage_logs - .iter() - .map(|log| { - GlueInto::::glue_into(log.log_query) - }) - .collect_vec(), + storage_logs.iter().map(|log| glue_log_query(log.log_query)), ) .1 .into_iter() - .map(GlueInto::::glue_into) + .map(glue_log_query) .collect(); deduplicated_logs diff --git a/core/lib/multivm/src/versions/vm_m5/vm_with_bootloader.rs b/core/lib/multivm/src/versions/vm_m5/vm_with_bootloader.rs index 0a7df48df80f..c137dcac0bd1 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm_with_bootloader.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm_with_bootloader.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_3_1::{ abstractions::{MAX_HEAP_PAGE_SIZE_IN_WORDS, MAX_MEMORY_BYTES}, aux_structures::{MemoryPage, Timestamp}, diff --git a/core/lib/multivm/src/versions/vm_m6/pubdata_utils.rs b/core/lib/multivm/src/versions/vm_m6/pubdata_utils.rs index 97bf290a2162..fb3e82a28243 100644 --- a/core/lib/multivm/src/versions/vm_m6/pubdata_utils.rs +++ b/core/lib/multivm/src/versions/vm_m6/pubdata_utils.rs @@ -1,14 +1,13 @@ use std::collections::HashMap; -use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; -use itertools::Itertools; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zk_evm_1_3_1::aux_structures::{LogQuery, Timestamp}; use zksync_types::{StorageKey, PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS}; use crate::{ glue::GlueInto, interface::VmEvent, - utils::bytecode::bytecode_len_in_bytes, + utils::{bytecode::bytecode_len_in_bytes, glue_log_query}, vm_m6::{ history_recorder::HistoryMode, oracles::storage::storage_key_of_log, storage::Storage, utils::collect_storage_log_queries_after_timestamp, VmInstance, @@ -80,16 +79,11 @@ impl VmInstance { // To allow calling the `vm-1.3.3`s. method, the `v1.3.1`'s `LogQuery` has to be converted // to the `vm-1.3.3`'s `LogQuery`. Then, we need to convert it back. let deduplicated_logs: Vec = sort_storage_access_queries( - &storage_logs - .iter() - .map(|log| { - GlueInto::::glue_into(log.log_query) - }) - .collect_vec(), + storage_logs.iter().map(|log| glue_log_query(log.log_query)), ) .1 .into_iter() - .map(GlueInto::::glue_into) + .map(glue_log_query) .collect(); deduplicated_logs diff --git a/core/lib/multivm/src/versions/vm_m6/vm_with_bootloader.rs b/core/lib/multivm/src/versions/vm_m6/vm_with_bootloader.rs index ff83abc45fcf..4b2eb8212e61 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm_with_bootloader.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm_with_bootloader.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_3_1::{ abstractions::{MAX_HEAP_PAGE_SIZE_IN_WORDS, MAX_MEMORY_BYTES}, aux_structures::{MemoryPage, Timestamp}, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/types/internals/vm_state.rs index 6776bc37c9d5..1c31c63d6893 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/types/internals/vm_state.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_3_3::{ aux_structures::{MemoryPage, Timestamp}, block_properties::BlockProperties, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs index 81b0c52cce5e..bfe35b1189f8 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs @@ -1,6 +1,6 @@ use std::rc::Rc; -use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; @@ -12,6 +12,7 @@ use crate::{ FinishedL1Batch, L1BatchEnv, L2BlockEnv, PushTransactionResult, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, }, + utils::glue_log_query, vm_latest::HistoryEnabled, vm_refunds_enhancement::{ bootloader_state::BootloaderState, @@ -56,8 +57,12 @@ impl Vm { let storage_log_queries = self.state.storage.get_final_log_queries(); - let deduped_storage_log_queries = - sort_storage_access_queries(storage_log_queries.iter().map(|log| &log.log_query)).1; + let deduped_storage_log_queries = sort_storage_access_queries( + storage_log_queries + .iter() + .map(|log| glue_log_query(log.log_query)), + ) + .1; CurrentExecutionState { events, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/refunds.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/refunds.rs index 59aa837cd8fb..28d80b3d1116 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/refunds.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/refunds.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Histogram, Metrics}; use zk_evm_1_3_3::{ aux_structures::Timestamp, @@ -18,7 +18,7 @@ use crate::{ L1BatchEnv, Refunds, VmEvent, VmExecutionResultAndLogs, }, tracers::dynamic::vm_1_3_3::DynTracer, - utils::bytecode::bytecode_len_in_bytes, + utils::{bytecode::bytecode_len_in_bytes, glue_log_query}, vm_virtual_blocks::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET}, @@ -372,15 +372,15 @@ fn pubdata_published_for_writes( .storage .storage_log_queries_after_timestamp(from_timestamp); let (_, deduplicated_logs) = - sort_storage_access_queries(storage_logs.iter().map(|log| &log.log_query)); + sort_storage_access_queries(storage_logs.iter().map(|log| glue_log_query(log.log_query))); deduplicated_logs .into_iter() .filter_map(|log| { if log.rw_flag { - let key = storage_key_of_log(&log); + let key = storage_key_of_log(&glue_log_query(log)); let pre_paid = pre_paid_before_tx(&key); - let to_pay_by_user = state.storage.base_price_for_write(&log); + let to_pay_by_user = state.storage.base_price_for_write(&glue_log_query(log)); if to_pay_by_user > pre_paid { Some(to_pay_by_user - pre_paid) diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/types/internals/vm_state.rs index d1509bd016d8..c7ab344849f2 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/types/internals/vm_state.rs @@ -1,4 +1,4 @@ -use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; +use circuit_sequencer_api::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_3_3::{ aux_structures::{MemoryPage, Timestamp}, block_properties::BlockProperties, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs index a2d18e10de44..cc255f550c55 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs @@ -1,6 +1,6 @@ use std::rc::Rc; -use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; +use circuit_sequencer_api::sort_storage_access::sort_storage_access_queries; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; @@ -12,6 +12,7 @@ use crate::{ FinishedL1Batch, L1BatchEnv, L2BlockEnv, PushTransactionResult, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, }, + utils::glue_log_query, vm_latest::HistoryEnabled, vm_virtual_blocks::{ bootloader_state::BootloaderState, @@ -56,8 +57,12 @@ impl Vm { let storage_log_queries = self.state.storage.get_final_log_queries(); - let deduped_storage_log_queries = - sort_storage_access_queries(storage_log_queries.iter().map(|log| &log.log_query)).1; + let deduped_storage_log_queries = sort_storage_access_queries( + storage_log_queries + .iter() + .map(|log| glue_log_query(log.log_query)), + ) + .1; CurrentExecutionState { events, diff --git a/core/lib/prover_interface/Cargo.toml b/core/lib/prover_interface/Cargo.toml index 50671fb3acb4..3ed8a9ff558f 100644 --- a/core/lib/prover_interface/Cargo.toml +++ b/core/lib/prover_interface/Cargo.toml @@ -16,7 +16,7 @@ zksync_object_store.workspace = true zksync_types.workspace = true # We can use the newest api to send proofs to L1. -circuit_sequencer_api_1_5_0.workspace = true +circuit_sequencer_api.workspace = true serde.workspace = true strum = { workspace = true, features = ["derive"] } diff --git a/core/lib/prover_interface/src/outputs.rs b/core/lib/prover_interface/src/outputs.rs index 60a9eaba760b..b6422473cea3 100644 --- a/core/lib/prover_interface/src/outputs.rs +++ b/core/lib/prover_interface/src/outputs.rs @@ -1,6 +1,6 @@ use core::fmt; -use circuit_sequencer_api_1_5_0::proof::FinalProof; +use circuit_sequencer_api::proof::FinalProof; use serde::{Deserialize, Serialize}; use serde_with::{hex::Hex, serde_as}; use zksync_object_store::{serialize_using_bincode, Bucket, StoredObject}; diff --git a/core/lib/prover_interface/tests/job_serialization.rs b/core/lib/prover_interface/tests/job_serialization.rs index ead59749abe3..d170520798d1 100644 --- a/core/lib/prover_interface/tests/job_serialization.rs +++ b/core/lib/prover_interface/tests/job_serialization.rs @@ -1,6 +1,6 @@ //! Integration tests for object store serialization of job objects. -use circuit_sequencer_api_1_5_0::proof::FinalProof; +use circuit_sequencer_api::proof::FinalProof; use tokio::fs; use zksync_object_store::{Bucket, MockObjectStore}; use zksync_prover_interface::{ diff --git a/core/lib/state/src/storage_overrides.rs b/core/lib/state/src/storage_overrides.rs deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/core/lib/utils/Cargo.toml b/core/lib/utils/Cargo.toml index 216f3b12d426..fb08afc59b70 100644 --- a/core/lib/utils/Cargo.toml +++ b/core/lib/utils/Cargo.toml @@ -20,6 +20,7 @@ futures.workspace = true reqwest = { workspace = true, features = ["blocking"] } serde_json.workspace = true once_cell.workspace = true +sha2.workspace = true [dev-dependencies] tokio = { workspace = true, features = ["macros", "rt"] } diff --git a/core/node/api_server/src/web3/namespaces/unstable/utils.rs b/core/node/api_server/src/web3/namespaces/unstable/utils.rs index 2d3187fab6b8..b1071aee28c4 100644 --- a/core/node/api_server/src/web3/namespaces/unstable/utils.rs +++ b/core/node/api_server/src/web3/namespaces/unstable/utils.rs @@ -1,12 +1,11 @@ use zksync_dal::{Connection, Core, CoreDal, DalError}; -use zksync_multivm::circuit_sequencer_api_latest::boojum::ethereum_types::U256; use zksync_system_constants::{ message_root::{CHAIN_COUNT_KEY, CHAIN_INDEX_TO_ID_KEY, CHAIN_TREE_KEY}, L2_MESSAGE_ROOT_ADDRESS, }; use zksync_types::{ h256_to_u256, l2_to_l1_log::CHAIN_ID_LEAF_PADDING, u256_to_h256, web3::keccak256, - AccountTreeId, L2BlockNumber, StorageKey, H256, + AccountTreeId, L2BlockNumber, StorageKey, H256, U256, }; use zksync_web3_decl::error::Web3Error; diff --git a/core/node/commitment_generator/Cargo.toml b/core/node/commitment_generator/Cargo.toml index f0b4046bab42..8a1af52e589d 100644 --- a/core/node/commitment_generator/Cargo.toml +++ b/core/node/commitment_generator/Cargo.toml @@ -20,13 +20,9 @@ zksync_eth_client.workspace = true zksync_contracts.workspace = true zksync_multivm.workspace = true zksync_system_constants.workspace = true -circuit_sequencer_api_1_4_0.workspace = true -circuit_sequencer_api_1_4_1.workspace = true -circuit_sequencer_api_1_5_0.workspace = true +circuit_encodings.workspace = true zk_evm_1_5_0.workspace = true -zk_evm_1_4_1.workspace = true -zk_evm_1_3_3.workspace = true tokio = { workspace = true, features = ["time"] } futures.workspace = true diff --git a/core/node/commitment_generator/src/utils.rs b/core/node/commitment_generator/src/utils.rs index cc44d7a03c71..b0a0562d8ec5 100644 --- a/core/node/commitment_generator/src/utils.rs +++ b/core/node/commitment_generator/src/utils.rs @@ -4,14 +4,6 @@ use std::fmt; use anyhow::Context; use itertools::Itertools; -use zk_evm_1_3_3::{ - aux_structures::Timestamp as Timestamp_1_3_3, - zk_evm_abstractions::queries::LogQuery as LogQuery_1_3_3, -}; -use zk_evm_1_4_1::{ - aux_structures::Timestamp as Timestamp_1_4_1, - zk_evm_abstractions::queries::LogQuery as LogQuery_1_4_1, -}; use zk_evm_1_5_0::{ aux_structures::Timestamp as Timestamp_1_5_0, zk_evm_abstractions::queries::LogQuery as LogQuery_1_5_0, @@ -22,7 +14,6 @@ use zksync_multivm::{interface::VmEvent, utils::get_used_bootloader_memory_bytes use zksync_system_constants::message_root::{AGG_TREE_HEIGHT_KEY, AGG_TREE_NODES_KEY}; use zksync_types::{ address_to_u256, h256_to_u256, u256_to_h256, - vm::VmVersion, web3::keccak256, zk_evm_types::{LogQuery, Timestamp}, AccountTreeId, L1BatchNumber, ProtocolVersionId, StorageKey, EVENT_WRITER_ADDRESS, H256, @@ -54,37 +45,15 @@ impl CommitmentComputer for RealCommitmentComputer { fn events_queue_commitment( &self, events_queue: &[LogQuery], - protocol_version: ProtocolVersionId, + _protocol_version: ProtocolVersionId, ) -> anyhow::Result { - match VmVersion::from(protocol_version) { - VmVersion::VmBoojumIntegration => Ok(H256( - circuit_sequencer_api_1_4_0::commitments::events_queue_commitment_fixed( - &events_queue - .iter() - .map(|x| to_log_query_1_3_3(*x)) - .collect(), - ), - )), - VmVersion::Vm1_4_1 | VmVersion::Vm1_4_2 => Ok(H256( - circuit_sequencer_api_1_4_1::commitments::events_queue_commitment_fixed( - &events_queue - .iter() - .map(|x| to_log_query_1_4_1(*x)) - .collect(), - ), - )), - VmVersion::Vm1_5_0SmallBootloaderMemory - | VmVersion::Vm1_5_0IncreasedBootloaderMemory - | VmVersion::VmGateway => Ok(H256( - circuit_sequencer_api_1_5_0::commitments::events_queue_commitment_fixed( - &events_queue - .iter() - .map(|x| to_log_query_1_5_0(*x)) - .collect(), - ), - )), - _ => anyhow::bail!("Unsupported protocol version: {protocol_version:?}"), - } + let commitment = circuit_encodings::commitments::events_queue_commitment_fixed( + &events_queue + .iter() + .map(|x| to_log_query_1_5_0(*x)) + .collect(), + ); + Ok(H256(commitment)) } fn bootloader_initial_content_commitment( @@ -100,27 +69,10 @@ impl CommitmentComputer for RealCommitmentComputer { let full_bootloader_memory = expand_memory_contents(initial_bootloader_contents, expanded_memory_size); - - match VmVersion::from(protocol_version) { - VmVersion::VmBoojumIntegration => Ok(H256( - circuit_sequencer_api_1_4_0::commitments::initial_heap_content_commitment_fixed( - &full_bootloader_memory, - ), - )), - VmVersion::Vm1_4_1 | VmVersion::Vm1_4_2 => Ok(H256( - circuit_sequencer_api_1_4_1::commitments::initial_heap_content_commitment_fixed( - &full_bootloader_memory, - ), - )), - VmVersion::Vm1_5_0SmallBootloaderMemory - | VmVersion::Vm1_5_0IncreasedBootloaderMemory - | VmVersion::VmGateway => Ok(H256( - circuit_sequencer_api_1_5_0::commitments::initial_heap_content_commitment_fixed( - &full_bootloader_memory, - ), - )), - _ => unreachable!(), - } + let commitment = circuit_encodings::commitments::initial_heap_content_commitment_fixed( + &full_bootloader_memory, + ); + Ok(H256(commitment)) } } @@ -133,37 +85,6 @@ fn expand_memory_contents(packed: &[(usize, U256)], memory_size_bytes: usize) -> result } -fn to_log_query_1_3_3(log_query: LogQuery) -> LogQuery_1_3_3 { - LogQuery_1_3_3 { - timestamp: Timestamp_1_3_3(log_query.timestamp.0), - tx_number_in_block: log_query.tx_number_in_block, - aux_byte: log_query.aux_byte, - shard_id: log_query.shard_id, - address: log_query.address, - key: log_query.key, - read_value: log_query.read_value, - written_value: log_query.written_value, - rw_flag: log_query.rw_flag, - rollback: log_query.rollback, - is_service: log_query.is_service, - } -} - -fn to_log_query_1_4_1(log_query: LogQuery) -> LogQuery_1_4_1 { - LogQuery_1_4_1 { - timestamp: Timestamp_1_4_1(log_query.timestamp.0), - tx_number_in_block: log_query.tx_number_in_block, - aux_byte: log_query.aux_byte, - shard_id: log_query.shard_id, - address: log_query.address, - key: log_query.key, - read_value: log_query.read_value, - written_value: log_query.written_value, - rw_flag: log_query.rw_flag, - rollback: log_query.rollback, - is_service: log_query.is_service, - } -} fn to_log_query_1_5_0(log_query: LogQuery) -> LogQuery_1_5_0 { LogQuery_1_5_0 { diff --git a/core/node/genesis/src/utils.rs b/core/node/genesis/src/utils.rs index a9b0831b31bc..ac3435835e80 100644 --- a/core/node/genesis/src/utils.rs +++ b/core/node/genesis/src/utils.rs @@ -99,7 +99,7 @@ pub fn get_deduped_log_queries(storage_logs: &[StorageLog]) -> Vec { }) .collect(); - let deduped_log_queries: Vec = sort_storage_access_queries(&log_queries) + let deduped_log_queries: Vec = sort_storage_access_queries(log_queries) .1 .into_iter() .map(|log_query| LogQuery { diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 185f68367c6b..fa8de019c740 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -625,9 +625,9 @@ dependencies = [ [[package]] name = "boojum" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ec2f007ff8f90cc459f03e9f30ca1065440170f013c868823646e2e48d0234" +checksum = "4337dc7b196fc3e5e55e2857bc21638b7441429ee1a953201a9cd2be187b764e" dependencies = [ "arrayvec 0.7.6", "bincode", @@ -657,9 +657,9 @@ dependencies = [ [[package]] name = "boojum-cuda" -version = "0.151.1" +version = "0.152.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b63a717789f92f16fd566c78655d64017c690be59e473c3e769080c975a1f9e" +checksum = "380468fadcba5dcc4021f18f4516a7aa4f4d0ec598c76cd7e7c5f2ff6a56733f" dependencies = [ "boojum", "cmake", @@ -667,6 +667,7 @@ dependencies = [ "era_cudart_sys", "itertools 0.13.0", "lazy_static", + "snark_wrapper", ] [[package]] @@ -804,11 +805,11 @@ dependencies = [ [[package]] name = "circuit_definitions" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76be9ee6e75f1f948d175ab9820ecc7189f72154c95ca503a1974012356f5363" +checksum = "931448074d9dad8aa7cf8f8f8d67101d4b2aac4d1f4699708b0744a9c000fc0b" dependencies = [ - "circuit_encodings 0.150.7", + "circuit_encodings", "crossbeam", "derivative", "seq-macro", @@ -818,117 +819,26 @@ dependencies = [ [[package]] name = "circuit_encodings" -version = "0.140.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6b7cc842eadb4c250cdc6a8bc1dd97624d9f08bbe54db3e11fb23c3a72be07" -dependencies = [ - "derivative", - "serde", - "zk_evm 0.140.0", - "zkevm_circuits 0.140.3", -] - -[[package]] -name = "circuit_encodings" -version = "0.141.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7898ffbf3cd413576b4b674fe1545a35488c67eb16bd5a4148425e42c2a2b65b" -dependencies = [ - "derivative", - "serde", - "zk_evm 0.141.0", - "zkevm_circuits 0.141.2", -] - -[[package]] -name = "circuit_encodings" -version = "0.142.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8364ecafcc4b2c896023f8d3af952c52a500aa55f14fd268bb5d9ab07f837369" -dependencies = [ - "derivative", - "serde", - "zk_evm 0.141.0", - "zkevm_circuits 0.141.2", -] - -[[package]] -name = "circuit_encodings" -version = "0.150.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2501cc688ef391013019495ae7035cfd54f86987e36d10f73976ce4c5d413c5a" -dependencies = [ - "derivative", - "serde", - "zk_evm 0.150.7", - "zkevm_circuits 0.150.7", -] - -[[package]] -name = "circuit_sequencer_api" -version = "0.133.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb959b1f8c6bbd8be711994d182e85452a26a5d2213a709290b71c8262af1331" -dependencies = [ - "derivative", - "rayon", - "serde", - "zk_evm 0.133.0", - "zksync_bellman", -] - -[[package]] -name = "circuit_sequencer_api" -version = "0.140.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5f22311ce609d852d7d9f4943535ea4610aeb785129ae6ff83d5201c4fb387" -dependencies = [ - "circuit_encodings 0.140.3", - "derivative", - "rayon", - "serde", - "zk_evm 0.140.0", - "zksync_bellman", -] - -[[package]] -name = "circuit_sequencer_api" -version = "0.141.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c47c71d6ba83a8beb0af13af70beffd627f5497caf3d44c6f96363e788b07ea" -dependencies = [ - "circuit_encodings 0.141.2", - "derivative", - "rayon", - "serde", - "zk_evm 0.141.0", - "zksync_bellman", -] - -[[package]] -name = "circuit_sequencer_api" -version = "0.142.2" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e264723359e6a1aad98110bdccf1ae3ad596e93e7d31da9e40f6adc07e4add54" +checksum = "e3dcfcb4aaa17e6a81ebd2db688d980aff50aa643d9b506d4d11c84976dbc03f" dependencies = [ - "circuit_encodings 0.142.2", "derivative", - "rayon", "serde", - "zk_evm 0.141.0", - "zksync_bellman", + "zk_evm 0.150.18", + "zkevm_circuits", ] [[package]] name = "circuit_sequencer_api" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917d27db531fdd98a51e42ea465bc097f48cc849e7fad68d7856087d15125be1" +checksum = "d13ed70909e8390a4f2599d5a76d9ac4189e5bbbf16146d11b7999788740f291" dependencies = [ - "circuit_encodings 0.150.7", "derivative", "rayon", "serde", + "zk_evm 0.150.18", "zksync_bellman", ] @@ -1796,9 +1706,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "era_cudart" -version = "0.151.1" +version = "0.152.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad950752eeb44f8938be405b95a1630f82e903f4a7adda355d92aad135fcd382" +checksum = "ac345935bc5d367922a8e44f8b9b8f909f564b4cdc922567e9d3fe6b0fafab28" dependencies = [ "bitflags 2.6.0", "era_cudart_sys", @@ -1807,9 +1717,9 @@ dependencies = [ [[package]] name = "era_cudart_sys" -version = "0.151.1" +version = "0.152.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c38607d52509b5db97cc4447c8644d6c5ca84f22ff8a9254f984669b1eb82ed4" +checksum = "50eca396c549365468fa210b0c9c4a38895e4bff4ae5ce6f6626c337010de143" dependencies = [ "serde_json", ] @@ -2030,9 +1940,9 @@ dependencies = [ [[package]] name = "franklin-crypto" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "971289216ea5c91872e5e0bb6989214b537bbce375d09fabea5c3ccfe031b204" +checksum = "5c128e2cf791053b3aefdd7b07d6e5ffdc7cf5dd779ca270d727a403057dfb68" dependencies = [ "arr_macro", "bit-vec 0.6.3", @@ -5109,9 +5019,9 @@ dependencies = [ [[package]] name = "rescue_poseidon" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82900c877a0ba5362ac5756efbd82c5b795dc509011c1253e2389d8708f1389d" +checksum = "b62e4ce7543582ab2df1d9544674a55897e168a23afe938a57e1547d2981a7f4" dependencies = [ "addchain", "arrayvec 0.7.6", @@ -5899,12 +5809,11 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "shivini" -version = "0.151.1" +version = "0.152.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d2ac4440b6c23005c43a81cf064b9aa123fbeb992ac91cd04c7d485abb1fbea" +checksum = "2673af97e7ea5aef8d1d2ad395e3833a2a9fd8aca6361c2516c44734c0ed92e2" dependencies = [ "bincode", - "blake2 0.10.6", "boojum", "boojum-cuda", "circuit_definitions", @@ -5912,9 +5821,9 @@ dependencies = [ "era_cudart", "era_cudart_sys", "hex", + "itertools 0.13.0", "rand 0.8.5", "serde", - "sha2 0.10.8", "smallvec", ] @@ -5991,13 +5900,14 @@ dependencies = [ [[package]] name = "snark_wrapper" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5dfdc3eed51d79541adff827593743750fe6626a65006814f8cfa4273371de" +checksum = "74645922ea9e18fbd4b6ae9c58e6a7080403edd81e558b610cf5b9dc60a90351" dependencies = [ "derivative", "rand 0.4.6", "rescue_poseidon", + "serde", ] [[package]] @@ -7878,9 +7788,9 @@ dependencies = [ [[package]] name = "zk_evm" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc74fbe2b45fd19e95c59ea792c795feebdb616ebaa463f0ac567f495f47387" +checksum = "3278d0f75408ab35d25998e1124124cd108b48b2a81ed8e71e892ddc5a6be0aa" dependencies = [ "anyhow", "lazy_static", @@ -7888,7 +7798,7 @@ dependencies = [ "serde", "serde_json", "static_assertions", - "zk_evm_abstractions 0.150.7", + "zk_evm_abstractions 0.150.18", ] [[package]] @@ -7919,22 +7829,22 @@ dependencies = [ [[package]] name = "zk_evm_abstractions" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37f333a3b059899df09e40deb041af881bc03e496fda5eec618ffb5e854ee7df" +checksum = "88b4e5a89cfe1594b6476be16c8c1d45f22ce12bff31c49e077b381a398edd8a" dependencies = [ "anyhow", "num_enum 0.6.1", "serde", "static_assertions", - "zkevm_opcode_defs 0.150.7", + "zkevm_opcode_defs 0.150.18", ] [[package]] name = "zkevm-assembly" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf011a0c83cbfb175f1e60811f0e0cd56551c9e35df596a762556662c638deb9" +checksum = "b4fdb2b380c43157160ec5f3f4f6912c6c9923e2a00886e79b7f5464f59108a7" dependencies = [ "env_logger 0.9.3", "hex", @@ -7947,58 +7857,14 @@ dependencies = [ "smallvec", "structopt", "thiserror 1.0.69", - "zkevm_opcode_defs 0.150.7", -] - -[[package]] -name = "zkevm_circuits" -version = "0.140.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c365c801e0c6eda83fbd153df45575172beb406bfb663d386f9154b4325eda" -dependencies = [ - "arrayvec 0.7.6", - "bincode", - "boojum", - "derivative", - "hex", - "itertools 0.10.5", - "rand 0.4.6", - "rand 0.8.5", - "seq-macro", - "serde", - "serde_json", - "smallvec", - "zkevm_opcode_defs 0.132.0", - "zksync_cs_derive", -] - -[[package]] -name = "zkevm_circuits" -version = "0.141.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccd0352e122a4e6f0046d2163b7e692e627b23fc3264faa77331a21b65833fd" -dependencies = [ - "arrayvec 0.7.6", - "bincode", - "boojum", - "derivative", - "hex", - "itertools 0.10.5", - "rand 0.4.6", - "rand 0.8.5", - "seq-macro", - "serde", - "serde_json", - "smallvec", - "zkevm_opcode_defs 0.141.0", - "zksync_cs_derive", + "zkevm_opcode_defs 0.150.18", ] [[package]] name = "zkevm_circuits" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06fb35b00699d25175a2ad447f86a9088af8b0bc698bb57086fb04c13e52eab" +checksum = "8b94288d2e246aecd6eecd22ef27db0d1f29a91cb4f59b9e339a45237131a9ff" dependencies = [ "arrayvec 0.7.6", "boojum", @@ -8010,7 +7876,7 @@ dependencies = [ "seq-macro", "serde", "smallvec", - "zkevm_opcode_defs 0.150.7", + "zkevm_opcode_defs 0.150.18", "zksync_cs_derive", ] @@ -8058,9 +7924,9 @@ dependencies = [ [[package]] name = "zkevm_opcode_defs" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b83f3b279248af4ca86dec20a54127f02110b45570f3f6c1d13df49ba75c28a5" +checksum = "5bad437d4891536fdcc0054a3f04562c408817ff19d83b6c27569217692e6e74" dependencies = [ "bitflags 2.6.0", "blake2 0.10.6", @@ -8075,13 +7941,14 @@ dependencies = [ [[package]] name = "zkevm_test_harness" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c801aa17e9009699aacf654588d6adfaeeb8a490b2d9121847c201e2766803" +checksum = "9bd2de75d0bf68137ba150e05dd5d36baad03e682e06b8616643c72b3fcce05d" dependencies = [ "bincode", "circuit_definitions", - "circuit_sequencer_api 0.150.7", + "circuit_encodings", + "circuit_sequencer_api", "codegen", "crossbeam", "derivative", @@ -8102,9 +7969,9 @@ dependencies = [ [[package]] name = "zksync-gpu-ffi" -version = "0.151.1" +version = "0.152.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5688dc060456f6c1e790d589f3abd6d9e9a11eb393d7383fbeb23b55961951e0" +checksum = "bc1f77eb5f1a513357e53fba148f46a03fdbea222dc71f270123984059c285bf" dependencies = [ "cmake", "crossbeam", @@ -8117,9 +7984,9 @@ dependencies = [ [[package]] name = "zksync-gpu-prover" -version = "0.151.1" +version = "0.152.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5714848e6f8361820346483246dd68b4e7fb05ec41dd6610a8b53fb5c3ca7f3a" +checksum = "3cc0c452445a120c5928e0ac89d47242f407b303ee819e3b7b2a97f6ce7491e4" dependencies = [ "bit-vec 0.6.3", "cfg-if", @@ -8134,9 +8001,9 @@ dependencies = [ [[package]] name = "zksync-wrapper-prover" -version = "0.151.1" +version = "0.152.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52a6a1863818d939d445c53af57e53c222f11c2c94b9a94c3612dd938a3d983c" +checksum = "972dc1059d4a97ad075ab5a3589722b16d22c5241ba6e711ac18a73195aa6584" dependencies = [ "circuit_definitions", "zkevm_test_harness", @@ -8166,9 +8033,9 @@ dependencies = [ [[package]] name = "zksync_bellman" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffa03efe9bdb137a4b36b97d1a74237e18c9ae42b755163d903a9d48c1a5d80" +checksum = "6b7c0061db44757522f2d82cad02f45dc98267210ac362071234ed08e30fd4d6" dependencies = [ "arrayvec 0.7.6", "bit-vec 0.6.3", @@ -8392,9 +8259,9 @@ dependencies = [ [[package]] name = "zksync_cs_derive" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5939e2df4288c263c706ff18ac718e984149223ad4289d6d957d767dcfc04c81" +checksum = "63296ce43c432d5d0111604173e874b2f2a856e1cb1c76378fa0bb5ac6018c27" dependencies = [ "proc-macro-error", "proc-macro2 1.0.92", @@ -8494,9 +8361,9 @@ dependencies = [ [[package]] name = "zksync_ff" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9524b06780b5e164e84b38840c7c428c739f051f35af6efc4d1285f629ceb88e" +checksum = "e6a500c97d9286f73540c26b63ae33b159bd48fec0c8bd206b4a9b4fe1217b8a" dependencies = [ "byteorder", "hex", @@ -8507,9 +8374,9 @@ dependencies = [ [[package]] name = "zksync_ff_derive" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f91e58e75d65877f09f83bc3dca8f054847ae7ec4f3e64bfa610a557edd8e8e" +checksum = "97bd48f18ebf350623093022d86be2f1ce23af332efa91890b751209aec8617a" dependencies = [ "num-bigint 0.4.6", "num-integer", @@ -8522,9 +8389,9 @@ dependencies = [ [[package]] name = "zksync_kzg" -version = "0.150.7" +version = "0.150.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc58af8e4e4ad1a851ffd2275e6a44ead0f15a7eaac9dc9d60a56b3b9c9b08e8" +checksum = "6384d2475e4a7e6ed4e2a703724cac1d8972d9ec40c49fdd17bf37942a81a635" dependencies = [ "boojum", "derivative", @@ -8534,7 +8401,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "zkevm_circuits 0.150.7", + "zkevm_circuits", ] [[package]] @@ -8566,11 +8433,7 @@ name = "zksync_multivm" version = "0.1.0" dependencies = [ "anyhow", - "circuit_sequencer_api 0.133.1", - "circuit_sequencer_api 0.140.3", - "circuit_sequencer_api 0.141.2", - "circuit_sequencer_api 0.142.2", - "circuit_sequencer_api 0.150.7", + "circuit_sequencer_api", "ethabi", "hex", "itertools 0.10.5", @@ -8582,7 +8445,7 @@ dependencies = [ "zk_evm 0.133.0", "zk_evm 0.140.0", "zk_evm 0.141.0", - "zk_evm 0.150.7", + "zk_evm 0.150.18", "zksync_contracts", "zksync_mini_merkle_tree", "zksync_system_constants", @@ -8616,9 +8479,9 @@ dependencies = [ [[package]] name = "zksync_pairing" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8412ae5574472fa567a097e183f9a01974b99dd0b5da3bfa1bbe6c57c579aa2" +checksum = "3b91b38db3a3f0f80d8b1f2342c77751ee8d63b746268e5719abbb5dfb150a8c" dependencies = [ "byteorder", "cfg-if", @@ -8634,7 +8497,7 @@ dependencies = [ "anyhow", "async-trait", "bincode", - "circuit_sequencer_api 0.150.7", + "circuit_sequencer_api", "clap 4.5.23", "ctrlc", "futures 0.3.31", @@ -8859,7 +8722,7 @@ name = "zksync_prover_interface" version = "0.1.0" dependencies = [ "chrono", - "circuit_sequencer_api 0.150.7", + "circuit_sequencer_api", "serde", "serde_with", "strum", @@ -8911,6 +8774,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bincode", + "boojum-cuda", "circuit_definitions", "futures 0.3.31", "hex", @@ -8942,9 +8806,9 @@ dependencies = [ [[package]] name = "zksync_solidity_vk_codegen" -version = "0.30.1" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b310ab8a21681270e73f177ddf7974cabb7a96f0624ab8b008fd6ee1f9b4f687" +checksum = "6f03e137db1b29be36abfa1e1e682dd3864b0335c68282c8dab68c2d397b8cbd" dependencies = [ "ethereum-types", "franklin-crypto", @@ -9005,6 +8869,7 @@ dependencies = [ "once_cell", "reqwest 0.12.9", "serde_json", + "sha2 0.10.8", "tokio", "tracing", "zksync_vlog", @@ -9062,8 +8927,8 @@ source = "git+https://github.com/matter-labs/vm2.git?rev=457d8a7eea9093af9440662 dependencies = [ "enum_dispatch", "primitive-types", - "zk_evm_abstractions 0.150.7", - "zkevm_opcode_defs 0.150.7", + "zk_evm_abstractions 0.150.18", + "zkevm_opcode_defs 0.150.18", "zksync_vm2_interface", ] diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 15e819d77f7d..aea458cb9e48 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -67,13 +67,14 @@ url = "2.5.2" vise = "0.2.0" # Proving dependencies -circuit_definitions = "=0.150.7" -circuit_sequencer_api = "=0.150.7" -zkevm_test_harness = "=0.150.7" +circuit_definitions = "=0.150.18" +circuit_sequencer_api = "=0.150.18" +zkevm_test_harness = "=0.150.18" # GPU proving dependencies -wrapper_prover = { package = "zksync-wrapper-prover", version = "=0.151.1" } -shivini = "=0.151.1" +wrapper_prover = { package = "zksync-wrapper-prover", version = "=0.152.9" } +shivini = "=0.152.9" +boojum-cuda = "=0.152.9" # Core workspace dependencies zksync_multivm = { path = "../core/lib/multivm", version = "0.1.0" } diff --git a/prover/crates/bin/prover_fri/src/gpu_prover_job_processor.rs b/prover/crates/bin/prover_fri/src/gpu_prover_job_processor.rs index cfd588c26662..9817362c9fea 100644 --- a/prover/crates/bin/prover_fri/src/gpu_prover_job_processor.rs +++ b/prover/crates/bin/prover_fri/src/gpu_prover_job_processor.rs @@ -1,6 +1,6 @@ #[cfg(feature = "gpu")] pub mod gpu_prover { - use std::{collections::HashMap, sync::Arc, time::Instant}; + use std::{alloc::Global, collections::HashMap, sync::Arc, time::Instant}; use anyhow::Context as _; use shivini::{ @@ -174,7 +174,7 @@ pub mod gpu_prover { DefaultTranscript, DefaultTreeHasher, NoPow, - _, + Global, >( &gpu_proof_config, &witness_vector, diff --git a/prover/crates/bin/prover_fri/src/lib.rs b/prover/crates/bin/prover_fri/src/lib.rs index 39757795d980..76a97f119f4b 100644 --- a/prover/crates/bin/prover_fri/src/lib.rs +++ b/prover/crates/bin/prover_fri/src/lib.rs @@ -1,5 +1,5 @@ #![allow(incomplete_features)] // We have to use generic const exprs. -#![feature(generic_const_exprs)] +#![feature(generic_const_exprs, allocator_api)] mod metrics; pub mod prover_job_processor; pub mod utils; diff --git a/prover/crates/bin/prover_fri/src/main.rs b/prover/crates/bin/prover_fri/src/main.rs index cbba8d0ddb4f..d464cb630be2 100644 --- a/prover/crates/bin/prover_fri/src/main.rs +++ b/prover/crates/bin/prover_fri/src/main.rs @@ -1,5 +1,5 @@ #![allow(incomplete_features)] // We have to use generic const exprs. -#![feature(generic_const_exprs)] +#![feature(generic_const_exprs, allocator_api)] use std::{future::Future, sync::Arc, time::Duration}; diff --git a/prover/crates/bin/witness_generator/src/rounds/basic_circuits/mod.rs b/prover/crates/bin/witness_generator/src/rounds/basic_circuits/mod.rs index adb2bf72d04f..233e59877cb8 100644 --- a/prover/crates/bin/witness_generator/src/rounds/basic_circuits/mod.rs +++ b/prover/crates/bin/witness_generator/src/rounds/basic_circuits/mod.rs @@ -4,7 +4,7 @@ use async_trait::async_trait; use circuit_definitions::zkevm_circuits::scheduler::{ block_header::BlockAuxilaryOutputWitness, input::SchedulerCircuitInstanceWitness, }; -use zksync_multivm::circuit_sequencer_api_latest::boojum::{ +use zkevm_test_harness::boojum::{ field::goldilocks::{GoldilocksExt2, GoldilocksField}, gadgets::recursion::recursive_tree_hasher::CircuitGoldilocksPoseidon2Sponge, }; diff --git a/prover/crates/bin/witness_generator/src/rounds/basic_circuits/utils.rs b/prover/crates/bin/witness_generator/src/rounds/basic_circuits/utils.rs index 31dc54814103..348ba1dcd996 100644 --- a/prover/crates/bin/witness_generator/src/rounds/basic_circuits/utils.rs +++ b/prover/crates/bin/witness_generator/src/rounds/basic_circuits/utils.rs @@ -11,11 +11,11 @@ use circuit_definitions::{ }; use tokio::sync::Semaphore; use tracing::Instrument; -use zkevm_test_harness::witness::oracle::WitnessGenerationArtifact; +use zkevm_test_harness::{ + boojum::field::goldilocks::GoldilocksField, witness::oracle::WitnessGenerationArtifact, +}; use zksync_multivm::{ - circuit_sequencer_api_latest::{ - boojum::field::goldilocks::GoldilocksField, geometry_config::get_geometry_config, - }, + circuit_sequencer_api_latest::geometry_config::ProtocolGeometry, interface::storage::StorageView, vm_latest::{constants::MAX_CYCLES_FOR_TX, HistoryDisabled, StorageOracle as VmStorageOracle}, zk_evm_latest::ethereum_types::Address, @@ -52,7 +52,7 @@ pub(super) async fn generate_witness( input.merkle_paths, input.previous_batch_metadata.root_hash.0, ); - let geometry_config = get_geometry_config(); + let geometry_config = ProtocolGeometry::V1_5_0.config(); let mut hasher = DefaultHasher::new(); geometry_config.hash(&mut hasher); tracing::info!( diff --git a/prover/crates/lib/circuit_prover_service/src/lib.rs b/prover/crates/lib/circuit_prover_service/src/lib.rs index 0d7b146cc43b..bbf1f9733f6f 100644 --- a/prover/crates/lib/circuit_prover_service/src/lib.rs +++ b/prover/crates/lib/circuit_prover_service/src/lib.rs @@ -1,5 +1,5 @@ #![allow(incomplete_features)] // Crypto code uses generic const exprs -#![feature(generic_const_exprs)] +#![feature(generic_const_exprs, allocator_api)] mod gpu_circuit_prover; pub mod job_runner; mod metrics; diff --git a/prover/crates/lib/circuit_prover_service/src/types/circuit.rs b/prover/crates/lib/circuit_prover_service/src/types/circuit.rs index 19c05666b2c5..264daba63b7d 100644 --- a/prover/crates/lib/circuit_prover_service/src/types/circuit.rs +++ b/prover/crates/lib/circuit_prover_service/src/types/circuit.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{alloc::Global, sync::Arc}; use anyhow::Context; use shivini::{gpu_proof_config::GpuProofConfig, gpu_prove_from_external_witness_data}; @@ -84,7 +84,7 @@ impl Circuit { let span = tracing::info_span!("prove_base_circuit").entered(); let gpu_proof_config = GpuProofConfig::from_base_layer_circuit(circuit); let boojum_proof_config = base_layer_proof_config(); - let proof = gpu_prove_from_external_witness_data::( + let proof = gpu_prove_from_external_witness_data::( &gpu_proof_config, &witness_vector, boojum_proof_config, @@ -113,7 +113,7 @@ impl Circuit { let span = tracing::info_span!("prove_recursive_circuit").entered(); let gpu_proof_config = GpuProofConfig::from_recursive_layer_circuit(circuit); let boojum_proof_config = recursion_layer_proof_config(); - let proof = gpu_prove_from_external_witness_data::( + let proof = gpu_prove_from_external_witness_data::( &gpu_proof_config, &witness_vector, boojum_proof_config, diff --git a/prover/crates/lib/keystore/Cargo.toml b/prover/crates/lib/keystore/Cargo.toml index 4d9addc26bc0..8dac09b782c0 100644 --- a/prover/crates/lib/keystore/Cargo.toml +++ b/prover/crates/lib/keystore/Cargo.toml @@ -17,6 +17,7 @@ zksync_prover_fri_types.workspace = true zkevm_test_harness.workspace = true circuit_definitions = { workspace = true, features = ["log_tracing"] } shivini = { workspace = true, optional = true } +boojum-cuda = { workspace = true, optional = true } anyhow.workspace = true tracing.workspace = true @@ -32,4 +33,4 @@ futures = { workspace = true, features = ["compat"] } [features] default = [] -gpu = ["shivini"] +gpu = ["shivini", "boojum-cuda"] diff --git a/prover/crates/lib/keystore/src/lib.rs b/prover/crates/lib/keystore/src/lib.rs index 7e60e3fa29cd..543b7b18ffe5 100644 --- a/prover/crates/lib/keystore/src/lib.rs +++ b/prover/crates/lib/keystore/src/lib.rs @@ -1,6 +1,8 @@ #![feature(allocator_api)] use serde::{Deserialize, Serialize}; +#[cfg(feature = "gpu")] +use shivini::cs::GpuSetup; use zkevm_test_harness::compute_setups::CircuitSetupData; use zksync_prover_fri_types::circuit_definitions::boojum::{ algebraic_props::{round_function::AbsorptionModeOverwrite, sponge::GenericAlgebraicSponge}, @@ -19,8 +21,6 @@ use zksync_prover_fri_types::circuit_definitions::boojum::{ }, implementations::poseidon2::Poseidon2Goldilocks, }; -#[cfg(feature = "gpu")] -use {shivini::cs::GpuSetup, std::alloc::Global}; pub mod commitment_utils; pub mod keystore; @@ -84,11 +84,12 @@ impl From for GoldilocksProverSetupData { #[cfg(feature = "gpu")] #[derive(Debug, Serialize, Deserialize)] #[serde(bound = "F: serde::Serialize + serde::de::DeserializeOwned")] -pub struct GpuProverSetupData> { - pub setup: GpuSetup, +pub struct GpuProverSetupData> +{ + pub setup: GpuSetup, #[serde(bound( - serialize = "H::Output: serde::Serialize", - deserialize = "H::Output: serde::de::DeserializeOwned" + serialize = ">::Output: serde::Serialize", + deserialize = ">::Output: serde::de::DeserializeOwned" ))] pub vk: VerificationKey, pub finalization_hint: FinalizationHintsForProver, diff --git a/prover/crates/lib/keystore/src/setup_data_generator.rs b/prover/crates/lib/keystore/src/setup_data_generator.rs index c4790d67feaa..0bbd6cb5d14d 100644 --- a/prover/crates/lib/keystore/src/setup_data_generator.rs +++ b/prover/crates/lib/keystore/src/setup_data_generator.rs @@ -5,13 +5,17 @@ use std::collections::HashMap; use anyhow::Context as _; use zkevm_test_harness::{ - compute_setups::{generate_circuit_setup_data, CircuitSetupData}, + compute_setups::{ + generate_circuit_setup_data, light::generate_light_circuit_setup_data, CircuitSetupData, + }, data_source::SetupDataSource, }; use zksync_prover_fri_types::ProverServiceDataKey; #[cfg(feature = "gpu")] use { - crate::GpuProverSetupData, shivini::cs::setup::GpuSetup, shivini::ProverContext, + crate::GpuProverSetupData, + boojum_cuda::poseidon2::GLHasher, + shivini::{cs::gpu_setup_and_vk_from_base_setup_vk_params_and_hints, ProverContext}, zksync_prover_fri_types::circuit_definitions::boojum::worker::Worker, }; @@ -25,7 +29,7 @@ pub fn generate_setup_data_common( ) -> anyhow::Result { let mut data_source = keystore.load_keys_to_data_source()?; let circuit_setup_data = generate_circuit_setup_data( - circuit.is_base_layer(), + circuit.round as u8, // TODO: Actually it's called "ProvingStage" now circuit.circuit_id, &mut data_source, ) @@ -151,20 +155,29 @@ impl SetupDataGenerator for GPUSetupDataGenerator { { let _context = ProverContext::create().context("failed initializing gpu prover context")?; - let circuit_setup_data = generate_setup_data_common(&self.keystore, circuit)?; - let worker = Worker::new(); - let gpu_setup_data = GpuSetup::from_setup_and_hints( - circuit_setup_data.setup_base, - circuit_setup_data.setup_tree, - circuit_setup_data.vars_hint.clone(), - circuit_setup_data.wits_hint, - &worker, + let mut data_source = self.keystore.load_keys_to_data_source()?; + let circuit_setup_data = generate_light_circuit_setup_data( + circuit.round as u8, + circuit.circuit_id, + &mut data_source, ) - .context("failed creating GPU base layer setup data")?; + .unwrap(); + + let worker = Worker::new(); + // TODO: add required assertions + let (gpu_setup_data, vk) = + gpu_setup_and_vk_from_base_setup_vk_params_and_hints::( + circuit_setup_data.setup_base, + circuit_setup_data.vk_geometry, + circuit_setup_data.vars_hint.clone(), + circuit_setup_data.wits_hint, + &worker, + ) + .context("failed creating GPU base layer setup data")?; let gpu_prover_setup_data = GpuProverSetupData { setup: gpu_setup_data, - vk: circuit_setup_data.vk, + vk: vk.clone(), finalization_hint: circuit_setup_data.finalization_hint, }; // Serialization should always succeed. diff --git a/prover/setup-data-gpu-keys.json b/prover/setup-data-gpu-keys.json index 4acc51b9add0..8a3bdeb262c1 100644 --- a/prover/setup-data-gpu-keys.json +++ b/prover/setup-data-gpu-keys.json @@ -1,5 +1,5 @@ { - "us": "gs://matterlabs-setup-data-us/ffc5da2-gpu/", - "europe": "gs://matterlabs-setup-data-europe/ffc5da2-gpu/", - "asia": "gs://matterlabs-setup-data-asia/ffc5da2-gpu/" + "us": "gs://matterlabs-setup-data-us/dc3bba7-gpu/", + "europe": "gs://matterlabs-setup-data-europe/dc3bba7-gpu/", + "asia": "gs://matterlabs-setup-data-asia/dc3bba7-gpu/" } diff --git a/zkstack_cli/Cargo.lock b/zkstack_cli/Cargo.lock index 900ac677fd61..4e9bb4b1c76c 100644 --- a/zkstack_cli/Cargo.lock +++ b/zkstack_cli/Cargo.lock @@ -6771,9 +6771,9 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c24c9a056499823227503dd9e5fb3037d93bcc3ae9b06c1ac0a47334c6283af" +checksum = "e8312ab73d3caa55775bd531795b507fa8f76bd9dabfaeb0954fe43e8fc1323b" dependencies = [ "anyhow", "once_cell", @@ -6804,9 +6804,9 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da303b01f24283e93f80f361bf62c3df4a761d061c8b38b4faebeebf26362fc" +checksum = "86b539960de98df3c3bd27d2d9b97de862027686bbb3bdfc5aaad5b74bb929a1" dependencies = [ "anyhow", "blst", @@ -6825,9 +6825,9 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f07db2a8ec2d2cda5cb4c5ac408101e81c8fa5d95c9f3302829dafae78d11c" +checksum = "c49949546895a10431b9daec6ec4208ef0917ace006446d304b51f5b234ba462" dependencies = [ "anyhow", "bit-vec", @@ -6847,9 +6847,9 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3222410c67617a86edb192e0c4bb48afc254a17052200a0a839c90e8b0378842" +checksum = "723e2a4b056cc5af192a83163c89a6951ee75c098cc5c4a4cdc435f4232d88bd" dependencies = [ "anyhow", "rand", @@ -6897,9 +6897,9 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05755c38b134b409736008bfdfd0fdb42bfa061947be93be4c78069aa10c9b3" +checksum = "e8986ad796f8e00d8999fee72effba1a21bce40f5f877d681ac9cd89a94834d8" dependencies = [ "anyhow", "bit-vec", @@ -6918,9 +6918,9 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c3930a73ca667780be6dcd94e469d40a93fa52f4654c9ab732991b62238cb5" +checksum = "8d870b31995e3acb8e47afeb68ebeeffcf6121e70020e65b3d5d31692115d236" dependencies = [ "anyhow", "heck", @@ -6946,6 +6946,7 @@ dependencies = [ "serde_yaml", "tracing", "zksync_basic_types", + "zksync_concurrency", "zksync_config", "zksync_protobuf", "zksync_protobuf_build", @@ -7000,6 +7001,7 @@ dependencies = [ "once_cell", "reqwest 0.12.9", "serde_json", + "sha2", "tokio", "tracing", "zksync_vlog",