Skip to content

Commit

Permalink
chore: clean up remaining ethers usage (#6254)
Browse files Browse the repository at this point in the history
* chore: remove usage of LosslessAbi/RawAbi

* use NamedChain instead of Ethers Chain

* rm forge upload-selectors

* rm resolve_addr

* stuff

* cast base

* fix

* rm rlp in config

* upgrade

* fix cast interface

* fix: shr

* chore: clippy

* stop using ethers

* fix doctests

* chore: clippy

* fmt

* migrate rlp

* fixes

* ok_or_else for eyre

* chore: sort deps in manifests

* deps

* update pragma

* winders

* update

* fmt json

* update ethers

* keep ethers patches
  • Loading branch information
DaniPopes authored Nov 10, 2023
1 parent f27a771 commit 74b641f
Show file tree
Hide file tree
Showing 147 changed files with 1,106 additions and 1,927 deletions.
119 changes: 69 additions & 50 deletions Cargo.lock

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,17 @@ foundry-compilers = { version = "0.1", default-features = false }

## revm
# no default features to avoid c-kzg
revm = { version = "3", default-features = false } #
revm = { version = "3", default-features = false }
revm-primitives = { version = "1", default-features = false }

## ethers
ethers = { version = "2.0", default-features = false }
ethers-addressbook = { version = "2.0", default-features = false }
ethers-core = { version = "2.0", default-features = false }
ethers-contract = { version = "2.0", default-features = false }
ethers-contract-abigen = { version = "2.0", default-features = false }
ethers-providers = { version = "2.0", default-features = false }
ethers-signers = { version = "2.0", default-features = false }
ethers-middleware = { version = "2.0", default-features = false }
ethers-etherscan = { version = "2.0", default-features = false }
ethers-solc = { version = "2.0", default-features = false }

## alloy
Expand All @@ -160,20 +158,23 @@ alloy-json-abi = "0.4.1"
alloy-sol-types = "0.4.1"
syn-solidity = "0.4.1"

alloy-rlp = "0.3.3"
solang-parser = "=0.3.3"

## misc
toml = "0.8"
itertools = "0.11"
chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }
color-eyre = "0.6"
eyre = "0.6"
hex = { package = "const-hex", version = "1.6", features = ["hex"] }
itertools = "0.11"
jsonpath_lib = "0.3"
pretty_assertions = "1.4"
protobuf = "=3.2.0"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
toml = "0.8"
tracing = "0.1"
jsonpath_lib = "0.3"
eyre = "0.6"
color-eyre = "0.6"

#[patch."https://github.com/gakonst/ethers-rs"]
#ethers = { path = "../ethers-rs/ethers" }
Expand All @@ -188,16 +189,16 @@ color-eyre = "0.6"
#ethers-solc = { path = "../ethers-rs/ethers-solc" }

[patch.crates-io]
ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" }
ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }
ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" }

foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" }

