Skip to content

Commit

Permalink
chore: misc cleanup (#6060)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Oct 18, 2023
1 parent 2ef0814 commit 490b588
Show file tree
Hide file tree
Showing 39 changed files with 117 additions and 122 deletions.
3 changes: 0 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 crates/abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository.workspace = true

[build-dependencies]
ethers-contract-abigen.workspace = true
eyre = "0.6"
eyre.workspace = true
syn = "2.0"

[dependencies]
Expand Down
6 changes: 3 additions & 3 deletions crates/anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tower = "0.4"
tower-http = { version = "0.4", features = ["trace"] }

# tracing
tracing = "0.1"
tracing.workspace = true
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }

# async
Expand All @@ -54,8 +54,8 @@ async-trait = "0.1"

# misc
flate2 = "1.0"
serde_json = "1"
serde = { version = "1", features = ["derive"] }
serde_json.workspace = true
serde.workspace = true
thiserror = "1"
yansi = "0.5"
tempfile = "3"
Expand Down
8 changes: 4 additions & 4 deletions crates/anvil/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ repository.workspace = true
# foundry internal
foundry-evm = { path = "../../evm" }
foundry-utils = { path = "../../utils" }
revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] }
revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] }

alloy-primitives = { workspace = true, features = ["serde"] }
ethers-core.workspace = true
serde = { version = "1", features = ["derive"], optional = true }
serde_json = "1"
serde = { workspace = true, optional = true }
serde_json.workspace = true
bytes = { version = "1.4" }
open-fastrlp = { version = "0.1.4", optional = true }

Expand All @@ -30,7 +30,7 @@ reference-trie = { version = "0.25" }
keccak-hasher = { version = "0.15" }

