diff --git a/crates/consensus/src/transaction/eip1559.rs b/crates/consensus/src/transaction/eip1559.rs index 219cf98c6fd..9016095e4e2 100644 --- a/crates/consensus/src/transaction/eip1559.rs +++ b/crates/consensus/src/transaction/eip1559.rs @@ -105,7 +105,7 @@ impl TxEip1559 { /// - `value` /// - `data` (`input`) /// - `access_list` - pub(crate) fn decode_fields(buf: &mut &[u8]) -> alloy_rlp::Result { + pub fn decode_fields(buf: &mut &[u8]) -> alloy_rlp::Result { Ok(Self { chain_id: Decodable::decode(buf)?, nonce: Decodable::decode(buf)?, @@ -179,12 +179,10 @@ impl TxEip1559 { /// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating /// hash that for eip2718 does not require a rlp header. #[doc(hidden)] - pub fn encode_with_signature( - &self, - signature: &Signature, - out: &mut dyn BufMut, - with_header: bool, - ) { + pub fn encode_with_signature(&self, signature: &S, out: &mut dyn BufMut, with_header: bool) + where + S: EncodableSignature, + { let payload_length = self.fields_len() + signature.rlp_vrs_len(); if with_header { Header { diff --git a/crates/consensus/src/transaction/eip2930.rs b/crates/consensus/src/transaction/eip2930.rs index ee0f0896323..bffebce22f2 100644 --- a/crates/consensus/src/transaction/eip2930.rs +++ b/crates/consensus/src/transaction/eip2930.rs @@ -86,7 +86,7 @@ impl TxEip2930 { /// - `value` /// - `data` (`input`) /// - `access_list` - pub(crate) fn decode_fields(buf: &mut &[u8]) -> alloy_rlp::Result { + pub fn decode_fields(buf: &mut &[u8]) -> alloy_rlp::Result { Ok(Self { chain_id: Decodable::decode(buf)?, nonce: Decodable::decode(buf)?, @@ -157,12 +157,10 @@ impl TxEip2930 { /// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating /// hash that for eip2718 does not require a rlp header #[doc(hidden)] - pub fn encode_with_signature( - &self, - signature: &Signature, - out: &mut dyn BufMut, - with_header: bool, - ) { + pub fn encode_with_signature(&self, signature: &S, out: &mut dyn BufMut, with_header: bool) + where + S: EncodableSignature, + { let payload_length = self.fields_len() + signature.rlp_vrs_len(); if with_header { Header { diff --git a/crates/consensus/src/transaction/eip4844.rs b/crates/consensus/src/transaction/eip4844.rs index 0b886fcfe19..95f92c5a291 100644 --- a/crates/consensus/src/transaction/eip4844.rs +++ b/crates/consensus/src/transaction/eip4844.rs @@ -122,12 +122,10 @@ impl TxEip4844Variant { /// If `with_header` is `true`, the following will be encoded: /// `rlp(tx_type (0x03) || rlp([transaction_payload_body, blobs, commitments, proofs]))` #[doc(hidden)] - pub fn encode_with_signature( - &self, - signature: &Signature, - out: &mut dyn BufMut, - with_header: bool, - ) { + pub fn encode_with_signature(&self, signature: &S, out: &mut dyn BufMut, with_header: bool) + where + S: EncodableSignature, + { let payload_length = match self { Self::TxEip4844(tx) => tx.fields_len() + signature.rlp_vrs_len(), Self::TxEip4844WithSidecar(tx) => { @@ -519,12 +517,10 @@ impl TxEip4844 { /// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating /// hash that for eip2718 does not require a rlp header #[doc(hidden)] - pub fn encode_with_signature( - &self, - signature: &Signature, - out: &mut dyn BufMut, - with_header: bool, - ) { + pub fn encode_with_signature(&self, signature: &S, out: &mut dyn BufMut, with_header: bool) + where + S: EncodableSignature, + { let payload_length = self.fields_len() + signature.rlp_vrs_len(); if with_header { Header { @@ -778,7 +774,10 @@ impl TxEip4844WithSidecar { /// /// where `tx_payload` is the RLP encoding of the [TxEip4844] transaction fields: /// `rlp([chain_id, nonce, max_priority_fee_per_gas, ..., v, r, s])` - pub fn encode_with_signature_fields(&self, signature: &Signature, out: &mut dyn BufMut) { + pub fn encode_with_signature_fields(&self, signature: &S, out: &mut dyn BufMut) + where + S: EncodableSignature, + { let inner_payload_length = self.tx.fields_len() + signature.rlp_vrs_len(); let inner_header = Header { list: true, payload_length: inner_payload_length }; diff --git a/crates/consensus/src/transaction/eip7702.rs b/crates/consensus/src/transaction/eip7702.rs index 6db47db3905..2d5221ac2b0 100644 --- a/crates/consensus/src/transaction/eip7702.rs +++ b/crates/consensus/src/transaction/eip7702.rs @@ -110,7 +110,7 @@ impl TxEip7702 { /// - `data` (`input`) /// - `access_list` /// - `authorization_list` - pub(crate) fn decode_fields(buf: &mut &[u8]) -> alloy_rlp::Result { + pub fn decode_fields(buf: &mut &[u8]) -> alloy_rlp::Result { Ok(Self { chain_id: Decodable::decode(buf)?, nonce: Decodable::decode(buf)?, @@ -187,12 +187,10 @@ impl TxEip7702 { /// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating /// hash that for eip2718 does not require a rlp header. #[doc(hidden)] - pub fn encode_with_signature( - &self, - signature: &Signature, - out: &mut dyn BufMut, - with_header: bool, - ) { + pub fn encode_with_signature(&self, signature: &S, out: &mut dyn BufMut, with_header: bool) + where + S: EncodableSignature, + { let payload_length = self.fields_len() + signature.rlp_vrs_len(); if with_header { Header {