Skip to content

Commit

Permalink
refactor: Clean up dependencies (#370)
Browse files Browse the repository at this point in the history
* refactor: Clean up dependencies

* Cargo fmt

* Fix tests
  • Loading branch information
popzxc authored Oct 31, 2024
1 parent a219915 commit a630f72
Show file tree
Hide file tree
Showing 28 changed files with 94 additions and 144 deletions.
18 changes: 0 additions & 18 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ categories = ["cryptography"]
publish = false # We don't want to publish our binaries.

[dependencies]
zkevm_opcode_defs = { git = "https://github.com/matter-labs/era-zkevm_opcode_defs.git", branch = "v1.5.0" }
zksync_basic_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "cfbcc11be0826e8c55fafa84ae01b2aead25d127" }
zksync_multivm = { git = "https://github.com/matter-labs/zksync-era.git", rev = "cfbcc11be0826e8c55fafa84ae01b2aead25d127" }
zksync_contracts = { git = "https://github.com/matter-labs/zksync-era.git", rev = "cfbcc11be0826e8c55fafa84ae01b2aead25d127" }
zksync_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "cfbcc11be0826e8c55fafa84ae01b2aead25d127" }
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/test/anvil-apis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("anvil_setCode", function () {
await provider.send("anvil_setCode", [address, shortCode]);
};

await expectThrowsAsync(action, "bytes must be divisible by 32");
await expectThrowsAsync(action, "Invalid bytecode");
});

