Skip to content

Commit

Permalink
chore: update zksync deps (#605)
Browse files Browse the repository at this point in the history
* update zksync deps

* fmt

* bump tonic version

* clippy

* revert zksync-web3-rs
  • Loading branch information
nbaztec authored Oct 9, 2024
1 parent dac2eea commit 18896e6
Show file tree
Hide file tree
Showing 12 changed files with 903 additions and 996 deletions.
1,751 changes: 848 additions & 903 deletions Cargo.lock

Large diffs are not rendered by default.

56 changes: 10 additions & 46 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ axum.opt-level = 3
scrypt.opt-level = 3

# zksync
multivm.opt-level = 3
zksync_multivm.opt-level = 3

# Override packages which aren't perf-sensitive for faster compilation speed and smaller binary size.
[profile.release.package]
Expand Down Expand Up @@ -230,15 +230,16 @@ alloy-trie = "0.5.0"
op-alloy-rpc-types = "0.2.9"

## zksync
era_test_node = { git="https://github.com/matter-labs/era-test-node.git" , rev = "2041018903aa7e00e74c450f8c0baf799c056d86" }
era_test_node = { git="https://github.com/matter-labs/era-test-node.git" , rev = "ceee937055a5a373e27b0ff9bf2e42391de78c59" }
zksync-web3-rs = {git = "https://github.com/jrigada/zksync-web3-rs.git", rev = "bc3e6d3e75b7ff3747ff2dccefa9fb74d770931b"}
zksync_basic_types = { git = "https://github.com/Moonsong-Labs/zksync-era.git", branch = "foundry-zksync" }
zksync_types = { git = "https://github.com/Moonsong-Labs/zksync-era.git", branch = "foundry-zksync" }
zksync_state = { git = "https://github.com/Moonsong-Labs/zksync-era.git", branch = "foundry-zksync" }
multivm = { git = "https://github.com/Moonsong-Labs/zksync-era.git", branch = "foundry-zksync" }
zksync_web3_decl = { git = "https://github.com/Moonsong-Labs/zksync-era.git", branch = "foundry-zksync" }
zksync_utils = { git = "https://github.com/Moonsong-Labs/zksync-era.git", branch = "foundry-zksync" }
zksync_contracts = { git = "https://github.com/Moonsong-Labs/zksync-era.git", branch = "foundry-zksync" }
# zksync-web3-rs = {git = "https://github.com/lambdaclass/zksync-web3-rs.git", rev = "56653345d14331e0865a6785c77cdda63c94eeba"}
zksync_basic_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "7ad0425e00a44e0dd1c3abf38ab2f6335c2f86e7" }
zksync_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "7ad0425e00a44e0dd1c3abf38ab2f6335c2f86e7" }
zksync_state = { git = "https://github.com/matter-labs/zksync-era.git", rev = "7ad0425e00a44e0dd1c3abf38ab2f6335c2f86e7" }
zksync_multivm = { git = "https://github.com/matter-labs/zksync-era.git", rev = "7ad0425e00a44e0dd1c3abf38ab2f6335c2f86e7" }
zksync_web3_decl = { git = "https://github.com/matter-labs/zksync-era.git", rev = "7ad0425e00a44e0dd1c3abf38ab2f6335c2f86e7" }
zksync_utils = { git = "https://github.com/matter-labs/zksync-era.git", rev = "7ad0425e00a44e0dd1c3abf38ab2f6335c2f86e7" }
zksync_contracts = { git = "https://github.com/matter-labs/zksync-era.git", rev = "7ad0425e00a44e0dd1c3abf38ab2f6335c2f86e7" }

## misc
async-trait = "0.1"
Expand Down Expand Up @@ -296,40 +297,3 @@ tower-http = "0.5"
soldeer = "=0.3.4"
proptest = "1"
comfy-table = "7"

# [patch.crates-io]
# alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }

[patch.'https://github.com/matter-labs/zksync-era.git']
# era-test-node uses the original ones
zksync_state = { git = "http://github.com/Moonsong-Labs/zksync-era", branch = "foundry-zksync" }
multivm = { git = "http://github.com/Moonsong-Labs/zksync-era", branch = "foundry-zksync" }
zksync_basic_types = { git = "http://github.com/Moonsong-Labs/zksync-era", branch = "foundry-zksync" }
zksync_contracts = { git = "http://github.com/Moonsong-Labs/zksync-era", branch = "foundry-zksync" }
zksync_types = { git = "http://github.com/Moonsong-Labs/zksync-era", branch = "foundry-zksync" }
zksync_dal = { git = "http://github.com/Moonsong-Labs/zksync-era", branch = "foundry-zksync" }

