Skip to content

Commit

Permalink
fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
tomg10 committed Nov 18, 2024
1 parent a1ac032 commit 165ce18
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 33 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/lib/dal/src/eth_sender_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
3 changes: 0 additions & 3 deletions core/lib/vm_executor/src/oneshot/block.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
15 changes: 9 additions & 6 deletions core/node/l1_recovery/src/l1_fetcher/l1_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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::{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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::{
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand Down
3 changes: 1 addition & 2 deletions core/node/l1_recovery/src/l1_fetcher/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
1 change: 0 additions & 1 deletion core/node/l1_recovery/src/processor/db_recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
11 changes: 5 additions & 6 deletions core/node/l1_recovery/src/processor/genesis.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -101,15 +100,15 @@ pub fn get_genesis_factory_deps() -> Vec<Vec<u8>> {
let mut hashes: HashSet<H256> = HashSet::new();
let mut bytecodes: Vec<Vec<u8>> = 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
Expand Down
1 change: 0 additions & 1 deletion core/node/l1_recovery/src/processor/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
5 changes: 3 additions & 2 deletions core/node/l1_recovery/src/processor/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion core/node/l1_recovery/src/processor/tree/tree_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
5 changes: 2 additions & 3 deletions core/node/l1_recovery/src/storage/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 1 addition & 4 deletions zkstack_cli/crates/zkstack/src/commands/args/run_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 165ce18

Please sign in to comment.