@@ -21,14 +21,13 @@ import (
2121 "bytes"
2222 "errors"
2323 "fmt"
24+ "github.com/ethereum/go-ethereum/metrics"
2425 "io"
2526 "math/big"
2627 "math/rand"
2728 "sync"
2829 "time"
2930
30- "github.com/ethereum/go-ethereum/metrics"
31-
3231 "github.com/ethereum/go-ethereum/accounts"
3332 "github.com/ethereum/go-ethereum/common"
3433 "github.com/ethereum/go-ethereum/common/hexutil"
@@ -53,7 +52,7 @@ const (
5352 inmemorySnapshots = 128 // Number of recent vote snapshots to keep in memory
5453 inmemorySignatures = 4096 // Number of recent block signatures to keep in memory
5554
56- wiggleTime = 100 * time .Millisecond // Random delay (per signer) to allow concurrent signers
55+ wiggleTime = 500 * time .Millisecond // Random delay (per signer) to allow concurrent signers
5756)
5857
5958// Clique proof-of-authority protocol constants.
@@ -256,7 +255,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
256255 number := header .Number .Uint64 ()
257256
258257 // Don't waste time checking blocks from the future
259- if header .Time > uint64 (time .Now ().UnixMilli ()) {
258+ if header .Time > uint64 (time .Now ().Unix ()) {
260259 return consensus .ErrFutureBlock
261260 }
262261 // Checkpoint blocks need to enforce zero beneficiary
@@ -347,7 +346,7 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
347346 if parent == nil || parent .Number .Uint64 () != number - 1 || parent .Hash () != header .ParentHash {
348347 return consensus .ErrUnknownAncestor
349348 }
350- if parent .Time + c .config .PeriodMs > header .Time {
349+ if parent .Time + c .config .PeriodMs / 1000 > header .Time {
351350 return errInvalidTimestamp
352351 }
353352 // Verify that the gasUsed is <= gasLimit
@@ -576,10 +575,9 @@ func (c *Clique) Prepare(chain consensus.ChainHeaderReader, header *types.Header
576575 if parent == nil {
577576 return consensus .ErrUnknownAncestor
578577 }
579-
580- header .Time = parent .Time + c .config .PeriodMs
581- if header .Time < uint64 (time .Now ().UnixMilli ()) {
582- header .Time = uint64 (time .Now ().UnixMilli ())
578+ header .Time = parent .Time + c .config .PeriodMs / 1000
579+ if header .Time < uint64 (time .Now ().Unix ()) {
580+ header .Time = uint64 (time .Now ().Unix ())
583581 }
584582 return nil
585583}
@@ -659,7 +657,7 @@ func (c *Clique) Seal(chain consensus.ChainHeaderReader, block *types.Block, res
659657 }
660658 }
661659 // Sweet, the protocol permits us to sign the block, wait for our time
662- delay := time .UnixMilli (int64 (header .Time )).Sub (time .Now ()) // nolint: gosimple
660+ delay := time .Unix (int64 (header .Time ), 0 ).Sub (time .Now ()) // nolint: gosimple
663661 if header .Difficulty .Cmp (diffNoTurn ) == 0 {
664662 // It's not our turn explicitly to sign, delay it a bit
665663 wiggle := time .Duration (len (snap .Signers )/ 2 + 1 ) * wiggleTime
0 commit comments