From 4f8f37b01582409d8672b4a1865e68ce74e65977 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 26 Jan 2023 10:07:20 +0100 Subject: [PATCH] cmd/utils: fix error at geth startup in --dev mode (#26550) This fixes a regression in #26541 where we turned the miner address being missing into a startup error. The address was not configured in --dev mode. --- cmd/utils/flags.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2bbbc381bea1..597fc5603fc9 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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 { @@ -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} @@ -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) }