From 2f16843c5ac8114d682a2a43491d31e8c6c29b14 Mon Sep 17 00:00:00 2001 From: lightclient Date: Mon, 3 Feb 2025 16:10:34 -0700 Subject: [PATCH] core: default genesis difficulty to zero for merged chains --- core/genesis.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/genesis.go b/core/genesis.go index b579e33c77..fca3b36f97 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -35,6 +35,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/params/forks" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/triedb" @@ -460,7 +461,13 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block { head.GasLimit = params.GenesisGasLimit } if g.Difficulty == nil && g.Mixhash == (common.Hash{}) { - head.Difficulty = params.GenesisDifficulty + if g.Config.LatestFork(g.Timestamp) >= forks.Shanghai { + // If chain is merged at genesis, set difficulty to zero. + head.Difficulty = big.NewInt(0) + } else { + // In case chain is not merged at genesis, set default genesis difficulty. + head.Difficulty = params.GenesisDifficulty + } } if g.Config != nil && g.Config.IsLondon(common.Big0) { if g.BaseFee != nil {