make developer genesis block difficulty 1. add additional checks for startup in dev mode: ttd present in genesis. difficulty > ttd in genesis

This commit is contained in:
Jared Wasinger 2023-11-13 18:11:05 +08:00
parent e057dddd40
commit 59bdc00f0a
2 changed files with 8 additions and 2 deletions

View file

@ -1877,7 +1877,13 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
Fatalf("Could not read genesis from database: %v", err) Fatalf("Could not read genesis from database: %v", err)
} }
if !genesis.Config.TerminalTotalDifficultyPassed { if !genesis.Config.TerminalTotalDifficultyPassed {
Fatalf("Bad genesis configuration: ttd must be passed in block 0 in developer mode") Fatalf("Bad developer-mode genesis configuration: terminal total difficulty must be passed in block 0 in developer mode")
}
if genesis.Config.TerminalTotalDifficulty == nil {
Fatalf("Bad developer-mode genesis configuration: terminal total difficulty must be specified.")
}
if genesis.Difficulty.Cmp(genesis.Config.TerminalTotalDifficulty) != 1 {
Fatalf("Bad developer-mode genesis configuration: genesis block difficulty must be greater than ttd")
} }
} }
chaindb.Close() chaindb.Close()

View file

@ -572,7 +572,7 @@ func DeveloperGenesisBlock(gasLimit uint64, faucet common.Address) *Genesis {
Config: &config, Config: &config,
GasLimit: gasLimit, GasLimit: gasLimit,
BaseFee: big.NewInt(params.InitialBaseFee), BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: big.NewInt(0), Difficulty: big.NewInt(1),
Alloc: map[common.Address]GenesisAccount{ Alloc: map[common.Address]GenesisAccount{
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256 common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256