Skip to content

Commit 4c17de8

Browse files
authored
fix: add missing 2718 impl for receipt (#20137)
1 parent a0dc85f commit 4c17de8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

crates/ethereum/primitives/src/receipt.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use core::fmt::Debug;
22

33
use alloc::vec::Vec;
44
use alloy_consensus::{
5-
Eip2718EncodableReceipt, Eip658Value, ReceiptEnvelope, ReceiptWithBloom, RlpDecodableReceipt,
6-
RlpEncodableReceipt, TxReceipt, TxType, Typed2718,
5+
Eip2718DecodableReceipt, Eip2718EncodableReceipt, Eip658Value, ReceiptEnvelope,
6+
ReceiptWithBloom, RlpDecodableReceipt, RlpEncodableReceipt, TxReceipt, TxType, Typed2718,
77
};
8-
use alloy_eips::eip2718::{Eip2718Error, Encodable2718, IsTyped2718};
8+
use alloy_eips::eip2718::{Eip2718Error, Eip2718Result, Encodable2718, IsTyped2718};
99
use alloy_primitives::{Bloom, Log, B256};
1010
use alloy_rlp::{BufMut, Decodable, Encodable, Header, RlpDecodable, RlpEncodable};
1111
use reth_primitives_traits::{proofs::ordered_trie_root_with_encoder, InMemorySize};
@@ -154,6 +154,16 @@ impl<T: TxTy> Eip2718EncodableReceipt for Receipt<T> {
154154
}
155155
}
156156

157+
impl<T: TxTy> Eip2718DecodableReceipt for Receipt<T> {
158+
fn typed_decode_with_bloom(ty: u8, buf: &mut &[u8]) -> Eip2718Result<ReceiptWithBloom<Self>> {
159+
Ok(Self::rlp_decode_inner(buf, T::try_from(ty)?)?)
160+
}
161+
162+
fn fallback_decode_with_bloom(buf: &mut &[u8]) -> Eip2718Result<ReceiptWithBloom<Self>> {
163+
Ok(Self::rlp_decode_inner(buf, T::try_from(0)?)?)
164+
}
165+
}
166+
157167
impl<T: TxTy> RlpEncodableReceipt for Receipt<T> {
158168
fn rlp_encoded_length_with_bloom(&self, bloom: &Bloom) -> usize {
159169
let mut len = self.eip2718_encoded_length_with_bloom(bloom);

0 commit comments

Comments
 (0)