-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(deps): Move to Alloy ABI encoding/decoding & alloy types #5986
Changes from 80 commits
ee18e87
6c6aa4e
f33e414
a8bb5b0
adc2786
8bc67d2
65f0918
a54005a
2c70bd9
55ad9bf
94fb974
b3935cc
8737a52
988e756
5b8c207
bd2fbb3
3c3b35c
7484d3b
3adebd5
c44e796
b51f741
bb68371
079c879
d9207b2
efd0323
de459d4
8356303
bcb57a2
4d4255b
5f145b7
90d5b05
3ea011c
48832e5
2cefb6f
6bef6ad
170f5e6
d8e54b9
5b404e0
2dbe680
ea9b980
a1b7442
23e281d
bdc95bb
8507f92
e42aeba
dc05ee5
944174a
4b2f0ea
f297ace
403de57
ffcb558
2c64c3d
ef21ace
99c228d
ebf9523
92c6b5a
e3dfa8b
da9b483
adc940a
b1f5ff7
0dbcf71
0e2c954
4d9ea34
9b5c45c
1d1dc01
e50cc48
5ce86fe
5c37c4b
30b2295
cd25d3b
6c88473
fb7bd39
5500c14
e4e347a
823a6e3
27f107a
cf7fdce
371e817
4e4e4c1
bcd565f
bd3e506
f958758
963234d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
use alloy_primitives::{keccak256, Address, B256, U256}; | ||
use cast::SimpleCast; | ||
use clap::Parser; | ||
use ethers::{ | ||
core::rand::thread_rng, | ||
types::{Address, Bytes, H256, U256}, | ||
utils::{get_create2_address_from_hash, keccak256}, | ||
}; | ||
use eyre::{Result, WrapErr}; | ||
use rayon::prelude::*; | ||
use regex::RegexSetBuilder; | ||
|
@@ -114,7 +110,7 @@ impl Create2Args { | |
let init_code_hash_bytes = hex::decode(init_code_hash)?; | ||
assert!(init_code_hash_bytes.len() == 32, "init code hash should be 32 bytes long"); | ||
a.copy_from_slice(&init_code_hash_bytes); | ||
a | ||
a.into() | ||
} else { | ||
keccak256(hex::decode(init_code)?) | ||
}; | ||
|
@@ -124,14 +120,9 @@ impl Create2Args { | |
let (salt, addr) = std::iter::repeat(()) | ||
.par_bridge() | ||
.map(|_| { | ||
let salt = H256::random_using(&mut thread_rng()); | ||
let salt = Bytes::from(salt.to_fixed_bytes()); | ||
let salt = B256::random(); | ||
|
||
let addr = SimpleCast::to_checksum_address(&get_create2_address_from_hash( | ||
deployer, | ||
salt.clone(), | ||
init_code_hash, | ||
)); | ||
let addr = SimpleCast::to_checksum_address(&deployer.create2(salt, init_code_hash)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get rid of this function In general I think SimpleCast was a mistake to begin with. I get the initial reason of having both a program and CLI Cast interface, but in practice it's only used for one or two functions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah definitely. This was migrated mainly to made the code compile, but it's completely redundant now Also agree about SimpleCast, it could just be a CLI There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree supportive of combining the two if the functions are simple enough. |
||
|
||
(salt, addr) | ||
}) | ||
|
@@ -142,7 +133,7 @@ impl Create2Args { | |
}) | ||
.unwrap(); | ||
|
||
let salt = U256::from(salt.to_vec().as_slice()); | ||
let salt = U256::from_be_bytes(*salt); | ||
let address = Address::from_str(&addr).unwrap(); | ||
|
||
println!( | ||
|
@@ -165,8 +156,6 @@ fn get_regex_hex_string(s: String) -> Result<String> { | |
|
||
#[cfg(test)] | ||
mod tests { | ||
use ethers::{abi::AbiEncode, utils::get_create2_address}; | ||
|
||
use super::*; | ||
|
||
const DEPLOYER: &str = "0x4e59b44847b379578588920ca78fbf26c0b4956c"; | ||
|
@@ -304,11 +293,12 @@ mod tests { | |
} | ||
|
||
fn verify_create2(deployer: Address, salt: U256, init_code: Vec<u8>) -> Address { | ||
// let init_code_hash = keccak256(init_code); | ||
get_create2_address(deployer, salt.encode(), init_code) | ||
let init_code_hash = keccak256(init_code); | ||
deployer.create2(salt.to_be_bytes(), init_code_hash) | ||
} | ||
|
||
fn verify_create2_hash(deployer: Address, salt: U256, init_code_hash: Vec<u8>) -> Address { | ||
get_create2_address_from_hash(deployer, salt.encode(), init_code_hash) | ||
let init_code_hash = B256::from_slice(&init_code_hash); | ||
deployer.create2(salt.to_be_bytes(), init_code_hash) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
use alloy_primitives::{Address, U256}; | ||
use cast::{Cast, TxBuilder}; | ||
use clap::Parser; | ||
use ethers::types::{NameOrAddress, U256}; | ||
use ethers::types::NameOrAddress; | ||
use eyre::Result; | ||
use foundry_cli::{ | ||
opts::{EtherscanOpts, RpcOpts}, | ||
utils::{self, parse_ether_value}, | ||
}; | ||
use foundry_config::{figment::Figment, Config}; | ||
use foundry_utils::types::ToEthers; | ||
use std::str::FromStr; | ||
|
||
/// CLI arguments for `cast estimate`. | ||
|
@@ -26,11 +28,11 @@ pub struct EstimateArgs { | |
#[clap( | ||
short, | ||
long, | ||
value_parser = NameOrAddress::from_str, | ||
value_parser = Address::from_str, | ||
default_value = "0x0000000000000000000000000000000000000000", | ||
env = "ETH_FROM", | ||
)] | ||
from: NameOrAddress, | ||
from: Address, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should also remain nameoraddress -- maybe i didn't communicate this appropriately, my thought was that we pull in |
||
|
||
/// Ether to send in the transaction. | ||
/// | ||
|
@@ -85,7 +87,7 @@ impl EstimateArgs { | |
let chain = utils::get_chain(config.chain_id, &provider).await?; | ||
let api_key = config.get_etherscan_api_key(Some(chain)); | ||
|
||
let mut builder = TxBuilder::new(&provider, from, to, chain, false).await?; | ||
let mut builder = TxBuilder::new(&provider, from.to_ethers(), to, chain, false).await?; | ||
builder.etherscan_api_key(api_key); | ||
|
||
match command { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the path towards removing these patches? why do we need them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main offender is
foundry-block-explorers
needing the chain enum from ethers. Once we havealloy-rs/chains
we can publish both block explorers and compilers and remove the patches. For alloy, we need a newer release with all the new features we're using off of master.