Skip to content

feat: add retry to get_receipts#1847

Merged
KolbyML merged 2 commits into
ethereum:masterfrom
KolbyML:retry-for-Receipt
May 22, 2025
Merged

feat: add retry to get_receipts#1847
KolbyML merged 2 commits into
ethereum:masterfrom
KolbyML:retry-for-Receipt

Conversation

@KolbyML
Copy link
Copy Markdown
Member

@KolbyML KolbyML commented May 22, 2025

This PR is a requirement for

What was wrong?

There is a delay for when receipts become available, as the EL has to generate them. I add something similar to this code because we needed it to make the latest bridge reliable. Due to the aforementioned issue above. I removed this logic in this PR #1757 well optimizing the Single-E2HS-Writer, because we no longer used this functionality.

How was it fixed?

Added the retry mechanism back, but only for get_receipts(), because it isn't needed in get_receipts_range as that function doesn't really have a reason to be used at the head of the chain.

I choose 5, because as I have seen delays of 3 seconds

@KolbyML KolbyML requested a review from morph-dev May 22, 2025 05:22
@KolbyML KolbyML self-assigned this May 22, 2025
@KolbyML KolbyML force-pushed the retry-for-Receipt branch from 21a29a5 to 9f73576 Compare May 22, 2025 05:45
Ok((content_key, content_value))
}

/// This function should only be used if we know the receipts should exist.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you clarify what you mean by: "if we know the receipts should exist"?
It implies that somebody might use it when either:

  • they know it doesn't exist (in which case, why would they call it in the first place?)
  • they are not sure if it exists. How can this happen? What should they do instead?

nit: somewhat less important, the first line of the function documentation usually stats on high level what function does, and the other lines describe more detailed behaviour

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok I updated the documentation, to make it more clear

/// This function should only be used if we know the receipts should exist.
///
/// The function will retry 5 times if the receipts are not ready yet.
/// Especially when querying for receipts at the end of the chain their is a delay until they
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Especially when querying for receipts at the end of the chain their is a delay until they
/// Especially when querying for receipts at the head of the chain, there is a delay until they

/// The function will retry 5 times if the receipts are not ready yet.
/// Especially when querying for receipts at the end of the chain their is a delay until they
/// become available.
pub async fn get_receipts(&self, block_number: u64) -> anyhow::Result<Receipts> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: would it make sense to have two functions:

  • get_receipts - without retry logic
  • get_receipts_retry - with retry logic, that would call get_receipts

Up to you

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this method is inherently more reliable so there is only upside's in all our usages. For example in the e2hs-writer head bridge I seen it fail to get receipts once, so it is fairly rare, but an EL can return null for any reason

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So I will just keep it as 1

@KolbyML KolbyML merged commit f4e7050 into ethereum:master May 22, 2025
16 checks passed
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.

2 participants