From 165ce189441b9e7759a4b2bc7aa29330662d67a6 Mon Sep 17 00:00:00 2001 From: tomg10 Date: Mon, 18 Nov 2024 02:43:18 +0100 Subject: [PATCH] fixes after rebase --- Cargo.lock | 5 ++--- core/lib/dal/src/eth_sender_dal.rs | 2 +- core/lib/vm_executor/src/oneshot/block.rs | 3 --- .../node/l1_recovery/src/l1_fetcher/l1_fetcher.rs | 15 +++++++++------ core/node/l1_recovery/src/l1_fetcher/types/mod.rs | 3 +-- .../node/l1_recovery/src/processor/db_recovery.rs | 1 - core/node/l1_recovery/src/processor/genesis.rs | 11 +++++------ .../l1_recovery/src/processor/snapshot/mod.rs | 1 - core/node/l1_recovery/src/processor/tree/mod.rs | 5 +++-- .../src/processor/tree/tree_wrapper.rs | 1 - core/node/l1_recovery/src/storage/snapshot.rs | 5 ++--- .../zkstack/src/commands/args/run_server.rs | 5 +---- 12 files changed, 24 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6137b5cf7f71..8e98f3c8e55b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4348,7 +4348,6 @@ dependencies = [ "equivalent", "hashbrown 0.15.0", "serde", - "serde", ] [[package]] @@ -11896,9 +11895,9 @@ dependencies = [ "clap 4.5.20", "ethabi", "hex", - "indexmap 2.5.0", + "indexmap 2.6.0", "rand 0.8.5", - "reqwest 0.12.7", + "reqwest 0.12.9", "rocksdb", "serde", "serde_json", diff --git a/core/lib/dal/src/eth_sender_dal.rs b/core/lib/dal/src/eth_sender_dal.rs index ee896a484b54..828fda2ca6a6 100644 --- a/core/lib/dal/src/eth_sender_dal.rs +++ b/core/lib/dal/src/eth_sender_dal.rs @@ -492,8 +492,8 @@ impl EthSenderDal<'_, '_> { "INSERT INTO eth_txs (raw_tx, nonce, tx_type, contract_address, predicted_gas_cost, created_at, updated_at) \ VALUES ('\\x00', 0, $1, $2, 0, now(), now()) \ RETURNING id", + tx_type.to_string(), format!("{:#x}", H160::zero()), - tx_type.to_string() ) .fetch_one(transaction.conn()) .await?; diff --git a/core/lib/vm_executor/src/oneshot/block.rs b/core/lib/vm_executor/src/oneshot/block.rs index 9aff7311018a..75191d943694 100644 --- a/core/lib/vm_executor/src/oneshot/block.rs +++ b/core/lib/vm_executor/src/oneshot/block.rs @@ -1,8 +1,5 @@ use std::time::SystemTime; -use std::str::FromStr; -use std::time::SystemTime; - use anyhow::Context; use zksync_dal::{Connection, Core, CoreDal, DalError}; use zksync_multivm::{ diff --git a/core/node/l1_recovery/src/l1_fetcher/l1_fetcher.rs b/core/node/l1_recovery/src/l1_fetcher/l1_fetcher.rs index 1c52e1f538f5..e8d18380b600 100644 --- a/core/node/l1_recovery/src/l1_fetcher/l1_fetcher.rs +++ b/core/node/l1_recovery/src/l1_fetcher/l1_fetcher.rs @@ -6,6 +6,7 @@ use rand::random; use thiserror::Error; use tokio::time::{sleep, Duration}; use zksync_basic_types::{ + bytecode::BytecodeHash, protocol_version::{L1VerifierConfig, ProtocolSemanticVersion}, web3::{contract::Tokenizable, BlockId, BlockNumber, FilterBuilder, Log, Transaction}, Address, L1BatchNumber, PriorityOpId, H256, U256, U64, @@ -15,7 +16,7 @@ use zksync_dal::eth_watcher_dal::EventType; use zksync_eth_client::{CallFunctionArgs, EthInterface}; use zksync_l1_contract_interface::i_executor::structures::StoredBatchInfo; use zksync_types::{l1::L1Tx, ProtocolVersion}; -use zksync_utils::{bytecode::hash_bytecode, env::Workspace}; +use zksync_utils::env::Workspace; use zksync_web3_decl::client::{DynClient, L1}; use crate::l1_fetcher::{ @@ -464,7 +465,7 @@ impl L1Fetcher { .priority_ops_onchain_data .push(priority_tx.common_data.onchain_data()); for factory_dep in &priority_tx.execute.factory_deps { - let hashed = hash_bytecode(factory_dep); + let hashed = BytecodeHash::for_bytecode(factory_dep).value(); if factory_deps_hashes.contains_key(&hashed) { continue; } else { @@ -695,9 +696,11 @@ mod tests { use std::{num::NonZero, str::FromStr, sync::Arc}; use tempfile::TempDir; - use zksync_basic_types::{url::SensitiveUrl, web3::keccak256, L1BatchNumber, H256, U64}; + use zksync_basic_types::{ + bytecode::BytecodeHash, url::SensitiveUrl, web3::keccak256, L1BatchNumber, H256, U64, + }; use zksync_dal::{ConnectionPool, Core}; - use zksync_utils::{bytecode::hash_bytecode, env::Workspace}; + use zksync_utils::env::Workspace; use zksync_web3_decl::client::{Client, DynClient, L1}; use crate::{ @@ -760,7 +763,7 @@ mod tests { let block = &blocks[0]; assert_eq!(9, block.factory_deps.len()); assert_eq!( - hash_bytecode(&block.factory_deps[0]), + BytecodeHash::for_bytecode(&block.factory_deps[0]).value(), H256::from_str("0x010000418c2c6cddb87cc900cb58ff9fd387862d6f77d4e7d40dc35694ba1ae4") .unwrap() ); @@ -790,7 +793,7 @@ mod tests { let block = &blocks[0]; assert_eq!(6, block.factory_deps.len()); assert_eq!( - hash_bytecode(&block.factory_deps[0]), + BytecodeHash::for_bytecode(&block.factory_deps[0]).value(), H256::from_str("0x0100009ffa898e7aa96817a2267079a0c8e92ce719b16b2be4cb17a4db04b0e2") .unwrap() ); diff --git a/core/node/l1_recovery/src/l1_fetcher/types/mod.rs b/core/node/l1_recovery/src/l1_fetcher/types/mod.rs index 32ba53695c5d..8c0314337c31 100644 --- a/core/node/l1_recovery/src/l1_fetcher/types/mod.rs +++ b/core/node/l1_recovery/src/l1_fetcher/types/mod.rs @@ -4,9 +4,8 @@ use ethabi; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use thiserror::Error; -use zksync_basic_types::{web3::keccak256, Address, H160, H256, U256}; +use zksync_basic_types::{u256_to_h256, web3::keccak256, Address, H160, H256, U256}; use zksync_types::{priority_op_onchain_data::PriorityOpOnchainData, L2_TO_L1_LOGS_TREE_ROOT_KEY}; -use zksync_utils::u256_to_h256; use self::{v1::V1, v2::V2, v3::V3}; use crate::{ diff --git a/core/node/l1_recovery/src/processor/db_recovery.rs b/core/node/l1_recovery/src/processor/db_recovery.rs index d26393250375..79519fdd9127 100644 --- a/core/node/l1_recovery/src/processor/db_recovery.rs +++ b/core/node/l1_recovery/src/processor/db_recovery.rs @@ -26,7 +26,6 @@ use zksync_types::{ SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, SYSTEM_CONTEXT_STORED_L2_BLOCK_HASHES, }; -use zksync_utils::{h256_to_u256, u256_to_h256}; use zksync_vm_interface::{ CircuitStatistic, L2Block, TransactionExecutionResult, TxExecutionStatus, VmExecutionMetrics, }; diff --git a/core/node/l1_recovery/src/processor/genesis.rs b/core/node/l1_recovery/src/processor/genesis.rs index 5cf5f61901f8..79103348f259 100644 --- a/core/node/l1_recovery/src/processor/genesis.rs +++ b/core/node/l1_recovery/src/processor/genesis.rs @@ -1,12 +1,11 @@ use std::{collections::HashSet, fs, path::PathBuf, str::FromStr}; use serde_json::Value; -use zksync_basic_types::{Address, H160, H256, U256}; +use zksync_basic_types::{bytecode::BytecodeHash, Address, H160, H256, U256}; use zksync_contracts::BaseSystemContracts; use zksync_merkle_tree::TreeEntry; use zksync_node_genesis::get_storage_logs; use zksync_types::system_contracts::get_system_smart_contracts; -use zksync_utils::{be_words_to_bytes, bytecode::hash_bytecode}; use crate::utils::derive_final_address_for_params; @@ -101,15 +100,15 @@ pub fn get_genesis_factory_deps() -> Vec> { let mut hashes: HashSet = HashSet::new(); let mut bytecodes: Vec> = vec![]; for contract in &contracts { - if hashes.contains(&hash_bytecode(&contract.bytecode)) { + if hashes.contains(&BytecodeHash::for_bytecode(&contract.bytecode).value()) { continue; } bytecodes.push(contract.bytecode.clone()); - hashes.insert(hash_bytecode(&contract.bytecode)); + hashes.insert(BytecodeHash::for_bytecode(&contract.bytecode).value()); } let base_contracts = BaseSystemContracts::load_from_disk(); - bytecodes.push(be_words_to_bytes(&base_contracts.bootloader.code.clone())); - bytecodes.push(be_words_to_bytes(&base_contracts.default_aa.code.clone())); + bytecodes.push(base_contracts.bootloader.code.clone()); + bytecodes.push(base_contracts.default_aa.code.clone()); tracing::info!("Found {} system contracts", bytecodes.len()); bytecodes diff --git a/core/node/l1_recovery/src/processor/snapshot/mod.rs b/core/node/l1_recovery/src/processor/snapshot/mod.rs index 483e2ccef6c7..3405d882d055 100644 --- a/core/node/l1_recovery/src/processor/snapshot/mod.rs +++ b/core/node/l1_recovery/src/processor/snapshot/mod.rs @@ -6,7 +6,6 @@ use zksync_types::{ snapshots::{SnapshotFactoryDependency, SnapshotStorageLog}, StorageKey, SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, }; -use zksync_utils::h256_to_u256; use zksync_vm_interface::L2Block; use crate::{ diff --git a/core/node/l1_recovery/src/processor/tree/mod.rs b/core/node/l1_recovery/src/processor/tree/mod.rs index d7d059e3bf39..5a074c956ab9 100644 --- a/core/node/l1_recovery/src/processor/tree/mod.rs +++ b/core/node/l1_recovery/src/processor/tree/mod.rs @@ -4,14 +4,15 @@ use std::{path::PathBuf, sync::Arc}; use anyhow::Result; use tokio::sync::Mutex; -use zksync_basic_types::{web3::keccak256, AccountTreeId, L2BlockNumber, H256, U256}; +use zksync_basic_types::{ + h256_to_u256, u256_to_h256, web3::keccak256, AccountTreeId, L2BlockNumber, H256, U256, +}; use zksync_merkle_tree::TreeEntry; use zksync_types::{ block::unpack_block_info, snapshots::SnapshotStorageLog, StorageKey, SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_HASHES_POSITION, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, SYSTEM_CONTEXT_CURRENT_TX_ROLLING_HASH_POSITION, SYSTEM_CONTEXT_STORED_L2_BLOCK_HASHES, }; -use zksync_utils::{h256_to_u256, u256_to_h256}; use zksync_vm_interface::L2Block; use self::tree_wrapper::TreeWrapper; diff --git a/core/node/l1_recovery/src/processor/tree/tree_wrapper.rs b/core/node/l1_recovery/src/processor/tree/tree_wrapper.rs index a517ae810dd0..bff235119c64 100644 --- a/core/node/l1_recovery/src/processor/tree/tree_wrapper.rs +++ b/core/node/l1_recovery/src/processor/tree/tree_wrapper.rs @@ -11,7 +11,6 @@ use zksync_basic_types::{H256, U256}; use zksync_merkle_tree::{Database, Key, MerkleTree, RocksDBWrapper, TreeEntry}; use zksync_storage::{RocksDB, RocksDBOptions}; use zksync_types::{snapshots::SnapshotStorageLog, StorageKey}; -use zksync_utils::h256_to_u256; use super::RootHash; use crate::{ diff --git a/core/node/l1_recovery/src/storage/snapshot.rs b/core/node/l1_recovery/src/storage/snapshot.rs index 84e83be439ee..90e1e07df978 100644 --- a/core/node/l1_recovery/src/storage/snapshot.rs +++ b/core/node/l1_recovery/src/storage/snapshot.rs @@ -2,9 +2,8 @@ use std::{ops::Deref, path::PathBuf}; use anyhow::Result; use rocksdb::{Options, DB}; -use zksync_basic_types::{H256, U256, U64}; +use zksync_basic_types::{bytecode::BytecodeHash, H256, U256, U64}; use zksync_types::snapshots::{SnapshotFactoryDependency, SnapshotStorageLog}; -use zksync_utils::bytecode; use crate::storage::{ snapshot_columns, DatabaseError, PackingType, INDEX_TO_KEY_MAP, KEY_TO_INDEX_MAP, METADATA, @@ -153,7 +152,7 @@ impl SnapshotDatabase { // Unwrapping column family handle here is safe because presence of // those CFs is ensured in construction of this DB. let factory_deps = self.cf_handle(snapshot_columns::FACTORY_DEPS).unwrap(); - let bytecode_hash = bytecode::hash_bytecode(&fdep.bytecode.0); + let bytecode_hash = BytecodeHash::for_bytecode(&fdep.bytecode.0).value(); self.put_cf(factory_deps, bytecode_hash, bincode::serialize(&fdep)?) .map_err(Into::into) } diff --git a/zkstack_cli/crates/zkstack/src/commands/args/run_server.rs b/zkstack_cli/crates/zkstack/src/commands/args/run_server.rs index e210fb611a06..00cdfc588c04 100644 --- a/zkstack_cli/crates/zkstack/src/commands/args/run_server.rs +++ b/zkstack_cli/crates/zkstack/src/commands/args/run_server.rs @@ -5,11 +5,8 @@ use crate::{ commands::args::WaitArgs, messages::{ MSG_SERVER_ADDITIONAL_ARGS_HELP, MSG_SERVER_COMPONENTS_HELP, MSG_SERVER_GENESIS_HELP, - MSG_SERVER_URING_HELP, + MSG_SERVER_L1_RECOVERY_HELP, MSG_SERVER_URING_HELP, }, -use crate::messages::{ - MSG_SERVER_ADDITIONAL_ARGS_HELP, MSG_SERVER_BUILD_HELP, MSG_SERVER_COMPONENTS_HELP, - MSG_SERVER_GENESIS_HELP, MSG_SERVER_L1_RECOVERY_HELP, MSG_SERVER_URING_HELP, }; #[derive(Debug, Parser)]