Skip to content

fix: Preload txn receipt from eth_api for historical deposit txns #28

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

haardikk21
Copy link
Contributor

The Flashblocks RPC had a bug where it would panic if getTransactionByHash was used to load historical deposit transactions.

These transactions did not exist in the mempool (system transaction) and did not exist in the cache (historical transaction) but in the case of deposit transactions we would always try to fetch a receipt from the cache to populate deposit_receipt_version and deposit_nonce.

Since we did unwrap() without an error check in that path, it would cause a panic.

This PR attempts to fix that by pre-loading the deposit transaction receipt from eth_api in case a historical deposit transaction is attempted to be fetched via getTransactionByHash.


P.S. Opened this PR as the forked repo PR did not allow me to trigger a base-builds sepolia alpha deployment to test without more changes than necessary to those Dockerfiles.

Edit; ignore the branch name. i thought the root cause was a race condition, it was not.

@haardikk21
Copy link
Contributor Author

The codebase has several other places where unsafe .unwrap() usage exists. Those broader fixes are out of scope for this PR as this focuses solely on fixing the reported bug of fetching historical deposit transactions. I will do a separate PR to remove unsafe unwraps everywhere else later.

@haardikk21 haardikk21 requested a review from jowparks May 13, 2025 18:56
@@ -387,7 +395,41 @@ where
block_number: Some(block_number),
base_fee,
};
Ok(Some(self.transform_tx(transaction, tx_info)))
// preload transaction receipt if it's a deposit transaction
if transaction.is_deposit() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did all this move to this method and pass in the receipt? Why not keep this logic in the transform_tx and prevent the addition of the receipt param? That way if the method is used anywhere else we won't have to replicate this logic. Otherwise looks good

Copy link
Contributor Author

@haardikk21 haardikk21 May 13, 2025

Choose a reason for hiding this comment

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

pretty much to avoid marking a bunch of other functions async because rust has colored functions

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