Skip to content

Commit 1cdf4d6

Browse files
authored
eth/catalyst: set FeeRecipient in dev mode (ethereum#31316)
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.
1 parent 74c6b69 commit 1cdf4d6

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

cmd/geth/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func makeFullNode(ctx *cli.Context) *node.Node {
233233

234234
if ctx.IsSet(utils.DeveloperFlag.Name) {
235235
// Start dev mode.
236-
simBeacon, err := catalyst.NewSimulatedBeacon(ctx.Uint64(utils.DeveloperPeriodFlag.Name), eth)
236+
simBeacon, err := catalyst.NewSimulatedBeacon(ctx.Uint64(utils.DeveloperPeriodFlag.Name), cfg.Eth.Miner.PendingFeeRecipient, eth)
237237
if err != nil {
238238
utils.Fatalf("failed to register dev mode catalyst service: %v", err)
239239
}

cmd/utils/flags.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,8 +1757,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
17571757
// the miner will fail to start.
17581758
cfg.Miner.PendingFeeRecipient = developer.Address
17591759

1760-
if err := ks.Unlock(developer, passphrase); err != nil {
1761-
Fatalf("Failed to unlock developer account: %v", err)
1760+
// try to unlock the first keystore account
1761+
if len(ks.Accounts()) > 0 {
1762+
if err := ks.Unlock(developer, passphrase); err != nil {
1763+
Fatalf("Failed to unlock developer account: %v", err)
1764+
}
17621765
}
17631766
log.Info("Using developer account", "address", developer.Address)
17641767

eth/catalyst/simulated_beacon.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func payloadVersion(config *params.ChainConfig, time uint64) engine.PayloadVersi
108108
}
109109

110110
// NewSimulatedBeacon constructs a new simulated beacon chain.
111-
func NewSimulatedBeacon(period uint64, eth *eth.Ethereum) (*SimulatedBeacon, error) {
111+
func NewSimulatedBeacon(period uint64, feeRecipient common.Address, eth *eth.Ethereum) (*SimulatedBeacon, error) {
112112
block := eth.BlockChain().CurrentBlock()
113113
current := engine.ForkchoiceStateV1{
114114
HeadBlockHash: block.Hash(),
@@ -131,6 +131,7 @@ func NewSimulatedBeacon(period uint64, eth *eth.Ethereum) (*SimulatedBeacon, err
131131
engineAPI: engineAPI,
132132
lastBlockTime: block.Time,
133133
curForkchoiceState: current,
134+
feeRecipient: feeRecipient,
134135
}, nil
135136
}
136137

eth/catalyst/simulated_beacon_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func startSimulatedBeaconEthService(t *testing.T, genesis *core.Genesis, period
5555
t.Fatal("can't create eth service:", err)
5656
}
5757

58-
simBeacon, err := NewSimulatedBeacon(period, ethservice)
58+
simBeacon, err := NewSimulatedBeacon(period, common.Address{}, ethservice)
5959
if err != nil {
6060
t.Fatal("can't create simulated beacon:", err)
6161
}

ethclient/simulated/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func newWithNode(stack *node.Node, conf *eth.Config, blockPeriod uint64) (*Backe
120120
return nil, err
121121
}
122122
// Set up the simulated beacon
123-
beacon, err := catalyst.NewSimulatedBeacon(blockPeriod, backend)
123+
beacon, err := catalyst.NewSimulatedBeacon(blockPeriod, common.Address{}, backend)
124124
if err != nil {
125125
return nil, err
126126
}

0 commit comments

Comments
 (0)