Skip to content

Commit

Permalink
Remove the use of initingGenesis flag
Browse files Browse the repository at this point in the history
This flag was being used to indicate the context that we were executing
in, in this case a  non test production context. Instead we can use
testing.Testing() that tells us whether we are operating in a test
context.
  • Loading branch information
piersy committed Feb 11, 2025
1 parent 1426122 commit df753d9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
2 changes: 0 additions & 2 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ func initGenesis(ctx *cli.Context) error {
triedb := utils.MakeTrieDatabase(ctx, chaindb, ctx.Bool(utils.CachePreimagesFlag.Name), false, genesis.IsVerkle())
defer triedb.Close()

// Set initing genesis here, to signal that we are in an initGenesis flow.
genesis.SetInitingGenesis()
_, hash, _, err := core.SetupGenesisBlockWithOverride(chaindb, triedb, genesis, &overrides)
if err != nil {
utils.Fatalf("Failed to write genesis block: %v", err)
Expand Down
10 changes: 0 additions & 10 deletions core/celo_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,3 @@ func addFeeCurrencyToStorage(feeCurrencyAddr common.Address, oracleAddr common.A
storage[structStart] = common.BytesToHash(oracleAddr.Bytes()) // oracle
storage[incHash(structStart, 1)] = common.BigToHash(big.NewInt(int64(FeeCurrencyIntrinsicGas))) // intrinsicGas
}

// SetInitingGenesis marks this genesis as one that is being used in the initGenesis operation.
func (g *Genesis) SetInitingGenesis() {
g.initingGenesis = true
}

// InitingGenesis returns true if this genesis is being used in the initGenesis operation.
func (g *Genesis) InitingGenesis() bool {
return g.initingGenesis
}
7 changes: 2 additions & 5 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"math/big"
"strings"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -79,10 +80,6 @@ type Genesis struct {
// Chains with history pruning, or extraordinarily large genesis allocation (e.g. after a regenesis event)
// may utilize this to get started, and then state-sync the latest state, while still verifying the header chain.
StateHash *common.Hash `json:"stateHash,omitempty"`

// initingGenesis is used to indicate whether this genesis config is being
// used in the initGenesis operation.
initingGenesis bool
}

func ReadGenesis(db ethdb.Database) (*Genesis, error) {
Expand Down Expand Up @@ -601,7 +598,7 @@ func (g *Genesis) toBlockWithRoot(stateRoot, storageRootMessagePasser common.Has
// condition, but TestFeeHistory, makes use of chains with pre-gingerbread
// genesis blocks without actually accounting for the different structure of
// the pre-gingerbread block.
if g.InitingGenesis() && g.Config.GingerbreadBlock != nil && !g.Config.IsGingerbread(number) {
if !testing.Testing() && g.Config.GingerbreadBlock != nil && !g.Config.IsGingerbread(number) {
head = types.NewPreGingerbreadHeader()
}

Expand Down

0 comments on commit df753d9

Please sign in to comment.