Skip to content

Commit 3411e9f

Browse files
committed
fix: address timing issue in system config worker
1 parent 40ebbd6 commit 3411e9f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

consensus/system_contract/consensus.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,12 @@ func (s *SystemContract) verifyHeader(chain consensus.ChainHeaderReader, header
116116
}
117117

118118
// Don't waste time checking blocks from the future
119-
if header.Time > uint64(time.Now().Unix()) {
120-
return consensus.ErrFutureBlock
119+
now := time.Now()
120+
if header.Time > uint64(now.Unix()) {
121+
// Add 100ms leeway since the scroll_worker internal timers might trigger early.
122+
if uint64(now.Unix())+1 != header.Time || now.Nanosecond() < 900000000 {
123+
return consensus.ErrFutureBlock
124+
}
121125
}
122126
// Ensure that the coinbase is zero
123127
if header.Coinbase != (common.Address{}) {

miner/scroll_worker.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ func (w *worker) collectPendingL1Messages(startIndex uint64) []types.L1MessageTx
464464
if len(l1MessagesV1) > 0 {
465465
// backdate the block to the parent block's timestamp -> not yet EuclidV2
466466
// TODO: might need to re-run Prepare here
467+
log.Warn("Back-labeling header timestamp to ensure it precedes the EuclidV2 transition", "blockNumber", w.current.header.Number, "oldTime", w.current.header.Time, "newTime", parent.Time)
467468
w.current.header.Time = parent.Time
468469
return l1MessagesV1
469470
}
@@ -541,6 +542,10 @@ func (w *worker) newWork(now time.Time, parentHash common.Hash, reorging bool, r
541542
// clique with relaxed period uses time.Now() as the header.Time, calculate the deadline
542543
deadline = time.Unix(int64(header.Time+w.chainConfig.Clique.Period), 0)
543544
}
545+
if w.chainConfig.SystemContract != nil && w.chainConfig.SystemContract.RelaxedPeriod {
546+
// system contract with relaxed period uses time.Now() as the header.Time, calculate the deadline
547+
deadline = time.Unix(int64(header.Time+w.chainConfig.SystemContract.Period), 0)
548+
}
544549

545550
w.current = &work{
546551
deadlineTimer: time.NewTimer(time.Until(deadline)),

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 18 // Patch version component of the current release
27+
VersionPatch = 19 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

0 commit comments

Comments
 (0)