@lodestar/validator 1.50.0-dev.db953a4f93 → 1.50.0-dev.dff4197219

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.
Files changed (34) hide show
  1. package/lib/services/block.d.ts.map +1 -1
  2. package/lib/services/block.js +14 -3
  3. package/lib/services/block.js.map +1 -1
  4. package/lib/services/{proposerPreferences.d.ts → proposalPreferences.d.ts} +16 -7
  5. package/lib/services/proposalPreferences.d.ts.map +1 -0
  6. package/lib/services/proposalPreferences.js +205 -0
  7. package/lib/services/proposalPreferences.js.map +1 -0
  8. package/lib/services/ptc.d.ts.map +1 -1
  9. package/lib/services/ptc.js +11 -2
  10. package/lib/services/ptc.js.map +1 -1
  11. package/lib/services/ptcDuties.js +2 -2
  12. package/lib/services/ptcDuties.js.map +1 -1
  13. package/lib/services/validatorStore.d.ts.map +1 -1
  14. package/lib/services/validatorStore.js +4 -9
  15. package/lib/services/validatorStore.js.map +1 -1
  16. package/lib/validator.d.ts.map +1 -1
  17. package/lib/validator.js +2 -4
  18. package/lib/validator.js.map +1 -1
  19. package/package.json +13 -13
  20. package/src/services/block.ts +18 -4
  21. package/src/services/proposalPreferences.ts +247 -0
  22. package/src/services/ptc.ts +12 -3
  23. package/src/services/ptcDuties.ts +2 -2
  24. package/src/services/validatorStore.ts +4 -8
  25. package/src/validator.ts +2 -4
  26. package/lib/services/builderPreferences.d.ts +0 -27
  27. package/lib/services/builderPreferences.d.ts.map +0 -1
  28. package/lib/services/builderPreferences.js +0 -127
  29. package/lib/services/builderPreferences.js.map +0 -1
  30. package/lib/services/proposerPreferences.d.ts.map +0 -1
  31. package/lib/services/proposerPreferences.js +0 -130
  32. package/lib/services/proposerPreferences.js.map +0 -1
  33. package/src/services/builderPreferences.ts +0 -142
  34. package/src/services/proposerPreferences.ts +0 -154
@@ -95,8 +95,8 @@ export class PtcDutiesService {
95
95
  }
96
96
 
