Skip to content

Commit caf5fed

Browse files
refcellavalonche
authored andcommitted
Add builder config toml support (#2)
1 parent ee678b3 commit caf5fed

File tree

4 files changed

+61
-19
lines changed

4 files changed

+61
-19
lines changed

builder/config.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package builder
2+
3+
type Config struct {
4+
Enabled bool `toml:",omitempty"`
5+
EnableValidatorChecks bool `toml:",omitempty"`
6+
EnableLocalRelay bool `toml:",omitempty"`
7+
DisableBundleFetcher bool `toml:",omitempty"`
8+
DryRun bool `toml:",omitempty"`
9+
BuilderSecretKey string `toml:",omitempty"`
10+
RelaySecretKey string `toml:",omitempty"`
11+
ListenAddr string `toml:",omitempty"`
12+
GenesisForkVersion string `toml:",omitempty"`
13+
BellatrixForkVersion string `toml:",omitempty"`
14+
GenesisValidatorsRoot string `toml:",omitempty"`
15+
BeaconEndpoint string `toml:",omitempty"`
16+
RemoteRelayEndpoint string `toml:",omitempty"`
17+
ValidationBlocklist string `toml:",omitempty"`
18+
}
19+
20+
// DefaultConfig is the default config for the builder.
21+
var DefaultConfig = Config{
22+
Enabled: false,
23+
EnableValidatorChecks: false,
24+
EnableLocalRelay: false,
25+
DisableBundleFetcher: false,
26+
DryRun: false,
27+
BuilderSecretKey: "0x2fc12ae741f29701f8e30f5de6350766c020cb80768a0ff01e6838ffd2431e11",
28+
RelaySecretKey: "0x2fc12ae741f29701f8e30f5de6350766c020cb80768a0ff01e6838ffd2431e11",
29+
ListenAddr: ":28545",
30+
GenesisForkVersion: "0x00000000",
31+
BellatrixForkVersion: "0x02000000",
32+
GenesisValidatorsRoot: "0x0000000000000000000000000000000000000000000000000000000000000000",
33+
BeaconEndpoint: "http://127.0.0.1:5052",
34+
RemoteRelayEndpoint: "",
35+
ValidationBlocklist: "",
36+
}

builder/service.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,7 @@ func NewService(listenAddr string, localRelay *LocalRelay, builder *Builder) *Se
104104
}
105105
}
106106

107-
type BuilderConfig struct {
108-
Enabled bool
109-
EnableValidatorChecks bool
110-
EnableLocalRelay bool
111-
DisableBundleFetcher bool
112-
DryRun bool
113-
BuilderSecretKey string
114-
RelaySecretKey string
115-
ListenAddr string
116-
GenesisForkVersion string
117-
BellatrixForkVersion string
118-
GenesisValidatorsRoot string
119-
BeaconEndpoint string
120-
RemoteRelayEndpoint string
121-
ValidationBlocklist string
122-
}
123-
124-
func Register(stack *node.Node, backend *eth.Ethereum, cfg *BuilderConfig) error {
107+
func Register(stack *node.Node, backend *eth.Ethereum, cfg *Config) error {
125108
envRelaySkBytes, err := hexutil.Decode(cfg.RelaySecretKey)
126109
if err != nil {
127110
return errors.New("incorrect builder API secret key provided")

cmd/geth/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ type gethConfig struct {
9292
Node node.Config
9393
Ethstats ethstatsConfig
9494
Metrics metrics.Config
95+
Builder builder.Config
9596
}
9697

9798
func loadConfig(file string, cfg *gethConfig) error {
@@ -127,6 +128,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
127128
Eth: ethconfig.Defaults,
128129
Node: defaultNodeConfig(),
129130
Metrics: metrics.DefaultConfig,
131+
Builder: builder.DefaultConfig,
130132
}
131133

132134
// Load config file.
@@ -153,6 +155,9 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
153155
}
154156
applyMetricConfig(ctx, &cfg)
155157

158+
// Apply builder flags
159+
utils.SetBuilderConfig(ctx, &cfg.Builder)
160+
156161
return stack, cfg
157162
}
158163

cmd/utils/flags.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,24 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
15501550
}
15511551
}
15521552

1553+
// SetBuilderConfig applies node-related command line flags to the config.
1554+
func SetBuilderConfig(ctx *cli.Context, cfg *builder.Config) {
1555+
cfg.Enabled = ctx.IsSet(BuilderEnabled.Name)
1556+
cfg.EnableValidatorChecks = ctx.IsSet(BuilderEnableValidatorChecks.Name)
1557+
cfg.EnableLocalRelay = ctx.IsSet(BuilderEnableLocalRelay.Name)
1558+
cfg.DisableBundleFetcher = ctx.IsSet(BuilderDisableBundleFetcher.Name)
1559+
cfg.DryRun = ctx.IsSet(BuilderDryRun.Name)
1560+
cfg.BuilderSecretKey = ctx.String(BuilderSecretKey.Name)
1561+
cfg.RelaySecretKey = ctx.String(BuilderRelaySecretKey.Name)
1562+
cfg.ListenAddr = ctx.String(BuilderListenAddr.Name)
1563+
cfg.GenesisForkVersion = ctx.String(BuilderGenesisForkVersion.Name)
1564+
cfg.BellatrixForkVersion = ctx.String(BuilderBellatrixForkVersion.Name)
1565+
cfg.GenesisValidatorsRoot = ctx.String(BuilderGenesisValidatorsRoot.Name)
1566+
cfg.BeaconEndpoint = ctx.String(BuilderBeaconEndpoint.Name)
1567+
cfg.RemoteRelayEndpoint = ctx.String(BuilderRemoteRelayEndpoint.Name)
1568+
cfg.ValidationBlocklist = ctx.String(BuilderBlockValidationBlacklistSourceFilePath.Name)
1569+
}
1570+
15531571
// SetNodeConfig applies node-related command line flags to the config.
15541572
func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
15551573
SetP2PConfig(ctx, &cfg.P2P)
@@ -2106,7 +2124,7 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis common.Hash) {
21062124
// RegisterEthService adds an Ethereum client to the stack.
21072125
// The second return value is the full node instance, which may be nil if the
21082126
// node is running as a light client.
2109-
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config, bpCfg *builder.BuilderConfig) (ethapi.Backend, *eth.Ethereum) {
2127+
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config, bpCfg *builder.Config) (ethapi.Backend, *eth.Ethereum) {
21102128
if cfg.SyncMode == downloader.LightSync {
21112129
backend, err := les.New(stack, cfg)
21122130
if err != nil {

0 commit comments

Comments
 (0)