@lodestar/validator 1.50.0-dev.072bf98853 → 1.50.0-dev.0837ebd402

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,247 @@
1
+ import {ApiClient, routes} from "@lodestar/api";
2
+ import {ChainForkConfig} from "@lodestar/config";
3
+ import {SLOTS_PER_EPOCH, isForkPostGloas} from "@lodestar/params";
4
+ import {IClock, computeEpochAtSlot} from "@lodestar/state-transition";
5
+ import {Epoch, RootHex, Slot, gloas} from "@lodestar/types";
6
+ import {fromHex, toPubkeyHex} from "@lodestar/utils";
7
+ import {Metrics} from "../metrics.js";
8
+ import {LoggerVc} from "../util/index.js";
9
+ import {BlockDutiesService} from "./blockDuties.js";
10
+ import {ValidatorStore} from "./validatorStore.js";
11
+
12
+ /**
13
+ * Submit the preferences of a proposal this many slots before the proposal slot.
14
+ *
15
+ * Earlier submission means more reorg-triggered resubmits (and gossip flood); later
16
+ * submission risks missing the bid-auction window for this proposal slot. The bid for
17
+ * slot S typically arrives at slot S-1, so we want preferences propagated to the network
18
+ * and consumed by builders before then. SLOTS_PER_EPOCH / 4 (8 slots @ 32 SPE, ~96s @ 12s
19
+ * slots) gives ample margin while bounding redundant resubmits.
20
+ */
21
+ const SUBMIT_BEFORE_PROPOSAL_SLOTS = Math.floor(SLOTS_PER_EPOCH / 4);
22
+
23
+ /** Per-epoch tracking of preferences already submitted under the current dependent_root. */
24
+ type SubmittedAtEpoch = {dependentRoot: RootHex; proposerSlots: Set<Slot>; builderSlots: Set<Slot>};
25
+ type PendingSubmission = {submission: SubmittedAtEpoch; slot: Slot};
26
+ /** A local proposal within the submission window along with the tracking of its epoch */
27
+ type UpcomingProposal = {duty: routes.validator.ProposerDuty; submission: SubmittedAtEpoch};
28
+
29
+ /**
30
+ * Signs and submits the preferences of local proposals within the next `SUBMIT_BEFORE_PROPOSAL_SLOTS`:
31
+ * the `SignedProposerPreferences` the beacon node broadcasts on gossip and the builder preferences
32
+ * it forwards to the builders configured for the validator. Signing the builder request auths here
33
+ * also pre-fills the auth cache used at proposal time.
34
+ *
35
+ * Re-submits automatically when the proposer dependent root for an epoch shifts (e.g. after a reorg)
36
+ * since the proposer for a slot may have changed. Detected by comparing the cached `dependentRoot`
37
+ * reported by `BlockDutiesService` against the one we last submitted under.
38
+ *
39
+ * Proposers should broadcast their preferences before the fork so the proposer preference caches
40
+ * of beacon nodes and builders are warm for the first Gloas slots. We start submitting
41
+ * as soon as a duty's proposal slot is in Gloas, which is up to `SUBMIT_BEFORE_PROPOSAL_SLOTS`
42
+ * before the fork, so only the first few Gloas slots are affected by this pre-fork submission.
43
+ */
44
+ export class ProposalPreferencesService {
45
+ private readonly submitted = new Map<Epoch, SubmittedAtEpoch>();
46
+ private activeScheduledGasLimit: number | undefined;
47
+
48
+ constructor(
49
+ private readonly config: ChainForkConfig,
50
+ private readonly logger: LoggerVc,
51
+ private readonly api: ApiClient,
52
+ clock: IClock,
53
+ private readonly validatorStore: ValidatorStore,
54
+ private readonly blockDutiesService: BlockDutiesService,
55
+ _metrics: Metrics | null
56
+ ) {
57
+ clock.runEverySlot(this.runPreferencesTask);
58
+ clock.runEveryEpoch(this.runEveryEpochTask);
59
+ }
60
+
61
+ private runPreferencesTask = async (slot: Slot): Promise<void> => {
62
+ // Start running once the submission window (`slot + SUBMIT_BEFORE_PROPOSAL_SLOTS`) reaches
63
+ // Gloas, i.e. already in the epoch before the fork. This allows builders to prepare and
64
+ // submit bids for the first Gloas slots.
65
+ if (!isForkPostGloas(this.config.getForkName(slot + SUBMIT_BEFORE_PROPOSAL_SLOTS))) {
66
+ return;
67
+ }
68
+
69
+ const proposals = this.getUpcomingProposals(slot);
70
+ if (proposals.length === 0) {
71
+ return;
72
+ }
73
+
74
+ // Signed and submitted independently, a slow signer for one must not delay the other
75
+ await Promise.all([
76
+ this.submitProposerPreferences(proposals, slot),
77
+ this.submitBuilderPreferences(proposals, slot),
78
+ ]);
79
+ };
80
+
81
+ private runEveryEpochTask = async (epoch: Epoch): Promise<void> => {
82
+ const scheduledGasLimit = this.config.getScheduledGasLimit(epoch);
83
+ if (scheduledGasLimit !== undefined && scheduledGasLimit !== this.activeScheduledGasLimit) {
84
+ const configuredDefaultGasLimit = this.validatorStore.getConfiguredDefaultGasLimit();
85
+ this.logger.info("Gas limit schedule active", {
86
+ epoch,
87
+ recommendedGasLimit: scheduledGasLimit,
88
+ effectiveDefaultGasLimit: configuredDefaultGasLimit ?? scheduledGasLimit,
89
+ defaultGasLimitSource: configuredDefaultGasLimit === undefined ? "schedule" : "operator",
90
+ });
91
+ this.activeScheduledGasLimit = scheduledGasLimit;
92
+ }
93
+
94
+ // Drop tracking for past epochs; only currentEpoch and currentEpoch + 1 are ever processed.
95
+ for (const trackedEpoch of this.submitted.keys()) {
96
+ if (trackedEpoch < epoch) {
97
+ this.submitted.delete(trackedEpoch);
98
+ }
99
+ }
100
+ };
101
+
102
+ /** Resets the tracking of `epoch` if the dependent root shifted, previously submitted preferences are stale. */
103
+ private getSubmissionAtEpoch(epoch: Epoch, dependentRoot: RootHex): SubmittedAtEpoch {
104
+ let submission = this.submitted.get(epoch);
105
+ if (submission === undefined || submission.dependentRoot !== dependentRoot) {
106
+ if (submission !== undefined) {
107
+ this.logger.info("Proposer-shuffling dependent root shifted; resubmitting preferences", {
108
+ epoch,
109
+ priorDependentRoot: submission.dependentRoot,
110
+ dependentRoot,
111
+ });
112
+ }
113
+ submission = {dependentRoot, proposerSlots: new Set(), builderSlots: new Set()};
114
+ this.submitted.set(epoch, submission);
115
+ }
116
+ return submission;
117
+ }
118
+
119
+ private getUpcomingProposals(slot: Slot): UpcomingProposal[] {
120
+ const currentEpoch = computeEpochAtSlot(slot);
121
+ const proposals: UpcomingProposal[] = [];
122
+
123
+ for (const epoch of [currentEpoch, currentEpoch + 1]) {
124
+ const dutiesAtEpoch = this.blockDutiesService.getProposersAtEpoch(epoch);
125
+ if (!dutiesAtEpoch) continue;
126
+
127
+ const submission = this.getSubmissionAtEpoch(epoch, dutiesAtEpoch.dependentRoot);
128
+
129
+ for (const duty of dutiesAtEpoch.data) {
130
+ if (duty.slot <= slot) continue;
131
+ if (duty.slot > slot + SUBMIT_BEFORE_PROPOSAL_SLOTS) continue;
132
+ if (!isForkPostGloas(this.config.getForkName(duty.slot))) continue;
133
+
134
+ proposals.push({duty, submission});
135
+ }
136
+ }
137
+
138
+ return proposals;
139
+ }
140
+
141
+ private async submitProposerPreferences(proposals: UpcomingProposal[], slot: Slot): Promise<void> {
142
+ const signedProposerPreferences: gloas.SignedProposerPreferences[] = [];
143
+ // Track which `(submission, slot)` pairs are pending an API submission so we can mark
144
+ // them only after the network call succeeds. Marking before would silently drop a
145
+ // preference on transient API failure (no retry until dependent_root shifts).
146
+ const pending: PendingSubmission[] = [];
147
+
148
+ for (const {duty, submission} of proposals) {
149
+ if (submission.proposerSlots.has(duty.slot)) continue;
150
+
151
+ try {
152
+ const pubkeyHex = toPubkeyHex(duty.pubkey);
153
+ const signed = await this.validatorStore.signProposerPreferences(
154
+ duty,
155
+ fromHex(submission.dependentRoot),
156
+ this.validatorStore.getFeeRecipient(pubkeyHex),
157
+ this.validatorStore.getGasLimit(pubkeyHex, duty.slot, this.logger),
158
+ slot
159
+ );
160
+ signedProposerPreferences.push(signed);
161
+ pending.push({submission, slot: duty.slot});
162
+ } catch (e) {
163
+ this.logger.error(
164
+ "Error signing proposer preferences",
165
+ {slot: duty.slot, validatorIndex: duty.validatorIndex},
166
+ e as Error
167
+ );
168
+ }
169
+ }
170
+
171
+ if (signedProposerPreferences.length === 0) {
172
+ return;
173
+ }
174
+
175
+ try {
176
+ (await this.api.validator.submitProposerPreferences({signedProposerPreferences})).assertOk();
177
+ // Only mark as submitted after the API call succeeds; a thrown error leaves the
178
+ // slot eligible for retry on the next tick.
179
+ for (const {submission, slot: submittedSlot} of pending) {
180
+ submission.proposerSlots.add(submittedSlot);
181
+ }
182
+ this.logger.debug("Submitted signed proposer preferences", {count: signedProposerPreferences.length});
183
+ } catch (e) {
184
+ this.logger.error(
185
+ "Error submitting signed proposer preferences",
186
+ {count: signedProposerPreferences.length},
187
+ e as Error
188
+ );
189
+ }
190
+ }
191
+
192
+ private async submitBuilderPreferences(proposals: UpcomingProposal[], slot: Slot): Promise<void> {
193
+ const builderPreferences: routes.validator.BuilderPreferencesEntry[] = [];
194
+ const pending: PendingSubmission[] = [];
195
+
196
+ for (const {duty, submission} of proposals) {
197
+ if (submission.builderSlots.has(duty.slot)) continue;
198
+
199
+ const pubkeyHex = toPubkeyHex(duty.pubkey);
200
+ const {selection} = this.validatorStore.getBuilderSelectionParams(pubkeyHex, duty.slot);
201
+ if (selection === routes.validator.BuilderSelection.ExecutionOnly) continue;
202
+
203
+ const builderEntries = this.validatorStore.getResolvedBuilderEntries(pubkeyHex);
204
+ if (builderEntries.length === 0) continue;
205
+
206
+ try {
207
+ // Collect entries per duty and only add them to the batch if signing
208
+ // succeeded for all builders, else the duty is retried on the next tick
209
+ const dutyEntries: routes.validator.BuilderPreferencesEntry[] = [];
210
+ for (const entry of builderEntries) {
211
+ const auth = await this.validatorStore.getBuilderRequestAuth(duty.pubkey, entry.authData, duty.slot, slot);
212
+ dutyEntries.push({
213
+ proposerPubkey: duty.pubkey,
214
+ url: new TextEncoder().encode(entry.url),
215
+ auth,
216
+ maxExecutionPayment: entry.maxExecutionPayment,
217
+ });
218
+ }
219
+ builderPreferences.push(...dutyEntries);
220
+ pending.push({submission, slot: duty.slot});
221
+ } catch (e) {
222
+ this.logger.error(
223
+ "Error signing builder preferences",
224
+ {slot: duty.slot, validatorIndex: duty.validatorIndex},
225
+ e as Error
226
+ );
227
+ }
228
+ }
229
+
230
+ if (builderPreferences.length === 0) {
231
+ return;
232
+ }
233
+
234
+ try {
235
+ (await this.api.validator.submitBuilderPreferences({builderPreferences})).assertOk();
236
+ // Only mark as submitted after the API call succeeds; a thrown error, including per-entry
237
+ // failures reported by index, leaves all slots eligible for retry on the next tick.
238
+ // Re-submitting preferences a builder already accepted is harmless.
239
+ for (const {submission, slot: submittedSlot} of pending) {
240
+ submission.builderSlots.add(submittedSlot);
241
+ }
242
+ this.logger.debug("Submitted builder preferences", {count: builderPreferences.length});
243
+ } catch (e) {
244
+ this.logger.warn("Error submitting builder preferences", {count: builderPreferences.length}, e as Error);
245
+ }
246
+ }
247
+ }
package/src/validator.ts CHANGED
@@ -16,14 +16,13 @@ import {MetaDataRepository} from "./repositories/metaDataRepository.js";
16
16
  import {AttestationService} from "./services/attestation.js";
