@lodestar/builder 1.52.0-dev.d3dc575c8e → 1.52.0-dev.d88015cb2a
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/builder.d.ts +4 -1
- package/lib/builder.d.ts.map +1 -1
- package/lib/builder.js +12 -1
- package/lib/builder.js.map +1 -1
- package/lib/services/bidLedger.d.ts +10 -7
- package/lib/services/bidLedger.d.ts.map +1 -1
- package/lib/services/bidLedger.js +35 -17
- package/lib/services/bidLedger.js.map +1 -1
- package/lib/services/bidPublisher.js +1 -1
- package/lib/services/bidPublisher.js.map +1 -1
- package/lib/services/bidder.d.ts +6 -2
- package/lib/services/bidder.d.ts.map +1 -1
- package/lib/services/bidder.js +14 -5
- package/lib/services/bidder.js.map +1 -1
- package/lib/services/headTracker.d.ts +23 -0
- package/lib/services/headTracker.d.ts.map +1 -0
- package/lib/services/headTracker.js +47 -0
- package/lib/services/headTracker.js.map +1 -0
- package/package.json +11 -11
- package/src/builder.ts +13 -0
- package/src/services/bidLedger.ts +54 -27
- package/src/services/bidPublisher.ts +1 -1
- package/src/services/bidder.ts +19 -7
- package/src/services/headTracker.ts +63 -0
package/lib/builder.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ProportionalBidPolicyOpts } from "./services/bidPolicy.js";
|
|
|
10
10
|
import { BlockObserver } from "./services/blockObserver.js";
|
|
11
11
|
import { BuilderSigner, Keypair } from "./services/builderSigner.js";
|
|
12
12
|
import { BuilderStatusTracker } from "./services/builderStatusTracker.js";
|
|
13
|
+
import { HeadTracker } from "./services/headTracker.js";
|
|
13
14
|
import { PayloadSource } from "./services/payloadSource.js";
|
|
14
15
|
import { PayloadStore } from "./services/payloadStore.js";
|
|
15
16
|
import { ProposerPreferencesTracker } from "./services/proposerPreferencesTracker.js";
|
|
@@ -20,6 +21,7 @@ export type BuilderModules = {
|
|
|
20
21
|
blockObserver: BlockObserver;
|
|
21
22
|
builderStatusTracker: BuilderStatusTracker;
|
|
22
23
|
proposerPreferencesTracker: ProposerPreferencesTracker;
|
|
24
|
+
headTracker: HeadTracker;
|
|
23
25
|
clock: IClock;
|
|
24
26
|
index: BuilderIndex;
|
|
25
27
|
payloadStore: PayloadStore;
|
|
@@ -54,6 +56,7 @@ export type BuilderOptions = {
|
|
|
54
56
|
export declare class Builder {
|
|
55
57
|
readonly builderSigner: BuilderSigner;
|
|
56
58
|
readonly proposerPreferencesTracker: ProposerPreferencesTracker;
|
|
59
|
+
readonly headTracker: HeadTracker;
|
|
57
60
|
private readonly blockObserver;
|
|
58
61
|
private readonly builderStatusTracker;
|
|
59
62
|
private readonly controller;
|
|
@@ -65,7 +68,7 @@ export declare class Builder {
|
|
|
65
68
|
private readonly ledger;
|
|
66
69
|
private readonly bidder;
|
|
67
70
|
private readonly revealer;
|
|
68
|
-
constructor({ opts, builderSigner, blockObserver, builderStatusTracker, proposerPreferencesTracker, clock, index, payloadStore, ledger, bidder, revealer, }: BuilderModules);
|
|
71
|
+
constructor({ opts, builderSigner, blockObserver, builderStatusTracker, proposerPreferencesTracker, headTracker, clock, index, payloadStore, ledger, bidder, revealer, }: BuilderModules);
|
|
69
72
|
static init(opts: BuilderOptions): Promise<Builder>;
|
|
70
73
|
private onSlot;
|
|
71
74
|
private subscribeToEvents;
|
package/lib/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAS,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,eAAe,EAAwC,MAAM,kBAAkB,CAAC;AAExF,OAAO,EAAQ,YAAY,EAAE,MAAM,EAAC,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAmC,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAAC,OAAO,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AAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuB;IAC5D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAmB;IACzD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IAEpC,YAAY,EACV,IAAI,EACJ,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,0BAA0B,EAC1B,WAAW,EACX,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,MAAM,EACN,QAAQ,GACT,EAAE,cAAc,EA8BhB;IAED,OAAa,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAoGxD;YAEa,MAAM;IAQpB,OAAO,CAAC,iBAAiB;IA2CzB;;;OAGG;YACW,wBAAwB;YAqBxB,OAAO;IA8Bf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;CACF"}
|
package/lib/builder.js
CHANGED
|
@@ -15,6 +15,7 @@ import { BlockObserver } from "./services/blockObserver.js";
|
|
|
15
15
|
import { BuilderSigner } from "./services/builderSigner.js";
|
|
16
16
|
import { BuilderStatusTracker } from "./services/builderStatusTracker.js";
|
|
17
17
|
import { EnvelopePublisher } from "./services/envelopePublisher.js";
|
|
18
|
+
import { HeadTracker } from "./services/headTracker.js";
|
|
18
19
|
import { PayloadOrchestrator } from "./services/payloadOrchestrator.js";
|
|
19
20
|
import { PayloadStore } from "./services/payloadStore.js";
|
|
20
21
|
import { ProposerPreferencesTracker } from "./services/proposerPreferencesTracker.js";
|
|
@@ -30,6 +31,7 @@ const PAYMENT_SETTLEMENT_SLOTS = 3 * SLOTS_PER_EPOCH;
|
|
|
30
31
|
export class Builder {
|
|
31
32
|
builderSigner;
|
|
32
33
|
proposerPreferencesTracker;
|
|
34
|
+
headTracker;
|
|
33
35
|
blockObserver;
|
|
34
36
|
builderStatusTracker;
|
|
35
37
|
controller;
|
|
@@ -41,11 +43,12 @@ export class Builder {
|
|
|
41
43
|
ledger;
|
|
42
44
|
bidder;
|
|
43
45
|
revealer;
|
|
44
|
-
constructor({ opts, builderSigner, blockObserver, builderStatusTracker, proposerPreferencesTracker, clock, index, payloadStore, ledger, bidder, revealer, }) {
|
|
46
|
+
constructor({ opts, builderSigner, blockObserver, builderStatusTracker, proposerPreferencesTracker, headTracker, clock, index, payloadStore, ledger, bidder, revealer, }) {
|
|
45
47
|
this.builderSigner = builderSigner;
|
|
46
48
|
this.blockObserver = blockObserver;
|
|
47
49
|
this.builderStatusTracker = builderStatusTracker;
|
|
48
50
|
this.proposerPreferencesTracker = proposerPreferencesTracker;
|
|
51
|
+
this.headTracker = headTracker;
|
|
49
52
|
this.clock = clock;
|
|
50
53
|
this.controller = opts.abortController;
|
|
51
54
|
this.logger = opts.logger;
|
|
@@ -87,6 +90,7 @@ export class Builder {
|
|
|
87
90
|
await builderStatusTracker.poll(clock.getCurrentEpoch());
|
|
88
91
|
const blockObserver = new BlockObserver(config, logger, api);
|
|
89
92
|
const proposerPreferencesTracker = new ProposerPreferencesTracker();
|
|
93
|
+
const headTracker = new HeadTracker();
|
|
90
94
|
const payloadStore = new PayloadStore();
|
|
91
95
|
const ledger = new BidLedger();
|
|
92
96
|
const signal = opts.abortController.signal;
|
|
@@ -108,6 +112,7 @@ export class Builder {
|
|
|
108
112
|
hasPayload: ({ blockHash }) => payloadStore.has(blockHash),
|
|
109
113
|
}),
|
|
110
114
|
proposerPreferencesTracker,
|
|
115
|
+
headTracker,
|
|
111
116
|
getBuilderStatus: () => builderStatusTracker.getStatus(),
|
|
112
117
|
builderIndex: index,
|
|
113
118
|
executionFeeRecipient: opts.executionFeeRecipient,
|
|
@@ -131,6 +136,7 @@ export class Builder {
|
|
|
131
136
|
blockObserver,
|
|
132
137
|
builderStatusTracker,
|
|
133
138
|
proposerPreferencesTracker,
|
|
139
|
+
headTracker,
|
|
134
140
|
clock,
|
|
135
141
|
index,
|
|
136
142
|
payloadStore,
|
|
@@ -142,6 +148,7 @@ export class Builder {
|
|
|
142
148
|
async onSlot(slot) {
|
|
143
149
|
this.payloadStore.prune(slot);
|
|
144
150
|
this.proposerPreferencesTracker.prune(slot);
|
|
151
|
+
this.headTracker.prune(slot);
|
|
145
152
|
this.ledger.settlePaymentsBefore(slot - PAYMENT_SETTLEMENT_SLOTS);
|
|
146
153
|
this.ledger.prune(slot);
|
|
147
154
|
}
|
|
@@ -150,6 +157,7 @@ export class Builder {
|
|
|
150
157
|
if (signal.aborted)
|
|
151
158
|
return;
|
|
152
159
|
const topics = [
|
|
160
|
+
routes.events.EventType.headV2,
|
|
153
161
|
routes.events.EventType.block,
|
|
154
162
|
routes.events.EventType.proposerPreferences,
|
|
155
163
|
routes.events.EventType.payloadAttributes,
|
|
@@ -210,6 +218,9 @@ export class Builder {
|
|
|
210
218
|
return;
|
|
211
219
|
try {
|
|
212
220
|
switch (event.type) {
|
|
221
|
+
case routes.events.EventType.headV2:
|
|
222
|
+
this.headTracker.onHead(event.message.data);
|
|
223
|
+
break;
|
|
213
224
|
case routes.events.EventType.block:
|
|
214
225
|
await this.blockObserver.processBlockEvent(event.message, signal);
|
|
215
226
|
break;
|
package/lib/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAC,MAAM,eAAe,CAAC;AAChD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AAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC5C,MAAM;gBACR,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK;oBAChC,MAAM,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAClE,MAAM;gBACR,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB;oBAC9C,IAAI,CAAC,0BAA0B,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC1E,MAAM;gBACR,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB;oBAC5C,MAAM,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBACrD,MAAM;YACV,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,iCAAiC,EACjC,EAAC,SAAS,EAAE,KAAK,CAAC,IAAI,EAAC,EACvB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CACtD,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { Epoch, RootHex, Slot } from "@lodestar/types";
|
|
1
|
+
import type { Epoch, RootHex, Slot, gloas } from "@lodestar/types";
|
|
2
2
|
import { LodestarError } from "@lodestar/utils";
|
|
3
3
|
export type SubmittedBid = {
|
|
4
|
+
signedBid: gloas.SignedExecutionPayloadBid;
|
|
5
|
+
signedBidRoot: RootHex;
|
|
6
|
+
};
|
|
7
|
+
export type BidIdentity = {
|
|
4
8
|
slot: Slot;
|
|
5
9
|
parentBlockHash: RootHex;
|
|
6
10
|
parentBlockRoot: RootHex;
|
|
7
11
|
blockHash: RootHex;
|
|
8
|
-
valueGwei: number;
|
|
9
|
-
signedBidRoot: RootHex;
|
|
10
12
|
};
|
|
11
|
-
export type
|
|
12
|
-
export type BidLedgerRecord = SubmittedBid & {
|
|
13
|
+
export type BidLedgerRecord = SubmittedBid & BidIdentity & {
|
|
13
14
|
wonBlockRoots: RootHex[];
|
|
14
15
|
};
|
|
15
16
|
export declare enum BidLedgerErrorCode {
|
|
@@ -50,8 +51,8 @@ export declare class BidLedger {
|
|
|
50
51
|
private readonly revealedPayloadByBlockRoot;
|
|
51
52
|
private pruneCutoffSlot;
|
|
52
53
|
hasSubmitted(slot: Slot, parentBlockHash: RootHex, parentBlockRoot: RootHex): boolean;
|
|
53
|
-
assertCanRecordBid({ slot, parentBlockHash, parentBlockRoot, }: Pick<
|
|
54
|
-
recordBid(
|
|
54
|
+
assertCanRecordBid({ slot, parentBlockHash, parentBlockRoot, }: Pick<BidIdentity, "slot" | "parentBlockHash" | "parentBlockRoot">): void;
|
|
55
|
+
recordBid({ signedBid, signedBidRoot }: SubmittedBid): BidLedgerRecord;
|
|
55
56
|
recordWin(identity: BidIdentity & Pick<SubmittedBid, "signedBidRoot">, blockRoot: RootHex): BidLedgerRecord | null;
|
|
56
57
|
hasWon(identity: BidIdentity, blockRoot: RootHex): boolean;
|
|
57
58
|
/** Release a winning bid liability only after its payment is known to be reflected in Builder balance. */
|
|
@@ -64,6 +65,8 @@ export declare class BidLedger {
|
|
|
64
65
|
/** Marks won bids before the given slot as settled, by then their payment is reflected in the builder balance. */
|
|
65
66
|
settlePaymentsBefore(slot: Slot): void;
|
|
66
67
|
getUnsettledValueGwei(currentEpoch: Epoch): number;
|
|
68
|
+
/** Returns the signed bid recorded for the slot and parent, null if no bid was recorded for it */
|
|
69
|
+
getSignedBid(slot: Slot, parentBlockHash: RootHex, parentBlockRoot: RootHex): gloas.SignedExecutionPayloadBid | null;
|
|
67
70
|
getBidsForSlot(slot: Slot): BidLedgerRecord[];
|
|
68
71
|
prune(currentSlot: Slot): number;
|
|
69
72
|
private getBid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidLedger.d.ts","sourceRoot":"","sources":["../../src/services/bidLedger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"bidLedger.d.ts","sourceRoot":"","sources":["../../src/services/bidLedger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAC,aAAa,EAAY,MAAM,iBAAiB,CAAC;AAEzD,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,KAAK,CAAC,yBAAyB,CAAC;IAC3C,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,GACxC,WAAW,GAAG;IACZ,aAAa,EAAE,OAAO,EAAE,CAAC;CAC1B,CAAC;AAkBJ,oBAAY,kBAAkB;IAC5B,iBAAiB,uCAAuC;IACxD,aAAa,mCAAmC;IAChD,WAAW,iCAAiC;IAC5C,eAAe,qCAAqC;IACpD,wBAAwB,8CAA8C;CACvE;AAED,MAAM,MAAM,kBAAkB,GAC1B;IACE,IAAI,EAAE,kBAAkB,CAAC,iBAAiB,CAAC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Error, toRootHex } from "@lodestar/utils";
|
|
3
3
|
export var BidLedgerErrorCode;
|
|
4
4
|
(function (BidLedgerErrorCode) {
|
|
5
5
|
BidLedgerErrorCode["INVALID_BID_VALUE"] = "BID_LEDGER_ERROR_INVALID_BID_VALUE";
|
|
@@ -28,24 +28,41 @@ export class BidLedger {
|
|
|
28
28
|
throw new BidLedgerError({ code: BidLedgerErrorCode.DUPLICATE_BID, slot, parentBlockHash, parentBlockRoot }, `Bid already recorded slot=${slot} parentBlockHash=${parentBlockHash} parentBlockRoot=${parentBlockRoot}`);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
recordBid(
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
recordBid({ signedBid, signedBidRoot }) {
|
|
32
|
+
const bid = signedBid.message;
|
|
33
|
+
const valueGwei = bid.value;
|
|
34
|
+
if (!Number.isSafeInteger(valueGwei) || valueGwei < 0) {
|
|
35
|
+
throw new BidLedgerError({ code: BidLedgerErrorCode.INVALID_BID_VALUE, valueGwei }, `Invalid bid value valueGwei=${valueGwei}`);
|
|
34
36
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
const identity = {
|
|
38
|
+
slot: bid.slot,
|
|
39
|
+
parentBlockHash: toRootHex(bid.parentBlockHash),
|
|
40
|
+
parentBlockRoot: toRootHex(bid.parentBlockRoot),
|
|
41
|
+
blockHash: toRootHex(bid.blockHash),
|
|
42
|
+
};
|
|
43
|
+
this.assertCanRecordBid(identity);
|
|
44
|
+
let bidsForSlot = this.bidsBySlot.get(identity.slot);
|
|
37
45
|
if (bidsForSlot === undefined) {
|
|
38
46
|
bidsForSlot = new Map();
|
|
39
|
-
this.bidsBySlot.set(
|
|
47
|
+
this.bidsBySlot.set(identity.slot, bidsForSlot);
|
|
40
48
|
}
|
|
41
|
-
const key = tupleKey(
|
|
42
|
-
const record = {
|
|
49
|
+
const key = tupleKey(identity.parentBlockHash, identity.parentBlockRoot);
|
|
50
|
+
const record = {
|
|
51
|
+
signedBid,
|
|
52
|
+
signedBidRoot,
|
|
53
|
+
identity,
|
|
54
|
+
valueGwei,
|
|
55
|
+
wonBlockRoots: new Set(),
|
|
56
|
+
paymentSettled: false,
|
|
57
|
+
};
|
|
43
58
|
bidsForSlot.set(key, record);
|
|
44
59
|
return toRecord(record);
|
|
45
60
|
}
|
|
46
61
|
recordWin(identity, blockRoot) {
|
|
47
62
|
const record = this.getBid(identity.slot, identity.parentBlockHash, identity.parentBlockRoot);
|
|
48
|
-
if (record === null ||
|
|
63
|
+
if (record === null ||
|
|
64
|
+
record.identity.blockHash !== identity.blockHash ||
|
|
65
|
+
record.signedBidRoot !== identity.signedBidRoot) {
|
|
49
66
|
return null;
|
|
50
67
|
}
|
|
51
68
|
record.wonBlockRoots.add(blockRoot);
|
|
@@ -53,12 +70,12 @@ export class BidLedger {
|
|
|
53
70
|
}
|
|
54
71
|
hasWon(identity, blockRoot) {
|
|
55
72
|
const record = this.getBid(identity.slot, identity.parentBlockHash, identity.parentBlockRoot);
|
|
56
|
-
return record !== null && record.blockHash === identity.blockHash && record.wonBlockRoots.has(blockRoot);
|
|
73
|
+
return record !== null && record.identity.blockHash === identity.blockHash && record.wonBlockRoots.has(blockRoot);
|
|
57
74
|
}
|
|
58
75
|
/** Release a winning bid liability only after its payment is known to be reflected in Builder balance. */
|
|
59
76
|
recordPaymentSettled(identity) {
|
|
60
77
|
const record = this.getBid(identity.slot, identity.parentBlockHash, identity.parentBlockRoot);
|
|
61
|
-
if (record === null || record.blockHash !== identity.blockHash || record.wonBlockRoots.size === 0) {
|
|
78
|
+
if (record === null || record.identity.blockHash !== identity.blockHash || record.wonBlockRoots.size === 0) {
|
|
62
79
|
return null;
|
|
63
80
|
}
|
|
64
81
|
record.paymentSettled = true;
|
|
@@ -127,6 +144,10 @@ export class BidLedger {
|
|
|
127
144
|
}
|
|
128
145
|
return total;
|
|
129
146
|
}
|
|
147
|
+
/** Returns the signed bid recorded for the slot and parent, null if no bid was recorded for it */
|
|
148
|
+
getSignedBid(slot, parentBlockHash, parentBlockRoot) {
|
|
149
|
+
return this.getBid(slot, parentBlockHash, parentBlockRoot)?.signedBid ?? null;
|
|
150
|
+
}
|
|
130
151
|
getBidsForSlot(slot) {
|
|
131
152
|
return Array.from(this.bidsBySlot.get(slot)?.values() ?? [], toRecord);
|
|
132
153
|
}
|
|
@@ -164,11 +185,8 @@ function tupleKey(parentBlockHash, parentBlockRoot) {
|
|
|
164
185
|
}
|
|
165
186
|
function toRecord(record) {
|
|
166
187
|
return {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
parentBlockRoot: record.parentBlockRoot,
|
|
170
|
-
blockHash: record.blockHash,
|
|
171
|
-
valueGwei: record.valueGwei,
|
|
188
|
+
...record.identity,
|
|
189
|
+
signedBid: record.signedBid,
|
|
172
190
|
signedBidRoot: record.signedBidRoot,
|
|
173
191
|
wonBlockRoots: Array.from(record.wonBlockRoots),
|
|
174
192
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidLedger.js","sourceRoot":"","sources":["../../src/services/bidLedger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"bidLedger.js","sourceRoot":"","sources":["../../src/services/bidLedger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,aAAa,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAmCzD,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,8EAAwD,CAAA;IACxD,sEAAgD,CAAA;IAChD,kEAA4C,CAAA;IAC5C,0EAAoD,CAAA;IACpD,4FAAsE,CAAA;AACxE,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B;AA+BD,MAAM,OAAO,cAAe,SAAQ,aAAiC;CAAG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AG,IAAI,CAAC,eAAe,EAAE,CAAC;gBAChD,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,MAAM,CAAC,IAAU,EAAE,eAAwB,EAAE,eAAwB;QAC3E,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,IAAI,IAAI,CAAC;IAC5F,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,eAAwB,EAAE,eAAwB;IAClE,OAAO,GAAG,eAAe,IAAI,eAAe,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,QAAQ,CAAC,MAA8B;IAC9C,OAAO;QACL,GAAG,MAAM,CAAC,QAAQ;QAClB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -41,7 +41,7 @@ export class BidPublisher {
|
|
|
41
41
|
ledger.assertCanRecordBid(identity);
|
|
42
42
|
const signedExecutionPayloadBid = signer.signExecutionPayloadBid(bid);
|
|
43
43
|
const signedBidRoot = toRootHex(sszTypesFor(fork, "SignedExecutionPayloadBid").hashTreeRoot(signedExecutionPayloadBid));
|
|
44
|
-
ledger.recordBid({
|
|
44
|
+
ledger.recordBid({ signedBid: signedExecutionPayloadBid, signedBidRoot });
|
|
45
45
|
const response = await api.beacon.publishExecutionPayloadBid({ signedExecutionPayloadBid }, { signal });
|
|
46
46
|
response.assertOk();
|
|
47
47
|
return signedExecutionPayloadBid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidPublisher.js","sourceRoot":"","sources":["../../src/services/bidPublisher.ts"],"names":[],"mappings":"AAEA,O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,EAAE,GAAG,QAAQ,EAAC,EAC/D,oCAAoC,QAAQ,CAAC,IAAI,oBAAoB,QAAQ,CAAC,eAAe,oBAAoB,QAAQ,CAAC,eAAe,cAAc,QAAQ,CAAC,SAAS,EAAE,CAC5K,CAAC;QACJ,CAAC;QAED,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAEpC,MAAM,yBAAyB,GAAG,MAAM,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;QACtE,MAAM,aAAa,GAAG,SAAS,CAC7B,WAAW,CAAC,IAAI,EAAE,2BAA2B,CAAC,CAAC,YAAY,CAAC,yBAAyB,CAAC,CACvF,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,EAAC,SAAS,EAAE,yBAAyB,EAAE,aAAa,EAAC,CAAC,CAAC;QAExE,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,0BAA0B,CAAC,EAAC,yBAAyB,EAAC,EAAE,EAAC,MAAM,EAAC,CAAC,CAAC;QACpG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,yBAAyB,CAAC;IACnC,CAAC;CACF"}
|
package/lib/services/bidder.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Metrics } from "../metrics.js";
|
|
|
7
7
|
import { BidLedger } from "./bidLedger.js";
|
|
8
8
|
import { BidPolicy } from "./bidPolicy.js";
|
|
9
9
|
import { BidPublisher } from "./bidPublisher.js";
|
|
10
|
+
import { HeadTracker } from "./headTracker.js";
|
|
10
11
|
import { PayloadOrchestrator } from "./payloadOrchestrator.js";
|
|
11
12
|
import { PayloadStore } from "./payloadStore.js";
|
|
12
13
|
import { ProposerPreferencesTracker } from "./proposerPreferencesTracker.js";
|
|
@@ -28,6 +29,7 @@ export type BidderModules = {
|
|
|
28
29
|
policy: BidPolicy;
|
|
29
30
|
bidPublisher: BidPublisher;
|
|
30
31
|
proposerPreferencesTracker: ProposerPreferencesTracker;
|
|
32
|
+
headTracker: HeadTracker;
|
|
31
33
|
getBuilderStatus: () => {
|
|
32
34
|
status: BuilderStatus | undefined;
|
|
33
35
|
balance: number | undefined;
|
|
@@ -48,8 +50,10 @@ export declare class Bidder {
|
|
|
48
50
|
constructor(modules: BidderModules, opts: BidderOptions);
|
|
49
51
|
onPayloadAttributes(event: PayloadAttributesEvent): Promise<void>;
|
|
50
52
|
/**
|
|
51
|
-
* Dependent root of the proposer duties
|
|
52
|
-
*
|
|
53
|
+
* Dependent root of the proposer duties for the proposal slot on the branch of the parent block, identifies
|
|
54
|
+
* the proposer preferences to bid against. Taken from the head events. A parent that was not announced as
|
|
55
|
+
* head, e.g. before the first head event after connecting, falls back to the proposer duties, which carry
|
|
56
|
+
* the dependent root of the beacon node's head branch.
|
|
53
57
|
*/
|
|
54
58
|
private getDependentRoot;
|
|
55
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidder.d.ts","sourceRoot":"","sources":["../../src/services/bidder.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,EAAqB,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAC,YAAY,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"bidder.d.ts","sourceRoot":"","sources":["../../src/services/bidder.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,EAAqB,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAC,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAuB,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAuB,MAAM,EAAoD,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAY,OAAO,EAAC,MAAM,eA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C;IACxB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,qBAAa,MAAM;IAIf,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAElD,YACmB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,aAAa,EAClC;IAEE,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+HtE;IAED;;;;;OAKG;YACW,gBAAgB;CAW/B"}
|
package/lib/services/bidder.js
CHANGED
|
@@ -42,7 +42,7 @@ export class Bidder {
|
|
|
42
42
|
logger.warn("Bidding is not supported for fork", { ...logCtx, fork: event.version });
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
const dependentRoot = await this.getDependentRoot(
|
|
45
|
+
const dependentRoot = await this.getDependentRoot(parentBlockRoot, slot, logCtx);
|
|
46
46
|
const proposerPreferences = proposerPreferencesTracker.get(slot, dependentRoot);
|
|
47
47
|
if (proposerPreferences === null) {
|
|
48
48
|
logger.debug("No proposer preferences known for slot, not bidding", { ...logCtx, dependentRoot });
|
|
@@ -134,11 +134,20 @@ export class Bidder {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* Dependent root of the proposer duties
|
|
138
|
-
*
|
|
137
|
+
* Dependent root of the proposer duties for the proposal slot on the branch of the parent block, identifies
|
|
138
|
+
* the proposer preferences to bid against. Taken from the head events. A parent that was not announced as
|
|
139
|
+
* head, e.g. before the first head event after connecting, falls back to the proposer duties, which carry
|
|
140
|
+
* the dependent root of the beacon node's head branch.
|
|
139
141
|
*/
|
|
140
|
-
async getDependentRoot(
|
|
141
|
-
|
|
142
|
+
async getDependentRoot(parentBlockRoot, slot, logCtx) {
|
|
143
|
+
const { api, headTracker, logger, signal } = this.modules;
|
|
144
|
+
const dependentRoot = headTracker.getDependentRoot(parentBlockRoot, slot);
|
|
145
|
+
if (dependentRoot !== null) {
|
|
146
|
+
return dependentRoot;
|
|
147
|
+
}
|
|
148
|
+
logger.debug("Parent block is not a tracked head, fetching proposer duties for dependent root", logCtx);
|
|
149
|
+
const duties = await api.validator.getProposerDutiesV2({ epoch: computeEpochAtSlot(slot) }, { signal });
|
|
150
|
+
return duties.meta().dependentRoot;
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
153
|
//# sourceMappingURL=bidder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidder.js","sourceRoot":"","sources":["../../src/services/bidder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAS,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"bidder.js","sourceRoot":"","sources":["../../src/services/bidder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAS,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAC,WAAW,EAAmB,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAC,SAAS,EAAU,MAAM,eAAe,CAAC;AAIjD,OAAO,EAAC,yBAAyB,EAAC,MAAM,0BAA0B,CAAC;AAkCnE;;;GAGG;AACH,MAAM,OAAO,MAAM;IAIE,OAAO;IACP,IAAI;IAJN,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IAElD,YACmB,OAAsB,EACtB,IAAmB;uBADnB,OAAO;oBACP,IAAI;IACpB,CAAC;IAEJ,KAAK,CAAC,mBAAmB,CAAC,KAA6B;QACrD,MAAM,EAAC,KAAK,EAAE,MAAM,EAAE,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,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAC,EAAE,EAAC,MAAM,EAAC,CAAC,CAAC;QACpG,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,aAAa,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { routes } from "@lodestar/api";
|
|
2
|
+
import type { RootHex, Slot } from "@lodestar/types";
|
|
3
|
+
export type HeadEvent = routes.events.EventData[routes.events.EventType.headV2];
|
|
4
|
+
/**
|
|
5
|
+
* Tracks the heads announced by the beacon node over `head_v2` events and the proposer duties dependent
|
|
6
|
+
* roots they carry. A bid is validated against the proposer preferences of its parent branch, the dependent
|
|
7
|
+
* root of a tracked head identifies those without fetching the proposer duties for every build.
|
|
8
|
+
*/
|
|
9
|
+
export declare class HeadTracker {
|
|
10
|
+
private readonly heads;
|
|
11
|
+
onHead(data: HeadEvent["data"]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Dependent root of the proposer duties for `proposalSlot` on the branch of `blockRoot`.
|
|
14
|
+
* Returns null if the block was not announced as head.
|
|
15
|
+
*/
|
|
16
|
+
getDependentRoot(blockRoot: RootHex, proposalSlot: Slot): RootHex | null;
|
|
17
|
+
/**
|
|
18
|
+
* Drops heads from before the previous epoch. An older head is only the parent of a proposal after a full
|
|
19
|
+
* epoch without blocks, the proposer duties fallback covers that.
|
|
20
|
+
*/
|
|
21
|
+
prune(currentSlot: Slot): number;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=headTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headTracker.d.ts","sourceRoot":"","sources":["../../src/services/headTracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAErC,OAAO,KAAK,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAEnD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAUhF;;;;GAIG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmC;IAEzD,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAGpC;IAED;;;OAGG;IACH,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,GAAG,OAAO,GAAG,IAAI,CAcvE;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,EAAE,IAAI,GAAG,MAAM,CAU/B;CACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { computeEpochAtSlot, computeStartSlotAtEpoch } from "@lodestar/state-transition";
|
|
2
|
+
/**
|
|
3
|
+
* Tracks the heads announced by the beacon node over `head_v2` events and the proposer duties dependent
|
|
4
|
+
* roots they carry. A bid is validated against the proposer preferences of its parent branch, the dependent
|
|
5
|
+
* root of a tracked head identifies those without fetching the proposer duties for every build.
|
|
6
|
+
*/
|
|
7
|
+
export class HeadTracker {
|
|
8
|
+
heads = new Map();
|
|
9
|
+
onHead(data) {
|
|
10
|
+
const { slot, block, currentEpochDependentRoot, nextEpochDependentRoot } = data;
|
|
11
|
+
this.heads.set(block, { slot, currentEpochDependentRoot, nextEpochDependentRoot });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Dependent root of the proposer duties for `proposalSlot` on the branch of `blockRoot`.
|
|
15
|
+
* Returns null if the block was not announced as head.
|
|
16
|
+
*/
|
|
17
|
+
getDependentRoot(blockRoot, proposalSlot) {
|
|
18
|
+
const head = this.heads.get(blockRoot);
|
|
19
|
+
if (head === undefined) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const epochDifference = computeEpochAtSlot(proposalSlot) - computeEpochAtSlot(head.slot);
|
|
23
|
+
if (epochDifference === 0) {
|
|
24
|
+
return head.currentEpochDependentRoot;
|
|
25
|
+
}
|
|
26
|
+
if (epochDifference === 1) {
|
|
27
|
+
return head.nextEpochDependentRoot;
|
|
28
|
+
}
|
|
29
|
+
return blockRoot;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Drops heads from before the previous epoch. An older head is only the parent of a proposal after a full
|
|
33
|
+
* epoch without blocks, the proposer duties fallback covers that.
|
|
34
|
+
*/
|
|
35
|
+
prune(currentSlot) {
|
|
36
|
+
const minSlot = computeStartSlotAtEpoch(Math.max(computeEpochAtSlot(currentSlot) - 1, 0));
|
|
37
|
+
let removed = 0;
|
|
38
|
+
for (const [blockRoot, head] of this.heads) {
|
|
39
|
+
if (head.slot < minSlot) {
|
|
40
|
+
this.heads.delete(blockRoot);
|
|
41
|
+
removed++;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return removed;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=headTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headTracker.js","sourceRoot":"","sources":["../../src/services/headTracker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAC,MAAM,4BAA4B,CAAC;AAavF;;;;GAIG;AACH,MAAM,OAAO,WAAW;IACL,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEzD,MAAM,CAAC,IAAuB;QAC5B,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,yBAAyB,EAAE,sBAAsB,EAAC,GAAG,IAAI,CAAC;QAC9E,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,EAAC,IAAI,EAAE,yBAAyB,EAAE,sBAAsB,EAAC,CAAC,CAAC;IACnF,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,SAAkB,EAAE,YAAkB;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,eAAe,GAAG,kBAAkB,CAAC,YAAY,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzF,IAAI,eAAe,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,yBAAyB,CAAC;QACxC,CAAC;QACD,IAAI,eAAe,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,sBAAsB,CAAC;QACrC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAiB;QACrB,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1F,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,KAAK,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3C,IAAI,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,CAAC;gBACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC7B,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodestar/builder",
|
|
3
|
-
"version": "1.52.0-dev.
|
|
3
|
+
"version": "1.52.0-dev.d88015cb2a",
|
|
4
4
|
"description": "A Typescript implementation of the builder client",
|
|
5
5
|
"author": "ChainSafe Systems",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@chainsafe/ssz": "^1.9.0",
|
|
50
|
-
"@lodestar/api": "^1.52.0-dev.
|
|
51
|
-
"@lodestar/config": "^1.52.0-dev.
|
|
52
|
-
"@lodestar/native": "^1.52.0-dev.
|
|
53
|
-
"@lodestar/params": "^1.52.0-dev.
|
|
54
|
-
"@lodestar/state-transition": "^1.52.0-dev.
|
|
55
|
-
"@lodestar/types": "^1.52.0-dev.
|
|
56
|
-
"@lodestar/utils": "^1.52.0-dev.
|
|
50
|
+
"@lodestar/api": "^1.52.0-dev.d88015cb2a",
|
|
51
|
+
"@lodestar/config": "^1.52.0-dev.d88015cb2a",
|
|
52
|
+
"@lodestar/native": "^1.52.0-dev.d88015cb2a",
|
|
53
|
+
"@lodestar/params": "^1.52.0-dev.d88015cb2a",
|
|
54
|
+
"@lodestar/state-transition": "^1.52.0-dev.d88015cb2a",
|
|
55
|
+
"@lodestar/types": "^1.52.0-dev.d88015cb2a",
|
|
56
|
+
"@lodestar/utils": "^1.52.0-dev.d88015cb2a"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@lodestar/logger": "^1.52.0-dev.
|
|
60
|
-
"@lodestar/test-utils": "^1.52.0-dev.
|
|
59
|
+
"@lodestar/logger": "^1.52.0-dev.d88015cb2a",
|
|
60
|
+
"@lodestar/test-utils": "^1.52.0-dev.d88015cb2a"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "ee8b11d2adebc117e1579d1b3b5b18d58e053f60"
|
|
63
63
|
}
|
package/src/builder.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {BlockObserver} from "./services/blockObserver.js";
|
|
|
17
17
|
import {BuilderSigner, Keypair} from "./services/builderSigner.js";
|
|
18
18
|
import {BuilderStatusTracker} from "./services/builderStatusTracker.js";
|
|
19
19
|
import {EnvelopePublisher} from "./services/envelopePublisher.js";
|
|
20
|
+
import {HeadTracker} from "./services/headTracker.js";
|
|
20
21
|
import {PayloadOrchestrator} from "./services/payloadOrchestrator.js";
|
|
21
22
|
import {PayloadSource} from "./services/payloadSource.js";
|
|
22
23
|
import {PayloadStore} from "./services/payloadStore.js";
|
|
@@ -35,6 +36,7 @@ export type BuilderModules = {
|
|
|
35
36
|
blockObserver: BlockObserver;
|
|
36
37
|
builderStatusTracker: BuilderStatusTracker;
|
|
37
38
|
proposerPreferencesTracker: ProposerPreferencesTracker;
|
|
39
|
+
headTracker: HeadTracker;
|
|
38
40
|
clock: IClock;
|
|
39
41
|
index: BuilderIndex;
|
|
40
42
|
payloadStore: PayloadStore;
|
|
@@ -72,6 +74,7 @@ export type BuilderOptions = {
|
|
|
72
74
|
export class Builder {
|
|
73
75
|
readonly builderSigner: BuilderSigner;
|
|
74
76
|
readonly proposerPreferencesTracker: ProposerPreferencesTracker;
|
|
77
|
+
readonly headTracker: HeadTracker;
|
|
75
78
|
private readonly blockObserver: BlockObserver;
|
|
76
79
|
private readonly builderStatusTracker: BuilderStatusTracker;
|
|
77
80
|
private readonly controller: AbortController;
|
|
@@ -90,6 +93,7 @@ export class Builder {
|
|
|
90
93
|
blockObserver,
|
|
91
94
|
builderStatusTracker,
|
|
92
95
|
proposerPreferencesTracker,
|
|
96
|
+
headTracker,
|
|
93
97
|
clock,
|
|
94
98
|
index,
|
|
95
99
|
payloadStore,
|
|
@@ -101,6 +105,7 @@ export class Builder {
|
|
|
101
105
|
this.blockObserver = blockObserver;
|
|
102
106
|
this.builderStatusTracker = builderStatusTracker;
|
|
103
107
|
this.proposerPreferencesTracker = proposerPreferencesTracker;
|
|
108
|
+
this.headTracker = headTracker;
|
|
104
109
|
this.clock = clock;
|
|
105
110
|
this.controller = opts.abortController;
|
|
106
111
|
this.logger = opts.logger;
|
|
@@ -159,6 +164,7 @@ export class Builder {
|
|
|
159
164
|
await builderStatusTracker.poll(clock.getCurrentEpoch());
|
|
160
165
|
const blockObserver = new BlockObserver(config, logger, api);
|
|
161
166
|
const proposerPreferencesTracker = new ProposerPreferencesTracker();
|
|
167
|
+
const headTracker = new HeadTracker();
|
|
162
168
|
|
|
163
169
|
const payloadStore = new PayloadStore();
|
|
164
170
|
const ledger = new BidLedger();
|
|
@@ -187,6 +193,7 @@ export class Builder {
|
|
|
187
193
|
hasPayload: ({blockHash}) => payloadStore.has(blockHash),
|
|
188
194
|
}),
|
|
189
195
|
proposerPreferencesTracker,
|
|
196
|
+
headTracker,
|
|
190
197
|
getBuilderStatus: () => builderStatusTracker.getStatus(),
|
|
191
198
|
builderIndex: index,
|
|
192
199
|
executionFeeRecipient: opts.executionFeeRecipient,
|
|
@@ -217,6 +224,7 @@ export class Builder {
|
|
|
217
224
|
blockObserver,
|
|
218
225
|
builderStatusTracker,
|
|
219
226
|
proposerPreferencesTracker,
|
|
227
|
+
headTracker,
|
|
220
228
|
clock,
|
|
221
229
|
index,
|
|
222
230
|
payloadStore,
|
|
@@ -229,6 +237,7 @@ export class Builder {
|
|
|
229
237
|
private async onSlot(slot: number): Promise<void> {
|
|
230
238
|
this.payloadStore.prune(slot);
|
|
231
239
|
this.proposerPreferencesTracker.prune(slot);
|
|
240
|
+
this.headTracker.prune(slot);
|
|
232
241
|
this.ledger.settlePaymentsBefore(slot - PAYMENT_SETTLEMENT_SLOTS);
|
|
233
242
|
this.ledger.prune(slot);
|
|
234
243
|
}
|
|
@@ -238,6 +247,7 @@ export class Builder {
|
|
|
238
247
|
if (signal.aborted) return;
|
|
239
248
|
|
|
240
249
|
const topics = [
|
|
250
|
+
routes.events.EventType.headV2,
|
|
241
251
|
routes.events.EventType.block,
|
|
242
252
|
routes.events.EventType.proposerPreferences,
|
|
243
253
|
routes.events.EventType.payloadAttributes,
|
|
@@ -306,6 +316,9 @@ export class Builder {
|
|
|
306
316
|
|
|
307
317
|
try {
|
|
308
318
|
switch (event.type) {
|
|
319
|
+
case routes.events.EventType.headV2:
|
|
320
|
+
this.headTracker.onHead(event.message.data);
|
|
321
|
+
break;
|
|
309
322
|
case routes.events.EventType.block:
|
|
310
323
|
await this.blockObserver.processBlockEvent(event.message, signal);
|
|
311
324
|
break;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
|
-
import type {Epoch, RootHex, Slot} from "@lodestar/types";
|
|
3
|
-
import {LodestarError} from "@lodestar/utils";
|
|
2
|
+
import type {Epoch, RootHex, Slot, gloas} from "@lodestar/types";
|
|
3
|
+
import {LodestarError, toRootHex} from "@lodestar/utils";
|
|
4
4
|
|
|
5
5
|
export type SubmittedBid = {
|
|
6
|
+
signedBid: gloas.SignedExecutionPayloadBid;
|
|
7
|
+
signedBidRoot: RootHex;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type BidIdentity = {
|
|
6
11
|
slot: Slot;
|
|
7
12
|
parentBlockHash: RootHex;
|
|
8
13
|
parentBlockRoot: RootHex;
|
|
9
14
|
blockHash: RootHex;
|
|
10
|
-
valueGwei: number;
|
|
11
|
-
signedBidRoot: RootHex;
|
|
12
15
|
};
|
|
13
16
|
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
17
|
+
export type BidLedgerRecord = SubmittedBid &
|
|
18
|
+
BidIdentity & {
|
|
19
|
+
wonBlockRoots: RootHex[];
|
|
20
|
+
};
|
|
19
21
|
|
|
20
22
|
type RevealedPayload = {
|
|
21
23
|
slot: Slot;
|
|
@@ -25,6 +27,10 @@ type RevealedPayload = {
|
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
type MutableBidLedgerRecord = SubmittedBid & {
|
|
30
|
+
/** Derived from the signed bid when it is recorded */
|
|
31
|
+
identity: BidIdentity;
|
|
32
|
+
/** Value of the signed bid when it is recorded, later changes to the signed bid do not affect the liability */
|
|
33
|
+
valueGwei: number;
|
|
28
34
|
wonBlockRoots: Set<RootHex>;
|
|
29
35
|
paymentSettled: boolean;
|
|
30
36
|
};
|
|
@@ -85,7 +91,7 @@ export class BidLedger {
|
|
|
85
91
|
slot,
|
|
86
92
|
parentBlockHash,
|
|
87
93
|
parentBlockRoot,
|
|
88
|
-
}: Pick<
|
|
94
|
+
}: Pick<BidIdentity, "slot" | "parentBlockHash" | "parentBlockRoot">): void {
|
|
89
95
|
if (slot < this.pruneCutoffSlot) {
|
|
90
96
|
throw new BidLedgerError({code: BidLedgerErrorCode.BID_TOO_OLD, slot, pruneCutoffSlot: this.pruneCutoffSlot});
|
|
91
97
|
}
|
|
@@ -97,30 +103,49 @@ export class BidLedger {
|
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
recordBid(
|
|
101
|
-
|
|
106
|
+
recordBid({signedBid, signedBidRoot}: SubmittedBid): BidLedgerRecord {
|
|
107
|
+
const bid = signedBid.message;
|
|
108
|
+
const valueGwei = bid.value;
|
|
109
|
+
if (!Number.isSafeInteger(valueGwei) || valueGwei < 0) {
|
|
102
110
|
throw new BidLedgerError(
|
|
103
|
-
{code: BidLedgerErrorCode.INVALID_BID_VALUE, valueGwei
|
|
104
|
-
`Invalid bid value valueGwei=${
|
|
111
|
+
{code: BidLedgerErrorCode.INVALID_BID_VALUE, valueGwei},
|
|
112
|
+
`Invalid bid value valueGwei=${valueGwei}`
|
|
105
113
|
);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
const identity: BidIdentity = {
|
|
117
|
+
slot: bid.slot,
|
|
118
|
+
parentBlockHash: toRootHex(bid.parentBlockHash),
|
|
119
|
+
parentBlockRoot: toRootHex(bid.parentBlockRoot),
|
|
120
|
+
blockHash: toRootHex(bid.blockHash),
|
|
121
|
+
};
|
|
122
|
+
this.assertCanRecordBid(identity);
|
|
123
|
+
let bidsForSlot = this.bidsBySlot.get(identity.slot);
|
|
110
124
|
if (bidsForSlot === undefined) {
|
|
111
125
|
bidsForSlot = new Map();
|
|
112
|
-
this.bidsBySlot.set(
|
|
126
|
+
this.bidsBySlot.set(identity.slot, bidsForSlot);
|
|
113
127
|
}
|
|
114
128
|
|
|
115
|
-
const key = tupleKey(
|
|
116
|
-
const record = {
|
|
129
|
+
const key = tupleKey(identity.parentBlockHash, identity.parentBlockRoot);
|
|
130
|
+
const record = {
|
|
131
|
+
signedBid,
|
|
132
|
+
signedBidRoot,
|
|
133
|
+
identity,
|
|
134
|
+
valueGwei,
|
|
135
|
+
wonBlockRoots: new Set<RootHex>(),
|
|
136
|
+
paymentSettled: false,
|
|
137
|
+
};
|
|
117
138
|
bidsForSlot.set(key, record);
|
|
118
139
|
return toRecord(record);
|
|
119
140
|
}
|
|
120
141
|
|
|
121
142
|
recordWin(identity: BidIdentity & Pick<SubmittedBid, "signedBidRoot">, blockRoot: RootHex): BidLedgerRecord | null {
|
|
122
143
|
const record = this.getBid(identity.slot, identity.parentBlockHash, identity.parentBlockRoot);
|
|
123
|
-
if (
|
|
144
|
+
if (
|
|
145
|
+
record === null ||
|
|
146
|
+
record.identity.blockHash !== identity.blockHash ||
|
|
147
|
+
record.signedBidRoot !== identity.signedBidRoot
|
|
148
|
+
) {
|
|
124
149
|
return null;
|
|
125
150
|
}
|
|
126
151
|
|
|
@@ -130,13 +155,13 @@ export class BidLedger {
|
|
|
130
155
|
|
|
131
156
|
hasWon(identity: BidIdentity, blockRoot: RootHex): boolean {
|
|
132
157
|
const record = this.getBid(identity.slot, identity.parentBlockHash, identity.parentBlockRoot);
|
|
133
|
-
return record !== null && record.blockHash === identity.blockHash && record.wonBlockRoots.has(blockRoot);
|
|
158
|
+
return record !== null && record.identity.blockHash === identity.blockHash && record.wonBlockRoots.has(blockRoot);
|
|
134
159
|
}
|
|
135
160
|
|
|
136
161
|
/** Release a winning bid liability only after its payment is known to be reflected in Builder balance. */
|
|
137
162
|
recordPaymentSettled(identity: BidIdentity): BidLedgerRecord | null {
|
|
138
163
|
const record = this.getBid(identity.slot, identity.parentBlockHash, identity.parentBlockRoot);
|
|
139
|
-
if (record === null || record.blockHash !== identity.blockHash || record.wonBlockRoots.size === 0) {
|
|
164
|
+
if (record === null || record.identity.blockHash !== identity.blockHash || record.wonBlockRoots.size === 0) {
|
|
140
165
|
return null;
|
|
141
166
|
}
|
|
142
167
|
|
|
@@ -225,6 +250,11 @@ export class BidLedger {
|
|
|
225
250
|
return total;
|
|
226
251
|
}
|
|
227
252
|
|
|
253
|
+
/** Returns the signed bid recorded for the slot and parent, null if no bid was recorded for it */
|
|
254
|
+
getSignedBid(slot: Slot, parentBlockHash: RootHex, parentBlockRoot: RootHex): gloas.SignedExecutionPayloadBid | null {
|
|
255
|
+
return this.getBid(slot, parentBlockHash, parentBlockRoot)?.signedBid ?? null;
|
|
256
|
+
}
|
|
257
|
+
|
|
228
258
|
getBidsForSlot(slot: Slot): BidLedgerRecord[] {
|
|
229
259
|
return Array.from(this.bidsBySlot.get(slot)?.values() ?? [], toRecord);
|
|
230
260
|
}
|
|
@@ -268,11 +298,8 @@ function tupleKey(parentBlockHash: RootHex, parentBlockRoot: RootHex): string {
|
|
|
268
298
|
|
|
269
299
|
function toRecord(record: MutableBidLedgerRecord): BidLedgerRecord {
|
|
270
300
|
return {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
parentBlockRoot: record.parentBlockRoot,
|
|
274
|
-
blockHash: record.blockHash,
|
|
275
|
-
valueGwei: record.valueGwei,
|
|
301
|
+
...record.identity,
|
|
302
|
+
signedBid: record.signedBid,
|
|
276
303
|
signedBidRoot: record.signedBidRoot,
|
|
277
304
|
wonBlockRoots: Array.from(record.wonBlockRoots),
|
|
278
305
|
};
|
|
@@ -86,7 +86,7 @@ export class BidPublisher {
|
|
|
86
86
|
const signedBidRoot = toRootHex(
|
|
87
87
|
sszTypesFor(fork, "SignedExecutionPayloadBid").hashTreeRoot(signedExecutionPayloadBid)
|
|
88
88
|
);
|
|
89
|
-
ledger.recordBid({
|
|
89
|
+
ledger.recordBid({signedBid: signedExecutionPayloadBid, signedBidRoot});
|
|
90
90
|
|
|
91
91
|
const response = await api.beacon.publishExecutionPayloadBid({signedExecutionPayloadBid}, {signal});
|
|
92
92
|
response.assertOk();
|
package/src/services/bidder.ts
CHANGED
|
@@ -2,13 +2,14 @@ import {ApiClient, routes} from "@lodestar/api";
|
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
3
|
import {ForkName, MIN_DEPOSIT_AMOUNT, isForkPostGloas} from "@lodestar/params";
|
|
4
4
|
import {IClock, computeEpochAtSlot} from "@lodestar/state-transition";
|
|
5
|
-
import {BuilderIndex, BuilderStatus,
|
|
6
|
-
import {GWEI_TO_WEI, Logger, isErrorAborted, prettyGweiToEth, toHex, toRootHex} from "@lodestar/utils";
|
|
5
|
+
import {BuilderIndex, BuilderStatus, ExecutionAddress, RootHex, Slot, gloas} from "@lodestar/types";
|
|
6
|
+
import {GWEI_TO_WEI, LogData, Logger, isErrorAborted, prettyGweiToEth, toHex, toRootHex} from "@lodestar/utils";
|
|
7
7
|
import {BidResult, Metrics} from "../metrics.js";
|
|
8
8
|
import {BidLedger} from "./bidLedger.js";
|
|
9
9
|
import {BidPolicy} from "./bidPolicy.js";
|
|
10
10
|
import {BidPublisher} from "./bidPublisher.js";
|
|
11
11
|
import {createExecutionPayloadBid} from "./executionPayloadBid.js";
|
|
12
|
+
import {HeadTracker} from "./headTracker.js";
|
|
12
13
|
import {PayloadOrchestrator} from "./payloadOrchestrator.js";
|
|
13
14
|
import {PayloadStore} from "./payloadStore.js";
|
|
14
15
|
import {ProposerPreferencesTracker} from "./proposerPreferencesTracker.js";
|
|
@@ -33,6 +34,7 @@ export type BidderModules = {
|
|
|
33
34
|
policy: BidPolicy;
|
|
34
35
|
bidPublisher: BidPublisher;
|
|
35
36
|
proposerPreferencesTracker: ProposerPreferencesTracker;
|
|
37
|
+
headTracker: HeadTracker;
|
|
36
38
|
getBuilderStatus: () => {status: BuilderStatus | undefined; balance: number | undefined};
|
|
37
39
|
builderIndex: BuilderIndex;
|
|
38
40
|
executionFeeRecipient: ExecutionAddress;
|
|
@@ -83,7 +85,7 @@ export class Bidder {
|
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
const dependentRoot = await this.getDependentRoot(
|
|
88
|
+
const dependentRoot = await this.getDependentRoot(parentBlockRoot, slot, logCtx);
|
|
87
89
|
const proposerPreferences = proposerPreferencesTracker.get(slot, dependentRoot);
|
|
88
90
|
if (proposerPreferences === null) {
|
|
89
91
|
logger.debug("No proposer preferences known for slot, not bidding", {...logCtx, dependentRoot});
|
|
@@ -182,10 +184,20 @@ export class Bidder {
|
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
/**
|
|
185
|
-
* Dependent root of the proposer duties
|
|
186
|
-
*
|
|
187
|
+
* Dependent root of the proposer duties for the proposal slot on the branch of the parent block, identifies
|
|
188
|
+
* the proposer preferences to bid against. Taken from the head events. A parent that was not announced as
|
|
189
|
+
* head, e.g. before the first head event after connecting, falls back to the proposer duties, which carry
|
|
190
|
+
* the dependent root of the beacon node's head branch.
|
|
187
191
|
*/
|
|
188
|
-
private async getDependentRoot(
|
|
189
|
-
|
|
192
|
+
private async getDependentRoot(parentBlockRoot: RootHex, slot: Slot, logCtx: LogData): Promise<RootHex> {
|
|
193
|
+
const {api, headTracker, logger, signal} = this.modules;
|
|
194
|
+
const dependentRoot = headTracker.getDependentRoot(parentBlockRoot, slot);
|
|
195
|
+
if (dependentRoot !== null) {
|
|
196
|
+
return dependentRoot;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
logger.debug("Parent block is not a tracked head, fetching proposer duties for dependent root", logCtx);
|
|
200
|
+
const duties = await api.validator.getProposerDutiesV2({epoch: computeEpochAtSlot(slot)}, {signal});
|
|
201
|
+
return duties.meta().dependentRoot;
|
|
190
202
|
}
|
|
191
203
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {routes} from "@lodestar/api";
|
|
2
|
+
import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
3
|
+
import type {RootHex, Slot} from "@lodestar/types";
|
|
4
|
+
|
|
5
|
+
export type HeadEvent = routes.events.EventData[routes.events.EventType.headV2];
|
|
6
|
+
|
|
7
|
+
type TrackedHead = {
|
|
8
|
+
slot: Slot;
|
|
9
|
+
/** Dependent root of the proposer duties in the epoch of the head block */
|
|
10
|
+
currentEpochDependentRoot: RootHex;
|
|
11
|
+
/** Dependent root of the proposer duties in the epoch after the head block */
|
|
12
|
+
nextEpochDependentRoot: RootHex;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Tracks the heads announced by the beacon node over `head_v2` events and the proposer duties dependent
|
|
17
|
+
* roots they carry. A bid is validated against the proposer preferences of its parent branch, the dependent
|
|
18
|
+
* root of a tracked head identifies those without fetching the proposer duties for every build.
|
|
19
|
+
*/
|
|
20
|
+
export class HeadTracker {
|
|
21
|
+
private readonly heads = new Map<RootHex, TrackedHead>();
|
|
22
|
+
|
|
23
|
+
onHead(data: HeadEvent["data"]): void {
|
|
24
|
+
const {slot, block, currentEpochDependentRoot, nextEpochDependentRoot} = data;
|
|
25
|
+
this.heads.set(block, {slot, currentEpochDependentRoot, nextEpochDependentRoot});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Dependent root of the proposer duties for `proposalSlot` on the branch of `blockRoot`.
|
|
30
|
+
* Returns null if the block was not announced as head.
|
|
31
|
+
*/
|
|
32
|
+
getDependentRoot(blockRoot: RootHex, proposalSlot: Slot): RootHex | null {
|
|
33
|
+
const head = this.heads.get(blockRoot);
|
|
34
|
+
if (head === undefined) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const epochDifference = computeEpochAtSlot(proposalSlot) - computeEpochAtSlot(head.slot);
|
|
39
|
+
if (epochDifference === 0) {
|
|
40
|
+
return head.currentEpochDependentRoot;
|
|
41
|
+
}
|
|
42
|
+
if (epochDifference === 1) {
|
|
43
|
+
return head.nextEpochDependentRoot;
|
|
44
|
+
}
|
|
45
|
+
return blockRoot;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Drops heads from before the previous epoch. An older head is only the parent of a proposal after a full
|
|
50
|
+
* epoch without blocks, the proposer duties fallback covers that.
|
|
51
|
+
*/
|
|
52
|
+
prune(currentSlot: Slot): number {
|
|
53
|
+
const minSlot = computeStartSlotAtEpoch(Math.max(computeEpochAtSlot(currentSlot) - 1, 0));
|
|
54
|
+
let removed = 0;
|
|
55
|
+
for (const [blockRoot, head] of this.heads) {
|
|
56
|
+
if (head.slot < minSlot) {
|
|
57
|
+
this.heads.delete(blockRoot);
|
|
58
|
+
removed++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return removed;
|
|
62
|
+
}
|
|
63
|
+
}
|