Skip to content

Conversation

@haardikk21
Copy link
Collaborator

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
Collaborator 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
};
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
Collaborator 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

@jowparks
Copy link
Collaborator

The diff looks crazy, does this need a rebase or something? I came back to approve this morning and looks like a bunch of cache stuff is in there.

@haardikk21 haardikk21 force-pushed the haardik/cache-read-race-condition branch from 337d51c to 4bec491 Compare May 14, 2025 19:05
@haardikk21
Copy link
Collaborator Author

The diff looks crazy, does this need a rebase or something? I came back to approve this morning and looks like a bunch of cache stuff is in there.

messed up previous rebase a bit. should be fine now.

@haardikk21 haardikk21 requested a review from jowparks May 14, 2025 19:08
@haardikk21 haardikk21 merged commit 6a6223b into main May 28, 2025
6 checks passed
0xsimulacra pushed a commit to 0xsimulacra/base-node-reth that referenced this pull request Oct 1, 2025
…se#28)

* preload txn receipt from eth_api for historical deposit txns

* error handle being unable to load txn receipt

* propogate upstream RPC error to client separately

* update cache to use structured keys

* preload txn receipt from eth_api for historical deposit txns

* remove old comment

* clean up match statement
@danyalprout danyalprout deleted the haardik/cache-read-race-condition branch October 10, 2025 19:00
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.

5 participants