diff --git a/pkg/exporter/config.go b/pkg/exporter/config.go index 0109b3e..3090918 100644 --- a/pkg/exporter/config.go +++ b/pkg/exporter/config.go @@ -20,9 +20,15 @@ type Config struct { // ConsensusNode represents a single ethereum consensus client. type ConsensusNode struct { - Enabled bool `yaml:"enabled"` - Name string `yaml:"name"` - URL string `yaml:"url"` + Enabled bool `yaml:"enabled"` + Name string `yaml:"name"` + URL string `yaml:"url"` + EventStream EventStream `yaml:"eventStream"` +} + +type EventStream struct { + Enabled *bool `yaml:"enabled"` + Topics []string `yaml:"topics"` } // ExecutionNode represents a single ethereum execution client. @@ -47,6 +53,8 @@ type PairConfig struct { // DefaultConfig represents a sane-default configuration. func DefaultConfig() *Config { + f := false + return &Config{ Execution: ExecutionNode{ Enabled: true, @@ -58,6 +66,10 @@ func DefaultConfig() *Config { Enabled: true, Name: "consensus", URL: "http://localhost:5052", + EventStream: EventStream{ + Enabled: &f, + Topics: []string{}, + }, }, DiskUsage: DiskUsage{ Enabled: false, diff --git a/pkg/exporter/exporter.go b/pkg/exporter/exporter.go index 1536b1f..7614f41 100644 --- a/pkg/exporter/exporter.go +++ b/pkg/exporter/exporter.go @@ -150,9 +150,22 @@ func (e *exporter) Serve(ctx context.Context, port int) error { func (e *exporter) bootstrapConsensusClients(_ context.Context) error { opts := *beacon.DefaultOptions(). - EnableDefaultBeaconSubscription(). EnablePrometheusMetrics() + if e.config.Consensus.EventStream.Enabled != nil && *e.config.Consensus.EventStream.Enabled { + opts.BeaconSubscription.Topics = e.config.Consensus.EventStream.Topics + + if len(opts.BeaconSubscription.Topics) == 0 { + opts.EnableDefaultBeaconSubscription() + } + + e.log.WithField( + "topics", strings.Join(opts.BeaconSubscription.Topics, ", "), + ).Info("Enabling beacon event stream with topics...") + + opts.BeaconSubscription.Enabled = true + } + e.beacon = beacon.NewNode(e.log, &beacon.Config{ Addr: e.config.Consensus.URL, Name: e.config.Consensus.Name,