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

Bug fixes from garden testing #1093

Merged
merged 5 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,12 @@ func (c *Core) WriteBlock(block *types.Block) {
}
nodeCtx := common.NodeLocation.Context()
if order == nodeCtx {
c.addToAppendQueue(block)
parentHeader := c.GetHeader(block.ParentHash(), block.NumberU64()-1)
if parentHeader != nil {
c.sl.WriteBlock(block)
c.InsertChain([]*types.Block{block})
}
c.addToAppendQueue(block)
// If a dom block comes in and we havent appended it yet
} else if order < nodeCtx && c.GetHeaderByHash(block.Hash()) == nil {
if c.sl.domClient != nil {
Expand Down
24 changes: 19 additions & 5 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 @@ -319,6 +324,7 @@ func (sl *Slice) Append(header *types.Header, domPendingHeader *types.Header, do
"uncles", len(block.Uncles()), "txs", len(block.Transactions()), "etxs", len(block.ExtTransactions()), "gas", block.GasUsed(),
"root", block.Root(),
"order", order,
"location", block.Header().Location(),
"elapsed", common.PrettyDuration(time.Since(start)))

if nodeCtx == common.ZONE_CTX {
Expand All @@ -333,11 +339,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 All @@ -359,7 +365,7 @@ func (sl *Slice) relayPh(block *types.Block, pendingHeaderWithTermini types.Pend
} else {
log.Warn("Pending Header for Best ph key does not exist", "best ph key", sl.bestPhKey)
}
} else if !domOrigin {
} else if !domOrigin && subReorg {
for _, i := range sl.randomRelayArray() {
if sl.subClients[i] != nil {
sl.subClients[i].SubRelayPendingHeader(context.Background(), pendingHeaderWithTermini, pendingHeaderWithTermini.Header().ParentEntropy(), location, subReorg)
Expand Down Expand Up @@ -416,7 +422,7 @@ func (sl *Slice) UpdateDom(oldTerminus common.Hash, newTerminus common.Hash, new
log.Info("pendingHeaderWithTermini:", "parent Hash:", pendingHeaderWithTermini.Header().ParentHash(), "Number", pendingHeaderWithTermini.Header().NumberArray())
for _, i := range sl.randomRelayArray() {
if sl.subClients[i] != nil {
go sl.subClients[i].SubRelayPendingHeader(context.Background(), pendingHeaderWithTermini, newEntropy, location, true)
sl.subClients[i].SubRelayPendingHeader(context.Background(), pendingHeaderWithTermini, newEntropy, location, true)
}
}
}
Expand Down Expand Up @@ -498,6 +504,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