-
Notifications
You must be signed in to change notification settings - Fork 20.9k
WIP: new transaction index #32063
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
base: master
Are you sure you want to change the base?
WIP: new transaction index #32063
Conversation
I personally against this change. Reason: The transaction index is quite heavy. We've chosen to retain indexes for only the last 2,350,000 blocks, yet it’s still substantial with the current format, 40 bytes per entry (32-byte key and 8-byte value).
With this change, the size of the transaction index will increase significantly. The value size is approximately 110 bytes, which would add around 36.9 GB for the past 2,350,000 blocks. EIP-4444 won't mitigate this issue. The situation is even worse for archive nodes, which store all transaction indexes.
|
Yeah, I'm not sure if this is worth it either. Lets discuss in the call today. |
So, here is the breakdown of total CPU time spent (with this PR merged) on parts of the "eth_getTransactionReceipt" RPC over ~400 queries.
We cannot get rid of some of these. For example // TxIndex is the collection of data that is stored per transaction for
// speeding up hashed based lookups
type TxIndex struct {
// Allows us to avoid finding the tx in block body (69 bytes) (~ 27GB per year)
// This gives us ~%7 speed up
Type uint8 // Transaction Type
Nonce uint64 // Transaction Nonce
To *common.Address `rlp:"optional"`
BlobGas uint64 `rlp:"optional"`
TxIndex uint32
Sender common.Address
EffectiveGasPrice *big.Int
// Allows us to avoid reading the header (64 bytes) (~ 25GB per year)
// Gives us ~%13 speed up
BlockNumber uint64
BlockHash common.Hash
BlockTime uint64
BaseFee *big.Int
BlobGasPrice *big.Int `rlp:"optional"`
// Allows us to avoid decoding all the receipts (12 bytes) (~ 5GB per year)
// Walking the receipts is cheap, gives pretty much nothing
GasUsed uint64
LogIndex uint32
} I don't find any of these additions to be worth it. Assuming that most of the |
this is an attempt at reducing wasted effort in GetReceiptByHash by not decoding or deriving unrelated receipts
f66616c
to
e90fa79
Compare
This PR adds a lot of contextual data to be stored in transaction index entry to help with speeding up tx-hash-based RPC queries.
First commit only moves some code around, so the actual changes are in the second commit.