17
17
  import {BlockProposingService} from "./services/block.js";
18
18
  import {BlockDutiesService} from "./services/blockDuties.js";
19
- import {BuilderPreferencesService} from "./services/builderPreferences.js";
20
19
  import {ChainHeaderTracker} from "./services/chainHeaderTracker.js";
21
20
  import {DoppelgangerService} from "./services/doppelgangerService.js";
22
21
  import {ValidatorEventEmitter} from "./services/emitter.js";
23
22
  import {ExternalSignerOptions, pollExternalSignerPubkeys} from "./services/externalSignerSync.js";
24
23
  import {IndicesService} from "./services/indices.js";
25
24
  import {pollBuilderValidatorRegistration, pollPrepareBeaconProposer} from "./services/prepareBeaconProposer.js";
26
- import {ProposerPreferencesService} from "./services/proposerPreferences.js";
25
+ import {ProposalPreferencesService} from "./services/proposalPreferences.js";
27
26
  import {PtcService} from "./services/ptc.js";
28
27
  import {SyncCommitteeService} from "./services/syncCommittee.js";
29
28
  import {SyncingStatusTracker} from "./services/syncingStatusTracker.js";
@@ -320,8 +319,7 @@ export class Validator {
320
319
  }
321
320
  );
322
321
 
