Skip to content
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

core: fix a crash in tx_pool.go when debug.setHead is used #1

Closed
wants to merge 1 commit into from

Conversation

albrow
Copy link

@albrow albrow commented May 9, 2018

This mirrors a PR to upstream. See ethereum#16713 for more information about the fix. I would suggest we wait for feedback from the Geth team before merging and use the sethead-txpool-fix branch for our development in the meantime.

Copy link

@fabioberger fabioberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving but happy to wait on merging.

@fabioberger
Copy link

fabioberger commented May 10, 2018

Comment by @recmo:
"After reading on the problem and the proposed solution I’m left wondering how Geth handles chain re-organizations. In that case you also rewind the chain.
In a re-org you would immediately grow it again with a chain of blocks that is at least as high (due to longest chain fork-choice rule)
But still, pointers to old headers which are now uncles could exist"

@albrow
Copy link
Author

albrow commented May 10, 2018

@recmo I'm still new to the codebase, but I can take a stab at answering this. It looks like it has something to do with these lines:

rem = pool.chain.GetBlock(oldHead.Hash(), oldHead.Number.Uint64())
add = pool.chain.GetBlock(newHead.Hash(), newHead.Number.Uint64())

For context, oldHead and newHead are block headers which we were tracking in a previous part of the code. I think the purpose of calling pool.chain.GetBlock here is to account for the fact that there could have been a re-org and the blocks we were tracking could have become uncles. But in that case, the blocks still exist in the chain. The reason debug.setHead breaks this is that one of the blocks we were tracking hasn't just moved; it no longer exists. So pool.chain.GetBlock(oldHead.Hash(), oldHead.Number.Uint64()) was returning nil.

@albrow albrow force-pushed the sethead-txpool-fix branch 2 times, most recently from e9a12cb to feacac7 Compare May 15, 2018 22:14
@albrow albrow closed this Apr 11, 2019
@albrow albrow deleted the sethead-txpool-fix branch April 11, 2019 23:26
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.

3 participants