Skip to content

Commit

Permalink
Use bestPh to pick inslice append phHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
kiltsonfire authored and gameofpointers committed Sep 12, 2023
1 parent 56a7c94 commit 923c34d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions core/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,12 @@ func (sl *Slice) Append(header *types.Header, domPendingHeader *types.Header, do

time8 = common.PrettyDuration(time.Since(start))

subReorg = sl.miningStrategy(bestPh, block)
tempPendingHeader, err := sl.generateSlicePendingHeader(block, newTermini, domPendingHeader, domOrigin, false, false)
if err != nil {
return nil, false, err
}

subReorg = sl.miningStrategy(bestPh, tempPendingHeader)

if order < nodeCtx {
// Store the inbound etxs for dom blocks that did not get picked and use
Expand Down Expand Up @@ -333,11 +338,11 @@ func (sl *Slice) Append(header *types.Header, domPendingHeader *types.Header, do
return subPendingEtxs, subReorg, nil
}
}
func (sl *Slice) miningStrategy(bestPh types.PendingHeader, block *types.Block) bool {
func (sl *Slice) miningStrategy(bestPh types.PendingHeader, pendingHeader types.PendingHeader) bool {
if bestPh.Header() == nil { // This is the case where we try to append the block before we have not initialized the bestPh
return true
}
subReorg := sl.poem(sl.engine.TotalLogS(block.Header()), bestPh.Header().ParentEntropy())
subReorg := sl.poem(sl.engine.TotalLogPhS(pendingHeader.Header()), sl.engine.TotalLogPhS(bestPh.Header()))
return subReorg
}

Expand Down Expand Up @@ -498,6 +503,14 @@ func (sl *Slice) generateSlicePendingHeader(block *types.Block, newTermini types
localPendingHeader = types.EmptyHeader()
localPendingHeader.SetParentHash(block.Hash(), nodeCtx)
localPendingHeader.SetNumber(big.NewInt(int64(block.NumberU64()) + 1))
localPendingHeader.SetParentEntropy(sl.engine.TotalLogS(block.Header()))
if nodeCtx != common.PRIME_CTX {
if domOrigin {
localPendingHeader.SetParentDeltaS(big.NewInt(0), nodeCtx)
} else {
localPendingHeader.SetParentDeltaS(sl.engine.DeltaLogS(block.Header()), nodeCtx)
}
}

manifestHash := sl.miner.worker.ComputeManifestHash(block.Header())
localPendingHeader.SetManifestHash(manifestHash)
Expand Down

0 comments on commit 923c34d

Please sign in to comment.