it("Should update code with a different smart contract", async function () {
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/test/hardhat-apis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe("hardhat_setCode", function () {
await provider.send("hardhat_setCode", [address, shortCode]);
};

await expectThrowsAsync(action, "bytes must be divisible by 32");
await expectThrowsAsync(action, "Invalid bytecode");
});

it("Should update code with a different smart contract", async function () {
Expand Down
2 changes: 1 addition & 1 deletion src/bootloader_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use zksync_multivm::{
};

use once_cell::sync::OnceCell;
use zksync_basic_types::U256;
use zksync_multivm::interface::storage::WriteStorage;
use zksync_multivm::vm_latest::{
constants::BOOTLOADER_HEAP_PAGE, BootloaderState, HistoryMode, SimpleMemory, VmTracer,
ZkSyncVmState,
};
use zksync_types::U256;

/// Magic value that we put in bootloader.yul at the beginning of the debug section - to detect that
/// debugger was enabled.
Expand Down
4 changes: 2 additions & 2 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::io::{BufReader, BufWriter};
use std::path::Path;
use std::result::Result;
use std::str::FromStr;
use zksync_basic_types::H256;
use zksync_types::api::{Block, BridgeAddresses, Transaction, TransactionVariant};
use zksync_types::Transaction as RawTransaction;
use zksync_types::H256;

use crate::config::cache::CacheConfig;

Expand Down Expand Up @@ -379,8 +379,8 @@ impl Cache {
#[cfg(test)]
mod tests {
use tempdir::TempDir;
use zksync_basic_types::{H160, U64};
use zksync_types::{Execute, ExecuteTransactionCommon};
use zksync_types::{H160, U64};

use crate::testing;

Expand Down
2 changes: 1 addition & 1 deletion src/deps/system_contracts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use once_cell::sync::Lazy;
use serde_json::Value;
use zksync_basic_types::{AccountTreeId, Address, H160};
use zksync_types::{
block::DeployedContract, ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS,
BOOTLOADER_UTILITIES_ADDRESS, CODE_ORACLE_ADDRESS, COMPRESSOR_ADDRESS,
Expand All @@ -11,6 +10,7 @@ use zksync_types::{
P256VERIFY_PRECOMPILE_ADDRESS, PUBDATA_CHUNK_PUBLISHER_ADDRESS, SHA256_PRECOMPILE_ADDRESS,
SYSTEM_CONTEXT_ADDRESS,
};
use zksync_types::{AccountTreeId, Address, H160};

/// The `ecAdd` system contract address.
pub const ECADD_PRECOMPILE_ADDRESS: Address = H160([
Expand Down
2 changes: 1 addition & 1 deletion src/filters.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::{HashMap, HashSet};

use zksync_basic_types::{H160, H256, U256, U64};
use zksync_types::api::{BlockNumber, Log};
use zksync_types::{H160, H256, U256, U64};
use zksync_web3_decl::types::FilterChanges;

use crate::utils;
Expand Down
4 changes: 2 additions & 2 deletions src/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{

use eyre::eyre;
use tokio::runtime::Builder;
use zksync_basic_types::{Address, L1BatchNumber, L2BlockNumber, L2ChainId, H256, U256, U64};
use zksync_types::{Address, L1BatchNumber, L2BlockNumber, L2ChainId, H256, U256, U64};

use zksync_types::{
api::{
Expand Down Expand Up @@ -727,9 +727,9 @@ impl ForkDetails {

#[cfg(test)]
mod tests {
use zksync_basic_types::{AccountTreeId, L1BatchNumber, H256};
use zksync_multivm::interface::storage::ReadStorage;
use zksync_types::{api::TransactionVariant, StorageKey};
use zksync_types::{AccountTreeId, L1BatchNumber, H256};

use crate::config::cache::CacheConfig;
use crate::config::gas::{
Expand Down
2 changes: 1 addition & 1 deletion src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::collections::HashMap;
use std::str;

use crate::fork::block_on;
use zksync_basic_types::H160;
use zksync_types::H160;

use zksync_multivm::interface::{Call, VmEvent, VmExecutionResultAndLogs};
use zksync_types::StorageLogWithPreviousValue;
Expand Down
23 changes: 10 additions & 13 deletions src/http_fork_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use crate::{
fork::{block_on, ForkSource},
};
use eyre::Context;
use zksync_basic_types::{H256, U256};
use zksync_types::{
api::{BridgeAddresses, Transaction},
url::SensitiveUrl,
};
use zksync_types::{H256, U256};
use zksync_web3_decl::{
client::Client,
namespaces::{EthNamespaceClient, ZksNamespaceClient},
Expand Down Expand Up @@ -54,27 +54,24 @@ impl ForkSource for HttpForkSource {

fn get_storage_at(
&self,
address: zksync_basic_types::Address,
idx: zksync_basic_types::U256,
address: zksync_types::Address,
idx: zksync_types::U256,
block: Option<zksync_types::api::BlockIdVariant>,
) -> eyre::Result<zksync_basic_types::H256> {
) -> eyre::Result<zksync_types::H256> {
let client = self.create_client();
block_on(async move { client.get_storage_at(address, idx, block).await })
.wrap_err("fork http client failed")
}

fn get_bytecode_by_hash(
&self,
hash: zksync_basic_types::H256,
) -> eyre::Result<Option<Vec<u8>>> {
fn get_bytecode_by_hash(&self, hash: zksync_types::H256) -> eyre::Result<Option<Vec<u8>>> {
let client = self.create_client();
block_on(async move { client.get_bytecode_by_hash(hash).await })
.wrap_err("fork http client failed")
}

fn get_transaction_by_hash(
&self,
hash: zksync_basic_types::H256,
hash: zksync_types::H256,
) -> eyre::Result<Option<zksync_types::api::Transaction>> {
if let Ok(Some(transaction)) = self
.cache
Expand Down Expand Up @@ -117,7 +114,7 @@ impl ForkSource for HttpForkSource {

fn get_raw_block_transactions(
&self,
block_number: zksync_basic_types::L2BlockNumber,
block_number: zksync_types::L2BlockNumber,
) -> eyre::Result<Vec<zksync_types::Transaction>> {
let number = block_number.0 as u64;
if let Ok(Some(transaction)) = self
Expand Down Expand Up @@ -151,7 +148,7 @@ impl ForkSource for HttpForkSource {

fn get_block_by_hash(
&self,
hash: zksync_basic_types::H256,
hash: zksync_types::H256,
full_transactions: bool,
) -> eyre::Result<Option<zksync_types::api::Block<zksync_types::api::TransactionVariant>>> {
if let Ok(Some(block)) = self
Expand Down Expand Up @@ -280,7 +277,7 @@ impl ForkSource for HttpForkSource {
/// Returns details of a block, given miniblock number
fn get_block_details(
&self,
miniblock: zksync_basic_types::L2BlockNumber,
miniblock: zksync_types::L2BlockNumber,
) -> eyre::Result<Option<zksync_types::api::BlockDetails>> {
let client = self.create_client();
block_on(async move { client.get_block_details(miniblock).await }).wrap_err(format!(
Expand Down Expand Up @@ -358,8 +355,8 @@ impl ForkSource for HttpForkSource {
mod tests {
use std::str::FromStr;

use zksync_basic_types::{Address, L2BlockNumber, H160, H256, U64};
use zksync_types::api::BlockNumber;
use zksync_types::{Address, L2BlockNumber, H160, H256, U64};

use crate::testing;

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use futures::{
FutureExt,
};
use jsonrpc_core::MetaIoHandler;
use zksync_basic_types::H160;
use zksync_types::H160;

use crate::constants::{LEGACY_RICH_WALLETS, RICH_WALLETS};
use crate::namespaces::{
Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/anvil.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use jsonrpc_derive::rpc;
use zksync_basic_types::{Address, U256, U64};
use zksync_types::{Address, U256, U64};

use super::{ResetRequest, RpcResult};

Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/eth_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_derive::rpc;
use zksync_basic_types::H256;
use zksync_types::transaction_request::CallRequest;
use zksync_types::H256;

///
/// ETH namespace extension for the test node.
Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/evm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use jsonrpc_derive::rpc;
use zksync_basic_types::{Address, U256, U64};
use zksync_types::{Address, U256, U64};

use crate::namespaces::RpcResult;

Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/hardhat.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use jsonrpc_derive::rpc;
use serde::{Deserialize, Serialize};
use zksync_basic_types::{Address, U256, U64};
use zksync_types::{Address, U256, U64};

use super::RpcResult;

Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/net.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use jsonrpc_derive::rpc;
use zksync_basic_types::U256;
use zksync_types::U256;

use crate::namespaces::Result;

Expand Down
2 changes: 1 addition & 1 deletion src/node/anvil.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zksync_basic_types::{Address, U256, U64};
use zksync_types::{Address, U256, U64};
use zksync_web3_decl::error::Web3Error;

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions src/node/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use zksync_multivm::tracers::CallTracer;
use zksync_multivm::vm_latest::HistoryDisabled;
use zksync_multivm::vm_latest::{constants::ETH_CALL_GAS_LIMIT, ToTracerPointer, Vm};

use zksync_basic_types::H256;
use zksync_types::H256;
use zksync_types::{
api::{BlockId, BlockNumber, DebugCall, ResultDebugCall, TracerConfig, TransactionVariant},
l2::L2Tx,
Expand Down Expand Up @@ -242,13 +242,13 @@ mod tests {
testing::{self, LogBuilder},
};
use ethers::abi::{short_signature, AbiEncode, HumanReadableParser, ParamType, Token};
use zksync_basic_types::{Address, Nonce, H160, U256};
use zksync_types::{
api::{Block, CallTracerConfig, SupportedTracers, TransactionReceipt},
transaction_request::CallRequestBuilder,
utils::deployed_address_create,
K256PrivateKey,
};
use zksync_types::{Address, Nonce, H160, U256};

fn deploy_test_contracts(node: &InMemoryNode<HttpForkSource>) -> (Address, Address) {
let private_key = K256PrivateKey::from_bytes(H256::repeat_byte(0xee)).unwrap();
Expand Down
Loading

0 comments on commit a630f72

Please sign in to comment.