From 339cae81d8992dfc6cf15c856b565f562fb46af4 Mon Sep 17 00:00:00 2001 From: lightclient <14004106+lightclient@users.noreply.github.com> Date: Thu, 18 Sep 2025 06:28:03 +0200 Subject: [PATCH] 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. --- core/blockchain.go | 13 +++++-------- params/forks/forks.go | 5 +++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 3466923648..30f3da3004 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "io" - "math" "math/big" "runtime" "slices" @@ -2663,13 +2662,11 @@ func (bc *BlockChain) reportBlock(block *types.Block, res *ProcessResult, err er // logForkReadiness will write a log when a future fork is scheduled, but not // active. This is useful so operators know their client is ready for the fork. func (bc *BlockChain) logForkReadiness(block *types.Block) { - config := bc.Config() - current, last := config.LatestFork(block.Time()), config.LatestFork(math.MaxUint64) + current := bc.Config().LatestFork(block.Time()) - // Short circuit if the timestamp of the last fork is undefined, - // or if the network has already passed the last configured fork. - t := config.Timestamp(last) - if t == nil || current >= last { + // Short circuit if the timestamp of the last fork is undefined. + t := bc.Config().Timestamp(current + 1) + if t == nil { return } at := time.Unix(int64(*t), 0) @@ -2679,7 +2676,7 @@ func (bc *BlockChain) logForkReadiness(block *types.Block) { // - Enough time has passed since last alert now := time.Now() if now.Before(at) && now.After(bc.lastForkReadyAlert.Add(forkReadyInterval)) { - log.Info("Ready for fork activation", "fork", last, "date", at.Format(time.RFC822), + log.Info("Ready for fork activation", "fork", current+1, "date", at.Format(time.RFC822), "remaining", time.Until(at).Round(time.Second), "timestamp", at.Unix()) bc.lastForkReadyAlert = time.Now() } diff --git a/params/forks/forks.go b/params/forks/forks.go index aab0a54ab7..adb65c8624 100644 --- a/params/forks/forks.go +++ b/params/forks/forks.go @@ -77,4 +77,9 @@ var forkToString = map[Fork]string{ Cancun: "Cancun", Prague: "Prague", Osaka: "Osaka", + BPO1: "BPO1", + BPO2: "BPO2", + BPO3: "BPO3", + BPO4: "BPO4", + BPO5: "BPO5", }