From cb9ac4e59fd16e6c125586bc02ef90e3b97ff80b Mon Sep 17 00:00:00 2001 From: Alex Ostrovski Date: Tue, 13 Aug 2024 14:40:45 +0300 Subject: [PATCH] feat(vm): Extract VM interface to separate crate (#2638) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ - Refactors `zksync_multivm` crate by extracting its interface part into a separate crate. - Revises `zksync_state` / `zksync_multivm` uses in the workspace. ## Why ❔ - This eliminates `multivm` dependency on `zksync_state`, which is quite heavyweight (depends on `sqlx`, `rocksdb` etc.). - Makes VM interface better defined and easier to reason about. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. --- Cargo.lock | 28 +-- Cargo.toml | 2 + .../bin/system-constants-generator/Cargo.toml | 1 - .../system-constants-generator/src/utils.rs | 8 +- core/lib/multivm/Cargo.toml | 4 +- core/lib/multivm/README.md | 10 +- core/lib/multivm/src/glue/tracers/mod.rs | 4 +- .../src/glue/types/vm/vm_block_result.rs | 4 +- core/lib/multivm/src/interface/traits/mod.rs | 2 - .../src/interface/traits/tracers/mod.rs | 1 - .../multivm/src/interface/types/errors/mod.rs | 11 -- .../multivm/src/interface/types/inputs/mod.rs | 9 - core/lib/multivm/src/lib.rs | 2 +- .../multivm/src/tracers/call_tracer/mod.rs | 4 +- .../src/tracers/call_tracer/vm_1_4_1/mod.rs | 6 +- .../src/tracers/call_tracer/vm_1_4_2/mod.rs | 6 +- .../call_tracer/vm_boojum_integration/mod.rs | 6 +- .../src/tracers/call_tracer/vm_latest/mod.rs | 6 +- .../call_tracer/vm_refunds_enhancement/mod.rs | 6 +- .../call_tracer/vm_virtual_blocks/mod.rs | 8 +- .../dyn_tracers => tracers/dynamic}/mod.rs | 0 .../dynamic}/vm_1_3_3.rs | 3 +- .../dynamic}/vm_1_4_0.rs | 3 +- .../dynamic}/vm_1_4_1.rs | 3 +- .../dynamic}/vm_1_5_0.rs | 3 +- core/lib/multivm/src/tracers/mod.rs | 24 ++- .../multivm/src/tracers/multivm_dispatcher.rs | 6 +- .../src/tracers/{old_tracers.rs => old.rs} | 0 .../src/tracers/prestate_tracer/mod.rs | 3 +- .../tracers/prestate_tracer/vm_1_4_1/mod.rs | 10 +- .../tracers/prestate_tracer/vm_1_4_2/mod.rs | 9 +- .../tracers/prestate_tracer/vm_latest/mod.rs | 9 +- .../vm_refunds_enhancement/mod.rs | 9 +- .../prestate_tracer/vm_virtual_blocks/mod.rs | 9 +- .../src/tracers/storage_invocation/mod.rs | 2 +- .../storage_invocation/vm_1_4_1/mod.rs | 6 +- .../storage_invocation/vm_1_4_2/mod.rs | 6 +- .../vm_boojum_integration/mod.rs | 6 +- .../storage_invocation/vm_latest/mod.rs | 6 +- .../vm_refunds_enhancement/mod.rs | 6 +- .../vm_virtual_blocks/mod.rs | 6 +- core/lib/multivm/src/tracers/validator/mod.rs | 9 +- .../multivm/src/tracers/validator/types.rs | 39 +++- .../src/tracers/validator/vm_1_4_1/mod.rs | 18 +- .../src/tracers/validator/vm_1_4_2/mod.rs | 18 +- .../validator/vm_boojum_integration/mod.rs | 18 +- .../src/tracers/validator/vm_latest/mod.rs | 18 +- .../validator/vm_refunds_enhancement/mod.rs | 18 +- .../validator/vm_virtual_blocks/mod.rs | 19 +- core/lib/multivm/src/utils.rs | 2 +- core/lib/multivm/src/versions/mod.rs | 1 + core/lib/multivm/src/versions/shadow.rs | 2 +- core/lib/multivm/src/versions/shared.rs | 46 +++++ .../src/versions/vm_1_3_2/history_recorder.rs | 9 +- core/lib/multivm/src/versions/vm_1_3_2/mod.rs | 1 - .../src/versions/vm_1_3_2/oracle_tools.rs | 18 +- .../versions/vm_1_3_2/oracles/decommitter.rs | 6 +- .../src/versions/vm_1_3_2/oracles/storage.rs | 14 +- .../vm_1_3_2/oracles/tracer/validation.rs | 20 +- .../src/versions/vm_1_3_2/pubdata_utils.rs | 6 +- .../multivm/src/versions/vm_1_3_2/refunds.rs | 14 +- .../src/versions/vm_1_3_2/test_utils.rs | 2 +- .../multivm/src/versions/vm_1_3_2/utils.rs | 10 +- core/lib/multivm/src/versions/vm_1_3_2/vm.rs | 4 +- .../src/versions/vm_1_3_2/vm_instance.rs | 6 +- .../versions/vm_1_3_2/vm_with_bootloader.rs | 3 +- .../vm_1_4_1/implementation/bytecode.rs | 10 +- .../vm_1_4_1/implementation/execution.rs | 4 +- .../versions/vm_1_4_1/implementation/gas.rs | 4 +- .../versions/vm_1_4_1/implementation/logs.rs | 3 +- .../vm_1_4_1/implementation/snapshots.rs | 6 +- .../vm_1_4_1/implementation/statistics.rs | 3 +- .../versions/vm_1_4_1/implementation/tx.rs | 2 +- core/lib/multivm/src/versions/vm_1_4_1/mod.rs | 7 - .../vm_1_4_1/old_vm/history_recorder.rs | 3 +- .../vm_1_4_1/old_vm/oracles/decommitter.rs | 8 +- .../src/versions/vm_1_4_1/old_vm/utils.rs | 6 +- .../src/versions/vm_1_4_1/oracles/storage.rs | 2 +- .../vm_1_4_1/tests/get_used_contracts.rs | 2 +- .../vm_1_4_1/tests/is_write_initial.rs | 2 +- .../src/versions/vm_1_4_1/tests/l2_blocks.rs | 2 +- .../src/versions/vm_1_4_1/tests/rollbacks.rs | 2 +- .../vm_1_4_1/tests/tester/inner_state.rs | 2 +- .../vm_1_4_1/tests/tester/vm_tester.rs | 2 +- .../src/versions/vm_1_4_1/tests/upgrade.rs | 2 +- .../src/versions/vm_1_4_1/tests/utils.rs | 2 +- .../vm_1_4_1/tracers/circuits_tracer.rs | 7 +- .../vm_1_4_1/tracers/default_tracers.rs | 7 +- .../versions/vm_1_4_1/tracers/dispatcher.rs | 4 +- .../vm_1_4_1/tracers/pubdata_tracer.rs | 7 +- .../src/versions/vm_1_4_1/tracers/refunds.rs | 5 +- .../vm_1_4_1/tracers/result_tracer.rs | 8 +- .../src/versions/vm_1_4_1/tracers/traits.rs | 5 +- .../vm_1_4_1/types/internals/vm_state.rs | 6 +- .../src/versions/vm_1_4_1/utils/fee.rs | 2 +- .../src/versions/vm_1_4_1/utils/l2_blocks.rs | 6 +- .../src/versions/vm_1_4_1/utils/logs.rs | 3 +- core/lib/multivm/src/versions/vm_1_4_1/vm.rs | 2 +- .../vm_1_4_2/implementation/bytecode.rs | 10 +- .../vm_1_4_2/implementation/execution.rs | 4 +- .../versions/vm_1_4_2/implementation/gas.rs | 4 +- .../versions/vm_1_4_2/implementation/logs.rs | 3 +- .../vm_1_4_2/implementation/snapshots.rs | 6 +- .../vm_1_4_2/implementation/statistics.rs | 3 +- .../versions/vm_1_4_2/implementation/tx.rs | 2 +- core/lib/multivm/src/versions/vm_1_4_2/mod.rs | 7 - .../vm_1_4_2/old_vm/history_recorder.rs | 3 +- .../vm_1_4_2/old_vm/oracles/decommitter.rs | 8 +- .../src/versions/vm_1_4_2/old_vm/utils.rs | 6 +- .../src/versions/vm_1_4_2/oracles/storage.rs | 2 +- .../vm_1_4_2/tests/get_used_contracts.rs | 2 +- .../vm_1_4_2/tests/is_write_initial.rs | 2 +- .../src/versions/vm_1_4_2/tests/l2_blocks.rs | 2 +- .../src/versions/vm_1_4_2/tests/rollbacks.rs | 2 +- .../vm_1_4_2/tests/tester/inner_state.rs | 2 +- .../vm_1_4_2/tests/tester/vm_tester.rs | 2 +- .../src/versions/vm_1_4_2/tests/upgrade.rs | 2 +- .../src/versions/vm_1_4_2/tests/utils.rs | 2 +- .../vm_1_4_2/tracers/circuits_tracer.rs | 7 +- .../vm_1_4_2/tracers/default_tracers.rs | 7 +- .../versions/vm_1_4_2/tracers/dispatcher.rs | 4 +- .../vm_1_4_2/tracers/pubdata_tracer.rs | 7 +- .../src/versions/vm_1_4_2/tracers/refunds.rs | 5 +- .../vm_1_4_2/tracers/result_tracer.rs | 8 +- .../src/versions/vm_1_4_2/tracers/traits.rs | 5 +- .../vm_1_4_2/types/internals/vm_state.rs | 6 +- .../src/versions/vm_1_4_2/utils/fee.rs | 2 +- .../src/versions/vm_1_4_2/utils/l2_blocks.rs | 6 +- .../src/versions/vm_1_4_2/utils/logs.rs | 3 +- core/lib/multivm/src/versions/vm_1_4_2/vm.rs | 2 +- .../implementation/bytecode.rs | 10 +- .../implementation/execution.rs | 4 +- .../implementation/gas.rs | 4 +- .../implementation/logs.rs | 3 +- .../implementation/snapshots.rs | 8 +- .../implementation/statistics.rs | 3 +- .../implementation/tx.rs | 2 +- .../src/versions/vm_boojum_integration/mod.rs | 7 - .../old_vm/history_recorder.rs | 3 +- .../old_vm/oracles/decommitter.rs | 8 +- .../old_vm/oracles/storage.rs | 2 +- .../vm_boojum_integration/old_vm/utils.rs | 8 +- .../vm_boojum_integration/oracles/storage.rs | 18 +- .../tests/get_used_contracts.rs | 2 +- .../tests/is_write_initial.rs | 2 +- .../vm_boojum_integration/tests/l2_blocks.rs | 2 +- .../vm_boojum_integration/tests/rollbacks.rs | 2 +- .../tests/tester/inner_state.rs | 2 +- .../tests/tester/vm_tester.rs | 2 +- .../vm_boojum_integration/tests/upgrade.rs | 2 +- .../vm_boojum_integration/tests/utils.rs | 2 +- .../tracers/circuits_tracer.rs | 7 +- .../tracers/default_tracers.rs | 7 +- .../tracers/dispatcher.rs | 4 +- .../tracers/pubdata_tracer.rs | 7 +- .../vm_boojum_integration/tracers/refunds.rs | 5 +- .../tracers/result_tracer.rs | 8 +- .../vm_boojum_integration/tracers/traits.rs | 5 +- .../types/internals/vm_state.rs | 6 +- .../vm_boojum_integration/utils/fee.rs | 2 +- .../vm_boojum_integration/utils/l2_blocks.rs | 6 +- .../vm_boojum_integration/utils/logs.rs | 3 +- .../src/versions/vm_boojum_integration/vm.rs | 2 +- .../multivm/src/versions/vm_fast/bytecode.rs | 2 +- .../multivm/src/versions/vm_fast/refund.rs | 2 +- .../vm_fast/tests/get_used_contracts.rs | 3 +- .../vm_fast/tests/is_write_initial.rs | 3 +- .../src/versions/vm_fast/tests/l2_blocks.rs | 6 +- .../versions/vm_fast/tests/require_eip712.rs | 3 +- .../src/versions/vm_fast/tests/sekp256r1.rs | 3 +- .../tests/tester/transaction_test_info.rs | 6 +- .../vm_fast/tests/tester/vm_tester.rs | 2 +- .../src/versions/vm_fast/tests/utils.rs | 3 +- core/lib/multivm/src/versions/vm_fast/vm.rs | 12 +- .../vm_latest/implementation/bytecode.rs | 10 +- .../vm_latest/implementation/execution.rs | 4 +- .../versions/vm_latest/implementation/gas.rs | 8 +- .../versions/vm_latest/implementation/logs.rs | 3 +- .../vm_latest/implementation/snapshots.rs | 12 +- .../vm_latest/implementation/statistics.rs | 3 +- .../versions/vm_latest/implementation/tx.rs | 2 +- .../lib/multivm/src/versions/vm_latest/mod.rs | 7 - .../vm_latest/old_vm/history_recorder.rs | 3 +- .../vm_latest/old_vm/oracles/decommitter.rs | 8 +- .../src/versions/vm_latest/old_vm/utils.rs | 6 +- .../src/versions/vm_latest/oracles/storage.rs | 4 +- .../src/versions/vm_latest/tests/block_tip.rs | 4 +- .../vm_latest/tests/get_used_contracts.rs | 3 +- .../vm_latest/tests/is_write_initial.rs | 3 +- .../src/versions/vm_latest/tests/l2_blocks.rs | 6 +- .../src/versions/vm_latest/tests/rollbacks.rs | 4 +- .../src/versions/vm_latest/tests/sekp256r1.rs | 4 +- .../vm_latest/tests/tester/inner_state.rs | 2 +- .../vm_latest/tests/tester/vm_tester.rs | 2 +- .../src/versions/vm_latest/tests/upgrade.rs | 5 +- .../src/versions/vm_latest/tests/utils.rs | 6 +- .../vm_latest/tracers/circuits_tracer.rs | 7 +- .../vm_latest/tracers/default_tracers.rs | 7 +- .../versions/vm_latest/tracers/dispatcher.rs | 4 +- .../vm_latest/tracers/pubdata_tracer.rs | 7 +- .../src/versions/vm_latest/tracers/refunds.rs | 5 +- .../vm_latest/tracers/result_tracer.rs | 8 +- .../src/versions/vm_latest/tracers/traits.rs | 5 +- .../vm_latest/types/internals/vm_state.rs | 6 +- .../src/versions/vm_latest/utils/fee.rs | 2 +- .../src/versions/vm_latest/utils/l2_blocks.rs | 6 +- .../src/versions/vm_latest/utils/logs.rs | 3 +- core/lib/multivm/src/versions/vm_latest/vm.rs | 2 +- core/lib/multivm/src/versions/vm_m5/mod.rs | 1 - .../lib/multivm/src/versions/vm_m5/storage.rs | 3 +- core/lib/multivm/src/versions/vm_m5/vm.rs | 5 +- .../multivm/src/versions/vm_m5/vm_instance.rs | 4 +- .../src/versions/vm_m5/vm_with_bootloader.rs | 2 +- core/lib/multivm/src/versions/vm_m6/mod.rs | 1 - .../lib/multivm/src/versions/vm_m6/storage.rs | 3 +- core/lib/multivm/src/versions/vm_m6/vm.rs | 7 +- .../multivm/src/versions/vm_m6/vm_instance.rs | 5 +- .../src/versions/vm_m6/vm_with_bootloader.rs | 2 +- .../implementation/bytecode.rs | 10 +- .../implementation/execution.rs | 2 +- .../implementation/gas.rs | 4 +- .../implementation/logs.rs | 3 +- .../implementation/snapshots.rs | 2 +- .../implementation/statistics.rs | 3 +- .../implementation/tx.rs | 2 +- .../old_vm/history_recorder.rs | 3 +- .../old_vm/oracles/decommitter.rs | 8 +- .../old_vm/oracles/storage.rs | 2 +- .../vm_refunds_enhancement/old_vm/utils.rs | 8 +- .../vm_refunds_enhancement/oracles/storage.rs | 2 +- .../tests/get_used_contracts.rs | 2 +- .../tests/is_write_initial.rs | 2 +- .../vm_refunds_enhancement/tests/l2_blocks.rs | 2 +- .../vm_refunds_enhancement/tests/rollbacks.rs | 2 +- .../tests/tester/inner_state.rs | 2 +- .../tests/tester/vm_tester.rs | 2 +- .../vm_refunds_enhancement/tests/upgrade.rs | 2 +- .../vm_refunds_enhancement/tests/utils.rs | 2 +- .../tracers/default_tracers.rs | 4 +- .../tracers/dispatcher.rs | 4 +- .../vm_refunds_enhancement/tracers/refunds.rs | 6 +- .../tracers/result_tracer.rs | 4 +- .../vm_refunds_enhancement/tracers/traits.rs | 5 +- .../types/internals/vm_state.rs | 6 +- .../vm_refunds_enhancement/utils/fee.rs | 2 +- .../vm_refunds_enhancement/utils/l2_blocks.rs | 6 +- .../src/versions/vm_refunds_enhancement/vm.rs | 2 +- .../implementation/bytecode.rs | 10 +- .../implementation/execution.rs | 2 +- .../vm_virtual_blocks/implementation/gas.rs | 4 +- .../vm_virtual_blocks/implementation/logs.rs | 3 +- .../implementation/snapshots.rs | 2 +- .../implementation/statistics.rs | 3 +- .../vm_virtual_blocks/implementation/tx.rs | 2 +- .../old_vm/history_recorder.rs | 3 +- .../old_vm/oracles/decommitter.rs | 8 +- .../old_vm/oracles/storage.rs | 2 +- .../vm_virtual_blocks/old_vm/utils.rs | 8 +- .../tests/get_used_contracts.rs | 2 +- .../tests/is_write_initial.rs | 2 +- .../vm_virtual_blocks/tests/l2_blocks.rs | 2 +- .../tests/tester/inner_state.rs | 2 +- .../tests/tester/vm_tester.rs | 2 +- .../vm_virtual_blocks/tests/upgrade.rs | 2 +- .../versions/vm_virtual_blocks/tests/utils.rs | 2 +- .../tracers/default_tracers.rs | 8 +- .../vm_virtual_blocks/tracers/dispatcher.rs | 6 +- .../vm_virtual_blocks/tracers/refunds.rs | 7 +- .../tracers/result_tracer.rs | 8 +- .../vm_virtual_blocks/tracers/traits.rs | 7 +- .../types/internals/vm_state.rs | 6 +- .../versions/vm_virtual_blocks/utils/fee.rs | 2 +- .../vm_virtual_blocks/utils/l2_blocks.rs | 6 +- .../src/versions/vm_virtual_blocks/vm.rs | 2 +- core/lib/multivm/src/vm_instance.rs | 2 +- core/lib/prover_interface/Cargo.toml | 1 - core/lib/prover_interface/src/inputs.rs | 1 - core/lib/state/Cargo.toml | 1 + core/lib/state/src/lib.rs | 79 +------- core/lib/state/src/postgres/mod.rs | 6 +- core/lib/state/src/rocksdb/mod.rs | 14 +- core/lib/state/src/shadow_storage.rs | 3 +- core/lib/state/src/storage_factory.rs | 5 +- core/lib/tee_verifier/Cargo.toml | 10 +- core/lib/tee_verifier/src/lib.rs | 38 +++- core/lib/types/src/vm_trace.rs | 94 +-------- core/lib/vm_interface/Cargo.toml | 22 +++ core/lib/vm_interface/README.md | 8 + .../mod.rs => vm_interface/src/lib.rs} | 17 +- .../src/storage}/in_memory.rs | 13 +- core/lib/vm_interface/src/storage/mod.rs | 75 ++++++++ .../src/storage/view.rs} | 4 +- .../src}/types/errors/bootloader_error.rs | 3 +- .../src}/types/errors/bytecode_compression.rs | 5 +- .../src}/types/errors/halt.rs | 6 +- core/lib/vm_interface/src/types/errors/mod.rs | 13 ++ .../src}/types/errors/tx_revert_reason.rs | 11 +- .../src}/types/errors/vm_revert_reason.rs | 10 +- .../src}/types/inputs/execution_mode.rs | 0 .../src}/types/inputs/l1_batch_env.rs | 0 .../src}/types/inputs/l2_block.rs | 0 core/lib/vm_interface/src/types/inputs/mod.rs | 11 ++ .../src}/types/inputs/system_env.rs | 0 .../src}/types/mod.rs | 2 +- .../src}/types/outputs/execution_result.rs | 9 +- .../src}/types/outputs/execution_state.rs | 0 .../src}/types/outputs/finished_l1batch.rs | 0 .../src}/types/outputs/l2_block.rs | 0 .../src}/types/outputs/mod.rs | 0 .../src}/types/outputs/statistic.rs | 0 .../src}/types/tracer.rs | 2 +- .../traits => vm_interface/src}/vm.rs | 48 +---- core/lib/vm_utils/Cargo.toml | 9 +- core/lib/vm_utils/src/lib.rs | 85 --------- core/lib/vm_utils/src/storage.rs | 10 +- core/lib/web3_decl/src/types.rs | 1 - .../api_server/src/execution_sandbox/apply.rs | 7 +- .../src/execution_sandbox/storage.rs | 4 +- .../src/execution_sandbox/tracers.rs | 4 +- .../src/execution_sandbox/validate.rs | 12 +- .../src/execution_sandbox/vm_metrics.rs | 5 +- core/node/api_server/src/web3/tests/vm.rs | 5 +- core/node/block_reverter/src/tests.rs | 2 +- core/node/consensus/Cargo.toml | 1 - core/node/consensus/src/testonly.rs | 6 +- .../src/batch_executor/main_executor.rs | 3 +- .../state_keeper/src/batch_executor/mod.rs | 5 +- core/node/state_keeper/src/metrics.rs | 2 +- core/node/state_keeper/src/testonly/mod.rs | 11 +- core/node/state_keeper/src/tests/mod.rs | 4 +- core/node/state_keeper/src/updates/mod.rs | 5 +- core/node/vm_runner/src/storage.rs | 2 +- core/node/vm_runner/src/tests/storage.rs | 2 +- .../harness/src/instruction_counter.rs | 4 +- core/tests/vm-benchmark/harness/src/lib.rs | 4 +- prover/Cargo.lock | 178 ++---------------- prover/Cargo.toml | 1 - .../crates/bin/witness_generator/Cargo.toml | 1 - .../witness_generator/src/basic_circuits.rs | 7 +- .../crates/bin/witness_generator/src/lib.rs | 7 +- .../crates/bin/witness_generator/src/main.rs | 18 +- .../bin/witness_generator}/src/witness.rs | 3 +- .../bin/witness_generator/tests/basic_test.rs | 3 +- 343 files changed, 1108 insertions(+), 1290 deletions(-) delete mode 100644 core/lib/multivm/src/interface/traits/mod.rs delete mode 100644 core/lib/multivm/src/interface/traits/tracers/mod.rs delete mode 100644 core/lib/multivm/src/interface/types/errors/mod.rs delete mode 100644 core/lib/multivm/src/interface/types/inputs/mod.rs rename core/lib/multivm/src/{interface/traits/tracers/dyn_tracers => tracers/dynamic}/mod.rs (100%) rename core/lib/multivm/src/{interface/traits/tracers/dyn_tracers => tracers/dynamic}/vm_1_3_3.rs (95%) rename core/lib/multivm/src/{interface/traits/tracers/dyn_tracers => tracers/dynamic}/vm_1_4_0.rs (95%) rename core/lib/multivm/src/{interface/traits/tracers/dyn_tracers => tracers/dynamic}/vm_1_4_1.rs (95%) rename core/lib/multivm/src/{interface/traits/tracers/dyn_tracers => tracers/dynamic}/vm_1_5_0.rs (95%) rename core/lib/multivm/src/tracers/{old_tracers.rs => old.rs} (100%) create mode 100644 core/lib/multivm/src/versions/shared.rs create mode 100644 core/lib/vm_interface/Cargo.toml create mode 100644 core/lib/vm_interface/README.md rename core/lib/{multivm/src/interface/mod.rs => vm_interface/src/lib.rs} (60%) rename core/lib/{state/src => vm_interface/src/storage}/in_memory.rs (95%) create mode 100644 core/lib/vm_interface/src/storage/mod.rs rename core/lib/{state/src/storage_view.rs => vm_interface/src/storage/view.rs} (99%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/errors/bootloader_error.rs (98%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/errors/bytecode_compression.rs (74%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/errors/halt.rs (97%) create mode 100644 core/lib/vm_interface/src/types/errors/mod.rs rename core/lib/{multivm/src/interface => vm_interface/src}/types/errors/tx_revert_reason.rs (96%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/errors/vm_revert_reason.rs (97%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/inputs/execution_mode.rs (100%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/inputs/l1_batch_env.rs (100%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/inputs/l2_block.rs (100%) create mode 100644 core/lib/vm_interface/src/types/inputs/mod.rs rename core/lib/{multivm/src/interface => vm_interface/src}/types/inputs/system_env.rs (100%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/mod.rs (73%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/outputs/execution_result.rs (93%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/outputs/execution_state.rs (100%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/outputs/finished_l1batch.rs (100%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/outputs/l2_block.rs (100%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/outputs/mod.rs (100%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/outputs/statistic.rs (100%) rename core/lib/{multivm/src/interface => vm_interface/src}/types/tracer.rs (97%) rename core/lib/{multivm/src/interface/traits => vm_interface/src}/vm.rs (75%) rename {core/lib/state => prover/crates/bin/witness_generator}/src/witness.rs (96%) diff --git a/Cargo.lock b/Cargo.lock index af059c472468..be06e1b4f326 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6463,7 +6463,6 @@ dependencies = [ "serde_json", "zksync_contracts", "zksync_multivm", - "zksync_state", "zksync_types", "zksync_utils", ] @@ -8927,7 +8926,6 @@ dependencies = [ "itertools 0.10.5", "once_cell", "pretty_assertions", - "serde", "thiserror", "tokio", "tracing", @@ -8940,11 +8938,11 @@ dependencies = [ "zk_evm 0.150.0", "zksync_contracts", "zksync_eth_signer", - "zksync_state", "zksync_system_constants", "zksync_test_account", "zksync_types", "zksync_utils", + "zksync_vm_interface", ] [[package]] @@ -9030,7 +9028,6 @@ dependencies = [ "zksync_node_sync", "zksync_node_test_utils", "zksync_protobuf", - "zksync_state", "zksync_state_keeper", "zksync_system_constants", "zksync_test_account", @@ -9373,7 +9370,6 @@ dependencies = [ "tokio", "zksync_multivm", "zksync_object_store", - "zksync_state", "zksync_types", ] @@ -9515,6 +9511,7 @@ dependencies = [ "zksync_storage", "zksync_types", "zksync_utils", + "zksync_vm_interface", ] [[package]] @@ -9608,7 +9605,6 @@ dependencies = [ "anyhow", "serde", "tracing", - "zksync_basic_types", "zksync_config", "zksync_contracts", "zksync_crypto_primitives", @@ -9619,10 +9615,8 @@ dependencies = [ "zksync_object_store", "zksync_prover_interface", "zksync_queued_job_processor", - "zksync_state", "zksync_types", "zksync_utils", - "zksync_vm_utils", ] [[package]] @@ -9756,6 +9750,20 @@ dependencies = [ "zksync_utils", ] +[[package]] +name = "zksync_vm_interface" +version = "0.1.0" +dependencies = [ + "hex", + "serde", + "thiserror", + "tracing", + "zksync_contracts", + "zksync_system_constants", + "zksync_types", + "zksync_utils", +] + [[package]] name = "zksync_vm_runner" version = "0.1.0" @@ -9799,10 +9807,8 @@ dependencies = [ "tracing", "zksync_contracts", "zksync_dal", - "zksync_multivm", - "zksync_state", "zksync_types", - "zksync_utils", + "zksync_vm_interface", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 48c5f4144ade..6619fd261758 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,7 @@ members = [ "core/lib/utils", "core/lib/vlog", "core/lib/multivm", + "core/lib/vm_interface", "core/lib/vm_utils", "core/lib/web3_decl", "core/lib/snapshots_applier", @@ -234,6 +235,7 @@ zksync_protobuf_build = "=0.1.0-rc.10" zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" } zksync_prover_dal = { version = "0.1.0", path = "prover/crates/lib/prover_dal" } zksync_vlog = { version = "0.1.0", path = "core/lib/vlog" } +zksync_vm_interface = { version = "0.1.0", path = "core/lib/vm_interface" } zksync_vm_utils = { version = "0.1.0", path = "core/lib/vm_utils" } zksync_vm_benchmark_harness = { version = "0.1.0", path = "core/tests/vm-benchmark/harness" } zksync_basic_types = { version = "0.1.0", path = "core/lib/basic_types" } diff --git a/core/bin/system-constants-generator/Cargo.toml b/core/bin/system-constants-generator/Cargo.toml index 8632b4c554cc..7177d29ca743 100644 --- a/core/bin/system-constants-generator/Cargo.toml +++ b/core/bin/system-constants-generator/Cargo.toml @@ -11,7 +11,6 @@ categories.workspace = true publish = false [dependencies] -zksync_state.workspace = true zksync_types.workspace = true zksync_utils.workspace = true zksync_contracts.workspace = true diff --git a/core/bin/system-constants-generator/src/utils.rs b/core/bin/system-constants-generator/src/utils.rs index f2e73028e6e4..96de0537d538 100644 --- a/core/bin/system-constants-generator/src/utils.rs +++ b/core/bin/system-constants-generator/src/utils.rs @@ -7,9 +7,12 @@ use zksync_contracts::{ }; use zksync_multivm::{ interface::{ - dyn_tracers::vm_1_5_0::DynTracer, tracer::VmExecutionStopReason, L1BatchEnv, L2BlockEnv, - SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory, VmInterface, + storage::{InMemoryStorage, StorageView, WriteStorage}, + tracer::VmExecutionStopReason, + L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory, + VmInterface, }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ constants::{BATCH_COMPUTATIONAL_GAS_LIMIT, BOOTLOADER_HEAP_PAGE}, BootloaderState, HistoryEnabled, HistoryMode, SimpleMemory, ToTracerPointer, Vm, VmTracer, @@ -17,7 +20,6 @@ use zksync_multivm::{ }, zk_evm_latest::aux_structures::Timestamp, }; -use zksync_state::{InMemoryStorage, StorageView, WriteStorage}; use zksync_types::{ block::L2BlockHasher, ethabi::Token, fee::Fee, fee_model::BatchFeeInput, l1::L1Tx, l2::L2Tx, utils::storage_key_for_eth_balance, AccountTreeId, Address, Execute, K256PrivateKey, diff --git a/core/lib/multivm/Cargo.toml b/core/lib/multivm/Cargo.toml index fc35f152ae19..a245acdfacf6 100644 --- a/core/lib/multivm/Cargo.toml +++ b/core/lib/multivm/Cargo.toml @@ -25,18 +25,16 @@ circuit_sequencer_api_1_4_2.workspace = true circuit_sequencer_api_1_5_0.workspace = true zksync_types.workspace = true -zksync_state.workspace = true zksync_contracts.workspace = true zksync_utils.workspace = true zksync_system_constants.workspace = true - +zksync_vm_interface.workspace = true anyhow.workspace = true hex.workspace = true itertools.workspace = true once_cell.workspace = true pretty_assertions.workspace = true -serde.workspace = true thiserror.workspace = true tracing.workspace = true vise.workspace = true diff --git a/core/lib/multivm/README.md b/core/lib/multivm/README.md index c117a4b3b9b4..5e2af426ae5b 100644 --- a/core/lib/multivm/README.md +++ b/core/lib/multivm/README.md @@ -1,6 +1,6 @@ -# External node's VM +# ZKsync Era VM Wrapper -This crate represents a wrapper over several versions of VM that have been used by the main node. It contains the glue -code that allows switching the VM version based on the externally provided marker while preserving the public interface. -This crate exists to enable the external node to process breaking upgrades and re-execute all the transactions from the -genesis block. +This crate represents a wrapper over several versions of VM that have been used by the ZKsync Era node. It contains the +glue code that allows switching the VM version based on the externally provided marker while preserving the public +interface. This crate exists to enable the external node to process breaking upgrades and re-execute all the +transactions from the genesis block. diff --git a/core/lib/multivm/src/glue/tracers/mod.rs b/core/lib/multivm/src/glue/tracers/mod.rs index 7aa792ef1f71..bf2f67cae501 100644 --- a/core/lib/multivm/src/glue/tracers/mod.rs +++ b/core/lib/multivm/src/glue/tracers/mod.rs @@ -30,9 +30,7 @@ //! - Add this trait as a trait bound for `T` in `MultiVMTracer` implementation. //! - Implement the trait for `T` with a bound to `VmTracer` for a specific version. -use zksync_state::WriteStorage; - -use crate::{tracers::old_tracers::OldTracers, HistoryMode}; +use crate::{interface::storage::WriteStorage, tracers::old::OldTracers, HistoryMode}; pub type MultiVmTracerPointer = Box>; 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 2bf320aeb140..ce928e652d76 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 @@ -6,8 +6,8 @@ use zksync_types::l2_to_l1_log::UserL2ToL1Log; use crate::{ glue::{GlueFrom, GlueInto}, interface::{ - types::outputs::VmExecutionLogs, CurrentExecutionState, ExecutionResult, Refunds, - VmExecutionResultAndLogs, VmExecutionStatistics, + CurrentExecutionState, ExecutionResult, Refunds, VmExecutionLogs, VmExecutionResultAndLogs, + VmExecutionStatistics, }, }; diff --git a/core/lib/multivm/src/interface/traits/mod.rs b/core/lib/multivm/src/interface/traits/mod.rs deleted file mode 100644 index a90c1c5281fc..000000000000 --- a/core/lib/multivm/src/interface/traits/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod tracers; -pub mod vm; diff --git a/core/lib/multivm/src/interface/traits/tracers/mod.rs b/core/lib/multivm/src/interface/traits/tracers/mod.rs deleted file mode 100644 index f045674dfcf2..000000000000 --- a/core/lib/multivm/src/interface/traits/tracers/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod dyn_tracers; diff --git a/core/lib/multivm/src/interface/types/errors/mod.rs b/core/lib/multivm/src/interface/types/errors/mod.rs deleted file mode 100644 index 43aecf796013..000000000000 --- a/core/lib/multivm/src/interface/types/errors/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub(crate) use bootloader_error::BootloaderErrorCode; -pub use bytecode_compression::BytecodeCompressionError; -pub use halt::Halt; -pub use tx_revert_reason::TxRevertReason; -pub use vm_revert_reason::{VmRevertReason, VmRevertReasonParsingError}; - -mod bootloader_error; -mod bytecode_compression; -mod halt; -mod tx_revert_reason; -mod vm_revert_reason; diff --git a/core/lib/multivm/src/interface/types/inputs/mod.rs b/core/lib/multivm/src/interface/types/inputs/mod.rs deleted file mode 100644 index f88d40def4bf..000000000000 --- a/core/lib/multivm/src/interface/types/inputs/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub use execution_mode::VmExecutionMode; -pub use l1_batch_env::L1BatchEnv; -pub use l2_block::L2BlockEnv; -pub use system_env::{SystemEnv, TxExecutionMode}; - -pub(crate) mod execution_mode; -pub(crate) mod l1_batch_env; -pub(crate) mod l2_block; -pub(crate) mod system_env; diff --git a/core/lib/multivm/src/lib.rs b/core/lib/multivm/src/lib.rs index 08b077ce3eab..77851a1df002 100644 --- a/core/lib/multivm/src/lib.rs +++ b/core/lib/multivm/src/lib.rs @@ -5,6 +5,7 @@ pub use circuit_sequencer_api_1_5_0 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; pub use crate::{ glue::{ @@ -19,7 +20,6 @@ pub use crate::{ }; mod glue; -pub mod interface; pub mod tracers; pub mod utils; pub mod versions; diff --git a/core/lib/multivm/src/tracers/call_tracer/mod.rs b/core/lib/multivm/src/tracers/call_tracer/mod.rs index 855768067b8a..4013be101e57 100644 --- a/core/lib/multivm/src/tracers/call_tracer/mod.rs +++ b/core/lib/multivm/src/tracers/call_tracer/mod.rs @@ -92,7 +92,7 @@ impl CallTracer { } impl IntoOldVmTracer for CallTracer { - fn old_tracer(&self) -> crate::tracers::old_tracers::OldTracers { - crate::tracers::old_tracers::OldTracers::CallTracer(self.result.clone()) + fn old_tracer(&self) -> crate::tracers::old::OldTracers { + crate::tracers::old::OldTracers::CallTracer(self.result.clone()) } } diff --git a/core/lib/multivm/src/tracers/call_tracer/vm_1_4_1/mod.rs b/core/lib/multivm/src/tracers/call_tracer/vm_1_4_1/mod.rs index 4e1e4deb729f..10ea9ba250ec 100644 --- a/core/lib/multivm/src/tracers/call_tracer/vm_1_4_1/mod.rs +++ b/core/lib/multivm/src/tracers/call_tracer/vm_1_4_1/mod.rs @@ -5,7 +5,6 @@ use zk_evm_1_4_1::{ RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_types::{ vm_trace::{Call, CallType}, @@ -16,10 +15,11 @@ use zksync_types::{ use crate::{ glue::GlueInto, interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, + storage::{StoragePtr, WriteStorage}, + tracer::VmExecutionStopReason, VmRevertReason, }, - tracers::call_tracer::CallTracer, + tracers::{dynamic::vm_1_4_1::DynTracer, CallTracer}, vm_1_4_1::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/call_tracer/vm_1_4_2/mod.rs b/core/lib/multivm/src/tracers/call_tracer/vm_1_4_2/mod.rs index d1ecd25db3ab..0464164a50a7 100644 --- a/core/lib/multivm/src/tracers/call_tracer/vm_1_4_2/mod.rs +++ b/core/lib/multivm/src/tracers/call_tracer/vm_1_4_2/mod.rs @@ -5,7 +5,6 @@ use zk_evm_1_4_1::{ RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_types::{ vm_trace::{Call, CallType}, @@ -16,10 +15,11 @@ use zksync_types::{ use crate::{ glue::GlueInto, interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, + storage::{StoragePtr, WriteStorage}, + tracer::VmExecutionStopReason, VmRevertReason, }, - tracers::call_tracer::CallTracer, + tracers::{dynamic::vm_1_4_1::DynTracer, CallTracer}, vm_1_4_2::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/call_tracer/vm_boojum_integration/mod.rs b/core/lib/multivm/src/tracers/call_tracer/vm_boojum_integration/mod.rs index 06f24ef9b092..a8d035e6c1cc 100644 --- a/core/lib/multivm/src/tracers/call_tracer/vm_boojum_integration/mod.rs +++ b/core/lib/multivm/src/tracers/call_tracer/vm_boojum_integration/mod.rs @@ -5,7 +5,6 @@ use zk_evm_1_4_0::{ RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_types::{ vm_trace::{Call, CallType}, @@ -16,10 +15,11 @@ use zksync_types::{ use crate::{ glue::GlueInto, interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_0::DynTracer, + storage::{StoragePtr, WriteStorage}, + tracer::VmExecutionStopReason, VmRevertReason, }, - tracers::call_tracer::CallTracer, + tracers::{dynamic::vm_1_4_0::DynTracer, CallTracer}, vm_boojum_integration::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/call_tracer/vm_latest/mod.rs b/core/lib/multivm/src/tracers/call_tracer/vm_latest/mod.rs index c5e4e0cdded4..8b1ccfa5b7af 100644 --- a/core/lib/multivm/src/tracers/call_tracer/vm_latest/mod.rs +++ b/core/lib/multivm/src/tracers/call_tracer/vm_latest/mod.rs @@ -5,7 +5,6 @@ use zk_evm_1_5_0::{ RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_types::{ vm_trace::{Call, CallType}, @@ -16,10 +15,11 @@ use zksync_types::{ use crate::{ glue::GlueInto, interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_5_0::DynTracer, + storage::{StoragePtr, WriteStorage}, + tracer::VmExecutionStopReason, VmRevertReason, }, - tracers::call_tracer::CallTracer, + tracers::{dynamic::vm_1_5_0::DynTracer, CallTracer}, vm_latest::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/call_tracer/vm_refunds_enhancement/mod.rs b/core/lib/multivm/src/tracers/call_tracer/vm_refunds_enhancement/mod.rs index d310e4595083..30a2effb9f5c 100644 --- a/core/lib/multivm/src/tracers/call_tracer/vm_refunds_enhancement/mod.rs +++ b/core/lib/multivm/src/tracers/call_tracer/vm_refunds_enhancement/mod.rs @@ -5,7 +5,6 @@ use zk_evm_1_3_3::{ RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_types::{ vm_trace::{Call, CallType}, @@ -16,10 +15,11 @@ use zksync_types::{ use crate::{ glue::GlueInto, interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_3_3::DynTracer, + storage::{StoragePtr, WriteStorage}, + tracer::VmExecutionStopReason, VmRevertReason, }, - tracers::call_tracer::CallTracer, + tracers::{dynamic::vm_1_3_3::DynTracer, CallTracer}, vm_refunds_enhancement::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/call_tracer/vm_virtual_blocks/mod.rs b/core/lib/multivm/src/tracers/call_tracer/vm_virtual_blocks/mod.rs index 43b9b8524e67..0e3bea139d6f 100644 --- a/core/lib/multivm/src/tracers/call_tracer/vm_virtual_blocks/mod.rs +++ b/core/lib/multivm/src/tracers/call_tracer/vm_virtual_blocks/mod.rs @@ -5,7 +5,6 @@ use zk_evm_1_3_3::{ RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_types::{ vm_trace::{Call, CallType}, @@ -15,8 +14,11 @@ use zksync_types::{ use crate::{ glue::GlueInto, - interface::{dyn_tracers::vm_1_3_3::DynTracer, VmExecutionResultAndLogs, VmRevertReason}, - tracers::call_tracer::CallTracer, + interface::{ + storage::{StoragePtr, WriteStorage}, + VmExecutionResultAndLogs, VmRevertReason, + }, + tracers::{dynamic::vm_1_3_3::DynTracer, CallTracer}, vm_virtual_blocks::{ ExecutionEndTracer, ExecutionProcessing, HistoryMode, SimpleMemory, VmTracer, }, diff --git a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/mod.rs b/core/lib/multivm/src/tracers/dynamic/mod.rs similarity index 100% rename from core/lib/multivm/src/interface/traits/tracers/dyn_tracers/mod.rs rename to core/lib/multivm/src/tracers/dynamic/mod.rs diff --git a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_3_3.rs b/core/lib/multivm/src/tracers/dynamic/vm_1_3_3.rs similarity index 95% rename from core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_3_3.rs rename to core/lib/multivm/src/tracers/dynamic/vm_1_3_3.rs index c088889aa038..0af3b33eed13 100644 --- a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_3_3.rs +++ b/core/lib/multivm/src/tracers/dynamic/vm_1_3_3.rs @@ -2,7 +2,8 @@ use zk_evm_1_3_3::{ abstractions::Memory, tracing::{AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::StoragePtr; + +use crate::interface::storage::StoragePtr; /// Version of zk_evm_1_3_3::Tracer suitable for dynamic dispatch. pub trait DynTracer { diff --git a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_4_0.rs b/core/lib/multivm/src/tracers/dynamic/vm_1_4_0.rs similarity index 95% rename from core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_4_0.rs rename to core/lib/multivm/src/tracers/dynamic/vm_1_4_0.rs index 7237e24cb681..20cbd8fea634 100644 --- a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_4_0.rs +++ b/core/lib/multivm/src/tracers/dynamic/vm_1_4_0.rs @@ -2,7 +2,8 @@ use zk_evm_1_4_0::{ abstractions::Memory, tracing::{AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::StoragePtr; + +use crate::interface::storage::StoragePtr; /// Version of `zk_evm_1_4_0::Tracer` suitable for dynamic dispatch. pub trait DynTracer { diff --git a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_4_1.rs b/core/lib/multivm/src/tracers/dynamic/vm_1_4_1.rs similarity index 95% rename from core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_4_1.rs rename to core/lib/multivm/src/tracers/dynamic/vm_1_4_1.rs index 4772d14cd20f..bbd9ea490843 100644 --- a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_4_1.rs +++ b/core/lib/multivm/src/tracers/dynamic/vm_1_4_1.rs @@ -2,7 +2,8 @@ use zk_evm_1_4_1::{ abstractions::Memory, tracing::{AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::StoragePtr; + +use crate::interface::storage::StoragePtr; /// Version of `zk_evm_1_4_1::Tracer` suitable for dynamic dispatch. pub trait DynTracer { diff --git a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_5_0.rs b/core/lib/multivm/src/tracers/dynamic/vm_1_5_0.rs similarity index 95% rename from core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_5_0.rs rename to core/lib/multivm/src/tracers/dynamic/vm_1_5_0.rs index f306190184c0..28d7fd361185 100644 --- a/core/lib/multivm/src/interface/traits/tracers/dyn_tracers/vm_1_5_0.rs +++ b/core/lib/multivm/src/tracers/dynamic/vm_1_5_0.rs @@ -2,7 +2,8 @@ use zk_evm_1_5_0::{ abstractions::Memory, tracing::{AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::StoragePtr; + +use crate::interface::storage::StoragePtr; /// Version of `zk_evm_1_5_0::Tracer` suitable for dynamic dispatch. pub trait DynTracer { diff --git a/core/lib/multivm/src/tracers/mod.rs b/core/lib/multivm/src/tracers/mod.rs index 3090628fcac7..0a6517a6cd2f 100644 --- a/core/lib/multivm/src/tracers/mod.rs +++ b/core/lib/multivm/src/tracers/mod.rs @@ -1,11 +1,15 @@ -pub mod call_tracer; -mod multivm_dispatcher; -pub mod old_tracers; -pub mod prestate_tracer; -pub mod storage_invocation; -pub mod validator; +pub use self::{ + call_tracer::CallTracer, + multivm_dispatcher::TracerDispatcher, + prestate_tracer::PrestateTracer, + storage_invocation::StorageInvocations, + validator::{ValidationError, ValidationTracer, ValidationTracerParams}, +}; -pub use call_tracer::CallTracer; -pub use multivm_dispatcher::TracerDispatcher; -pub use prestate_tracer::PrestateTracer; -pub use storage_invocation::StorageInvocations; +mod call_tracer; +pub mod dynamic; +mod multivm_dispatcher; +pub mod old; +mod prestate_tracer; +mod storage_invocation; +mod validator; diff --git a/core/lib/multivm/src/tracers/multivm_dispatcher.rs b/core/lib/multivm/src/tracers/multivm_dispatcher.rs index 5b0d36b5e793..0a15ece53152 100644 --- a/core/lib/multivm/src/tracers/multivm_dispatcher.rs +++ b/core/lib/multivm/src/tracers/multivm_dispatcher.rs @@ -1,6 +1,4 @@ -use zksync_state::WriteStorage; - -use crate::{tracers::old_tracers, HistoryMode, MultiVmTracerPointer}; +use crate::{interface::storage::WriteStorage, tracers::old, HistoryMode, MultiVmTracerPointer}; /// Tracer dispatcher is a tracer that can dispatch calls to multiple tracers. pub struct TracerDispatcher { @@ -100,7 +98,7 @@ impl From> for () { fn from(_value: TracerDispatcher) -> Self {} } -impl From> for old_tracers::TracerDispatcher { +impl From> for old::TracerDispatcher { fn from(value: TracerDispatcher) -> Self { Self::new(value.tracers.into_iter().map(|x| x.old_tracer()).collect()) } diff --git a/core/lib/multivm/src/tracers/old_tracers.rs b/core/lib/multivm/src/tracers/old.rs similarity index 100% rename from core/lib/multivm/src/tracers/old_tracers.rs rename to core/lib/multivm/src/tracers/old.rs diff --git a/core/lib/multivm/src/tracers/prestate_tracer/mod.rs b/core/lib/multivm/src/tracers/prestate_tracer/mod.rs index 81e2acfd4bed..e8a7cc2cc420 100644 --- a/core/lib/multivm/src/tracers/prestate_tracer/mod.rs +++ b/core/lib/multivm/src/tracers/prestate_tracer/mod.rs @@ -1,13 +1,14 @@ use std::{collections::HashMap, fmt, sync::Arc}; use once_cell::sync::OnceCell; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ get_code_key, get_nonce_key, web3::keccak256, AccountTreeId, Address, StorageKey, StorageValue, H160, H256, L2_BASE_TOKEN_ADDRESS, U256, }; use zksync_utils::{address_to_h256, h256_to_u256}; +use crate::interface::storage::{StoragePtr, WriteStorage}; + pub mod vm_1_4_1; pub mod vm_1_4_2; pub mod vm_latest; diff --git a/core/lib/multivm/src/tracers/prestate_tracer/vm_1_4_1/mod.rs b/core/lib/multivm/src/tracers/prestate_tracer/vm_1_4_1/mod.rs index f2080b2740fe..2433138e341c 100644 --- a/core/lib/multivm/src/tracers/prestate_tracer/vm_1_4_1/mod.rs +++ b/core/lib/multivm/src/tracers/prestate_tracer/vm_1_4_1/mod.rs @@ -1,16 +1,16 @@ use zk_evm_1_4_1::tracing::{BeforeExecutionData, VmLocalStateData}; -use zksync_state::{StoragePtr, WriteStorage}; -use zksync_types::StorageKey; +use zksync_types::{StorageKey, U256}; use super::{ get_account_data, process_modified_storage_keys, process_result, PrestateTracer, State, StorageAccess, }; use crate::{ - interface::dyn_tracers::vm_1_4_1::DynTracer, - tracers::prestate_tracer::U256, + interface::storage::{StoragePtr, WriteStorage}, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_1::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; + impl DynTracer> for PrestateTracer { fn before_execution( &mut self, @@ -52,7 +52,7 @@ impl VmTracer for PrestateTracer { } } -impl StorageAccess for ZkSyncVmState { +impl StorageAccess for ZkSyncVmState { fn read_from_storage(&self, key: &StorageKey) -> U256 { self.storage.storage.read_from_storage(key) } diff --git a/core/lib/multivm/src/tracers/prestate_tracer/vm_1_4_2/mod.rs b/core/lib/multivm/src/tracers/prestate_tracer/vm_1_4_2/mod.rs index d51220ab41ff..834b3e2d3540 100644 --- a/core/lib/multivm/src/tracers/prestate_tracer/vm_1_4_2/mod.rs +++ b/core/lib/multivm/src/tracers/prestate_tracer/vm_1_4_2/mod.rs @@ -1,14 +1,13 @@ use zk_evm_1_4_1::tracing::{BeforeExecutionData, VmLocalStateData}; -use zksync_state::{StoragePtr, WriteStorage}; -use zksync_types::StorageKey; +use zksync_types::{StorageKey, U256}; use super::{ get_account_data, process_modified_storage_keys, process_result, PrestateTracer, State, StorageAccess, }; use crate::{ - interface::dyn_tracers::vm_1_4_1::DynTracer, - tracers::prestate_tracer::U256, + interface::storage::{StoragePtr, WriteStorage}, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_2::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; @@ -53,7 +52,7 @@ impl VmTracer for PrestateTracer { } } -impl StorageAccess for ZkSyncVmState { +impl StorageAccess for ZkSyncVmState { fn read_from_storage(&self, key: &StorageKey) -> U256 { self.storage.storage.read_from_storage(key) } diff --git a/core/lib/multivm/src/tracers/prestate_tracer/vm_latest/mod.rs b/core/lib/multivm/src/tracers/prestate_tracer/vm_latest/mod.rs index c93974085fe9..de9cc20e395a 100644 --- a/core/lib/multivm/src/tracers/prestate_tracer/vm_latest/mod.rs +++ b/core/lib/multivm/src/tracers/prestate_tracer/vm_latest/mod.rs @@ -1,14 +1,13 @@ use zk_evm_1_5_0::tracing::{BeforeExecutionData, VmLocalStateData}; -use zksync_state::{StoragePtr, WriteStorage}; -use zksync_types::StorageKey; +use zksync_types::{StorageKey, U256}; use super::{ get_account_data, process_modified_storage_keys, process_result, PrestateTracer, State, StorageAccess, }; use crate::{ - interface::dyn_tracers::vm_1_5_0::DynTracer, - tracers::prestate_tracer::U256, + interface::storage::{StoragePtr, WriteStorage}, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; @@ -53,7 +52,7 @@ impl VmTracer for PrestateTracer { } } -impl StorageAccess for ZkSyncVmState { +impl StorageAccess for ZkSyncVmState { fn read_from_storage(&self, key: &StorageKey) -> U256 { self.storage.storage.read_from_storage(key) } diff --git a/core/lib/multivm/src/tracers/prestate_tracer/vm_refunds_enhancement/mod.rs b/core/lib/multivm/src/tracers/prestate_tracer/vm_refunds_enhancement/mod.rs index 970b0a8387ba..d236a744b5a7 100644 --- a/core/lib/multivm/src/tracers/prestate_tracer/vm_refunds_enhancement/mod.rs +++ b/core/lib/multivm/src/tracers/prestate_tracer/vm_refunds_enhancement/mod.rs @@ -1,16 +1,15 @@ use std::collections::HashMap; use zk_evm_1_3_3::tracing::{BeforeExecutionData, VmLocalStateData}; -use zksync_state::{StoragePtr, WriteStorage}; -use zksync_types::{StorageKey, H256}; +use zksync_types::{StorageKey, H256, U256}; use super::{ get_account_data, process_modified_storage_keys, process_result, PrestateTracer, State, StorageAccess, }; use crate::{ - interface::dyn_tracers::vm_1_3_3::DynTracer, - tracers::prestate_tracer::U256, + interface::storage::{StoragePtr, WriteStorage}, + tracers::dynamic::vm_1_3_3::DynTracer, vm_refunds_enhancement::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; @@ -63,7 +62,7 @@ impl VmTracer for PrestateTracer { } } -impl StorageAccess for ZkSyncVmState { +impl StorageAccess for ZkSyncVmState { fn read_from_storage(&self, key: &StorageKey) -> U256 { self.storage.storage.read_from_storage(key) } diff --git a/core/lib/multivm/src/tracers/prestate_tracer/vm_virtual_blocks/mod.rs b/core/lib/multivm/src/tracers/prestate_tracer/vm_virtual_blocks/mod.rs index 34c60a6bc07a..13e755bf96b2 100644 --- a/core/lib/multivm/src/tracers/prestate_tracer/vm_virtual_blocks/mod.rs +++ b/core/lib/multivm/src/tracers/prestate_tracer/vm_virtual_blocks/mod.rs @@ -1,16 +1,15 @@ use std::collections::HashMap; use zk_evm_1_3_3::tracing::{BeforeExecutionData, VmLocalStateData}; -use zksync_state::{StoragePtr, WriteStorage}; -use zksync_types::{StorageKey, H256}; +use zksync_types::{StorageKey, H256, U256}; use super::{ get_account_data, process_modified_storage_keys, process_result, PrestateTracer, State, StorageAccess, }; use crate::{ - interface::dyn_tracers::vm_1_3_3::DynTracer, - tracers::prestate_tracer::U256, + interface::storage::{StoragePtr, WriteStorage}, + tracers::dynamic::vm_1_3_3::DynTracer, vm_virtual_blocks::{ BootloaderState, ExecutionEndTracer, ExecutionProcessing, HistoryMode, SimpleMemory, ZkSyncVmState, @@ -69,7 +68,7 @@ impl ExecutionProcessing for PrestateTrac } } -impl StorageAccess for ZkSyncVmState { +impl StorageAccess for ZkSyncVmState { fn read_from_storage(&self, key: &StorageKey) -> U256 { self.storage.storage.read_from_storage(key) } diff --git a/core/lib/multivm/src/tracers/storage_invocation/mod.rs b/core/lib/multivm/src/tracers/storage_invocation/mod.rs index 8c9677ba8d7c..2b81845a2de1 100644 --- a/core/lib/multivm/src/tracers/storage_invocation/mod.rs +++ b/core/lib/multivm/src/tracers/storage_invocation/mod.rs @@ -1,4 +1,4 @@ -use crate::{glue::tracers::IntoOldVmTracer, tracers::old_tracers::OldTracers}; +use crate::{glue::tracers::IntoOldVmTracer, tracers::old::OldTracers}; pub mod vm_1_4_1; pub mod vm_1_4_2; diff --git a/core/lib/multivm/src/tracers/storage_invocation/vm_1_4_1/mod.rs b/core/lib/multivm/src/tracers/storage_invocation/vm_1_4_1/mod.rs index be3a30adb1d4..97037014e469 100644 --- a/core/lib/multivm/src/tracers/storage_invocation/vm_1_4_1/mod.rs +++ b/core/lib/multivm/src/tracers/storage_invocation/vm_1_4_1/mod.rs @@ -1,12 +1,10 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ + storage::WriteStorage, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, Halt, }, - tracers::storage_invocation::StorageInvocations, + tracers::{dynamic::vm_1_4_1::DynTracer, StorageInvocations}, vm_1_4_1::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/storage_invocation/vm_1_4_2/mod.rs b/core/lib/multivm/src/tracers/storage_invocation/vm_1_4_2/mod.rs index 186b3234d009..07c02c5984ca 100644 --- a/core/lib/multivm/src/tracers/storage_invocation/vm_1_4_2/mod.rs +++ b/core/lib/multivm/src/tracers/storage_invocation/vm_1_4_2/mod.rs @@ -1,12 +1,10 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ + storage::WriteStorage, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, Halt, }, - tracers::storage_invocation::StorageInvocations, + tracers::{dynamic::vm_1_4_1::DynTracer, StorageInvocations}, vm_1_4_2::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/storage_invocation/vm_boojum_integration/mod.rs b/core/lib/multivm/src/tracers/storage_invocation/vm_boojum_integration/mod.rs index 05651485bd79..4b10ba7cbb4e 100644 --- a/core/lib/multivm/src/tracers/storage_invocation/vm_boojum_integration/mod.rs +++ b/core/lib/multivm/src/tracers/storage_invocation/vm_boojum_integration/mod.rs @@ -1,12 +1,10 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ + storage::WriteStorage, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - traits::tracers::dyn_tracers::vm_1_4_0::DynTracer, Halt, }, - tracers::storage_invocation::StorageInvocations, + tracers::{dynamic::vm_1_4_0::DynTracer, StorageInvocations}, vm_boojum_integration::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/storage_invocation/vm_latest/mod.rs b/core/lib/multivm/src/tracers/storage_invocation/vm_latest/mod.rs index 48802a27b495..8eb1dac1fdf1 100644 --- a/core/lib/multivm/src/tracers/storage_invocation/vm_latest/mod.rs +++ b/core/lib/multivm/src/tracers/storage_invocation/vm_latest/mod.rs @@ -1,12 +1,10 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ + storage::WriteStorage, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - traits::tracers::dyn_tracers::vm_1_5_0::DynTracer, Halt, }, - tracers::storage_invocation::StorageInvocations, + tracers::{dynamic::vm_1_5_0::DynTracer, StorageInvocations}, vm_latest::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/storage_invocation/vm_refunds_enhancement/mod.rs b/core/lib/multivm/src/tracers/storage_invocation/vm_refunds_enhancement/mod.rs index 1e562374afd5..db4bfd299ea5 100644 --- a/core/lib/multivm/src/tracers/storage_invocation/vm_refunds_enhancement/mod.rs +++ b/core/lib/multivm/src/tracers/storage_invocation/vm_refunds_enhancement/mod.rs @@ -1,12 +1,10 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ + storage::WriteStorage, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - traits::tracers::dyn_tracers::vm_1_3_3::DynTracer, Halt, }, - tracers::storage_invocation::StorageInvocations, + tracers::{dynamic::vm_1_3_3::DynTracer, StorageInvocations}, vm_refunds_enhancement::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; diff --git a/core/lib/multivm/src/tracers/storage_invocation/vm_virtual_blocks/mod.rs b/core/lib/multivm/src/tracers/storage_invocation/vm_virtual_blocks/mod.rs index cd0ab9f4bb54..d6f67aa55630 100644 --- a/core/lib/multivm/src/tracers/storage_invocation/vm_virtual_blocks/mod.rs +++ b/core/lib/multivm/src/tracers/storage_invocation/vm_virtual_blocks/mod.rs @@ -1,8 +1,6 @@ -use zksync_state::WriteStorage; - use crate::{ - interface::dyn_tracers::vm_1_3_3::DynTracer, - tracers::storage_invocation::StorageInvocations, + interface::storage::WriteStorage, + tracers::{dynamic::vm_1_3_3::DynTracer, StorageInvocations}, vm_virtual_blocks::{ BootloaderState, ExecutionEndTracer, ExecutionProcessing, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState, diff --git a/core/lib/multivm/src/tracers/validator/mod.rs b/core/lib/multivm/src/tracers/validator/mod.rs index 635915f95278..a91006368b6a 100644 --- a/core/lib/multivm/src/tracers/validator/mod.rs +++ b/core/lib/multivm/src/tracers/validator/mod.rs @@ -1,21 +1,22 @@ use std::{collections::HashSet, marker::PhantomData, sync::Arc}; use once_cell::sync::OnceCell; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::{ ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, L2_BASE_TOKEN_ADDRESS, MSG_VALUE_SIMULATOR_ADDRESS, SYSTEM_CONTEXT_ADDRESS, }; use zksync_types::{ - vm::VmVersion, vm_trace::ViolatedValidationRule, web3::keccak256, AccountTreeId, Address, - StorageKey, H256, U256, + vm::VmVersion, web3::keccak256, AccountTreeId, Address, StorageKey, H256, U256, }; use zksync_utils::{be_bytes_to_safe_address, u256_to_account_address, u256_to_h256}; pub use crate::tracers::validator::types::{ValidationError, ValidationTracerParams}; use crate::{ glue::tracers::IntoOldVmTracer, - tracers::validator::types::{NewTrustedValidationItems, ValidationTracerMode}, + interface::storage::{StoragePtr, WriteStorage}, + tracers::validator::types::{ + NewTrustedValidationItems, ValidationTracerMode, ViolatedValidationRule, + }, }; mod types; diff --git a/core/lib/multivm/src/tracers/validator/types.rs b/core/lib/multivm/src/tracers/validator/types.rs index de6217c29889..418d2b893503 100644 --- a/core/lib/multivm/src/tracers/validator/types.rs +++ b/core/lib/multivm/src/tracers/validator/types.rs @@ -1,6 +1,7 @@ -use std::{collections::HashSet, fmt::Display}; +use std::{collections::HashSet, fmt, fmt::Display}; -use zksync_types::{vm_trace::ViolatedValidationRule, Address, H256, U256}; +use zksync_types::{Address, H256, U256}; +use zksync_utils::u256_to_h256; use crate::interface::Halt; @@ -37,6 +38,40 @@ pub struct ValidationTracerParams { pub computational_gas_limit: u32, } +#[derive(Debug, Clone)] +pub enum ViolatedValidationRule { + TouchedUnallowedStorageSlots(Address, U256), + CalledContractWithNoCode(Address), + TouchedUnallowedContext, + TookTooManyComputationalGas(u32), +} + +impl fmt::Display for ViolatedValidationRule { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ViolatedValidationRule::TouchedUnallowedStorageSlots(contract, key) => write!( + f, + "Touched unallowed storage slots: address {}, key: {}", + hex::encode(contract), + hex::encode(u256_to_h256(*key)) + ), + ViolatedValidationRule::CalledContractWithNoCode(contract) => { + write!(f, "Called contract with no code: {}", hex::encode(contract)) + } + ViolatedValidationRule::TouchedUnallowedContext => { + write!(f, "Touched unallowed context") + } + ViolatedValidationRule::TookTooManyComputationalGas(gas_limit) => { + write!( + f, + "Took too many computational gas, allowed limit: {}", + gas_limit + ) + } + } + } +} + #[derive(Debug, Clone)] pub enum ValidationError { FailedTx(Halt), diff --git a/core/lib/multivm/src/tracers/validator/vm_1_4_1/mod.rs b/core/lib/multivm/src/tracers/validator/vm_1_4_1/mod.rs index 81d885fa788e..2beca41fb481 100644 --- a/core/lib/multivm/src/tracers/validator/vm_1_4_1/mod.rs +++ b/core/lib/multivm/src/tracers/validator/vm_1_4_1/mod.rs @@ -2,22 +2,22 @@ use zk_evm_1_4_1::{ tracing::{BeforeExecutionData, VmLocalStateData}, zkevm_opcode_defs::{ContextOpcode, FarCallABI, LogOpcode, Opcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::KECCAK256_PRECOMPILE_ADDRESS; -use zksync_types::{ - get_code_key, vm_trace::ViolatedValidationRule, AccountTreeId, StorageKey, H256, -}; +use zksync_types::{get_code_key, AccountTreeId, StorageKey, H256}; use zksync_utils::{h256_to_account_address, u256_to_account_address, u256_to_h256}; use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, - types::tracer::{TracerExecutionStatus, TracerExecutionStopReason}, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason}, Halt, }, - tracers::validator::{ - types::{NewTrustedValidationItems, ValidationTracerMode}, - ValidationRoundResult, ValidationTracer, + tracers::{ + dynamic::vm_1_4_1::DynTracer, + validator::{ + types::{NewTrustedValidationItems, ValidationTracerMode, ViolatedValidationRule}, + ValidationRoundResult, ValidationTracer, + }, }, vm_1_4_1::{ tracers::utils::{ diff --git a/core/lib/multivm/src/tracers/validator/vm_1_4_2/mod.rs b/core/lib/multivm/src/tracers/validator/vm_1_4_2/mod.rs index 657b621c2c4a..3394a6c3f2b5 100644 --- a/core/lib/multivm/src/tracers/validator/vm_1_4_2/mod.rs +++ b/core/lib/multivm/src/tracers/validator/vm_1_4_2/mod.rs @@ -2,22 +2,22 @@ use zk_evm_1_4_1::{ tracing::{BeforeExecutionData, VmLocalStateData}, zkevm_opcode_defs::{ContextOpcode, FarCallABI, LogOpcode, Opcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::KECCAK256_PRECOMPILE_ADDRESS; -use zksync_types::{ - get_code_key, vm_trace::ViolatedValidationRule, AccountTreeId, StorageKey, H256, -}; +use zksync_types::{get_code_key, AccountTreeId, StorageKey, H256}; use zksync_utils::{h256_to_account_address, u256_to_account_address, u256_to_h256}; use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, - types::tracer::{TracerExecutionStatus, TracerExecutionStopReason}, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason}, Halt, }, - tracers::validator::{ - types::{NewTrustedValidationItems, ValidationTracerMode}, - ValidationRoundResult, ValidationTracer, + tracers::{ + dynamic::vm_1_4_1::DynTracer, + validator::{ + types::{NewTrustedValidationItems, ValidationTracerMode, ViolatedValidationRule}, + ValidationRoundResult, ValidationTracer, + }, }, vm_1_4_2::{ tracers::utils::{ diff --git a/core/lib/multivm/src/tracers/validator/vm_boojum_integration/mod.rs b/core/lib/multivm/src/tracers/validator/vm_boojum_integration/mod.rs index 2c9a708abcaa..53b5bf04d2e7 100644 --- a/core/lib/multivm/src/tracers/validator/vm_boojum_integration/mod.rs +++ b/core/lib/multivm/src/tracers/validator/vm_boojum_integration/mod.rs @@ -2,22 +2,22 @@ use zk_evm_1_4_0::{ tracing::{BeforeExecutionData, VmLocalStateData}, zkevm_opcode_defs::{ContextOpcode, FarCallABI, LogOpcode, Opcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::KECCAK256_PRECOMPILE_ADDRESS; -use zksync_types::{ - get_code_key, vm_trace::ViolatedValidationRule, AccountTreeId, StorageKey, H256, -}; +use zksync_types::{get_code_key, AccountTreeId, StorageKey, H256}; use zksync_utils::{h256_to_account_address, u256_to_account_address, u256_to_h256}; use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_4_0::DynTracer, - types::tracer::{TracerExecutionStatus, TracerExecutionStopReason}, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason}, Halt, }, - tracers::validator::{ - types::{NewTrustedValidationItems, ValidationTracerMode}, - ValidationRoundResult, ValidationTracer, + tracers::{ + dynamic::vm_1_4_0::DynTracer, + validator::{ + types::{NewTrustedValidationItems, ValidationTracerMode, ViolatedValidationRule}, + ValidationRoundResult, ValidationTracer, + }, }, vm_boojum_integration::{ tracers::utils::{ diff --git a/core/lib/multivm/src/tracers/validator/vm_latest/mod.rs b/core/lib/multivm/src/tracers/validator/vm_latest/mod.rs index 3cd4e88a409c..e963c79f4e41 100644 --- a/core/lib/multivm/src/tracers/validator/vm_latest/mod.rs +++ b/core/lib/multivm/src/tracers/validator/vm_latest/mod.rs @@ -2,22 +2,22 @@ use zk_evm_1_5_0::{ tracing::{BeforeExecutionData, VmLocalStateData}, zkevm_opcode_defs::{ContextOpcode, FarCallABI, LogOpcode, Opcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::KECCAK256_PRECOMPILE_ADDRESS; -use zksync_types::{ - get_code_key, vm_trace::ViolatedValidationRule, AccountTreeId, StorageKey, H256, -}; +use zksync_types::{get_code_key, AccountTreeId, StorageKey, H256}; use zksync_utils::{h256_to_account_address, u256_to_account_address, u256_to_h256}; use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_5_0::DynTracer, - types::tracer::{TracerExecutionStatus, TracerExecutionStopReason}, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason}, Halt, }, - tracers::validator::{ - types::{NewTrustedValidationItems, ValidationTracerMode}, - ValidationRoundResult, ValidationTracer, + tracers::{ + dynamic::vm_1_5_0::DynTracer, + validator::{ + types::{NewTrustedValidationItems, ValidationTracerMode, ViolatedValidationRule}, + ValidationRoundResult, ValidationTracer, + }, }, vm_latest::{ tracers::utils::{computational_gas_price, get_calldata_page_via_abi, VmHook}, diff --git a/core/lib/multivm/src/tracers/validator/vm_refunds_enhancement/mod.rs b/core/lib/multivm/src/tracers/validator/vm_refunds_enhancement/mod.rs index ab3a16c4b901..6107125d14d0 100644 --- a/core/lib/multivm/src/tracers/validator/vm_refunds_enhancement/mod.rs +++ b/core/lib/multivm/src/tracers/validator/vm_refunds_enhancement/mod.rs @@ -2,22 +2,22 @@ use zk_evm_1_3_3::{ tracing::{BeforeExecutionData, VmLocalStateData}, zkevm_opcode_defs::{ContextOpcode, FarCallABI, LogOpcode, Opcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::KECCAK256_PRECOMPILE_ADDRESS; -use zksync_types::{ - get_code_key, vm_trace::ViolatedValidationRule, AccountTreeId, StorageKey, H256, -}; +use zksync_types::{get_code_key, AccountTreeId, StorageKey, H256}; use zksync_utils::{h256_to_account_address, u256_to_account_address, u256_to_h256}; use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_3_3::DynTracer, - types::tracer::{TracerExecutionStatus, TracerExecutionStopReason}, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason}, Halt, }, - tracers::validator::{ - types::{NewTrustedValidationItems, ValidationTracerMode}, - ValidationRoundResult, ValidationTracer, + tracers::{ + dynamic::vm_1_3_3::DynTracer, + validator::{ + types::{NewTrustedValidationItems, ValidationTracerMode, ViolatedValidationRule}, + ValidationRoundResult, ValidationTracer, + }, }, vm_refunds_enhancement::{ tracers::utils::{ diff --git a/core/lib/multivm/src/tracers/validator/vm_virtual_blocks/mod.rs b/core/lib/multivm/src/tracers/validator/vm_virtual_blocks/mod.rs index 6fd2955f60b6..bb166bedcdad 100644 --- a/core/lib/multivm/src/tracers/validator/vm_virtual_blocks/mod.rs +++ b/core/lib/multivm/src/tracers/validator/vm_virtual_blocks/mod.rs @@ -2,18 +2,21 @@ use zk_evm_1_3_3::{ tracing::{BeforeExecutionData, VmLocalStateData}, zkevm_opcode_defs::{ContextOpcode, FarCallABI, LogOpcode, Opcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::KECCAK256_PRECOMPILE_ADDRESS; -use zksync_types::{ - get_code_key, vm_trace::ViolatedValidationRule, AccountTreeId, StorageKey, H256, -}; +use zksync_types::{get_code_key, AccountTreeId, StorageKey, H256}; use zksync_utils::{h256_to_account_address, u256_to_account_address, u256_to_h256}; use crate::{ - interface::{dyn_tracers::vm_1_3_3::DynTracer, VmExecutionResultAndLogs}, - tracers::validator::{ - types::{NewTrustedValidationItems, ValidationTracerMode}, - ValidationRoundResult, ValidationTracer, + interface::{ + storage::{StoragePtr, WriteStorage}, + VmExecutionResultAndLogs, + }, + tracers::{ + dynamic::vm_1_3_3::DynTracer, + validator::{ + types::{NewTrustedValidationItems, ValidationTracerMode, ViolatedValidationRule}, + ValidationRoundResult, ValidationTracer, + }, }, vm_virtual_blocks::{ tracers::utils::{ diff --git a/core/lib/multivm/src/utils.rs b/core/lib/multivm/src/utils.rs index 96ae580a5f73..4ea613252d0b 100644 --- a/core/lib/multivm/src/utils.rs +++ b/core/lib/multivm/src/utils.rs @@ -4,7 +4,7 @@ use zksync_types::{ U256, }; -use crate::vm_latest::L1BatchEnv; +use crate::interface::L1BatchEnv; /// Calculates the base fee and gas per pubdata for the given L1 gas price. pub fn derive_base_fee_and_gas_per_pubdata( diff --git a/core/lib/multivm/src/versions/mod.rs b/core/lib/multivm/src/versions/mod.rs index e9e34c1cda16..81358a482f1a 100644 --- a/core/lib/multivm/src/versions/mod.rs +++ b/core/lib/multivm/src/versions/mod.rs @@ -1,4 +1,5 @@ pub mod shadow; +mod shared; pub mod vm_1_3_2; pub mod vm_1_4_1; pub mod vm_1_4_2; diff --git a/core/lib/multivm/src/versions/shadow.rs b/core/lib/multivm/src/versions/shadow.rs index 675a95c5ba73..8fe10f833674 100644 --- a/core/lib/multivm/src/versions/shadow.rs +++ b/core/lib/multivm/src/versions/shadow.rs @@ -4,12 +4,12 @@ use std::{ }; use anyhow::Context as _; -use zksync_state::{ImmutableStorageView, ReadStorage, StoragePtr, StorageView}; use zksync_types::{StorageKey, StorageLog, StorageLogWithPreviousValue, Transaction}; use zksync_utils::bytecode::CompressedBytecodeInfo; use crate::{ interface::{ + storage::{ImmutableStorageView, ReadStorage, StoragePtr, StorageView}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, diff --git a/core/lib/multivm/src/versions/shared.rs b/core/lib/multivm/src/versions/shared.rs new file mode 100644 index 000000000000..97954043f426 --- /dev/null +++ b/core/lib/multivm/src/versions/shared.rs @@ -0,0 +1,46 @@ +//! Types shared by multiple (usually old) VMs. + +use std::collections::{HashMap, HashSet}; + +use zksync_types::{vm_trace::Call, Address, U256}; + +#[derive(Debug, Clone, PartialEq)] +pub enum VmTrace { + ExecutionTrace(VmExecutionTrace), + CallTrace(Vec), +} + +#[derive(Debug, Clone, Default, PartialEq)] +pub struct VmExecutionTrace { + pub steps: Vec, + pub contracts: HashSet
, +} + +#[derive(Debug, Clone, PartialEq)] +pub struct VmExecutionStep { + pub contract_address: Address, + pub memory_page_index: usize, + pub child_memory_index: usize, + pub pc: u16, + pub set_flags: Vec, + pub registers: Vec, + pub register_interactions: HashMap, + pub sp: Option, + pub memory_interactions: Vec, + pub error: Option, +} + +#[derive(Debug, Clone, PartialEq)] +pub struct MemoryInteraction { + pub memory_type: String, + pub page: usize, + pub address: u16, + pub value: U256, + pub direction: MemoryDirection, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum MemoryDirection { + Read, + Write, +} diff --git a/core/lib/multivm/src/versions/vm_1_3_2/history_recorder.rs b/core/lib/multivm/src/versions/vm_1_3_2/history_recorder.rs index bb3c12580c4f..2912fad2841d 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/history_recorder.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/history_recorder.rs @@ -1,14 +1,11 @@ use std::{collections::HashMap, fmt::Debug, hash::Hash}; -use zk_evm_1_3_3::{ - aux_structures::Timestamp, - vm_state::PrimitiveValue, - zkevm_opcode_defs::{self}, -}; -use zksync_state::{StoragePtr, WriteStorage}; +use zk_evm_1_3_3::{aux_structures::Timestamp, vm_state::PrimitiveValue, zkevm_opcode_defs}; use zksync_types::{StorageKey, U256}; use zksync_utils::{h256_to_u256, u256_to_h256}; +use crate::interface::storage::{StoragePtr, WriteStorage}; + pub type MemoryWithHistory = HistoryRecorder; pub type IntFrameManagerWithHistory = HistoryRecorder, H>; diff --git a/core/lib/multivm/src/versions/vm_1_3_2/mod.rs b/core/lib/multivm/src/versions/vm_1_3_2/mod.rs index 45fb0cfa388f..8feea5f48d7f 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/mod.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/mod.rs @@ -1,7 +1,6 @@ #![allow(clippy::derive_partial_eq_without_eq)] pub use zk_evm_1_3_3::{self, block_properties::BlockProperties}; -pub use zksync_types::vm_trace::VmExecutionTrace; pub(crate) use self::vm_instance::VmInstance; pub use self::{ diff --git a/core/lib/multivm/src/versions/vm_1_3_2/oracle_tools.rs b/core/lib/multivm/src/versions/vm_1_3_2/oracle_tools.rs index f271d86474cb..d215d78361d6 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/oracle_tools.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/oracle_tools.rs @@ -1,15 +1,17 @@ use std::fmt::Debug; use zk_evm_1_3_3::witness_trace::DummyTracer; -use zksync_state::{StoragePtr, WriteStorage}; -use crate::vm_1_3_2::{ - event_sink::InMemoryEventSink, - history_recorder::HistoryMode, - memory::SimpleMemory, - oracles::{ - decommitter::DecommitterOracle, precompile::PrecompilesProcessorWithHistory, - storage::StorageOracle, +use crate::{ + interface::storage::{StoragePtr, WriteStorage}, + vm_1_3_2::{ + event_sink::InMemoryEventSink, + history_recorder::HistoryMode, + memory::SimpleMemory, + oracles::{ + decommitter::DecommitterOracle, precompile::PrecompilesProcessorWithHistory, + storage::StorageOracle, + }, }, }; diff --git a/core/lib/multivm/src/versions/vm_1_3_2/oracles/decommitter.rs b/core/lib/multivm/src/versions/vm_1_3_2/oracles/decommitter.rs index 8bf0e70026b8..e9a85f8ba4b1 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/oracles/decommitter.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/oracles/decommitter.rs @@ -6,13 +6,13 @@ use zk_evm_1_3_3::{ DecommittmentQuery, MemoryIndex, MemoryLocation, MemoryPage, MemoryQuery, Timestamp, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use zksync_utils::{bytecode::bytecode_len_in_words, bytes_to_be_words, u256_to_h256}; use super::OracleWithHistory; -use crate::vm_1_3_2::history_recorder::{ - HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, +use crate::{ + interface::storage::{StoragePtr, WriteStorage}, + vm_1_3_2::history_recorder::{HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory}, }; /// The main job of the DecommiterOracle is to implement the DecommitmentProcessor trait - that is diff --git a/core/lib/multivm/src/versions/vm_1_3_2/oracles/storage.rs b/core/lib/multivm/src/versions/vm_1_3_2/oracles/storage.rs index 692a0496751a..ac4cc3df1706 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/oracles/storage.rs @@ -5,7 +5,6 @@ use zk_evm_1_3_3::{ aux_structures::{LogQuery, Timestamp}, zkevm_opcode_defs::system_params::INITIAL_STORAGE_WRITE_PUBDATA_BYTES, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_eth_balance, AccountTreeId, Address, StorageKey, StorageLogKind, BOOTLOADER_ADDRESS, U256, @@ -13,12 +12,15 @@ use zksync_types::{ use zksync_utils::u256_to_h256; use super::OracleWithHistory; -use crate::vm_1_3_2::{ - history_recorder::{ - AppDataFrameManagerWithHistory, HashMapHistoryEvent, HistoryEnabled, HistoryMode, - HistoryRecorder, StorageWrapper, WithHistory, +use crate::{ + interface::storage::{StoragePtr, WriteStorage}, + vm_1_3_2::{ + history_recorder::{ + AppDataFrameManagerWithHistory, HashMapHistoryEvent, HistoryEnabled, HistoryMode, + HistoryRecorder, StorageWrapper, WithHistory, + }, + utils::StorageLogQuery, }, - utils::StorageLogQuery, }; // While the storage does not support different shards, it was decided to write the diff --git a/core/lib/multivm/src/versions/vm_1_3_2/oracles/tracer/validation.rs b/core/lib/multivm/src/versions/vm_1_3_2/oracles/tracer/validation.rs index 1681bf63a2ba..f52b6b8940db 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/oracles/tracer/validation.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/oracles/tracer/validation.rs @@ -6,7 +6,6 @@ use zk_evm_1_3_3::{ }, zkevm_opcode_defs::{ContextOpcode, FarCallABI, LogOpcode, Opcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::{ ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, KECCAK256_PRECOMPILE_ADDRESS, L2_BASE_TOKEN_ADDRESS, MSG_VALUE_SIMULATOR_ADDRESS, @@ -17,15 +16,18 @@ use zksync_utils::{ be_bytes_to_safe_address, h256_to_account_address, u256_to_account_address, u256_to_h256, }; -use crate::vm_1_3_2::{ - errors::VmRevertReasonParsingResult, - history_recorder::HistoryMode, - memory::SimpleMemory, - oracles::tracer::{ - utils::{ - computational_gas_price, get_calldata_page_via_abi, print_debug_if_needed, VmHook, +use crate::{ + interface::storage::{StoragePtr, WriteStorage}, + vm_1_3_2::{ + errors::VmRevertReasonParsingResult, + history_recorder::HistoryMode, + memory::SimpleMemory, + oracles::tracer::{ + utils::{ + computational_gas_price, get_calldata_page_via_abi, print_debug_if_needed, VmHook, + }, + ExecutionEndTracer, PendingRefundTracer, PubdataSpentTracer, StorageInvocationTracer, }, - ExecutionEndTracer, PendingRefundTracer, PubdataSpentTracer, StorageInvocationTracer, }, }; 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 9e7f43bdb65c..2c16fc6129ee 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 @@ -2,15 +2,15 @@ use std::collections::HashMap; use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{ event::{extract_long_l2_to_l1_messages, extract_published_bytecodes}, StorageKey, PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS, }; use zksync_utils::bytecode::bytecode_len_in_bytes; -use crate::vm_1_3_2::{ - history_recorder::HistoryMode, oracles::storage::storage_key_of_log, VmInstance, +use crate::{ + interface::storage::WriteStorage, + vm_1_3_2::{history_recorder::HistoryMode, oracles::storage::storage_key_of_log, VmInstance}, }; impl VmInstance { diff --git a/core/lib/multivm/src/versions/vm_1_3_2/refunds.rs b/core/lib/multivm/src/versions/vm_1_3_2/refunds.rs index 555dd0f643ea..163992516d27 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/refunds.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/refunds.rs @@ -1,12 +1,16 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::U256; use zksync_utils::ceil_div_u256; -use crate::vm_1_3_2::{ - history_recorder::HistoryMode, - vm_with_bootloader::{eth_price_per_pubdata_byte, BOOTLOADER_HEAP_PAGE, TX_GAS_LIMIT_OFFSET}, - VmInstance, +use crate::{ + interface::storage::WriteStorage, + vm_1_3_2::{ + history_recorder::HistoryMode, + vm_with_bootloader::{ + eth_price_per_pubdata_byte, BOOTLOADER_HEAP_PAGE, TX_GAS_LIMIT_OFFSET, + }, + VmInstance, + }, }; impl VmInstance { diff --git a/core/lib/multivm/src/versions/vm_1_3_2/test_utils.rs b/core/lib/multivm/src/versions/vm_1_3_2/test_utils.rs index 603725790f8d..a29e1101d520 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/test_utils.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/test_utils.rs @@ -11,7 +11,6 @@ use std::collections::HashMap; use itertools::Itertools; use zk_evm_1_3_3::{aux_structures::Timestamp, vm_state::VmLocalState}; use zksync_contracts::deployer_contract; -use zksync_state::WriteStorage; use zksync_types::{ ethabi::{Address, Token}, web3::keccak256, @@ -21,6 +20,7 @@ use zksync_utils::{ address_to_h256, bytecode::hash_bytecode, h256_to_account_address, u256_to_h256, }; +use crate::interface::storage::WriteStorage; /// The tests here help us with the testing the VM use crate::vm_1_3_2::{ event_sink::InMemoryEventSink, diff --git a/core/lib/multivm/src/versions/vm_1_3_2/utils.rs b/core/lib/multivm/src/versions/vm_1_3_2/utils.rs index 0be7a2837af0..da4e2f5350f9 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/utils.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/utils.rs @@ -6,14 +6,16 @@ use zk_evm_1_3_3::{ zkevm_opcode_defs::FatPointer, }; use zksync_contracts::{read_zbin_bytecode, BaseSystemContracts}; -use zksync_state::WriteStorage; use zksync_system_constants::ZKPORTER_IS_AVAILABLE; use zksync_types::{Address, StorageLogKind, H160, MAX_L2_TX_GAS_LIMIT, U256}; use zksync_utils::h256_to_u256; -use crate::vm_1_3_2::{ - history_recorder::HistoryMode, memory::SimpleMemory, oracles::tracer::PubdataSpentTracer, - vm_with_bootloader::BlockContext, VmInstance, +use crate::{ + interface::storage::WriteStorage, + vm_1_3_2::{ + history_recorder::HistoryMode, memory::SimpleMemory, oracles::tracer::PubdataSpentTracer, + vm_with_bootloader::BlockContext, VmInstance, + }, }; pub const INITIAL_TIMESTAMP: u32 = 1024; diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs index ff6c7f2f3d08..3bf5ae25e39f 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs @@ -1,7 +1,6 @@ use std::collections::HashSet; use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, Transaction, @@ -14,12 +13,13 @@ use zksync_utils::{ use crate::{ glue::{history_mode::HistoryMode, GlueInto}, interface::{ + storage::{StoragePtr, WriteStorage}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, }, - tracers::old_tracers::TracerDispatcher, + tracers::old::TracerDispatcher, vm_1_3_2::{events::merge_events, VmInstance}, }; diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm_instance.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm_instance.rs index 1a33f5cb7bb3..a2bc552e9ec7 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm_instance.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm_instance.rs @@ -10,17 +10,17 @@ use zk_evm_1_3_3::{ definitions::RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::WriteStorage; use zksync_types::{ l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, tx::tx_execution_info::TxExecutionStatus, - vm_trace::{Call, VmExecutionTrace, VmTrace}, + vm_trace::Call, L1BatchNumber, VmEvent, H256, U256, }; use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::{storage::WriteStorage, VmExecutionLogs}, + versions::shared::{VmExecutionTrace, VmTrace}, vm_1_3_2::{ bootloader_state::BootloaderState, errors::{TxRevertReason, VmRevertReason, VmRevertReasonParsingResult}, 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 9e4eaf4a1a5b..aef5b1dc78a2 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 @@ -13,7 +13,6 @@ use zk_evm_1_3_3::{ }, }; use zksync_contracts::BaseSystemContracts; -use zksync_state::WriteStorage; use zksync_system_constants::MAX_L2_TX_GAS_LIMIT; use zksync_types::{ fee_model::L1PeggedBatchFeeModelInput, l1::is_l1_tx_type, Address, Transaction, @@ -27,6 +26,7 @@ use zksync_utils::{ }; use crate::{ + interface::{storage::WriteStorage, L1BatchEnv}, vm_1_3_2::{ bootloader_state::BootloaderState, history_recorder::HistoryMode, @@ -37,7 +37,6 @@ use crate::{ vm_instance::ZkSyncVmState, OracleTools, VmInstance, }, - vm_latest::L1BatchEnv, }; // TODO (SMA-1703): move these to config and make them programmatically generable. diff --git a/core/lib/multivm/src/versions/vm_1_4_1/implementation/bytecode.rs b/core/lib/multivm/src/versions/vm_1_4_1/implementation/bytecode.rs index 73473e225bd4..cc03b53aa533 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/implementation/bytecode.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/implementation/bytecode.rs @@ -1,12 +1,18 @@ use itertools::Itertools; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use zksync_utils::{ bytecode::{compress_bytecode, hash_bytecode, CompressedBytecodeInfo}, bytes_to_be_words, }; -use crate::{interface::VmInterface, vm_1_4_1::Vm, HistoryMode}; +use crate::{ + interface::{ + storage::{StoragePtr, WriteStorage}, + VmInterface, + }, + vm_1_4_1::Vm, + HistoryMode, +}; impl Vm { /// Checks the last transaction has successfully published compressed bytecodes and returns `true` if there is at least one is still unknown. diff --git a/core/lib/multivm/src/versions/vm_1_4_1/implementation/execution.rs b/core/lib/multivm/src/versions/vm_1_4_1/implementation/execution.rs index 2378bb905d4a..01ee21f1836f 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/implementation/execution.rs @@ -1,9 +1,9 @@ use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; use crate::{ interface::{ - types::tracer::{TracerExecutionStatus, VmExecutionStopReason}, + storage::WriteStorage, + tracer::{TracerExecutionStatus, VmExecutionStopReason}, VmExecutionMode, VmExecutionResultAndLogs, VmInterface, }, vm_1_4_1::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_1/implementation/gas.rs b/core/lib/multivm/src/versions/vm_1_4_1/implementation/gas.rs index 2ac365f4a38e..bd30aa6218b1 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/implementation/gas.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/implementation/gas.rs @@ -1,7 +1,5 @@ -use zksync_state::WriteStorage; - use crate::{ - interface::VmInterface, + interface::{storage::WriteStorage, VmInterface}, vm_1_4_1::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_1_4_1/implementation/logs.rs b/core/lib/multivm/src/versions/vm_1_4_1/implementation/logs.rs index fb1b6f3625db..3a2321d4d0e7 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/implementation/logs.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/implementation/logs.rs @@ -1,5 +1,4 @@ use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{ event::extract_l2tol1logs_from_l1_messenger, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, @@ -8,7 +7,7 @@ use zksync_types::{ use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::{storage::WriteStorage, VmExecutionLogs}, vm_1_4_1::{old_vm::utils::precompile_calls_count_after_timestamp, utils::logs, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_1_4_1/implementation/snapshots.rs b/core/lib/multivm/src/versions/vm_1_4_1/implementation/snapshots.rs index 08e4e1c9e49e..1b1a439ef2ec 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/implementation/snapshots.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/implementation/snapshots.rs @@ -2,9 +2,11 @@ use std::time::Duration; use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Histogram, Metrics}; use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; -use crate::vm_1_4_1::{old_vm::oracles::OracleWithHistory, types::internals::VmSnapshot, vm::Vm}; +use crate::{ + interface::storage::WriteStorage, + vm_1_4_1::{old_vm::oracles::OracleWithHistory, types::internals::VmSnapshot, vm::Vm}, +}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EncodeLabelSet, EncodeLabelValue)] #[metrics(label = "stage", rename_all = "snake_case")] diff --git a/core/lib/multivm/src/versions/vm_1_4_1/implementation/statistics.rs b/core/lib/multivm/src/versions/vm_1_4_1/implementation/statistics.rs index d71199320688..dfdd42be7181 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/implementation/statistics.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/implementation/statistics.rs @@ -1,9 +1,8 @@ use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{circuit::CircuitStatistic, U256}; use crate::{ - interface::{VmExecutionStatistics, VmMemoryMetrics}, + interface::{storage::WriteStorage, VmExecutionStatistics, VmMemoryMetrics}, vm_1_4_1::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_1_4_1/implementation/tx.rs b/core/lib/multivm/src/versions/vm_1_4_1/implementation/tx.rs index 4aea2649c99c..326be7379d6e 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/implementation/tx.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/implementation/tx.rs @@ -1,8 +1,8 @@ use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{l1::is_l1_tx_type, Transaction}; use crate::{ + interface::storage::WriteStorage, vm_1_4_1::{ constants::BOOTLOADER_HEAP_PAGE, implementation::bytecode::{bytecode_to_factory_dep, compress_bytecodes}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/mod.rs b/core/lib/multivm/src/versions/vm_1_4_1/mod.rs index 83693e4b24e9..81267701b5cd 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/mod.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/mod.rs @@ -15,13 +15,6 @@ pub use self::{ utils::transaction_encoding::TransactionVmExt, vm::Vm, }; -pub use crate::interface::types::{ - inputs::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode}, - outputs::{ - BootloaderMemory, CurrentExecutionState, ExecutionResult, FinishedL1Batch, L2Block, - Refunds, VmExecutionLogs, VmExecutionResultAndLogs, VmExecutionStatistics, VmMemoryMetrics, - }, -}; mod bootloader_state; pub mod constants; diff --git a/core/lib/multivm/src/versions/vm_1_4_1/old_vm/history_recorder.rs b/core/lib/multivm/src/versions/vm_1_4_1/old_vm/history_recorder.rs index e9e2d51632dc..c9d899742202 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/old_vm/history_recorder.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/old_vm/history_recorder.rs @@ -5,10 +5,11 @@ use zk_evm_1_4_1::{ vm_state::PrimitiveValue, zkevm_opcode_defs::{self}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{StorageKey, H256, U256}; use zksync_utils::{h256_to_u256, u256_to_h256}; +use crate::interface::storage::{StoragePtr, WriteStorage}; + pub(crate) type MemoryWithHistory = HistoryRecorder; pub(crate) type IntFrameManagerWithHistory = HistoryRecorder, H>; diff --git a/core/lib/multivm/src/versions/vm_1_4_1/old_vm/oracles/decommitter.rs b/core/lib/multivm/src/versions/vm_1_4_1/old_vm/oracles/decommitter.rs index c301b3cb18b7..636a4058a037 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/old_vm/oracles/decommitter.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/old_vm/oracles/decommitter.rs @@ -6,13 +6,15 @@ use zk_evm_1_4_1::{ DecommittmentQuery, MemoryIndex, MemoryLocation, MemoryPage, MemoryQuery, Timestamp, }, }; -use zksync_state::{ReadStorage, StoragePtr}; use zksync_types::U256; use zksync_utils::{bytecode::bytecode_len_in_words, bytes_to_be_words, u256_to_h256}; use super::OracleWithHistory; -use crate::vm_1_4_1::old_vm::history_recorder::{ - HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, +use crate::{ + interface::storage::{ReadStorage, StoragePtr}, + vm_1_4_1::old_vm::history_recorder::{ + HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, + }, }; /// The main job of the DecommiterOracle is to implement the DecommittmentProcessor trait - that is /// used by the VM to 'load' bytecodes into memory. diff --git a/core/lib/multivm/src/versions/vm_1_4_1/old_vm/utils.rs b/core/lib/multivm/src/versions/vm_1_4_1/old_vm/utils.rs index ef73f9a54c1d..00e04b019f9f 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/old_vm/utils.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/old_vm/utils.rs @@ -6,10 +6,12 @@ use zk_evm_1_4_1::{ FatPointer, RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::WriteStorage; use zksync_types::{Address, U256}; -use crate::vm_1_4_1::{old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode}; +use crate::{ + interface::storage::WriteStorage, + vm_1_4_1::{old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode}, +}; #[derive(Debug, Clone)] pub(crate) enum VmExecutionResult { diff --git a/core/lib/multivm/src/versions/vm_1_4_1/oracles/storage.rs b/core/lib/multivm/src/versions/vm_1_4_1/oracles/storage.rs index a5ff6b8883a6..3debfd1ca627 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/oracles/storage.rs @@ -5,7 +5,6 @@ use zk_evm_1_4_1::{ aux_structures::{LogQuery, Timestamp}, zkevm_opcode_defs::system_params::INITIAL_STORAGE_WRITE_PUBDATA_BYTES, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_eth_balance, writes::{ @@ -18,6 +17,7 @@ use zksync_utils::u256_to_h256; use crate::{ glue::GlueInto, + interface::storage::{StoragePtr, WriteStorage}, vm_1_4_1::{ old_vm::{ history_recorder::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_1_4_1/tests/get_used_contracts.rs index ab52ac4e1db3..a7cbcd8e2953 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tests/get_used_contracts.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use itertools::Itertools; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_test_account::Account; use zksync_types::{Execute, U256}; diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_1_4_1/tests/is_write_initial.rs index fd5813bdf949..7644064f4af6 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tests/is_write_initial.rs @@ -1,4 +1,4 @@ -use zksync_state::ReadStorage; +use crate::interface::storage::ReadStorage; use zksync_types::get_nonce_key; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_1_4_1/tests/l2_blocks.rs index 0aaa1e6a6c5e..073d9ce5800b 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tests/l2_blocks.rs @@ -4,7 +4,7 @@ //! use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_system_constants::REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE; use zksync_types::{ block::{pack_block_info, MiniblockHasher}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tests/rollbacks.rs b/core/lib/multivm/src/versions/vm_1_4_1/tests/rollbacks.rs index 4bee819e90e8..2ae942c26526 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tests/rollbacks.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tests/rollbacks.rs @@ -1,6 +1,6 @@ use ethabi::Token; use zksync_contracts::{get_loadnext_contract, test_contracts::LoadnextContractExecutionParams}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{get_nonce_key, Execute, U256}; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tests/tester/inner_state.rs b/core/lib/multivm/src/versions/vm_1_4_1/tests/tester/inner_state.rs index 63e2be6a3620..11e9d7fd6dfe 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tests/tester/inner_state.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tests/tester/inner_state.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use zk_evm_1_4_1::{aux_structures::Timestamp, vm_state::VmLocalState}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{StorageKey, StorageValue, U256}; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_1_4_1/tests/tester/vm_tester.rs index 4da556114589..24bd0b4d0bcc 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tests/tester/vm_tester.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use zksync_contracts::BaseSystemContracts; -use zksync_state::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; +use crate::interface::storage::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; use zksync_types::{ block::MiniblockHasher, fee_model::BatchFeeInput, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_1_4_1/tests/upgrade.rs index 2c2b341338ae..af3701d919fa 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tests/upgrade.rs @@ -1,6 +1,6 @@ use zk_evm_1_4_1::aux_structures::Timestamp; use zksync_contracts::{deployer_contract, load_sys_contract, read_bytecode}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_test_account::TxType; use zksync_types::{ ethabi::{Contract, Token}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tests/utils.rs b/core/lib/multivm/src/versions/vm_1_4_1/tests/utils.rs index f0fc0f07f2b5..da69c107a20b 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tests/utils.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tests/utils.rs @@ -3,7 +3,7 @@ use once_cell::sync::Lazy; use zksync_contracts::{ load_contract, read_bytecode, read_zbin_bytecode, BaseSystemContracts, SystemContractCode, }; -use zksync_state::{StoragePtr, WriteStorage}; +use crate::interface::storage::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_standard_token_balance, AccountTreeId, Address, StorageKey, H256, U256, }; diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/circuits_tracer.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/circuits_tracer.rs index 06244179aa80..43a41897fddb 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/circuits_tracer.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/circuits_tracer.rs @@ -5,12 +5,15 @@ use zk_evm_1_4_1::{ zk_evm_abstractions::precompiles::PrecompileAddress, zkevm_opcode_defs::{LogOpcode, Opcode, UMAOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::circuit::CircuitCycleStatistic; use super::circuits_capacity::*; use crate::{ - interface::{dyn_tracers::vm_1_4_1::DynTracer, tracer::TracerExecutionStatus}, + interface::{ + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, + }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_1::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/default_tracers.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/default_tracers.rs index 05da8f60248a..a4f32df8bc73 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/default_tracers.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/default_tracers.rs @@ -12,17 +12,16 @@ use zk_evm_1_4_1::{ witness_trace::DummyTracer, zkevm_opcode_defs::{decoding::EncodingModeProduction, Opcode, RetOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use super::PubdataTracer; use crate::{ glue::GlueInto, interface::{ - tracer::{TracerExecutionStopReason, VmExecutionStopReason}, - traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, - types::tracer::TracerExecutionStatus, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason, VmExecutionStopReason}, Halt, VmExecutionMode, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_1::{ bootloader_state::{utils::apply_l2_block, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/dispatcher.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/dispatcher.rs index feffd6c20f99..187731753cdf 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/dispatcher.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/dispatcher.rs @@ -1,13 +1,13 @@ use zk_evm_1_4_1::tracing::{ AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData, }; -use zksync_state::{StoragePtr, WriteStorage}; use crate::{ interface::{ - dyn_tracers::vm_1_4_1::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_1::{ BootloaderState, HistoryMode, SimpleMemory, TracerPointer, VmTracer, ZkSyncVmState, }, 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 e4e6c1dd4936..d32691ebdfb0 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 @@ -5,7 +5,6 @@ use zk_evm_1_4_1::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ event::{ extract_bytecode_publication_requests_from_l1_messenger, @@ -18,11 +17,11 @@ use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ interface::{ - dyn_tracers::vm_1_4_1::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - types::inputs::L1BatchEnv, - VmExecutionMode, + L1BatchEnv, VmExecutionMode, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_1::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/refunds.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/refunds.rs index bfb06deb28a4..6de4b170eb1b 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/refunds.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/refunds.rs @@ -7,7 +7,6 @@ use zk_evm_1_4_1::{ vm_state::VmLocalState, zkevm_opcode_defs::system_params::L1_MESSAGE_PUBDATA_BYTES, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::{PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS}; use zksync_types::{ event::{extract_long_l2_to_l1_messages, extract_published_bytecodes}, @@ -18,9 +17,11 @@ use zksync_utils::{bytecode::bytecode_len_in_bytes, ceil_div_u256, u256_to_h256} use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, types::tracer::TracerExecutionStatus, + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, L1BatchEnv, Refunds, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_1::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/result_tracer.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/result_tracer.rs index a0090393b889..ffec3ae9030d 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/result_tracer.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/result_tracer.rs @@ -5,15 +5,15 @@ use zk_evm_1_4_1::{ vm_state::{ErrorFlags, VmLocalState}, zkevm_opcode_defs::FatPointer, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use crate::{ interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, - types::tracer::TracerExecutionStopReason, ExecutionResult, Halt, TxRevertReason, - VmExecutionMode, VmRevertReason, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStopReason, VmExecutionStopReason}, + ExecutionResult, Halt, TxRevertReason, VmExecutionMode, VmRevertReason, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_1::{ constants::{BOOTLOADER_HEAP_PAGE, RESULT_SUCCESS_FIRST_SLOT}, old_vm::utils::{vm_may_have_ended_inner, VmExecutionResult}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/traits.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/traits.rs index d738c9484fdc..abe6c988545b 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/traits.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/traits.rs @@ -1,10 +1,9 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ - dyn_tracers::vm_1_4_1::DynTracer, + storage::WriteStorage, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_1::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, 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 15830bbfdd55..b91733c7ca14 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 @@ -10,13 +10,15 @@ use zk_evm_1_4_1::{ STARTING_BASE_PAGE, STARTING_TIMESTAMP, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::{block::L2BlockHasher, Address, L2BlockNumber}; use zksync_utils::h256_to_u256; use crate::{ - interface::{L1BatchEnv, L2Block, SystemEnv}, + interface::{ + storage::{StoragePtr, WriteStorage}, + L1BatchEnv, L2Block, SystemEnv, + }, vm_1_4_1::{ bootloader_state::BootloaderState, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/utils/fee.rs b/core/lib/multivm/src/versions/vm_1_4_1/utils/fee.rs index 6498a86d3536..b5d4cc971b9e 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/utils/fee.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/utils/fee.rs @@ -2,7 +2,7 @@ use zksync_types::fee_model::PubdataIndependentBatchFeeModelInput; use zksync_utils::ceil_div; -use crate::vm_1_4_1::{constants::MAX_GAS_PER_PUBDATA_BYTE, L1BatchEnv}; +use crate::{interface::L1BatchEnv, vm_1_4_1::constants::MAX_GAS_PER_PUBDATA_BYTE}; /// Calculates the base fee and gas per pubdata for the given L1 gas price. pub(crate) fn derive_base_fee_and_gas_per_pubdata( diff --git a/core/lib/multivm/src/versions/vm_1_4_1/utils/l2_blocks.rs b/core/lib/multivm/src/versions/vm_1_4_1/utils/l2_blocks.rs index ec30a86013b9..ff5536ae0b97 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/utils/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/utils/l2_blocks.rs @@ -1,4 +1,3 @@ -use zksync_state::{ReadStorage, StoragePtr}; use zksync_system_constants::{ SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, @@ -9,7 +8,10 @@ use zksync_types::{ }; use zksync_utils::{h256_to_u256, u256_to_h256}; -use crate::interface::{L2Block, L2BlockEnv}; +use crate::interface::{ + storage::{ReadStorage, StoragePtr}, + L2Block, L2BlockEnv, +}; pub(crate) fn get_l2_block_hash_key(block_number: u32) -> StorageKey { let position = h256_to_u256(SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION) diff --git a/core/lib/multivm/src/versions/vm_1_4_1/utils/logs.rs b/core/lib/multivm/src/versions/vm_1_4_1/utils/logs.rs index fab90d9bee56..48a1b49a4600 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/utils/logs.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/utils/logs.rs @@ -1,10 +1,9 @@ use zk_evm_1_4_1::aux_structures::{LogQuery, Timestamp}; -use zksync_state::WriteStorage; use zksync_types::{l2_to_l1_log::L2ToL1Log, StorageLogKind, VmEvent}; use crate::{ glue::GlueInto, - interface::L1BatchEnv, + interface::{storage::WriteStorage, L1BatchEnv}, vm_1_4_1::{ old_vm::{events::merge_events, history_recorder::HistoryMode}, types::internals::ZkSyncVmState, 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 345948bfdfbb..e37a8757ee19 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,5 +1,4 @@ use circuit_sequencer_api_1_4_1::sort_storage_access::sort_storage_access_queries; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ event::extract_l2tol1logs_from_l1_messenger, l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, @@ -10,6 +9,7 @@ use zksync_utils::bytecode::CompressedBytecodeInfo; use crate::{ glue::GlueInto, interface::{ + storage::{StoragePtr, WriteStorage}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/implementation/bytecode.rs b/core/lib/multivm/src/versions/vm_1_4_2/implementation/bytecode.rs index 0358c3f7d2e4..a4bd40110f2d 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/implementation/bytecode.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/implementation/bytecode.rs @@ -1,12 +1,18 @@ use itertools::Itertools; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use zksync_utils::{ bytecode::{compress_bytecode, hash_bytecode, CompressedBytecodeInfo}, bytes_to_be_words, }; -use crate::{interface::VmInterface, vm_1_4_2::Vm, HistoryMode}; +use crate::{ + interface::{ + storage::{StoragePtr, WriteStorage}, + VmInterface, + }, + vm_1_4_2::Vm, + HistoryMode, +}; impl Vm { /// Checks the last transaction has successfully published compressed bytecodes and returns `true` if there is at least one is still unknown. diff --git a/core/lib/multivm/src/versions/vm_1_4_2/implementation/execution.rs b/core/lib/multivm/src/versions/vm_1_4_2/implementation/execution.rs index 006d0ac12837..a04e071fe436 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/implementation/execution.rs @@ -1,9 +1,9 @@ use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; use crate::{ interface::{ - types::tracer::{TracerExecutionStatus, VmExecutionStopReason}, + storage::WriteStorage, + tracer::{TracerExecutionStatus, VmExecutionStopReason}, VmExecutionMode, VmExecutionResultAndLogs, VmInterface, }, vm_1_4_2::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_2/implementation/gas.rs b/core/lib/multivm/src/versions/vm_1_4_2/implementation/gas.rs index bcc53cc7c391..d5b74de94554 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/implementation/gas.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/implementation/gas.rs @@ -1,7 +1,5 @@ -use zksync_state::WriteStorage; - use crate::{ - interface::VmInterface, + interface::{storage::WriteStorage, VmInterface}, vm_1_4_2::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_1_4_2/implementation/logs.rs b/core/lib/multivm/src/versions/vm_1_4_2/implementation/logs.rs index c307b7aa8099..04acc26467df 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/implementation/logs.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/implementation/logs.rs @@ -1,5 +1,4 @@ use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{ event::extract_l2tol1logs_from_l1_messenger, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, @@ -8,7 +7,7 @@ use zksync_types::{ use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::{storage::WriteStorage, VmExecutionLogs}, vm_1_4_2::{old_vm::utils::precompile_calls_count_after_timestamp, utils::logs, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_1_4_2/implementation/snapshots.rs b/core/lib/multivm/src/versions/vm_1_4_2/implementation/snapshots.rs index 93fbd7f51daf..04d4f958712a 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/implementation/snapshots.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/implementation/snapshots.rs @@ -2,9 +2,11 @@ use std::time::Duration; use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Histogram, Metrics}; use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; -use crate::vm_1_4_2::{old_vm::oracles::OracleWithHistory, types::internals::VmSnapshot, vm::Vm}; +use crate::{ + interface::storage::WriteStorage, + vm_1_4_2::{old_vm::oracles::OracleWithHistory, types::internals::VmSnapshot, vm::Vm}, +}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EncodeLabelSet, EncodeLabelValue)] #[metrics(label = "stage", rename_all = "snake_case")] diff --git a/core/lib/multivm/src/versions/vm_1_4_2/implementation/statistics.rs b/core/lib/multivm/src/versions/vm_1_4_2/implementation/statistics.rs index 3d3649750e3e..4d1675227fbb 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/implementation/statistics.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/implementation/statistics.rs @@ -1,9 +1,8 @@ use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{circuit::CircuitStatistic, U256}; use crate::{ - interface::{VmExecutionStatistics, VmMemoryMetrics}, + interface::{storage::WriteStorage, VmExecutionStatistics, VmMemoryMetrics}, vm_1_4_2::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_1_4_2/implementation/tx.rs b/core/lib/multivm/src/versions/vm_1_4_2/implementation/tx.rs index 587b7e687f66..044941221965 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/implementation/tx.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/implementation/tx.rs @@ -1,8 +1,8 @@ use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{l1::is_l1_tx_type, Transaction}; use crate::{ + interface::storage::WriteStorage, vm_1_4_2::{ constants::BOOTLOADER_HEAP_PAGE, implementation::bytecode::{bytecode_to_factory_dep, compress_bytecodes}, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/mod.rs b/core/lib/multivm/src/versions/vm_1_4_2/mod.rs index c23fc7076b29..40d720379b72 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/mod.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/mod.rs @@ -15,13 +15,6 @@ pub use self::{ utils::transaction_encoding::TransactionVmExt, vm::Vm, }; -pub use crate::interface::types::{ - inputs::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode}, - outputs::{ - BootloaderMemory, CurrentExecutionState, ExecutionResult, FinishedL1Batch, L2Block, - Refunds, VmExecutionLogs, VmExecutionResultAndLogs, VmExecutionStatistics, VmMemoryMetrics, - }, -}; mod bootloader_state; pub mod constants; diff --git a/core/lib/multivm/src/versions/vm_1_4_2/old_vm/history_recorder.rs b/core/lib/multivm/src/versions/vm_1_4_2/old_vm/history_recorder.rs index b90953bdeca2..d8d32a2b6c50 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/old_vm/history_recorder.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/old_vm/history_recorder.rs @@ -5,10 +5,11 @@ use zk_evm_1_4_1::{ vm_state::PrimitiveValue, zkevm_opcode_defs::{self}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{StorageKey, H256, U256}; use zksync_utils::{h256_to_u256, u256_to_h256}; +use crate::interface::storage::{StoragePtr, WriteStorage}; + pub(crate) type MemoryWithHistory = HistoryRecorder; pub(crate) type IntFrameManagerWithHistory = HistoryRecorder, H>; diff --git a/core/lib/multivm/src/versions/vm_1_4_2/old_vm/oracles/decommitter.rs b/core/lib/multivm/src/versions/vm_1_4_2/old_vm/oracles/decommitter.rs index 1bec6d6df936..706e70d4b116 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/old_vm/oracles/decommitter.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/old_vm/oracles/decommitter.rs @@ -6,13 +6,15 @@ use zk_evm_1_4_1::{ DecommittmentQuery, MemoryIndex, MemoryLocation, MemoryPage, MemoryQuery, Timestamp, }, }; -use zksync_state::{ReadStorage, StoragePtr}; use zksync_types::U256; use zksync_utils::{bytecode::bytecode_len_in_words, bytes_to_be_words, u256_to_h256}; use super::OracleWithHistory; -use crate::vm_1_4_2::old_vm::history_recorder::{ - HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, +use crate::{ + interface::storage::{ReadStorage, StoragePtr}, + vm_1_4_2::old_vm::history_recorder::{ + HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, + }, }; /// The main job of the DecommiterOracle is to implement the DecommittmentProcessor trait - that is /// used by the VM to 'load' bytecodes into memory. diff --git a/core/lib/multivm/src/versions/vm_1_4_2/old_vm/utils.rs b/core/lib/multivm/src/versions/vm_1_4_2/old_vm/utils.rs index 4ea0a526f6e8..24102513fc1d 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/old_vm/utils.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/old_vm/utils.rs @@ -6,10 +6,12 @@ use zk_evm_1_4_1::{ FatPointer, RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::WriteStorage; use zksync_types::{Address, U256}; -use crate::vm_1_4_2::{old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode}; +use crate::{ + interface::storage::WriteStorage, + vm_1_4_2::{old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode}, +}; #[derive(Debug, Clone)] pub(crate) enum VmExecutionResult { diff --git a/core/lib/multivm/src/versions/vm_1_4_2/oracles/storage.rs b/core/lib/multivm/src/versions/vm_1_4_2/oracles/storage.rs index 9cc9945f84ff..e8d387621907 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/oracles/storage.rs @@ -5,7 +5,6 @@ use zk_evm_1_4_1::{ aux_structures::{LogQuery, Timestamp}, zkevm_opcode_defs::system_params::INITIAL_STORAGE_WRITE_PUBDATA_BYTES, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_eth_balance, writes::{ @@ -18,6 +17,7 @@ use zksync_utils::u256_to_h256; use crate::{ glue::GlueInto, + interface::storage::{StoragePtr, WriteStorage}, vm_1_4_2::{ old_vm::{ history_recorder::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_1_4_2/tests/get_used_contracts.rs index 2ce3891fda8e..cfe3e1bfc235 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tests/get_used_contracts.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use itertools::Itertools; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_test_account::Account; use zksync_types::{Execute, U256}; diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_1_4_2/tests/is_write_initial.rs index 035ae5b9c6b2..7da250ef7a9f 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tests/is_write_initial.rs @@ -1,4 +1,4 @@ -use zksync_state::ReadStorage; +use crate::interface::storage::ReadStorage; use zksync_types::get_nonce_key; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_1_4_2/tests/l2_blocks.rs index 2abc6892d602..f722890f474b 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tests/l2_blocks.rs @@ -4,7 +4,7 @@ //! use zk_evm_1_4_1::aux_structures::Timestamp; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_system_constants::REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE; use zksync_types::{ block::{pack_block_info, MiniblockHasher}, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tests/rollbacks.rs b/core/lib/multivm/src/versions/vm_1_4_2/tests/rollbacks.rs index 36a891984b95..2ce18cc01361 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tests/rollbacks.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tests/rollbacks.rs @@ -1,6 +1,6 @@ use ethabi::Token; use zksync_contracts::{get_loadnext_contract, test_contracts::LoadnextContractExecutionParams}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{get_nonce_key, Execute, U256}; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tests/tester/inner_state.rs b/core/lib/multivm/src/versions/vm_1_4_2/tests/tester/inner_state.rs index 1553fbfc9f51..d6c072d1b1ed 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tests/tester/inner_state.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tests/tester/inner_state.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use zk_evm_1_4_1::{aux_structures::Timestamp, vm_state::VmLocalState}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{StorageKey, StorageValue, U256}; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_1_4_2/tests/tester/vm_tester.rs index c27df9148b17..44f861f8d331 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tests/tester/vm_tester.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use zksync_contracts::BaseSystemContracts; -use zksync_state::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; +use crate::interface::storage::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; use zksync_types::{ block::MiniblockHasher, fee_model::BatchFeeInput, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_1_4_2/tests/upgrade.rs index 1c64ee766ed5..2af2928b1c44 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tests/upgrade.rs @@ -1,6 +1,6 @@ use zk_evm_1_4_1::aux_structures::Timestamp; use zksync_contracts::{deployer_contract, load_sys_contract, read_bytecode}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_test_account::TxType; use zksync_types::{ ethabi::{Contract, Token}, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tests/utils.rs b/core/lib/multivm/src/versions/vm_1_4_2/tests/utils.rs index 306953bab28e..5655e90fb4ee 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tests/utils.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tests/utils.rs @@ -3,7 +3,7 @@ use once_cell::sync::Lazy; use zksync_contracts::{ load_contract, read_bytecode, read_zbin_bytecode, BaseSystemContracts, SystemContractCode, }; -use zksync_state::{StoragePtr, WriteStorage}; +use crate::interface::storage::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_standard_token_balance, AccountTreeId, Address, StorageKey, H256, U256, }; diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/circuits_tracer.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/circuits_tracer.rs index f4045b53dd87..b781ee186fdd 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/circuits_tracer.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/circuits_tracer.rs @@ -5,12 +5,15 @@ use zk_evm_1_4_1::{ zk_evm_abstractions::precompiles::PrecompileAddress, zkevm_opcode_defs::{LogOpcode, Opcode, UMAOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::circuit::CircuitCycleStatistic; use super::circuits_capacity::*; use crate::{ - interface::{dyn_tracers::vm_1_4_1::DynTracer, tracer::TracerExecutionStatus}, + interface::{ + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, + }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_2::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/default_tracers.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/default_tracers.rs index dbf02d0d8d60..c7bdf3de3530 100755 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/default_tracers.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/default_tracers.rs @@ -12,17 +12,16 @@ use zk_evm_1_4_1::{ witness_trace::DummyTracer, zkevm_opcode_defs::{decoding::EncodingModeProduction, Opcode, RetOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use super::PubdataTracer; use crate::{ glue::GlueInto, interface::{ - tracer::{TracerExecutionStopReason, VmExecutionStopReason}, - traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, - types::tracer::TracerExecutionStatus, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason, VmExecutionStopReason}, Halt, VmExecutionMode, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_2::{ bootloader_state::{utils::apply_l2_block, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/dispatcher.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/dispatcher.rs index 36a8ad954f2a..1d1c50b615b5 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/dispatcher.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/dispatcher.rs @@ -1,13 +1,13 @@ use zk_evm_1_4_1::tracing::{ AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData, }; -use zksync_state::{StoragePtr, WriteStorage}; use crate::{ interface::{ - dyn_tracers::vm_1_4_1::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_2::{ BootloaderState, HistoryMode, SimpleMemory, TracerPointer, VmTracer, ZkSyncVmState, }, 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 579213be248a..fab790ec5727 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 @@ -5,7 +5,6 @@ use zk_evm_1_4_1::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ event::{ extract_bytecode_publication_requests_from_l1_messenger, @@ -18,11 +17,11 @@ use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ interface::{ - dyn_tracers::vm_1_4_1::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - types::inputs::L1BatchEnv, - VmExecutionMode, + L1BatchEnv, VmExecutionMode, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_2::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/refunds.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/refunds.rs index 503aad00c68e..6af3a34376c7 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/refunds.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/refunds.rs @@ -7,7 +7,6 @@ use zk_evm_1_4_1::{ vm_state::VmLocalState, zkevm_opcode_defs::system_params::L1_MESSAGE_PUBDATA_BYTES, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::{PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS}; use zksync_types::{ event::{extract_long_l2_to_l1_messages, extract_published_bytecodes}, @@ -18,9 +17,11 @@ use zksync_utils::{bytecode::bytecode_len_in_bytes, ceil_div_u256, u256_to_h256} use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, types::tracer::TracerExecutionStatus, + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, L1BatchEnv, Refunds, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_2::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET}, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/result_tracer.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/result_tracer.rs index 775ed69838cb..2936d7663d1b 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/result_tracer.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/result_tracer.rs @@ -5,15 +5,15 @@ use zk_evm_1_4_1::{ vm_state::{ErrorFlags, VmLocalState}, zkevm_opcode_defs::FatPointer, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use crate::{ interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_1::DynTracer, - types::tracer::TracerExecutionStopReason, ExecutionResult, Halt, TxRevertReason, - VmExecutionMode, VmRevertReason, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStopReason, VmExecutionStopReason}, + ExecutionResult, Halt, TxRevertReason, VmExecutionMode, VmRevertReason, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_2::{ constants::{BOOTLOADER_HEAP_PAGE, RESULT_SUCCESS_FIRST_SLOT}, old_vm::utils::{vm_may_have_ended_inner, VmExecutionResult}, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/traits.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/traits.rs index 156cfa04f9fc..ce213b534966 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/traits.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/traits.rs @@ -1,10 +1,9 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ - dyn_tracers::vm_1_4_1::DynTracer, + storage::WriteStorage, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_4_1::DynTracer, vm_1_4_2::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, 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 3190687fa683..87630a1ff372 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 @@ -10,13 +10,15 @@ use zk_evm_1_4_1::{ STARTING_BASE_PAGE, STARTING_TIMESTAMP, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::{block::L2BlockHasher, Address, L2BlockNumber}; use zksync_utils::h256_to_u256; use crate::{ - interface::{L1BatchEnv, L2Block, SystemEnv}, + interface::{ + storage::{StoragePtr, WriteStorage}, + L1BatchEnv, L2Block, SystemEnv, + }, vm_1_4_2::{ bootloader_state::BootloaderState, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/utils/fee.rs b/core/lib/multivm/src/versions/vm_1_4_2/utils/fee.rs index 02d1a3737cec..11f8b6b6c427 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/utils/fee.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/utils/fee.rs @@ -2,7 +2,7 @@ use zksync_types::fee_model::PubdataIndependentBatchFeeModelInput; use zksync_utils::ceil_div; -use crate::vm_1_4_2::{constants::MAX_GAS_PER_PUBDATA_BYTE, L1BatchEnv}; +use crate::{interface::L1BatchEnv, vm_1_4_2::constants::MAX_GAS_PER_PUBDATA_BYTE}; /// Calculates the base fee and gas per pubdata for the given L1 gas price. pub(crate) fn derive_base_fee_and_gas_per_pubdata( diff --git a/core/lib/multivm/src/versions/vm_1_4_2/utils/l2_blocks.rs b/core/lib/multivm/src/versions/vm_1_4_2/utils/l2_blocks.rs index ec30a86013b9..ff5536ae0b97 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/utils/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/utils/l2_blocks.rs @@ -1,4 +1,3 @@ -use zksync_state::{ReadStorage, StoragePtr}; use zksync_system_constants::{ SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, @@ -9,7 +8,10 @@ use zksync_types::{ }; use zksync_utils::{h256_to_u256, u256_to_h256}; -use crate::interface::{L2Block, L2BlockEnv}; +use crate::interface::{ + storage::{ReadStorage, StoragePtr}, + L2Block, L2BlockEnv, +}; pub(crate) fn get_l2_block_hash_key(block_number: u32) -> StorageKey { let position = h256_to_u256(SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION) diff --git a/core/lib/multivm/src/versions/vm_1_4_2/utils/logs.rs b/core/lib/multivm/src/versions/vm_1_4_2/utils/logs.rs index ef9f124773be..48832f0ecf2a 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/utils/logs.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/utils/logs.rs @@ -1,10 +1,9 @@ use zk_evm_1_4_1::aux_structures::{LogQuery, Timestamp}; -use zksync_state::WriteStorage; use zksync_types::{l2_to_l1_log::L2ToL1Log, StorageLogKind, VmEvent}; use crate::{ glue::GlueInto, - interface::L1BatchEnv, + interface::{storage::WriteStorage, L1BatchEnv}, vm_1_4_2::{ old_vm::{events::merge_events, history_recorder::HistoryMode}, types::internals::ZkSyncVmState, 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 264ebde5611d..434e8ea1c42c 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,5 +1,4 @@ use circuit_sequencer_api_1_4_2::sort_storage_access::sort_storage_access_queries; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ event::extract_l2tol1logs_from_l1_messenger, l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, @@ -10,6 +9,7 @@ use zksync_utils::bytecode::CompressedBytecodeInfo; use crate::{ glue::GlueInto, interface::{ + storage::{StoragePtr, WriteStorage}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/bytecode.rs b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/bytecode.rs index 2e3770a9c52e..00ff620727b6 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/bytecode.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/bytecode.rs @@ -1,12 +1,18 @@ use itertools::Itertools; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use zksync_utils::{ bytecode::{compress_bytecode, hash_bytecode, CompressedBytecodeInfo}, bytes_to_be_words, }; -use crate::{interface::VmInterface, vm_boojum_integration::Vm, HistoryMode}; +use crate::{ + interface::{ + storage::{StoragePtr, WriteStorage}, + VmInterface, + }, + vm_boojum_integration::Vm, + HistoryMode, +}; impl Vm { /// Checks the last transaction has successfully published compressed bytecodes and returns `true` if there is at least one is still unknown. diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/execution.rs b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/execution.rs index 22f2a50efde3..664cb90531e4 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/execution.rs @@ -1,9 +1,9 @@ use zk_evm_1_4_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use crate::{ interface::{ - types::tracer::{TracerExecutionStatus, VmExecutionStopReason}, + storage::WriteStorage, + tracer::{TracerExecutionStatus, VmExecutionStopReason}, VmExecutionMode, VmExecutionResultAndLogs, VmInterface, }, vm_boojum_integration::{ diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/gas.rs b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/gas.rs index 304b7a3b7564..b31e4c3536bc 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/gas.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/gas.rs @@ -1,7 +1,5 @@ -use zksync_state::WriteStorage; - use crate::{ - interface::VmInterface, + interface::{storage::WriteStorage, VmInterface}, vm_boojum_integration::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/logs.rs b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/logs.rs index daf077fcca51..fa4600893021 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/logs.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/logs.rs @@ -1,5 +1,4 @@ use zk_evm_1_4_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{ event::extract_l2tol1logs_from_l1_messenger, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, @@ -8,7 +7,7 @@ use zksync_types::{ use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::{storage::WriteStorage, VmExecutionLogs}, vm_boojum_integration::{ old_vm::utils::precompile_calls_count_after_timestamp, utils::logs, vm::Vm, }, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/snapshots.rs b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/snapshots.rs index b5b09c0fd6d2..b581cea558b2 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/snapshots.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/snapshots.rs @@ -2,10 +2,12 @@ use std::time::Duration; use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Histogram, Metrics}; use zk_evm_1_4_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; -use crate::vm_boojum_integration::{ - old_vm::oracles::OracleWithHistory, types::internals::VmSnapshot, vm::Vm, +use crate::{ + interface::storage::WriteStorage, + vm_boojum_integration::{ + old_vm::oracles::OracleWithHistory, types::internals::VmSnapshot, vm::Vm, + }, }; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EncodeLabelSet, EncodeLabelValue)] diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/statistics.rs b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/statistics.rs index 744ac6d40978..fe5b8abd6834 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/statistics.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/statistics.rs @@ -1,9 +1,8 @@ use zk_evm_1_4_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{circuit::CircuitStatistic, U256}; use crate::{ - interface::{VmExecutionStatistics, VmMemoryMetrics}, + interface::{storage::WriteStorage, VmExecutionStatistics, VmMemoryMetrics}, vm_boojum_integration::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/tx.rs b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/tx.rs index 9eac3e749837..73d689e089e5 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/implementation/tx.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/implementation/tx.rs @@ -1,8 +1,8 @@ use zk_evm_1_4_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{l1::is_l1_tx_type, Transaction}; use crate::{ + interface::storage::WriteStorage, vm_boojum_integration::{ constants::BOOTLOADER_HEAP_PAGE, implementation::bytecode::{bytecode_to_factory_dep, compress_bytecodes}, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/mod.rs b/core/lib/multivm/src/versions/vm_boojum_integration/mod.rs index 83693e4b24e9..81267701b5cd 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/mod.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/mod.rs @@ -15,13 +15,6 @@ pub use self::{ utils::transaction_encoding::TransactionVmExt, vm::Vm, }; -pub use crate::interface::types::{ - inputs::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode}, - outputs::{ - BootloaderMemory, CurrentExecutionState, ExecutionResult, FinishedL1Batch, L2Block, - Refunds, VmExecutionLogs, VmExecutionResultAndLogs, VmExecutionStatistics, VmMemoryMetrics, - }, -}; mod bootloader_state; pub mod constants; diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/history_recorder.rs b/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/history_recorder.rs index 90d0c868ea33..704a774893d3 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/history_recorder.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/history_recorder.rs @@ -5,10 +5,11 @@ use zk_evm_1_4_0::{ vm_state::PrimitiveValue, zkevm_opcode_defs::{self}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{StorageKey, U256}; use zksync_utils::{h256_to_u256, u256_to_h256}; +use crate::interface::storage::{StoragePtr, WriteStorage}; + pub(crate) type MemoryWithHistory = HistoryRecorder; pub(crate) type IntFrameManagerWithHistory = HistoryRecorder, H>; diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/oracles/decommitter.rs b/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/oracles/decommitter.rs index 6ff63e17ce00..eb7db7097920 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/oracles/decommitter.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/oracles/decommitter.rs @@ -6,13 +6,15 @@ use zk_evm_1_4_0::{ DecommittmentQuery, MemoryIndex, MemoryLocation, MemoryPage, MemoryQuery, Timestamp, }, }; -use zksync_state::{ReadStorage, StoragePtr}; use zksync_types::U256; use zksync_utils::{bytecode::bytecode_len_in_words, bytes_to_be_words, u256_to_h256}; use super::OracleWithHistory; -use crate::vm_boojum_integration::old_vm::history_recorder::{ - HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, +use crate::{ + interface::storage::{ReadStorage, StoragePtr}, + vm_boojum_integration::old_vm::history_recorder::{ + HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, + }, }; /// The main job of the DecommiterOracle is to implement the DecommitmentProcessor trait - that is diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/oracles/storage.rs b/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/oracles/storage.rs index 1c14706de87a..db99273076ed 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/oracles/storage.rs @@ -12,7 +12,7 @@ use zk_evm_1_4_0::{ aux_structures::{LogQuery, Timestamp}, }; -use zksync_state::{StoragePtr, WriteStorage}; +use crate::interface::storage::{StoragePtr, WriteStorage}; use zksync_types::utils::storage_key_for_eth_balance; use zksync_types::{ AccountTreeId, Address, StorageKey, StorageLogQuery, StorageLogQueryType, BOOTLOADER_ADDRESS, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/utils.rs b/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/utils.rs index 130bad49e38a..2dcbe3284639 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/utils.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/old_vm/utils.rs @@ -6,12 +6,14 @@ use zk_evm_1_4_0::{ FatPointer, RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::WriteStorage; use zksync_system_constants::L1_GAS_PER_PUBDATA_BYTE; use zksync_types::{Address, U256}; -use crate::vm_boojum_integration::{ - old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode, +use crate::{ + interface::storage::WriteStorage, + vm_boojum_integration::{ + old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode, + }, }; #[derive(Debug, Clone)] diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/oracles/storage.rs b/core/lib/multivm/src/versions/vm_boojum_integration/oracles/storage.rs index e505c2d9630c..acdfbaaa42e0 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/oracles/storage.rs @@ -5,7 +5,6 @@ use zk_evm_1_4_0::{ aux_structures::{LogQuery, Timestamp}, zkevm_opcode_defs::system_params::INITIAL_STORAGE_WRITE_PUBDATA_BYTES, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_eth_balance, writes::{ @@ -16,15 +15,18 @@ use zksync_types::{ }; use zksync_utils::u256_to_h256; -use crate::vm_boojum_integration::{ - old_vm::{ - history_recorder::{ - AppDataFrameManagerWithHistory, HashMapHistoryEvent, HistoryEnabled, HistoryMode, - HistoryRecorder, StorageWrapper, VectorHistoryEvent, WithHistory, +use crate::{ + interface::storage::{StoragePtr, WriteStorage}, + vm_boojum_integration::{ + old_vm::{ + history_recorder::{ + AppDataFrameManagerWithHistory, HashMapHistoryEvent, HistoryEnabled, HistoryMode, + HistoryRecorder, StorageWrapper, VectorHistoryEvent, WithHistory, + }, + oracles::OracleWithHistory, }, - oracles::OracleWithHistory, + utils::logs::StorageLogQuery, }, - utils::logs::StorageLogQuery, }; // While the storage does not support different shards, it was decided to write the diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tests/get_used_contracts.rs index 25aab0871f14..658bcd75b059 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tests/get_used_contracts.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use itertools::Itertools; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_test_account::Account; use zksync_types::{Execute, U256}; diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tests/is_write_initial.rs index bf56aa2b816d..67901490edfa 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tests/is_write_initial.rs @@ -1,4 +1,4 @@ -use zksync_state::ReadStorage; +use crate::interface::storage::ReadStorage; use zksync_types::get_nonce_key; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tests/l2_blocks.rs index b26cc09e0577..d637d583c0ec 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tests/l2_blocks.rs @@ -4,7 +4,7 @@ //! use zk_evm_1_4_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_system_constants::REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE; use zksync_types::{ block::{pack_block_info, MiniblockHasher}, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tests/rollbacks.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tests/rollbacks.rs index 3d3127f8428b..cfaf1952c702 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tests/rollbacks.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tests/rollbacks.rs @@ -1,6 +1,6 @@ use ethabi::Token; use zksync_contracts::{get_loadnext_contract, test_contracts::LoadnextContractExecutionParams}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{get_nonce_key, Execute, U256}; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tests/tester/inner_state.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tests/tester/inner_state.rs index 24f31c5a9393..078a971e4bf1 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tests/tester/inner_state.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tests/tester/inner_state.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use zk_evm_1_4_0::{aux_structures::Timestamp, vm_state::VmLocalState}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{StorageKey, StorageLogQuery, StorageValue, U256}; use crate::{ diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tests/tester/vm_tester.rs index 30bf9535eb8b..fcea03e12cc8 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tests/tester/vm_tester.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use zksync_contracts::BaseSystemContracts; -use zksync_state::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; +use crate::interface::storage::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; use zksync_types::{ block::MiniblockHasher, get_code_key, get_is_account_key, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tests/upgrade.rs index 4442d7c4082d..bc3d62f62a19 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tests/upgrade.rs @@ -1,6 +1,6 @@ use zk_evm_1_4_0::aux_structures::Timestamp; use zksync_contracts::{deployer_contract, load_contract, load_sys_contract, read_bytecode}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_test_account::TxType; use zksync_types::{ ethabi::{Contract, Token}, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tests/utils.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tests/utils.rs index 2dd8e2350eb4..4fba188ac5b7 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tests/utils.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tests/utils.rs @@ -3,7 +3,7 @@ use once_cell::sync::Lazy; use zksync_contracts::{ load_contract, read_bytecode, read_zbin_bytecode, BaseSystemContracts, SystemContractCode, }; -use zksync_state::{StoragePtr, WriteStorage}; +use crate::interface::storage::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_standard_token_balance, AccountTreeId, Address, StorageKey, H256, U256, }; diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/circuits_tracer.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/circuits_tracer.rs index 27f4cc6db00f..9bcf2a3783f5 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/circuits_tracer.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/circuits_tracer.rs @@ -5,12 +5,15 @@ use zk_evm_1_4_0::{ zk_evm_abstractions::precompiles::PrecompileAddress, zkevm_opcode_defs::{LogOpcode, Opcode, UMAOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::circuit::CircuitCycleStatistic; use super::circuits_capacity::*; use crate::{ - interface::{dyn_tracers::vm_1_4_0::DynTracer, tracer::TracerExecutionStatus}, + interface::{ + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, + }, + tracers::dynamic::vm_1_4_0::DynTracer, vm_boojum_integration::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/default_tracers.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/default_tracers.rs index 01b21d809509..2730fb701b1f 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/default_tracers.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/default_tracers.rs @@ -12,16 +12,15 @@ use zk_evm_1_4_0::{ witness_trace::DummyTracer, zkevm_opcode_defs::{decoding::EncodingModeProduction, Opcode, RetOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use super::PubdataTracer; use crate::{ interface::{ - tracer::{TracerExecutionStopReason, VmExecutionStopReason}, - traits::tracers::dyn_tracers::vm_1_4_0::DynTracer, - types::tracer::TracerExecutionStatus, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason, VmExecutionStopReason}, Halt, VmExecutionMode, }, + tracers::dynamic::vm_1_4_0::DynTracer, vm_boojum_integration::{ bootloader_state::{utils::apply_l2_block, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/dispatcher.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/dispatcher.rs index 11262c4d7665..6825186319ac 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/dispatcher.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/dispatcher.rs @@ -1,13 +1,13 @@ use zk_evm_1_4_0::tracing::{ AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData, }; -use zksync_state::{StoragePtr, WriteStorage}; use crate::{ interface::{ - dyn_tracers::vm_1_4_0::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_4_0::DynTracer, vm_boojum_integration::{ BootloaderState, HistoryMode, SimpleMemory, TracerPointer, VmTracer, ZkSyncVmState, }, 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 c74f4f4bd16d..6727dfd54e8c 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 @@ -5,7 +5,6 @@ use zk_evm_1_4_0::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ event::{ extract_bytecode_publication_requests_from_l1_messenger, @@ -18,11 +17,11 @@ use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ interface::{ - dyn_tracers::vm_1_4_0::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - types::inputs::L1BatchEnv, - VmExecutionMode, + L1BatchEnv, VmExecutionMode, }, + tracers::dynamic::vm_1_4_0::DynTracer, vm_boojum_integration::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/refunds.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/refunds.rs index c23ddf47acd4..5f2ceb105b99 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/refunds.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/refunds.rs @@ -6,7 +6,6 @@ use zk_evm_1_4_0::{ tracing::{BeforeExecutionData, VmLocalStateData}, vm_state::VmLocalState, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::{PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS}; use zksync_types::{ event::{extract_long_l2_to_l1_messages, extract_published_bytecodes}, @@ -17,9 +16,11 @@ use zksync_utils::{bytecode::bytecode_len_in_bytes, ceil_div_u256, u256_to_h256} use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_4_0::DynTracer, types::tracer::TracerExecutionStatus, + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, L1BatchEnv, Refunds, }, + tracers::dynamic::vm_1_4_0::DynTracer, vm_boojum_integration::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET}, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/result_tracer.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/result_tracer.rs index 2293273228b1..d32200bc177d 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/result_tracer.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/result_tracer.rs @@ -5,15 +5,15 @@ use zk_evm_1_4_0::{ vm_state::{ErrorFlags, VmLocalState}, zkevm_opcode_defs::FatPointer, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use crate::{ interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_0::DynTracer, - types::tracer::TracerExecutionStopReason, ExecutionResult, Halt, TxRevertReason, - VmExecutionMode, VmRevertReason, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStopReason, VmExecutionStopReason}, + ExecutionResult, Halt, TxRevertReason, VmExecutionMode, VmRevertReason, }, + tracers::dynamic::vm_1_4_0::DynTracer, vm_boojum_integration::{ constants::{BOOTLOADER_HEAP_PAGE, RESULT_SUCCESS_FIRST_SLOT}, old_vm::utils::{vm_may_have_ended_inner, VmExecutionResult}, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/traits.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/traits.rs index 767f45c6050a..c7b2b66ee262 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/traits.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/traits.rs @@ -1,10 +1,9 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ - dyn_tracers::vm_1_4_0::DynTracer, + storage::WriteStorage, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_4_0::DynTracer, vm_boojum_integration::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, 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 75c6e89ee7d8..5b6b9b2eca17 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 @@ -10,13 +10,15 @@ use zk_evm_1_4_0::{ STARTING_BASE_PAGE, STARTING_TIMESTAMP, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::{block::L2BlockHasher, Address, L2BlockNumber}; use zksync_utils::h256_to_u256; use crate::{ - interface::{L1BatchEnv, L2Block, SystemEnv}, + interface::{ + storage::{StoragePtr, WriteStorage}, + L1BatchEnv, L2Block, SystemEnv, + }, vm_boojum_integration::{ bootloader_state::BootloaderState, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/utils/fee.rs b/core/lib/multivm/src/versions/vm_boojum_integration/utils/fee.rs index 55c7d0894598..8e785775697a 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/utils/fee.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/utils/fee.rs @@ -3,10 +3,10 @@ use zksync_types::fee_model::L1PeggedBatchFeeModelInput; use zksync_utils::ceil_div; use crate::{ + interface::L1BatchEnv, vm_boojum_integration::{ constants::MAX_GAS_PER_PUBDATA_BYTE, old_vm::utils::eth_price_per_pubdata_byte, }, - vm_latest::L1BatchEnv, }; /// Calculates the amount of gas required to publish one byte of pubdata diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/utils/l2_blocks.rs b/core/lib/multivm/src/versions/vm_boojum_integration/utils/l2_blocks.rs index ec30a86013b9..ff5536ae0b97 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/utils/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/utils/l2_blocks.rs @@ -1,4 +1,3 @@ -use zksync_state::{ReadStorage, StoragePtr}; use zksync_system_constants::{ SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, @@ -9,7 +8,10 @@ use zksync_types::{ }; use zksync_utils::{h256_to_u256, u256_to_h256}; -use crate::interface::{L2Block, L2BlockEnv}; +use crate::interface::{ + storage::{ReadStorage, StoragePtr}, + L2Block, L2BlockEnv, +}; pub(crate) fn get_l2_block_hash_key(block_number: u32) -> StorageKey { let position = h256_to_u256(SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION) diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/utils/logs.rs b/core/lib/multivm/src/versions/vm_boojum_integration/utils/logs.rs index bc15f88c5437..f26cea2f2f53 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/utils/logs.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/utils/logs.rs @@ -1,11 +1,10 @@ use zk_evm_1_3_3::aux_structures::LogQuery; use zk_evm_1_4_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{l2_to_l1_log::L2ToL1Log, StorageLogKind, VmEvent}; use crate::{ glue::GlueInto, - interface::L1BatchEnv, + interface::{storage::WriteStorage, L1BatchEnv}, vm_boojum_integration::{ old_vm::{events::merge_events, history_recorder::HistoryMode}, types::internals::ZkSyncVmState, 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 90cea403084c..1e9f73be5987 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs @@ -1,5 +1,4 @@ use circuit_sequencer_api_1_4_0::sort_storage_access::sort_storage_access_queries; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ event::extract_l2tol1logs_from_l1_messenger, l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, @@ -10,6 +9,7 @@ use zksync_utils::bytecode::CompressedBytecodeInfo; use crate::{ glue::GlueInto, interface::{ + storage::{StoragePtr, WriteStorage}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, diff --git a/core/lib/multivm/src/versions/vm_fast/bytecode.rs b/core/lib/multivm/src/versions/vm_fast/bytecode.rs index 7a16b5940df6..3507b84840e8 100644 --- a/core/lib/multivm/src/versions/vm_fast/bytecode.rs +++ b/core/lib/multivm/src/versions/vm_fast/bytecode.rs @@ -1,5 +1,4 @@ use itertools::Itertools; -use zksync_state::ReadStorage; use zksync_types::H256; use zksync_utils::{ bytecode::{compress_bytecode, hash_bytecode, CompressedBytecodeInfo}, @@ -7,6 +6,7 @@ use zksync_utils::{ }; use super::Vm; +use crate::interface::storage::ReadStorage; impl Vm { /// Checks the last transaction has successfully published compressed bytecodes and returns `true` if there is at least one is still unknown. diff --git a/core/lib/multivm/src/versions/vm_fast/refund.rs b/core/lib/multivm/src/versions/vm_fast/refund.rs index 524a6ca4c3bc..05648acddcfe 100644 --- a/core/lib/multivm/src/versions/vm_fast/refund.rs +++ b/core/lib/multivm/src/versions/vm_fast/refund.rs @@ -1,7 +1,7 @@ use zksync_types::{H256, U256}; use zksync_utils::ceil_div_u256; -use crate::vm_latest::{utils::fee::get_batch_base_fee, L1BatchEnv}; +use crate::{interface::L1BatchEnv, vm_latest::utils::fee::get_batch_base_fee}; pub(crate) fn compute_refund( l1_batch: &L1BatchEnv, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs index af90566671ee..1bfc2f8ff11f 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs @@ -1,14 +1,13 @@ use std::collections::HashSet; use itertools::Itertools; -use zksync_state::ReadStorage; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_test_account::Account; use zksync_types::{Execute, U256}; use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{storage::ReadStorage, TxExecutionMode, VmExecutionMode, VmInterface}, vm_fast::{ tests::{ tester::{TxType, VmTesterBuilder}, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_fast/tests/is_write_initial.rs index 0bbf633254eb..ff97c0389aa9 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/is_write_initial.rs @@ -1,8 +1,7 @@ -use zksync_state::ReadStorage; use zksync_types::get_nonce_key; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{storage::ReadStorage, TxExecutionMode, VmExecutionMode, VmInterface}, vm_fast::tests::{ tester::{Account, TxType, VmTesterBuilder}, utils::read_test_contract, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_fast/tests/l2_blocks.rs index 1f9d0aaff091..6ff5ed426cba 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/l2_blocks.rs @@ -3,7 +3,6 @@ //! The description for each of the tests can be found in the corresponding `.yul` file. //! -use zksync_state::ReadStorage; use zksync_system_constants::REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE; use zksync_types::{ block::{pack_block_info, L2BlockHasher}, @@ -15,7 +14,10 @@ use zksync_types::{ use zksync_utils::{h256_to_u256, u256_to_h256}; use crate::{ - interface::{ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{ + storage::ReadStorage, ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode, + VmInterface, + }, vm_fast::{ tests::tester::{default_l1_batch, VmTesterBuilder}, vm::Vm, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/require_eip712.rs b/core/lib/multivm/src/versions/vm_fast/tests/require_eip712.rs index 7e378a2b62c4..352e709b7043 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/require_eip712.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/require_eip712.rs @@ -1,6 +1,5 @@ use ethabi::Token; use zksync_eth_signer::{EthereumSigner, TransactionParameters}; -use zksync_state::ReadStorage; use zksync_system_constants::L2_BASE_TOKEN_ADDRESS; use zksync_types::{ fee::Fee, l2::L2Tx, transaction_request::TransactionRequest, @@ -10,7 +9,7 @@ use zksync_types::{ use zksync_utils::h256_to_u256; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{storage::ReadStorage, TxExecutionMode, VmExecutionMode, VmInterface}, vm_fast::tests::{ tester::{Account, VmTester, VmTesterBuilder}, utils::read_many_owners_custom_account_contract, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs b/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs index 1e761b30ca62..76357d44cf38 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs @@ -4,9 +4,8 @@ use zksync_types::{web3::keccak256, Execute, H256, U256}; use zksync_utils::h256_to_u256; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{ExecutionResult, TxExecutionMode, VmExecutionMode, VmInterface}, vm_fast::tests::tester::VmTesterBuilder, - vm_latest::ExecutionResult, }; #[test] diff --git a/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs index 9bb013542c7d..562a8a6a6bdd 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs @@ -1,11 +1,11 @@ -use zksync_state::ReadStorage; use zksync_types::{ExecuteTransactionCommon, Transaction, H160, U256}; use super::VmTester; use crate::{ interface::{ - CurrentExecutionState, ExecutionResult, Halt, TxRevertReason, VmExecutionMode, - VmExecutionResultAndLogs, VmInterface, VmInterfaceHistoryEnabled, VmRevertReason, + storage::ReadStorage, CurrentExecutionState, ExecutionResult, Halt, TxRevertReason, + VmExecutionMode, VmExecutionResultAndLogs, VmInterface, VmInterfaceHistoryEnabled, + VmRevertReason, }, vm_fast::Vm, }; diff --git a/core/lib/multivm/src/versions/vm_fast/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_fast/tests/tester/vm_tester.rs index 7715dd0a6d49..efab73aed1df 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/tester/vm_tester.rs @@ -2,7 +2,6 @@ use std::{cell::RefCell, rc::Rc}; use vm2::WorldDiff; use zksync_contracts::BaseSystemContracts; -use zksync_state::{InMemoryStorage, StoragePtr}; use zksync_test_account::{Account, TxType}; use zksync_types::{ block::L2BlockHasher, @@ -17,6 +16,7 @@ use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; use crate::{ interface::{ + storage::{InMemoryStorage, StoragePtr}, L1BatchEnv, L2Block, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmInterface, }, versions::vm_fast::{tests::utils::read_test_contract, vm::Vm}, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/utils.rs b/core/lib/multivm/src/versions/vm_fast/tests/utils.rs index 0a72667bd80e..6b17e66f2616 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/utils.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/utils.rs @@ -6,13 +6,14 @@ use vm2::{instruction_handlers::HeapInterface, HeapId, State}; use zksync_contracts::{ load_contract, read_bytecode, read_zbin_bytecode, BaseSystemContracts, SystemContractCode, }; -use zksync_state::ReadStorage; use zksync_types::{ utils::storage_key_for_standard_token_balance, AccountTreeId, Address, StorageKey, H160, H256, U256, }; use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256}; +use crate::interface::storage::ReadStorage; + pub(crate) static BASE_SYSTEM_CONTRACTS: Lazy = Lazy::new(BaseSystemContracts::load_from_disk); diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index a4dad0b324de..56d98a537bf5 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -6,7 +6,6 @@ use vm2::{ }; use zk_evm_1_5_0::zkevm_opcode_defs::system_params::INITIAL_FRAME_FORMAL_EH_LOCATION; use zksync_contracts::SystemContractCode; -use zksync_state::ReadStorage; use zksync_types::{ event::{ extract_l2tol1logs_from_l1_messenger, extract_long_l2_to_l1_messages, @@ -35,7 +34,10 @@ use super::{ use crate::{ glue::GlueInto, interface::{ - BytecodeCompressionError, Halt, TxRevertReason, VmInterface, VmInterfaceHistoryEnabled, + storage::ReadStorage, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, + ExecutionResult, FinishedL1Batch, Halt, L1BatchEnv, L2BlockEnv, Refunds, SystemEnv, + TxRevertReason, VmExecutionLogs, VmExecutionMode, VmExecutionResultAndLogs, + VmExecutionStatistics, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, VmRevertReason, }, vm_fast::{ @@ -49,9 +51,7 @@ use crate::{ get_vm_hook_params_start_position, get_vm_hook_position, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET, VM_HOOK_PARAMS_COUNT, }, - BootloaderMemory, CurrentExecutionState, ExecutionResult, FinishedL1Batch, L1BatchEnv, - L2BlockEnv, MultiVMSubversion, Refunds, SystemEnv, VmExecutionLogs, VmExecutionMode, - VmExecutionResultAndLogs, VmExecutionStatistics, + MultiVMSubversion, }, }; @@ -575,7 +575,7 @@ impl VmInterface for Vm { } } - fn record_vm_memory_metrics(&self) -> crate::vm_latest::VmMemoryMetrics { + fn record_vm_memory_metrics(&self) -> VmMemoryMetrics { todo!("Unused during batch execution") } diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/bytecode.rs b/core/lib/multivm/src/versions/vm_latest/implementation/bytecode.rs index bda1803067fb..30a428bb834e 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/bytecode.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/bytecode.rs @@ -1,12 +1,18 @@ use itertools::Itertools; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use zksync_utils::{ bytecode::{compress_bytecode, hash_bytecode, CompressedBytecodeInfo}, bytes_to_be_words, }; -use crate::{interface::VmInterface, vm_latest::Vm, HistoryMode}; +use crate::{ + interface::{ + storage::{StoragePtr, WriteStorage}, + VmInterface, + }, + vm_latest::Vm, + HistoryMode, +}; impl Vm { /// Checks the last transaction has successfully published compressed bytecodes and returns `true` if there is at least one is still unknown. diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs b/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs index fe984f88acab..4676fd82d5e2 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs @@ -1,9 +1,9 @@ use zk_evm_1_5_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use crate::{ interface::{ - types::tracer::{TracerExecutionStatus, VmExecutionStopReason}, + storage::WriteStorage, + tracer::{TracerExecutionStatus, VmExecutionStopReason}, VmExecutionMode, VmExecutionResultAndLogs, VmInterface, }, vm_latest::{ diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/gas.rs b/core/lib/multivm/src/versions/vm_latest/implementation/gas.rs index 40cedb60a394..1e33eecf6325 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/gas.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/gas.rs @@ -1,6 +1,8 @@ -use zksync_state::WriteStorage; - -use crate::{interface::VmInterface, vm_latest::vm::Vm, HistoryMode}; +use crate::{ + interface::{storage::WriteStorage, VmInterface}, + vm_latest::vm::Vm, + HistoryMode, +}; impl Vm { pub(crate) fn calculate_computational_gas_used(&self, gas_remaining_before: u32) -> u32 { diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/logs.rs b/core/lib/multivm/src/versions/vm_latest/implementation/logs.rs index b42ce16cd0f2..4417bf7a3ff1 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/logs.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/logs.rs @@ -1,5 +1,4 @@ use zk_evm_1_5_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{ event::extract_l2tol1logs_from_l1_messenger, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, @@ -8,7 +7,7 @@ use zksync_types::{ use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::{storage::WriteStorage, VmExecutionLogs}, vm_latest::{old_vm::utils::precompile_calls_count_after_timestamp, utils::logs, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/snapshots.rs b/core/lib/multivm/src/versions/vm_latest/implementation/snapshots.rs index d226e3af5724..377c4f548b06 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/snapshots.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/snapshots.rs @@ -2,12 +2,14 @@ use std::time::Duration; use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Histogram, Metrics}; use zk_evm_1_5_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; -use crate::vm_latest::{ - old_vm::{history_recorder::HistoryEnabled, oracles::OracleWithHistory}, - types::internals::VmSnapshot, - vm::Vm, +use crate::{ + interface::storage::WriteStorage, + vm_latest::{ + old_vm::{history_recorder::HistoryEnabled, oracles::OracleWithHistory}, + types::internals::VmSnapshot, + vm::Vm, + }, }; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EncodeLabelSet, EncodeLabelValue)] diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/statistics.rs b/core/lib/multivm/src/versions/vm_latest/implementation/statistics.rs index 7fbd6fb2be02..ed61962648a7 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/statistics.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/statistics.rs @@ -1,9 +1,8 @@ use zk_evm_1_5_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{circuit::CircuitStatistic, U256}; use crate::{ - interface::{VmExecutionStatistics, VmMemoryMetrics}, + interface::{storage::WriteStorage, VmExecutionStatistics, VmMemoryMetrics}, vm_latest::vm::Vm, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/tx.rs b/core/lib/multivm/src/versions/vm_latest/implementation/tx.rs index bcfc72934913..98d71efa00f3 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/tx.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/tx.rs @@ -1,8 +1,8 @@ use zk_evm_1_5_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{l1::is_l1_tx_type, Transaction}; use crate::{ + interface::storage::WriteStorage, vm_latest::{ constants::BOOTLOADER_HEAP_PAGE, implementation::bytecode::{bytecode_to_factory_dep, compress_bytecodes}, diff --git a/core/lib/multivm/src/versions/vm_latest/mod.rs b/core/lib/multivm/src/versions/vm_latest/mod.rs index 850215c77460..211c527c3816 100644 --- a/core/lib/multivm/src/versions/vm_latest/mod.rs +++ b/core/lib/multivm/src/versions/vm_latest/mod.rs @@ -16,13 +16,6 @@ pub use self::{ utils::transaction_encoding::TransactionVmExt, vm::Vm, }; -pub use crate::interface::types::{ - inputs::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode}, - outputs::{ - BootloaderMemory, CurrentExecutionState, ExecutionResult, FinishedL1Batch, L2Block, - Refunds, VmExecutionLogs, VmExecutionResultAndLogs, VmExecutionStatistics, VmMemoryMetrics, - }, -}; mod bootloader_state; pub mod constants; diff --git a/core/lib/multivm/src/versions/vm_latest/old_vm/history_recorder.rs b/core/lib/multivm/src/versions/vm_latest/old_vm/history_recorder.rs index 650c0217ca65..e7277f38289d 100644 --- a/core/lib/multivm/src/versions/vm_latest/old_vm/history_recorder.rs +++ b/core/lib/multivm/src/versions/vm_latest/old_vm/history_recorder.rs @@ -5,10 +5,11 @@ use zk_evm_1_5_0::{ vm_state::PrimitiveValue, zkevm_opcode_defs::{self}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{StorageKey, H256, U256}; use zksync_utils::{h256_to_u256, u256_to_h256}; +use crate::interface::storage::{StoragePtr, WriteStorage}; + pub(crate) type MemoryWithHistory = HistoryRecorder; pub(crate) type IntFrameManagerWithHistory = HistoryRecorder, H>; diff --git a/core/lib/multivm/src/versions/vm_latest/old_vm/oracles/decommitter.rs b/core/lib/multivm/src/versions/vm_latest/old_vm/oracles/decommitter.rs index f5cd38779217..0315aa38327d 100644 --- a/core/lib/multivm/src/versions/vm_latest/old_vm/oracles/decommitter.rs +++ b/core/lib/multivm/src/versions/vm_latest/old_vm/oracles/decommitter.rs @@ -9,13 +9,15 @@ use zk_evm_1_5_0::{ ContractCodeSha256, VersionedHashDef, VersionedHashHeader, VersionedHashNormalizedPreimage, }, }; -use zksync_state::{ReadStorage, StoragePtr}; use zksync_types::{H256, U256}; use zksync_utils::{bytes_to_be_words, h256_to_u256, u256_to_h256}; use super::OracleWithHistory; -use crate::vm_latest::old_vm::history_recorder::{ - HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, +use crate::{ + interface::storage::{ReadStorage, StoragePtr}, + vm_latest::old_vm::history_recorder::{ + HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, + }, }; /// The main job of the DecommiterOracle is to implement the DecommittmentProcessor trait - that is diff --git a/core/lib/multivm/src/versions/vm_latest/old_vm/utils.rs b/core/lib/multivm/src/versions/vm_latest/old_vm/utils.rs index f7933b4f603f..c020d1db000a 100644 --- a/core/lib/multivm/src/versions/vm_latest/old_vm/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/old_vm/utils.rs @@ -6,11 +6,11 @@ use zk_evm_1_5_0::{ FatPointer, RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::WriteStorage; use zksync_types::{Address, U256}; -use crate::vm_latest::{ - old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode, +use crate::{ + interface::storage::WriteStorage, + vm_latest::{old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode}, }; #[derive(Debug, Clone)] diff --git a/core/lib/multivm/src/versions/vm_latest/oracles/storage.rs b/core/lib/multivm/src/versions/vm_latest/oracles/storage.rs index 075660ad58aa..9c7b68c1ad51 100644 --- a/core/lib/multivm/src/versions/vm_latest/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_latest/oracles/storage.rs @@ -9,7 +9,6 @@ use zk_evm_1_5_0::{ TRANSIENT_STORAGE_AUX_BYTE, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_eth_balance, writes::{ @@ -22,6 +21,7 @@ use zksync_utils::{h256_to_u256, u256_to_h256}; use crate::{ glue::GlueInto, + interface::storage::{StoragePtr, WriteStorage}, vm_latest::{ old_vm::{ history_recorder::{ @@ -620,11 +620,11 @@ fn get_pubdata_price_bytes(initial_value: U256, final_value: U256, is_initial: b #[cfg(test)] mod tests { - use zksync_state::{InMemoryStorage, StorageView}; use zksync_types::H256; use zksync_utils::h256_to_u256; use super::*; + use crate::interface::storage::{InMemoryStorage, StorageView}; #[test] fn test_get_pubdata_price_bytes() { diff --git a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs index 78136602dae2..f1851eaae425 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs @@ -15,7 +15,7 @@ use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u25 use super::utils::{get_complex_upgrade_abi, read_complex_upgrade}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{L1BatchEnv, TxExecutionMode, VmExecutionMode, VmInterface}, vm_latest::{ constants::{ BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD, @@ -26,7 +26,7 @@ use crate::{ default_l1_batch, get_empty_storage, InMemoryStorageView, VmTesterBuilder, }, tracers::PubdataTracer, - HistoryEnabled, L1BatchEnv, TracerDispatcher, + HistoryEnabled, TracerDispatcher, }, }; diff --git a/core/lib/multivm/src/versions/vm_latest/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_latest/tests/get_used_contracts.rs index 1798c700ea2d..752fd1a9087d 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/get_used_contracts.rs @@ -9,14 +9,13 @@ use zk_evm_1_5_0::{ aux_structures::{DecommittmentQuery, MemoryPage, Timestamp}, zkevm_opcode_defs::{VersionedHashHeader, VersionedHashNormalizedPreimage}, }; -use zksync_state::WriteStorage; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_test_account::Account; use zksync_types::{Execute, U256}; use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{storage::WriteStorage, TxExecutionMode, VmExecutionMode, VmInterface}, vm_latest::{ tests::{ tester::{TxType, VmTesterBuilder}, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_latest/tests/is_write_initial.rs index d5a6679502b5..900f322bc3f3 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/is_write_initial.rs @@ -1,8 +1,7 @@ -use zksync_state::ReadStorage; use zksync_types::get_nonce_key; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{storage::ReadStorage, TxExecutionMode, VmExecutionMode, VmInterface}, vm_latest::{ tests::{ tester::{Account, TxType, VmTesterBuilder}, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs index e62786bb55ef..1f4c36bb25b7 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs @@ -4,7 +4,6 @@ //! use zk_evm_1_5_0::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_system_constants::REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE; use zksync_types::{ block::{pack_block_info, L2BlockHasher}, @@ -16,7 +15,10 @@ use zksync_types::{ use zksync_utils::{h256_to_u256, u256_to_h256}; use crate::{ - interface::{ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{ + storage::WriteStorage, ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode, + VmInterface, + }, vm_latest::{ constants::{ BOOTLOADER_HEAP_PAGE, TX_OPERATOR_L2_BLOCK_INFO_OFFSET, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs b/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs index e0c3ec4157dc..489c762aac4e 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs @@ -1,14 +1,14 @@ use ethabi::Token; use zksync_contracts::{get_loadnext_contract, test_contracts::LoadnextContractExecutionParams}; -use zksync_state::WriteStorage; use zksync_types::{get_nonce_key, Execute, U256}; use crate::{ interface::{ - dyn_tracers::vm_1_5_0::DynTracer, + storage::WriteStorage, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceHistoryEnabled, }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ tests::{ tester::{DeployContractsTx, TransactionTestInfo, TxModifier, TxType, VmTesterBuilder}, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs b/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs index 07b25eb0a8b0..3cd50e0eb917 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs @@ -4,8 +4,8 @@ use zksync_types::{web3::keccak256, Execute, H256, U256}; use zksync_utils::h256_to_u256; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, - vm_latest::{tests::tester::VmTesterBuilder, ExecutionResult, HistoryEnabled}, + interface::{ExecutionResult, TxExecutionMode, VmExecutionMode, VmInterface}, + vm_latest::{tests::tester::VmTesterBuilder, HistoryEnabled}, }; #[test] diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/inner_state.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/inner_state.rs index 2a6fead8cf9c..c0ef52afaa52 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/inner_state.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/inner_state.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; use zk_evm_1_5_0::{aux_structures::Timestamp, vm_state::VmLocalState}; -use zksync_state::WriteStorage; use zksync_types::{StorageKey, StorageValue, U256}; use crate::{ + interface::storage::WriteStorage, vm_latest::{ old_vm::{ event_sink::InMemoryEventSink, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs index 28d853486485..9aba2539e001 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs @@ -1,7 +1,6 @@ use std::marker::PhantomData; use zksync_contracts::BaseSystemContracts; -use zksync_state::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; use zksync_types::{ block::L2BlockHasher, fee_model::BatchFeeInput, @@ -14,6 +13,7 @@ use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; use crate::{ interface::{ + storage::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}, L1BatchEnv, L2Block, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory, VmInterface, }, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs index 80e16248fb2d..020b12a7a6e9 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs @@ -1,6 +1,5 @@ use zk_evm_1_5_0::aux_structures::Timestamp; use zksync_contracts::{deployer_contract, load_sys_contract, read_bytecode}; -use zksync_state::WriteStorage; use zksync_test_account::TxType; use zksync_types::{ ethabi::{Contract, Token}, @@ -15,8 +14,8 @@ use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u25 use super::utils::{get_complex_upgrade_abi, read_test_contract}; use crate::{ interface::{ - ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, VmInterface, - VmInterfaceHistoryEnabled, + storage::WriteStorage, ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, + VmInterface, VmInterfaceHistoryEnabled, }, vm_latest::{ tests::{ diff --git a/core/lib/multivm/src/versions/vm_latest/tests/utils.rs b/core/lib/multivm/src/versions/vm_latest/tests/utils.rs index 2482df0d0e89..cfa7ba1c7e2c 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/utils.rs @@ -3,14 +3,14 @@ use once_cell::sync::Lazy; use zksync_contracts::{ load_contract, read_bytecode, read_zbin_bytecode, BaseSystemContracts, SystemContractCode, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_standard_token_balance, AccountTreeId, Address, StorageKey, H256, U256, }; use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256}; -use crate::vm_latest::{ - tests::tester::InMemoryStorageView, types::internals::ZkSyncVmState, HistoryMode, +use crate::{ + interface::storage::{StoragePtr, WriteStorage}, + vm_latest::{tests::tester::InMemoryStorageView, types::internals::ZkSyncVmState, HistoryMode}, }; pub(crate) static BASE_SYSTEM_CONTRACTS: Lazy = diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/circuits_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/circuits_tracer.rs index 4d5dc0b13273..b3a0e2480dcf 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/circuits_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/circuits_tracer.rs @@ -5,12 +5,15 @@ use zk_evm_1_5_0::{ zk_evm_abstractions::precompiles::PrecompileAddress, zkevm_opcode_defs::{LogOpcode, Opcode, UMAOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::circuit::CircuitCycleStatistic; use super::circuits_capacity::*; use crate::{ - interface::{dyn_tracers::vm_1_5_0::DynTracer, tracer::TracerExecutionStatus}, + interface::{ + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, + }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs b/core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs index 988abec7d156..6a908c2a73ed 100755 --- a/core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs @@ -12,17 +12,16 @@ use zk_evm_1_5_0::{ witness_trace::DummyTracer, zkevm_opcode_defs::{decoding::EncodingModeProduction, Opcode, RetOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use super::PubdataTracer; use crate::{ glue::GlueInto, interface::{ - dyn_tracers::vm_1_5_0::DynTracer, - tracer::{TracerExecutionStopReason, VmExecutionStopReason}, - types::tracer::TracerExecutionStatus, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStatus, TracerExecutionStopReason, VmExecutionStopReason}, Halt, VmExecutionMode, }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ bootloader_state::{utils::apply_l2_block, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/dispatcher.rs b/core/lib/multivm/src/versions/vm_latest/tracers/dispatcher.rs index 7949f73bc20c..3c3ef1173f53 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/dispatcher.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/dispatcher.rs @@ -1,13 +1,13 @@ use zk_evm_1_5_0::tracing::{ AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData, }; -use zksync_state::{StoragePtr, WriteStorage}; use crate::{ interface::{ - dyn_tracers::vm_1_5_0::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ BootloaderState, HistoryMode, SimpleMemory, TracerPointer, VmTracer, ZkSyncVmState, }, 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 ad6b4f238281..edd244a2d082 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 @@ -5,7 +5,6 @@ use zk_evm_1_5_0::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ event::{ extract_bytecode_publication_requests_from_l1_messenger, @@ -18,11 +17,11 @@ use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ interface::{ - dyn_tracers::vm_1_5_0::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - types::inputs::L1BatchEnv, - VmExecutionMode, + L1BatchEnv, VmExecutionMode, }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs b/core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs index 9411b2782a49..78826a16313d 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs @@ -5,15 +5,16 @@ use zk_evm_1_5_0::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{H256, U256}; use zksync_utils::ceil_div_u256; use crate::{ interface::{ - traits::tracers::dyn_tracers::vm_1_5_0::DynTracer, types::tracer::TracerExecutionStatus, + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, L1BatchEnv, Refunds, }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET}, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs index a86210acabfc..6ba00f4a0998 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs @@ -5,16 +5,16 @@ use zk_evm_1_5_0::{ vm_state::{ErrorFlags, VmLocalState}, zkevm_opcode_defs::{FatPointer, Opcode, RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::U256; use crate::{ interface::{ - tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_5_0::DynTracer, - types::tracer::TracerExecutionStopReason, ExecutionResult, Halt, TxRevertReason, - VmExecutionMode, VmRevertReason, + storage::{StoragePtr, WriteStorage}, + tracer::{TracerExecutionStopReason, VmExecutionStopReason}, + ExecutionResult, Halt, TxRevertReason, VmExecutionMode, VmRevertReason, }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ constants::{get_result_success_first_slot, BOOTLOADER_HEAP_PAGE}, old_vm::utils::{vm_may_have_ended_inner, VmExecutionResult}, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/traits.rs b/core/lib/multivm/src/versions/vm_latest/tracers/traits.rs index 5800ff4a3bcf..76dab3dd70a1 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/traits.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/traits.rs @@ -1,10 +1,9 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ - dyn_tracers::vm_1_5_0::DynTracer, + storage::WriteStorage, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, 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 b9ac0bfad229..6f9522572ad8 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 @@ -10,13 +10,15 @@ use zk_evm_1_5_0::{ STARTING_BASE_PAGE, STARTING_TIMESTAMP, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::{block::L2BlockHasher, Address, L2BlockNumber}; use zksync_utils::h256_to_u256; use crate::{ - interface::{L1BatchEnv, L2Block, SystemEnv}, + interface::{ + storage::{StoragePtr, WriteStorage}, + L1BatchEnv, L2Block, SystemEnv, + }, vm_latest::{ bootloader_state::BootloaderState, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_latest/utils/fee.rs b/core/lib/multivm/src/versions/vm_latest/utils/fee.rs index c17e585330c9..666fcca87e12 100644 --- a/core/lib/multivm/src/versions/vm_latest/utils/fee.rs +++ b/core/lib/multivm/src/versions/vm_latest/utils/fee.rs @@ -2,7 +2,7 @@ use zksync_types::fee_model::PubdataIndependentBatchFeeModelInput; use zksync_utils::ceil_div; -use crate::vm_latest::{constants::MAX_GAS_PER_PUBDATA_BYTE, L1BatchEnv}; +use crate::{interface::L1BatchEnv, vm_latest::constants::MAX_GAS_PER_PUBDATA_BYTE}; /// Calculates the base fee and gas per pubdata for the given L1 gas price. pub(crate) fn derive_base_fee_and_gas_per_pubdata( diff --git a/core/lib/multivm/src/versions/vm_latest/utils/l2_blocks.rs b/core/lib/multivm/src/versions/vm_latest/utils/l2_blocks.rs index d3253ffd7fb3..59d3eb0ef0fc 100644 --- a/core/lib/multivm/src/versions/vm_latest/utils/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_latest/utils/l2_blocks.rs @@ -1,4 +1,3 @@ -use zksync_state::{ReadStorage, StoragePtr}; use zksync_system_constants::{ SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, @@ -9,7 +8,10 @@ use zksync_types::{ }; use zksync_utils::{h256_to_u256, u256_to_h256}; -use crate::interface::{L2Block, L2BlockEnv}; +use crate::interface::{ + storage::{ReadStorage, StoragePtr}, + L2Block, L2BlockEnv, +}; pub(crate) fn get_l2_block_hash_key(block_number: u32) -> StorageKey { let position = h256_to_u256(SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION) diff --git a/core/lib/multivm/src/versions/vm_latest/utils/logs.rs b/core/lib/multivm/src/versions/vm_latest/utils/logs.rs index 82e096cd3e7f..67d202657f6b 100644 --- a/core/lib/multivm/src/versions/vm_latest/utils/logs.rs +++ b/core/lib/multivm/src/versions/vm_latest/utils/logs.rs @@ -1,10 +1,9 @@ use zk_evm_1_5_0::aux_structures::{LogQuery, Timestamp}; -use zksync_state::WriteStorage; use zksync_types::{l2_to_l1_log::L2ToL1Log, StorageLogKind, VmEvent}; use crate::{ glue::GlueInto, - interface::L1BatchEnv, + interface::{storage::WriteStorage, L1BatchEnv}, vm_latest::{ old_vm::{events::merge_events, history_recorder::HistoryMode}, types::internals::ZkSyncVmState, diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index f11431f01546..a5e7d8ef8be3 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -1,5 +1,4 @@ use circuit_sequencer_api_1_5_0::sort_storage_access::sort_storage_access_queries; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ event::extract_l2tol1logs_from_l1_messenger, l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, @@ -11,6 +10,7 @@ use zksync_utils::bytecode::CompressedBytecodeInfo; use crate::{ glue::GlueInto, interface::{ + storage::{StoragePtr, WriteStorage}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, diff --git a/core/lib/multivm/src/versions/vm_m5/mod.rs b/core/lib/multivm/src/versions/vm_m5/mod.rs index 946b2e4bf56c..880cac78832e 100644 --- a/core/lib/multivm/src/versions/vm_m5/mod.rs +++ b/core/lib/multivm/src/versions/vm_m5/mod.rs @@ -1,7 +1,6 @@ #![allow(clippy::derive_partial_eq_without_eq)] pub use zk_evm_1_3_1; -pub use zksync_types::vm_trace::VmExecutionTrace; pub use self::{ errors::TxRevertReason, diff --git a/core/lib/multivm/src/versions/vm_m5/storage.rs b/core/lib/multivm/src/versions/vm_m5/storage.rs index deb3501b4160..e65122a0a4b5 100644 --- a/core/lib/multivm/src/versions/vm_m5/storage.rs +++ b/core/lib/multivm/src/versions/vm_m5/storage.rs @@ -1,8 +1,9 @@ use std::{cell::RefCell, collections::HashMap, fmt::Debug, rc::Rc}; -use zksync_state::{ReadStorage, WriteStorage}; use zksync_types::{StorageKey, StorageValue, H256}; +use crate::interface::storage::{ReadStorage, WriteStorage}; + pub trait Storage: Debug { fn get_value(&mut self, key: &StorageKey) -> StorageValue; // Returns the original value. diff --git a/core/lib/multivm/src/versions/vm_m5/vm.rs b/core/lib/multivm/src/versions/vm_m5/vm.rs index 53189dbcfef5..a0d6ea39ceaa 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm.rs @@ -1,7 +1,6 @@ use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use itertools::Itertools; use zk_evm_1_3_1::aux_structures::LogQuery; -use zksync_state::StoragePtr; use zksync_types::{ l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, vm::VmVersion, @@ -12,8 +11,8 @@ use zksync_utils::{bytecode::CompressedBytecodeInfo, h256_to_u256, u256_to_h256} use crate::{ glue::{history_mode::HistoryMode, GlueInto}, interface::{ - BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, - L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, + storage::StoragePtr, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, + FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, }, diff --git a/core/lib/multivm/src/versions/vm_m5/vm_instance.rs b/core/lib/multivm/src/versions/vm_m5/vm_instance.rs index 3f708f3470f2..b97b5e047c66 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm_instance.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm_instance.rs @@ -12,13 +12,13 @@ use zk_evm_1_3_1::{ use zksync_types::{ l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, tx::tx_execution_info::TxExecutionStatus, - vm_trace::VmExecutionTrace, L1BatchNumber, VmEvent, U256, }; use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::VmExecutionLogs, + versions::shared::VmExecutionTrace, vm_m5::{ bootloader_state::BootloaderState, errors::{TxRevertReason, VmRevertReason, VmRevertReasonParsingResult}, 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 dde97cdabdc0..cd2979db5e57 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 @@ -22,7 +22,7 @@ use zksync_utils::{ }; use crate::{ - vm_latest::L1BatchEnv, + interface::L1BatchEnv, vm_m5::{ bootloader_state::BootloaderState, oracles::OracleWithHistory, diff --git a/core/lib/multivm/src/versions/vm_m6/mod.rs b/core/lib/multivm/src/versions/vm_m6/mod.rs index 3aeff47dbdcd..e8e8b53dc249 100644 --- a/core/lib/multivm/src/versions/vm_m6/mod.rs +++ b/core/lib/multivm/src/versions/vm_m6/mod.rs @@ -26,7 +26,6 @@ pub use oracles::storage::StorageOracle; pub use vm::Vm; pub use vm_instance::{VmBlockResult, VmExecutionResult, VmInstance}; pub use zk_evm_1_3_1; -pub use zksync_types::vm_trace::VmExecutionTrace; pub type Word = zksync_types::U256; diff --git a/core/lib/multivm/src/versions/vm_m6/storage.rs b/core/lib/multivm/src/versions/vm_m6/storage.rs index 80f7e0160108..7878c48c3560 100644 --- a/core/lib/multivm/src/versions/vm_m6/storage.rs +++ b/core/lib/multivm/src/versions/vm_m6/storage.rs @@ -1,8 +1,9 @@ use std::{cell::RefCell, collections::HashMap, fmt::Debug, rc::Rc}; -use zksync_state::{ReadStorage, WriteStorage}; use zksync_types::{get_known_code_key, StorageKey, StorageValue, H256}; +use crate::interface::storage::{ReadStorage, WriteStorage}; + pub trait Storage: Debug { /// Returns a value from a given key. If value never existed, returns 0. fn get_value(&mut self, key: &StorageKey) -> StorageValue; diff --git a/core/lib/multivm/src/versions/vm_m6/vm.rs b/core/lib/multivm/src/versions/vm_m6/vm.rs index 634867697a92..3626378ce59e 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm.rs @@ -3,7 +3,6 @@ use std::collections::HashSet; use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use itertools::Itertools; use zk_evm_1_3_1::aux_structures::LogQuery; -use zksync_state::StoragePtr; use zksync_types::{ l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, vm::VmVersion, @@ -17,12 +16,12 @@ use zksync_utils::{ use crate::{ glue::{history_mode::HistoryMode, GlueInto}, interface::{ - BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, - L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, + storage::StoragePtr, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, + FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, }, - tracers::old_tracers::TracerDispatcher, + tracers::old::TracerDispatcher, vm_m6::{events::merge_events, storage::Storage, vm_instance::MultiVMSubversion, VmInstance}, }; diff --git a/core/lib/multivm/src/versions/vm_m6/vm_instance.rs b/core/lib/multivm/src/versions/vm_m6/vm_instance.rs index e7c81dfb2865..5d6a9bf91498 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm_instance.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm_instance.rs @@ -12,13 +12,14 @@ use zk_evm_1_3_1::{ use zksync_types::{ l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, tx::tx_execution_info::TxExecutionStatus, - vm_trace::{Call, VmExecutionTrace, VmTrace}, + vm_trace::Call, L1BatchNumber, VmEvent, H256, U256, }; use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::VmExecutionLogs, + versions::shared::{VmExecutionTrace, VmTrace}, vm_m6::{ bootloader_state::BootloaderState, errors::{TxRevertReason, VmRevertReason, VmRevertReasonParsingResult}, 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 c80eb7df840f..4409a7a89583 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 @@ -25,7 +25,7 @@ use zksync_utils::{ }; use crate::{ - vm_latest::L1BatchEnv, + interface::L1BatchEnv, vm_m6::{ bootloader_state::BootloaderState, history_recorder::HistoryMode, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/bytecode.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/bytecode.rs index 69670f9682b0..b3f578302c07 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/bytecode.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/bytecode.rs @@ -1,12 +1,18 @@ use itertools::Itertools; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use zksync_utils::{ bytecode::{compress_bytecode, hash_bytecode, CompressedBytecodeInfo}, bytes_to_be_words, }; -use crate::{interface::VmInterface, vm_refunds_enhancement::Vm, HistoryMode}; +use crate::{ + interface::{ + storage::{StoragePtr, WriteStorage}, + VmInterface, + }, + vm_refunds_enhancement::Vm, + HistoryMode, +}; impl Vm { /// Checks the last transaction has successfully published compressed bytecodes and returns `true` if there is at least one is still unknown. diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/execution.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/execution.rs index f1de2afd8b76..3f6dd7e0e9e5 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/execution.rs @@ -1,8 +1,8 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use crate::{ interface::{ + storage::WriteStorage, tracer::{TracerExecutionStatus, VmExecutionStopReason}, VmExecutionMode, VmExecutionResultAndLogs, VmInterface, }, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/gas.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/gas.rs index bc5913fdf319..0f4b5c6b6b0e 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/gas.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/gas.rs @@ -1,7 +1,5 @@ -use zksync_state::WriteStorage; - use crate::{ - interface::VmInterface, + interface::{storage::WriteStorage, VmInterface}, vm_refunds_enhancement::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/logs.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/logs.rs index dee06ee6180a..91f502eafd72 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/logs.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/logs.rs @@ -1,5 +1,4 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{ l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, VmEvent, @@ -7,7 +6,7 @@ use zksync_types::{ use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::{storage::WriteStorage, VmExecutionLogs}, vm_refunds_enhancement::{ old_vm::{events::merge_events, utils::precompile_calls_count_after_timestamp}, vm::Vm, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/snapshots.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/snapshots.rs index 56c219fffa4b..c5559eed57c2 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/snapshots.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/snapshots.rs @@ -2,9 +2,9 @@ use std::time::Duration; use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Histogram, Metrics}; use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use crate::{ + interface::storage::WriteStorage, vm_latest::HistoryEnabled, vm_refunds_enhancement::{ old_vm::oracles::OracleWithHistory, types::internals::VmSnapshot, vm::Vm, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/statistics.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/statistics.rs index 1feae1f72e2b..dcda1457b765 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/statistics.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/statistics.rs @@ -1,9 +1,8 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::U256; use crate::{ - interface::{VmExecutionStatistics, VmMemoryMetrics}, + interface::{storage::WriteStorage, VmExecutionStatistics, VmMemoryMetrics}, vm_refunds_enhancement::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/tx.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/tx.rs index 6dc4772d095a..d06e92a3c59f 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/tx.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/implementation/tx.rs @@ -1,8 +1,8 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{l1::is_l1_tx_type, Transaction}; use crate::{ + interface::storage::WriteStorage, vm_refunds_enhancement::{ constants::BOOTLOADER_HEAP_PAGE, implementation::bytecode::{bytecode_to_factory_dep, compress_bytecodes}, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/history_recorder.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/history_recorder.rs index 682a8264faee..8af2c42db957 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/history_recorder.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/history_recorder.rs @@ -5,10 +5,11 @@ use zk_evm_1_3_3::{ vm_state::PrimitiveValue, zkevm_opcode_defs::{self}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{StorageKey, H256, U256}; use zksync_utils::{h256_to_u256, u256_to_h256}; +use crate::interface::storage::{StoragePtr, WriteStorage}; + pub(crate) type MemoryWithHistory = HistoryRecorder; pub(crate) type IntFrameManagerWithHistory = HistoryRecorder, H>; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/oracles/decommitter.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/oracles/decommitter.rs index 9a7addc97e11..ccc8d9052b7e 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/oracles/decommitter.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/oracles/decommitter.rs @@ -6,13 +6,15 @@ use zk_evm_1_3_3::{ DecommittmentQuery, MemoryIndex, MemoryLocation, MemoryPage, MemoryQuery, Timestamp, }, }; -use zksync_state::{ReadStorage, StoragePtr}; use zksync_types::U256; use zksync_utils::{bytecode::bytecode_len_in_words, bytes_to_be_words, u256_to_h256}; use super::OracleWithHistory; -use crate::vm_refunds_enhancement::old_vm::history_recorder::{ - HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, +use crate::{ + interface::storage::{ReadStorage, StoragePtr}, + vm_refunds_enhancement::old_vm::history_recorder::{ + HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, + }, }; /// The main job of the DecommiterOracle is to implement the DecommitmentProcessor trait - that is diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/oracles/storage.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/oracles/storage.rs index bf1871c9b682..526ad357e520 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/oracles/storage.rs @@ -12,7 +12,7 @@ use zk_evm_1_3_3::{ aux_structures::{LogQuery, Timestamp}, }; -use zksync_state::{StoragePtr, WriteStorage}; +use crate::interface::storage::{StoragePtr, WriteStorage}; use zksync_types::utils::storage_key_for_eth_balance; use zksync_types::{ AccountTreeId, Address, StorageKey, StorageLogQuery, StorageLogQueryType, BOOTLOADER_ADDRESS, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/utils.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/utils.rs index 6d7ab7e7a2d9..5838cbb31ea4 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/utils.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/old_vm/utils.rs @@ -6,12 +6,14 @@ use zk_evm_1_3_3::{ FatPointer, RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::WriteStorage; use zksync_system_constants::L1_GAS_PER_PUBDATA_BYTE; use zksync_types::{Address, U256}; -use crate::vm_refunds_enhancement::{ - old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode, +use crate::{ + interface::storage::WriteStorage, + vm_refunds_enhancement::{ + old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode, + }, }; #[derive(Debug, Clone)] diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/oracles/storage.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/oracles/storage.rs index 7b2cd8c61588..a9c5b71e782e 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/oracles/storage.rs @@ -5,7 +5,6 @@ use zk_evm_1_3_3::{ aux_structures::{LogQuery, Timestamp}, zkevm_opcode_defs::system_params::INITIAL_STORAGE_WRITE_PUBDATA_BYTES, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_eth_balance, AccountTreeId, Address, StorageKey, StorageLogKind, BOOTLOADER_ADDRESS, U256, @@ -14,6 +13,7 @@ use zksync_utils::u256_to_h256; use crate::{ glue::GlueInto, + interface::storage::{StoragePtr, WriteStorage}, vm_refunds_enhancement::{ old_vm::{ history_recorder::{ diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/get_used_contracts.rs index a798a3178f5d..8c121db3e43e 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/get_used_contracts.rs @@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet}; use itertools::Itertools; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_test_account::Account; use zksync_types::{Execute, U256}; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/is_write_initial.rs index ca7ff595e193..d7b961330002 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/is_write_initial.rs @@ -1,4 +1,4 @@ -use zksync_state::ReadStorage; +use crate::interface::storage::ReadStorage; use zksync_types::get_nonce_key; use crate::interface::{TxExecutionMode, VmExecutionMode}; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/l2_blocks.rs index 9130b6627ca2..269b6cf396c6 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/l2_blocks.rs @@ -12,7 +12,7 @@ use crate::vm_refunds_enhancement::tests::tester::VmTesterBuilder; use crate::vm_refunds_enhancement::utils::l2_blocks::get_l2_block_hash_key; use crate::vm_refunds_enhancement::{HistoryEnabled, HistoryMode, Vm}; use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::{ReadStorage, WriteStorage}; +use crate::interface::storage::{ReadStorage, WriteStorage}; use zksync_system_constants::{ CURRENT_VIRTUAL_BLOCK_INFO_POSITION, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE, }; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/rollbacks.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/rollbacks.rs index 84c5a61c10df..8107ddcdabf6 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/rollbacks.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/rollbacks.rs @@ -3,7 +3,7 @@ use ethabi::Token; use zksync_contracts::get_loadnext_contract; use zksync_contracts::test_contracts::LoadnextContractExecutionParams; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{get_nonce_key, Execute, U256}; use crate::interface::{TxExecutionMode, VmExecutionMode}; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/tester/inner_state.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/tester/inner_state.rs index 5af50ee0d91f..3158fc494441 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/tester/inner_state.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/tester/inner_state.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use zk_evm_1_3_3::aux_structures::Timestamp; use zk_evm_1_3_3::vm_state::VmLocalState; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{StorageKey, StorageLogQuery, StorageValue, U256}; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/tester/vm_tester.rs index 9c2478a4dbe7..800af517ed3c 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/tester/vm_tester.rs @@ -1,5 +1,5 @@ use zksync_contracts::BaseSystemContracts; -use zksync_state::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; +use crate::interface::storage::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; use zksync_types::block::legacy_miniblock_hash; use zksync_types::helpers::unix_timestamp_ms; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/upgrade.rs index 9a7eaa084681..cbbec9a83d5e 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/upgrade.rs @@ -11,7 +11,7 @@ use zksync_types::{ use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256}; use zksync_contracts::{deployer_contract, load_contract, load_sys_contract, read_bytecode}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_test_account::TxType; use crate::interface::{ExecutionResult, Halt, TxExecutionMode, VmExecutionMode}; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/utils.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/utils.rs index 3a936f95681d..ffbb9d892607 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/utils.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tests/utils.rs @@ -5,7 +5,7 @@ use crate::vm_refunds_enhancement::tests::tester::InMemoryStorageView; use zksync_contracts::{ load_contract, read_bytecode, read_zbin_bytecode, BaseSystemContracts, SystemContractCode, }; -use zksync_state::{StoragePtr, WriteStorage}; +use crate::interface::storage::{StoragePtr, WriteStorage}; use zksync_types::utils::storage_key_for_standard_token_balance; use zksync_types::{AccountTreeId, Address, StorageKey, H256, U256}; use zksync_utils::bytecode::hash_bytecode; diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/default_tracers.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/default_tracers.rs index b5787a6ec47f..595f1851f82a 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/default_tracers.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/default_tracers.rs @@ -9,14 +9,14 @@ use zk_evm_1_3_3::{ witness_trace::DummyTracer, zkevm_opcode_defs::{decoding::EncodingModeProduction, Opcode, RetOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use crate::{ interface::{ - dyn_tracers::vm_1_3_3::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason, VmExecutionStopReason}, Halt, VmExecutionMode, }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_refunds_enhancement::{ bootloader_state::{utils::apply_l2_block, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/dispatcher.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/dispatcher.rs index 2392c3e51afa..7d3f508383c5 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/dispatcher.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/dispatcher.rs @@ -1,13 +1,13 @@ use zk_evm_1_3_3::tracing::{ AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData, }; -use zksync_state::{StoragePtr, WriteStorage}; use crate::{ interface::{ - dyn_tracers::vm_1_3_3::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_refunds_enhancement::{ BootloaderState, HistoryMode, SimpleMemory, TracerPointer, VmTracer, ZkSyncVmState, }, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/refunds.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/refunds.rs index ca99e862b2d8..cb56acd7e43c 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/refunds.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/refunds.rs @@ -4,7 +4,6 @@ use zk_evm_1_3_3::{ tracing::{BeforeExecutionData, VmLocalStateData}, vm_state::VmLocalState, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::{PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS}; use zksync_types::{ event::{extract_long_l2_to_l1_messages, extract_published_bytecodes}, @@ -15,8 +14,11 @@ use zksync_utils::{bytecode::bytecode_len_in_bytes, ceil_div_u256, u256_to_h256} use crate::{ interface::{ - dyn_tracers::vm_1_3_3::DynTracer, tracer::TracerExecutionStatus, L1BatchEnv, Refunds, + storage::{StoragePtr, WriteStorage}, + tracer::TracerExecutionStatus, + L1BatchEnv, Refunds, }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_refunds_enhancement::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET}, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/result_tracer.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/result_tracer.rs index 22cf08c8ef93..cc8dc93b5f9a 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/result_tracer.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/result_tracer.rs @@ -3,15 +3,15 @@ use zk_evm_1_3_3::{ vm_state::{ErrorFlags, VmLocalState}, zkevm_opcode_defs::FatPointer, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use crate::{ interface::{ - dyn_tracers::vm_1_3_3::DynTracer, + storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStopReason, VmExecutionStopReason}, ExecutionResult, Halt, TxRevertReason, VmExecutionMode, VmRevertReason, }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_refunds_enhancement::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, RESULT_SUCCESS_FIRST_SLOT}, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/traits.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/traits.rs index b54819148fad..a05043a6d448 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/traits.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/tracers/traits.rs @@ -1,10 +1,9 @@ -use zksync_state::WriteStorage; - use crate::{ interface::{ - dyn_tracers::vm_1_3_3::DynTracer, + storage::WriteStorage, tracer::{TracerExecutionStatus, VmExecutionStopReason}, }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_refunds_enhancement::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, 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 58c352c4c6cb..22f92891e40a 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 @@ -10,13 +10,15 @@ use zk_evm_1_3_3::{ STARTING_BASE_PAGE, STARTING_TIMESTAMP, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::{block::L2BlockHasher, Address, L2BlockNumber}; use zksync_utils::h256_to_u256; use crate::{ - interface::{L1BatchEnv, L2Block, SystemEnv}, + interface::{ + storage::{StoragePtr, WriteStorage}, + L1BatchEnv, L2Block, SystemEnv, + }, vm_refunds_enhancement::{ bootloader_state::BootloaderState, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/utils/fee.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/utils/fee.rs index a2fccb596309..f7203b57b4c4 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/utils/fee.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/utils/fee.rs @@ -3,7 +3,7 @@ use zksync_types::fee_model::L1PeggedBatchFeeModelInput; use zksync_utils::ceil_div; use crate::{ - vm_latest::L1BatchEnv, + interface::L1BatchEnv, vm_refunds_enhancement::{ constants::MAX_GAS_PER_PUBDATA_BYTE, old_vm::utils::eth_price_per_pubdata_byte, }, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/utils/l2_blocks.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/utils/l2_blocks.rs index ec30a86013b9..ff5536ae0b97 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/utils/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/utils/l2_blocks.rs @@ -1,4 +1,3 @@ -use zksync_state::{ReadStorage, StoragePtr}; use zksync_system_constants::{ SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, @@ -9,7 +8,10 @@ use zksync_types::{ }; use zksync_utils::{h256_to_u256, u256_to_h256}; -use crate::interface::{L2Block, L2BlockEnv}; +use crate::interface::{ + storage::{ReadStorage, StoragePtr}, + L2Block, L2BlockEnv, +}; pub(crate) fn get_l2_block_hash_key(block_number: u32) -> StorageKey { let position = h256_to_u256(SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION) 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 c580b84e2022..599387884666 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs @@ -1,11 +1,11 @@ use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; use zksync_utils::bytecode::CompressedBytecodeInfo; use crate::{ glue::GlueInto, interface::{ + storage::{StoragePtr, WriteStorage}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/bytecode.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/bytecode.rs index 570581740ef6..7c1b15027b4a 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/bytecode.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/bytecode.rs @@ -1,12 +1,18 @@ use itertools::Itertools; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use zksync_utils::{ bytecode::{compress_bytecode, hash_bytecode, CompressedBytecodeInfo}, bytes_to_be_words, }; -use crate::{interface::VmInterface, vm_virtual_blocks::Vm, HistoryMode}; +use crate::{ + interface::{ + storage::{StoragePtr, WriteStorage}, + VmInterface, + }, + vm_virtual_blocks::Vm, + HistoryMode, +}; impl Vm { /// Checks the last transaction has successfully published compressed bytecodes and returns `true` if there is at least one is still unknown. diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/execution.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/execution.rs index 78a817f647ce..aafcca3821be 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/execution.rs @@ -1,8 +1,8 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use crate::{ interface::{ + storage::WriteStorage, tracer::{TracerExecutionStopReason, VmExecutionStopReason}, VmExecutionMode, VmExecutionResultAndLogs, VmInterface, }, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/gas.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/gas.rs index ea8df4cd7e18..28f0ec6df4a9 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/gas.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/gas.rs @@ -1,7 +1,5 @@ -use zksync_state::WriteStorage; - use crate::{ - interface::VmInterface, + interface::{storage::WriteStorage, VmInterface}, vm_virtual_blocks::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/logs.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/logs.rs index 6c2b801c1d0f..8b60953c8341 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/logs.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/logs.rs @@ -1,5 +1,4 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{ l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, VmEvent, @@ -7,7 +6,7 @@ use zksync_types::{ use crate::{ glue::GlueInto, - interface::types::outputs::VmExecutionLogs, + interface::{storage::WriteStorage, VmExecutionLogs}, vm_virtual_blocks::{ old_vm::{events::merge_events, utils::precompile_calls_count_after_timestamp}, vm::Vm, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/snapshots.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/snapshots.rs index 2b653333a5c1..70d58b8315b8 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/snapshots.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/snapshots.rs @@ -2,9 +2,9 @@ use std::time::Duration; use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Histogram, Metrics}; use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use crate::{ + interface::storage::WriteStorage, vm_latest::HistoryEnabled, vm_virtual_blocks::{old_vm::oracles::OracleWithHistory, types::internals::VmSnapshot, vm::Vm}, }; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/statistics.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/statistics.rs index 4a15b07530fa..d082085a1550 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/statistics.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/statistics.rs @@ -1,9 +1,8 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::U256; use crate::{ - interface::{VmExecutionStatistics, VmMemoryMetrics}, + interface::{storage::WriteStorage, VmExecutionStatistics, VmMemoryMetrics}, vm_virtual_blocks::{tracers::DefaultExecutionTracer, vm::Vm}, HistoryMode, }; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/tx.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/tx.rs index 0f4705a633f2..ddb7267eab7a 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/tx.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/implementation/tx.rs @@ -1,8 +1,8 @@ use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::WriteStorage; use zksync_types::{l1::is_l1_tx_type, Transaction}; use crate::{ + interface::storage::WriteStorage, vm_virtual_blocks::{ constants::BOOTLOADER_HEAP_PAGE, implementation::bytecode::{bytecode_to_factory_dep, compress_bytecodes}, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/history_recorder.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/history_recorder.rs index 664de3a90037..cbd4dc0ed738 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/history_recorder.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/history_recorder.rs @@ -5,10 +5,11 @@ use zk_evm_1_3_3::{ vm_state::PrimitiveValue, zkevm_opcode_defs::{self}, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{StorageKey, H256, U256}; use zksync_utils::{h256_to_u256, u256_to_h256}; +use crate::interface::storage::{StoragePtr, WriteStorage}; + pub(crate) type MemoryWithHistory = HistoryRecorder; pub(crate) type IntFrameManagerWithHistory = HistoryRecorder, H>; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/oracles/decommitter.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/oracles/decommitter.rs index f01394cebb52..3c8d72b0b33a 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/oracles/decommitter.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/oracles/decommitter.rs @@ -6,13 +6,15 @@ use zk_evm_1_3_3::{ DecommittmentQuery, MemoryIndex, MemoryLocation, MemoryPage, MemoryQuery, Timestamp, }, }; -use zksync_state::{ReadStorage, StoragePtr}; use zksync_types::U256; use zksync_utils::{bytecode::bytecode_len_in_words, bytes_to_be_words, u256_to_h256}; use super::OracleWithHistory; -use crate::vm_virtual_blocks::old_vm::history_recorder::{ - HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, +use crate::{ + interface::storage::{ReadStorage, StoragePtr}, + vm_virtual_blocks::old_vm::history_recorder::{ + HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory, + }, }; /// The main job of the DecommiterOracle is to implement the DecommitmentProcessor trait - that is diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/oracles/storage.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/oracles/storage.rs index 682814b8d512..defbad70f1a9 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/oracles/storage.rs @@ -5,7 +5,6 @@ use zk_evm_1_3_3::{ aux_structures::{LogQuery, Timestamp}, zkevm_opcode_defs::system_params::INITIAL_STORAGE_WRITE_PUBDATA_BYTES, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{ utils::storage_key_for_eth_balance, AccountTreeId, Address, StorageKey, StorageLogKind, BOOTLOADER_ADDRESS, U256, @@ -15,6 +14,7 @@ use zksync_utils::u256_to_h256; use super::OracleWithHistory; use crate::{ glue::GlueInto, + interface::storage::{StoragePtr, WriteStorage}, vm_virtual_blocks::{ old_vm::history_recorder::{ AppDataFrameManagerWithHistory, HashMapHistoryEvent, HistoryEnabled, HistoryMode, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/utils.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/utils.rs index 834b9988f693..07757bc5a3ef 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/utils.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/old_vm/utils.rs @@ -6,12 +6,14 @@ use zk_evm_1_3_3::{ FatPointer, RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER, }, }; -use zksync_state::WriteStorage; use zksync_system_constants::L1_GAS_PER_PUBDATA_BYTE; use zksync_types::{Address, U256}; -use crate::vm_virtual_blocks::{ - old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode, +use crate::{ + interface::storage::WriteStorage, + vm_virtual_blocks::{ + old_vm::memory::SimpleMemory, types::internals::ZkSyncVmState, HistoryMode, + }, }; #[derive(Debug, Clone)] diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/get_used_contracts.rs index 496b7a847eda..06d8191310bc 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/get_used_contracts.rs @@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet}; use itertools::Itertools; use crate::HistoryMode; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_test_account::Account; use zksync_types::{Execute, U256}; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/is_write_initial.rs index 8ac932687744..2c7ef4a8d11a 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/is_write_initial.rs @@ -1,4 +1,4 @@ -use zksync_state::ReadStorage; +use crate::interface::storage::ReadStorage; use zksync_types::get_nonce_key; use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l2_blocks.rs index aebb389ebaf3..cba534deeaf6 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l2_blocks.rs @@ -16,7 +16,7 @@ use crate::vm_virtual_blocks::utils::l2_blocks::get_l2_block_hash_key; use crate::vm_virtual_blocks::Vm; use crate::HistoryMode; use zk_evm_1_3_3::aux_structures::Timestamp; -use zksync_state::{ReadStorage, WriteStorage}; +use crate::interface::storage::{ReadStorage, WriteStorage}; use zksync_system_constants::{ CURRENT_VIRTUAL_BLOCK_INFO_POSITION, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE, }; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/inner_state.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/inner_state.rs index 83ad0b9044b5..a5c0db9468b0 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/inner_state.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/inner_state.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use zk_evm_1_3_3::aux_structures::Timestamp; use zk_evm_1_3_3::vm_state::VmLocalState; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_types::{StorageKey, StorageLogQuery, StorageValue, U256}; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/vm_tester.rs index adae9a4cc8db..9fe0635eba39 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/vm_tester.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; use zksync_contracts::BaseSystemContracts; -use zksync_state::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; +use crate::interface::storage::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; use crate::HistoryMode; use zksync_types::block::legacy_miniblock_hash; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/upgrade.rs index 7ba8ec6dfc0c..8b3fa0ea2910 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/upgrade.rs @@ -11,7 +11,7 @@ use zksync_types::{ use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256}; use zksync_contracts::{deployer_contract, load_contract, load_sys_contract, read_bytecode}; -use zksync_state::WriteStorage; +use crate::interface::storage::WriteStorage; use zksync_test_account::TxType; use crate::interface::{ diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/utils.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/utils.rs index ca04d2fedf55..e3db232ffceb 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/utils.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/utils.rs @@ -5,7 +5,7 @@ use crate::vm_virtual_blocks::tests::tester::InMemoryStorageView; use zksync_contracts::{ load_contract, read_bytecode, read_zbin_bytecode, BaseSystemContracts, SystemContractCode, }; -use zksync_state::{StoragePtr, WriteStorage}; +use crate::interface::storage::{StoragePtr, WriteStorage}; use zksync_types::utils::storage_key_for_standard_token_balance; use zksync_types::{AccountTreeId, Address, StorageKey, H256, U256}; use zksync_utils::bytecode::hash_bytecode; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/default_tracers.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/default_tracers.rs index 1e7780edda24..d1a4a0932ffa 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/default_tracers.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/default_tracers.rs @@ -12,10 +12,14 @@ use zk_evm_1_3_3::{ witness_trace::DummyTracer, zkevm_opcode_defs::{Opcode, RetOpcode}, }; -use zksync_state::{StoragePtr, WriteStorage}; use crate::{ - interface::{dyn_tracers::vm_1_3_3::DynTracer, tracer::VmExecutionStopReason, VmExecutionMode}, + interface::{ + storage::{StoragePtr, WriteStorage}, + tracer::VmExecutionStopReason, + VmExecutionMode, + }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_virtual_blocks::{ bootloader_state::{utils::apply_l2_block, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/dispatcher.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/dispatcher.rs index b1b5ef418eeb..efd91e3d3c89 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/dispatcher.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/dispatcher.rs @@ -1,12 +1,14 @@ use zk_evm_1_3_3::tracing::{ AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData, }; -use zksync_state::{StoragePtr, WriteStorage}; use crate::{ interface::{ - dyn_tracers::vm_1_3_3::DynTracer, tracer::VmExecutionStopReason, VmExecutionResultAndLogs, + storage::{StoragePtr, WriteStorage}, + tracer::VmExecutionStopReason, + VmExecutionResultAndLogs, }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_virtual_blocks::{ BootloaderState, ExecutionEndTracer, ExecutionProcessing, HistoryMode, SimpleMemory, TracerPointer, VmTracer, ZkSyncVmState, 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 7b687536da59..b97d86889c86 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 @@ -7,7 +7,6 @@ use zk_evm_1_3_3::{ tracing::{BeforeExecutionData, VmLocalStateData}, vm_state::VmLocalState, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::{PUBLISH_BYTECODE_OVERHEAD, SYSTEM_CONTEXT_ADDRESS}; use zksync_types::{ event::{extract_long_l2_to_l1_messages, extract_published_bytecodes}, @@ -17,7 +16,11 @@ use zksync_types::{ use zksync_utils::{bytecode::bytecode_len_in_bytes, ceil_div_u256, u256_to_h256}; use crate::{ - interface::{dyn_tracers::vm_1_3_3::DynTracer, L1BatchEnv, Refunds, VmExecutionResultAndLogs}, + interface::{ + storage::{StoragePtr, WriteStorage}, + L1BatchEnv, Refunds, VmExecutionResultAndLogs, + }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_virtual_blocks::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET}, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/result_tracer.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/result_tracer.rs index 3ba396fd0c4c..5c0e371a9bc4 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/result_tracer.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/result_tracer.rs @@ -3,14 +3,16 @@ use zk_evm_1_3_3::{ vm_state::{ErrorFlags, VmLocalState}, zkevm_opcode_defs::FatPointer, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::U256; use crate::{ interface::{ - dyn_tracers::vm_1_3_3::DynTracer, tracer::VmExecutionStopReason, ExecutionResult, Halt, - TxRevertReason, VmExecutionMode, VmExecutionResultAndLogs, VmRevertReason, + storage::{StoragePtr, WriteStorage}, + tracer::VmExecutionStopReason, + ExecutionResult, Halt, TxRevertReason, VmExecutionMode, VmExecutionResultAndLogs, + VmRevertReason, }, + tracers::dynamic::vm_1_3_3::DynTracer, vm_virtual_blocks::{ bootloader_state::BootloaderState, constants::{BOOTLOADER_HEAP_PAGE, RESULT_SUCCESS_FIRST_SLOT}, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/traits.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/traits.rs index ed6ad67b5dcd..aa3b78ed7c5b 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/traits.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/traits.rs @@ -1,9 +1,6 @@ -use zksync_state::WriteStorage; - use crate::{ - interface::{ - dyn_tracers::vm_1_3_3::DynTracer, tracer::VmExecutionStopReason, VmExecutionResultAndLogs, - }, + interface::{storage::WriteStorage, tracer::VmExecutionStopReason, VmExecutionResultAndLogs}, + tracers::dynamic::vm_1_3_3::DynTracer, vm_virtual_blocks::{ bootloader_state::BootloaderState, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, 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 fc28e49de503..d26acc4e9301 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 @@ -10,13 +10,15 @@ use zk_evm_1_3_3::{ STARTING_BASE_PAGE, STARTING_TIMESTAMP, }, }; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::{block::L2BlockHasher, Address, L2BlockNumber}; use zksync_utils::h256_to_u256; use crate::{ - interface::{L1BatchEnv, L2Block, SystemEnv}, + interface::{ + storage::{StoragePtr, WriteStorage}, + L1BatchEnv, L2Block, SystemEnv, + }, vm_virtual_blocks::{ bootloader_state::BootloaderState, constants::BOOTLOADER_HEAP_PAGE, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/utils/fee.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/utils/fee.rs index 14133553b04b..a53951a851e1 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/utils/fee.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/utils/fee.rs @@ -3,7 +3,7 @@ use zksync_types::fee_model::L1PeggedBatchFeeModelInput; use zksync_utils::ceil_div; use crate::{ - vm_latest::L1BatchEnv, + interface::L1BatchEnv, vm_virtual_blocks::{ constants::MAX_GAS_PER_PUBDATA_BYTE, old_vm::utils::eth_price_per_pubdata_byte, }, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/utils/l2_blocks.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/utils/l2_blocks.rs index ec30a86013b9..ff5536ae0b97 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/utils/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/utils/l2_blocks.rs @@ -1,4 +1,3 @@ -use zksync_state::{ReadStorage, StoragePtr}; use zksync_system_constants::{ SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, @@ -9,7 +8,10 @@ use zksync_types::{ }; use zksync_utils::{h256_to_u256, u256_to_h256}; -use crate::interface::{L2Block, L2BlockEnv}; +use crate::interface::{ + storage::{ReadStorage, StoragePtr}, + L2Block, L2BlockEnv, +}; pub(crate) fn get_l2_block_hash_key(block_number: u32) -> StorageKey { let position = h256_to_u256(SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION) 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 a7cef17591ad..9d234ec117ac 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs @@ -1,11 +1,11 @@ use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; -use zksync_state::{StoragePtr, WriteStorage}; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; use zksync_utils::bytecode::CompressedBytecodeInfo; use crate::{ glue::GlueInto, interface::{ + storage::{StoragePtr, WriteStorage}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index c8a7ce837991..0cc8916a104b 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -1,10 +1,10 @@ -use zksync_state::{ImmutableStorageView, ReadStorage, StoragePtr, StorageView}; use zksync_types::vm::{FastVmMode, VmVersion}; use zksync_utils::bytecode::CompressedBytecodeInfo; use crate::{ glue::history_mode::HistoryMode, interface::{ + storage::{ImmutableStorageView, ReadStorage, StoragePtr, StorageView}, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, diff --git a/core/lib/prover_interface/Cargo.toml b/core/lib/prover_interface/Cargo.toml index 89e402b27759..8c73c2c6ac38 100644 --- a/core/lib/prover_interface/Cargo.toml +++ b/core/lib/prover_interface/Cargo.toml @@ -14,7 +14,6 @@ categories.workspace = true zksync_multivm.workspace = true zksync_object_store.workspace = true zksync_types.workspace = true -zksync_state.workspace = true # We can use the newest api to send proofs to L1. circuit_sequencer_api_1_5_0.workspace = true diff --git a/core/lib/prover_interface/src/inputs.rs b/core/lib/prover_interface/src/inputs.rs index 8f2403d3369a..22a20223c8b4 100644 --- a/core/lib/prover_interface/src/inputs.rs +++ b/core/lib/prover_interface/src/inputs.rs @@ -4,7 +4,6 @@ use serde::{Deserialize, Serialize}; use serde_with::{serde_as, Bytes}; use zksync_multivm::interface::{L1BatchEnv, SystemEnv}; use zksync_object_store::{serialize_using_bincode, Bucket, StoredObject}; -pub use zksync_state::WitnessStorage; use zksync_types::{ basic_fri_types::Eip4844Blobs, block::L2BlockExecutionData, witness_block_state::WitnessStorageState, L1BatchNumber, ProtocolVersionId, H256, U256, diff --git a/core/lib/state/Cargo.toml b/core/lib/state/Cargo.toml index 119bc800b800..dd56368f3d2e 100644 --- a/core/lib/state/Cargo.toml +++ b/core/lib/state/Cargo.toml @@ -17,6 +17,7 @@ zksync_types.workspace = true zksync_utils.workspace = true zksync_shared_metrics.workspace = true zksync_storage.workspace = true +zksync_vm_interface.workspace = true anyhow.workspace = true async-trait.workspace = true diff --git a/core/lib/state/src/lib.rs b/core/lib/state/src/lib.rs index 7041b9bc2a6f..c386426d0669 100644 --- a/core/lib/state/src/lib.rs +++ b/core/lib/state/src/lib.rs @@ -9,20 +9,11 @@ clippy::doc_markdown // frequent false positive: RocksDB )] -use std::{cell::RefCell, collections::HashMap, fmt, rc::Rc}; - -use zksync_types::{ - get_known_code_key, - storage::{StorageKey, StorageValue}, - H256, -}; +pub use zksync_vm_interface::storage as interface; pub use self::{ cache::sequential_cache::SequentialCache, catchup::{AsyncCatchupTask, RocksdbCell}, - // Note, that `test_infra` of the bootloader tests relies on this value to be exposed - in_memory::InMemoryStorage, - in_memory::IN_MEMORY_STORAGE_DEFAULT_NETWORK_ID, postgres::{PostgresStorage, PostgresStorageCaches, PostgresStorageCachesTask}, rocksdb::{ RocksdbStorage, RocksdbStorageBuilder, RocksdbStorageOptions, StateKeeperColumnFamily, @@ -32,81 +23,13 @@ pub use self::{ BatchDiff, OwnedPostgresStorage, OwnedStorage, PgOrRocksdbStorage, ReadStorageFactory, RocksdbWithMemory, }, - storage_view::{ImmutableStorageView, StorageView, StorageViewCache, StorageViewMetrics}, - witness::WitnessStorage, }; mod cache; mod catchup; -mod in_memory; mod postgres; mod rocksdb; mod shadow_storage; mod storage_factory; -mod storage_view; #[cfg(test)] mod test_utils; -mod witness; - -/// Functionality to read from the VM storage. -pub trait ReadStorage: fmt::Debug { - /// Read value of the key. - fn read_value(&mut self, key: &StorageKey) -> StorageValue; - - /// Checks whether a write to this storage at the specified `key` would be an initial write. - /// Roughly speaking, this is the case when the storage doesn't contain `key`, although - /// in case of mutable storage, the caveats apply (a write to a key that is present - /// in the storage but was not committed is still an initial write). - fn is_write_initial(&mut self, key: &StorageKey) -> bool; - - /// Load the factory dependency code by its hash. - fn load_factory_dep(&mut self, hash: H256) -> Option>; - - /// Returns whether a bytecode hash is "known" to the system. - fn is_bytecode_known(&mut self, bytecode_hash: &H256) -> bool { - let code_key = get_known_code_key(bytecode_hash); - self.read_value(&code_key) != H256::zero() - } - - /// Retrieves the enumeration index for a given `key`. - fn get_enumeration_index(&mut self, key: &StorageKey) -> Option; -} - -/// Functionality to write to the VM storage in a batch. -/// -/// So far, this trait is implemented only for [`StorageView`]. -pub trait WriteStorage: ReadStorage { - /// Returns the map with the key–value pairs read by this batch. - fn read_storage_keys(&self) -> &HashMap; - - /// Sets the new value under a given key and returns the previous value. - fn set_value(&mut self, key: StorageKey, value: StorageValue) -> StorageValue; - - /// Returns a map with the key–value pairs updated by this batch. - fn modified_storage_keys(&self) -> &HashMap; - - /// Returns the number of read / write ops for which the value was read from the underlying - /// storage. - fn missed_storage_invocations(&self) -> usize; -} - -/// Smart pointer to [`WriteStorage`]. -pub type StoragePtr = Rc>; - -impl ReadStorage for StoragePtr { - fn read_value(&mut self, key: &StorageKey) -> StorageValue { - self.borrow_mut().read_value(key) - } - - fn is_write_initial(&mut self, key: &StorageKey) -> bool { - self.borrow_mut().is_write_initial(key) - } - - fn load_factory_dep(&mut self, hash: H256) -> Option> { - self.borrow_mut().load_factory_dep(hash) - } - - fn get_enumeration_index(&mut self, key: &StorageKey) -> Option { - self.borrow_mut().get_enumeration_index(key) - } -} diff --git a/core/lib/state/src/postgres/mod.rs b/core/lib/state/src/postgres/mod.rs index 9d7f6c3f71fa..67866634ee4b 100644 --- a/core/lib/state/src/postgres/mod.rs +++ b/core/lib/state/src/postgres/mod.rs @@ -15,12 +15,10 @@ use tokio::{ }; use zksync_dal::{Connection, ConnectionPool, Core, CoreDal}; use zksync_types::{L1BatchNumber, L2BlockNumber, StorageKey, StorageValue, H256}; +use zksync_vm_interface::storage::ReadStorage; use self::metrics::{Method, ValuesUpdateStage, CACHE_METRICS, STORAGE_METRICS}; -use crate::{ - cache::{lru_cache::LruCache, CacheValue}, - ReadStorage, -}; +use crate::cache::{lru_cache::LruCache, CacheValue}; mod metrics; #[cfg(test)] diff --git a/core/lib/state/src/rocksdb/mod.rs b/core/lib/state/src/rocksdb/mod.rs index 61a1eb362be1..f866a22a3e52 100644 --- a/core/lib/state/src/rocksdb/mod.rs +++ b/core/lib/state/src/rocksdb/mod.rs @@ -33,11 +33,11 @@ use tokio::sync::watch; use zksync_dal::{Connection, Core, CoreDal, DalError}; use zksync_storage::{db::NamedColumnFamily, RocksDB, RocksDBOptions}; use zksync_types::{L1BatchNumber, StorageKey, StorageValue, H256}; +use zksync_vm_interface::storage::ReadStorage; #[cfg(test)] use self::tests::RocksdbStorageEventListener; use self::{metrics::METRICS, recovery::Strategy}; -use crate::{InMemoryStorage, ReadStorage}; mod metrics; mod recovery; @@ -154,11 +154,17 @@ impl RocksdbStorageOptions { } } +#[derive(Debug, Clone, Default)] +struct PendingPatch { + state: HashMap, + factory_deps: HashMap>, +} + /// [`ReadStorage`] implementation backed by RocksDB. #[derive(Debug, Clone)] pub struct RocksdbStorage { db: RocksDB, - pending_patch: InMemoryStorage, + pending_patch: PendingPatch, /// Test-only listeners to events produced by the storage. #[cfg(test)] listener: RocksdbStorageEventListener, @@ -174,7 +180,7 @@ impl RocksdbStorageBuilder { pub fn from_rocksdb(value: RocksDB) -> Self { RocksdbStorageBuilder(RocksdbStorage { db: value, - pending_patch: InMemoryStorage::default(), + pending_patch: PendingPatch::default(), #[cfg(test)] listener: RocksdbStorageEventListener::default(), }) @@ -309,7 +315,7 @@ impl RocksdbStorage { .context("failed initializing state keeper RocksDB")?; Ok(Self { db, - pending_patch: InMemoryStorage::default(), + pending_patch: PendingPatch::default(), #[cfg(test)] listener: RocksdbStorageEventListener::default(), }) diff --git a/core/lib/state/src/shadow_storage.rs b/core/lib/state/src/shadow_storage.rs index 5e32f9b25e71..28d7b997cd1f 100644 --- a/core/lib/state/src/shadow_storage.rs +++ b/core/lib/state/src/shadow_storage.rs @@ -1,7 +1,6 @@ use vise::{Counter, Metrics}; use zksync_types::{L1BatchNumber, StorageKey, StorageValue, H256}; - -use crate::ReadStorage; +use zksync_vm_interface::storage::ReadStorage; #[allow(clippy::struct_field_names)] #[derive(Debug, Metrics)] diff --git a/core/lib/state/src/storage_factory.rs b/core/lib/state/src/storage_factory.rs index c506bf7042d1..d3b978356a50 100644 --- a/core/lib/state/src/storage_factory.rs +++ b/core/lib/state/src/storage_factory.rs @@ -6,10 +6,9 @@ use tokio::{runtime::Handle, sync::watch}; use zksync_dal::{Connection, ConnectionPool, Core, CoreDal}; use zksync_storage::RocksDB; use zksync_types::{L1BatchNumber, StorageKey, StorageValue, H256}; +use zksync_vm_interface::storage::ReadStorage; -use crate::{ - PostgresStorage, ReadStorage, RocksdbStorage, RocksdbStorageBuilder, StateKeeperColumnFamily, -}; +use crate::{PostgresStorage, RocksdbStorage, RocksdbStorageBuilder, StateKeeperColumnFamily}; /// Factory that can produce [`OwnedStorage`] instances on demand. #[async_trait] diff --git a/core/lib/tee_verifier/Cargo.toml b/core/lib/tee_verifier/Cargo.toml index 0d50684e165d..a56f383bdbad 100644 --- a/core/lib/tee_verifier/Cargo.toml +++ b/core/lib/tee_verifier/Cargo.toml @@ -11,11 +11,7 @@ keywords.workspace = true categories.workspace = true [dependencies] -anyhow.workspace = true zksync_multivm.workspace = true -serde.workspace = true -tracing.workspace = true -zksync_vm_utils.workspace = true zksync_config.workspace = true zksync_crypto_primitives.workspace = true zksync_dal.workspace = true @@ -24,10 +20,12 @@ zksync_merkle_tree.workspace = true zksync_object_store.workspace = true zksync_prover_interface.workspace = true zksync_queued_job_processor.workspace = true -zksync_state.workspace = true zksync_types.workspace = true zksync_utils.workspace = true +anyhow.workspace = true +serde.workspace = true +tracing.workspace = true + [dev-dependencies] zksync_contracts.workspace = true -zksync_basic_types.workspace = true diff --git a/core/lib/tee_verifier/src/lib.rs b/core/lib/tee_verifier/src/lib.rs index 32443b60c8ca..4234754a75f2 100644 --- a/core/lib/tee_verifier/src/lib.rs +++ b/core/lib/tee_verifier/src/lib.rs @@ -12,17 +12,18 @@ use zksync_merkle_tree::{ BlockOutputWithProofs, TreeInstruction, TreeLogEntry, TreeLogEntryWithProof, ValueHash, }; use zksync_multivm::{ - interface::{FinishedL1Batch, L2BlockEnv, VmFactory, VmInterface}, + interface::{ + storage::{InMemoryStorage, ReadStorage, StorageView}, + FinishedL1Batch, L2BlockEnv, VmFactory, VmInterface, VmInterfaceHistoryEnabled, + }, vm_latest::HistoryEnabled, VmInstance, }; use zksync_prover_interface::inputs::{ StorageLogMetadata, V1TeeVerifierInput, WitnessInputMerklePaths, }; -use zksync_state::{InMemoryStorage, ReadStorage, StorageView}; -use zksync_types::{block::L2BlockExecutionData, L1BatchNumber, StorageLog, H256}; +use zksync_types::{block::L2BlockExecutionData, L1BatchNumber, StorageLog, Transaction, H256}; use zksync_utils::bytecode::hash_bytecode; -use zksync_vm_utils::execute_tx; /// A structure to hold the result of verification. pub struct VerificationResult { @@ -236,13 +237,40 @@ fn generate_tree_instructions( .collect::, _>>() } +fn execute_tx( + tx: &Transaction, + vm: &mut VmInstance, +) -> anyhow::Result<()> { + // Attempt to run VM with bytecode compression on. + vm.make_snapshot(); + if vm + .execute_transaction_with_bytecode_compression(tx.clone(), true) + .0 + .is_ok() + { + vm.pop_snapshot_no_rollback(); + return Ok(()); + } + + // If failed with bytecode compression, attempt to run without bytecode compression. + vm.rollback_to_the_latest_snapshot(); + if vm + .execute_transaction_with_bytecode_compression(tx.clone(), false) + .0 + .is_err() + { + anyhow::bail!("compression can't fail if we don't apply it"); + } + Ok(()) +} + #[cfg(test)] mod tests { - use zksync_basic_types::U256; use zksync_contracts::{BaseSystemContracts, SystemContractCode}; use zksync_multivm::interface::{L1BatchEnv, SystemEnv, TxExecutionMode}; use zksync_object_store::StoredObject; use zksync_prover_interface::inputs::TeeVerifierInput; + use zksync_types::U256; use super::*; diff --git a/core/lib/types/src/vm_trace.rs b/core/lib/types/src/vm_trace.rs index f01cbae77862..80a3eea92f6c 100644 --- a/core/lib/types/src/vm_trace.rs +++ b/core/lib/types/src/vm_trace.rs @@ -1,68 +1,10 @@ -use std::{ - collections::{HashMap, HashSet}, - fmt, - fmt::Display, -}; +use std::fmt; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use zksync_system_constants::BOOTLOADER_ADDRESS; -use zksync_utils::u256_to_h256; use crate::{zk_evm_types::FarCallOpcode, Address, U256}; -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub enum VmTrace { - ExecutionTrace(VmExecutionTrace), - CallTrace(Vec), -} - -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq)] -pub struct VmExecutionTrace { - pub steps: Vec, - pub contracts: HashSet
, -} - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct VmExecutionStep { - pub contract_address: Address, - pub memory_page_index: usize, - pub child_memory_index: usize, - pub pc: u16, - pub set_flags: Vec, - pub registers: Vec, - pub register_interactions: HashMap, - pub sp: Option, - pub memory_interactions: Vec, - pub error: Option, -} - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct MemoryInteraction { - pub memory_type: String, - pub page: usize, - pub address: u16, - pub value: U256, - pub direction: MemoryDirection, -} - -#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)] -pub enum MemoryDirection { - Read, - Write, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct ContractSourceDebugInfo { - pub assembly_code: String, - pub pc_line_mapping: HashMap, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct VmDebugTrace { - pub steps: Vec, - pub sources: HashMap>, -} - #[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)] pub enum CallType { #[serde(serialize_with = "far_call_type_to_u8")] @@ -383,40 +325,6 @@ impl fmt::Debug for LegacyCall { } } -#[derive(Debug, Clone)] -pub enum ViolatedValidationRule { - TouchedUnallowedStorageSlots(Address, U256), - CalledContractWithNoCode(Address), - TouchedUnallowedContext, - TookTooManyComputationalGas(u32), -} - -impl Display for ViolatedValidationRule { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - ViolatedValidationRule::TouchedUnallowedStorageSlots(contract, key) => write!( - f, - "Touched unallowed storage slots: address {}, key: {}", - hex::encode(contract), - hex::encode(u256_to_h256(*key)) - ), - ViolatedValidationRule::CalledContractWithNoCode(contract) => { - write!(f, "Called contract with no code: {}", hex::encode(contract)) - } - ViolatedValidationRule::TouchedUnallowedContext => { - write!(f, "Touched unallowed context") - } - ViolatedValidationRule::TookTooManyComputationalGas(gas_limit) => { - write!( - f, - "Took too many computational gas, allowed limit: {}", - gas_limit - ) - } - } - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/core/lib/vm_interface/Cargo.toml b/core/lib/vm_interface/Cargo.toml new file mode 100644 index 000000000000..75362d7da3f6 --- /dev/null +++ b/core/lib/vm_interface/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "zksync_vm_interface" +description = "ZKsync Era VM interfaces" +version.workspace = true +edition.workspace = true +authors.workspace = true +homepage.workspace = true +repository.workspace = true +license.workspace = true +keywords.workspace = true +categories.workspace = true + +[dependencies] +zksync_contracts.workspace = true +zksync_system_constants.workspace = true +zksync_types.workspace = true +zksync_utils.workspace = true + +hex.workspace = true +serde.workspace = true +thiserror.workspace = true +tracing.workspace = true diff --git a/core/lib/vm_interface/README.md b/core/lib/vm_interface/README.md new file mode 100644 index 000000000000..fad9c8fd9890 --- /dev/null +++ b/core/lib/vm_interface/README.md @@ -0,0 +1,8 @@ +# ZKsync Era VM Interfaces + +This crate declares interfaces used by all version of the ZKsync Era VM. + +## See also + +- [`zksync_multivm`](https://crates.io/crates/zksync_multivm): crate with ZKsync Era VM implementations. +- [`zksync_state`](https://crates.io/crates/zksync_state): crate with VM state implementations. diff --git a/core/lib/multivm/src/interface/mod.rs b/core/lib/vm_interface/src/lib.rs similarity index 60% rename from core/lib/multivm/src/interface/mod.rs rename to core/lib/vm_interface/src/lib.rs index 360d53df52a7..1837bec4aff9 100644 --- a/core/lib/multivm/src/interface/mod.rs +++ b/core/lib/vm_interface/src/lib.rs @@ -1,11 +1,6 @@ -pub(crate) mod traits; -pub mod types; +//! ZKsync Era VM interfaces. -pub use self::{ - traits::{ - tracers::dyn_tracers, - vm::{VmFactory, VmInterface, VmInterfaceHistoryEnabled}, - }, +pub use crate::{ types::{ errors::{ BytecodeCompressionError, Halt, TxRevertReason, VmRevertReason, @@ -14,8 +9,14 @@ pub use self::{ inputs::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode}, outputs::{ BootloaderMemory, CurrentExecutionState, ExecutionResult, FinishedL1Batch, L2Block, - Refunds, VmExecutionResultAndLogs, VmExecutionStatistics, VmMemoryMetrics, + Refunds, VmExecutionLogs, VmExecutionResultAndLogs, VmExecutionStatistics, + VmMemoryMetrics, }, tracer, }, + vm::{VmFactory, VmInterface, VmInterfaceHistoryEnabled}, }; + +pub mod storage; +mod types; +mod vm; diff --git a/core/lib/state/src/in_memory.rs b/core/lib/vm_interface/src/storage/in_memory.rs similarity index 95% rename from core/lib/state/src/in_memory.rs rename to core/lib/vm_interface/src/storage/in_memory.rs index 594eae128169..d4b5e57f1fa0 100644 --- a/core/lib/state/src/in_memory.rs +++ b/core/lib/vm_interface/src/storage/in_memory.rs @@ -3,11 +3,10 @@ use std::collections::{hash_map::Entry, BTreeMap, HashMap}; use zksync_types::{ block::DeployedContract, get_code_key, get_known_code_key, get_system_context_init_logs, system_contracts::get_system_smart_contracts, L2ChainId, StorageKey, StorageLog, StorageValue, - H256, U256, + H256, }; -use zksync_utils::u256_to_h256; -use crate::ReadStorage; +use super::ReadStorage; /// Network ID we use by default for in memory storage. pub const IN_MEMORY_STORAGE_DEFAULT_NETWORK_ID: u32 = 270; @@ -15,8 +14,8 @@ pub const IN_MEMORY_STORAGE_DEFAULT_NETWORK_ID: u32 = 270; /// In-memory storage. #[derive(Debug, Default, Clone)] pub struct InMemoryStorage { - pub(crate) state: HashMap, - pub(crate) factory_deps: HashMap>, + state: HashMap, + factory_deps: HashMap>, last_enum_index_set: u64, } @@ -57,9 +56,9 @@ impl InMemoryStorage { let deployer_code_key = get_code_key(contract.account_id.address()); let is_known_code_key = get_known_code_key(&bytecode_hash); - vec![ + [ StorageLog::new_write_log(deployer_code_key, bytecode_hash), - StorageLog::new_write_log(is_known_code_key, u256_to_h256(U256::one())), + StorageLog::new_write_log(is_known_code_key, H256::from_low_u64_be(1)), ] }) .chain(system_context_init_log) diff --git a/core/lib/vm_interface/src/storage/mod.rs b/core/lib/vm_interface/src/storage/mod.rs new file mode 100644 index 000000000000..96cc1f19862c --- /dev/null +++ b/core/lib/vm_interface/src/storage/mod.rs @@ -0,0 +1,75 @@ +use std::{cell::RefCell, collections::HashMap, fmt, rc::Rc}; + +use zksync_types::{get_known_code_key, StorageKey, StorageValue, H256}; + +pub use self::{ + // Note, that `test_infra` of the bootloader tests relies on this value to be exposed + in_memory::{InMemoryStorage, IN_MEMORY_STORAGE_DEFAULT_NETWORK_ID}, + view::{ImmutableStorageView, StorageView, StorageViewCache, StorageViewMetrics}, +}; + +mod in_memory; +mod view; + +/// Functionality to read from the VM storage. +pub trait ReadStorage: fmt::Debug { + /// Read value of the key. + fn read_value(&mut self, key: &StorageKey) -> StorageValue; + + /// Checks whether a write to this storage at the specified `key` would be an initial write. + /// Roughly speaking, this is the case when the storage doesn't contain `key`, although + /// in case of mutable storage, the caveats apply (a write to a key that is present + /// in the storage but was not committed is still an initial write). + fn is_write_initial(&mut self, key: &StorageKey) -> bool; + + /// Load the factory dependency code by its hash. + fn load_factory_dep(&mut self, hash: H256) -> Option>; + + /// Returns whether a bytecode hash is "known" to the system. + fn is_bytecode_known(&mut self, bytecode_hash: &H256) -> bool { + let code_key = get_known_code_key(bytecode_hash); + self.read_value(&code_key) != H256::zero() + } + + /// Retrieves the enumeration index for a given `key`. + fn get_enumeration_index(&mut self, key: &StorageKey) -> Option; +} + +/// Functionality to write to the VM storage in a batch. +/// +/// So far, this trait is implemented only for [`StorageView`]. +pub trait WriteStorage: ReadStorage { + /// Returns the map with the key–value pairs read by this batch. + fn read_storage_keys(&self) -> &HashMap; + + /// Sets the new value under a given key and returns the previous value. + fn set_value(&mut self, key: StorageKey, value: StorageValue) -> StorageValue; + + /// Returns a map with the key–value pairs updated by this batch. + fn modified_storage_keys(&self) -> &HashMap; + + /// Returns the number of read / write ops for which the value was read from the underlying + /// storage. + fn missed_storage_invocations(&self) -> usize; +} + +/// Smart pointer to [`WriteStorage`]. +pub type StoragePtr = Rc>; + +impl ReadStorage for StoragePtr { + fn read_value(&mut self, key: &StorageKey) -> StorageValue { + self.borrow_mut().read_value(key) + } + + fn is_write_initial(&mut self, key: &StorageKey) -> bool { + self.borrow_mut().is_write_initial(key) + } + + fn load_factory_dep(&mut self, hash: H256) -> Option> { + self.borrow_mut().load_factory_dep(hash) + } + + fn get_enumeration_index(&mut self, key: &StorageKey) -> Option { + self.borrow_mut().get_enumeration_index(key) + } +} diff --git a/core/lib/state/src/storage_view.rs b/core/lib/vm_interface/src/storage/view.rs similarity index 99% rename from core/lib/state/src/storage_view.rs rename to core/lib/vm_interface/src/storage/view.rs index b01f423f0787..691a9d442ca8 100644 --- a/core/lib/state/src/storage_view.rs +++ b/core/lib/vm_interface/src/storage/view.rs @@ -8,7 +8,7 @@ use std::{ use zksync_types::{StorageKey, StorageValue, H256}; -use crate::{ReadStorage, StoragePtr, WriteStorage}; +use super::{ReadStorage, StoragePtr, WriteStorage}; /// Metrics for [`StorageView`]. #[derive(Debug, Default, Clone, Copy)] @@ -269,7 +269,7 @@ mod test { use zksync_types::{AccountTreeId, Address, H256}; use super::*; - use crate::InMemoryStorage; + use crate::storage::InMemoryStorage; #[test] fn test_storage_access() { diff --git a/core/lib/multivm/src/interface/types/errors/bootloader_error.rs b/core/lib/vm_interface/src/types/errors/bootloader_error.rs similarity index 98% rename from core/lib/multivm/src/interface/types/errors/bootloader_error.rs rename to core/lib/vm_interface/src/types/errors/bootloader_error.rs index 0f0e14408669..f06da7aa14ea 100644 --- a/core/lib/multivm/src/interface/types/errors/bootloader_error.rs +++ b/core/lib/vm_interface/src/types/errors/bootloader_error.rs @@ -1,6 +1,7 @@ /// Error codes returned by the bootloader. #[derive(Debug)] -pub(crate) enum BootloaderErrorCode { +#[non_exhaustive] +pub enum BootloaderErrorCode { EthCall, AccountTxValidationFailed, FailedToChargeFee, diff --git a/core/lib/multivm/src/interface/types/errors/bytecode_compression.rs b/core/lib/vm_interface/src/types/errors/bytecode_compression.rs similarity index 74% rename from core/lib/multivm/src/interface/types/errors/bytecode_compression.rs rename to core/lib/vm_interface/src/types/errors/bytecode_compression.rs index c6cd094ae948..418be6b85733 100644 --- a/core/lib/multivm/src/interface/types/errors/bytecode_compression.rs +++ b/core/lib/vm_interface/src/types/errors/bytecode_compression.rs @@ -1,7 +1,6 @@ -use thiserror::Error; - /// Errors related to bytecode compression. -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum BytecodeCompressionError { #[error("Bytecode compression failed")] BytecodeCompressionFailed, diff --git a/core/lib/multivm/src/interface/types/errors/halt.rs b/core/lib/vm_interface/src/types/errors/halt.rs similarity index 97% rename from core/lib/multivm/src/interface/types/errors/halt.rs rename to core/lib/vm_interface/src/types/errors/halt.rs index 70de7548f14e..88328e42b812 100644 --- a/core/lib/multivm/src/interface/types/errors/halt.rs +++ b/core/lib/vm_interface/src/types/errors/halt.rs @@ -1,4 +1,4 @@ -use std::fmt::{Display, Formatter}; +use std::fmt; use super::VmRevertReason; @@ -44,8 +44,8 @@ pub enum Halt { FailedToPublishCompressedBytecodes, } -impl Display for Halt { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { +impl fmt::Display for Halt { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Halt::ValidationFailed(reason) => { write!(f, "Account validation error: {}", reason) diff --git a/core/lib/vm_interface/src/types/errors/mod.rs b/core/lib/vm_interface/src/types/errors/mod.rs new file mode 100644 index 000000000000..070e7aa28427 --- /dev/null +++ b/core/lib/vm_interface/src/types/errors/mod.rs @@ -0,0 +1,13 @@ +pub use self::{ + bootloader_error::BootloaderErrorCode, + bytecode_compression::BytecodeCompressionError, + halt::Halt, + tx_revert_reason::TxRevertReason, + vm_revert_reason::{VmRevertReason, VmRevertReasonParsingError}, +}; + +mod bootloader_error; +mod bytecode_compression; +mod halt; +mod tx_revert_reason; +mod vm_revert_reason; diff --git a/core/lib/multivm/src/interface/types/errors/tx_revert_reason.rs b/core/lib/vm_interface/src/types/errors/tx_revert_reason.rs similarity index 96% rename from core/lib/multivm/src/interface/types/errors/tx_revert_reason.rs rename to core/lib/vm_interface/src/types/errors/tx_revert_reason.rs index d863e387e019..793565e054ca 100644 --- a/core/lib/multivm/src/interface/types/errors/tx_revert_reason.rs +++ b/core/lib/vm_interface/src/types/errors/tx_revert_reason.rs @@ -1,13 +1,12 @@ -use std::fmt::Display; +use std::fmt; use super::{halt::Halt, BootloaderErrorCode, VmRevertReason}; #[derive(Debug, Clone, PartialEq)] pub enum TxRevertReason { - // Returned when the execution of an L2 transaction has failed - // Or EthCall has failed + /// Returned when the execution of an L2 transaction or a call has failed. TxReverted(VmRevertReason), - // Returned when some validation has failed or some internal errors + /// Returned when some validation has failed or some internal errors. Halt(Halt), } @@ -135,8 +134,8 @@ impl TxRevertReason { } } -impl Display for TxRevertReason { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl fmt::Display for TxRevertReason { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self { TxRevertReason::TxReverted(reason) => write!(f, "{}", reason), TxRevertReason::Halt(reason) => write!(f, "{}", reason), diff --git a/core/lib/multivm/src/interface/types/errors/vm_revert_reason.rs b/core/lib/vm_interface/src/types/errors/vm_revert_reason.rs similarity index 97% rename from core/lib/multivm/src/interface/types/errors/vm_revert_reason.rs rename to core/lib/vm_interface/src/types/errors/vm_revert_reason.rs index 6b211d543a92..d76b7d4ddb9f 100644 --- a/core/lib/multivm/src/interface/types/errors/vm_revert_reason.rs +++ b/core/lib/vm_interface/src/types/errors/vm_revert_reason.rs @@ -1,8 +1,9 @@ -use std::fmt::{Debug, Display}; +use std::fmt; use zksync_types::U256; #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum VmRevertReasonParsingError { #[error("Incorrect data offset. Data: {0:?}")] IncorrectDataOffset(Vec), @@ -14,6 +15,7 @@ pub enum VmRevertReasonParsingError { /// Rich Revert Reasons `https://github.com/0xProject/ZEIPs/issues/32` #[derive(Debug, Clone, PartialEq)] +#[non_exhaustive] pub enum VmRevertReason { General { msg: String, @@ -29,6 +31,7 @@ pub enum VmRevertReason { impl VmRevertReason { const GENERAL_ERROR_SELECTOR: &'static [u8] = &[0x08, 0xc3, 0x79, 0xa0]; + fn parse_general_error(raw_bytes: &[u8]) -> Result { let bytes = &raw_bytes[4..]; if bytes.len() < 32 { @@ -111,7 +114,6 @@ impl VmRevertReason { function_selector: function_selector.to_vec(), data: bytes.to_vec(), }; - tracing::debug!("Unsupported error type: {}", result); Ok(result) } } @@ -144,8 +146,8 @@ impl From<&[u8]> for VmRevertReason { } } -impl Display for VmRevertReason { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl fmt::Display for VmRevertReason { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use VmRevertReason::{General, InnerTxError, Unknown, VmError}; match self { diff --git a/core/lib/multivm/src/interface/types/inputs/execution_mode.rs b/core/lib/vm_interface/src/types/inputs/execution_mode.rs similarity index 100% rename from core/lib/multivm/src/interface/types/inputs/execution_mode.rs rename to core/lib/vm_interface/src/types/inputs/execution_mode.rs diff --git a/core/lib/multivm/src/interface/types/inputs/l1_batch_env.rs b/core/lib/vm_interface/src/types/inputs/l1_batch_env.rs similarity index 100% rename from core/lib/multivm/src/interface/types/inputs/l1_batch_env.rs rename to core/lib/vm_interface/src/types/inputs/l1_batch_env.rs diff --git a/core/lib/multivm/src/interface/types/inputs/l2_block.rs b/core/lib/vm_interface/src/types/inputs/l2_block.rs similarity index 100% rename from core/lib/multivm/src/interface/types/inputs/l2_block.rs rename to core/lib/vm_interface/src/types/inputs/l2_block.rs diff --git a/core/lib/vm_interface/src/types/inputs/mod.rs b/core/lib/vm_interface/src/types/inputs/mod.rs new file mode 100644 index 000000000000..1d2c49cdfa11 --- /dev/null +++ b/core/lib/vm_interface/src/types/inputs/mod.rs @@ -0,0 +1,11 @@ +pub use self::{ + execution_mode::VmExecutionMode, + l1_batch_env::L1BatchEnv, + l2_block::L2BlockEnv, + system_env::{SystemEnv, TxExecutionMode}, +}; + +mod execution_mode; +mod l1_batch_env; +mod l2_block; +mod system_env; diff --git a/core/lib/multivm/src/interface/types/inputs/system_env.rs b/core/lib/vm_interface/src/types/inputs/system_env.rs similarity index 100% rename from core/lib/multivm/src/interface/types/inputs/system_env.rs rename to core/lib/vm_interface/src/types/inputs/system_env.rs diff --git a/core/lib/multivm/src/interface/types/mod.rs b/core/lib/vm_interface/src/types/mod.rs similarity index 73% rename from core/lib/multivm/src/interface/types/mod.rs rename to core/lib/vm_interface/src/types/mod.rs index a70d0a59ead7..6d874f75efe6 100644 --- a/core/lib/multivm/src/interface/types/mod.rs +++ b/core/lib/vm_interface/src/types/mod.rs @@ -1,4 +1,4 @@ -pub mod errors; +pub(crate) mod errors; pub(crate) mod inputs; pub(crate) mod outputs; pub mod tracer; diff --git a/core/lib/multivm/src/interface/types/outputs/execution_result.rs b/core/lib/vm_interface/src/types/outputs/execution_result.rs similarity index 93% rename from core/lib/multivm/src/interface/types/outputs/execution_result.rs rename to core/lib/vm_interface/src/types/outputs/execution_result.rs index 35d14524e0a8..1037cc1d6e8e 100644 --- a/core/lib/multivm/src/interface/types/outputs/execution_result.rs +++ b/core/lib/vm_interface/src/types/outputs/execution_result.rs @@ -3,11 +3,14 @@ use zksync_types::{ event::{extract_long_l2_to_l1_messages, extract_published_bytecodes}, l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, tx::ExecutionMetrics, - StorageLogWithPreviousValue, Transaction, VmEvent, + StorageLogWithPreviousValue, Transaction, VmEvent, H256, }; -use zksync_utils::bytecode::bytecode_len_in_bytes; -use crate::interface::{Halt, VmExecutionStatistics, VmRevertReason}; +use crate::{Halt, VmExecutionStatistics, VmRevertReason}; + +pub fn bytecode_len_in_bytes(bytecodehash: H256) -> usize { + usize::from(u16::from_be_bytes([bytecodehash[2], bytecodehash[3]])) * 32 +} /// Refunds produced for the user. #[derive(Debug, Clone, Default, PartialEq)] diff --git a/core/lib/multivm/src/interface/types/outputs/execution_state.rs b/core/lib/vm_interface/src/types/outputs/execution_state.rs similarity index 100% rename from core/lib/multivm/src/interface/types/outputs/execution_state.rs rename to core/lib/vm_interface/src/types/outputs/execution_state.rs diff --git a/core/lib/multivm/src/interface/types/outputs/finished_l1batch.rs b/core/lib/vm_interface/src/types/outputs/finished_l1batch.rs similarity index 100% rename from core/lib/multivm/src/interface/types/outputs/finished_l1batch.rs rename to core/lib/vm_interface/src/types/outputs/finished_l1batch.rs diff --git a/core/lib/multivm/src/interface/types/outputs/l2_block.rs b/core/lib/vm_interface/src/types/outputs/l2_block.rs similarity index 100% rename from core/lib/multivm/src/interface/types/outputs/l2_block.rs rename to core/lib/vm_interface/src/types/outputs/l2_block.rs diff --git a/core/lib/multivm/src/interface/types/outputs/mod.rs b/core/lib/vm_interface/src/types/outputs/mod.rs similarity index 100% rename from core/lib/multivm/src/interface/types/outputs/mod.rs rename to core/lib/vm_interface/src/types/outputs/mod.rs diff --git a/core/lib/multivm/src/interface/types/outputs/statistic.rs b/core/lib/vm_interface/src/types/outputs/statistic.rs similarity index 100% rename from core/lib/multivm/src/interface/types/outputs/statistic.rs rename to core/lib/vm_interface/src/types/outputs/statistic.rs diff --git a/core/lib/multivm/src/interface/types/tracer.rs b/core/lib/vm_interface/src/types/tracer.rs similarity index 97% rename from core/lib/multivm/src/interface/types/tracer.rs rename to core/lib/vm_interface/src/types/tracer.rs index 4221eddaf7a7..1b42b2eabbb3 100644 --- a/core/lib/multivm/src/interface/types/tracer.rs +++ b/core/lib/vm_interface/src/types/tracer.rs @@ -1,4 +1,4 @@ -use crate::interface::Halt; +use crate::Halt; #[derive(Debug, Clone, PartialEq)] pub enum TracerExecutionStopReason { diff --git a/core/lib/multivm/src/interface/traits/vm.rs b/core/lib/vm_interface/src/vm.rs similarity index 75% rename from core/lib/multivm/src/interface/traits/vm.rs rename to core/lib/vm_interface/src/vm.rs index 0fd41934cc61..fd488e5100ca 100644 --- a/core/lib/multivm/src/interface/traits/vm.rs +++ b/core/lib/vm_interface/src/vm.rs @@ -10,54 +10,14 @@ //! //! Generally speaking, in most cases, the tracer dispatcher is a wrapper around `Vec>`, //! where `VmTracer` is a trait implemented for a specific VM version. -//! -//! Example usage: -//! ``` -//! use std::{ -//! cell::RefCell, -//! rc::Rc, -//! sync::Arc -//! }; -//! use once_cell::sync::OnceCell; -//! use zksync_multivm::{ -//! interface::{L1BatchEnv, SystemEnv, VmInterface}, -//! tracers::CallTracer , -//! vm_latest::ToTracerPointer -//! }; -//! use zksync_state::{InMemoryStorage, StorageView}; -//! use zksync_types::Transaction; -//! -//! // Prepare the environment for the VM. -//! let l1_batch_env = L1BatchEnv::new(); -//! let system_env = SystemEnv::default(); -//! // Create storage -//! let storage = Rc::new(RefCell::new(StorageView::new(InMemoryStorage::default()))); -//! // Instantiate VM with the desired version. -//! let mut vm = multivm::vm_latest::Vm::new(l1_batch_env, system_env, storage); -//! // Push a transaction to the VM. -//! let tx = Transaction::default(); -//! vm.push_transaction(tx); -//! // Instantiate a tracer. -//! let result = Arc::new(OnceCell::new()); -//! let call_tracer = CallTracer::new(result.clone()).into_tracer_pointer(); -//! // Inspect the transaction with a tracer. You can use either one tracer or a vector of tracers. -//! let result = vm.inspect(call_tracer.into(), multivm::interface::VmExecutionMode::OneTx); -//! -//! // To obtain the result of the entire batch, you can use the following code: -//! let result = vm.execute(multivm::interface::VmExecutionMode::Batch); -//! ``` -use zksync_state::StoragePtr; use zksync_types::Transaction; use zksync_utils::bytecode::CompressedBytecodeInfo; -use crate::interface::{ - types::{ - errors::BytecodeCompressionError, - inputs::{L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode}, - outputs::{BootloaderMemory, CurrentExecutionState, VmExecutionResultAndLogs}, - }, - FinishedL1Batch, VmMemoryMetrics, +use crate::{ + storage::StoragePtr, BootloaderMemory, BytecodeCompressionError, CurrentExecutionState, + FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, + VmMemoryMetrics, }; pub trait VmInterface { diff --git a/core/lib/vm_utils/Cargo.toml b/core/lib/vm_utils/Cargo.toml index c325f0e9db30..cb12e7c8f673 100644 --- a/core/lib/vm_utils/Cargo.toml +++ b/core/lib/vm_utils/Cargo.toml @@ -11,12 +11,11 @@ keywords.workspace = true categories.workspace = true [dependencies] -zksync_multivm.workspace = true -zksync_types.workspace = true +zksync_contracts.workspace = true zksync_dal.workspace = true -zksync_state.workspace = true +zksync_types.workspace = true +zksync_vm_interface.workspace = true + tokio.workspace = true anyhow.workspace = true tracing.workspace = true -zksync_utils.workspace = true -zksync_contracts.workspace = true diff --git a/core/lib/vm_utils/src/lib.rs b/core/lib/vm_utils/src/lib.rs index a3ec715851a4..30f61eb69f21 100644 --- a/core/lib/vm_utils/src/lib.rs +++ b/core/lib/vm_utils/src/lib.rs @@ -1,86 +1 @@ -use anyhow::{anyhow, Context}; -use tokio::runtime::Handle; -use zksync_dal::{Connection, Core}; -use zksync_multivm::{ - interface::{VmFactory, VmInterface, VmInterfaceHistoryEnabled}, - vm_latest::HistoryEnabled, - VmInstance, -}; -use zksync_state::{PostgresStorage, ReadStorage, StoragePtr, StorageView}; -use zksync_types::{L1BatchNumber, L2ChainId, Transaction}; - -use crate::storage::L1BatchParamsProvider; - pub mod storage; - -pub type VmAndStorage<'a> = ( - VmInstance, HistoryEnabled>, - StoragePtr>>, -); - -pub fn create_vm( - rt_handle: Handle, - l1_batch_number: L1BatchNumber, - mut connection: Connection<'_, Core>, - l2_chain_id: L2ChainId, -) -> anyhow::Result { - let mut l1_batch_params_provider = L1BatchParamsProvider::new(); - rt_handle - .block_on(l1_batch_params_provider.initialize(&mut connection)) - .context("failed initializing L1 batch params provider")?; - let first_l2_block_in_batch = rt_handle - .block_on( - l1_batch_params_provider.load_first_l2_block_in_batch(&mut connection, l1_batch_number), - ) - .with_context(|| format!("failed loading first L2 block in L1 batch #{l1_batch_number}"))? - .with_context(|| format!("no L2 blocks persisted for L1 batch #{l1_batch_number}"))?; - - // In the state keeper, this value is used to reject execution. - // All batches ran by BasicWitnessInputProducer have already been executed by State Keeper. - // This means we don't want to reject any execution, therefore we're using MAX as an allow all. - let validation_computational_gas_limit = u32::MAX; - - let (system_env, l1_batch_env) = rt_handle - .block_on(l1_batch_params_provider.load_l1_batch_params( - &mut connection, - &first_l2_block_in_batch, - validation_computational_gas_limit, - l2_chain_id, - )) - .context("expected L2 block to be executed and sealed")?; - - let storage_l2_block_number = first_l2_block_in_batch.number() - 1; - let pg_storage = - PostgresStorage::new(rt_handle.clone(), connection, storage_l2_block_number, true); - let storage_view = StorageView::new(pg_storage).to_rc_ptr(); - let vm = VmInstance::new(l1_batch_env, system_env, storage_view.clone()); - - Ok((vm, storage_view)) -} - -pub fn execute_tx( - tx: &Transaction, - vm: &mut VmInstance, -) -> anyhow::Result<()> { - // Attempt to run VM with bytecode compression on. - vm.make_snapshot(); - if vm - .execute_transaction_with_bytecode_compression(tx.clone(), true) - .0 - .is_ok() - { - vm.pop_snapshot_no_rollback(); - return Ok(()); - } - - // If failed with bytecode compression, attempt to run without bytecode compression. - vm.rollback_to_the_latest_snapshot(); - if vm - .execute_transaction_with_bytecode_compression(tx.clone(), false) - .0 - .is_err() - { - return Err(anyhow!("compression can't fail if we don't apply it")); - } - Ok(()) -} diff --git a/core/lib/vm_utils/src/storage.rs b/core/lib/vm_utils/src/storage.rs index fbf52a67623d..1e43543bc5aa 100644 --- a/core/lib/vm_utils/src/storage.rs +++ b/core/lib/vm_utils/src/storage.rs @@ -3,15 +3,13 @@ use std::time::{Duration, Instant}; use anyhow::Context; use zksync_contracts::BaseSystemContracts; use zksync_dal::{Connection, Core, CoreDal, DalError}; -use zksync_multivm::{ - interface::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode}, - vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, - zk_evm_latest::ethereum_types::H256, -}; use zksync_types::{ block::L2BlockHeader, fee_model::BatchFeeInput, snapshots::SnapshotRecoveryStatus, Address, - L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersionId, ZKPORTER_IS_AVAILABLE, + L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersionId, H256, ZKPORTER_IS_AVAILABLE, }; +use zksync_vm_interface::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode}; + +const BATCH_COMPUTATIONAL_GAS_LIMIT: u32 = u32::MAX; /// Typesafe wrapper around [`L2BlockHeader`] returned by [`L1BatchParamsProvider`]. #[derive(Debug)] diff --git a/core/lib/web3_decl/src/types.rs b/core/lib/web3_decl/src/types.rs index 41902e408e7a..9994d21107be 100644 --- a/core/lib/web3_decl/src/types.rs +++ b/core/lib/web3_decl/src/types.rs @@ -16,7 +16,6 @@ use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; pub use zksync_types::{ api::{Block, BlockNumber, Log, TransactionReceipt, TransactionRequest}, ethabi, - vm_trace::{ContractSourceDebugInfo, VmDebugTrace, VmExecutionStep}, web3::{BlockHeader, Bytes, CallRequest, FeeHistory, Index, SyncState, TraceFilter, Work}, Address, Transaction, H160, H256, H64, U256, U64, }; diff --git a/core/node/api_server/src/execution_sandbox/apply.rs b/core/node/api_server/src/execution_sandbox/apply.rs index 99664697b14c..c0c8398f690d 100644 --- a/core/node/api_server/src/execution_sandbox/apply.rs +++ b/core/node/api_server/src/execution_sandbox/apply.rs @@ -12,12 +12,15 @@ use anyhow::Context as _; use tokio::runtime::Handle; use zksync_dal::{Connection, ConnectionPool, Core, CoreDal, DalError}; use zksync_multivm::{ - interface::{L1BatchEnv, L2BlockEnv, SystemEnv, VmInterface}, + interface::{ + storage::{ReadStorage, StoragePtr, StorageView, WriteStorage}, + L1BatchEnv, L2BlockEnv, SystemEnv, VmInterface, + }, utils::adjust_pubdata_price_for_tx, vm_latest::{constants::BATCH_COMPUTATIONAL_GAS_LIMIT, HistoryDisabled}, VmInstance, }; -use zksync_state::{PostgresStorage, ReadStorage, StoragePtr, StorageView, WriteStorage}; +use zksync_state::PostgresStorage; use zksync_system_constants::{ SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, ZKPORTER_IS_AVAILABLE, diff --git a/core/node/api_server/src/execution_sandbox/storage.rs b/core/node/api_server/src/execution_sandbox/storage.rs index 749945b4e341..0d4c88d4a0ae 100644 --- a/core/node/api_server/src/execution_sandbox/storage.rs +++ b/core/node/api_server/src/execution_sandbox/storage.rs @@ -5,7 +5,7 @@ use std::{ fmt, }; -use zksync_state::ReadStorage; +use zksync_multivm::interface::storage::ReadStorage; use zksync_types::{ api::state_override::{OverrideState, StateOverride}, get_code_key, get_nonce_key, @@ -119,7 +119,7 @@ impl ReadStorage for StorageWithOverrides { #[cfg(test)] mod tests { - use zksync_state::InMemoryStorage; + use zksync_multivm::interface::storage::InMemoryStorage; use zksync_types::{ api::state_override::{Bytecode, OverrideAccount}, Address, diff --git a/core/node/api_server/src/execution_sandbox/tracers.rs b/core/node/api_server/src/execution_sandbox/tracers.rs index ba258ab7c74a..f03c17a5fa42 100644 --- a/core/node/api_server/src/execution_sandbox/tracers.rs +++ b/core/node/api_server/src/execution_sandbox/tracers.rs @@ -2,9 +2,9 @@ use std::sync::Arc; use once_cell::sync::OnceCell; use zksync_multivm::{ - tracers::CallTracer, vm_latest::HistoryMode, MultiVMTracer, MultiVmTracerPointer, + interface::storage::WriteStorage, tracers::CallTracer, vm_latest::HistoryMode, MultiVMTracer, + MultiVmTracerPointer, }; -use zksync_state::WriteStorage; use zksync_types::vm_trace::Call; /// Custom tracers supported by our API diff --git a/core/node/api_server/src/execution_sandbox/validate.rs b/core/node/api_server/src/execution_sandbox/validate.rs index 5e958cada66e..a856386b4562 100644 --- a/core/node/api_server/src/execution_sandbox/validate.rs +++ b/core/node/api_server/src/execution_sandbox/validate.rs @@ -5,8 +5,8 @@ use zksync_dal::{Connection, ConnectionPool, Core, CoreDal}; use zksync_multivm::{ interface::{ExecutionResult, VmExecutionMode, VmInterface}, tracers::{ - validator::{self, ValidationTracer, ValidationTracerParams}, - StorageInvocations, + StorageInvocations, ValidationError as RawValidationError, ValidationTracer, + ValidationTracerParams, }, vm_latest::HistoryDisabled, MultiVMTracer, @@ -25,7 +25,7 @@ use super::{ #[derive(Debug, thiserror::Error)] pub(crate) enum ValidationError { #[error("VM validation error: {0}")] - Vm(validator::ValidationError), + Vm(RawValidationError), #[error("Internal error")] Internal(#[from] anyhow::Error), } @@ -94,11 +94,9 @@ impl TransactionExecutor { ); let result = match (result.result, validation_result.get()) { - (_, Some(err)) => { - Err(validator::ValidationError::ViolatedRule(err.clone())) - } + (_, Some(err)) => Err(RawValidationError::ViolatedRule(err.clone())), (ExecutionResult::Halt { reason }, _) => { - Err(validator::ValidationError::FailedTx(reason)) + Err(RawValidationError::FailedTx(reason)) } (_, None) => Ok(()), }; diff --git a/core/node/api_server/src/execution_sandbox/vm_metrics.rs b/core/node/api_server/src/execution_sandbox/vm_metrics.rs index e1e96d8eee5e..27e1c2ab305a 100644 --- a/core/node/api_server/src/execution_sandbox/vm_metrics.rs +++ b/core/node/api_server/src/execution_sandbox/vm_metrics.rs @@ -3,9 +3,10 @@ use std::time::Duration; use vise::{ Buckets, EncodeLabelSet, EncodeLabelValue, Family, Gauge, Histogram, LatencyObserver, Metrics, }; -use zksync_multivm::interface::{VmExecutionResultAndLogs, VmMemoryMetrics}; +use zksync_multivm::interface::{ + storage::StorageViewMetrics, VmExecutionResultAndLogs, VmMemoryMetrics, +}; use zksync_shared_metrics::InteractionType; -use zksync_state::StorageViewMetrics; use zksync_types::{ event::{extract_long_l2_to_l1_messages, extract_published_bytecodes}, fee::TransactionExecutionMetrics, diff --git a/core/node/api_server/src/web3/tests/vm.rs b/core/node/api_server/src/web3/tests/vm.rs index 50de027174f3..f9629f6dab91 100644 --- a/core/node/api_server/src/web3/tests/vm.rs +++ b/core/node/api_server/src/web3/tests/vm.rs @@ -4,9 +4,8 @@ use std::sync::atomic::{AtomicU32, Ordering}; use api::state_override::{OverrideAccount, StateOverride}; use itertools::Itertools; -use zksync_multivm::{ - interface::{ExecutionResult, VmRevertReason}, - vm_latest::{VmExecutionLogs, VmExecutionResultAndLogs}, +use zksync_multivm::interface::{ + ExecutionResult, VmExecutionLogs, VmExecutionResultAndLogs, VmRevertReason, }; use zksync_types::{ api::{ApiStorageLog, Log}, diff --git a/core/node/block_reverter/src/tests.rs b/core/node/block_reverter/src/tests.rs index 5be1af040714..a2dcae1724fe 100644 --- a/core/node/block_reverter/src/tests.rs +++ b/core/node/block_reverter/src/tests.rs @@ -9,7 +9,7 @@ use tokio::sync::watch; use zksync_dal::Connection; use zksync_merkle_tree::TreeInstruction; use zksync_object_store::{Bucket, MockObjectStore}; -use zksync_state::ReadStorage; +use zksync_state::interface::ReadStorage; use zksync_types::{ block::{L1BatchHeader, L2BlockHeader}, snapshots::SnapshotVersion, diff --git a/core/node/consensus/Cargo.toml b/core/node/consensus/Cargo.toml index 574ae6fdf9f8..e82969dae6c6 100644 --- a/core/node/consensus/Cargo.toml +++ b/core/node/consensus/Cargo.toml @@ -22,7 +22,6 @@ zksync_consensus_bft.workspace = true zksync_consensus_utils.workspace = true zksync_protobuf.workspace = true zksync_dal.workspace = true -zksync_state.workspace = true zksync_l1_contract_interface.workspace = true zksync_metadata_calculator.workspace = true zksync_merkle_tree.workspace = true diff --git a/core/node/consensus/src/testonly.rs b/core/node/consensus/src/testonly.rs index 24e3d73e824e..2c6fdc79a521 100644 --- a/core/node/consensus/src/testonly.rs +++ b/core/node/consensus/src/testonly.rs @@ -29,7 +29,6 @@ use zksync_node_sync::{ ExternalIO, MainNodeClient, SyncState, }; use zksync_node_test_utils::{create_l1_batch_metadata, l1_batch_metadata_to_commitment_artifacts}; -use zksync_state::RocksdbStorageOptions; use zksync_state_keeper::{ io::{IoCursor, L1BatchParams, L2BlockParams}, seal_criteria::NoopSealer, @@ -522,10 +521,7 @@ impl StateKeeperRunner { .join("cache") .to_string_lossy() .into(), - RocksdbStorageOptions { - block_cache_capacity: (1 << 20), // `1MB` - max_open_files: None, - }, + Default::default(), ); s.spawn_bg({ let stop_recv = stop_recv.clone(); diff --git a/core/node/state_keeper/src/batch_executor/main_executor.rs b/core/node/state_keeper/src/batch_executor/main_executor.rs index d3595323a9a3..cc05da9235b5 100644 --- a/core/node/state_keeper/src/batch_executor/main_executor.rs +++ b/core/node/state_keeper/src/batch_executor/main_executor.rs @@ -5,6 +5,7 @@ use once_cell::sync::OnceCell; use tokio::{runtime::Handle, sync::mpsc}; use zksync_multivm::{ interface::{ + storage::{ReadStorage, StorageView}, ExecutionResult, FinishedL1Batch, Halt, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionResultAndLogs, VmInterface, VmInterfaceHistoryEnabled, }, @@ -13,7 +14,7 @@ use zksync_multivm::{ MultiVMTracer, VmInstance, }; use zksync_shared_metrics::{InteractionType, TxStage, APP_METRICS}; -use zksync_state::{OwnedStorage, ReadStorage, StorageView}; +use zksync_state::OwnedStorage; use zksync_types::{vm::FastVmMode, vm_trace::Call, Transaction}; use zksync_utils::bytecode::CompressedBytecodeInfo; diff --git a/core/node/state_keeper/src/batch_executor/mod.rs b/core/node/state_keeper/src/batch_executor/mod.rs index d4fea2e9dfd5..b6f57694afa0 100644 --- a/core/node/state_keeper/src/batch_executor/mod.rs +++ b/core/node/state_keeper/src/batch_executor/mod.rs @@ -6,9 +6,10 @@ use tokio::{ task::JoinHandle, }; use zksync_multivm::interface::{ - FinishedL1Batch, Halt, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionResultAndLogs, + storage::StorageViewCache, FinishedL1Batch, Halt, L1BatchEnv, L2BlockEnv, SystemEnv, + VmExecutionResultAndLogs, }; -use zksync_state::{OwnedStorage, StorageViewCache}; +use zksync_state::OwnedStorage; use zksync_types::{vm_trace::Call, Transaction}; use zksync_utils::bytecode::CompressedBytecodeInfo; diff --git a/core/node/state_keeper/src/metrics.rs b/core/node/state_keeper/src/metrics.rs index c154719e3900..0f9650881b2b 100644 --- a/core/node/state_keeper/src/metrics.rs +++ b/core/node/state_keeper/src/metrics.rs @@ -111,7 +111,7 @@ fn vm_revert_reason_as_metric_label(reason: &VmRevertReason) -> &'static str { VmRevertReason::General { .. } => "General", VmRevertReason::InnerTxError => "InnerTxError", VmRevertReason::VmError => "VmError", - VmRevertReason::Unknown { .. } => "Unknown", + _ => "Unknown", } } diff --git a/core/node/state_keeper/src/testonly/mod.rs b/core/node/state_keeper/src/testonly/mod.rs index e47e1182699d..02b0043b97cf 100644 --- a/core/node/state_keeper/src/testonly/mod.rs +++ b/core/node/state_keeper/src/testonly/mod.rs @@ -5,14 +5,11 @@ use once_cell::sync::Lazy; use tokio::sync::mpsc; use zksync_contracts::BaseSystemContracts; use zksync_dal::{ConnectionPool, Core, CoreDal as _}; -use zksync_multivm::{ - interface::{ - CurrentExecutionState, ExecutionResult, FinishedL1Batch, L1BatchEnv, Refunds, SystemEnv, - VmExecutionResultAndLogs, VmExecutionStatistics, - }, - vm_latest::VmExecutionLogs, +use zksync_multivm::interface::{ + storage::StorageViewCache, CurrentExecutionState, ExecutionResult, FinishedL1Batch, L1BatchEnv, + Refunds, SystemEnv, VmExecutionLogs, VmExecutionResultAndLogs, VmExecutionStatistics, }; -use zksync_state::{OwnedStorage, StorageViewCache}; +use zksync_state::OwnedStorage; use zksync_test_account::Account; use zksync_types::{ fee::Fee, utils::storage_key_for_standard_token_balance, AccountTreeId, Address, Execute, diff --git a/core/node/state_keeper/src/tests/mod.rs b/core/node/state_keeper/src/tests/mod.rs index 2d0af7dd281b..a5239f444832 100644 --- a/core/node/state_keeper/src/tests/mod.rs +++ b/core/node/state_keeper/src/tests/mod.rs @@ -11,9 +11,9 @@ use zksync_config::configs::chain::StateKeeperConfig; use zksync_multivm::{ interface::{ ExecutionResult, Halt, L1BatchEnv, L2BlockEnv, Refunds, SystemEnv, TxExecutionMode, - VmExecutionResultAndLogs, VmExecutionStatistics, + VmExecutionLogs, VmExecutionResultAndLogs, VmExecutionStatistics, }, - vm_latest::{constants::BATCH_COMPUTATIONAL_GAS_LIMIT, VmExecutionLogs}, + vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, }; use zksync_node_test_utils::create_l2_transaction; use zksync_types::{ diff --git a/core/node/state_keeper/src/updates/mod.rs b/core/node/state_keeper/src/updates/mod.rs index e05432c57b21..b1310800d8ac 100644 --- a/core/node/state_keeper/src/updates/mod.rs +++ b/core/node/state_keeper/src/updates/mod.rs @@ -1,9 +1,10 @@ use zksync_contracts::BaseSystemContractsHashes; use zksync_multivm::{ - interface::{FinishedL1Batch, L1BatchEnv, SystemEnv, VmExecutionResultAndLogs}, + interface::{ + storage::StorageViewCache, FinishedL1Batch, L1BatchEnv, SystemEnv, VmExecutionResultAndLogs, + }, utils::get_batch_base_fee, }; -use zksync_state::StorageViewCache; use zksync_types::{ block::BlockGasCount, fee_model::BatchFeeInput, storage_writes_deduplicator::StorageWritesDeduplicator, diff --git a/core/node/vm_runner/src/storage.rs b/core/node/vm_runner/src/storage.rs index 1c83b6525c7b..b7518903cae3 100644 --- a/core/node/vm_runner/src/storage.rs +++ b/core/node/vm_runner/src/storage.rs @@ -9,7 +9,7 @@ use anyhow::Context as _; use async_trait::async_trait; use tokio::sync::{watch, RwLock}; use zksync_dal::{Connection, ConnectionPool, Core, CoreDal}; -use zksync_multivm::{interface::L1BatchEnv, vm_1_4_2::SystemEnv}; +use zksync_multivm::interface::{L1BatchEnv, SystemEnv}; use zksync_state::{ AsyncCatchupTask, BatchDiff, OwnedPostgresStorage, OwnedStorage, PgOrRocksdbStorage, RocksdbCell, RocksdbStorage, RocksdbStorageBuilder, RocksdbWithMemory, diff --git a/core/node/vm_runner/src/tests/storage.rs b/core/node/vm_runner/src/tests/storage.rs index 90aeda335e1d..1dfb5a60135a 100644 --- a/core/node/vm_runner/src/tests/storage.rs +++ b/core/node/vm_runner/src/tests/storage.rs @@ -9,7 +9,7 @@ use tokio::{ }; use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_node_genesis::{insert_genesis_batch, GenesisParams}; -use zksync_state::{OwnedStorage, PostgresStorage, ReadStorage}; +use zksync_state::{interface::ReadStorage, OwnedStorage, PostgresStorage}; use zksync_test_account::Account; use zksync_types::{AccountTreeId, L1BatchNumber, L2ChainId, StorageKey}; diff --git a/core/tests/vm-benchmark/harness/src/instruction_counter.rs b/core/tests/vm-benchmark/harness/src/instruction_counter.rs index 017b13da44ca..28e6d1519656 100644 --- a/core/tests/vm-benchmark/harness/src/instruction_counter.rs +++ b/core/tests/vm-benchmark/harness/src/instruction_counter.rs @@ -1,10 +1,10 @@ use std::{cell::RefCell, rc::Rc}; use zksync_multivm::{ - interface::{dyn_tracers::vm_1_5_0::DynTracer, tracer::TracerExecutionStatus}, + interface::{storage::WriteStorage, tracer::TracerExecutionStatus}, + tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState}, }; -use zksync_state::WriteStorage; pub struct InstructionCounter { count: usize, diff --git a/core/tests/vm-benchmark/harness/src/lib.rs b/core/tests/vm-benchmark/harness/src/lib.rs index a30221cfa0be..f206728d40bb 100644 --- a/core/tests/vm-benchmark/harness/src/lib.rs +++ b/core/tests/vm-benchmark/harness/src/lib.rs @@ -4,13 +4,13 @@ use once_cell::sync::Lazy; use zksync_contracts::{deployer_contract, BaseSystemContracts}; use zksync_multivm::{ interface::{ - L2BlockEnv, TxExecutionMode, VmExecutionMode, VmExecutionResultAndLogs, VmInterface, + storage::InMemoryStorage, L2BlockEnv, TxExecutionMode, VmExecutionMode, + VmExecutionResultAndLogs, VmInterface, }, utils::get_max_gas_per_pubdata_byte, vm_fast::Vm, vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, }; -use zksync_state::InMemoryStorage; use zksync_types::{ block::L2BlockHasher, ethabi::{encode, Token}, diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 772e30eb7fa1..a7249ca9ffc0 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -332,18 +332,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "backon" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d67782c3f868daa71d3533538e98a8e13713231969def7536e8039606fc46bf0" -dependencies = [ - "fastrand", - "futures-core", - "pin-project", - "tokio", -] - [[package]] name = "backtrace" version = "0.3.72" @@ -800,12 +788,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "bytecount" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" - [[package]] name = "byteorder" version = "1.5.0" @@ -829,37 +811,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "camino" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", -] - [[package]] name = "cc" version = "1.0.98" @@ -1555,19 +1506,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if 1.0.0", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "debugid" version = "0.8.0" @@ -1914,15 +1852,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "error-chain" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -dependencies = [ - "version_check", -] - [[package]] name = "etcetera" version = "0.8.0" @@ -3502,21 +3431,6 @@ dependencies = [ "unicase", ] -[[package]] -name = "mini-moka" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c325dfab65f261f386debee8b0969da215b3fa0037e74c8a1234db7ba986d803" -dependencies = [ - "crossbeam-channel 0.5.13", - "crossbeam-utils 0.8.20", - "dashmap", - "skeptic", - "smallvec", - "tagptr", - "triomphe", -] - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -4562,17 +4476,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "pulldown-cmark" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" -dependencies = [ - "bitflags 2.6.0", - "memchr", - "unicase", -] - [[package]] name = "quick-error" version = "1.2.3" @@ -5298,9 +5201,6 @@ name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" -dependencies = [ - "serde", -] [[package]] name = "send_wrapper" @@ -5679,21 +5579,6 @@ dependencies = [ "time", ] -[[package]] -name = "skeptic" -version = "0.13.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8" -dependencies = [ - "bytecount", - "cargo_metadata", - "error-chain", - "glob", - "pulldown-cmark", - "tempfile", - "walkdir", -] - [[package]] name = "slab" version = "0.4.9" @@ -6173,12 +6058,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tagptr" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" - [[package]] name = "tap" version = "1.0.1" @@ -6622,12 +6501,6 @@ dependencies = [ "tracing-serde", ] -[[package]] -name = "triomphe" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b2cb4fbb9995eeb36ac86fadf24031ccd58f99d6b4b2d7b911db70bddb80d90" - [[package]] name = "try-lock" version = "0.2.5" @@ -8014,7 +7887,6 @@ dependencies = [ "itertools 0.10.5", "once_cell", "pretty_assertions", - "serde", "thiserror", "tracing", "vise", @@ -8025,10 +7897,10 @@ dependencies = [ "zk_evm 0.141.0", "zk_evm 0.150.0", "zksync_contracts", - "zksync_state", "zksync_system_constants", "zksync_types", "zksync_utils", + "zksync_vm_interface", ] [[package]] @@ -8274,7 +8146,6 @@ dependencies = [ "strum", "zksync_multivm", "zksync_object_store", - "zksync_state", "zksync_types", ] @@ -8290,38 +8161,6 @@ dependencies = [ "zksync_utils", ] -[[package]] -name = "zksync_shared_metrics" -version = "0.1.0" -dependencies = [ - "rustc_version", - "tracing", - "vise", - "zksync_dal", - "zksync_types", -] - -[[package]] -name = "zksync_state" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "backon", - "chrono", - "itertools 0.10.5", - "mini-moka", - "once_cell", - "tokio", - "tracing", - "vise", - "zksync_dal", - "zksync_shared_metrics", - "zksync_storage", - "zksync_types", - "zksync_utils", -] - [[package]] name = "zksync_storage" version = "0.1.0" @@ -8423,6 +8262,20 @@ dependencies = [ "vise-exporter", ] +[[package]] +name = "zksync_vm_interface" +version = "0.1.0" +dependencies = [ + "hex", + "serde", + "thiserror", + "tracing", + "zksync_contracts", + "zksync_system_constants", + "zksync_types", + "zksync_utils", +] + [[package]] name = "zksync_web3_decl" version = "0.1.0" @@ -8476,7 +8329,6 @@ dependencies = [ "zksync_prover_fri_utils", "zksync_prover_interface", "zksync_queued_job_processor", - "zksync_state", "zksync_system_constants", "zksync_types", "zksync_utils", diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 8e808f63d83c..8be6f3552230 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -75,7 +75,6 @@ zksync_env_config = { path = "../core/lib/env_config" } zksync_object_store = { path = "../core/lib/object_store" } zksync_prover_interface = { path = "../core/lib/prover_interface" } zksync_queued_job_processor = { path = "../core/lib/queued_job_processor" } -zksync_state = { path = "../core/lib/state" } zksync_system_constants = { path = "../core/lib/constants" } zksync_types = { path = "../core/lib/types" } zksync_utils = { path = "../core/lib/utils" } diff --git a/prover/crates/bin/witness_generator/Cargo.toml b/prover/crates/bin/witness_generator/Cargo.toml index 7eb75bb3d82f..cffb55906065 100644 --- a/prover/crates/bin/witness_generator/Cargo.toml +++ b/prover/crates/bin/witness_generator/Cargo.toml @@ -21,7 +21,6 @@ zksync_queued_job_processor.workspace = true zksync_multivm.workspace = true zksync_object_store.workspace = true zksync_types.workspace = true -zksync_state.workspace = true zksync_utils.workspace = true vk_setup_data_generator_server_fri.workspace = true zksync_prover_fri_types.workspace = true diff --git a/prover/crates/bin/witness_generator/src/basic_circuits.rs b/prover/crates/bin/witness_generator/src/basic_circuits.rs index dc2506446418..75326ace7f6b 100644 --- a/prover/crates/bin/witness_generator/src/basic_circuits.rs +++ b/prover/crates/bin/witness_generator/src/basic_circuits.rs @@ -16,8 +16,9 @@ use tokio::sync::Semaphore; use tracing::Instrument; use zkevm_test_harness::geometry_config::get_geometry_config; use zksync_config::configs::FriWitnessGeneratorConfig; -use zksync_multivm::vm_latest::{ - constants::MAX_CYCLES_FOR_TX, HistoryDisabled, StorageOracle as VmStorageOracle, +use zksync_multivm::{ + interface::storage::StorageView, + vm_latest::{constants::MAX_CYCLES_FOR_TX, HistoryDisabled, StorageOracle as VmStorageOracle}, }; use zksync_object_store::ObjectStore; use zksync_prover_dal::{ConnectionPool, Prover, ProverDal}; @@ -38,7 +39,6 @@ use zksync_prover_fri_types::{ use zksync_prover_fri_utils::get_recursive_layer_circuit_id_for_base_layer; use zksync_prover_interface::inputs::WitnessInputData; use zksync_queued_job_processor::JobProcessor; -use zksync_state::{StorageView, WitnessStorage}; use zksync_types::{ basic_fri_types::AggregationRound, protocol_version::ProtocolSemanticVersion, Address, L1BatchNumber, BOOTLOADER_ADDRESS, @@ -52,6 +52,7 @@ use crate::{ expand_bootloader_contents, save_circuit, ClosedFormInputWrapper, SchedulerPartialInputWrapper, KZG_TRUSTED_SETUP_FILE, }, + witness::WitnessStorage, }; pub struct BasicCircuitArtifacts { diff --git a/prover/crates/bin/witness_generator/src/lib.rs b/prover/crates/bin/witness_generator/src/lib.rs index a80f06312d12..00d2ebf2bb3d 100644 --- a/prover/crates/bin/witness_generator/src/lib.rs +++ b/prover/crates/bin/witness_generator/src/lib.rs @@ -3,14 +3,13 @@ pub mod basic_circuits; pub mod leaf_aggregation; +pub mod metrics; pub mod node_aggregation; pub mod precalculated_merkle_paths_provider; pub mod recursion_tip; pub mod scheduler; mod storage_oracle; -pub mod utils; - -pub mod metrics; - #[cfg(test)] mod tests; +pub mod utils; +mod witness; diff --git a/prover/crates/bin/witness_generator/src/main.rs b/prover/crates/bin/witness_generator/src/main.rs index d3b828b06558..e914d3742b5b 100644 --- a/prover/crates/bin/witness_generator/src/main.rs +++ b/prover/crates/bin/witness_generator/src/main.rs @@ -5,6 +5,8 @@ use std::time::{Duration, Instant}; use anyhow::{anyhow, Context as _}; use futures::{channel::mpsc, executor::block_on, SinkExt, StreamExt}; +#[cfg(not(target_env = "msvc"))] +use jemallocator::Jemalloc; use structopt::StructOpt; use tokio::sync::watch; use zksync_core_leftovers::temp_config_store::{load_database_secrets, load_general_config}; @@ -17,26 +19,12 @@ use zksync_types::basic_fri_types::AggregationRound; use zksync_utils::wait_for_tasks::ManagedTasks; use zksync_vk_setup_data_server_fri::commitment_utils::get_cached_commitments; use zksync_vlog::prometheus::PrometheusExporterConfig; - -use crate::{ +use zksync_witness_generator::{ basic_circuits::BasicWitnessGenerator, leaf_aggregation::LeafAggregationWitnessGenerator, metrics::SERVER_METRICS, node_aggregation::NodeAggregationWitnessGenerator, recursion_tip::RecursionTipWitnessGenerator, scheduler::SchedulerWitnessGenerator, }; -mod basic_circuits; -mod leaf_aggregation; -mod metrics; -mod node_aggregation; -mod precalculated_merkle_paths_provider; -mod recursion_tip; -mod scheduler; -mod storage_oracle; -mod utils; - -#[cfg(not(target_env = "msvc"))] -use jemallocator::Jemalloc; - #[cfg(not(target_env = "msvc"))] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; diff --git a/core/lib/state/src/witness.rs b/prover/crates/bin/witness_generator/src/witness.rs similarity index 96% rename from core/lib/state/src/witness.rs rename to prover/crates/bin/witness_generator/src/witness.rs index 5965f3c11884..8bedf5657e09 100644 --- a/core/lib/state/src/witness.rs +++ b/prover/crates/bin/witness_generator/src/witness.rs @@ -1,7 +1,6 @@ +use zksync_multivm::interface::storage::ReadStorage; use zksync_types::{witness_block_state::WitnessStorageState, StorageKey, StorageValue, H256}; -use crate::ReadStorage; - /// [`ReadStorage`] implementation backed by binary serialized [`WitnessHashBlockState`]. /// Note that `load_factory_deps` is not used. /// FactoryDeps data is used straight inside witness generator, loaded with the blob. diff --git a/prover/crates/bin/witness_generator/tests/basic_test.rs b/prover/crates/bin/witness_generator/tests/basic_test.rs index d9ac679ab647..f8a21179adb7 100644 --- a/prover/crates/bin/witness_generator/tests/basic_test.rs +++ b/prover/crates/bin/witness_generator/tests/basic_test.rs @@ -15,8 +15,7 @@ use zksync_types::{ }; use zksync_witness_generator::{ leaf_aggregation::{prepare_leaf_aggregation_job, LeafAggregationWitnessGenerator}, - node_aggregation, - node_aggregation::NodeAggregationWitnessGenerator, + node_aggregation::{self, NodeAggregationWitnessGenerator}, utils::AggregationWrapper, };