Skip to content

Commit

Permalink
consensus/parlia: micro adjust initial back off time
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 authored and NathanBSC committed Jan 23, 2025
1 parent 085051b commit 278aae7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ const (
validatorBytesLength = common.AddressLength + types.BLSPublicKeyLength
validatorNumberSize = 1 // Fixed number of extra prefix bytes reserved for validator number after Luban

wiggleTime = uint64(1000) // milliseconds, Random delay (per signer) to allow concurrent signers
initialBackOffTime = uint64(1000) // milliseconds
wiggleTime = uint64(1000) // milliseconds, Random delay (per signer) to allow concurrent signers
defaultInitialBackOffTime = uint64(1000) // milliseconds, Backoff time for the second validator permitted to produce blocks

systemRewardPercent = 4 // it means 1/2^4 = 1/16 percentage of gas fee incoming will be distributed to system

Expand Down Expand Up @@ -2097,7 +2097,10 @@ func (p *Parlia) backOffTime(snap *Snapshot, header *types.Header, val common.Ad
log.Debug("backOffTime", "blockNumber", header.Number, "in turn validator", val)
return 0
} else {
delay := initialBackOffTime
delay := defaultInitialBackOffTime
if p.chainConfig.IsLorentz(header.Number, header.Time) && snap.lastBlockInOneTurn(header.Number.Uint64()) {
delay = uint64(snap.BlockInterval) / 2
}
validators := snap.validators()
if p.chainConfig.IsPlanck(header.Number) {
counts := snap.countRecents()
Expand Down
2 changes: 1 addition & 1 deletion consensus/parlia/parlia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func producerBlockDelay(candidates map[int]bool, height, numOfValidators int) (i
minCandidate = c
}
}
delay := initialBackOffTime + uint64(minDelay)*wiggleTime
delay := defaultInitialBackOffTime + uint64(minDelay)*wiggleTime
return minCandidate, delay
}

Expand Down

0 comments on commit 278aae7

Please sign in to comment.