[dev-dependencies]
serde = { version = "1.0", features = ["derive"] }
serde.workspace = true

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/core/src/eth/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_primitives::{Address as rAddress, U256 as rU256};
use alloy_primitives::{Address as aAddress, U256 as rU256};
use ethers_core::{
types::{transaction::eip2930::AccessListItem, Address, U256},
utils::{
Expand All @@ -23,7 +23,7 @@ pub fn to_access_list(list: Vec<AccessListItem>) -> Vec<(Address, Vec<U256>)> {
.collect()
}

pub fn to_revm_access_list(list: Vec<AccessListItem>) -> Vec<(rAddress, Vec<rU256>)> {
pub fn to_revm_access_list(list: Vec<AccessListItem>) -> Vec<(aAddress, Vec<rU256>)> {
list.into_iter()
.map(|item| {
(
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ homepage.workspace = true
repository.workspace = true

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
serde.workspace = true
serde_json.workspace = true

[dev-dependencies]
rand = "0.8"
6 changes: 3 additions & 3 deletions crates/anvil/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ hyper = "0.14"
tower-http = { version = "0.4", features = ["trace", "cors"] }

# tracing
tracing = "0.1"
tracing.workspace = true

# async
parking_lot = "0.12"
Expand All @@ -31,8 +31,8 @@ bytes = { version = "1.4", optional = true }
tokio-util = { version = "0.7", features = ["codec"], optional = true }

# misc
serde_json = "1"
serde = { version = "1", features = ["derive"] }
serde_json.workspace = true
serde.workspace = true
async-trait = "0.1"
thiserror = "1"

Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub struct NodeConfig {

impl NodeConfig {
fn as_string(&self, fork: Option<&ClientFork>) -> String {
let mut config_string: String = "".to_owned();
let mut config_string: String = String::new();
let _ = write!(config_string, "\n{}", Paint::green(BANNER));
let _ = write!(config_string, "\n {VERSION_MESSAGE}");
let _ = write!(
Expand Down
6 changes: 3 additions & 3 deletions crates/anvil/src/eth/backend/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
eth::backend::db::{Db, MaybeHashDatabase},
genesis::Genesis,
};
use alloy_primitives::{Address as B160, B256, U256};
use alloy_primitives::{Address as aAddress, B256, U256};
use ethers::{
abi::ethereum_types::BigEndianHash,
types::{Address, H256},
Expand Down Expand Up @@ -103,7 +103,7 @@ pub(crate) struct AtGenesisStateDb<'a> {

impl<'a> DatabaseRef for AtGenesisStateDb<'a> {
type Error = DatabaseError;
fn basic(&self, address: B160) -> DatabaseResult<Option<AccountInfo>> {
fn basic(&self, address: aAddress) -> DatabaseResult<Option<AccountInfo>> {
if let Some(acc) = self.accounts.get(&(address.to_ethers())).cloned() {
return Ok(Some(acc))
}
Expand All @@ -117,7 +117,7 @@ impl<'a> DatabaseRef for AtGenesisStateDb<'a> {
self.db.code_by_hash(code_hash)
}

fn storage(&self, address: B160, index: U256) -> DatabaseResult<U256> {
fn storage(&self, address: aAddress, index: U256) -> DatabaseResult<U256> {
if let Some(acc) = self
.genesis
.as_ref()
Expand Down
11 changes: 3 additions & 8 deletions crates/anvil/src/eth/backend/mem/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ mod tests {
revm::primitives::AccountInfo,
Address,
};
use alloy_primitives::U256 as rU256;
use bytes::Bytes;
use alloy_primitives::{Bytes, U256 as rU256};
use ethers::types::U256;
use foundry_evm::{
executor::{backend::MemDb, DatabaseRef},
Expand All @@ -159,9 +158,7 @@ mod tests {

let mut dump_db = MemDb::default();

let contract_code: Bytecode =
Bytecode::new_raw(alloy_primitives::Bytes(Bytes::from("fake contract code")))
.to_checked();
let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")).to_checked();

dump_db.insert_account(
test_addr,
Expand Down Expand Up @@ -201,9 +198,7 @@ mod tests {
let test_addr2: Address =
Address::from_str("0x70997970c51812dc3a010c7d01b50e0d17dc79c8").unwrap();

let contract_code: Bytecode =
Bytecode::new_raw(alloy_primitives::Bytes(Bytes::from("fake contract code")))
.to_checked();
let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")).to_checked();

let mut db = MemDb::default();

Expand Down
10 changes: 5 additions & 5 deletions crates/anvil/src/eth/backend/mem/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use foundry_evm::{
revm,
revm::{
interpreter::{CallInputs, CreateInputs, Gas, InstructionResult, Interpreter},
primitives::{Address as rAddress, Bytes, B256},
primitives::{Address, Bytes, B256},
EVMData,
},
};
Expand Down Expand Up @@ -71,7 +71,7 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
fn log(
&mut self,
evm_data: &mut EVMData<'_, DB>,
address: &rAddress,
address: &Address,
topics: &[B256],
data: &Bytes,
) {
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
&mut self,
data: &mut EVMData<'_, DB>,
call: &mut CreateInputs,
) -> (InstructionResult, Option<rAddress>, Gas, Bytes) {
) -> (InstructionResult, Option<Address>, Gas, Bytes) {
call_inspectors!([&mut self.tracer], |inspector| {
inspector.create(data, call);
});
Expand All @@ -140,10 +140,10 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
data: &mut EVMData<'_, DB>,
inputs: &CreateInputs,
status: InstructionResult,
address: Option<rAddress>,
address: Option<Address>,
gas: Gas,
retdata: Bytes,
) -> (InstructionResult, Option<rAddress>, Gas, Bytes) {
) -> (InstructionResult, Option<Address>, Gas, Bytes) {
call_inspectors!([&mut self.tracer], |inspector| {
inspector.create_end(data, inputs, status, address, gas, retdata.clone());
});
Expand Down
11 changes: 5 additions & 6 deletions crates/anvil/src/eth/backend/mem/state.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Support for generating the state root for memdb storage
use crate::eth::{backend::db::AsHashDB, error::BlockchainError};
use alloy_primitives::{Address as rAddress, U256 as rU256};
use alloy_primitives::{Address, Bytes, U256 as rU256};
use anvil_core::eth::{state::StateOverride, trie::RefSecTrieDBMut};
use bytes::Bytes;
use ethers::{
types::H256,
utils::{rlp, rlp::RlpStream},
Expand Down Expand Up @@ -63,7 +62,7 @@ pub fn storage_trie_db(storage: &Map<rU256, rU256>) -> (AsHashDB, H256) {
}

/// Returns the account data as `HashDB`
pub fn trie_hash_db(accounts: &Map<rAddress, DbAccount>) -> (AsHashDB, H256) {
pub fn trie_hash_db(accounts: &Map<Address, DbAccount>) -> (AsHashDB, H256) {
let accounts = trie_accounts(accounts);

// Populate DB with full trie from entries.
Expand All @@ -83,7 +82,7 @@ pub fn trie_hash_db(accounts: &Map<rAddress, DbAccount>) -> (AsHashDB, H256) {
}

/// Returns all RLP-encoded Accounts
pub fn trie_accounts(accounts: &Map<rAddress, DbAccount>) -> Vec<(rAddress, Bytes)> {
pub fn trie_accounts(accounts: &Map<Address, DbAccount>) -> Vec<(Address, Bytes)> {
accounts
.iter()
.map(|(address, account)| {
Expand All @@ -93,7 +92,7 @@ pub fn trie_accounts(accounts: &Map<rAddress, DbAccount>) -> Vec<(rAddress, Byte
.collect()
}

pub fn state_merkle_trie_root(accounts: &Map<rAddress, DbAccount>) -> H256 {
pub fn state_merkle_trie_root(accounts: &Map<Address, DbAccount>) -> H256 {
trie_hash_db(accounts).1
}

Expand All @@ -104,7 +103,7 @@ pub fn trie_account_rlp(info: &AccountInfo, storage: &Map<rU256, rU256>) -> Byte
stream.append(&info.balance.to_ethers());
stream.append(&storage_trie_db(storage).1);
stream.append(&info.code_hash.as_slice());
stream.out().freeze()
stream.out().freeze().into()
}

/// Applies the given state overrides to the state, returning a new CacheDB state
Expand Down
4 changes: 2 additions & 2 deletions crates/binder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository.workspace = true
[dependencies]
foundry-config.workspace = true
ethers-contract = { workspace = true, features = ["abigen"] }
eyre = "0.6"
eyre.workspace = true
git2 = { version = "0.18", default-features = false }
url = "2"
tracing = "0.1"
tracing.workspace = true
tempfile = "3"
9 changes: 4 additions & 5 deletions crates/cast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ ethers-core.workspace = true
ethers-providers.workspace = true
chrono.workspace = true
evm-disassembler = "0.2"
eyre = "0.6"
eyre.workspace = true
futures = "0.3"
hex.workspace = true
rayon = "1"
serde = "1"
serde_json = "1"
serde.workspace = true
serde_json.workspace = true

# aws
rusoto_core = { version = "0.48", default-features = false }
Expand All @@ -48,7 +48,6 @@ foundry-cli.workspace = true
ethers = { workspace = true, features = ["rustls"] }
eth-keystore = "0.5"

bytes = "1.4"
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
clap_complete = "4"
clap_complete_fig = "4"
Expand All @@ -61,7 +60,7 @@ rpassword = "7"
semver = "1"
tempfile = "3"
tokio = { version = "1", features = ["macros", "signal"] }
tracing = "0.1"
tracing.workspace = true
yansi = "0.5"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/cast/bin/cmd/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ mod tests {
None,
None,
Some(TRANSFER_SIG.to_string()),
vec!["".to_string(), ADDRESS.to_string()],
vec![String::new(), ADDRESS.to_string()],
)
.unwrap();
assert_eq!(filter, expected)
Expand Down Expand Up @@ -352,7 +352,7 @@ mod tests {
None,
None,
Some(TRANSFER_TOPIC.to_string()),
vec!["".to_string(), TRANSFER_TOPIC.to_string()],
vec![String::new(), TRANSFER_TOPIC.to_string()],
)
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion crates/cast/bin/cmd/wallet/vanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl VanityArgs {
nonce.unwrap(),
))
} else {
"".to_string()
String::new()
},
SimpleCast::to_checksum_address(&wallet.address()),
hex::encode(wallet.signer().to_bytes()),
Expand Down
7 changes: 3 additions & 4 deletions crates/chisel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ rustyline = "12"
solang-parser.workspace = true
yansi = "0.5"
strum = { version = "0.25", features = ["derive"] }
serde = "1"
serde_json = { version = "1", features = ["raw_value"] }
serde.workspace = true
serde_json.workspace = true
semver = "1"
bytes = "1"
revm.workspace = true
eyre = "0.6"
eyre.workspace = true
dirs = "5"
time = { version = "0.3", features = ["formatting"] }
regex = "1"
Expand Down
4 changes: 2 additions & 2 deletions crates/chisel/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct ChiselResult {
/// Map of addresses to their labels
pub labeled_addresses: BTreeMap<Address, String>,
/// Return data
pub returned: bytes::Bytes,
pub returned: Bytes,
/// Called address
pub address: Option<Address>,
/// EVM State at the final instruction of the `run()` function
Expand Down Expand Up @@ -200,7 +200,7 @@ impl ChiselRunner {
let RawCallResult { result, reverted, logs, traces, labels, chisel_state, .. } = res;

Ok(ChiselResult {
returned: result.0,
returned: result,
success: !reverted,
gas_used,
logs,
Expand Down
Loading

0 comments on commit 490b588

Please sign in to comment.