From efbfd60222dce7f36e3842a4cc9bcb84d07648e1 Mon Sep 17 00:00:00 2001 From: lightclient Date: Sat, 8 Mar 2025 22:16:53 +0100 Subject: [PATCH] core: return early if scheduled fork's timestamp can't be retrieved --- core/blockchain.go | 7 ++++--- params/config.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 7ae7510fc1..40c750b8b3 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2471,10 +2471,11 @@ func (bc *BlockChain) reportBlock(block *types.Block, res *ProcessResult, err er func (bc *BlockChain) logForkReadiness(block *types.Block) { c := bc.Config() current, last := c.LatestFork(block.Time()), c.LatestFork(math.MaxUint64) - var at time.Time - if t := c.Timestamp(last); t != nil { - at = time.Unix(int64(*t), 0) + t := c.Timestamp(last) + if t == nil { + return } + at := time.Unix(int64(*t), 0) if current < last && time.Now().After(bc.lastForkReadyAlert.Add(forkReadyInterval)) { log.Info("Ready for fork activation", "fork", last, "date", at.Format(time.RFC822), "remaining", time.Until(at).Round(time.Second), "timestamp", at.Unix()) diff --git a/params/config.go b/params/config.go index 1fbebd42e4..8ba247c447 100644 --- a/params/config.go +++ b/params/config.go @@ -888,7 +888,7 @@ func (c *ChainConfig) Timestamp(fork forks.Fork) *uint64 { case fork == forks.Shanghai: return c.ShanghaiTime default: - panic("unknown timestamp fork requested") + return nil } }