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 state inconsistent when doing diffsync #628

Merged
merged 3 commits into from
Dec 5, 2021

Conversation

unclezoro
Copy link
Collaborator

@unclezoro unclezoro commented Dec 4, 2021

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:

  1. Stop The node.
  2. Upgrade the binary to the release with this patch.
  3. Start your node with --snapshot=false
  4. Wait for few minutes(it depends on how fast your nodes are), until the block height is 128 higher than where it stopped.
  5. Restart the node with --snapshot=true
  6. The node will continue to sync and repair the corrupt data.

Changes

All the client that use diffsync is suggested to upgrade

Checks

It is been verified on Unittest and Testnet.

Related issues

No

@unclezoro unclezoro changed the title [WIP]fix state inconsistent between snapshot and MPT when doing diffsync [WIP]fix state inconsistent when doing diffsync Dec 5, 2021
Copy link
Contributor

@KeefeL KeefeL left a comment

Choose a reason for hiding this comment

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

LGTM

@unclezoro unclezoro changed the title [WIP]fix state inconsistent when doing diffsync [R4R]fix state inconsistent when doing diffsync Dec 5, 2021
@unclezoro unclezoro changed the base branch from master to develop December 5, 2021 03:34
@unclezoro unclezoro changed the base branch from develop to master December 5, 2021 03:35
@unclezoro unclezoro mentioned this pull request Dec 5, 2021
@unclezoro unclezoro merged commit 74f6b61 into bnb-chain:master Dec 5, 2021
@liuyangc3
Copy link

liuyangc3 commented Dec 6, 2021

In some cases(will disclose in future)...

Hi @guagualvcha Can you provide more info about this?

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.

None yet

4 participants