[R4R]fix state inconsistent when doing diffsync #628
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR is to fix a possible inconsistent state when doing diffsync. Since it is a syncing vulnerability which impact many clients, will release v1.1.7 especially for this patch.
Rationale
Diffsync will assemble the modification to MPT and snapshot according to the received difflayer and verify against the block header. In some cases(will disclose in future), the modification to MPT and snapshot is incorrect.
The problematic logic is apply too stick condition to modify the smart contract trie: https://github.com/binance-chain/bsc/blob/0b575443c43f47f2f50ed5549d2bcaf7ccc39ab4/core/state_processor.go#L256
Example
The current release, if you come across with bad block error with log message like:
expected tx hash xx, get xx, nonce xx, to xx, value xx, gas xx, gasPrice xx, data xx
. Here are some steps you can try to recover your node:--snapshot=false
--snapshot=true
Changes
All the client that use
diffsync
is suggested to upgradeChecks
It is been verified on Unittest and Testnet.
Related issues
No