From 4b8a66ff0e9ddd1482913d08540ff7fc3e1d63bc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 16 Jul 2024 23:44:31 +0200 Subject: [PATCH] chore: rm outdated impls (#9560) --- crates/primitives/src/transaction/eip7702.rs | 92 +------------------- 1 file changed, 2 insertions(+), 90 deletions(-) diff --git a/crates/primitives/src/transaction/eip7702.rs b/crates/primitives/src/transaction/eip7702.rs index ad020b4175..feaa37aa26 100644 --- a/crates/primitives/src/transaction/eip7702.rs +++ b/crates/primitives/src/transaction/eip7702.rs @@ -14,11 +14,8 @@ use reth_codecs::Compact; /// [EIP-7702 Set Code Transaction](https://eips.ethereum.org/EIPS/eip-7702) /// /// Set EOA account code for one transaction -#[cfg_attr( - any(test, feature = "reth-codec"), - reth_codecs::reth_codec(no_arbitrary, add_arbitrary_tests) -)] -#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::reth_codec)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct TxEip7702 { /// Added as EIP-155: Simple replay attack protection pub chain_id: ChainId, @@ -247,91 +244,6 @@ impl TxEip7702 { } } -// TODO(onbjerg): This is temporary until we upstream `Arbitrary` to EIP-7702 types and `Signature` -// in alloy -#[cfg(any(test, feature = "arbitrary"))] -impl<'a> arbitrary::Arbitrary<'a> for TxEip7702 { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - use arbitrary::Arbitrary; - #[derive(Arbitrary)] - struct ArbitrarySignedAuth { - chain_id: ChainId, - address: alloy_primitives::Address, - nonce: Option, - parity: bool, - r: U256, - s: U256, - } - - let iter = u.arbitrary_iter::()?; - let mut authorization_list = Vec::new(); - for auth in iter { - let auth = auth?; - - let sig = alloy_primitives::Signature::from_rs_and_parity( - auth.r, - auth.s, - alloy_primitives::Parity::Parity(auth.parity), - ) - .unwrap_or_else(|_| { - // Give a default one if the randomly generated one failed - alloy_primitives::Signature::from_rs_and_parity( - alloy_primitives::b256!( - "1fd474b1f9404c0c5df43b7620119ffbc3a1c3f942c73b6e14e9f55255ed9b1d" - ) - .into(), - alloy_primitives::b256!( - "29aca24813279a901ec13b5f7bb53385fa1fc627b946592221417ff74a49600d" - ) - .into(), - false, - ) - .unwrap() - }); - - authorization_list.push( - alloy_eips::eip7702::Authorization { - chain_id: auth.chain_id, - address: auth.address, - nonce: auth.nonce.into(), - } - .into_signed(sig), - ); - } - - Ok(Self { - chain_id: Arbitrary::arbitrary(u)?, - nonce: Arbitrary::arbitrary(u)?, - gas_limit: Arbitrary::arbitrary(u)?, - max_fee_per_gas: Arbitrary::arbitrary(u)?, - max_priority_fee_per_gas: Arbitrary::arbitrary(u)?, - to: Arbitrary::arbitrary(u)?, - value: Arbitrary::arbitrary(u)?, - access_list: Arbitrary::arbitrary(u)?, - authorization_list, - input: Arbitrary::arbitrary(u)?, - }) - } -} - -// TODO(onbjerg): This is temporary until we upstream `Hash` for EIP-7702 types in alloy -impl core::hash::Hash for TxEip7702 { - fn hash(&self, state: &mut H) { - self.chain_id.hash(state); - self.nonce.hash(state); - self.gas_limit.hash(state); - self.max_fee_per_gas.hash(state); - self.max_priority_fee_per_gas.hash(state); - self.to.hash(state); - self.value.hash(state); - self.access_list.hash(state); - for auth in &self.authorization_list { - auth.signature_hash().hash(state); - } - self.input.hash(state); - } -} - #[cfg(test)] mod tests { use super::TxEip7702;