From d4fecea1fe83ae1e3e06325e737778c746d95b42 Mon Sep 17 00:00:00 2001 From: buddh0 Date: Fri, 6 Sep 2024 14:28:16 +0800 Subject: [PATCH] consensus/parlia: wait more time when processing huge blocks --- consensus/parlia/parlia.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index 4a79ec344b..79ff3f93af 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -68,7 +68,6 @@ const ( wiggleTime = uint64(1) // second, Random delay (per signer) to allow concurrent signers initialBackOffTime = uint64(1) // second - processBackOffTime = uint64(1) // second systemRewardPercent = 4 // it means 1/2^4 = 1/16 percentage of gas fee incoming will be distributed to system @@ -1616,12 +1615,15 @@ func (p *Parlia) Seal(chain consensus.ChainHeaderReader, block *types.Block, res copy(header.Extra[len(header.Extra)-extraSeal:], sig) if p.shouldWaitForCurrentBlockProcess(chain, header, snap) { - log.Info("Waiting for received in turn block to process") + highestVerifiedHeader := chain.GetHighestVerifiedHeader() + // including time for writing and committing blocks + waitProcessEstimate := math.Ceil(float64(highestVerifiedHeader.GasUsed) / float64(100_000_000)) + log.Info("Waiting for received in turn block to process", "waitProcessEstimate(Seconds)", waitProcessEstimate) select { case <-stop: log.Info("Received block process finished, abort block seal") return - case <-time.After(time.Duration(processBackOffTime) * time.Second): + case <-time.After(time.Duration(waitProcessEstimate) * time.Second): if chain.CurrentHeader().Number.Uint64() >= header.Number.Uint64() { log.Info("Process backoff time exhausted, and current header has updated to abort this seal") return