mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 17:18:08 -05:00
chore: make decode_enveloped args consistent with other fns (#5456)
This commit is contained in:
@@ -173,7 +173,7 @@ impl PayloadBuilderAttributes {
|
||||
.as_deref()
|
||||
.unwrap_or(&[])
|
||||
.iter()
|
||||
.map(|tx| TransactionSigned::decode_enveloped(tx.clone()))
|
||||
.map(|tx| TransactionSigned::decode_enveloped(&mut tx.as_ref()))
|
||||
.collect::<Result<_, _>>()?;
|
||||
(payload_id(&parent, &attributes, &transactions), transactions)
|
||||
};
|
||||
|
||||
@@ -1241,9 +1241,7 @@ impl TransactionSigned {
|
||||
///
|
||||
/// To decode EIP-4844 transactions in `eth_sendRawTransaction`, use
|
||||
/// [PooledTransactionsElement::decode_enveloped].
|
||||
pub fn decode_enveloped(tx: Bytes) -> alloy_rlp::Result<Self> {
|
||||
let mut data = tx.as_ref();
|
||||
|
||||
pub fn decode_enveloped(data: &mut &[u8]) -> alloy_rlp::Result<Self> {
|
||||
if data.is_empty() {
|
||||
return Err(RlpError::InputTooShort)
|
||||
}
|
||||
@@ -1251,9 +1249,9 @@ impl TransactionSigned {
|
||||
// Check if the tx is a list
|
||||
if data[0] >= EMPTY_LIST_CODE {
|
||||
// decode as legacy transaction
|
||||
TransactionSigned::decode_rlp_legacy_transaction(&mut data)
|
||||
TransactionSigned::decode_rlp_legacy_transaction(data)
|
||||
} else {
|
||||
TransactionSigned::decode_enveloped_typed_transaction(&mut data)
|
||||
TransactionSigned::decode_enveloped_typed_transaction(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1548,7 +1546,7 @@ mod tests {
|
||||
// random mainnet tx <https://etherscan.io/tx/0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f>
|
||||
let tx_bytes = hex!("02f872018307910d808507204d2cb1827d0094388c818ca8b9251b393131c08a736a67ccb19297880320d04823e2701c80c001a0cf024f4815304df2867a1a74e9d2707b6abda0337d2d54a4438d453f4160f190a07ac0e6b3bc9395b5b9c8b9e6d77204a236577a5b18467b9175c01de4faa208d9");
|
||||
|
||||
let decoded = TransactionSigned::decode_enveloped(tx_bytes[..].to_vec().into()).unwrap();
|
||||
let decoded = TransactionSigned::decode_enveloped(&mut &tx_bytes[..]).unwrap();
|
||||
assert_eq!(
|
||||
decoded.recover_signer(),
|
||||
Some(Address::from_str("0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5").unwrap())
|
||||
@@ -1728,7 +1726,7 @@ mod tests {
|
||||
fn test_envelop_decode() {
|
||||
// random tx: <https://etherscan.io/getRawTx?tx=0x9448608d36e721ef403c53b00546068a6474d6cbab6816c3926de449898e7bce>
|
||||
let input = bytes!("02f871018302a90f808504890aef60826b6c94ddf4c5025d1a5742cf12f74eec246d4432c295e487e09c3bbcc12b2b80c080a0f21a4eacd0bf8fea9c5105c543be5a1d8c796516875710fafafdf16d16d8ee23a001280915021bb446d1973501a67f93d2b38894a514b976e7b46dc2fe54598d76");
|
||||
let decoded = TransactionSigned::decode_enveloped(input.clone()).unwrap();
|
||||
let decoded = TransactionSigned::decode_enveloped(&mut input.as_ref()).unwrap();
|
||||
|
||||
let encoded = decoded.envelope_encoded();
|
||||
assert_eq!(encoded, input);
|
||||
|
||||
@@ -155,7 +155,7 @@ mod tests {
|
||||
fn test_rlp_roundtrip() {
|
||||
let bytes = Bytes::from_static(&hex!("7ef9015aa044bae9d41b8380d781187b426c6fe43df5fb2fb57bd4466ef6a701e1f01e015694deaddeaddeaddeaddeaddeaddeaddeaddead000194420000000000000000000000000000000000001580808408f0d18001b90104015d8eb900000000000000000000000000000000000000000000000000000000008057650000000000000000000000000000000000000000000000000000000063d96d10000000000000000000000000000000000000000000000000000000000009f35273d89754a1e0387b89520d989d3be9c37c1f32495a88faf1ea05c61121ab0d1900000000000000000000000000000000000000000000000000000000000000010000000000000000000000002d679b567db6187c0c8323fa982cfb88b74dbcc7000000000000000000000000000000000000000000000000000000000000083400000000000000000000000000000000000000000000000000000000000f4240"));
|
||||
|
||||
let tx_a = TransactionSigned::decode_enveloped(bytes.clone()).unwrap();
|
||||
let tx_a = TransactionSigned::decode_enveloped(&mut bytes.as_ref()).unwrap();
|
||||
let tx_b = TransactionSigned::decode(&mut &bytes[..]).unwrap();
|
||||
|
||||
let mut buf_a = BytesMut::default();
|
||||
|
||||
@@ -159,7 +159,7 @@ mod test_l1_fee {
|
||||
use reth_primitives::{hex_literal::hex, Bytes, Header, TransactionSigned};
|
||||
|
||||
let bytes = Bytes::from_static(&hex!("7ef9015aa044bae9d41b8380d781187b426c6fe43df5fb2fb57bd4466ef6a701e1f01e015694deaddeaddeaddeaddeaddeaddeaddeaddead000194420000000000000000000000000000000000001580808408f0d18001b90104015d8eb900000000000000000000000000000000000000000000000000000000008057650000000000000000000000000000000000000000000000000000000063d96d10000000000000000000000000000000000000000000000000000000000009f35273d89754a1e0387b89520d989d3be9c37c1f32495a88faf1ea05c61121ab0d1900000000000000000000000000000000000000000000000000000000000000010000000000000000000000002d679b567db6187c0c8323fa982cfb88b74dbcc7000000000000000000000000000000000000000000000000000000000000083400000000000000000000000000000000000000000000000000000000000f4240"));
|
||||
let l1_info_tx = TransactionSigned::decode_enveloped(bytes).unwrap();
|
||||
let l1_info_tx = TransactionSigned::decode_enveloped(&mut bytes.as_ref()).unwrap();
|
||||
let mock_block = Block {
|
||||
header: Header::default(),
|
||||
body: vec![l1_info_tx],
|
||||
|
||||
@@ -23,7 +23,7 @@ pub fn try_payload_v1_to_block(payload: ExecutionPayloadV1) -> Result<Block, Pay
|
||||
let transactions = payload
|
||||
.transactions
|
||||
.into_iter()
|
||||
.map(TransactionSigned::decode_enveloped)
|
||||
.map(|tx| TransactionSigned::decode_enveloped(&mut tx.as_ref()))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let transactions_root = proofs::calculate_transaction_root(&transactions);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user