Skip to content

Commit 0172aa6

Browse files
authored
Merge pull request #33 from primevprotocol/revert-modify-chain-to-ms-timestamps
revert: Updates timestamps to Millisecond Precision - Pre-Confirmations Decay
2 parents 8b89ba7 + 7b28ce8 commit 0172aa6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

consensus/clique/clique.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

geth-poa/genesis.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
},
2222
"nonce": "0x0",
23-
"timestamp": "0x18E0A4E0D22",
23+
"timestamp": "0x6546df6d",
2424
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000d9cd8E5DE6d55f796D980B818D350C0746C25b97788EBABe5c3dD422Ef92Ca6714A69e2eabcE1Ee4f6ba5bca9b489de3a4ac3a57823d5d97d608feb90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
2525
"gasLimit": "0x1c9c380",
2626
"difficulty": "0x1",

0 commit comments

Comments
 (0)