Skip to content

Commit

Permalink
Fix syncing issue, init db with genesis manifest. Remove genesis chec…
Browse files Browse the repository at this point in the history
…k in headerchain:Append.
  • Loading branch information
Djadih committed Jun 15, 2023
1 parent d36708f commit 927e152
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 6 additions & 8 deletions core/headerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,12 @@ func (hc *HeaderChain) Append(batch ethdb.Batch, block *types.Block, newInboundE
// coincident with a higher order chain. So, this check is skipped for prime
// nodes.
if nodeCtx > common.PRIME_CTX {
if block.ParentHash() != hc.config.GenesisHash {
manifest := rawdb.ReadManifest(hc.headerDb, block.ParentHash())
if manifest == nil {
return errors.New("manifest not found for parent")
}
if block.ManifestHash(nodeCtx) != types.DeriveSha(manifest, trie.NewStackTrie(nil)) {
return errors.New("manifest does not match hash")
}
manifest := rawdb.ReadManifest(hc.headerDb, block.ParentHash())
if manifest == nil {
return errors.New("manifest not found for parent")
}
if block.ManifestHash(nodeCtx) != types.DeriveSha(manifest, trie.NewStackTrie(nil)) {
return errors.New("manifest does not match hash")
}
}
elapsedCollectBlockManifest := common.PrettyDuration(time.Since(collectBlockManifest))
Expand Down
1 change: 1 addition & 0 deletions core/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ func (sl *Slice) init(genesis *Genesis) error {
// Initialize slice state for genesis knot
genesisTermini := []common.Hash{genesisHash, genesisHash, genesisHash, genesisHash}
rawdb.WriteTermini(sl.sliceDb, genesisHash, genesisTermini)
rawdb.WriteManifest(sl.sliceDb, genesisHash, types.BlockManifest{genesisHash})

// Append each of the knot blocks
sl.bestPhKey = genesisHash
Expand Down

0 comments on commit 927e152

Please sign in to comment.