-
Notifications
You must be signed in to change notification settings - Fork 150
fix(exporter): populate dutyStore in all modes — stop blackholing exit/proposer/sync-contribution messages #2892
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
base: stage
Are you sure you want to change the base?
Changes from 3 commits
c50df37
d104430
9527b05
863bc11
0eae766
f927ae0
651052b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -693,3 +693,61 @@ func TestScheduler_HandleHeadEvent_DoesNotBlockWithoutReorgConsumer(t *testing.T | |
| PreviousDutyDependentRootChanged: true, | ||
| }}, drainReorgEvents(s.reorgCh)) | ||
| } | ||
|
|
||
| func TestNewScheduler_HandlerRegistration(t *testing.T) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about extending this to cover the safety invariant, not just registration? It asserts the handler set per mode, which is great, but nothing about A focused assertion at the node/scheduler boundary (exporter mode ⇒ no-op executor, or handlers carry
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extended the test to assert exporterMode propagates into each handler type and that Scheduler.exporterMode is set correctly. |
||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| exporterMode bool | ||
| archiveMode bool | ||
| wantHandlers []string | ||
| }{ | ||
| { | ||
| name: "operator mode", | ||
| exporterMode: false, | ||
| archiveMode: false, | ||
| wantHandlers: []string{"PROPOSER", "SYNC_COMMITTEE", "VOLUNTARY_EXIT", "ATTESTER", "CLUSTER", "VALIDATOR_REGISTRATION"}, | ||
| }, | ||
| { | ||
| name: "standard exporter", | ||
| exporterMode: true, | ||
| archiveMode: false, | ||
| // VoluntaryExit is included so the dutyStore is populated for message validation; | ||
| // Attester is excluded because the standard exporter does not trace duties. | ||
| wantHandlers: []string{"PROPOSER", "SYNC_COMMITTEE", "VOLUNTARY_EXIT"}, | ||
| }, | ||
| { | ||
| name: "archive exporter", | ||
| exporterMode: true, | ||
| archiveMode: true, | ||
| // Archive exporter needs Attester for full duty tracing but still skips | ||
| // execution-only handlers (CLUSTER, VALIDATOR_REGISTRATION). | ||
| wantHandlers: []string{"PROPOSER", "SYNC_COMMITTEE", "VOLUNTARY_EXIT", "ATTESTER"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| defer cancel() | ||
|
|
||
| s := NewScheduler(zap.NewNop(), &SchedulerOptions{ | ||
| ExporterMode: tc.exporterMode, | ||
| ArchiveMode: tc.archiveMode, | ||
| SlotTickerProvider: func() slotticker.SlotTicker { | ||
| return NewMockSlotTicker(ctx) | ||
| }, | ||
| }) | ||
|
|
||
| got := make([]string, 0, len(s.dutyHandlers)) | ||
| for _, h := range s.dutyHandlers { | ||
| got = append(got, h.Name()) | ||
| } | ||
|
|
||
| require.ElementsMatch(t, tc.wantHandlers, got) | ||
| }) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -78,8 +78,8 @@ type Node struct { | |||||||||||||||||||
| exporterRead *exporter2.Exporter | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| func shouldRunDutyScheduler(exporterOpts exporter.Options) bool { | ||||||||||||||||||||
| return !exporterOpts.Enabled || exporterOpts.Mode == exporter.ModeArchive | ||||||||||||||||||||
| func shouldRunDutyScheduler(_ exporter.Options) bool { | ||||||||||||||||||||
| return true | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||||||
|
|
||||||||||||||||||||
| // New is the constructor of Node | ||||||||||||||||||||
|
|
@@ -105,8 +105,8 @@ func New(logger *zap.Logger, opts Options, exporterOpts exporter.Options, slotTi | |||||||||||||||||||
|
|
||||||||||||||||||||
| var dutyScheduler *duties.Scheduler | ||||||||||||||||||||
| if shouldRunDutyScheduler(exporterOpts) { | ||||||||||||||||||||
| // Prepare scheduler wiring; in exporter archive mode we swap to AllShares provider, | ||||||||||||||||||||
| // a prefetching beacon adapter, and a no-op executor. | ||||||||||||||||||||
| // Prepare scheduler wiring; in exporter mode (both standard and archive) swap to AllShares | ||||||||||||||||||||
| // provider, a prefetching beacon adapter, and a no-op executor. | ||||||||||||||||||||
| schedulerBeacon := duties.BeaconNode(opts.BeaconNode) | ||||||||||||||||||||
| validatorProvider := duties.ValidatorProvider(selfValidatorStore) | ||||||||||||||||||||
| dutyExecutor := duties.DutyExecutor(opts.ValidatorController) | ||||||||||||||||||||
|
|
@@ -132,6 +132,7 @@ func New(logger *zap.Logger, opts Options, exporterOpts exporter.Options, slotTi | |||||||||||||||||||
| SlotTickerProvider: slotTickerProvider, | ||||||||||||||||||||
| P2PNetwork: opts.P2PNetwork, | ||||||||||||||||||||
| ExporterMode: exporterOpts.Enabled, | ||||||||||||||||||||
| ArchiveMode: exporterOpts.Mode == exporter.ModeArchive, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -179,8 +180,6 @@ func (n *Node) Start(ctx context.Context) error { | |||||||||||||||||||
| if err := n.dutyScheduler.Start(ctx); err != nil { | ||||||||||||||||||||
| return fmt.Errorf("failed to run duty scheduler: %w", err) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| n.logger.Info("exporter standard mode: skipping duty scheduler") | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| n.validatorsCtrl.StartNetworkHandlers() | ||||||||||||||||||||
|
|
||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding a symmetric guard for VoluntaryExit.
Proposer and SyncCommittee both short-circuit with
if h.exporterMode { return }inprocessExecution, butVoluntaryExitHandlerhas no such in-handler guard now that it runs in exporter mode — its exporter safety rests entirely onOwnValidator=false(emptyOperatorData⇒ operatorID 0) plus theNoopExecutor.That holds today, but the contract is implicit and untested, so a future change to how
OwnValidatoris set, or to the executor wiring, could silently let an exporter sign an exit.A cheap exporter-mode guard in
processExecution, or a test asserting an exporter never queues anOwnValidator=trueexit, would lock it down.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, added it. now has an field and guards before calling .