Skip to content

Commit fb95505

Browse files
authored
Merge pull request #128 from ethpandaops/chore/expose-more-cfg
feat(beacons): expose attestation subnet mismatch detection tunables
2 parents 2073cef + c82def3 commit fb95505

File tree

5 files changed

+156
-45
lines changed

5 files changed

+156
-45
lines changed

pkg/application/beacons.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,43 @@ func (a *Application) createBeaconConfig(address string) *ethereum.Config {
164164
if int(a.config.AttestationSubnetCheck.MaxSubnets) != 0 {
165165
config.AttestationSubnetConfig.MaxSubnets = int(a.config.AttestationSubnetCheck.MaxSubnets)
166166
}
167+
168+
// Apply mismatch detection settings if provided
169+
if a.config.AttestationSubnetCheck.MismatchDetectionWindow != 0 {
170+
config.AttestationSubnetConfig.MismatchDetectionWindow = int(a.config.AttestationSubnetCheck.MismatchDetectionWindow)
171+
}
172+
173+
if a.config.AttestationSubnetCheck.MismatchThreshold != 0 {
174+
config.AttestationSubnetConfig.MismatchThreshold = int(a.config.AttestationSubnetCheck.MismatchThreshold)
175+
}
176+
177+
if a.config.AttestationSubnetCheck.MismatchCooldownSeconds != 0 {
178+
config.AttestationSubnetConfig.MismatchCooldownSeconds = int(a.config.AttestationSubnetCheck.MismatchCooldownSeconds)
179+
}
180+
181+
if a.config.AttestationSubnetCheck.SubnetHighWaterMark != 0 {
182+
config.AttestationSubnetConfig.SubnetHighWaterMark = int(a.config.AttestationSubnetCheck.SubnetHighWaterMark)
183+
}
167184
}
168185

169186
return config
170187
}
171188

172189
// createTopicManager creates and configures a topic manager for the beacon node.
173190
func (a *Application) createTopicManager(ctx context.Context, log logrus.FieldLogger, config *ethereum.Config) (ethereum.TopicManager, error) {
191+
// Log attestation subnet configuration
192+
if config.AttestationSubnetConfig.Enabled {
193+
log.WithFields(logrus.Fields{
194+
"max_subnets": config.AttestationSubnetConfig.MaxSubnets,
195+
"mismatch_detection_window": config.AttestationSubnetConfig.MismatchDetectionWindow,
196+
"mismatch_threshold": config.AttestationSubnetConfig.MismatchThreshold,
197+
"mismatch_cooldown_seconds": config.AttestationSubnetConfig.MismatchCooldownSeconds,
198+
"subnet_high_water_mark": config.AttestationSubnetConfig.SubnetHighWaterMark,
199+
}).Info("Attestation subnet checking enabled")
200+
} else {
201+
log.Info("Attestation subnet checking disabled")
202+
}
203+
174204
topicManager := ethereum.NewTopicManager(log, &ethereum.TopicConfig{
175205
AllTopics: ethereum.GetDefaultAllTopics(),
176206
OptInTopics: ethereum.GetOptInTopics(),

pkg/config/v1/config.pb.go

Lines changed: 92 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/v1/config.pb.validate.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ethereum/config.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@ import (
44
"errors"
55
)
66

7-
const defaultMaxSubnets = 2
7+
const (
8+
// Max number of subnets acceptable to monitor.
9+
defaultMaxSubnets = 2
10+
// Number of slots to track to determine a mismatch.
11+
defaultMismatchDetectionWindow = 2
12+
// Number of times a detection window mismatch needs to trigger before reconnection.
13+
defaultMismatchThreshold = 1
14+
// Number of seconds post reconnection before another reconnection can potentially occur.
15+
defaultMismatchCooldownSeconds = 300 // 5 minutes.
16+
// Number of additional events on subnets other than the advetised allowed before mismatch is triggered.
17+
subnetHighWaterMark = 5
18+
)
819

920
// Config defines the configuration for the Ethereum beacon node.
1021
type Config struct {
@@ -42,10 +53,10 @@ func NewDefaultConfig() *Config {
4253
AttestationSubnetConfig: SubnetConfig{
4354
Enabled: false,
4455
MaxSubnets: defaultMaxSubnets,
45-
MismatchDetectionWindow: 32,
46-
MismatchThreshold: 1,
47-
MismatchCooldownSeconds: 300, // 5 minutes
48-
SubnetHighWaterMark: 5, // Allow up to 5 additional temporary subnets
56+
MismatchDetectionWindow: defaultMismatchDetectionWindow,
57+
MismatchThreshold: defaultMismatchThreshold,
58+
MismatchCooldownSeconds: defaultMismatchCooldownSeconds,
59+
SubnetHighWaterMark: subnetHighWaterMark,
4960
},
5061
}
5162
}

proto/config/v1/config.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ message AttestationSubnetCheck {
7070
// MaxSubnets is the maximum number of subnets a node can be subscribed to
7171
// before single_attestation topic is disabled.
7272
uint32 max_subnets = 2 [(buf.validate.field).uint32 = { lte: 64 }];
73+
// MismatchDetectionWindow is the number of slots to track for subnet activity.
74+
uint32 mismatch_detection_window = 3;
75+
// MismatchThreshold is the number of mismatches required before triggering reconnection.
76+
uint32 mismatch_threshold = 4;
77+
// MismatchCooldownSeconds is the cooldown period between reconnections in seconds.
78+
uint32 mismatch_cooldown_seconds = 5;
79+
// SubnetHighWaterMark allows temporary participation in additional subnets
80+
// without triggering a restart. This accommodates validators temporarily
81+
// joining subnets to submit attestations while protecting privacy.
82+
uint32 subnet_high_water_mark = 6;
7383
}
7484

7585

0 commit comments

Comments
 (0)