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

cmd/geth: fix error when writing state history after covert from hbss to pbss #1906

Merged
merged 1 commit into from
Oct 8, 2023

Conversation

fynnss
Copy link
Contributor

@fynnss fynnss commented Oct 7, 2023

Description

When trieNode is converted from hbss to pbss format, the historical state data also needs to be modified accordingly, otherwise the following error will occur:

t=2023-10-07T11:11:19+0800 lvl=eror msg="WriteStateHistory failed" err="the append operation is out-order: have 443956 want 0"

Rationale

This PR modifies the meta of the freezer table to avoid the above error, and enables continued writing of historical state after block chasing.

Example

./geth db hbss-to-pbss --datadir ./node 5000

Changes

Notable changes:

  • Refactor the hbss2pbss tools
  • Add state ancient repair function

@fynnss fynnss force-pushed the fix_state_history_write_error branch from 341cbcc to e02ad5c Compare October 7, 2023 06:28
@fynnss fynnss changed the title cmd/geth: Fix error when writing state history after covert from hbss to pbss cmd/geth: fix error when writing state history after covert from hbss to pbss Oct 7, 2023
@fynnss fynnss force-pushed the fix_state_history_write_error branch from e02ad5c to 4259f4c Compare October 7, 2023 06:42
op.AppendRaw(stateHistoryAccountData, id-1, accounts)
op.AppendRaw(stateHistoryStorageData, id-1, storages)
err := op.AppendRaw(stateHistoryMeta, id-1, meta)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did the community ignore this error?
Why can't we ignore it?

Copy link
Contributor Author

@fynnss fynnss Oct 7, 2023

Choose a reason for hiding this comment

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

It's possible that this issue hasn't come up for them before.

And we also ignore it. Take a look at the code in db.ModifyAncients and WriteStateHistory. In these sections, we intentionally disregard this error and don't propagate it further.

Copy link

@RenRick RenRick left a comment

Choose a reason for hiding this comment

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

LGTM

@fynnss fynnss merged commit 5cd647b into bnb-chain:develop Oct 8, 2023
5 checks passed
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