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

Fix sync and migration on compacted state #3472

Merged
merged 1 commit into from Jul 10, 2021
Merged

Conversation

nzpr
Copy link
Collaborator

@nzpr nzpr commented Jul 10, 2021

Overview

Closes #3471

Notes

Please make sure that this PR:

Bors cheat-sheet:

  • bors r+ runs integration tests and merges the PR (if it's approved),
  • bors try runs integration tests for the PR,
  • bors delegate+ enables non-maintainer PR authors to run the above.

@nzpr nzpr added the bug-fix label Jul 10, 2021
@nzpr nzpr added this to the Block merge milestone Jul 10, 2021
@nzpr nzpr requested review from tgrospic and zsluedem July 10, 2021 09:31
@nzpr nzpr added this to In progress in Core team via automation Jul 10, 2021
blocksInfoMap
.get(bh)
// with trimmed state edge parents might not be in the blockmetadataDB, so filter them out
.map(_.parents.toList.filterA(blockMetadataDb.contains(_)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On compacted state finalized block set during migration were including edge blocks parents, which do not exist in metadata store. Fix is filtering them out.

minHeight <- getMinBlockHeight
_ <- heightMap.flatMap(_._2).toList.traverse_ { hash =>
_ <- heightMap.flatMap(_._2).toList.reverse.traverse_ { hash =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have to add LFB first, because each DagStore.insert returns DagRepresentation, which requires having finalized block in DagStore. Also each insert checks consistency of the DAG (heights should be continuous)

private def validateDagState(state: DagState): DagState = {
// Validate height map index (block numbers) are in sequence without holes
val m = state.heightMap
val (min, max) = if (m.nonEmpty) (m.firstKey, m.lastKey + 1) else (0L, 0L)
assert(max - min == m.size.toLong, "DAG store height map has numbers not in sequence.")
state
}

So fix is to add blocks in reverse order - down from LFB.

Copy link
Collaborator

@tgrospic tgrospic left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@zsluedem zsluedem left a comment

Choose a reason for hiding this comment

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

LGTM

@nzpr
Copy link
Collaborator Author

nzpr commented Jul 10, 2021

bors merge

@bors
Copy link
Contributor

bors bot commented Jul 10, 2021

Build succeeded:

@bors bors bot merged commit 46d352e into rchain:dev Jul 10, 2021
Core team automation moved this from In progress to Done Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

Startup and migration error with v0.11.0-rc1
3 participants