Skip to content

Commit

Permalink
feat: rename turnTerm to turnLength
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBSC committed Jun 27, 2024
1 parent a68b85a commit 4d2d720
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 120 deletions.
12 changes: 6 additions & 6 deletions cmd/extradump/extradump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestExtraParse(t *testing.T) {
}
}

// case 3, |---Extra Vanity---|---Validators Number and Validators Bytes---|---Turn Term---|---Empty---|---Extra Seal---|
// case 3, |---Extra Vanity---|---Validators Number and Validators Bytes---|---Turn Length---|---Empty---|---Extra Seal---|
{
extraData := "0xd983010209846765746889676f312e31392e3131856c696e75780000a6bf97c1152465176c461afb316ebc773c61faee85a6515daa8a923564c6ffd37fb2fe9f118ef88092e8762c7addb526ab7eb1e772baef85181f892c731be0c1891a50e6b06262c816295e26495cef6f69dfa69911d9d8e4f3bbadb89b977cf58294f7239d515e15b24cfeb82494056cf691eaf729b165f32c9757c429dba5051155903067e56ebe3698678e912d4c407bbe49438ed859fe965b140dcf1aab71a993c1f7f6929d1fe2a17b4e14614ef9fc5bdc713d6631d675403fbeefac55611bf612700b1b65f4744861b80b0f7d6ab03f349bbafec1551819b8be1efea2fc46ca749aa184248a459464eec1a21e7fc7b71a053d9644e9bb8da4853b8f872cd7c1d6b324bf1922829830646ceadfb658d3de009a61dd481a114a2e761c554b641742c973867899d300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000069c77a677c40c7fbea129d4b171a39b7a8ddabfab2317f59d86abfaf690850223d90e9e7593d91a29331dfc2f84d5adecc75fc39ecab4632c1b4400a3dd1e1298835bcca70f657164e5b75689b64b7fd1fa275f334f28e1896a26afa1295da81418593bd12814463d9f6e45c36a0e47eb4cd3e5b6af29c41e2a3a5636430155a466e216585af3ba772b61c6014342d914470ec7ac2975be345796c2b81db0422a5fd08e40db1fc2368d2245e4b18b1d0b85c921aaaafd2e341760e29fc613edd39f71254614e2055c3287a517ae2f5b9e386cd1b50a4550696d957cb4900f03ab84f83ff2df44193496793b847f64e9d6db1b3953682bb95edd096eb1e69bbd357c200992ca78050d0cbe180cfaa018e8b6c8fd93d6f4cea42bbb345dbc6f0dfdb5bec73a8a257074e82b881cfa06ef3eb4efeca060c2531359abd0eab8af1e3edfa2025fca464ac9c3fd123f6c24a0d78869485a6f79b60359f141df90a0c745125b131caaffd12000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b218c5d6af1f979ac42bc68d98a5a0d796c6ab01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b4dd66d7c2c7e57f628210187192fb89d4b99dd4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000be807dddb074639cd9fa61b47676c064fc50d62cb1f2c71577def3144fabeb75a8a1c8cb5b51d1d1b4a05eec67988b8685008baa17459ec425dbaebc852f496dc92196cdcc8e6d00c17eb431350c6c50d8b8f05176b90b11b3a3d4feb825ae9702711566df5dbf38e82add4dd1b573b95d2466fa6501ccb81e9d26a352b96150ccbf7b697fd0a419d1d6bf74282782b0b3eb1413c901d6ecf02e8e28000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e2d3a739effcd3a99387d015e260eefac72ebea1956c470ddff48cb49300200b5f83497f3a3ccb3aeb83c5edd9818569038e61d197184f4aa6939ea5e9911e3e98ac6d21e9ae3261a475a27bb1028f140bc2a7c843318afd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ea0a6e3c511bbd10f4519ece37dc24887e11b55db2d4c6283c44a1c7bd503aaba7666e9f0c830e0ff016c1c750a5e48757a713d0836b1cabfd5c281b1de3b77d1c192183ee226379db83cffc681495730c11fdde79ba4c0c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ef0274e31810c9df02f98fafde0f841f4e66a1cd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004e99f701bb14cb7dfb68b90bd3e6d1ca656964630de71beffc7f33f7f08ec99d336ec51ad9fad0ac84ae77ca2e8ad9512acc56e0d7c93f3c2ce7de1b69149a5a400"
extra, err := parseExtra(extraData)
Expand All @@ -70,10 +70,10 @@ func TestExtraParse(t *testing.T) {
}
}
{
var have = extra.TurnTerm
var have = extra.TurnLength
var want = uint8(4)
if *have != want {
t.Fatalf("extra.TurnTerm mismatch, have %d, want %d", *have, want)
t.Fatalf("extra.TurnLength mismatch, have %d, want %d", *have, want)
}
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestExtraParse(t *testing.T) {
}
}

