diff --git a/crates/consensus/src/block.rs b/crates/consensus/src/block.rs index 9a144ddec7b..f540cc52dae 100644 --- a/crates/consensus/src/block.rs +++ b/crates/consensus/src/block.rs @@ -76,14 +76,14 @@ mod block_rlp { } impl Encodable for Block { - fn length(&self) -> usize { + fn encode(&self, out: &mut dyn alloy_rlp::bytes::BufMut) { let helper: HelperRef<'_, T> = self.into(); - helper.length() + helper.encode(out) } - fn encode(&self, out: &mut dyn alloy_rlp::bytes::BufMut) { + fn length(&self) -> usize { let helper: HelperRef<'_, T> = self.into(); - helper.encode(out) + helper.length() } } diff --git a/crates/consensus/src/transaction/eip1559.rs b/crates/consensus/src/transaction/eip1559.rs index 31975f60378..f523e23b3be 100644 --- a/crates/consensus/src/transaction/eip1559.rs +++ b/crates/consensus/src/transaction/eip1559.rs @@ -288,14 +288,14 @@ impl Transaction for TxEip1559 { Some(self.max_priority_fee_per_gas) } - fn priority_fee_or_price(&self) -> u128 { - self.max_priority_fee_per_gas - } - fn max_fee_per_blob_gas(&self) -> Option { None } + fn priority_fee_or_price(&self) -> u128 { + self.max_priority_fee_per_gas + } + fn to(&self) -> TxKind { self.to } diff --git a/crates/consensus/src/transaction/eip2930.rs b/crates/consensus/src/transaction/eip2930.rs index 5c404f32334..909959a45bf 100644 --- a/crates/consensus/src/transaction/eip2930.rs +++ b/crates/consensus/src/transaction/eip2930.rs @@ -252,14 +252,14 @@ impl Transaction for TxEip2930 { None } - fn priority_fee_or_price(&self) -> u128 { - self.gas_price - } - fn max_fee_per_blob_gas(&self) -> Option { None } + fn priority_fee_or_price(&self) -> u128 { + self.gas_price + } + fn to(&self) -> TxKind { self.to } diff --git a/crates/consensus/src/transaction/eip4844.rs b/crates/consensus/src/transaction/eip4844.rs index 4fb5a3cb1a4..1825e8d343d 100644 --- a/crates/consensus/src/transaction/eip4844.rs +++ b/crates/consensus/src/transaction/eip4844.rs @@ -228,17 +228,17 @@ impl Transaction for TxEip4844Variant { } } - fn priority_fee_or_price(&self) -> u128 { + fn max_fee_per_blob_gas(&self) -> Option { match self { - Self::TxEip4844(tx) => tx.priority_fee_or_price(), - Self::TxEip4844WithSidecar(tx) => tx.priority_fee_or_price(), + Self::TxEip4844(tx) => tx.max_fee_per_blob_gas(), + Self::TxEip4844WithSidecar(tx) => tx.max_fee_per_blob_gas(), } } - fn max_fee_per_blob_gas(&self) -> Option { + fn priority_fee_or_price(&self) -> u128 { match self { - Self::TxEip4844(tx) => tx.max_fee_per_blob_gas(), - Self::TxEip4844WithSidecar(tx) => tx.max_fee_per_blob_gas(), + Self::TxEip4844(tx) => tx.priority_fee_or_price(), + Self::TxEip4844WithSidecar(tx) => tx.priority_fee_or_price(), } } @@ -709,14 +709,14 @@ impl Transaction for TxEip4844 { Some(self.max_priority_fee_per_gas) } - fn priority_fee_or_price(&self) -> u128 { - self.max_priority_fee_per_gas - } - fn max_fee_per_blob_gas(&self) -> Option { Some(self.max_fee_per_blob_gas) } + fn priority_fee_or_price(&self) -> u128 { + self.max_priority_fee_per_gas + } + fn to(&self) -> TxKind { self.to.into() } @@ -982,14 +982,14 @@ impl Transaction for TxEip4844WithSidecar { self.tx.max_priority_fee_per_gas() } - fn priority_fee_or_price(&self) -> u128 { - self.tx.priority_fee_or_price() - } - fn max_fee_per_blob_gas(&self) -> Option { self.tx.max_fee_per_blob_gas() } + fn priority_fee_or_price(&self) -> u128 { + self.tx.priority_fee_or_price() + } + fn to(&self) -> TxKind { self.tx.to() } diff --git a/crates/consensus/src/transaction/eip7702.rs b/crates/consensus/src/transaction/eip7702.rs index ddd7979ae41..04b38827b4b 100644 --- a/crates/consensus/src/transaction/eip7702.rs +++ b/crates/consensus/src/transaction/eip7702.rs @@ -298,14 +298,14 @@ impl Transaction for TxEip7702 { Some(self.max_priority_fee_per_gas) } - fn priority_fee_or_price(&self) -> u128 { - self.max_priority_fee_per_gas - } - fn max_fee_per_blob_gas(&self) -> Option { None } + fn priority_fee_or_price(&self) -> u128 { + self.max_priority_fee_per_gas + } + fn to(&self) -> TxKind { self.to.into() } diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index f275a71d82f..243bf8b807e 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -382,6 +382,16 @@ impl Transaction for TxEnvelope { } } + fn nonce(&self) -> u64 { + match self { + Self::Legacy(tx) => tx.tx().nonce(), + Self::Eip2930(tx) => tx.tx().nonce(), + Self::Eip1559(tx) => tx.tx().nonce(), + Self::Eip4844(tx) => tx.tx().nonce(), + Self::Eip7702(tx) => tx.tx().nonce(), + } + } + fn gas_limit(&self) -> u64 { match self { Self::Legacy(tx) => tx.tx().gas_limit(), @@ -422,16 +432,6 @@ impl Transaction for TxEnvelope { } } - fn priority_fee_or_price(&self) -> u128 { - match self { - Self::Legacy(tx) => tx.tx().priority_fee_or_price(), - Self::Eip2930(tx) => tx.tx().priority_fee_or_price(), - Self::Eip1559(tx) => tx.tx().priority_fee_or_price(), - Self::Eip4844(tx) => tx.tx().priority_fee_or_price(), - Self::Eip7702(tx) => tx.tx().priority_fee_or_price(), - } - } - fn max_fee_per_blob_gas(&self) -> Option { match self { Self::Legacy(tx) => tx.tx().max_fee_per_blob_gas(), @@ -442,23 +442,13 @@ impl Transaction for TxEnvelope { } } - fn input(&self) -> &[u8] { - match self { - Self::Legacy(tx) => tx.tx().input(), - Self::Eip2930(tx) => tx.tx().input(), - Self::Eip1559(tx) => tx.tx().input(), - Self::Eip4844(tx) => tx.tx().input(), - Self::Eip7702(tx) => tx.tx().input(), - } - } - - fn nonce(&self) -> u64 { + fn priority_fee_or_price(&self) -> u128 { match self { - Self::Legacy(tx) => tx.tx().nonce(), - Self::Eip2930(tx) => tx.tx().nonce(), - Self::Eip1559(tx) => tx.tx().nonce(), - Self::Eip4844(tx) => tx.tx().nonce(), - Self::Eip7702(tx) => tx.tx().nonce(), + Self::Legacy(tx) => tx.tx().priority_fee_or_price(), + Self::Eip2930(tx) => tx.tx().priority_fee_or_price(), + Self::Eip1559(tx) => tx.tx().priority_fee_or_price(), + Self::Eip4844(tx) => tx.tx().priority_fee_or_price(), + Self::Eip7702(tx) => tx.tx().priority_fee_or_price(), } } @@ -482,6 +472,16 @@ impl Transaction for TxEnvelope { } } + fn input(&self) -> &[u8] { + match self { + Self::Legacy(tx) => tx.tx().input(), + Self::Eip2930(tx) => tx.tx().input(), + Self::Eip1559(tx) => tx.tx().input(), + Self::Eip4844(tx) => tx.tx().input(), + Self::Eip7702(tx) => tx.tx().input(), + } + } + fn ty(&self) -> u8 { match self { Self::Legacy(tx) => tx.tx().ty(), diff --git a/crates/consensus/src/transaction/legacy.rs b/crates/consensus/src/transaction/legacy.rs index d917cd2507d..26910666268 100644 --- a/crates/consensus/src/transaction/legacy.rs +++ b/crates/consensus/src/transaction/legacy.rs @@ -230,14 +230,14 @@ impl Transaction for TxLegacy { None } - fn priority_fee_or_price(&self) -> u128 { - self.gas_price - } - fn max_fee_per_blob_gas(&self) -> Option { None } + fn priority_fee_or_price(&self) -> u128 { + self.gas_price + } + fn to(&self) -> TxKind { self.to } diff --git a/crates/consensus/src/transaction/typed.rs b/crates/consensus/src/transaction/typed.rs index 32ed7e5d786..ca193019bb9 100644 --- a/crates/consensus/src/transaction/typed.rs +++ b/crates/consensus/src/transaction/typed.rs @@ -196,16 +196,6 @@ impl Transaction for TypedTransaction { } } - fn priority_fee_or_price(&self) -> u128 { - match self { - Self::Legacy(tx) => tx.priority_fee_or_price(), - Self::Eip2930(tx) => tx.priority_fee_or_price(), - Self::Eip1559(tx) => tx.priority_fee_or_price(), - Self::Eip4844(tx) => tx.priority_fee_or_price(), - Self::Eip7702(tx) => tx.priority_fee_or_price(), - } - } - fn max_fee_per_blob_gas(&self) -> Option { match self { Self::Legacy(tx) => tx.max_fee_per_blob_gas(), @@ -216,6 +206,16 @@ impl Transaction for TypedTransaction { } } + fn priority_fee_or_price(&self) -> u128 { + match self { + Self::Legacy(tx) => tx.priority_fee_or_price(), + Self::Eip2930(tx) => tx.priority_fee_or_price(), + Self::Eip1559(tx) => tx.priority_fee_or_price(), + Self::Eip4844(tx) => tx.priority_fee_or_price(), + Self::Eip7702(tx) => tx.priority_fee_or_price(), + } + } + fn to(&self) -> TxKind { match self { Self::Legacy(tx) => tx.to(), diff --git a/crates/rpc-types-eth/src/block.rs b/crates/rpc-types-eth/src/block.rs index 02c1f6c75c2..58b09b0a971 100644 --- a/crates/rpc-types-eth/src/block.rs +++ b/crates/rpc-types-eth/src/block.rs @@ -372,8 +372,8 @@ pub struct BlockOverrides { } impl BlockResponse for Block { - type Transaction = T; type Header = H; + type Transaction = T; fn header(&self) -> &Self::Header { &self.header