Skip to content

Commit

Permalink
cmd/geth,console,params: fixup DeveloperGenesisBlock and her uses
Browse files Browse the repository at this point in the history
Date: 2024-02-23 07:12:33-07:00
Signed-off-by: meows <[email protected]>
  • Loading branch information
meowsbits committed Feb 23, 2024
1 parent 15c73ed commit 193e17f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func dumpGenesis(ctx *cli.Context) error {
if utils.IsNetworkPreset(ctx) {
genesis = utils.MakeGenesis(ctx)
} else if ctx.IsSet(utils.DeveloperFlag.Name) && !ctx.IsSet(utils.DataDirFlag.Name) {
genesis = params.DeveloperGenesisBlock(11_500_000, nil)
genesis = params.DeveloperGenesisBlock(11_500_000, nil, ctx.Bool(utils.DeveloperPoWFlag.Name))
}

if genesis != nil {
Expand Down
2 changes: 1 addition & 1 deletion console/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func newTester(t *testing.T, confOverride func(*ethconfig.Config)) *tester {
t.Fatalf("failed to create node: %v", err)
}
ethConf := &ethconfig.Config{
Genesis: params.DeveloperGenesisBlock(11_500_000, common.Address{}, true),
Genesis: params.DeveloperGenesisBlock(11_500_000, nil, true),
Miner: miner.Config{
Etherbase: common.HexToAddress(testAddress),
},
Expand Down
17 changes: 12 additions & 5 deletions params/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ func DefaultHoleskyGenesisBlock() *genesisT.Genesis {

// DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must
// be seeded with the
func DeveloperGenesisBlock(gasLimit uint64, faucet common.Address, useEthash bool) *genesisT.Genesis {
func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address, useEthash bool) *genesisT.Genesis {
if !useEthash {
// Make a copy to avoid unpredicted contamination.
config := &goethereum.ChainConfig{}
*config = *AllDevChainProtocolChanges

// Assemble and return the genesis with the precompiles and faucet pre-funded
return &genesisT.Genesis{
genesis := &genesisT.Genesis{
Config: config,
GasLimit: gasLimit,
BaseFee: big.NewInt(vars.InitialBaseFee),
Expand All @@ -102,9 +102,13 @@ func DeveloperGenesisBlock(gasLimit uint64, faucet common.Address, useEthash boo
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b
faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))},
*faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))},
},
}
if faucet != nil {
genesis.Alloc[*faucet] = genesisT.GenesisAccount{Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}
}
return genesis
}

// Use an ETC equivalent of AllEthashProtocolChanges.
Expand Down Expand Up @@ -153,7 +157,7 @@ func DeveloperGenesisBlock(gasLimit uint64, faucet common.Address, useEthash boo
}

// Assemble and return the genesis with the precompiles and faucet pre-funded
return &genesisT.Genesis{
genesis := &genesisT.Genesis{
Config: config,
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
GasLimit: 6283185,
Expand All @@ -168,7 +172,10 @@ func DeveloperGenesisBlock(gasLimit uint64, faucet common.Address, useEthash boo
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))},
},
}
if faucet != nil {
genesis.Alloc[*faucet] = genesisT.GenesisAccount{Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}
}
return genesis
}

0 comments on commit 193e17f

Please sign in to comment.