Skip to content

Commit 339cae8

Browse files
authored
core: fix fork readiness log (#32623)
When I implemented in #31340 I didn't expect multiple forks to be configured at once, but this is exactly how BPOs are defined. This updates the method to determine the next scheduled fork rather than the last fork.
1 parent 6492751 commit 339cae8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

core/blockchain.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"errors"
2222
"fmt"
2323
"io"
24-
"math"
2524
"math/big"
2625
"runtime"
2726
"slices"
@@ -2663,13 +2662,11 @@ func (bc *BlockChain) reportBlock(block *types.Block, res *ProcessResult, err er
26632662
// logForkReadiness will write a log when a future fork is scheduled, but not
26642663
// active. This is useful so operators know their client is ready for the fork.
26652664
func (bc *BlockChain) logForkReadiness(block *types.Block) {
2666-
config := bc.Config()
2667-
current, last := config.LatestFork(block.Time()), config.LatestFork(math.MaxUint64)
2665+
current := bc.Config().LatestFork(block.Time())
26682666

2669-
// Short circuit if the timestamp of the last fork is undefined,
2670-
// or if the network has already passed the last configured fork.
2671-
t := config.Timestamp(last)
2672-
if t == nil || current >= last {
2667+
// Short circuit if the timestamp of the last fork is undefined.
2668+
t := bc.Config().Timestamp(current + 1)
2669+
if t == nil {
26732670
return
26742671
}
26752672
at := time.Unix(int64(*t), 0)
@@ -2679,7 +2676,7 @@ func (bc *BlockChain) logForkReadiness(block *types.Block) {
26792676
// - Enough time has passed since last alert
26802677
now := time.Now()
26812678
if now.Before(at) && now.After(bc.lastForkReadyAlert.Add(forkReadyInterval)) {
2682-
log.Info("Ready for fork activation", "fork", last, "date", at.Format(time.RFC822),
2679+
log.Info("Ready for fork activation", "fork", current+1, "date", at.Format(time.RFC822),
26832680
"remaining", time.Until(at).Round(time.Second), "timestamp", at.Unix())
26842681
bc.lastForkReadyAlert = time.Now()
26852682
}

params/forks/forks.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,9 @@ var forkToString = map[Fork]string{
7777
Cancun: "Cancun",
7878
Prague: "Prague",
7979
Osaka: "Osaka",
80+
BPO1: "BPO1",
81+
BPO2: "BPO2",
82+
BPO3: "BPO3",
83+
BPO4: "BPO4",
84+
BPO5: "BPO5",
8085
}

0 commit comments

Comments
 (0)