[patch.'https://github.com/matter-labs/era-boojum.git']
boojum = "0.2.2"
2 changes: 1 addition & 1 deletion crates/zksync/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ serde.workspace = true
serde_json.workspace = true

# zk
multivm.workspace = true
zksync_multivm.workspace = true
zksync_basic_types.workspace = true
zksync_types.workspace = true
zksync-web3-rs.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/zksync/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ use serde::{Deserialize, Serialize};
pub use utils::{fix_l2_gas_limit, fix_l2_gas_price};
pub use vm::{balance, encode_create_params, nonce};

pub use zksync_multivm::interface::{Call, CallType};
use zksync_types::utils::storage_key_for_eth_balance;
pub use zksync_types::{
vm_trace::{Call, CallType},
ACCOUNT_CODE_STORAGE_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, H256, L2_BASE_TOKEN_ADDRESS,
NONCE_HOLDER_ADDRESS,
};
Expand Down
7 changes: 3 additions & 4 deletions crates/zksync/core/src/vm/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use alloy_primitives::{Address, U256 as rU256};
use foundry_cheatcodes_common::record::RecordAccess;
use revm::{primitives::Account, Database, EvmContext, InnerEvmContext};
use zksync_basic_types::{L2ChainId, H160, H256, U256};
use zksync_state::ReadStorage;
use zksync_state::interface::ReadStorage;
use zksync_types::{
get_code_key, get_nonce_key, get_system_context_init_logs,
utils::{decompose_full_nonce, storage_key_for_eth_balance},
Nonce, StorageKey, StorageLog, StorageLogKind, StorageValue,
Nonce, StorageKey, StorageLog, StorageValue,
};

use zksync_utils::{bytecode::hash_bytecode, h256_to_u256};
Expand Down Expand Up @@ -92,8 +92,7 @@ where
})
.chain(system_context_init_log)
.for_each(|log| {
(log.kind == StorageLogKind::Write)
.then_some(override_keys.insert(log.key, log.value));
(log.is_write()).then_some(override_keys.insert(log.key, log.value));
});

