diff --git a/crates/consensus/src/transaction/eip4844.rs b/crates/consensus/src/transaction/eip4844.rs index 52dd343d6ef..7df9c6994d8 100644 --- a/crates/consensus/src/transaction/eip4844.rs +++ b/crates/consensus/src/transaction/eip4844.rs @@ -246,17 +246,10 @@ impl RlpEcdsaTx for TxEip4844Variant { } } - fn rlp_encoded_length(&self) -> usize { - match self { - Self::TxEip4844(inner) => inner.rlp_encoded_length(), - Self::TxEip4844WithSidecar(inner) => inner.rlp_encoded_length(), - } - } - - fn rlp_encoded_length_with_signature(&self, signature: &Signature) -> usize { + fn rlp_header_signed(&self, signature: &Signature) -> Header { match self { - Self::TxEip4844(inner) => inner.rlp_encoded_length_with_signature(signature), - Self::TxEip4844WithSidecar(inner) => inner.rlp_encoded_length_with_signature(signature), + Self::TxEip4844(inner) => inner.rlp_header_signed(signature), + Self::TxEip4844WithSidecar(inner) => inner.rlp_header_signed(signature), } } @@ -289,21 +282,6 @@ impl RlpEcdsaTx for TxEip4844Variant { TxEip4844::rlp_decode_fields(buf).map(Into::into) } - fn rlp_decode(buf: &mut &[u8]) -> alloy_rlp::Result { - let header = Header::decode(buf)?; - if !header.list { - return Err(alloy_rlp::Error::UnexpectedString); - } - let remaining = buf.len(); - - let res = Self::rlp_decode_fields(buf)?; - - if buf.len() + header.payload_length != remaining { - return Err(alloy_rlp::Error::UnexpectedLength); - } - Ok(res) - } - fn rlp_decode_with_signature(buf: &mut &[u8]) -> alloy_rlp::Result<(Self, Signature)> { // We need to determine if this has a sidecar tx or not. The needle ref // is consumed to look for headers. @@ -334,8 +312,10 @@ impl RlpEcdsaTx for TxEip4844Variant { } fn tx_hash_with_type(&self, signature: &Signature, ty: u8) -> alloy_primitives::TxHash { - // eip4844 tx_hash is always based on the non-sidecar encoding - self.tx().tx_hash_with_type(signature, ty) + match self { + Self::TxEip4844(inner) => inner.tx_hash_with_type(signature, ty), + Self::TxEip4844WithSidecar(inner) => inner.tx_hash_with_type(signature, ty), + } } } @@ -779,7 +759,7 @@ impl SignableTransaction for TxEip4844WithSidecar { let signature = signature.with_parity_bool(); // important: must hash the tx WITHOUT the sidecar - let hash = self.tx.tx_hash(&signature); + let hash = self.tx_hash(&signature); Signed::new_unchecked(self, signature, hash) } @@ -895,6 +875,7 @@ impl RlpEcdsaTx for TxEip4844WithSidecar { } fn tx_hash_with_type(&self, signature: &Signature, ty: u8) -> alloy_primitives::TxHash { + // eip4844 tx_hash is always based on the non-sidecar encoding self.tx.tx_hash_with_type(signature, ty) } } diff --git a/crates/rpc-types-eth/src/transaction/mod.rs b/crates/rpc-types-eth/src/transaction/mod.rs index ec753b9accc..b33cd0264ef 100644 --- a/crates/rpc-types-eth/src/transaction/mod.rs +++ b/crates/rpc-types-eth/src/transaction/mod.rs @@ -3,7 +3,7 @@ use alloy_consensus::{ Signed, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip7702, TxEnvelope, TxLegacy, }; -use alloy_eips::eip7702::SignedAuthorization; +use alloy_eips::{eip2718::Encodable2718, eip7702::SignedAuthorization}; use alloy_network_primitives::TransactionResponse; use alloy_primitives::{Address, BlockHash, Bytes, ChainId, TxKind, B256, U256}; @@ -237,10 +237,9 @@ impl TransactionTrait for Transaction { } } -impl TransactionResponse for Transaction { +impl TransactionResponse for Transaction { fn tx_hash(&self) -> B256 { - Default::default() - // self.hash + self.inner.trie_hash() } fn block_hash(&self) -> Option {