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
Conversation
blocksInfoMap | ||
.get(bh) | ||
// with trimmed state edge parents might not be in the blockmetadataDB, so filter them out | ||
.map(_.parents.toList.filterA(blockMetadataDb.contains(_))) |
There was a problem hiding this comment.
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 => |
There was a problem hiding this comment.
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)
rchain/block-storage/src/main/scala/coop/rchain/blockstorage/dag/BlockMetadataStore.scala
Lines 186 to 192 in 56c35c0
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bors merge |
Build succeeded: |
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.