-
Notifications
You must be signed in to change notification settings - Fork 817
No TX Index without ReceiptsManager #3926
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
Comments
Can we use this issue to write down the database key/values we are currently maintaining and if those are always present or only present under a flag? How do other clients do this? It seems to me that our lookup of It would make sense to me for a txhash to create a table for the txhashes, and then in this table store two things: (1) the tx data itself and (2) the blockhash it is included in in the canonical chain. (So we can also lookup in whatever block it was included, or if it was not included at all (pending txs in mempool would not have a blockhash field but would have a data field)) |
@jochem-brouwer i think this is comprehensive. i'm not sure about the
|
I am curious too, but i believe that others do the same. we wouldn't want to store tx data, because we're already storing it in the block bodies. as far as i know, looking up the blockhash and index (meaning which tx in the block does the hash refer), and then finding the tx data in the block is a pretty standard approach. |
Context:
When
--saveReceipts
is set, the client maintains in its DB a "transaction index". The "transaction index" is a key/value mapping oftxHash
>[blockHash, txIndex]
.To find a transaction by hash, we look up the
txHash
to retrieve theblockHash
andindex
(index
here meaning whichtx
in theblock.transactions
array). We then use theblockHash
to retrieve the block, and find thetransaction
at the rightindex
in that block.Problem:
This is only possible via the
ReceiptsManager
, which only exists if--saveReceipts
is on. Transactions are not indexed otherwise. This does not feel like a necessary coupling. Additionally, in the process of looking up a transaction by hash (viaeth_getTransactionByHash
), we currently also do an unnecessary retrieval of thereceipt
from the DB.Solution:
If we were to maintain the
TxIndex
independently ofReceipts
, we could enable Tx lookup by hash without also needing to have--saveReceipts
on.getTransactionByHash
to avoid the extra DB lookup.The text was updated successfully, but these errors were encountered: