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

[R4R] fix validator pipecommit issue #877

Merged

Conversation

forcodedancing
Copy link
Contributor

@forcodedancing forcodedancing commented Apr 27, 2022

Description

If a validator runs 1.1.9 with pipecommit enabled, sometimes it will fail to write block due to incorrect account roots, like this:

t=2022-04-25T05:11:48+0000 lvl=info msg=“Sealing block with”                    number=17,244,681 delay=2.740279174s  headerDifficulty=2 val=0x70F657164e5b75689b64B7fd1fA275F334f28e18
t=2022-04-25T05:11:51+0000 lvl=eror msg=“Failed writing block to chain”         err=“can’t create storage trie: missing trie node 542e5fc2709de84248e9bce43a9c0c8943a608029001360f8ab55bf113b23d28 (path )”

This pr fix this issue by calling CorrectAccountsRoot before commit the block in mining.

Rationale

In pipecommit, the account roots are populated with dummy data, in the importing process the account roots are corrected, however, they are not corrected in the mining process. If the miner uses dummy roots to commit block, there will be errors.

Example

Fix with this pr, validators can commit block successfully.

t=2022-04-27T08:58:03+0000 lvl=info msg="Commit new mining work"                 number=17,306,482 sealhash=0xd73b981fe17df5e509a7bb9187f3bc7aa605b060691ab83175adbd9aeaa093f6 uncles=0 txs=0    gas=24428   elapsed=19.800ms
t=2022-04-27T08:58:03+0000 lvl=info msg="Sealing block with"                     number=17,306,482 delay=-132.915737ms headerDifficulty=1 val=0x0075E536980C629619a44d489De40837551f82FF
t=2022-04-27T08:58:03+0000 lvl=info msg="Successfully sealed new block"          number=17,306,482 sealhash=0xd73b981fe17df5e509a7bb9187f3bc7aa605b060691ab83175adbd9aeaa093f6 hash=0x8eba9ca7775c565d621acad75333da58a2c7bd85dbf70fd9cb686c514938f6d5 elapsed="697.7µs"
t=2022-04-27T08:58:03+0000 lvl=info msg="🔨 mined potential block"                number=17,306,482 hash=0x8eba9ca7775c565d621acad75333da58a2c7bd85dbf70fd9cb686c514938f6d5

Changes

Notable changes:

  • fix account roots during mining

@forcodedancing forcodedancing changed the title [WIP] fix validator pipecommit issue [R4R] fix validator pipecommit issue Apr 27, 2022
unclezoro
unclezoro previously approved these changes Apr 28, 2022
Microcom88
Microcom88 previously approved these changes Apr 28, 2022
keefel
keefel previously approved these changes Apr 28, 2022
calmbeing
calmbeing previously approved these changes Apr 28, 2022
core/state/statedb.go Outdated Show resolved Hide resolved
@bnb-chain bnb-chain deleted a comment from Lippertt Apr 29, 2022
@unclezoro unclezoro merged commit 5b5abc4 into bnb-chain:develop Apr 29, 2022
j75689 pushed a commit to j75689/bsc that referenced this pull request Jun 15, 2022
* fix validator account root issue in piepecommit

* fix test and imports

* add check for snap

* refacto a bit
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.

7 participants