Skip to content

Commit

Permalink
Compute the manifest only once
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers committed Oct 2, 2023
1 parent ff5a143 commit 09a6d19
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions core/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -888,20 +888,24 @@ func (w *worker) adjustGasLimit(interrupt *int32, env *environment, parent *type
// ComputeManifestHash given a header computes the manifest hash for the header
// and stores it in the database
func (w *worker) ComputeManifestHash(header *types.Header) common.Hash {
nodeCtx := common.NodeLocation.Context()
// Compute and set manifest hash
manifest := types.BlockManifest{}
if nodeCtx == common.PRIME_CTX {
// Nothing to do for prime chain
// check if the manifest was already computed
manifest := rawdb.ReadManifest(w.workerDb, header.Hash())
if manifest != nil {
nodeCtx := common.NodeLocation.Context()
// Compute and set manifest hash
manifest = types.BlockManifest{}
} else if w.engine.IsDomCoincident(w.hc, header) {
manifest = types.BlockManifest{header.Hash()}
} else {
parentManifest := rawdb.ReadManifest(w.workerDb, header.ParentHash())
manifest = append(parentManifest, header.Hash())
if nodeCtx == common.PRIME_CTX {
// Nothing to do for prime chain
manifest = types.BlockManifest{}
} else if w.engine.IsDomCoincident(w.hc, header) {
manifest = types.BlockManifest{header.Hash()}
} else {
parentManifest := rawdb.ReadManifest(w.workerDb, header.ParentHash())
manifest = append(parentManifest, header.Hash())
}
// write the manifest into the disk
rawdb.WriteManifest(w.workerDb, header.Hash(), manifest)
}
// write the manifest into the disk
rawdb.WriteManifest(w.workerDb, header.Hash(), manifest)
manifestHash := types.DeriveSha(manifest, trie.NewStackTrie(nil))

return manifestHash
Expand Down

0 comments on commit 09a6d19

Please sign in to comment.