Skip to content

core: properly reset the statedb on sethead#22247

Merged
holiman merged 4 commits intoethereum:masterfrom
MariusVanDerWijden:debug_sethead_txpoolreset
Feb 3, 2021
Merged

core: properly reset the statedb on sethead#22247
holiman merged 4 commits intoethereum:masterfrom
MariusVanDerWijden:debug_sethead_txpoolreset

Conversation

@MariusVanDerWijden
Copy link
Copy Markdown
Member

This pr fixes an issue where local transactions that were included in the chain before a SetHead could not be replayed since the txpool still had the old statedb after the setHead and would reject them with nonce to low.
For a repro see the linked issue

resolves: #19346

Copy link
Copy Markdown
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

Semantically, this totally LGTM, and it's correct.

However, it would be totally possible to rewrite this a bit, so that instead of updating the things inside of the nested clause, you reorder the clauses a bit so that this case can just fall through. That way we don't need to increase the code size, and you would also get that pool fork update fixed.

Comment thread core/tx_pool.go Outdated
Copy link
Copy Markdown
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM, minor nitpick

Copy link
Copy Markdown
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@antazoey
Copy link
Copy Markdown

I think part of this issue is unresolved:

#26154

gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request May 14, 2024
fixes an issue where local transactions that were included in the chain before a SetHead were rejected if resubmitted, since the txpool had not reset the state to the current (older) state.
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.

debug_setHead causes Clique to hang when period is 0

3 participants