Skip to content

Comments

feat(consensus): add EthereumReceipt type ported from reth#3683

Merged
mattsse merged 3 commits intoalloy-rs:mainfrom
stevencartavia:tx-type-on-tx-receipt-trait
Feb 17, 2026
Merged

feat(consensus): add EthereumReceipt type ported from reth#3683
mattsse merged 3 commits intoalloy-rs:mainfrom
stevencartavia:tx-type-on-tx-receipt-trait

Conversation

@stevencartavia
Copy link
Contributor

@stevencartavia stevencartavia commented Feb 13, 2026

Motivation

Port reth's EthereumReceipt into alloy-consensus as a step towards unifying receipt types between alloy and reth.

Solution

Add crates/consensus/src/receipt/receipt2.rs containing:

  • TxTy trait — bounds alias for the tx type generic (Debug + Copy + Eq + Send + Sync + InMemorySize + Typed2718 + TryFrom<u8> + Decodable + 'static)
  • EthereumReceipt<T, L> struct — generic over tx type and log type, with tx_type, success, cumulative_gas_used, logs fields
  • Trait impls: TxReceipt, Typed2718, IsTyped2718, Eip2718EncodableReceipt, Eip2718DecodableReceipt, RlpEncodableReceipt, RlpDecodableReceipt, InMemorySize
  • From conversions: ReceiptEnvelope → EthereumReceipt, EthereumReceipt → Receipt, EthereumReceipt<TxType> → ReceiptEnvelope
  • serde_bincode_compat module for bincode serialization support

Wire it up via mod.rs and re-export EthereumReceipt and TxTy from the crate root.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

following my review, this change is breaking

@onbjerg onbjerg added the breaking Breaking changes have been made label Feb 13, 2026
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we need this logic then we should be able to selectively enforce the Typed trait but always requiring a txtype introduces issues for

pub struct Receipt<T = Log> {

@github-project-automation github-project-automation bot moved this to In Progress in Alloy Feb 14, 2026
@stevencartavia stevencartavia changed the title feat: add tx_type() to TxReceipt trait feat: add tx_type field to Receipt Feb 15, 2026
@stevencartavia
Copy link
Contributor Author

Updated based on review, tx_type() is no longer on the TxReceipt trait. Instead, Receipt now has a tx_type: u8 field exposed via Typed2718. TransactionReceipt::tx_type() bounds on Typed2718 instead of TxReceipt.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@klkvr how should we solve this

maybe upstream:

https://github.com/paradigmxyz/reth/blob/main/crates/ethereum/primitives/src/receipt.rs#L55-L69

keep alloy's receipt type (maybe rename as RawReceipt or smth)
and mark envelope type as deprecated

Comment on lines 61 to 69
let mut receipt = receipt.into();
receipt.receipt.tx_type = tx_type as u8;
match tx_type {
TxType::Legacy => Self::Legacy(receipt.into()),
TxType::Eip2930 => Self::Eip2930(receipt.into()),
TxType::Eip1559 => Self::Eip1559(receipt.into()),
TxType::Eip4844 => Self::Eip4844(receipt.into()),
TxType::Eip7702 => Self::Eip7702(receipt.into()),
TxType::Legacy => Self::Legacy(receipt),
TxType::Eip2930 => Self::Eip2930(receipt),
TxType::Eip1559 => Self::Eip1559(receipt),
TxType::Eip4844 => Self::Eip4844(receipt),
TxType::Eip7702 => Self::Eip7702(receipt),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit redundant imo

@stevencartavia stevencartavia force-pushed the tx-type-on-tx-receipt-trait branch from c1ed2fb to 82126b3 Compare February 17, 2026 00:00
@stevencartavia stevencartavia changed the title feat: add tx_type field to Receipt feat(consensus): add EthereumReceipt type ported from reth Feb 17, 2026
@github-project-automation github-project-automation bot moved this from In Progress to Reviewed in Alloy Feb 17, 2026
@mattsse mattsse merged commit a555eba into alloy-rs:main Feb 17, 2026
30 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in Alloy Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking changes have been made

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants