-
Notifications
You must be signed in to change notification settings - Fork 631
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: alloy migration #535
Conversation
5686acc
to
b36e3e4
Compare
8b3fd9a
to
67414f3
Compare
6173cc0
to
d577f07
Compare
8341293
to
01d2fb6
Compare
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.
two nits and one q, but otherwise this looks great!
Will pause other PR's until this is merged, so you don't have conflicts.
rlp = { version = "0.5", default-features = false } | ||
ruint = { version = "1.8.0", features = ["rlp", "serde"] } | ||
alloy-rlp = { version = "0.3", default-features = false, features = ["arrayvec"] } | ||
ruint = { version = "1.9.0", features = ["rlp", "serde"] } |
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.
Would be good to reexport it from alloy so the version and all other things are tied to it.
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.
ruint is already reexported so it can be removed, but rlp needs the "arrayvec" feature flag
|
||
pub fn log_rlp_hash(logs: &[Log]) -> B256 { | ||
let mut out = Vec::with_capacity(alloy_rlp::list_length(logs)); | ||
alloy_rlp::encode_list(logs, &mut out); |
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.
oh, this is nice!
Ok(output) | ||
} | ||
|
||
pub fn deserialize_str_as_u256<'de, D>(deserializer: D) -> Result<U256, D::Error> |
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.
nice
pub storage_keys: Vec<B256>, | ||
} | ||
|
||
pub type AccessList = Vec<AccessListItem>; | ||
|
||
pub fn deserialize_maybe_empty<'de, D>(deserializer: D) -> Result<Option<Address>, D::Error> |
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.
You moved this function from models/deserializalizer.rs
file, imo original place seems like a better place?
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.
I removed all the functions preemptively then added them back in because it failed parsing. Just forgot to put it back in its original place
|| name == "Call50000_sha256.json" | ||
|| name == "static_Call50000_sha256.json" | ||
|| name == "loopMul.json" | ||
|| name == "CALLBlake2f_MaxRounds.json" |
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.
good cleanup
)), | ||
B160(hex!("dcc5ba93a1ed7e045690d722f2bf460a51c61415")), | ||
b256!("fe13266ff57000135fb9aa854bbfe455d8da85b21f626307bf3263a0c2a8e7fe"), | ||
address!("dcc5ba93a1ed7e045690d722f2bf460a51c61415"), |
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.
love this macros
fn basic(&mut self, address: B160) -> Result<Option<AccountInfo>, Self::Error> { | ||
let add = eH160::from(address.0); | ||
fn basic(&mut self, address: Address) -> Result<Option<AccountInfo>, Self::Error> { | ||
let add = eH160::from(address.0 .0); |
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.
Is this correct?
let add = eH160::from(address.0 .0); | |
let add = eH160::from(address.0); |
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.
Yes, Address
is a wrapper around FixedBytes<20>
, which itself is a wrapper around [u8; 20]
: https://docs.rs/alloy-primitives/latest/alloy_primitives/struct.Address.html
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.
I thought that Address wraps only [u8; 20]
, makes sense
fn storage(&mut self, address: B160, index: U256) -> Result<U256, Self::Error> { | ||
let add = eH160::from(address.0); | ||
fn storage(&mut self, address: Address, index: U256) -> Result<U256, Self::Error> { | ||
let add = eH160::from(address.0 .0); |
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.
same here?
let add = eH160::from(address.0 .0); | |
let add = eH160::from(address.0); |
This reverts commit f95b7a4.
This reverts commit f95b7a4
Based on #499, so using that as PR base for better diff for now.
Will need an
alloy-primitives
v0.2.1 release for hex macros and other stuff.Main changes:
B160
,B256
) are now coming fromalloy_primitives
, which are type aliases toFixedBytes<N>
B*([...])
) is not allowed, so we use::new
or::from
B160 -> Address
:Address
is its own type, different fromB160
, with its own methods and trait implshex::decode
moved to use ofaddress!
,b256!
,bytes!
macrosserde_hex_bytes
and other util functions are not needed anymore, since the base serde impls ofBytes
andFixedBytes
use hex by default.sha3::Keccak256
toalloy_primitives::keccak256
, which usestiny_keccak
ruint
withalloy_primitives::ruint
(which isruint2
for now which includes many unreleased changes, see: recmo/uint@v1.8.0...alloy-rs:uint:main)rlp
in favor ofalloy_rlp
where possible (revme
)