// case 6, |---Extra Vanity---|---Validators Number and Validators Bytes---|---Turn Term---|---Vote Attestation---|---Extra Seal---|
// case 6, |---Extra Vanity---|---Validators Number and Validators Bytes---|---Turn Length---|---Vote Attestation---|---Extra Seal---|
{
extraData := "0xd883010209846765746888676f312e31392e38856c696e7578000000dc55905c071284214b9b9c85549ab3d2b972df0deef66ac2c98e82934ca974fdcd97f3309de967d3c9c43fa711a8d673af5d75465844bf8969c8d1948d903748ac7b8b1720fa64e50c35552c16704d214347f29fa77f77da6d75d7c752b742ad4855bae330426b823e742da31f816cc83bc16d69a9134be0cfb4a1d17ec34f1b5b32d5c20440b8536b1e88f0f247788386d0ed6c748e03a53160b4b30ed3748cc5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000980a75ecd1309ea12fa2ed87a8744fbfc9b863d589037a9ace3b590165ea1c0c5ac72bf600b7c88c1e435f41932c1132aae1bfa0bb68e46b96ccb12c3415e4d82af717d8a2959d3f95eae5dc7d70144ce1b73b403b7eb6e0b973c2d38487e58fd6e145491b110080fb14ac915a0411fc78f19e09a399ddee0d20c63a75d8f930f1694544ad2dc01bb71b214cb885500844365e95cd9942c7276e7fd8a2750ec6dded3dcdc2f351782310b0eadc077db59abca0f0cd26776e2e7acb9f3bce40b1fa5221fd1561226c6263cc5ff474cf03cceff28abc65c9cbae594f725c80e12d96c9b86c3400e529bfe184056e257c07940bb664636f689e8d2027c834681f8f878b73445261034e946bb2d901b4b87804f8b27bb8608c11016739b3f8a19e54ab8c7abacd936cfeba200f3645a98b65adb0dd3692b69ce0b3ae10e7176b9a4b0d83f04065b1042b4bcb646a34b75c550f92fc34b8b2b1db0fa0d3172db23ba92727c80bcd306320d0ff411bf858525fde13bc8e0370f84c8401e9c2e6a0820dc11d63176a0eb1b828bc5376867b275579112b7013358da40317e7bab6e98401e9c2e7a00edc71ce80105a3220a87bea2792fa340d66c59002f02b0a09349ed1ed28407080048b972fac2b9077a4dcb6fc37093799a652858016c99142b227500c844fa97ec22e3f9d3b1e982f14bcd999a7453e89ce5ef5c55f1c7f8f74ba904186cd67828200"
extra, err := parseExtra(extraData)
Expand Down Expand Up @@ -182,10 +182,10 @@ func TestExtraParse(t *testing.T) {
}
}
{
var have = extra.TurnTerm
var have = extra.TurnLength
var want = uint8(4)
if *have != want {
t.Fatalf("extra.TurnTerm mismatch, have %d, want %d", *have, want)
t.Fatalf("extra.TurnLength mismatch, have %d, want %d", *have, want)
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/extradump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
BLSPublicKeyLength = 48

// follow order in extra field
// |---Extra Vanity---|---Validators Number and Validators Bytes (or Empty)---|---Turn Term (or Empty)---|---Vote Attestation (or Empty)---|---Extra Seal---|
// |---Extra Vanity---|---Validators Number and Validators Bytes (or Empty)---|---Turn Length (or Empty)---|---Vote Attestation (or Empty)---|---Extra Seal---|
extraVanityLength = 32 // Fixed number of extra-data prefix bytes reserved for signer vanity
validatorNumberSize = 1 // Fixed number of extra prefix bytes reserved for validator number after Luban
validatorBytesLength = common.AddressLength + types.BLSPublicKeyLength
Expand All @@ -35,7 +35,7 @@ type Extra struct {
ExtraVanity string
ValidatorSize uint8
Validators validatorsAscending
TurnTerm *uint8
TurnLength *uint8
*types.VoteAttestation
ExtraSeal []byte
}
Expand Down Expand Up @@ -115,10 +115,10 @@ func parseExtra(hexData string) (*Extra, error) {
data = data[validatorBytesTotalLength-validatorNumberSize:]
dataLength = len(data)

// parse TurnTerm
// parse TurnLength
if dataLength > 0 {
if data[0] != '\xf8' {
extra.TurnTerm = &data[0]
extra.TurnLength = &data[0]
data = data[1:]
dataLength = len(data)
}
Expand Down Expand Up @@ -158,8 +158,8 @@ func prettyExtra(extra Extra) {
}
}

if extra.TurnTerm != nil {
fmt.Printf("TurnTerm : %d\n", *extra.TurnTerm)
if extra.TurnLength != nil {
fmt.Printf("TurnLength : %d\n", *extra.TurnLength)
}

if extra.VoteAttestation != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
if ctx.IsSet(utils.OverrideBreatheBlockInterval.Name) {
params.BreatheBlockInterval = ctx.Uint64(utils.OverrideBreatheBlockInterval.Name)
}
if ctx.IsSet(utils.OverrideFixedTurnTerm.Name) {
params.FixedTurnTerm = ctx.Uint64(utils.OverrideFixedTurnTerm.Name)
if ctx.IsSet(utils.OverrideFixedTurnLength.Name) {
params.FixedTurnLength = ctx.Uint64(utils.OverrideFixedTurnLength.Name)
}

backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var (
utils.OverrideMinBlocksForBlobRequests,
utils.OverrideDefaultExtraReserveForBlobRequests,
utils.OverrideBreatheBlockInterval,
utils.OverrideFixedTurnTerm,
utils.OverrideFixedTurnLength,
utils.EnablePersonal,
utils.TxPoolLocalsFlag,
utils.TxPoolNoLocalsFlag,
Expand Down
8 changes: 4 additions & 4 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ var (
Value: params.BreatheBlockInterval,
Category: flags.EthCategory,
}
OverrideFixedTurnTerm = &cli.Uint64Flag{
Name: "override.fixedturnterm",
Usage: "It use fixed or random values for turn terms instead of reading from the contract, only for testing purpose",
Value: params.FixedTurnTerm,
OverrideFixedTurnLength = &cli.Uint64Flag{
Name: "override.fixedturnlength",
Usage: "It use fixed or random values for turn length instead of reading from the contract, only for testing purpose",
Value: params.FixedTurnLength,
Category: flags.EthCategory,
}
SyncModeFlag = &flags.TextMarshalerFlag{
Expand Down
2 changes: 1 addition & 1 deletion consensus/parlia/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ const validatorSetABI = `
},
{
"inputs": [],
"name": "getTurnTerm",
"name": "getTurnLength",
"outputs": [
{
"internalType": "uint256",
Expand Down
48 changes: 24 additions & 24 deletions consensus/parlia/bohrFork.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,49 @@ import (
"github.com/ethereum/go-ethereum/rpc"
)

func (p *Parlia) getTurnTerm(chain consensus.ChainHeaderReader, header *types.Header) (*uint8, error) {
func (p *Parlia) getTurnLength(chain consensus.ChainHeaderReader, header *types.Header) (*uint8, error) {
parent := chain.GetHeaderByHash(header.ParentHash)
if parent == nil {
return nil, errors.New("parent not found")
}

var turnTerm uint8
var turnLength uint8
if p.chainConfig.IsBohr(parent.Number, parent.Time) {
turnTermFromContract, err := p.getTurnTermFromContract(parent)
turnLengthFromContract, err := p.getTurnLengthFromContract(parent)
if err != nil {
return nil, err
}
if turnTermFromContract == nil {
return nil, errors.New("unexpected error when getTurnTermFromContract")
if turnLengthFromContract == nil {
return nil, errors.New("unexpected error when getTurnLengthFromContract")
}
turnTerm = uint8(turnTermFromContract.Int64())
turnLength = uint8(turnLengthFromContract.Int64())
} else {
turnTerm = defaultTurnTerm
turnLength = defaultTurnLength
}
log.Debug("getTurnTerm", "turnTerm", turnTerm)
log.Debug("getTurnLength", "turnLength", turnLength)

return &turnTerm, nil
return &turnLength, nil
}

func (p *Parlia) getTurnTermFromContract(header *types.Header) (turnTerm *big.Int, err error) {
// mock to get turnTerm from the contract
if params.FixedTurnTerm >= 1 && params.FixedTurnTerm <= 9 {
if params.FixedTurnTerm == 2 {
return p.getRandTurnTerm(header)
func (p *Parlia) getTurnLengthFromContract(header *types.Header) (turnLength *big.Int, err error) {
// mock to get turnLength from the contract
if params.FixedTurnLength >= 1 && params.FixedTurnLength <= 9 {
if params.FixedTurnLength == 2 {
return p.getRandTurnLength(header)
}
return big.NewInt(int64(params.FixedTurnTerm)), nil
return big.NewInt(int64(params.FixedTurnLength)), nil
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

method := "getTurnTerm"
method := "getTurnLength"
toAddress := common.HexToAddress(systemcontracts.ValidatorContract)
gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2))

data, err := p.validatorSetABI.Pack(method)
if err != nil {
log.Error("Unable to pack tx for getTurnTerm", "error", err)
log.Error("Unable to pack tx for getTurnLength", "error", err)
return nil, err
}
msgData := (hexutil.Bytes)(data)
Expand All @@ -75,17 +75,17 @@ func (p *Parlia) getTurnTermFromContract(header *types.Header) (turnTerm *big.In
return nil, err
}

if err := p.validatorSetABI.UnpackIntoInterface(&turnTerm, method, result); err != nil {
if err := p.validatorSetABI.UnpackIntoInterface(&turnLength, method, result); err != nil {
return nil, err
}

return turnTerm, nil
return turnLength, nil
}

// getRandTurnTerm returns a random valid value, used to test switching turn terms
func (p *Parlia) getRandTurnTerm(header *types.Header) (turnTerm *big.Int, err error) {
turnTerms := [8]uint8{1, 3, 4, 5, 6, 7, 8, 9}
// getRandTurnLength returns a random valid value, used to test switching turn length
func (p *Parlia) getRandTurnLength(header *types.Header) (turnLength *big.Int, err error) {
turnLengths := [8]uint8{1, 3, 4, 5, 6, 7, 8, 9}
r := mrand.New(mrand.NewSource(int64(header.Time)))
termIndex := int(r.Int31n(int32(len(turnTerms))))
return big.NewInt(int64(turnTerms[termIndex])), nil
lengthIndex := int(r.Int31n(int32(len(turnLengths))))
return big.NewInt(int64(turnLengths[lengthIndex])), nil
}
52 changes: 26 additions & 26 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ const (

checkpointInterval = 1024 // Number of blocks after which to save the snapshot to the database
defaultEpochLength = uint64(100) // Default number of blocks of checkpoint to update validatorSet from contract
defaultTurnTerm = uint8(1) // Default consecutive number of blocks a validator receives priority for block production
defaultTurnLength = uint8(1) // Default consecutive number of blocks a validator receives priority for block production

extraVanity = 32 // Fixed number of extra-data prefix bytes reserved for signer vanity
extraSeal = 65 // Fixed number of extra-data suffix bytes reserved for signer seal
nextForkHashSize = 4 // Fixed number of extra-data suffix bytes reserved for nextForkHash.
turnTermSize = 1 // Fixed number of extra-data suffix bytes reserved for turnTerm
turnLengthSize = 1 // Fixed number of extra-data suffix bytes reserved for turnLength

validatorBytesLengthBeforeLuban = common.AddressLength
validatorBytesLength = common.AddressLength + types.BLSPublicKeyLength
Expand Down Expand Up @@ -128,9 +128,9 @@ var (
// invalid list of validators (i.e. non divisible by 20 bytes).
errInvalidSpanValidators = errors.New("invalid validator list on sprint end block")

// errInvalidTurnTerm is returned if a block contains an
// invalid term of turn (i.e. no data left after parsing validators).
errInvalidTurnTerm = errors.New("invalid turnTerm")
// errInvalidTurnLength is returned if a block contains an
// invalid length of turn (i.e. no data left after parsing validators).
errInvalidTurnLength = errors.New("invalid turnLength")

// errInvalidMixDigest is returned if a block's mix digest is non-zero.
errInvalidMixDigest = errors.New("non-zero mix digest")
Expand All @@ -142,9 +142,9 @@ var (
// list of validators different than the one the local node calculated.
errMismatchingEpochValidators = errors.New("mismatching validator list on epoch block")

// errMismatchingEpochTurnTerm is returned if a sprint block contains a
// turn term different than the one the local node calculated.
errMismatchingEpochTurnTerm = errors.New("mismatching turn term on epoch block")
// errMismatchingEpochTurnLength is returned if a sprint block contains a
// turn length different than the one the local node calculated.
errMismatchingEpochTurnLength = errors.New("mismatching turn length on epoch block")

// errInvalidDifficulty is returned if the difficulty of a block is missing.
errInvalidDifficulty = errors.New("invalid difficulty")
Expand Down Expand Up @@ -375,7 +375,7 @@ func (p *Parlia) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*typ
// On luban fork, we introduce vote attestation into the header's extra field, so extra format is different from before.
// Before luban fork: |---Extra Vanity---|---Validators Bytes (or Empty)---|---Extra Seal---|
// After luban fork: |---Extra Vanity---|---Validators Number and Validators Bytes (or Empty)---|---Vote Attestation (or Empty)---|---Extra Seal---|
// After bohr fork: |---Extra Vanity---|---Validators Number and Validators Bytes (or Empty)---|---Turn Term (or Empty)---|---Vote Attestation (or Empty)---|---Extra Seal---|
// After bohr fork: |---Extra Vanity---|---Validators Number and Validators Bytes (or Empty)---|---Turn Length (or Empty)---|---Vote Attestation (or Empty)---|---Extra Seal---|
func getValidatorBytesFromHeader(header *types.Header, chainConfig *params.ChainConfig, parliaConfig *params.ParliaConfig) []byte {
if len(header.Extra) <= extraVanity+extraSeal {
return nil
Expand All @@ -396,7 +396,7 @@ func getValidatorBytesFromHeader(header *types.Header, chainConfig *params.Chain
end := start + num*validatorBytesLength
extraMinLen := end + extraSeal
if chainConfig.IsBohr(header.Number, header.Time) {
extraMinLen += turnTermSize
extraMinLen += turnLengthSize
}
if num == 0 || len(header.Extra) < extraMinLen {
return nil
Expand All @@ -421,7 +421,7 @@ func getVoteAttestationFromHeader(header *types.Header, chainConfig *params.Chai
num := int(header.Extra[extraVanity])
start := extraVanity + validatorNumberSize + num*validatorBytesLength
if chainConfig.IsBohr(header.Number, header.Time) {
start += turnTermSize
start += turnLengthSize
}
end := len(header.Extra) - extraSeal
if end <= start {
Expand Down Expand Up @@ -902,19 +902,19 @@ func (p *Parlia) prepareValidators(header *types.Header) error {
return nil
}

func (p *Parlia) prepareTurnTerm(chain consensus.ChainHeaderReader, header *types.Header) error {
func (p *Parlia) prepareTurnLength(chain consensus.ChainHeaderReader, header *types.Header) error {
if header.Number.Uint64()%p.config.Epoch != 0 ||
!p.chainConfig.IsBohr(header.Number, header.Time) {
return nil
}

turnTerm, err := p.getTurnTerm(chain, header)
turnLength, err := p.getTurnLength(chain, header)
if err != nil {
return err
}

if turnTerm != nil {
header.Extra = append(header.Extra, *turnTerm)
if turnLength != nil {
header.Extra = append(header.Extra, *turnLength)
}

return nil
Expand Down Expand Up @@ -1051,7 +1051,7 @@ func (p *Parlia) Prepare(chain consensus.ChainHeaderReader, header *types.Header
return err
}

if err := p.prepareTurnTerm(chain, header); err != nil {
if err := p.prepareTurnLength(chain, header); err != nil {
return err
}
// add extra seal space
Expand Down Expand Up @@ -1104,28 +1104,28 @@ func (p *Parlia) verifyValidators(header *types.Header) error {
return nil
}

func (p *Parlia) verifyTurnTerm(chain consensus.ChainHeaderReader, header *types.Header) error {
func (p *Parlia) verifyTurnLength(chain consensus.ChainHeaderReader, header *types.Header) error {
if header.Number.Uint64()%p.config.Epoch != 0 ||
!p.chainConfig.IsBohr(header.Number, header.Time) {
return nil
}

turnTermFromHeader, err := parseTurnTerm(header, p.chainConfig, p.config)
turnLengthFromHeader, err := parseTurnLength(header, p.chainConfig, p.config)
if err != nil {
return err
}
if turnTermFromHeader != nil {
turnTerm, err := p.getTurnTerm(chain, header)
if turnLengthFromHeader != nil {
turnLength, err := p.getTurnLength(chain, header)
if err != nil {
return err
}
if turnTerm != nil && *turnTerm == *turnTermFromHeader {
log.Debug("verifyTurnTerm", "turnTerm", *turnTerm)
if turnLength != nil && *turnLength == *turnLengthFromHeader {
log.Debug("verifyTurnLength", "turnLength", *turnLength)
return nil
}
}

return errMismatchingEpochTurnTerm
return errMismatchingEpochTurnLength
}

func (p *Parlia) distributeFinalityReward(chain consensus.ChainHeaderReader, state *state.StateDB, header *types.Header,
Expand Down Expand Up @@ -1222,7 +1222,7 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
return err
}

if err := p.verifyTurnTerm(chain, header); err != nil {
if err := p.verifyTurnLength(chain, header); err != nil {
return err
}

Expand Down Expand Up @@ -1496,9 +1496,9 @@ func (p *Parlia) Delay(chain consensus.ChainReader, header *types.Header, leftOv
delay = delay - *leftOver
}

// The blocking time should be no more than half of period when snap.TurnTerm == 1
// The blocking time should be no more than half of period when snap.TurnLength == 1
timeForMining := time.Duration(p.config.Period) * time.Second / 2
if snap.TurnTerm > 1 {
if snap.TurnLength > 1 {
if snap.lastBlockInOneTurn(header.Number.Uint64()) {
// To ensure that the next validator produces and broadcasts blocks in a timely manner,
// set the value of timeForMining to a small amount
Expand Down
Loading

0 comments on commit 4d2d720

Please sign in to comment.