97
97
  private runDutiesTasks = async (epoch: Epoch): Promise<void> => {
98
- const nextEpoch = epoch + 1;
99
- if (!isForkPostGloas(this.config.getForkName(nextEpoch * SLOTS_PER_EPOCH))) {
98
+ // PTC duties of the first Gloas epoch only exist after the fork upgrade, they can't be polled one epoch ahead
99
+ if (!isForkPostGloas(this.config.getForkName(epoch * SLOTS_PER_EPOCH))) {
100
100
  return;
101
101
  }
102
102
 
@@ -359,14 +359,10 @@ export class ValidatorStore {
359
359
  }
360
360
 
361
361
  // Post-Gloas block production uses standard builder boost factor. Need to normalize the
362
- // gloas-deprecated "builderonly" and "executiononly" to the gloas fallback "builderalways"
363
- // and "executionalways" equivalent before deriving the boost factor.
364
- if (isPostGloas) {
365
- if (selection === routes.validator.BuilderSelection.BuilderOnly) {
366
- selection = routes.validator.BuilderSelection.BuilderAlways;
367
- } else if (selection === routes.validator.BuilderSelection.ExecutionOnly) {
368
- selection = routes.validator.BuilderSelection.ExecutionAlways;
369
- }
362
+ // gloas-deprecated "builderonly" to the gloas fallback "builderalways" equivalent before
363
+ // deriving the boost factor.
364
+ if (isPostGloas && selection === routes.validator.BuilderSelection.BuilderOnly) {
365
+ selection = routes.validator.BuilderSelection.BuilderAlways;
370
366
  }
371
367
 
372
368
  const boostFactor = getBuilderBoostFactor(
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;AAEtE,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAM5C;;;;GAIG;AACH,MAAM,4BAA4B,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;AAKrE;;;;;;;;GAQG;AACH,MAAM,OAAO,yBAAyB;IAIjB,MAAM;IACN,MAAM;IACN,GAAG;IAEH,cAAc;IACd,kBAAkB;IARpB,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEhE,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,yBAAyB,CAAC,CAAC;IACrD,CAAC;IAEO,yBAAyB,GAAG,KAAK,EAAE,IAAU,EAAiB,EAAE;QACtE,2FAA2F;QAC3F,wFAAwF;QACxF,yCAAyC;QACzC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC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M,EAAC,EAAE,CAAU,CAAC,CAAC;QAChG,CAAC;IACH,CAAC,CAAC;CACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"proposerPreferences.d.ts","sourceRoot":"","sources":["../../src/services/proposerPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,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;AAgBnD;;;;;;;;;;GAUG;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 });
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,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,EAAiB,EAAE;QAChE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAClE,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC1F,MAAM,yBAAyB,GAAG,IAAI,CAAC,cAAc,CAAC,4BAA4B,EAAE,CAAC;YACrF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE;gBAC5C,KAAK;gBACL,mBAAmB,EAAE,iBAAiB;gBACtC,wBAAwB,EAAE,yBAAyB,IAAI,iBAAiB;gBACxE,qBAAqB,EAAE,yBAAyB,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU;aACzF,CAAC,CAAC;YACH,IAAI,CAAC,uBAAuB,GAAG,iBAAiB,CAAC;QACnD,CAAC;QAED,4FAA4F;QAC5F,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;YACjD,IAAI,YAAY,GAAG,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC,CAAC;CACH"}
@@ -1,142 +0,0 @@
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} from "@lodestar/types";
6
- import {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 a proposer's builder preferences this many slots before the proposal slot.
14
- * Same pacing as `ProposerPreferencesService`, builders must have the preferences
15
- * before the bid request arrives at proposal time.
16
- */
17
- const SUBMIT_BEFORE_PROPOSAL_SLOTS = Math.floor(SLOTS_PER_EPOCH / 4);
18
-
19
- /** Per-epoch tracking of preferences already submitted under the current dependent_root. */
20
- type SubmittedAtEpoch = {dependentRoot: RootHex; slots: Set<Slot>};
21
-
22
- /**
23
- * Signs and submits builder preferences for any local validator that will propose within the
24
- * next `SUBMIT_BEFORE_PROPOSAL_SLOTS` and has external builders configured. Signing the request
25
- * auths here also pre-fills the auth cache used at proposal time.
26
- *
27
- * The beacon node submits each entry to the builder at the entry's url. Re-submits automatically
28
- * when the proposer dependent root for an epoch shifts (e.g. after a reorg) since the proposer
29
- * for a slot may have changed.
30
- */
31
- export class BuilderPreferencesService {
32
- private readonly submitted = new Map<Epoch, SubmittedAtEpoch>();
33
-
34
- constructor(
35
- private readonly config: ChainForkConfig,
36
- private readonly logger: LoggerVc,
37
- private readonly api: ApiClient,
38
- clock: IClock,
39
- private readonly validatorStore: ValidatorStore,
40
- private readonly blockDutiesService: BlockDutiesService,
41
- _metrics: Metrics | null
42
- ) {
43
- clock.runEverySlot(this.runBuilderPreferencesTask);
44
- }
45
-
46
- private runBuilderPreferencesTask = async (slot: Slot): Promise<void> => {
47
- // Start running once the submission window (`slot + SUBMIT_BEFORE_PROPOSAL_SLOTS`) reaches
48
- // Gloas, i.e. already in the epoch before the fork. This allows builders to prepare and
49
- // submit bids for the first Gloas slots.
50
- if (!isForkPostGloas(this.config.getForkName(slot + SUBMIT_BEFORE_PROPOSAL_SLOTS))) {
51
- return;
52
- }
53
-
54
- const currentEpoch = computeEpochAtSlot(slot);
55
- const entries: routes.validator.BuilderPreferencesEntry[] = [];
56
- // Track which `(submission, slot)` pairs are pending an API submission so we can mark
57
- // them only after the network call succeeds. Marking before would silently drop a
58
- // preference on transient API failure (no retry until dependent_root shifts).
59
- const pending: {submission: SubmittedAtEpoch; slot: Slot}[] = [];
60
-
61
- for (const epoch of [currentEpoch, currentEpoch + 1]) {
62
- const dutiesAtEpoch = this.blockDutiesService.getProposersAtEpoch(epoch);
63
- if (!dutiesAtEpoch) continue;
64
-
65
- // Reset submission tracking if the dependent root for this epoch has shifted
66
- // (e.g. due to a reorg). The proposer for a slot may have changed.
67
- let submission = this.submitted.get(epoch);
68
- if (submission === undefined || submission.dependentRoot !== dutiesAtEpoch.dependentRoot) {
69
- if (submission !== undefined) {
70
- this.logger.info("Proposer-shuffling dependent root shifted; resubmitting builder preferences", {
71
- epoch,
72
- priorDependentRoot: submission.dependentRoot,
73
- dependentRoot: dutiesAtEpoch.dependentRoot,
74
- });
75
- }
76
- submission = {dependentRoot: dutiesAtEpoch.dependentRoot, slots: new Set()};
77
- this.submitted.set(epoch, submission);
78
- }
79
-
80
- for (const duty of dutiesAtEpoch.data) {
81
- if (duty.slot <= slot) continue;
82
- if (duty.slot > slot + SUBMIT_BEFORE_PROPOSAL_SLOTS) continue;
83
- if (!isForkPostGloas(this.config.getForkName(duty.slot))) continue;
84
- if (submission.slots.has(duty.slot)) continue;
85
-
86
- const pubkeyHex = toPubkeyHex(duty.pubkey);
87
- const {selection} = this.validatorStore.getBuilderSelectionParams(pubkeyHex, duty.slot);
88
- if (selection === routes.validator.BuilderSelection.ExecutionOnly) continue;
89
-
90
- const builderEntries = this.validatorStore.getResolvedBuilderEntries(pubkeyHex);
91
- if (builderEntries.length === 0) continue;
92
-
93
- try {
94
- // Collect entries per duty and only add them to the batch if signing
95
- // succeeded for all builders, else the duty is retried on the next tick
96
- const dutyEntries: routes.validator.BuilderPreferencesEntry[] = [];
97
- for (const entry of builderEntries) {
98
- const auth = await this.validatorStore.getBuilderRequestAuth(duty.pubkey, entry.authData, duty.slot, slot);
99
- dutyEntries.push({
100
- proposerPubkey: duty.pubkey,
101
- url: new TextEncoder().encode(entry.url),
102
- auth,
103
- maxExecutionPayment: entry.maxExecutionPayment,
104
- });
105
- }
106
- entries.push(...dutyEntries);
107
- pending.push({submission, slot: duty.slot});
108
- } catch (e) {
109
- this.logger.error(
110
- "Error signing builder preferences",
111
- {slot: duty.slot, validatorIndex: duty.validatorIndex},
112
- e as Error
113
- );
114
- }
115
- }
116
- }
117
-
118
- // Prune tracking for past epochs
119
- for (const epoch of this.submitted.keys()) {
120
- if (epoch < currentEpoch) {
121
- this.submitted.delete(epoch);
122
- }
123
- }
124
-
125
- if (entries.length === 0) {
126
- return;
127
- }
128
-
129
- try {
130
- (await this.api.validator.submitBuilderPreferences({builderPreferences: entries})).assertOk();
131
- // Only mark as submitted after the API call succeeds; a thrown error, including per-entry
132
- // failures reported by index, leaves all slots eligible for retry on the next tick.
133
- // Re-submitting preferences a builder already accepted is harmless.
134
- for (const {submission, slot: submittedSlot} of pending) {
135
- submission.slots.add(submittedSlot);
136
- }
137
- this.logger.debug("Submitted builder preferences", {count: entries.length});
138
- } catch (e) {
139
- this.logger.warn("Error submitting builder preferences", {count: entries.length}, e as Error);
140
- }
141
- };
142
- }