Skip to content

Commit

Permalink
Merge pull request #114 from ethpandaops/feat/disable-event-stream
Browse files Browse the repository at this point in the history
feat(consensus): Add EventStream config
  • Loading branch information
samcm authored Nov 24, 2024
2 parents 9ad01d5 + 0cb2bf8 commit 69f8e01
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
18 changes: 15 additions & 3 deletions pkg/exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -47,6 +53,8 @@ type PairConfig struct {

// DefaultConfig represents a sane-default configuration.
func DefaultConfig() *Config {
f := false

return &Config{
Execution: ExecutionNode{
Enabled: true,
Expand All @@ -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,
Expand Down
15 changes: 14 additions & 1 deletion pkg/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 69f8e01

Please sign in to comment.