Fix for "transaction indexing is in progress" #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue that we've had in our differential testing framework where we would sometimes fail to get the transaction receipt of certain transactions and would instead get the error "transaction indexing is in progress" as can be seen in the following logs:
Description
I have added a comment to the code that explains this entire issue that we have been having with "transaction indexing is in progress", but will also re-iterate it here in the PR description. The hope is that we would keep that comment in the code so that it's context for future us to know why we're doing getting the receipt in this way.
In Geth, before we can get a transaction receipt of a committed transaction, the transaction must be indexed first by the transaction indexer. The indexer runs in a separate process and therefore if a transaction is committed it doesn't necessarily mean that the transaction has been indexed and that we can get its receipt. Attempting to get the receipt before the indexer has indexed it returns the error: "transaction indexing is in progress". Some of the ecosystem tooling have deployed a fix for this in the form of retrying to get the receipt if the RPC method returns "transaction indexing is in progress".
In alloy, once it sees that a transaction has been confirmed it assumes that it has also been indexed and therefore they attempt to immediately get the receipt, which could fail as the indexer could still be running trying to index the transaction as seen here.
I have implemented similar logic to Web3.py in this PR where we retry getting the receipt if it fails with up to a maximum number of retries. If the receipt is found it's returned.