323
- new ProposerPreferencesService(config, loggerVc, api, clock, validatorStore, blockDutiesService, metrics);
324
- new BuilderPreferencesService(config, loggerVc, api, clock, validatorStore, blockDutiesService, metrics);
322
+ new ProposalPreferencesService(config, loggerVc, api, clock, validatorStore, blockDutiesService, metrics);
325
323
 
326
324
  return new Validator({
327
325
  opts,
@@ -1,27 +0,0 @@
1
- import { ApiClient } from "@lodestar/api";
2
- import { ChainForkConfig } from "@lodestar/config";
3
- import { IClock } from "@lodestar/state-transition";
4
- import { Metrics } from "../metrics.js";
5
- import { LoggerVc } from "../util/index.js";
6
- import { BlockDutiesService } from "./blockDuties.js";
7
- import { ValidatorStore } from "./validatorStore.js";
8
- /**
9
- * Signs and submits builder preferences for any local validator that will propose within the
10
- * next `SUBMIT_BEFORE_PROPOSAL_SLOTS` and has external builders configured. Signing the request
11
- * auths here also pre-fills the auth cache used at proposal time.
12
- *
13
- * The beacon node submits each entry to the builder at the entry's url. Re-submits automatically
14
- * when the proposer dependent root for an epoch shifts (e.g. after a reorg) since the proposer
15
- * for a slot may have changed.
16
- */
17
- export declare class BuilderPreferencesService {
18
- private readonly config;
19
- private readonly logger;
20
- private readonly api;
21
- private readonly validatorStore;
22
- private readonly blockDutiesService;
23
- private readonly submitted;
24
- constructor(config: ChainForkConfig, logger: LoggerVc, api: ApiClient, clock: IClock, validatorStore: ValidatorStore, blockDutiesService: BlockDutiesService, _metrics: Metrics | null);
25
- private runBuilderPreferencesTask;
26
- }
27
- //# sourceMappingURL=builderPreferences.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builderPreferences.d.ts","sourceRoot":"","sources":["../../src/services/builderPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,MAAM,EAAqB,MAAM,4BAA4B,CAAC;AAGtE,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAYnD;;;;;;;;GAQG;AACH,qBAAa,yBAAyB;IAIlC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAEpB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IARrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsC;IAEhE,YACmB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,QAAQ,EAChB,GAAG,EAAE,SAAS,EAC/B,KAAK,EAAE,MAAM,EACI,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE,kBAAkB,EACvD,QAAQ,EAAE,OAAO,GAAG,IAAI,EAGzB;IAED,OAAO,CAAC,yBAAyB,CA+F/B;CACH"}
@@ -1,127 +0,0 @@
1
- import { routes } from "@lodestar/api";
2
- import { SLOTS_PER_EPOCH, isForkPostGloas } from "@lodestar/params";
3
- import { computeEpochAtSlot } from "@lodestar/state-transition";
4
- import { toPubkeyHex } from "@lodestar/utils";
5
- /**
6
- * Submit a proposer's builder preferences this many slots before the proposal slot.
7
- * Same pacing as `ProposerPreferencesService`, builders must have the preferences
8
- * before the bid request arrives at proposal time.
9
- */
10
- const SUBMIT_BEFORE_PROPOSAL_SLOTS = Math.floor(SLOTS_PER_EPOCH / 4);
11
- /**
12
- * Signs and submits builder preferences for any local validator that will propose within the
13
- * next `SUBMIT_BEFORE_PROPOSAL_SLOTS` and has external builders configured. Signing the request
14
- * auths here also pre-fills the auth cache used at proposal time.
15
- *
16
- * The beacon node submits each entry to the builder at the entry's url. Re-submits automatically
17
- * when the proposer dependent root for an epoch shifts (e.g. after a reorg) since the proposer
18
- * for a slot may have changed.
19
- */
20
- export class BuilderPreferencesService {
21
- config;
22
- logger;
23
- api;
24
- validatorStore;
25
- blockDutiesService;
26
- submitted = new Map();
27
- constructor(config, logger, api, clock, validatorStore, blockDutiesService, _metrics) {
28
- this.config = config;
29
- this.logger = logger;
30
- this.api = api;
31
- this.validatorStore = validatorStore;
32
- this.blockDutiesService = blockDutiesService;
33
- clock.runEverySlot(this.runBuilderPreferencesTask);
34
- }
35
- runBuilderPreferencesTask = async (slot) => {
36
- // Start running once the submission window (`slot + SUBMIT_BEFORE_PROPOSAL_SLOTS`) reaches
37
- // Gloas, i.e. already in the epoch before the fork. This allows builders to prepare and
38
- // submit bids for the first Gloas slots.
39
- if (!isForkPostGloas(this.config.getForkName(slot + SUBMIT_BEFORE_PROPOSAL_SLOTS))) {
40
- return;
41
- }
42
- const currentEpoch = computeEpochAtSlot(slot);
43
- const entries = [];
44
- // Track which `(submission, slot)` pairs are pending an API submission so we can mark
45
- // them only after the network call succeeds. Marking before would silently drop a
46
- // preference on transient API failure (no retry until dependent_root shifts).
47
- const pending = [];
48
- for (const epoch of [currentEpoch, currentEpoch + 1]) {
49
- const dutiesAtEpoch = this.blockDutiesService.getProposersAtEpoch(epoch);
50
- if (!dutiesAtEpoch)
51
- continue;
52
- // Reset submission tracking if the dependent root for this epoch has shifted
53
- // (e.g. due to a reorg). The proposer for a slot may have changed.
54
- let submission = this.submitted.get(epoch);
55
- if (submission === undefined || submission.dependentRoot !== dutiesAtEpoch.dependentRoot) {
56
- if (submission !== undefined) {
57
- this.logger.info("Proposer-shuffling dependent root shifted; resubmitting builder preferences", {
58
- epoch,
59
- priorDependentRoot: submission.dependentRoot,
60
- dependentRoot: dutiesAtEpoch.dependentRoot,
61
- });
62
- }
63
- submission = { dependentRoot: dutiesAtEpoch.dependentRoot, slots: new Set() };
64
- this.submitted.set(epoch, submission);
65
- }
66
- for (const duty of dutiesAtEpoch.data) {
67
- if (duty.slot <= slot)
68
- continue;
69
- if (duty.slot > slot + SUBMIT_BEFORE_PROPOSAL_SLOTS)
70
- continue;
71
- if (!isForkPostGloas(this.config.getForkName(duty.slot)))
72
- continue;
73
- if (submission.slots.has(duty.slot))
74
- continue;
75
- const pubkeyHex = toPubkeyHex(duty.pubkey);
76
- const { selection } = this.validatorStore.getBuilderSelectionParams(pubkeyHex, duty.slot);
77
- if (selection === routes.validator.BuilderSelection.ExecutionOnly)
78
- continue;
79
- const builderEntries = this.validatorStore.getResolvedBuilderEntries(pubkeyHex);
80
- if (builderEntries.length === 0)
81
- continue;
82
- try {
83
- // Collect entries per duty and only add them to the batch if signing
84
- // succeeded for all builders, else the duty is retried on the next tick
85
- const dutyEntries = [];
86
- for (const entry of builderEntries) {
87
- const auth = await this.validatorStore.getBuilderRequestAuth(duty.pubkey, entry.authData, duty.slot, slot);
88
- dutyEntries.push({
89
- proposerPubkey: duty.pubkey,
90
- url: new TextEncoder().encode(entry.url),
91
- auth,
92
- maxExecutionPayment: entry.maxExecutionPayment,
93
- });
94
- }
95
- entries.push(...dutyEntries);
96
- pending.push({ submission, slot: duty.slot });
97
- }
98
- catch (e) {
99
- this.logger.error("Error signing builder preferences", { slot: duty.slot, validatorIndex: duty.validatorIndex }, e);
100
- }
101
- }
102
- }
103
- // Prune tracking for past epochs
104
- for (const epoch of this.submitted.keys()) {
105
- if (epoch < currentEpoch) {
106
- this.submitted.delete(epoch);
107
- }
108
- }
109
- if (entries.length === 0) {
110
- return;
111
- }
112
- try {
113
- (await this.api.validator.submitBuilderPreferences({ builderPreferences: entries })).assertOk();
114
- // Only mark as submitted after the API call succeeds; a thrown error, including per-entry
115
- // failures reported by index, leaves all slots eligible for retry on the next tick.
116
- // Re-submitting preferences a builder already accepted is harmless.
117
- for (const { submission, slot: submittedSlot } of pending) {
118
- submission.slots.add(submittedSlot);
119
- }
120
- this.logger.debug("Submitted builder preferences", { count: entries.length });
121
- }
122
- catch (e) {
123
- this.logger.warn("Error submitting builder preferences", { count: entries.length }, e);
124
- }
125
- };
126
- }
127
- //# sourceMappingURL=builderPreferences.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builderPreferences.js","sourceRoot":"","sources":["../../src/services/builderPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAC,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAC,eAAe,EAAE,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAS,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAEt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AACH,qBAAa,0BAA0B;IAKnC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAEpB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IATrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsC;IAChE,OAAO,CAAC,uBAAuB,CAAqB;IAEpD,YACmB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,QAAQ,EAChB,GAAG,EAAE,SAAS,EAC/B,KAAK,EAAE,MAAM,EACI,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE,kBAAkB,EACvD,QAAQ,EAAE,OAAO,GAAG,IAAI,EAIzB;IAED,OAAO,CAAC,0BAA0B,CA8EhC;IAEF,OAAO,CAAC,iBAAiB,CAmBvB;CACH"}
@@ -1,130 +0,0 @@
1
- import { SLOTS_PER_EPOCH, isForkPostGloas } from "@lodestar/params";
2
- import { computeEpochAtSlot } from "@lodestar/state-transition";
3
- import { fromHex, toPubkeyHex } from "@lodestar/utils";
4
- /**
5
- * Submit a proposer's `SignedProposerPreferences` this many slots before the proposal slot.
6
- *
7
- * Earlier submission means more reorg-triggered resubmits (and gossip flood); later
8
- * submission risks missing the bid-auction window for this proposal slot. The bid for
9
- * slot S typically arrives at slot S-1, so we want preferences propagated to the network
10
- * and consumed by builders before then. SLOTS_PER_EPOCH / 4 (8 slots @ 32 SPE, ~96s @ 12s
11
- * slots) gives ample margin while bounding redundant resubmits.
12
- */
13
- const SUBMIT_BEFORE_PROPOSAL_SLOTS = Math.floor(SLOTS_PER_EPOCH / 4);
14
- /**
15
- * Signs and submits `SignedProposerPreferences` for any local validator that will propose
16
- * within the next `SUBMIT_BEFORE_PROPOSAL_SLOTS`. Re-submits automatically when the proposer
17
- * dependent root for an epoch shifts (e.g. after a reorg) — detected by comparing the cached
18
- * `dependentRoot` reported by `BlockDutiesService` against the one we last submitted under.
19
- *
20
- * Proposers should broadcast their preferences before the fork so the proposer preference caches
21
- * of beacon nodes and builders are warm for the first Gloas slots. We start submitting
22
- * as soon as a duty's proposal slot is in Gloas, which is up to `SUBMIT_BEFORE_PROPOSAL_SLOTS`
23
- * before the fork, so only the first few Gloas slots are affected by this pre-fork submission.
24
- */
25
- export class ProposerPreferencesService {
26
- config;
27
- logger;
28
- api;
29
- validatorStore;
30
- blockDutiesService;
31
- submitted = new Map();
32
- activeScheduledGasLimit;
33
- constructor(config, logger, api, clock, validatorStore, blockDutiesService, _metrics) {
34
- this.config = config;
35
- this.logger = logger;
36
- this.api = api;
37
- this.validatorStore = validatorStore;
38
- this.blockDutiesService = blockDutiesService;
39
- clock.runEverySlot(this.runProposerPreferencesTask);
40
- clock.runEveryEpoch(this.runEveryEpochTask);
41
- }
42
- runProposerPreferencesTask = async (slot) => {
43
- // Start running once the submission window (`slot + SUBMIT_BEFORE_PROPOSAL_SLOTS`) reaches
44
- // Gloas, i.e. already in the epoch before the fork. This allows builders to prepare and
45
- // submit bids for the first Gloas slots.
46
- if (!isForkPostGloas(this.config.getForkName(slot + SUBMIT_BEFORE_PROPOSAL_SLOTS))) {
47
- return;
48
- }
49
- const currentEpoch = computeEpochAtSlot(slot);
50
- const batch = [];
51
- // Track which `(submission, slot)` pairs are pending an API submission so we can mark
52
- // them only after the network call succeeds. Marking before would silently drop a
53
- // preference on transient API failure (no retry until dependent_root shifts).
54
- const pending = [];
55
- for (const epoch of [currentEpoch, currentEpoch + 1]) {
56
- const dutiesAtEpoch = this.blockDutiesService.getProposersAtEpoch(epoch);
57
- if (!dutiesAtEpoch)
58
- continue;
59
- // Reset submission tracking if the dependent root for this epoch has shifted
60
- // (e.g. due to a reorg). Any previously-submitted preferences are now stale.
61
- let submission = this.submitted.get(epoch);
62
- if (submission === undefined || submission.dependentRoot !== dutiesAtEpoch.dependentRoot) {
63
- if (submission !== undefined) {
64
- this.logger.info("Proposer-shuffling dependent root shifted; resubmitting preferences", {
65
- epoch,
66
- priorDependentRoot: submission.dependentRoot,
67
- dependentRoot: dutiesAtEpoch.dependentRoot,
68
- });
69
- }
70
- submission = { dependentRoot: dutiesAtEpoch.dependentRoot, slots: new Set() };
71
- this.submitted.set(epoch, submission);
72
- }
73
- const dependentRootBytes = fromHex(dutiesAtEpoch.dependentRoot);
74
- for (const duty of dutiesAtEpoch.data) {
75
- if (duty.slot <= slot)
76
- continue;
77
- if (duty.slot > slot + SUBMIT_BEFORE_PROPOSAL_SLOTS)
78
- continue;
79
- if (!isForkPostGloas(this.config.getForkName(duty.slot)))
80
- continue;
81
- if (submission.slots.has(duty.slot))
82
- continue;
83
- try {
84
- const pubkeyHex = toPubkeyHex(duty.pubkey);
85
- const signed = await this.validatorStore.signProposerPreferences(duty, dependentRootBytes, this.validatorStore.getFeeRecipient(pubkeyHex), this.validatorStore.getGasLimit(pubkeyHex, duty.slot, this.logger), slot);
86
- batch.push(signed);
87
- pending.push({ submission, slot: duty.slot });
88
- }
89
- catch (e) {
90
- this.logger.error("Error signing proposer preferences", { slot: duty.slot, validatorIndex: duty.validatorIndex }, e);
91
- }
92
- }
93
- }
94
- if (batch.length === 0) {
95
- return;
96
- }
97
- try {
98
- (await this.api.validator.submitProposerPreferences({ signedProposerPreferences: batch })).assertOk();
99
- // Only mark as submitted after the API call succeeds; a thrown error leaves the
100
- // slot eligible for retry on the next tick.
101
- for (const { submission, slot: submittedSlot } of pending) {
102
- submission.slots.add(submittedSlot);
103
- }
104
- this.logger.debug("Submitted signed proposer preferences", { count: batch.length });
105
- }
106
- catch (e) {
107
- this.logger.error("Error submitting signed proposer preferences", { count: batch.length }, e);
108
- }
109
- };
110
- runEveryEpochTask = async (epoch) => {
111
- const scheduledGasLimit = this.config.getScheduledGasLimit(epoch);
112
- if (scheduledGasLimit !== undefined && scheduledGasLimit !== this.activeScheduledGasLimit) {
113
- const configuredDefaultGasLimit = this.validatorStore.getConfiguredDefaultGasLimit();
114
- this.logger.info("Gas limit schedule active", {
115
- epoch,
116
- recommendedGasLimit: scheduledGasLimit,
117
- effectiveDefaultGasLimit: configuredDefaultGasLimit ?? scheduledGasLimit,
118
- defaultGasLimitSource: configuredDefaultGasLimit === undefined ? "schedule" : "operator",
119
- });
120
- this.activeScheduledGasLimit = scheduledGasLimit;
121
- }
122
- // Drop tracking for past epochs; only currentEpoch and currentEpoch + 1 are ever processed.
123
- for (const trackedEpoch of this.submitted.keys()) {
124
- if (trackedEpoch < epoch) {
125
- this.submitted.delete(trackedEpoch);
126
- }
127
- }
128
- };
129
- }
130
- //# sourceMappingURL=proposerPreferences.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proposerPreferences.js","sourceRoot":"","sources":["../../src/services/proposerPreferences.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAE,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAS,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAMrD;;;;;;;;GAQG;AACH,MAAM,4BAA4B,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;AAKrE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,0BAA0B;IAKlB,MAAM;IACN,MAAM;IACN,GAAG;IAEH,cAAc;IACd,kBAAkB;IATpB,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;IACxD,uBAAuB,CAAqB;IAEpD,YACmB,MAAuB,EACvB,MAAgB,EAChB,GAAc,EAC/B,KAAa,EACI,cAA8B,EAC9B,kBAAsC,EACvD,QAAwB;sBANP,MAAM;sBACN,MAAM;mBACN,GAAG;8BAEH,cAAc;kCACd,kBAAkB;QAGnC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACpD,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC9C,C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