Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network: Add status method to ReceiptResponse trait #846

Merged
merged 5 commits into from
Jun 12, 2024

Conversation

moricho
Copy link
Contributor

@moricho moricho commented Jun 7, 2024

Motivation

from: #845

It would be helpful to know the tx status from the receipt gotten by get_receipt method in PendingTransactionBuilder or by get_transaction_receipt in Provider.

Solution

Define status method in ReceiptResponse trait and implement it in TransactionReceipt for each network

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@prestwich
Copy link
Member

prestwich commented Jun 7, 2024

directionally approve. can you copy the doc warnings from #848 ?

    /// ## Note
    ///
    /// Caution must be taken when using this method for deep-historical
    /// receipts, as it may not accurately reflect the status of the
    /// transaction. The transaction status is not knowable from the receipt
    /// for transactions before [EIP-658].
    ///
    /// This can be handled using [`TxReceipt::status_or_post_state`].
    ///
    /// [EIP-658]: https://eips.ethereum.org/EIPS/eip-658

@prestwich
Copy link
Member

cc @mattsse should type ReceiptResponse: ReceiptResponse also be constrained to + AsRef<Self::ReceiptEnvelope> to ensure that network implementers ALWAYS embed the envelope in the response?

@mattsse
Copy link
Member

mattsse commented Jun 8, 2024

ah, right this way we could enforce embedding the receipt type in rpc, so ReceiptResponse is Receipt + BlockContext

this makes sense, then we could also add Into<Self::ReceiptEnvelope>

@prestwich
Copy link
Member

this is more work than belongs in this PR. captured in #854

@moricho moricho marked this pull request as ready for review June 11, 2024 09:58
@moricho
Copy link
Contributor Author

moricho commented Jun 11, 2024

@prestwich Added the doc warnings ✅

Comment on lines 39 to 49
/// ## Note
///
/// Caution must be taken when using this method for deep-historical
/// receipts, as it may not accurately reflect the status of the
/// transaction. The transaction status is not knowable from the receipt
/// for transactions before [EIP-658].
///
/// This can be handled using [`TxReceipt::status_or_post_state`].
///
/// [EIP-658]: https://eips.ethereum.org/EIPS/eip-658
/// [`TxReceipt::status_or_post_state`]: alloy_consensus::TxReceipt::status_or_post_state
Copy link
Member

Choose a reason for hiding this comment

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

duplicating the docs is not necessary imo

Copy link
Member

Choose a reason for hiding this comment

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

i'd like the docs to be on every place the user may encounter this (potentially confusing) behavior

Copy link
Member

Choose a reason for hiding this comment

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

trait impls never need docstrings tho :)

Copy link
Member

Choose a reason for hiding this comment

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

yes, they are inherited from the trait definition, pls remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got it, removed the docs from the trait impls: b42dce5

@moricho moricho requested a review from mattsse June 12, 2024 02:46
@prestwich prestwich merged commit 6c9defc into alloy-rs:main Jun 12, 2024
22 checks passed
@moricho moricho deleted the receipt-status branch June 12, 2024 06:36
ben186 pushed a commit to ben186/alloy that referenced this pull request Jul 27, 2024
* network: Add status func to ReceiptResponse trait

* Add doc warnings

* Fix doc test

* Fix doc test

* Remove unnecessary docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants