Skip to content

Conversation

islishude
Copy link
Contributor

@islishude islishude commented Mar 5, 2025

This PR fixes a bug in dev mode. When dev mode is started together with the --miner.pending.feeRecipient it will use that account as the "developer account". I.e. that address will be prefunded.

However this feature was buggy, in that geth would fail to boot up when that flag was present.

Additionally: the same address will be set as the default fee recipient when a block is mined. Previously it was only possible to update fee recipient in dev mode via dev_setFeeRecipient.

@islishude islishude changed the title eth/catlyst,cmd/geth: improve devnet experience eth/catalyst,cmd/geth: improve devnet experience Mar 5, 2025
@@ -1730,20 +1730,21 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// setEtherbase has been called above, configuring the miner address from command line flags.
if cfg.Miner.PendingFeeRecipient != (common.Address{}) {
developer = accounts.Account{Address: cfg.Miner.PendingFeeRecipient}
} else if accs := ks.Accounts(); len(accs) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from removing the call to unlock the keystore, the changes in this file seem like a no-op.

Copy link
Contributor

@jwasinger jwasinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the changes to automatically set the fee recipient are okay and should be kept, but the keystore changes are not correct.

@islishude
Copy link
Contributor Author

Do you mean that you need a dev account even if an address is given?

@jwasinger
Copy link
Contributor

Yes, we should always attempt to unlock the first account in the keystore if it exists. Dev mode can be operated non-ephemerally, and when restarted the dev-mode account should be unlocked. Other cases, (e.g. where a user wants to swap to a different keystore, and don't necessarily want the first account unlocked) don't really matter for dev mode IMO.

@islishude
Copy link
Contributor Author

Yes, we should always attempt to unlock the first account in the keystore if it exists.

updated.

@jwasinger
Copy link
Contributor

Just revert all the changes except for setting the fee recipient to what is specified by the miner flag.

@islishude
Copy link
Contributor Author

if I don't have any accounts in keystore, the unlock will fail.

I have to create a keystore first to start geth --dev, that's I want to avoid.

@islishude
Copy link
Contributor Author

My use case is not to use the keystore to start geth --dev

geth --dev on the master branch will create a new random address, and the address will have initial fund in genesis. so that if I want to use the address in my apps, I have to get the private key or transfer fund to my own address.

or I have to create a keystore first.

geth account import --datadir ./data --password ./password test.key
geth --dev --keystore ... --password

My PR is to avoid the chores, and lemme manage the keys in my apps.

@jwasinger
Copy link
Contributor

jwasinger commented Mar 12, 2025

okay, I think I see what is wrong:

You are trying to instantiate a dev mode instance from a chain you have configured with your own account (that isn't in the keystore). You are setting the cfg.Miner.PendingFeeRecipient to your account which triggers an attempt to unlock it via the keystore, and fails.

edit maybe not.

@islishude
Copy link
Contributor Author

yes, the keystore.unlock alwasy gets called, that's the problem.

@MariusVanDerWijden MariusVanDerWijden merged commit 1cdf4d6 into ethereum:master Mar 17, 2025
1 of 2 checks passed
sivaratrisrinivas pushed a commit to sivaratrisrinivas/go-ethereum that referenced this pull request Apr 21, 2025
this adds 2 features to improve `geth --dev` experience.

1. we don't need to use `dev_SetFeeRecipient` to set initial coinbase
address. it was a pain.
2. we don't need to unlock keystore if we don't use it. we had it
because of clique.
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Jul 3, 2025
this adds 2 features to improve `geth --dev` experience.

1. we don't need to use `dev_SetFeeRecipient` to set initial coinbase
address. it was a pain.
2. we don't need to unlock keystore if we don't use it. we had it
because of clique.
howjmay pushed a commit to iotaledger/go-ethereum that referenced this pull request Aug 27, 2025
this adds 2 features to improve `geth --dev` experience.

1. we don't need to use `dev_SetFeeRecipient` to set initial coinbase
address. it was a pain.
2. we don't need to unlock keystore if we don't use it. we had it
because of clique.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants