From fcfd572edc1fd6856b228fd3974503ebd5b95218 Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:26:52 +0530 Subject: [PATCH 1/9] Update signed.rs --- crates/consensus/src/signed.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/consensus/src/signed.rs b/crates/consensus/src/signed.rs index 9a4bc6b87c0..cb215ff475f 100644 --- a/crates/consensus/src/signed.rs +++ b/crates/consensus/src/signed.rs @@ -184,12 +184,12 @@ where } /// EIP-2718 decode the signed transaction. - pub fn eip2718_decode(buf: &mut &[u8]) -> Eip2718Result { + pub fn eip2718_decode(self, buf: &mut &[u8]) -> Eip2718Result { T::eip2718_decode(buf) } /// Network decode the signed transaction with a specified type flag. - pub fn network_decode_with_type(buf: &mut &[u8], ty: u8) -> Eip2718Result { + pub fn network_decode_with_type(&self.tx, buf: &mut &[u8], ty: u8) -> Eip2718Result { T::network_decode_with_type(buf, ty) } From 3a4d603207f00e3c944adad319069660b3fcb6f9 Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:27:30 +0530 Subject: [PATCH 2/9] Update eip1559.rs --- crates/consensus/src/transaction/eip1559.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/consensus/src/transaction/eip1559.rs b/crates/consensus/src/transaction/eip1559.rs index 92a02a3e566..4699e892d6d 100644 --- a/crates/consensus/src/transaction/eip1559.rs +++ b/crates/consensus/src/transaction/eip1559.rs @@ -98,8 +98,6 @@ impl TxEip1559 { } impl RlpEcdsaEncodableTx for TxEip1559 { - const DEFAULT_TX_TYPE: u8 = { Self::tx_type() as u8 }; - /// Outputs the length of the transaction's fields, without a RLP header. fn rlp_encoded_fields_length(&self) -> usize { self.chain_id.length() From cfaf1b411ed26ff14ce9c0658ccb2f18ca84de78 Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:28:25 +0530 Subject: [PATCH 3/9] Update eip2930.rs --- crates/consensus/src/transaction/eip2930.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/consensus/src/transaction/eip2930.rs b/crates/consensus/src/transaction/eip2930.rs index 4a796b7cbce..e1d78f73735 100644 --- a/crates/consensus/src/transaction/eip2930.rs +++ b/crates/consensus/src/transaction/eip2930.rs @@ -83,8 +83,6 @@ impl TxEip2930 { } impl RlpEcdsaEncodableTx for TxEip2930 { - const DEFAULT_TX_TYPE: u8 = { Self::tx_type() as u8 }; - /// Outputs the length of the transaction's fields, without a RLP header. fn rlp_encoded_fields_length(&self) -> usize { self.chain_id.length() From 3bdcef5835a04f23030e4b397ac0ab64d29ddf42 Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:30:12 +0530 Subject: [PATCH 4/9] Update eip4844.rs --- crates/consensus/src/transaction/eip4844.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/consensus/src/transaction/eip4844.rs b/crates/consensus/src/transaction/eip4844.rs index c0b5971f084..26f7f93f3f4 100644 --- a/crates/consensus/src/transaction/eip4844.rs +++ b/crates/consensus/src/transaction/eip4844.rs @@ -287,7 +287,6 @@ impl Typed2718 for TxEip4844 { } impl RlpEcdsaEncodableTx for TxEip4844Variant { - const DEFAULT_TX_TYPE: u8 = { Self::tx_type() as u8 }; fn rlp_encoded_fields_length(&self) -> usize { match self { @@ -542,7 +541,6 @@ impl TxEip4844 { } impl RlpEcdsaEncodableTx for TxEip4844 { - const DEFAULT_TX_TYPE: u8 = { Self::tx_type() as u8 }; fn rlp_encoded_fields_length(&self) -> usize { self.chain_id.length() @@ -916,7 +914,6 @@ impl Typed2718 for TxEip4844WithSidecar { } impl RlpEcdsaEncodableTx for TxEip4844WithSidecar { - const DEFAULT_TX_TYPE: u8 = { Self::tx_type() as u8 }; fn rlp_encoded_fields_length(&self) -> usize { self.sidecar.rlp_encoded_fields_length() + self.tx.rlp_encoded_length() From 02f9de7f8b0fd647bd029011a7473b2eef4a5544 Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:30:43 +0530 Subject: [PATCH 5/9] Update eip7702.rs --- crates/consensus/src/transaction/eip7702.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/consensus/src/transaction/eip7702.rs b/crates/consensus/src/transaction/eip7702.rs index a2a861ef13f..e8616a80b2e 100644 --- a/crates/consensus/src/transaction/eip7702.rs +++ b/crates/consensus/src/transaction/eip7702.rs @@ -107,7 +107,6 @@ impl TxEip7702 { } impl RlpEcdsaEncodableTx for TxEip7702 { - const DEFAULT_TX_TYPE: u8 = { Self::tx_type() as u8 }; /// Outputs the length of the transaction's fields, without a RLP header. #[doc(hidden)] From 620ef9fb9ba0dd5f8cd8b5466547f7aaaa1e6bb8 Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:32:36 +0530 Subject: [PATCH 6/9] Update legacy.rs --- crates/consensus/src/transaction/legacy.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/consensus/src/transaction/legacy.rs b/crates/consensus/src/transaction/legacy.rs index 9281fb7611a..23ecb7a6fdb 100644 --- a/crates/consensus/src/transaction/legacy.rs +++ b/crates/consensus/src/transaction/legacy.rs @@ -112,7 +112,6 @@ impl TxLegacy { // Legacy transaction network and 2718 encodings are identical to the RLP // encoding. impl RlpEcdsaEncodableTx for TxLegacy { - const DEFAULT_TX_TYPE: u8 = { Self::TX_TYPE as u8 }; fn rlp_encoded_fields_length(&self) -> usize { self.nonce.length() @@ -224,7 +223,7 @@ impl RlpEcdsaDecodableTx for TxLegacy { Self::rlp_decode_signed(buf).map_err(Into::into) } - fn eip2718_decode(buf: &mut &[u8]) -> alloy_eips::eip2718::Eip2718Result> { + fn eip2718_decode(&self, buf: &mut &[u8]) -> alloy_eips::eip2718::Eip2718Result> { Self::rlp_decode_signed(buf).map_err(Into::into) } From 56cea4ec2f933aa3bbb43e6ddae05fa5b17137ff Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:33:19 +0530 Subject: [PATCH 7/9] Update rlp.rs --- crates/consensus/src/transaction/rlp.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/consensus/src/transaction/rlp.rs b/crates/consensus/src/transaction/rlp.rs index 31131268184..e0f6b15d2be 100644 --- a/crates/consensus/src/transaction/rlp.rs +++ b/crates/consensus/src/transaction/rlp.rs @@ -1,6 +1,9 @@ use crate::Signed; use alloc::vec::Vec; -use alloy_eips::eip2718::{Eip2718Error, Eip2718Result}; +use alloy_eips::{ + eip2718::{Eip2718Error, Eip2718Result}, + Typed2718, +}; use alloy_primitives::{keccak256, PrimitiveSignature as Signature, TxHash}; use alloy_rlp::{Buf, BufMut, Decodable, Encodable, Header}; From 41ba90463884f7c026b737a9222960262391fae6 Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:36:23 +0530 Subject: [PATCH 8/9] Update rlp.rs --- crates/consensus/src/transaction/rlp.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/consensus/src/transaction/rlp.rs b/crates/consensus/src/transaction/rlp.rs index e0f6b15d2be..ccf5157c831 100644 --- a/crates/consensus/src/transaction/rlp.rs +++ b/crates/consensus/src/transaction/rlp.rs @@ -11,10 +11,7 @@ use alloy_rlp::{Buf, BufMut, Decodable, Encodable, Header}; #[doc(hidden)] #[doc(alias = "RlpEncodableTx", alias = "RlpTxEncoding")] #[auto_impl::auto_impl(&, Arc)] -pub trait RlpEcdsaEncodableTx: Sized { - /// The default transaction type for this transaction. - const DEFAULT_TX_TYPE: u8; - +pub trait RlpEcdsaEncodableTx: Sized + Typed2718 { /// Calculate the encoded length of the transaction's fields, without a RLP /// header. fn rlp_encoded_fields_length(&self) -> usize; @@ -74,7 +71,7 @@ pub trait RlpEcdsaEncodableTx: Sized { /// EIP-2718 encode the transaction with the given signature and the default /// type flag. fn eip2718_encode(&self, signature: &Signature, out: &mut dyn BufMut) { - self.eip2718_encode_with_type(signature, Self::DEFAULT_TX_TYPE, out); + self.eip2718_encode_with_type(signature, self.ty(), out); } /// Create an rlp header for the network encoded transaction. This will @@ -100,7 +97,7 @@ pub trait RlpEcdsaEncodableTx: Sized { /// Network encode the transaction with the given signature and the default /// type flag. fn network_encode(&self, signature: &Signature, out: &mut dyn BufMut) { - self.network_encode_with_type(signature, Self::DEFAULT_TX_TYPE, out); + self.network_encode_with_type(signature, self.ty(), out); } /// Calculate the transaction hash for the given signature and type. @@ -112,14 +109,14 @@ pub trait RlpEcdsaEncodableTx: Sized { /// Calculate the transaction hash for the given signature. fn tx_hash(&self, signature: &Signature) -> TxHash { - self.tx_hash_with_type(signature, Self::DEFAULT_TX_TYPE) + self.tx_hash_with_type(signature, self.ty()) } } /// Helper trait for managing RLP decoding of transactions inside 2718 envelopes. #[doc(hidden)] #[doc(alias = "RlpDecodableTx", alias = "RlpTxDecoding")] -pub trait RlpEcdsaDecodableTx: RlpEcdsaEncodableTx { +pub trait RlpEcdsaDecodableTx: RlpEcdsaEncodableTx + Typed2718 { /// Decodes the fields of the transaction from RLP bytes. Do not decode a /// header. You may assume the buffer is long enough to contain the /// transaction. @@ -198,8 +195,8 @@ pub trait RlpEcdsaDecodableTx: RlpEcdsaEncodableTx { /// Decodes the transaction from eip2718 bytes, expecting the default type /// flag. - fn eip2718_decode(buf: &mut &[u8]) -> Eip2718Result> { - Self::eip2718_decode_with_type(buf, Self::DEFAULT_TX_TYPE) + fn eip2718_decode(self, buf: &mut &[u8]) -> Eip2718Result> { + Self::eip2718_decode_with_type(buf, slef.ty()) } /// Decodes the transaction from network bytes. @@ -221,8 +218,8 @@ pub trait RlpEcdsaDecodableTx: RlpEcdsaEncodableTx { /// Decodes the transaction from network bytes, expecting the default type /// flag. - fn network_decode(buf: &mut &[u8]) -> Eip2718Result> { - Self::network_decode_with_type(buf, Self::DEFAULT_TX_TYPE) + fn network_decode(&self, buf: &mut &[u8]) -> Eip2718Result> { + Self::network_decode_with_type(buf, self.ty()) } } From e9ca721d842688176b48c49c08852155e9993e9d Mon Sep 17 00:00:00 2001 From: Ayush Dubey <61616662+Ayushdubey86@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:36:50 +0530 Subject: [PATCH 9/9] Update typed.rs --- crates/consensus/src/transaction/typed.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/consensus/src/transaction/typed.rs b/crates/consensus/src/transaction/typed.rs index 1751ee86bbd..79144363d1b 100644 --- a/crates/consensus/src/transaction/typed.rs +++ b/crates/consensus/src/transaction/typed.rs @@ -375,7 +375,6 @@ impl Typed2718 for EthereumTypedTransaction { impl RlpEcdsaEncodableTx for EthereumTypedTransaction { - const DEFAULT_TX_TYPE: u8 = 0; fn rlp_encoded_fields_length(&self) -> usize { match self {