-
Notifications
You must be signed in to change notification settings - Fork 20.9k
core: respect history cutoff in txindexer #31393
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
05624a8
to
85b6921
Compare
85b6921
to
e9e5ab1
Compare
In ethereum#31384 we unindex TXes prior to the merge block. However when the node starts up it will try to re-index those back if the config is to index the whole chain. This change makes the indexer aware of the history cutoff block, avoiding reindexing in that segment. --------- Co-authored-by: Gary Rong <garyrong0905@gmail.com> Co-authored-by: Felix Lange <fjl@twurst.com>
Fixes #31732. This logic was removed in the recent refactoring in the txindexer to handle history cutoff (#31393). It was first introduced in this PR: #28908. I have tested it and it works as an alternative to #31745. This PR packs 3 changes to the flow of fetching txs from the API: - It caches the indexer tail after each run is over to avoid hitting the db all the time as was done originally in #28908. - Changes `backend.GetTransaction`. It doesn't return an error anymore when tx indexer is in progress. It shifts the responsibility to the caller to check the progress. The reason is that in most cases we anyway check the txpool for the tx. If it was indeed a pending tx we can avoid the indexer progress check. --------- Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Fixes ethereum#31732. This logic was removed in the recent refactoring in the txindexer to handle history cutoff (ethereum#31393). It was first introduced in this PR: ethereum#28908. I have tested it and it works as an alternative to ethereum#31745. This PR packs 3 changes to the flow of fetching txs from the API: - It caches the indexer tail after each run is over to avoid hitting the db all the time as was done originally in ethereum#28908. - Changes `backend.GetTransaction`. It doesn't return an error anymore when tx indexer is in progress. It shifts the responsibility to the caller to check the progress. The reason is that in most cases we anyway check the txpool for the tx. If it was indeed a pending tx we can avoid the indexer progress check. --------- Co-authored-by: Gary Rong <garyrong0905@gmail.com>
In ethereum#31384 we unindex TXes prior to the merge block. However when the node starts up it will try to re-index those back if the config is to index the whole chain. This change makes the indexer aware of the history cutoff block, avoiding reindexing in that segment. --------- Co-authored-by: Gary Rong <garyrong0905@gmail.com> Co-authored-by: Felix Lange <fjl@twurst.com>
func (indexer *txIndexer) report(head uint64) TxIndexProgress { | ||
// Special case if the head is even below the cutoff, | ||
// nothing to index. | ||
if head < indexer.cutoff { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check for head == 0
too here because if someone calls some json rpc api methods of getting receipt on an empty blockchain, they will get error txn indexing is in progress
which is a bit misleading because there is no indexing on genesis block @s1na
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you seen this error in practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm yes, I have observed it when writing unit tests with a chain that starts from genesis. When I commit the first transaction to the chain, and wait for its receipt, I keep on getting error txn indexing is in progress
and it keeps on going until the first block is committed. After that getting transaction receipt is smooth and fast
In the #31384 we unindex txes prior to the merge block. However when the node starts up it will try to re-index those back if the config is to index the whole chain.