Expand Down
6 changes: 2 additions & 4 deletions crates/anvil/core/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,12 @@ impl From<Header> for PartialHeader {

#[cfg(test)]
mod tests {
use std::str::FromStr;

use super::*;
use ethers_core::{
types::H160,
utils::{hex, hex::FromHex},
};

use super::*;
use std::str::FromStr;

#[test]
fn header_rlp_roundtrip() {
Expand Down
12 changes: 4 additions & 8 deletions crates/anvil/core/src/eth/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,13 @@ mod tests {
#[cfg(feature = "fastrlp")]
// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
fn encode_legacy_receipt() {
use std::str::FromStr;

use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt};
use ethers_core::{
types::{Bytes, H160, H256},
utils::hex,
};
use open_fastrlp::Encodable;

use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt};
use std::str::FromStr;

let expected = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap();

Expand Down Expand Up @@ -317,15 +315,13 @@ mod tests {
#[cfg(feature = "fastrlp")]
// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
fn decode_legacy_receipt() {
use std::str::FromStr;

use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt};
use ethers_core::{
types::{Bytes, H160, H256},
utils::hex,
};
use open_fastrlp::Decodable;

use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt};
use std::str::FromStr;

let data = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap();

Expand Down
3 changes: 1 addition & 2 deletions crates/anvil/core/src/eth/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;

use ethers_core::types::{Address, Bytes, H256, U256};
use std::collections::HashMap;

#[derive(Clone, Debug, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
3 changes: 1 addition & 2 deletions crates/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,8 @@ impl FromStr for ForkUrl {

#[cfg(test)]
mod tests {
use std::{env, net::Ipv4Addr};

use super::*;
use std::{env, net::Ipv4Addr};

#[test]
fn test_parse_fork_url() {
Expand Down
3 changes: 1 addition & 2 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::{backend::mem::BlockRequest, sign::build_typed_transaction};
use crate::{
eth::{
backend,
Expand Down Expand Up @@ -75,8 +76,6 @@ use parking_lot::RwLock;
use std::{collections::HashSet, future::Future, sync::Arc, time::Duration};
use tracing::{trace, warn};

use super::{backend::mem::BlockRequest, sign::build_typed_transaction};

/// The client version: `anvil/v{major}.{minor}.{patch}`
pub const CLIENT_VERSION: &str = concat!("anvil/v", env!("CARGO_PKG_VERSION"));

Expand Down
3 changes: 1 addition & 2 deletions crates/anvil/src/eth/backend/time.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
//! Manages the block time
use crate::eth::error::BlockchainError;
use chrono::{DateTime, NaiveDateTime, Utc};
use parking_lot::RwLock;
use std::{sync::Arc, time::Duration};
use tracing::trace;

use crate::eth::error::BlockchainError;

/// Returns the `Utc` datetime for the given seconds since unix epoch
pub fn utc_from_secs(secs: u64) -> DateTime<Utc> {
DateTime::<Utc>::from_naive_utc_and_offset(
Expand Down
10 changes: 4 additions & 6 deletions crates/anvil/src/eth/otterscan/api.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use super::types::{
OtsBlockDetails, OtsBlockTransactions, OtsContractCreator, OtsInternalOperation,
OtsSearchTransactions, OtsTrace,
};
use crate::eth::{
error::{BlockchainError, Result},
macros::node_info,
EthApi,
};

use ethers::types::{
Action, Address, Block, BlockId, BlockNumber, Bytes, Call, Create, CreateResult, Res, Reward,
Transaction, TxHash, H256, U256, U64,
};
use itertools::Itertools;

use super::types::{
OtsBlockDetails, OtsBlockTransactions, OtsContractCreator, OtsInternalOperation,
OtsSearchTransactions, OtsTrace,
};

impl EthApi {
/// Otterscan currently requires this endpoint, even though it's not part of the ots_*
/// https://github.com/otterscan/otterscan/blob/071d8c55202badf01804f6f8d53ef9311d4a9e47/src/useProvider.ts#L71
Expand Down
9 changes: 4 additions & 5 deletions crates/anvil/src/eth/otterscan/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use crate::eth::{
backend::mem::{storage::MinedTransaction, Backend},
error::{BlockchainError, Result},
};
use alloy_primitives::U256 as rU256;
use ethers::types::{
Action, Address, Block, Bytes, CallType, Trace, Transaction, TransactionReceipt, H256, U256,
Expand All @@ -8,11 +12,6 @@ use futures::future::join_all;
use serde::{de::DeserializeOwned, Serialize};
use serde_repr::Serialize_repr;

use crate::eth::{
backend::mem::{storage::MinedTransaction, Backend},
error::{BlockchainError, Result},
};

/// Patched Block struct, to include the additional `transactionCount` field expected by Otterscan
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase", bound = "TX: Serialize + DeserializeOwned")]
Expand Down
3 changes: 1 addition & 2 deletions crates/anvil/tests/it/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! general eth api tests
use crate::abi::{MulticallContract, SimpleStorage};
use anvil::{
eth::{api::CLIENT_VERSION, EthApi},
spawn, NodeConfig, CHAIN_ID,
Expand All @@ -14,8 +15,6 @@ use ethers::{
};
use std::{collections::HashMap, sync::Arc, time::Duration};

use crate::abi::{MulticallContract, SimpleStorage};

#[tokio::test(flavor = "multi_thread")]
async fn can_get_block_number() {
let (api, handle) = spawn(NodeConfig::test()).await;
Expand Down
14 changes: 7 additions & 7 deletions crates/anvil/tests/it/proof/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//! tests for `eth_getProof`
use crate::proof::eip1186::verify_proof;
use anvil::{spawn, NodeConfig};
use anvil_core::eth::{
proof::{AccountProof, BasicAccount},
trie::ExtensionLayout,
};
use ethers::{
abi::ethereum_types::BigEndianHash,
types::{Address, H256, U256},
utils::{keccak256, rlp},
};

use anvil_core::eth::proof::{AccountProof, BasicAccount};
use foundry_utils::types::ToEthers;

use crate::proof::eip1186::verify_proof;
use anvil_core::eth::trie::ExtensionLayout;
use ethers::utils::{keccak256, rlp};
use foundry_evm::revm::primitives::KECCAK_EMPTY;
use foundry_utils::types::ToEthers;

mod eip1186;

Expand Down
Loading

0 comments on commit 74b641f

Please sign in to comment.