Skip to content

Conversation

futreall
Copy link
Contributor

Implements transaction_receipts_stream method in EthPubSub similar to new_headers_stream.
Adds build_convert_receipt_inputs helper function in rpc-convert for reusability.
Prep work for alloy-rs/alloy#2974.

Closes #19055

Copy link
Collaborator

@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.

cool, a few suggestions

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Oct 16, 2025
@mattsse mattsse added C-enhancement New feature or request A-rpc Related to the RPC implementation labels Oct 16, 2025
@futreall
Copy link
Contributor Author

@mattsse re point 4: should I wire this into the match statement now even though SubscriptionKind::TransactionReceipts doesn't exist yet in alloy? Or is the current approach with separate impl block fine until alloy 2974 lands?

Copy link
Collaborator

@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.

few more nits and q for @klkvr

) -> Vec<ConvertReceiptInput<'a, N>>
where
N::SignedTx: TxHashRef,
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

@klkvr thoughts on this

whould we perhaps make this a native fn of RecoveredBlock ?

Copy link
Member

Choose a reason for hiding this comment

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

yep sgtm, thoughConvertReceiptInput::from_block_and_receipts might be eaiser here because ConvertReceiptInput is RPC-only type

also I would prefer this to be re-used in

let inputs = block
.transactions_recovered()
.zip(Arc::unwrap_or_clone(receipts))
.enumerate()
.map(|(idx, (tx, receipt))| {
let meta = TransactionMeta {
tx_hash: *tx.tx_hash(),
index: idx as u64,
block_hash,
block_number,
base_fee,
excess_blob_gas,
timestamp,
};
let cumulative_gas_used = receipt.cumulative_gas_used();
let logs_len = receipt.logs().len();
let input = ConvertReceiptInput {
tx,
gas_used: cumulative_gas_used - gas_used,
next_log_index,
meta,
receipt,
};
gas_used = cumulative_gas_used;
next_log_index += logs_len;
input
})
.collect::<Vec<_>>();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattsse separate PR for the refactor or include here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@futreall let's do a separate one for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rpc Related to the RPC implementation C-enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Add subscription stream function for transaction receipts

3 participants