Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sentry): allow config subscription of topics #237

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/sentry.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Sentry requires a single `yaml` config file. An example file can be found [here]
| name | string | | Unique name of the sentry |
| labels | object | | A key value map of labels to append to every sentry event |
| ethereum.beaconNodeAddress | string | | [Ethereum consensus client](https://ethereum.org/en/developers/docs/nodes-and-clients/#consensus-clients) http server endpoint |
| ethereum.beaconSubscriptions | array<string> | | List of [topcis](https://ethereum.github.io/beacon-APIs/#/Events/eventstream) to subscribe to. If empty, all subscriptions are subscribed to.
| ntpServer | string | `pool.ntp.org` | NTP server to calculate clock drift for events |
| outputs | array<object> | | List of outputs for the sentry to send data to |
| outputs[].name | string | | Name of the output |
Expand Down
10 changes: 9 additions & 1 deletion pkg/sentry/ethereum/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@ type BeaconNode struct {
func NewBeaconNode(ctx context.Context, name string, config *Config, log logrus.FieldLogger) (*BeaconNode, error) {
opts := *beacon.
DefaultOptions().
EnableDefaultBeaconSubscription().
DisablePrometheusMetrics()

if config.BeaconSubscriptions != nil {
opts.BeaconSubscription = beacon.BeaconSubscriptionOptions{
Enabled: true,
Topics: *config.BeaconSubscriptions,
}
} else {
opts.EnableDefaultBeaconSubscription()
}

opts.HealthCheck.Interval.Duration = time.Second * 3
opts.HealthCheck.SuccessfulResponses = 1

Expand Down
2 changes: 2 additions & 0 deletions pkg/sentry/ethereum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type Config struct {
OverrideNetworkName string `yaml:"overrideNetworkName" default:""`
// BeaconNodeHeaders is a map of headers to send to the beacon node.
BeaconNodeHeaders map[string]string `yaml:"beaconNodeHeaders"`
// BeaconSubscriptions is a list of beacon subscriptions to subscribe to.
BeaconSubscriptions *[]string `yaml:"beaconSubscriptions"`
}

func (c *Config) Validate() error {
Expand Down
Loading