let mut factory_deps = contracts
Expand Down
15 changes: 6 additions & 9 deletions crates/zksync/core/src/vm/env.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use multivm::{
interface::{L1BatchEnv, L2BlockEnv, SystemEnv},
vm_latest::{
constants::BATCH_COMPUTATIONAL_GAS_LIMIT, utils::l2_blocks::load_last_l2_block,
TxExecutionMode,
},
};
use zksync_basic_types::{AccountTreeId, L1BatchNumber, L2BlockNumber, L2ChainId, H160};
use zksync_contracts::BaseSystemContracts;
use zksync_state::{ReadStorage, StoragePtr};
use zksync_multivm::{
interface::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode},
vm_latest::{constants::BATCH_COMPUTATIONAL_GAS_LIMIT, utils::l2_blocks::load_last_l2_block},
};
use zksync_state::interface::{ReadStorage, StoragePtr};
use zksync_types::{
block::{unpack_block_info, L2BlockHasher},
fee_model::L1PeggedBatchFeeModelInput,
Expand All @@ -20,7 +17,7 @@ pub(crate) fn create_l1_batch_env<ST: ReadStorage>(
l1_gas_price: u64,
fair_l2_gas_price: u64,
) -> L1BatchEnv {
let mut first_l2_block = if let Some(last_l2_block) = load_last_l2_block(storage.clone()) {
let mut first_l2_block = if let Some(last_l2_block) = load_last_l2_block(&storage) {
L2BlockEnv {
number: last_l2_block.number + 1,
timestamp: last_l2_block.timestamp + 1,
Expand Down
6 changes: 3 additions & 3 deletions crates/zksync/core/src/vm/farcall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use std::{collections::HashMap, default, fmt::Debug};

use alloy_primitives::{hex, Address};
use itertools::Itertools;
use multivm::{
use zksync_basic_types::{H160, U256};
use zksync_multivm::{
vm_1_3_2::zk_evm_1_3_3::zkevm_opcode_defs::RetABI,
vm_latest::{BootloaderState, HistoryMode, SimpleMemory, ZkSyncVmState},
zk_evm_latest::{
Expand All @@ -20,8 +21,7 @@ use multivm::{
},
},
};
use zksync_basic_types::{H160, U256};
use zksync_state::{StoragePtr, WriteStorage};
use zksync_state::interface::{StoragePtr, WriteStorage};
use zksync_types::MSG_VALUE_SIMULATOR_ADDRESS;

use crate::convert::{ConvertAddress, ConvertH256, ConvertU256};
Expand Down
35 changes: 18 additions & 17 deletions crates/zksync/core/src/vm/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ use era_test_node::{
utils::bytecode_to_factory_dep,
};
use itertools::Itertools;
use multivm::{
interface::{Halt, VmInterface, VmRevertReason},
tracers::CallTracer,
vm_latest::{
ExecutionResult, HistoryDisabled, ToTracerPointer, Vm, VmExecutionMode,
VmExecutionResultAndLogs,
},
};
use revm::{
db::states::StorageSlot,
primitives::{
Expand All @@ -25,10 +17,18 @@ use revm::{
};
use tracing::{debug, error, info, trace, warn};
use zksync_basic_types::{ethabi, L2ChainId, Nonce, H160, H256, U256};
use zksync_state::{ReadStorage, StoragePtr, WriteStorage};
use zksync_multivm::{
interface::{
Call, CallType, ExecutionResult, Halt, VmEvent, VmExecutionResultAndLogs, VmFactory,
VmInterface, VmRevertReason,
},
tracers::CallTracer,
vm_latest::{HistoryDisabled, ToTracerPointer, Vm},
};
use zksync_state::interface::{ReadStorage, StoragePtr, WriteStorage};
use zksync_types::{
l2::L2Tx, vm_trace::Call, PackedEthSignature, StorageKey, Transaction, VmEvent,
ACCOUNT_CODE_STORAGE_ADDRESS, CONTRACT_DEPLOYER_ADDRESS,
l2::L2Tx, PackedEthSignature, StorageKey, Transaction, ACCOUNT_CODE_STORAGE_ADDRESS,
CONTRACT_DEPLOYER_ADDRESS,
};
use zksync_utils::{be_words_to_bytes, h256_to_account_address, h256_to_u256, u256_to_h256};

Expand Down Expand Up @@ -430,7 +430,6 @@ fn inspect_inner<S: ReadStorage>(

let tx: Transaction = l2_tx.clone().into();

vm.push_transaction(tx.clone());
let call_tracer_result = Arc::default();
let cheatcode_tracer_result = Arc::default();
let mut expected_calls = HashMap::<_, _>::new();
Expand All @@ -455,7 +454,10 @@ fn inspect_inner<S: ReadStorage>(
)
.into_tracer_pointer(),
];
let mut tx_result = vm.inspect(tracers.into(), VmExecutionMode::OneTx);
let (compressed_bytecodes, mut tx_result) =
vm.inspect_transaction_with_bytecode_compression(&mut tracers.into(), tx, true);
let compressed_bytecodes = compressed_bytecodes.expect("failed compressing bytecodes");

let mut call_traces = Arc::try_unwrap(call_tracer_result).unwrap().take().unwrap_or_default();
trace!(?tx_result.result, "zk vm result");

Expand Down Expand Up @@ -540,8 +542,7 @@ fn inspect_inner<S: ReadStorage>(
formatter::print_event(event, resolve_hashes);
}

let bytecodes = vm
.get_last_tx_compressed_bytecodes()
let bytecodes = compressed_bytecodes
.iter()
.map(|b| {
bytecode_to_factory_dep(b.original.clone())
Expand Down Expand Up @@ -606,7 +607,7 @@ fn call_traces_patch_create<S: ReadStorage>(
storage: StoragePtr<StorageView<S>>,
call: &mut Call,
) {
if matches!(call.r#type, zksync_types::vm_trace::CallType::Create) {
if matches!(call.r#type, CallType::Create) {
if let Some(hash) = deployed_bytecode_hashes.get(&call.to).cloned() {
let maybe_bytecode = bytecodes
.get(&h256_to_u256(hash))
Expand Down Expand Up @@ -767,7 +768,7 @@ fn split_tx_by_factory_deps(mut tx: L2Tx) -> Vec<L2Tx> {
let mut txs = Vec::with_capacity(batched.len() + 1);
for deps in batched.into_iter() {
txs.push(L2Tx::new(
H160::zero(),
Some(H160::zero()),
Vec::default(),
tx.common_data.nonce,
tx.common_data.fee.clone(),
Expand Down
6 changes: 3 additions & 3 deletions crates/zksync/core/src/vm/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
let (gas_limit, max_fee_per_gas) = gas_params(&mut ecx, caller, &PaymasterParams::default());
debug!(?gas_limit, ?max_fee_per_gas, "tx gas parameters");
let tx = L2Tx::new(
transact_to,
Some(transact_to),
env.tx.data.to_vec(),
nonce,
Fee {
Expand Down Expand Up @@ -147,7 +147,7 @@ where
info!(?gas_limit, ?max_fee_per_gas, "tx gas parameters");

let tx = L2Tx::new(
CONTRACT_DEPLOYER_ADDRESS,
Some(CONTRACT_DEPLOYER_ADDRESS),
calldata,
nonce,
Fee {
Expand Down Expand Up @@ -206,7 +206,7 @@ where
info!(?gas_limit, ?max_fee_per_gas, "tx gas parameters");

let tx = L2Tx::new(
call.bytecode_address.to_h160(),
Some(call.bytecode_address.to_h160()),
call.input.to_vec(),
nonce,
Fee {
Expand Down
4 changes: 2 additions & 2 deletions crates/zksync/core/src/vm/storage_view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{cell::RefCell, collections::HashMap, fmt, rc::Rc};

use zksync_state::{ReadStorage, WriteStorage};
use zksync_state::interface::{ReadStorage, WriteStorage};
use zksync_types::{StorageKey, StorageValue, ACCOUNT_CODE_STORAGE_ADDRESS, H160, H256};

use crate::convert::ConvertH160;
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<S: ReadStorage + fmt::Debug> WriteStorage for StorageView<S> {
#[cfg(test)]
mod test {
use super::*;
use zksync_state::InMemoryStorage;
use zksync_state::interface::InMemoryStorage;
use zksync_types::{AccountTreeId, Address, H256};

#[test]
Expand Down
9 changes: 5 additions & 4 deletions crates/zksync/core/src/vm/tracers/cheatcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ use foundry_cheatcodes_common::{
mock::{MockCallDataContext, MockCallReturnData},
record::RecordAccess,
};
use multivm::{
interface::{dyn_tracers::vm_1_5_0::DynTracer, tracer::TracerExecutionStatus},
use zksync_multivm::{
interface::tracer::TracerExecutionStatus,
tracers::dynamic::vm_1_5_0::DynTracer,
vm_latest::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState},
zk_evm_latest::{
tracing::{AfterDecodingData, AfterExecutionData, BeforeExecutionData, VmLocalStateData},
zkevm_opcode_defs::{FatPointer, Opcode, CALL_IMPLICIT_CALLDATA_FAT_PTR_REGISTER},
},
};
use zksync_state::{ReadStorage, StoragePtr, WriteStorage};
use zksync_state::interface::{ReadStorage, StoragePtr, WriteStorage};
use zksync_types::{
get_code_key, StorageValue, BOOTLOADER_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, H256,
SYSTEM_CONTEXT_ADDRESS, U256,
Expand Down Expand Up @@ -393,7 +394,7 @@ impl<S: WriteStorage, H: HistoryMode> VmTracer<S, H> for CheatcodeTracer {
&mut self,
_state: &mut ZkSyncVmState<S, H>,
_bootloader_state: &BootloaderState,
_stop_reason: multivm::interface::tracer::VmExecutionStopReason,
_stop_reason: zksync_multivm::interface::tracer::VmExecutionStopReason,
) {
let cell = self.result.as_ref();
cell.set(CheatcodeTracerResult { expected_calls: self.expected_calls.clone() }).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions crates/zksync/core/src/vm/tracers/error.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use multivm::{
interface::dyn_tracers::vm_1_5_0::DynTracer,
use zksync_multivm::{
tracers::dynamic::vm_1_5_0::DynTracer,
vm_latest::{HistoryMode, SimpleMemory, VmTracer},
zk_evm_latest::{
tracing::{AfterDecodingData, VmLocalStateData},
vm_state::ErrorFlags,
},
};
use zksync_state::{ReadStorage, WriteStorage};
use zksync_state::interface::{ReadStorage, WriteStorage};

/// A tracer to allow logging low-level vm errors.
#[derive(Debug, Default)]
Expand Down

0 comments on commit 18896e6

Please sign in to comment.