From 0531964d05a09a324b7620e64672c096af49c9e7 Mon Sep 17 00:00:00 2001 From: Andrew Ashikhmin <34320705+yperbasis@users.noreply.github.com> Date: Mon, 20 Mar 2023 16:44:22 +0100 Subject: [PATCH] Drop Default from GenesisBlock* functions (#7147) Small cosmetic changes and clean-ups --- cmd/hack/hack.go | 38 ++-------- cmd/integration/commands/stages.go | 10 +-- cmd/integration/commands/state_domains.go | 6 +- cmd/integration/commands/state_stages.go | 6 +- .../commands/get_chain_config_test.go | 2 +- cmd/state/commands/root.go | 4 +- cmd/utils/flags.go | 2 +- consensus/aura/aura_test.go | 4 +- core/genesis.go | 70 +++++++++---------- core/genesis_test.go | 18 ++--- core/rawdb/rawdbreset/reset_stages.go | 2 +- core/system_contract_lookup.go | 2 +- turbo/stages/genesis_test.go | 2 +- 13 files changed, 69 insertions(+), 97 deletions(-) diff --git a/cmd/hack/hack.go b/cmd/hack/hack.go index b91a6f0faa1..4ff7be58cf8 100644 --- a/cmd/hack/hack.go +++ b/cmd/hack/hack.go @@ -20,7 +20,6 @@ import ( "github.com/RoaringBitmap/roaring/roaring64" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/common/length" @@ -31,12 +30,8 @@ import ( "github.com/ledgerwatch/erigon-lib/recsplit" "github.com/ledgerwatch/erigon-lib/recsplit/eliasfano32" librlp "github.com/ledgerwatch/erigon-lib/rlp" - "golang.org/x/exp/slices" - - "github.com/ledgerwatch/erigon/turbo/debug" - "github.com/ledgerwatch/erigon/turbo/logging" - "github.com/ledgerwatch/log/v3" + "golang.org/x/exp/slices" hackdb "github.com/ledgerwatch/erigon/cmd/hack/db" "github.com/ledgerwatch/erigon/cmd/hack/flow" @@ -55,6 +50,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb/cbor" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/erigon/turbo/debug" + "github.com/ledgerwatch/erigon/turbo/logging" "github.com/ledgerwatch/erigon/turbo/snapshotsync" ) @@ -1103,33 +1100,8 @@ func devTx(chaindata string) error { } func chainConfig(name string) error { - var chainConfig *chain.Config - switch name { - case "mainnet": - chainConfig = params.MainnetChainConfig - case "sepolia": - chainConfig = params.SepoliaChainConfig - case "rinkeby": - chainConfig = params.RinkebyChainConfig - case "goerli": - chainConfig = params.GoerliChainConfig - case "bsc": - chainConfig = params.BSCChainConfig - case "sokol": - chainConfig = params.SokolChainConfig - case "chapel": - chainConfig = params.ChapelChainConfig - case "rialto": - chainConfig = params.RialtoChainConfig - case "mumbai": - chainConfig = params.MumbaiChainConfig - case "bor-mainnet": - chainConfig = params.BorMainnetChainConfig - case "gnosis": - chainConfig = params.GnosisChainConfig - case "chiado": - chainConfig = params.ChiadoChainConfig - default: + chainConfig := params.ChainConfigByChainName(name) + if chainConfig == nil { return fmt.Errorf("unknown name: %s", name) } f, err := os.Create(filepath.Join("params", "chainspecs", fmt.Sprintf("%s.json", name))) diff --git a/cmd/integration/commands/stages.go b/cmd/integration/commands/stages.go index 466b8323ef7..9623b209a14 100644 --- a/cmd/integration/commands/stages.go +++ b/cmd/integration/commands/stages.go @@ -761,7 +761,7 @@ func stageExec(db kv.RwDB, ctx context.Context) error { syncCfg.ExecWorkerCount = int(workers) syncCfg.ReconWorkerCount = int(reconWorkers) - genesis := core.DefaultGenesisBlockByChainName(chain) + genesis := core.GenesisBlockByChainName(chain) cfg := stagedsync.StageExecuteBlocksCfg(db, pm, batchSize, nil, chainConfig, engine, vmConfig, nil, /*stateStream=*/ false, /*badBlockHalt=*/ false, historyV3, dirs, getBlockReader(db), nil, genesis, syncCfg, agg) @@ -1282,7 +1282,7 @@ func allDomains(ctx context.Context, db kv.RoDB, stepSize uint64, mode libstate. func newDomains(ctx context.Context, db kv.RwDB, stepSize uint64, mode libstate.CommitmentMode, trie commitment.TrieVariant) (consensus.Engine, ethconfig.Config, *snapshotsync.RoSnapshots, *libstate.Aggregator) { historyV3, pm := kvcfg.HistoryV3.FromDB(db), fromdb.PruneMode(db) //events := shards.NewEvents() - genesis := core.DefaultGenesisBlockByChainName(chain) + genesis := core.GenesisBlockByChainName(chain) chainConfig, genesisBlock, genesisErr := core.CommitGenesisBlock(db, genesis, "") _ = genesisBlock // TODO apply if needed here @@ -1305,7 +1305,7 @@ func newDomains(ctx context.Context, db kv.RwDB, stepSize uint64, mode libstate. cfg.Prune = pm cfg.BatchSize = batchSize cfg.DeprecatedTxPool.Disable = true - cfg.Genesis = core.DefaultGenesisBlockByChainName(chain) + cfg.Genesis = core.GenesisBlockByChainName(chain) //if miningConfig != nil { // cfg.Miner = *miningConfig //} @@ -1325,7 +1325,7 @@ func newSync(ctx context.Context, db kv.RwDB, miningConfig *params.MiningConfig) events := shards.NewEvents() - genesis := core.DefaultGenesisBlockByChainName(chain) + genesis := core.GenesisBlockByChainName(chain) chainConfig, genesisBlock, genesisErr := core.CommitGenesisBlock(db, genesis, "") if _, ok := genesisErr.(*chain2.ConfigCompatError); genesisErr != nil && !ok { panic(genesisErr) @@ -1345,7 +1345,7 @@ func newSync(ctx context.Context, db kv.RwDB, miningConfig *params.MiningConfig) cfg.Prune = pm cfg.BatchSize = batchSize cfg.DeprecatedTxPool.Disable = true - cfg.Genesis = core.DefaultGenesisBlockByChainName(chain) + cfg.Genesis = core.GenesisBlockByChainName(chain) if miningConfig != nil { cfg.Miner = *miningConfig } diff --git a/cmd/integration/commands/state_domains.go b/cmd/integration/commands/state_domains.go index b6329b2ce1f..4849473f0bc 100644 --- a/cmd/integration/commands/state_domains.go +++ b/cmd/integration/commands/state_domains.go @@ -95,7 +95,7 @@ var readDomains = &cobra.Command{ cfg := &nodecfg.DefaultConfig utils.SetNodeConfigCobra(cmd, cfg) ethConfig := ðconfig.Defaults - ethConfig.Genesis = core.DefaultGenesisBlockByChainName(chain) + ethConfig.Genesis = core.GenesisBlockByChainName(chain) erigoncli.ApplyFlagsForEthConfigCobra(cmd.Flags(), ethConfig) var readFromDomain string @@ -220,7 +220,7 @@ var stateDomains = &cobra.Command{ cfg := &nodecfg.DefaultConfig utils.SetNodeConfigCobra(cmd, cfg) ethConfig := ðconfig.Defaults - ethConfig.Genesis = core.DefaultGenesisBlockByChainName(chain) + ethConfig.Genesis = core.GenesisBlockByChainName(chain) erigoncli.ApplyFlagsForEthConfigCobra(cmd.Flags(), ethConfig) dirs := datadir.New(datadirCli) @@ -309,7 +309,7 @@ func loopProcessDomains(chainDb, stateDb kv.RwDB, ctx context.Context) error { go proc.PrintStatsLoop(ctx, 30*time.Second) if proc.startTxNum == 0 { - genesis := core.DefaultGenesisBlockByChainName(chain) + genesis := core.GenesisBlockByChainName(chain) if err := proc.ApplyGenesis(genesis); err != nil { return err } diff --git a/cmd/integration/commands/state_stages.go b/cmd/integration/commands/state_stages.go index 12da63e690c..dd2c0eefec5 100644 --- a/cmd/integration/commands/state_stages.go +++ b/cmd/integration/commands/state_stages.go @@ -58,7 +58,7 @@ Examples: cfg := &nodecfg.DefaultConfig utils.SetNodeConfigCobra(cmd, cfg) ethConfig := ðconfig.Defaults - ethConfig.Genesis = core.DefaultGenesisBlockByChainName(chain) + ethConfig.Genesis = core.GenesisBlockByChainName(chain) erigoncli.ApplyFlagsForEthConfigCobra(cmd.Flags(), ethConfig) miningConfig := params.MiningConfig{} utils.SetupMinerCobra(cmd, &miningConfig) @@ -195,7 +195,7 @@ func syncBySmallSteps(db kv.RwDB, miningConfig params.MiningConfig, ctx context. stateStages.DisableStages(stages.Snapshots, stages.Headers, stages.BlockHashes, stages.Bodies, stages.Senders) changesAcc := shards.NewAccumulator() - genesis := core.DefaultGenesisBlockByChainName(chain) + genesis := core.GenesisBlockByChainName(chain) syncCfg := ethconfig.Defaults.Sync syncCfg.ExecWorkerCount = int(workers) syncCfg.ReconWorkerCount = int(reconWorkers) @@ -525,7 +525,7 @@ func loopExec(db kv.RwDB, ctx context.Context, unwind uint64) error { from := progress(tx, stages.Execution) to := from + unwind - genesis := core.DefaultGenesisBlockByChainName(chain) + genesis := core.GenesisBlockByChainName(chain) syncCfg := ethconfig.Defaults.Sync syncCfg.ExecWorkerCount = int(workers) syncCfg.ReconWorkerCount = int(reconWorkers) diff --git a/cmd/rpcdaemon/commands/get_chain_config_test.go b/cmd/rpcdaemon/commands/get_chain_config_test.go index efb9f59d082..9e1c9e79ee7 100644 --- a/cmd/rpcdaemon/commands/get_chain_config_test.go +++ b/cmd/rpcdaemon/commands/get_chain_config_test.go @@ -10,7 +10,7 @@ import ( func TestGetChainConfig(t *testing.T) { db := memdb.NewTestDB(t) - config, _, err := core.CommitGenesisBlock(db, core.DefaultGenesisBlock(), "") + config, _, err := core.CommitGenesisBlock(db, core.MainnetGenesisBlock(), "") if err != nil { t.Fatalf("setting up genensis block: %v", err) } diff --git a/cmd/state/commands/root.go b/cmd/state/commands/root.go index 4bd771e4b7a..d54dfea58b6 100644 --- a/cmd/state/commands/root.go +++ b/cmd/state/commands/root.go @@ -75,9 +75,9 @@ func genesisFromFile(genesisPath string) *core.Genesis { func getChainGenesisAndConfig() (genesis *core.Genesis, chainConfig *chain2.Config) { if chain == "" { - genesis, chainConfig = core.DefaultGenesisBlock(), params.MainnetChainConfig + genesis, chainConfig = core.MainnetGenesisBlock(), params.MainnetChainConfig } else { - genesis, chainConfig = core.DefaultGenesisBlockByChainName(chain), params.ChainConfigByChainName(chain) + genesis, chainConfig = core.GenesisBlockByChainName(chain), params.ChainConfigByChainName(chain) } return genesis, chainConfig } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 0355ff9b39c..0c43334e5a5 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1548,7 +1548,7 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C switch chain { default: - genesis := core.DefaultGenesisBlockByChainName(chain) + genesis := core.GenesisBlockByChainName(chain) genesisHash := params.GenesisHashByChainName(chain) if (genesis == nil) || (genesisHash == nil) { Fatalf("ChainDB name is not recognized: %s", chain) diff --git a/consensus/aura/aura_test.go b/consensus/aura/aura_test.go index 6cf88e6b5eb..314d5e49ee2 100644 --- a/consensus/aura/aura_test.go +++ b/consensus/aura/aura_test.go @@ -101,7 +101,7 @@ func TestRewardContract(t *testing.T) { auraDB, require := memdb.NewTestDB(t), require.New(t) engine, err := aura.NewAuRa(nil, auraDB, libcommon.Address{}, test.AuthorityRoundBlockRewardContract) require.NoError(err) - m := stages.MockWithGenesisEngine(t, core.DefaultSokolGenesisBlock(), engine, false) + m := stages.MockWithGenesisEngine(t, core.SokolGenesisBlock(), engine, false) m.EnableLogs() var accBefore *accounts.Account @@ -202,7 +202,7 @@ func TestEmptyBlock(t *testing.T) { } require := require.New(t) - genesis := core.DefaultGnosisGenesisBlock() + genesis := core.GnosisGenesisBlock() genesisBlock, _, err := genesis.ToBlock("") require.NoError(err) diff --git a/core/genesis.go b/core/genesis.go index 3aa8bb9628c..5a8668c14a7 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -179,7 +179,7 @@ func (e *GenesisMismatchError) Error() string { // // genesis == nil genesis != nil // +------------------------------------------ -// db has no genesis | main-net default | genesis +// db has no genesis | main-net | genesis // db has genesis | from DB | genesis (if compatible) // // The stored chain configuration will be updated if it is compatible (i.e. does not @@ -235,8 +235,8 @@ func WriteGenesisBlock(db kv.RwTx, genesis *Genesis, overrideShanghaiTime *big.I if (storedHash == libcommon.Hash{}) { custom := true if genesis == nil { - log.Info("Writing default main-net genesis block") - genesis = DefaultGenesisBlock() + log.Info("Writing main-net genesis block") + genesis = MainnetGenesisBlock() custom = false } applyOverrides(genesis.Config) @@ -590,8 +590,8 @@ func GenesisWithAccounts(db kv.RwDB, accs []GenAccount, tmpDir string) *types.Bl return block } -// DefaultGenesisBlock returns the Ethereum main net genesis block. -func DefaultGenesisBlock() *Genesis { +// MainnetGenesisBlock returns the Ethereum main net genesis block. +func MainnetGenesisBlock() *Genesis { return &Genesis{ Config: params.MainnetChainConfig, Nonce: 66, @@ -602,8 +602,8 @@ func DefaultGenesisBlock() *Genesis { } } -// DefaultSepoliaGenesisBlock returns the Sepolia network genesis block. -func DefaultSepoliaGenesisBlock() *Genesis { +// SepoliaGenesisBlock returns the Sepolia network genesis block. +func SepoliaGenesisBlock() *Genesis { return &Genesis{ Config: params.SepoliaChainConfig, Nonce: 0, @@ -615,8 +615,8 @@ func DefaultSepoliaGenesisBlock() *Genesis { } } -// DefaultRinkebyGenesisBlock returns the Rinkeby network genesis block. -func DefaultRinkebyGenesisBlock() *Genesis { +// RinkebyGenesisBlock returns the Rinkeby network genesis block. +func RinkebyGenesisBlock() *Genesis { return &Genesis{ Config: params.RinkebyChainConfig, Timestamp: 1492009146, @@ -627,8 +627,8 @@ func DefaultRinkebyGenesisBlock() *Genesis { } } -// DefaultGoerliGenesisBlock returns the Görli network genesis block. -func DefaultGoerliGenesisBlock() *Genesis { +// GoerliGenesisBlock returns the Görli network genesis block. +func GoerliGenesisBlock() *Genesis { return &Genesis{ Config: params.GoerliChainConfig, Timestamp: 1548854791, @@ -639,7 +639,7 @@ func DefaultGoerliGenesisBlock() *Genesis { } } -func DefaultSokolGenesisBlock() *Genesis { +func SokolGenesisBlock() *Genesis { /* header rlp: f9020da00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0fad4af258fd11939fae0c6c6eec9d340b1caac0b0196fd9a1bc3f489c5bf00b3a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008083663be080808080b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 */ @@ -653,7 +653,7 @@ func DefaultSokolGenesisBlock() *Genesis { } } -func DefaultBSCGenesisBlock() *Genesis { +func BSCGenesisBlock() *Genesis { return &Genesis{ Config: params.BSCChainConfig, Nonce: 0x00, @@ -669,7 +669,7 @@ func DefaultBSCGenesisBlock() *Genesis { } } -func DefaultChapelGenesisBlock() *Genesis { +func ChapelGenesisBlock() *Genesis { return &Genesis{ Config: params.ChapelChainConfig, Nonce: 0x00, @@ -685,7 +685,7 @@ func DefaultChapelGenesisBlock() *Genesis { } } -func DefaultRialtoGenesisBlock() *Genesis { +func RialtoGenesisBlock() *Genesis { return &Genesis{ Config: params.RialtoChainConfig, Nonce: 0x00, @@ -701,7 +701,7 @@ func DefaultRialtoGenesisBlock() *Genesis { } } -func DefaultMumbaiGenesisBlock() *Genesis { +func MumbaiGenesisBlock() *Genesis { return &Genesis{ Config: params.MumbaiChainConfig, Nonce: 0, @@ -714,8 +714,8 @@ func DefaultMumbaiGenesisBlock() *Genesis { } } -// DefaultBorMainnet returns the Bor Mainnet network gensis block. -func DefaultBorMainnetGenesisBlock() *Genesis { +// BorMainnetGenesisBlock returns the Bor Mainnet network genesis block. +func BorMainnetGenesisBlock() *Genesis { return &Genesis{ Config: params.BorMainnetChainConfig, Nonce: 0, @@ -728,7 +728,7 @@ func DefaultBorMainnetGenesisBlock() *Genesis { } } -func DefaultBorDevnetGenesisBlock() *Genesis { +func BorDevnetGenesisBlock() *Genesis { return &Genesis{ Config: params.BorDevnetChainConfig, Nonce: 0, @@ -741,7 +741,7 @@ func DefaultBorDevnetGenesisBlock() *Genesis { } } -func DefaultGnosisGenesisBlock() *Genesis { +func GnosisGenesisBlock() *Genesis { return &Genesis{ Config: params.GnosisChainConfig, Timestamp: 0, @@ -752,7 +752,7 @@ func DefaultGnosisGenesisBlock() *Genesis { } } -func DefaultChiadoGenesisBlock() *Genesis { +func ChiadoGenesisBlock() *Genesis { return &Genesis{ Config: params.ChiadoChainConfig, Timestamp: 0, @@ -801,34 +801,34 @@ func readPrealloc(filename string) GenesisAlloc { return ga } -func DefaultGenesisBlockByChainName(chain string) *Genesis { +func GenesisBlockByChainName(chain string) *Genesis { switch chain { case networkname.MainnetChainName: - return DefaultGenesisBlock() + return MainnetGenesisBlock() case networkname.SepoliaChainName: - return DefaultSepoliaGenesisBlock() + return SepoliaGenesisBlock() case networkname.RinkebyChainName: - return DefaultRinkebyGenesisBlock() + return RinkebyGenesisBlock() case networkname.GoerliChainName: - return DefaultGoerliGenesisBlock() + return GoerliGenesisBlock() case networkname.SokolChainName: - return DefaultSokolGenesisBlock() + return SokolGenesisBlock() case networkname.BSCChainName: - return DefaultBSCGenesisBlock() + return BSCGenesisBlock() case networkname.ChapelChainName: - return DefaultChapelGenesisBlock() + return ChapelGenesisBlock() case networkname.RialtoChainName: - return DefaultRialtoGenesisBlock() + return RialtoGenesisBlock() case networkname.MumbaiChainName: - return DefaultMumbaiGenesisBlock() + return MumbaiGenesisBlock() case networkname.BorMainnetChainName: - return DefaultBorMainnetGenesisBlock() + return BorMainnetGenesisBlock() case networkname.BorDevnetChainName: - return DefaultBorDevnetGenesisBlock() + return BorDevnetGenesisBlock() case networkname.GnosisChainName: - return DefaultGnosisGenesisBlock() + return GnosisGenesisBlock() case networkname.ChiadoChainName: - return DefaultChiadoGenesisBlock() + return ChiadoGenesisBlock() default: return nil } diff --git a/core/genesis_test.go b/core/genesis_test.go index 2bfb531674c..1c176e3f04f 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -22,10 +22,10 @@ import ( "github.com/ledgerwatch/erigon/rlp" ) -func TestDefaultGenesisBlockHashes(t *testing.T) { +func TestGenesisBlockHashes(t *testing.T) { db := memdb.NewTestDB(t) check := func(network string) { - genesis := core.DefaultGenesisBlockByChainName(network) + genesis := core.GenesisBlockByChainName(network) tx, err := db.BeginRw(context.Background()) if err != nil { t.Fatal(err) @@ -42,16 +42,16 @@ func TestDefaultGenesisBlockHashes(t *testing.T) { } } -func TestDefaultGenesisBlockRoots(t *testing.T) { +func TestGenesisBlockRoots(t *testing.T) { require := require.New(t) var err error - block, _, _ := core.DefaultGenesisBlock().ToBlock("") + block, _, _ := core.MainnetGenesisBlock().ToBlock("") if block.Hash() != params.MainnetGenesisHash { t.Errorf("wrong mainnet genesis hash, got %v, want %v", block.Hash(), params.MainnetGenesisHash) } - block, _, err = core.DefaultSokolGenesisBlock().ToBlock("") + block, _, err = core.SokolGenesisBlock().ToBlock("") require.NoError(err) if block.Root() != params.SokolGenesisStateRoot { t.Errorf("wrong Sokol genesis state root, got %v, want %v", block.Root(), params.SokolGenesisStateRoot) @@ -60,7 +60,7 @@ func TestDefaultGenesisBlockRoots(t *testing.T) { t.Errorf("wrong Sokol genesis hash, got %v, want %v", block.Hash(), params.SokolGenesisHash) } - block, _, err = core.DefaultGnosisGenesisBlock().ToBlock("") + block, _, err = core.GnosisGenesisBlock().ToBlock("") require.NoError(err) if block.Root() != params.GnosisGenesisStateRoot { t.Errorf("wrong Gnosis Chain genesis state root, got %v, want %v", block.Root(), params.GnosisGenesisStateRoot) @@ -69,7 +69,7 @@ func TestDefaultGenesisBlockRoots(t *testing.T) { t.Errorf("wrong Gnosis Chain genesis hash, got %v, want %v", block.Hash(), params.GnosisGenesisHash) } - block, _, err = core.DefaultChiadoGenesisBlock().ToBlock("") + block, _, err = core.ChiadoGenesisBlock().ToBlock("") require.NoError(err) if block.Root() != params.ChiadoGenesisStateRoot { t.Errorf("wrong Chiado genesis state root, got %v, want %v", block.Root(), params.ChiadoGenesisStateRoot) @@ -81,7 +81,7 @@ func TestDefaultGenesisBlockRoots(t *testing.T) { func TestCommitGenesisIdempotency(t *testing.T) { _, tx := memdb.NewTestTx(t) - genesis := core.DefaultGenesisBlockByChainName(networkname.MainnetChainName) + genesis := core.GenesisBlockByChainName(networkname.MainnetChainName) _, _, err := core.WriteGenesisBlock(tx, genesis, nil, "") require.NoError(t, err) seq, err := tx.ReadSequence(kv.EthTx) @@ -99,7 +99,7 @@ func TestSokolHeaderRLP(t *testing.T) { require := require.New(t) { //sokol expect := common.FromHex("f9020da00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0fad4af258fd11939fae0c6c6eec9d340b1caac0b0196fd9a1bc3f489c5bf00b3a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008083663be080808080b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") - block, _, err := core.DefaultSokolGenesisBlock().ToBlock("") + block, _, err := core.SokolGenesisBlock().ToBlock("") require.NoError(err) b, err := rlp.EncodeToBytes(block.Header()) require.NoError(err) diff --git a/core/rawdb/rawdbreset/reset_stages.go b/core/rawdb/rawdbreset/reset_stages.go index 67b84322a16..489945e6817 100644 --- a/core/rawdb/rawdbreset/reset_stages.go +++ b/core/rawdb/rawdbreset/reset_stages.go @@ -169,7 +169,7 @@ func ResetExec(ctx context.Context, db kv.RwDB, chain string, tmpDir string) (er return nil } if !historyV3 { - genesis := core.DefaultGenesisBlockByChainName(chain) + genesis := core.GenesisBlockByChainName(chain) if _, _, err := genesis.WriteGenesisState(tx, tmpDir); err != nil { return err } diff --git a/core/system_contract_lookup.go b/core/system_contract_lookup.go index 186e0f36e94..5a5198cf44b 100644 --- a/core/system_contract_lookup.go +++ b/core/system_contract_lookup.go @@ -19,7 +19,7 @@ func init() { byChain := map[libcommon.Address][]libcommon.CodeRecord{} systemcontracts.SystemContractCodeLookup[chainName] = byChain // Apply genesis with the block number 0 - genesisBlock := DefaultGenesisBlockByChainName(chainName) + genesisBlock := GenesisBlockByChainName(chainName) for addr, alloc := range genesisBlock.Alloc { if len(alloc.Code) > 0 { list := byChain[addr] diff --git a/turbo/stages/genesis_test.go b/turbo/stages/genesis_test.go index 94b680b6c9a..3519c132fbf 100644 --- a/turbo/stages/genesis_test.go +++ b/turbo/stages/genesis_test.go @@ -93,7 +93,7 @@ func TestSetupGenesis(t *testing.T) { name: "custom block in DB, genesis == sepolia", fn: func(db kv.RwDB) (*chain.Config, *types.Block, error) { customg.MustCommit(db, tmpdir) - return core.CommitGenesisBlock(db, core.DefaultSepoliaGenesisBlock(), tmpdir) + return core.CommitGenesisBlock(db, core.SepoliaGenesisBlock(), tmpdir) }, wantErr: &core.GenesisMismatchError{Stored: customghash, New: params.SepoliaGenesisHash}, wantHash: params.SepoliaGenesisHash,