core: base readiness on next configured fork

This commit is contained in:
lightclient 2025-09-16 09:40:44 +02:00
parent b05fe4aa64
commit 39fe73f760
No known key found for this signature in database
GPG key ID: 657913021EF45A6A

View file

@ -21,7 +21,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"math"
"math/big" "math/big"
"runtime" "runtime"
"slices" "slices"
@ -2659,13 +2658,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 // 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. // active. This is useful so operators know their client is ready for the fork.
func (bc *BlockChain) logForkReadiness(block *types.Block) { func (bc *BlockChain) logForkReadiness(block *types.Block) {
config := bc.Config() current := bc.Config().LatestFork(block.Time())
current, last := config.LatestFork(block.Time()), config.LatestFork(math.MaxUint64)
// Short circuit if the timestamp of the last fork is undefined, // Short circuit if the timestamp of the last fork is undefined.
// or if the network has already passed the last configured fork. t := bc.Config().Timestamp(current + 1)
t := config.Timestamp(last) if t == nil {
if t == nil || current >= last {
return return
} }
at := time.Unix(int64(*t), 0) at := time.Unix(int64(*t), 0)
@ -2675,7 +2672,7 @@ func (bc *BlockChain) logForkReadiness(block *types.Block) {
// - Enough time has passed since last alert // - Enough time has passed since last alert
now := time.Now() now := time.Now()
if now.Before(at) && now.After(bc.lastForkReadyAlert.Add(forkReadyInterval)) { 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()) "remaining", time.Until(at).Round(time.Second), "timestamp", at.Unix())
bc.lastForkReadyAlert = time.Now() bc.lastForkReadyAlert = time.Now()
} }