You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When --saveReceipts is set, the client maintains in its DB a "transaction index". The "transaction index" is a key/value mapping of txHash > [blockHash, txIndex].
To find a transaction by hash, we look up the txHash to retrieve the blockHash and index (index here meaning which tx in the block.transactions array). We then use the blockHash to retrieve the block, and find the transaction at the right index 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 (via eth_getTransactionByHash), we currently also do an unnecessary retrieval of the receipt from the DB.
Solution:
If we were to maintain the TxIndex independently of Receipts, we could enable Tx lookup by hash without also needing to have --saveReceipts on.
At a very minimum we should refactor getTransactionByHash to avoid the extra DB lookup.
The text was updated successfully, but these errors were encountered:
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: