Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
emhane committed Nov 10, 2024
1 parent 68108f8 commit 99c9943
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 18 deletions.
5 changes: 4 additions & 1 deletion crates/primitives-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub use tx_type::TxType;
pub mod header;
#[cfg(any(test, feature = "arbitrary", feature = "test-utils"))]
pub use header::test_utils;
pub use header::{Header, HeaderError, SealedHeader};
pub use header::{BlockHeader, Header, HeaderError, SealedHeader};

/// Bincode-compatible serde implementations for common abstracted types in Reth.
///
Expand All @@ -73,8 +73,11 @@ pub mod serde_bincode_compat {
/// Helper trait that requires arbitrary implementation if the feature is enabled.
#[cfg(feature = "arbitrary")]
pub trait MaybeArbitrary: for<'a> arbitrary::Arbitrary<'a> {}
/// Helper trait that requires arbitrary implementation if the feature is enabled.
#[cfg(not(feature = "arbitrary"))]
pub trait MaybeArbitrary {}

#[cfg(feature = "arbitrary")]
impl<T> MaybeArbitrary for T where T: for<'a> arbitrary::Arbitrary<'a> {}
#[cfg(not(feature = "arbitrary"))]
impl<T> MaybeArbitrary for T {}
4 changes: 0 additions & 4 deletions crates/primitives-traits/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ pub trait Transaction:
+ Hash
+ Serialize
+ for<'de> Deserialize<'de>
+ alloy_rlp::Encodable
+ alloy_rlp::Decodable
+ AlloyTransactionExt
+ MaybeArbitrary
{
Expand All @@ -43,8 +41,6 @@ impl<T> Transaction for T where
+ Hash
+ Serialize
+ for<'de> Deserialize<'de>
+ alloy_rlp::Encodable
+ alloy_rlp::Decodable
+ AlloyTransactionExt
+ MaybeArbitrary
{
Expand Down
23 changes: 11 additions & 12 deletions crates/primitives-traits/src/tx_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::fmt::{Debug, Display};
use core::fmt;

use alloy_eips::eip2718::Eip2718Error;
use alloy_primitives::{U64, U8};
use alloy_rlp::{Decodable, Encodable};

Expand All @@ -11,11 +10,11 @@ pub trait TxType:
+ PartialEq
+ Eq
+ PartialEq<u8>
+ TryFrom<u8, Error = Eip2718Error>
+ TryFrom<u64>
+ TryFrom<U64>
+ Debug
+ Display
+ TryFrom<u8, Error: fmt::Debug>
+ TryFrom<u64, Error: fmt::Debug>
+ TryFrom<U64, Error: fmt::Debug>
+ fmt::Debug
+ fmt::Display
+ Clone
+ Copy
+ Default
Expand All @@ -33,11 +32,11 @@ impl<T> TxType for T where
+ PartialEq
+ Eq
+ PartialEq<u8>
+ TryFrom<u8, Error = Eip2718Error>
+ TryFrom<u64>
+ TryFrom<U64>
+ Debug
+ Display
+ TryFrom<u8, Error: fmt::Debug>
+ TryFrom<u64, Error: fmt::Debug>
+ TryFrom<U64, Error: fmt::Debug>
+ fmt::Debug
+ fmt::Display
+ Clone
+ Copy
+ Default
Expand Down
8 changes: 8 additions & 0 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,17 @@ impl AlloyTransactionExt for Transaction {
Self::Eip1559(tx) => tx.signature_hash(),
Self::Eip4844(tx) => tx.signature_hash(),
Self::Eip7702(tx) => tx.signature_hash(),
#[cfg(feature = "optimism")]
_ => todo!("use op type for op"),
}
}

fn is_dynamic_fee(&self) -> bool {
match self {
Self::Legacy(_) | Self::Eip2930(_) => false,
Self::Eip1559(_) | Self::Eip4844(_) | Self::Eip7702(_) => true,
#[cfg(feature = "optimism")]
_ => todo!("use op type for op"),
}
}

Expand All @@ -860,6 +864,8 @@ impl AlloyTransactionExt for Transaction {
Self::Eip1559(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee),
Self::Eip4844(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee),
Self::Eip7702(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee),
#[cfg(feature = "optimism")]
_ => todo!("use op type for op"),
}
}

Expand All @@ -871,6 +877,8 @@ impl AlloyTransactionExt for Transaction {
Self::Eip1559(tx) => tx.size(),
Self::Eip4844(tx) => tx.size(),
Self::Eip7702(tx) => tx.size(),
#[cfg(feature = "optimism")]
_ => todo!("use op type for op"),
}
}
}
Expand Down
21 changes: 20 additions & 1 deletion crates/primitives/src/transaction/tx_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use alloy_consensus::constants::{
};
use alloy_primitives::{U64, U8};
use alloy_rlp::{Decodable, Encodable};
use derive_more::Display;
use serde::{Deserialize, Serialize};

/// Identifier parameter for legacy transaction
Expand Down Expand Up @@ -36,24 +37,42 @@ pub const DEPOSIT_TX_TYPE_ID: u8 = 126;
///
/// Other required changes when adding a new type can be seen on [PR#3953](https://github.com/paradigmxyz/reth/pull/3953/files).
#[derive(
Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Default, Serialize, Deserialize, Hash,
Clone,
Copy,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Default,
Serialize,
Deserialize,
Hash,
Display,
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))]
#[display("tx type: {_variant}")]
pub enum TxType {
/// Legacy transaction pre EIP-2929
#[default]
#[display("legacy (0)")]
Legacy = 0_isize,
/// AccessList transaction
#[display("eip2930 (1)")]
Eip2930 = 1_isize,
/// Transaction with Priority fee
#[display("eip1559 (2)")]
Eip1559 = 2_isize,
/// Shard Blob Transactions - EIP-4844
#[display("eip4844 (3)")]
Eip4844 = 3_isize,
/// EOA Contract Code Transactions - EIP-7702
#[display("eip7702 (4)")]
Eip7702 = 4_isize,
/// Optimism Deposit transaction.
#[cfg(feature = "optimism")]
#[display("deposit (126)")]
Deposit = 126_isize,
}

Expand Down

0 comments on commit 99c9943

Please sign in to comment.