Skip to content

Commit

Permalink
cmd/utils: fix error at geth startup in --dev mode (ethereum#26550)
Browse files Browse the repository at this point in the history
This fixes a regression in ethereum#26541 where we turned the miner address
being missing into a startup error. The address was not configured in
--dev mode.
  • Loading branch information
fjl authored and shekhirin committed Jun 6, 2023
1 parent 7c8cfdd commit 4f8f37b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// when we're definitely concerned with only one account.
passphrase = list[0]
}

// Unlock the developer account by local keystore.
var ks *keystore.KeyStore
if keystores := stack.AccountManager().Backends(keystore.KeyStoreType); len(keystores) > 0 {
Expand All @@ -1920,6 +1921,8 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if ks == nil {
Fatalf("Keystore is not available")
}

// Figure out the dev account address.
// setEtherbase has been called above, configuring the miner address from command line flags.
if cfg.Miner.Etherbase != (common.Address{}) {
developer = accounts.Account{Address: cfg.Miner.Etherbase}
Expand All @@ -1931,6 +1934,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
Fatalf("Failed to create developer account: %v", err)
}
}
// Make sure the address is configured as fee recipient, otherwise
// the miner will fail to start.
cfg.Miner.Etherbase = developer.Address

if err := ks.Unlock(developer, passphrase); err != nil {
Fatalf("Failed to unlock developer account: %v", err)
}
Expand Down

0 comments on commit 4f8f37b

Please sign in to comment.