@lodestar/validator 1.51.0-dev.2593063a82 → 1.51.0-dev.2b933d3b9a
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.
- package/lib/services/chainHeaderTracker.d.ts.map +1 -1
- package/lib/services/chainHeaderTracker.js +6 -1
- package/lib/services/chainHeaderTracker.js.map +1 -1
- package/lib/services/emitter.d.ts +10 -1
- package/lib/services/emitter.d.ts.map +1 -1
- package/lib/services/emitter.js +4 -0
- package/lib/services/emitter.js.map +1 -1
- package/lib/services/inclusionList.d.ts +25 -0
- package/lib/services/inclusionList.d.ts.map +1 -0
- package/lib/services/inclusionList.js +101 -0
- package/lib/services/inclusionList.js.map +1 -0
- package/lib/services/inclusionListDuties.d.ts +59 -0
- package/lib/services/inclusionListDuties.d.ts.map +1 -0
- package/lib/services/inclusionListDuties.js +252 -0
- package/lib/services/inclusionListDuties.js.map +1 -0
- package/lib/services/validatorStore.d.ts +7 -1
- package/lib/services/validatorStore.d.ts.map +1 -1
- package/lib/services/validatorStore.js +27 -2
- package/lib/services/validatorStore.js.map +1 -1
- package/lib/slashingProtection/attestation/index.d.ts +1 -0
- package/lib/slashingProtection/attestation/index.d.ts.map +1 -1
- package/lib/slashingProtection/attestation/index.js +77 -44
- package/lib/slashingProtection/attestation/index.js.map +1 -1
- package/lib/slashingProtection/index.d.ts +2 -0
- package/lib/slashingProtection/index.d.ts.map +1 -1
- package/lib/slashingProtection/index.js +48 -5
- package/lib/slashingProtection/index.js.map +1 -1
- package/lib/util/externalSignerClient.d.ts +6 -2
- package/lib/util/externalSignerClient.d.ts.map +1 -1
- package/lib/util/externalSignerClient.js +4 -0
- package/lib/util/externalSignerClient.js.map +1 -1
- package/lib/validator.d.ts +4 -1
- package/lib/validator.d.ts.map +1 -1
- package/lib/validator.js +11 -4
- package/lib/validator.js.map +1 -1
- package/package.json +12 -12
- package/src/services/chainHeaderTracker.ts +8 -1
- package/src/services/emitter.ts +10 -0
- package/src/services/inclusionList.ts +140 -0
- package/src/services/inclusionListDuties.ts +306 -0
- package/src/services/validatorStore.ts +41 -2
- package/src/slashingProtection/attestation/index.ts +81 -46
- package/src/slashingProtection/index.ts +50 -6
- package/src/util/externalSignerClient.ts +8 -1
- package/src/validator.ts +31 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chainHeaderTracker.d.ts","sourceRoot":"","sources":["../../src/services/chainHeaderTracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,MAAM,EAAU,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAiB,qBAAqB,EAAC,MAAM,cAAc,CAAC;AAInE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,OAAO,CAAC;IACd,yBAAyB,EAAE,OAAO,CAAC;IACnC,wBAAwB,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,IAAI,CAAC;IACX,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1D;;GAEG;AACH,qBAAa,kBAAkB;IAO3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAT1B,OAAO,CAAC,aAAa,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9B,CAAC;AAEF,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1D;;GAEG;AACH,qBAAa,kBAAkB;IAO3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAT1B,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,4BAA4B,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAoB;IAExC,YACmB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,qBAAqB,EAC7C;IAEJ,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAuB/B;IAED,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAE3C;IAED,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI,CAQpD;IAED,YAAY,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAEjC;IAED,OAAO,CAAC,OAAO,CA4Cb;CACH"}
|
|
@@ -27,7 +27,7 @@ export class ChainHeaderTracker {
|
|
|
27
27
|
// We wait until the gloas fork is configured to avoid breaking
|
|
28
28
|
// connections with pre-gloas beacon nodes
|
|
29
29
|
if (this.config.GLOAS_FORK_EPOCH !== Infinity) {
|
|
30
|
-
topics.push(EventType.executionPayloadAvailable);
|
|
30
|
+
topics.push(EventType.executionPayloadAvailable, EventType.executionPayload);
|
|
31
31
|
}
|
|
32
32
|
this.api.events
|
|
33
33
|
.eventstream({
|
|
@@ -89,6 +89,11 @@ export class ChainHeaderTracker {
|
|
|
89
89
|
blockRoot: event.message.blockRoot,
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
+
if (event.type === EventType.executionPayload) {
|
|
93
|
+
const { slot, blockRoot } = event.message;
|
|
94
|
+
this.emitter.emit(ValidatorEvent.executionPayloadImported, { slot, blockRoot });
|
|
95
|
+
this.logger.verbose("Found execution payload imported", { slot, blockRoot });
|
|
96
|
+
}
|
|
92
97
|
};
|
|
93
98
|
}
|
|
94
99
|
//# sourceMappingURL=chainHeaderTracker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chainHeaderTracker.js","sourceRoot":"","sources":["../../src/services/chainHeaderTracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAC,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAS,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAwB,MAAM,cAAc,CAAC;AAEnE,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,MAAM,CAAC;AAqBlC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAOV,MAAM;IACN,MAAM;IACN,GAAG;IACH,OAAO;IATlB,aAAa,GAAS,YAAY,CAAC;IACnC,aAAa,GAAgB,IAAI,CAAC;IAClC,4BAA4B,GAAG,KAAK,CAAC;IAC5B,GAAG,GAAiB,EAAE,CAAC;IAExC,YACmB,MAAoB,EACpB,MAAc,EACd,GAAc,EACd,OAA8B;sBAH9B,MAAM;sBACN,MAAM;mBACN,GAAG;uBACH,OAAO;IACvB,CAAC;IAEJ,KAAK,CAAC,MAAmB;QACvB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;QAEvD,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,+DAA+D;QAC/D,0CAA0C;QAC1C,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI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I,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,wBAAwB,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC,CAAC;YAE9E,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kCAAkC,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC,CAAC;CACH"}
|
|
@@ -10,15 +10,24 @@ export declare enum ValidatorEvent {
|
|
|
10
10
|
/**
|
|
11
11
|
* This event signals that an execution payload and blobs are available for payload attestation.
|
|
12
12
|
*/
|
|
13
|
-
executionPayloadAvailable = "executionPayloadAvailable"
|
|
13
|
+
executionPayloadAvailable = "executionPayloadAvailable",
|
|
14
|
+
/**
|
|
15
|
+
* This event signals that an execution payload was verified by the execution client and imported to fork choice.
|
|
16
|
+
*/
|
|
17
|
+
executionPayloadImported = "executionPayloadImported"
|
|
14
18
|
}
|
|
15
19
|
export type ExecutionPayloadAvailableEventData = {
|
|
16
20
|
slot: Slot;
|
|
17
21
|
blockRoot: string;
|
|
18
22
|
};
|
|
23
|
+
export type ExecutionPayloadImportedEventData = {
|
|
24
|
+
slot: Slot;
|
|
25
|
+
blockRoot: string;
|
|
26
|
+
};
|
|
19
27
|
export type ValidatorEvents = {
|
|
20
28
|
[ValidatorEvent.chainHead]: (head: HeadEventData) => void;
|
|
21
29
|
[ValidatorEvent.executionPayloadAvailable]: (payload: ExecutionPayloadAvailableEventData) => void;
|
|
30
|
+
[ValidatorEvent.executionPayloadImported]: (payload: ExecutionPayloadImportedEventData) => void;
|
|
22
31
|
};
|
|
23
32
|
declare const ValidatorEventEmitter_base: new () => StrictEventEmitter<EventEmitter, ValidatorEvents>;
|
|
24
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/services/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EA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sB,SAAQ,0BAEzC;IACA;;OAEG;IACG,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBhD;CACF"}
|
package/lib/services/emitter.js
CHANGED
|
@@ -9,6 +9,10 @@ export var ValidatorEvent;
|
|
|
9
9
|
* This event signals that an execution payload and blobs are available for payload attestation.
|
|
10
10
|
*/
|
|
11
11
|
ValidatorEvent["executionPayloadAvailable"] = "executionPayloadAvailable";
|
|
12
|
+
/**
|
|
13
|
+
* This event signals that an execution payload was verified by the execution client and imported to fork choice.
|
|
14
|
+
*/
|
|
15
|
+
ValidatorEvent["executionPayloadImported"] = "executionPayloadImported";
|
|
12
16
|
})(ValidatorEvent || (ValidatorEvent = {}));
|
|
13
17
|
/**
|
|
14
18
|
* Emit important validator events.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/services/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAKzC,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/services/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAKzC,MAAM,CAAN,IAAY,cAaX;AAbD,WAAY,cAAc;IACxB;;OAEG;IACH,yCAAuB,CAAA;IACvB;;OAEG;IACH,yEAAuD,CAAA;IACvD;;OAEG;IACH,uEAAqD,CAAA;AACvD,CAAC,EAbW,cAAc,KAAd,cAAc,QAazB;AAkBD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAS,YAE1C;IACA;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,IAAU;QAC/B,IAAI,YAA2C,CAAC;QAEhD,MAAM,MAAM,GAAG,GAAS,EAAE;YACxB,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACnD,CAAC,CAAC;QAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,YAAY,GAAG,CAAC,IAAmB,EAAQ,EAAE;gBAC3C,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;oBACtB,MAAM,EAAE,CAAC;oBACT,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC;YACF,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApiClient } from "@lodestar/api";
|
|
2
|
+
import { ChainForkConfig } from "@lodestar/config";
|
|
3
|
+
import { IClock } from "@lodestar/state-transition";
|
|
4
|
+
import { PubkeyHex } from "../types.js";
|
|
5
|
+
import { LoggerVc } from "../util/index.js";
|
|
6
|
+
import { ChainHeaderTracker } from "./chainHeaderTracker.js";
|
|
7
|
+
import { ValidatorEventEmitter } from "./emitter.js";
|
|
8
|
+
import { SyncingStatusTracker } from "./syncingStatusTracker.js";
|
|
9
|
+
import { ValidatorStore } from "./validatorStore.js";
|
|
10
|
+
export declare class InclusionListService {
|
|
11
|
+
private readonly config;
|
|
12
|
+
private readonly logger;
|
|
13
|
+
private readonly api;
|
|
14
|
+
private readonly clock;
|
|
15
|
+
private readonly validatorStore;
|
|
16
|
+
private readonly emitter;
|
|
17
|
+
private readonly dutiesService;
|
|
18
|
+
constructor(config: ChainForkConfig, logger: LoggerVc, api: ApiClient, clock: IClock, validatorStore: ValidatorStore, chainHeadTracker: ChainHeaderTracker, syncingStatusTracker: SyncingStatusTracker, emitter: ValidatorEventEmitter);
|
|
19
|
+
removeDutiesForKey(pubkey: PubkeyHex): void;
|
|
20
|
+
private runInclusionListTasks;
|
|
21
|
+
private produceInclusionList;
|
|
22
|
+
/** One inclusion list per slot, signed by every validator on duty */
|
|
23
|
+
private signAndPublishInclusionList;
|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EY,oBAAoB;IAIlC,qEAAqE;YACvD,2BAA2B;CA4C1C"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { sleep } from "@lodestar/utils";
|
|
2
|
+
import { ValidatorEvent } from "./emitter.js";
|
|
3
|
+
import { InclusionListDutiesService } from "./inclusionListDuties.js";
|
|
4
|
+
export class InclusionListService {
|
|
5
|
+
config;
|
|
6
|
+
logger;
|
|
7
|
+
api;
|
|
8
|
+
clock;
|
|
9
|
+
validatorStore;
|
|
10
|
+
emitter;
|
|
11
|
+
dutiesService;
|
|
12
|
+
constructor(config, logger, api, clock, validatorStore, chainHeadTracker, syncingStatusTracker, emitter) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.api = api;
|
|
16
|
+
this.clock = clock;
|
|
17
|
+
this.validatorStore = validatorStore;
|
|
18
|
+
this.emitter = emitter;
|
|
19
|
+
this.dutiesService = new InclusionListDutiesService(config, logger, api, clock, validatorStore, chainHeadTracker, syncingStatusTracker);
|
|
20
|
+
// At most every slot, check existing duties from InclusionListDutiesService and run tasks
|
|
21
|
+
clock.runEverySlot(this.runInclusionListTasks);
|
|
22
|
+
}
|
|
23
|
+
removeDutiesForKey(pubkey) {
|
|
24
|
+
this.dutiesService.removeDutiesForKey(pubkey);
|
|
25
|
+
}
|
|
26
|
+
runInclusionListTasks = async (slot, signal) => {
|
|
27
|
+
if (this.dutiesService.getDutiesAtSlot(slot).length === 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// Spec: broadcast by get_inclusion_list_due_ms(). Wait until the beacon node imported the slot's payload,
|
|
31
|
+
// emitted once the execution client verified it and the fork choice update was queued, so the list is built
|
|
32
|
+
// from a mempool without that payload's transactions. Fall back to the deadline for empty or late slots.
|
|
33
|
+
const dueMs = Math.max(0, this.config.getInclusionListDueMs(this.config.getForkName(slot)) - this.clock.msFromSlot(slot));
|
|
34
|
+
// Publish ahead of the deadline so the list still counts as timely for peers
|
|
35
|
+
const beforeDueMs = 1000;
|
|
36
|
+
let resolvePayloadImported = () => { };
|
|
37
|
+
const payloadImported = new Promise((resolve) => {
|
|
38
|
+
resolvePayloadImported = resolve;
|
|
39
|
+
});
|
|
40
|
+
const onPayloadImported = (payload) => {
|
|
41
|
+
if (payload.slot === slot) {
|
|
42
|
+
resolvePayloadImported();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this.emitter.on(ValidatorEvent.executionPayloadImported, onPayloadImported);
|
|
46
|
+
try {
|
|
47
|
+
await Promise.race([sleep(Math.max(0, dueMs - beforeDueMs), signal), payloadImported]);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
this.emitter.off(ValidatorEvent.executionPayloadImported, onPayloadImported);
|
|
51
|
+
}
|
|
52
|
+
const inclusionListTransactions = await this.produceInclusionList(slot);
|
|
53
|
+
// Empty lists are ignored by gossip validation (consensus-specs#5576)
|
|
54
|
+
if (inclusionListTransactions.length === 0) {
|
|
55
|
+
this.logger.debug("Produced inclusion list has no transactions, skipping publish", { slot });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// Read the duties after the wait, a reorg handled meanwhile may have changed the dependent root
|
|
59
|
+
const duties = this.dutiesService.getDutiesAtSlot(slot);
|
|
60
|
+
if (duties.length === 0) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await this.signAndPublishInclusionList(inclusionListTransactions, duties);
|
|
64
|
+
};
|
|
65
|
+
async produceInclusionList(slot) {
|
|
66
|
+
return (await this.api.validator.produceInclusionList({ slot })).value();
|
|
67
|
+
}
|
|
68
|
+
/** One inclusion list per slot, signed by every validator on duty */
|
|
69
|
+
async signAndPublishInclusionList(inclusionListTransactions, duties) {
|
|
70
|
+
const signedInclusionLists = [];
|
|
71
|
+
await Promise.all(duties.map(async (duty) => {
|
|
72
|
+
const inclusionList = {
|
|
73
|
+
slot: duty.slot,
|
|
74
|
+
validatorIndex: duty.validatorIndex,
|
|
75
|
+
dependentRoot: duty.dependentRoot,
|
|
76
|
+
transactions: inclusionListTransactions,
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
signedInclusionLists.push(await this.validatorStore.signInclusionList(duty, inclusionList));
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
this.logger.error("Error signing inclusion list", { slot: duty.slot, validatorIndex: duty.validatorIndex }, e);
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
for (const signedInclusionList of signedInclusionLists) {
|
|
86
|
+
const { slot, validatorIndex, transactions } = signedInclusionList.message;
|
|
87
|
+
try {
|
|
88
|
+
(await this.api.validator.publishInclusionList({ signedInclusionList })).assertOk();
|
|
89
|
+
this.logger.info("Published inclusionList", {
|
|
90
|
+
slot,
|
|
91
|
+
validatorIndex,
|
|
92
|
+
transactions: transactions.length,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
this.logger.error("Error publishing inclusionList", { slot, validatorIndex, transactions: transactions.length }, e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=inclusionList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inclusionList.js","sourceRoot":"","sources":["../../src/services/inclusionList.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAItC,OAAO,EAAoC,cAAc,EAAwB,MAAM,cAAc,CAAC;AACtG,OAAO,EAAC,0BAA0B,EAAC,MAAM,0BAA0B,CAAC;AAIpE,MAAM,OAAO,oBAAoB;IAIZ,MAAM;IACN,MAAM;IACN,GAAG;IACH,KAAK;IACL,cAAc;IAGd,OAAO;IAVT,aAAa,CAA6B;IAE3D,YACmB,MAAuB,EACvB,MAAgB,EAChB,GAAc,EACd,KAAa,EACb,cAA8B,EAC/C,gBAAoC,EACpC,oBAA0C,EACzB,OAA8B;sBAP9B,MAAM;sBACN,MA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AC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ApiClient, routes } from "@lodestar/api";
|
|
2
|
+
import { ChainForkConfig } from "@lodestar/config";
|
|
3
|
+
import { IClock } from "@lodestar/state-transition";
|
|
4
|
+
import { Slot } from "@lodestar/types";
|
|
5
|
+
import { PubkeyHex } from "../types.js";
|
|
6
|
+
import { LoggerVc } from "../util/index.js";
|
|
7
|
+
import { ChainHeaderTracker } from "./chainHeaderTracker.js";
|
|
8
|
+
import { SyncingStatusTracker } from "./syncingStatusTracker.js";
|
|
9
|
+
import { ValidatorStore } from "./validatorStore.js";
|
|
10
|
+
type InclusionListDuty = routes.validator.InclusionListDuty;
|
|
11
|
+
/**
|
|
12
|
+
* Similar to AttestationDutiesService but
|
|
13
|
+
* - No generating and caching selection proof
|
|
14
|
+
* - No handling and maintaining subnet subscription
|
|
15
|
+
*/
|
|
16
|
+
export declare class InclusionListDutiesService {
|
|
17
|
+
private readonly config;
|
|
18
|
+
private readonly logger;
|
|
19
|
+
private readonly api;
|
|
20
|
+
private clock;
|
|
21
|
+
private readonly validatorStore;
|
|
22
|
+
/** Maps a validator index to its duty for each epoch */
|
|
23
|
+
private readonly dutiesByIndexByEpoch;
|
|
24
|
+
/**
|
|
25
|
+
* We may receive new dependentRoot of an epoch but it's not the last slot of epoch
|
|
26
|
+
* so we have to wait for getting close to the next epoch to redownload new inclusionListDuties.
|
|
27
|
+
*/
|
|
28
|
+
private readonly pendingDependentRootByEpoch;
|
|
29
|
+
constructor(config: ChainForkConfig, logger: LoggerVc, api: ApiClient, clock: IClock, validatorStore: ValidatorStore, chainHeadTracker: ChainHeaderTracker, syncingStatusTracker: SyncingStatusTracker);
|
|
30
|
+
removeDutiesForKey(pubkey: PubkeyHex): void;
|
|
31
|
+
/** Returns all `ValidatorDuty` for the given `slot` */
|
|
32
|
+
getDutiesAtSlot(slot: Slot): InclusionListDuty[];
|
|
33
|
+
/**
|
|
34
|
+
* If a reorg dependent root comes at a slot other than last slot of epoch
|
|
35
|
+
* just update this.pendingDependentRootByEpoch() and process here
|
|
36
|
+
*/
|
|
37
|
+
private prepareForNextEpoch;
|
|
38
|
+
private runDutiesTasks;
|
|
39
|
+
private pollInclusionListCommittee;
|
|
40
|
+
/**
|
|
41
|
+
* For the given `indexArr`, download the duties for the given `epoch` and store them in duties.
|
|
42
|
+
*/
|
|
43
|
+
private pollInclusionListCommitteeForEpoch;
|
|
44
|
+
private handleInclusionListDutiesReorg;
|
|
45
|
+
/**
|
|
46
|
+
* inclusion list duties may be reorged due to 2 scenarios:
|
|
47
|
+
* 1. node is syncing (for nextEpoch duties)
|
|
48
|
+
* 2. node is reorged
|
|
49
|
+
* previousDutyDependentRoot = get_block_root_at_slot(state, compute_start_slot_at_epoch(epoch - 1) - 1)
|
|
50
|
+
* => dependent root of current epoch
|
|
51
|
+
* currentDutyDependentRoot = get_block_root_at_slot(state, compute_start_slot_at_epoch(epoch) - 1)
|
|
52
|
+
* => dependent root of next epoch
|
|
53
|
+
*/
|
|
54
|
+
private onNewHead;
|
|
55
|
+
/** Run once per epoch to prune duties map */
|
|
56
|
+
private pruneOldDuties;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=inclusionListDuties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inclusionListDuties.d.ts","sourceRoot":"","sources":["../../src/services/inclusionListDuties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,MAAM,EAAyC,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAiB,IAAI,EAAiB,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC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otOfEpoch } from "@lodestar/state-transition";
|
|
3
|
+
import { sleep, toPubkeyHex } from "@lodestar/utils";
|
|
4
|
+
/** Only retain `HISTORICAL_DUTIES_EPOCHS` duties prior to the current epoch. */
|
|
5
|
+
const HISTORICAL_DUTIES_EPOCHS = 2;
|
|
6
|
+
/**
|
|
7
|
+
* Similar to AttestationDutiesService but
|
|
8
|
+
* - No generating and caching selection proof
|
|
9
|
+
* - No handling and maintaining subnet subscription
|
|
10
|
+
*/
|
|
11
|
+
export class InclusionListDutiesService {
|
|
12
|
+
config;
|
|
13
|
+
logger;
|
|
14
|
+
api;
|
|
15
|
+
clock;
|
|
16
|
+
validatorStore;
|
|
17
|
+
/** Maps a validator index to its duty for each epoch */
|
|
18
|
+
dutiesByIndexByEpoch = new Map();
|
|
19
|
+
/**
|
|
20
|
+
* We may receive new dependentRoot of an epoch but it's not the last slot of epoch
|
|
21
|
+
* so we have to wait for getting close to the next epoch to redownload new inclusionListDuties.
|
|
22
|
+
*/
|
|
23
|
+
pendingDependentRootByEpoch = new Map();
|
|
24
|
+
constructor(config, logger, api, clock, validatorStore, chainHeadTracker, syncingStatusTracker) {
|
|
25
|
+
this.config = config;
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
this.api = api;
|
|
28
|
+
this.clock = clock;
|
|
29
|
+
this.validatorStore = validatorStore;
|
|
30
|
+
// Running this task every epoch is safe since a re-org of two epochs is very unlikely
|
|
31
|
+
clock.runEveryEpoch(this.runDutiesTasks);
|
|
32
|
+
clock.runEverySlot(this.prepareForNextEpoch);
|
|
33
|
+
chainHeadTracker.runOnNewHead(this.onNewHead);
|
|
34
|
+
syncingStatusTracker.runOnResynced(async (slot) => {
|
|
35
|
+
// Skip on first slot of epoch since tasks are already scheduled
|
|
36
|
+
if (!isStartSlotOfEpoch(slot)) {
|
|
37
|
+
return this.runDutiesTasks(computeEpochAtSlot(slot));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
removeDutiesForKey(pubkey) {
|
|
42
|
+
for (const [epoch, dutiesAtEpoch] of this.dutiesByIndexByEpoch) {
|
|
43
|
+
for (const [vIndex, duty] of dutiesAtEpoch.dutiesByIndex) {
|
|
44
|
+
if (toPubkeyHex(duty.pubkey) === pubkey) {
|
|
45
|
+
dutiesAtEpoch.dutiesByIndex.delete(vIndex);
|
|
46
|
+
if (dutiesAtEpoch.dutiesByIndex.size === 0) {
|
|
47
|
+
this.dutiesByIndexByEpoch.delete(epoch);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Returns all `ValidatorDuty` for the given `slot` */
|
|
54
|
+
getDutiesAtSlot(slot) {
|
|
55
|
+
const epoch = computeEpochAtSlot(slot);
|
|
56
|
+
const duties = [];
|
|
57
|
+
const epochDuties = this.dutiesByIndexByEpoch.get(epoch);
|
|
58
|
+
if (epochDuties === undefined) {
|
|
59
|
+
return duties;
|
|
60
|
+
}
|
|
61
|
+
for (const validatorDuty of epochDuties.dutiesByIndex.values()) {
|
|
62
|
+
if (validatorDuty.slot === slot) {
|
|
63
|
+
duties.push(validatorDuty);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return duties;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* If a reorg dependent root comes at a slot other than last slot of epoch
|
|
70
|
+
* just update this.pendingDependentRootByEpoch() and process here
|
|
71
|
+
*/
|
|
72
|
+
prepareForNextEpoch = async (slot, signal) => {
|
|
73
|
+
// only interested in last slot of epoch
|
|
74
|
+
if ((slot + 1) % SLOTS_PER_EPOCH !== 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// during the 1 / 3 of epoch, last block of epoch may come
|
|
78
|
+
await sleep(this.clock.msToSlot(slot + 1 / 3), signal);
|
|
79
|
+
const nextEpoch = computeEpochAtSlot(slot) + 1;
|
|
80
|
+
const dependentRoot = this.dutiesByIndexByEpoch.get(nextEpoch)?.dependentRoot;
|
|
81
|
+
const pendingDependentRoot = this.pendingDependentRootByEpoch.get(nextEpoch);
|
|
82
|
+
if (dependentRoot && pendingDependentRoot && dependentRoot !== pendingDependentRoot) {
|
|
83
|
+
// this happens when pendingDependentRoot is not the last block of an epoch
|
|
84
|
+
this.logger.info("Redownload inclusion list duties when it's close to epoch boundary", { nextEpoch, slot });
|
|
85
|
+
await this.handleInclusionListDutiesReorg(nextEpoch, slot, dependentRoot, pendingDependentRoot);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
runDutiesTasks = async (epoch) => {
|
|
89
|
+
// pollInclusionListCommittee also polls epoch + 1, so start one epoch before the fork
|
|
90
|
+
if (epoch + 1 < this.config.HEZE_FORK_EPOCH) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
await Promise.all([
|
|
94
|
+
// Run pollInclusionListCommittee immediately for all known local indices
|
|
95
|
+
this.pollInclusionListCommittee(epoch, this.validatorStore.getAllLocalIndices()).catch((e) => {
|
|
96
|
+
this.logger.error("Error on poll inclusion list committee", { epoch }, e);
|
|
97
|
+
}),
|
|
98
|
+
// At the same time fetch any remaining unknown validator indices, then poll duties for those newIndices only
|
|
99
|
+
this.validatorStore
|
|
100
|
+
.pollValidatorIndices()
|
|
101
|
+
.then((newIndices) => this.pollInclusionListCommittee(epoch, newIndices))
|
|
102
|
+
.catch((e) => {
|
|
103
|
+
this.logger.error("Error on poll indices and inclusion list committee", { epoch }, e);
|
|
104
|
+
}),
|
|
105
|
+
]);
|
|
106
|
+
// After both, prune
|
|
107
|
+
this.pruneOldDuties(epoch);
|
|
108
|
+
};
|
|
109
|
+
async pollInclusionListCommittee(currentEpoch, indexArr) {
|
|
110
|
+
const nextEpoch = currentEpoch + 1;
|
|
111
|
+
// No need to bother the BN if we don't have any validators.
|
|
112
|
+
if (indexArr.length === 0) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
for (const epoch of [currentEpoch, nextEpoch]) {
|
|
116
|
+
// Download the duties and update the duties for the current and next epoch.
|
|
117
|
+
await this.pollInclusionListCommitteeForEpoch(epoch, indexArr).catch((e) => {
|
|
118
|
+
this.logger.error("Failed to download inclusion list duties", { epoch }, e);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* For the given `indexArr`, download the duties for the given `epoch` and store them in duties.
|
|
124
|
+
*/
|
|
125
|
+
async pollInclusionListCommitteeForEpoch(epoch, indexArr) {
|
|
126
|
+
// Don't fetch duties for epochs before genesis. However, should fetch epoch 0 duties at epoch -1
|
|
127
|
+
if (epoch < 0) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// Inclusion list committees only exist post-heze; the beacon node rejects earlier epochs
|
|
131
|
+
if (epoch < this.config.HEZE_FORK_EPOCH) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const res = await this.api.validator.getInclusionListCommitteeDuties({ epoch, indices: indexArr });
|
|
135
|
+
const inclusionListDuties = res.value();
|
|
136
|
+
const { dependentRoot } = res.meta();
|
|
137
|
+
const relevantDuties = inclusionListDuties.filter((duty) => {
|
|
138
|
+
const pubkeyHex = toPubkeyHex(duty.pubkey);
|
|
139
|
+
return this.validatorStore.hasVotingPubkey(pubkeyHex) && this.validatorStore.isDoppelgangerSafe(pubkeyHex);
|
|
140
|
+
});
|
|
141
|
+
this.logger.debug("Downloaded inclusion list duties", { epoch, dependentRoot, count: relevantDuties.length });
|
|
142
|
+
const dutiesAtEpoch = this.dutiesByIndexByEpoch.get(epoch);
|
|
143
|
+
const priorDependentRoot = dutiesAtEpoch?.dependentRoot;
|
|
144
|
+
const dependentRootChanged = priorDependentRoot !== undefined && priorDependentRoot !== dependentRoot;
|
|
145
|
+
if (!priorDependentRoot || dependentRootChanged) {
|
|
146
|
+
const dutiesByIndex = new Map();
|
|
147
|
+
for (const duty of relevantDuties) {
|
|
148
|
+
dutiesByIndex.set(duty.validatorIndex, duty);
|
|
149
|
+
}
|
|
150
|
+
this.dutiesByIndexByEpoch.set(epoch, { dependentRoot, dutiesByIndex });
|
|
151
|
+
if (priorDependentRoot && dependentRootChanged) {
|
|
152
|
+
this.logger.warn("Inclusion list duties re-org. This may happen from time to time", {
|
|
153
|
+
priorDependentRoot: priorDependentRoot,
|
|
154
|
+
dependentRoot: dependentRoot,
|
|
155
|
+
epoch,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const existingDuties = dutiesAtEpoch.dutiesByIndex;
|
|
161
|
+
const existingDutiesCount = existingDuties.size;
|
|
162
|
+
for (const duty of relevantDuties) {
|
|
163
|
+
if (!existingDuties.has(duty.validatorIndex)) {
|
|
164
|
+
existingDuties.set(duty.validatorIndex, duty);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (existingDuties.size > existingDutiesCount) {
|
|
168
|
+
this.logger.debug("Discovered new inclusion list duties", {
|
|
169
|
+
epoch,
|
|
170
|
+
dependentRoot,
|
|
171
|
+
count: existingDuties.size - existingDutiesCount,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async handleInclusionListDutiesReorg(dutyEpoch, slot, oldDependentRoot, newDependentRoot) {
|
|
177
|
+
const logContext = { dutyEpoch, slot, oldDependentRoot, newDependentRoot };
|
|
178
|
+
this.logger.debug("Redownload inclusion list duties", logContext);
|
|
179
|
+
await this.pollInclusionListCommitteeForEpoch(dutyEpoch, this.validatorStore.getAllLocalIndices())
|
|
180
|
+
.then(() => {
|
|
181
|
+
this.pendingDependentRootByEpoch.delete(dutyEpoch);
|
|
182
|
+
})
|
|
183
|
+
.catch((e) => {
|
|
184
|
+
this.logger.error("Failed to redownload inclusion list duties when reorg happens", logContext, e);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* inclusion list duties may be reorged due to 2 scenarios:
|
|
189
|
+
* 1. node is syncing (for nextEpoch duties)
|
|
190
|
+
* 2. node is reorged
|
|
191
|
+
* previousDutyDependentRoot = get_block_root_at_slot(state, compute_start_slot_at_epoch(epoch - 1) - 1)
|
|
192
|
+
* => dependent root of current epoch
|
|
193
|
+
* currentDutyDependentRoot = get_block_root_at_slot(state, compute_start_slot_at_epoch(epoch) - 1)
|
|
194
|
+
* => dependent root of next epoch
|
|
195
|
+
*/
|
|
196
|
+
onNewHead = async ({ slot, head, previousDutyDependentRoot, currentDutyDependentRoot, }) => {
|
|
197
|
+
const currentEpoch = computeEpochAtSlot(slot);
|
|
198
|
+
const nextEpoch = currentEpoch + 1;
|
|
199
|
+
const nextTwoEpoch = currentEpoch + 2;
|
|
200
|
+
const nextTwoEpochDependentRoot = this.dutiesByIndexByEpoch.get(currentEpoch + 2)?.dependentRoot;
|
|
201
|
+
// this may happen ONLY when node is syncing
|
|
202
|
+
// it's safe to get inclusion list duties at epoch n + 1 thanks to nextEpochShuffling cache
|
|
203
|
+
// but it's an issue to request inclusion list duties for epoch n + 2 as dependent root keeps changing while node is syncing
|
|
204
|
+
// see https://github.com/ChainSafe/lodestar/issues/3211
|
|
205
|
+
if (nextTwoEpochDependentRoot && head !== nextTwoEpochDependentRoot) {
|
|
206
|
+
// last slot of epoch, we're sure it's the correct dependent root
|
|
207
|
+
if ((slot + 1) % SLOTS_PER_EPOCH === 0) {
|
|
208
|
+
this.logger.info("Next 2 epoch inclusion list duties reorg", { slot, dutyEpoch: nextTwoEpoch, head });
|
|
209
|
+
await this.handleInclusionListDutiesReorg(nextTwoEpoch, slot, nextTwoEpochDependentRoot, head);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
this.logger.debug("Potential next 2 epoch inclusion list duties reorg", { slot, dutyEpoch: nextTwoEpoch, head });
|
|
213
|
+
// node may send adjacent onHead events while it's syncing
|
|
214
|
+
// wait for getting close to next epoch to make sure the dependRoot
|
|
215
|
+
this.pendingDependentRootByEpoch.set(nextTwoEpoch, head);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// dependent root for next epoch changed
|
|
219
|
+
const nextEpochDependentRoot = this.dutiesByIndexByEpoch.get(nextEpoch)?.dependentRoot;
|
|
220
|
+
if (nextEpochDependentRoot && currentDutyDependentRoot !== nextEpochDependentRoot) {
|
|
221
|
+
this.logger.warn("Potential next epoch inclusion list duties reorg", {
|
|
222
|
+
slot,
|
|
223
|
+
dutyEpoch: nextEpoch,
|
|
224
|
+
priorDependentRoot: nextEpochDependentRoot,
|
|
225
|
+
newDependentRoot: currentDutyDependentRoot,
|
|
226
|
+
});
|
|
227
|
+
await this.handleInclusionListDutiesReorg(nextEpoch, slot, nextEpochDependentRoot, currentDutyDependentRoot);
|
|
228
|
+
}
|
|
229
|
+
// dependent root for current epoch changed
|
|
230
|
+
const currentEpochDependentRoot = this.dutiesByIndexByEpoch.get(currentEpoch)?.dependentRoot;
|
|
231
|
+
if (currentEpochDependentRoot && currentEpochDependentRoot !== previousDutyDependentRoot) {
|
|
232
|
+
this.logger.warn("Potential current epoch inclusion list duties reorg", {
|
|
233
|
+
slot,
|
|
234
|
+
dutyEpoch: currentEpoch,
|
|
235
|
+
priorDependentRoot: currentEpochDependentRoot,
|
|
236
|
+
newDependentRoot: previousDutyDependentRoot,
|
|
237
|
+
});
|
|
238
|
+
await this.handleInclusionListDutiesReorg(currentEpoch, slot, currentEpochDependentRoot, previousDutyDependentRoot);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
/** Run once per epoch to prune duties map */
|
|
242
|
+
pruneOldDuties(currentEpoch) {
|
|
243
|
+
for (const byEpochMap of [this.dutiesByIndexByEpoch, this.pendingDependentRootByEpoch]) {
|
|
244
|
+
for (const epoch of byEpochMap.keys()) {
|
|
245
|
+
if (epoch + HISTORICAL_DUTIES_EPOCHS < currentEpoch) {
|
|
246
|
+
byEpochMap.delete(epoch);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=inclusionListDuties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inclusionListDuties.js","sourceRoot":"","sources":["../../src/services/inclusionListDuties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAS,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAE1F,OAAO,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAOnD,gFAAgF;AAChF,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAMnC;;;;GAIG;AACH,MAAM,OAAO,0BAA0B;IAUlB,MAAM;IACN,MAAM;IACN,GAAG;IACZ,KAAK;IACI,cAAc;IAbjC,wDAAwD;IACvC,oBAAoB,GAAG,IAAI,GAAG,EAAqC,CAAC;IACrF;;;OAGG;IACc,2BAA2B,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzE,YACmB,MAAuB,EACvB,MAAgB,EAChB,GAAc,EACvB,KAAa,EACJ,cAA8B,EAC/C,gBAAoC,EACpC,oBAA0C;sBANzB,MAAM;sBACN,MAAM;mBACN,GAAG;qBACZ,KAAK;8BACI,cAAc;QAI/B,sFAAsF;QACtF,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACzC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC7C,gBAAgB,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9C,oBAAoB,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChD,gEAAgE;YAChE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC9B,OAAO,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;YACvD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kBAAkB,CAAC,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AAC;CACF"}
|
|
@@ -2,7 +2,7 @@ import { SecretKey } from "@chainsafe/lodestar-z/blst";
|
|
|
2
2
|
import { routes } from "@lodestar/api";
|
|
3
3
|
import { BuilderConfigData, BuilderEntryConfig } from "@lodestar/api/keymanager";
|
|
4
4
|
import { BeaconConfig } from "@lodestar/config";
|
|
5
|
-
import { Attestation, BLSPubkey, BLSSignature, BeaconBlock, BlindedBeaconBlock, Epoch, Root, SignedAggregateAndProof, SignedBeaconBlock, SignedBlindedBeaconBlock, SingleAttestation, Slot, ValidatorIndex, altair, bellatrix, gloas, phase0 } from "@lodestar/types";
|
|
5
|
+
import { Attestation, BLSPubkey, BLSSignature, BeaconBlock, BlindedBeaconBlock, Epoch, Root, SignedAggregateAndProof, SignedBeaconBlock, SignedBlindedBeaconBlock, SingleAttestation, Slot, ValidatorIndex, altair, bellatrix, gloas, heze, phase0 } from "@lodestar/types";
|
|
6
6
|
import { Metrics } from "../metrics.js";
|
|
7
7
|
import { ISlashingProtection } from "../slashingProtection/index.js";
|
|
8
8
|
import { PubkeyHex } from "../types.js";
|
|
@@ -161,6 +161,7 @@ export declare class ValidatorStore {
|
|
|
161
161
|
}, selectionProof: BLSSignature, contribution: altair.SyncCommitteeContribution): Promise<altair.SignedContributionAndProof>;
|
|
162
162
|
signPayloadAttestation(duty: routes.validator.PtcDuty, data: gloas.PayloadAttestationData, currentSlot: Slot, logger?: LoggerVc): Promise<gloas.PayloadAttestationMessage>;
|
|
163
163
|
signProposerPreferences(duty: routes.validator.ProposerDuty, dependentRoot: Uint8Array, feeRecipient: ExecutionAddress, gasLimit: number, currentSlot: Slot): Promise<gloas.SignedProposerPreferences>;
|
|
164
|
+
signInclusionList(duty: routes.validator.InclusionListDuty, inclusionList: heze.InclusionList): Promise<heze.SignedInclusionList>;
|
|
164
165
|
signAttestationSelectionProof(pubkey: BLSPubkeyMaybeHex, slot: Slot): Promise<BLSSignature>;
|
|
165
166
|
signSyncCommitteeSelectionProof(pubkey: BLSPubkeyMaybeHex, slot: Slot, subcommitteeIndex: number): Promise<BLSSignature>;
|
|
166
167
|
signVoluntaryExit(pubkey: BLSPubkeyMaybeHex, validatorIndex: number, exitEpoch: Epoch): Promise<phase0.SignedVoluntaryExit>;
|
|
@@ -184,6 +185,11 @@ export declare class ValidatorStore {
|
|
|
184
185
|
/** Prevent signing bad data sent by the Beacon node */
|
|
185
186
|
private validateAttestationDuty;
|
|
186
187
|
private validatePtcDuty;
|
|
188
|
+
/**
|
|
189
|
+
* Required before signing a message that is slashable or that the beacon node counts as validator
|
|
190
|
+
* liveness (see `validatorSeenAtEpoch`), otherwise doppelganger detection would flag our own messages.
|
|
191
|
+
* Skip it for anything else.
|
|
192
|
+
*/
|
|
187
193
|
private assertDoppelgangerSafe;
|
|
188
194
|
}
|
|
189
195
|
export {};
|