@lodestar/builder 1.50.0-dev.b4eaa62b30 → 1.50.0-dev.be50566b7e
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 +2 -0
- package/lib/builder.d.ts.map +1 -1
- package/lib/builder.js +56 -4
- package/lib/builder.js.map +1 -1
- package/lib/services/bidLedger.d.ts +7 -0
- package/lib/services/bidLedger.d.ts.map +1 -1
- package/lib/services/bidLedger.js +15 -10
- package/lib/services/bidLedger.js.map +1 -1
- package/lib/services/bidPublisher.d.ts +43 -0
- package/lib/services/bidPublisher.d.ts.map +1 -0
- package/lib/services/bidPublisher.js +50 -0
- package/lib/services/bidPublisher.js.map +1 -0
- package/lib/services/bidSelector.d.ts +67 -0
- package/lib/services/bidSelector.d.ts.map +1 -0
- package/lib/services/bidSelector.js +59 -0
- package/lib/services/bidSelector.js.map +1 -0
- package/lib/services/blockObserver.d.ts +1 -2
- package/lib/services/blockObserver.d.ts.map +1 -1
- package/lib/services/blockObserver.js +3 -35
- package/lib/services/blockObserver.js.map +1 -1
- package/lib/services/builderSigner.d.ts +2 -1
- package/lib/services/builderSigner.d.ts.map +1 -1
- package/lib/services/builderSigner.js.map +1 -1
- package/lib/services/executionPayloadBid.d.ts +57 -0
- package/lib/services/executionPayloadBid.d.ts.map +1 -0
- package/lib/services/executionPayloadBid.js +69 -0
- package/lib/services/executionPayloadBid.js.map +1 -0
- package/lib/services/proposerPreferencesTracker.d.ts +0 -6
- package/lib/services/proposerPreferencesTracker.d.ts.map +1 -1
- package/lib/services/proposerPreferencesTracker.js +0 -38
- package/lib/services/proposerPreferencesTracker.js.map +1 -1
- package/package.json +10 -10
- package/src/builder.ts +63 -5
- package/src/services/bidLedger.ts +28 -14
- package/src/services/bidPublisher.ts +95 -0
- package/src/services/bidSelector.ts +138 -0
- package/src/services/blockObserver.ts +3 -41
- package/src/services/builderSigner.ts +3 -1
- package/src/services/executionPayloadBid.ts +125 -0
- package/src/services/proposerPreferencesTracker.ts +1 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockObserver.js","sourceRoot":"","sources":["../../src/services/blockObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAgB,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAmC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAS,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAEpH,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,MAAM,CAAC;AAqBlC;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAQL,MAAM;IACN,MAAM;IACN,GAAG;IATL,GAAG,GAAmB,EAAE,CAAC;IACzB,cAAc,GAAG,IAAI,GAAG,EAAW,CAAC;IACpC,OAAO,CAAS;IAChB,UAAU,CAAS;IACnB,iBAAiB,CAAS;IAE3C,YACmB,MAAuB,EACvB,MAAc,EACd,GAAc,EAC/B,EAAC,OAAO,GAAG,CAAC,EAAE,UAAU,GAAG,GAAG,EAAE,iBAAiB,GAAG,GAAG,EAAC,GAAyB,EAAE;sBAHlE,MAAM;sBACN,MAAM;mBACN,GAAG;QAGpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"blockObserver.js","sourceRoot":"","sources":["../../src/services/blockObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAgB,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAmC,kBAAkB,EAAC,MAAM,i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AK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CACtD,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,8BAA8B,CAAC,KAAY;IACzD,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;IACrD,CAAC;IAED,OAAO,KAAK,YAAY,YAAY,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublicKey, SecretKey } from "@chainsafe/lodestar-z/blst";
|
|
2
2
|
import { BeaconConfig } from "@lodestar/config";
|
|
3
|
-
import { gloas } from "@lodestar/types";
|
|
3
|
+
import { gloas, heze } from "@lodestar/types";
|
|
4
4
|
export type Keypair = {
|
|
5
5
|
publicKey: PublicKey;
|
|
6
6
|
secretKey: SecretKey;
|
|
@@ -10,6 +10,7 @@ export declare class BuilderSigner {
|
|
|
10
10
|
private readonly keypair;
|
|
11
11
|
constructor(config: BeaconConfig, keypair: Keypair);
|
|
12
12
|
signExecutionPayloadEnvelope(envelope: gloas.ExecutionPayloadEnvelope): gloas.SignedExecutionPayloadEnvelope;
|
|
13
|
+
signExecutionPayloadBid(bid: heze.ExecutionPayloadBid): heze.SignedExecutionPayloadBid;
|
|
13
14
|
signExecutionPayloadBid(bid: gloas.ExecutionPayloadBid): gloas.SignedExecutionPayloadBid;
|
|
14
15
|
getPubkeyHex(): string;
|
|
15
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builderSigner.d.ts","sourceRoot":"","sources":["../../src/services/builderSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"builderSigner.d.ts","sourceRoot":"","sources":["../../src/services/builderSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,OAAO,GAAG;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAC,CAAC;AAEnE,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC,YAAY,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAGjD;IAED,4BAA4B,CAAC,QAAQ,EAAE,KAAK,CAAC,wBAAwB,GAAG,KAAK,CAAC,8BAA8B,CAO3G;IAED,uBAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,yBAAyB,CAAC;IACvF,uBAAuB,CAAC,GAAG,EAAE,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,yBAAyB,CAAC;IAUzF,YAAY,IAAI,MAAM,CAErB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builderSigner.js","sourceRoot":"","sources":["../../src/services/builderSigner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,iCAAiC,EAAE,sCAAsC,EAAC,MAAM,4BAA4B,CAAC;AAKrH,MAAM,OAAO,aAAa;IACP,MAAM,CAAe;IACrB,OAAO,CAAU;IAElC,YAAY,MAAoB,EAAE,OAAgB;QAChD,IAAI,CAAC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AO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ForkName, type ForkPostGloas } from "@lodestar/params";
|
|
2
|
+
import type { BuilderIndex, Bytes32, ExecutionAddress, ExecutionPayloadBid, Root, RootHex, Slot, gloas, heze } from "@lodestar/types";
|
|
3
|
+
import { LodestarError } from "@lodestar/utils";
|
|
4
|
+
import type { BuiltPayload } from "./payloadSource.js";
|
|
5
|
+
type CommonBidInput<F extends ForkPostGloas> = {
|
|
6
|
+
slot: Slot;
|
|
7
|
+
parentBlockRoot: Root;
|
|
8
|
+
/** Expected value from the BN payload attributes used for this build. */
|
|
9
|
+
prevRandao: Bytes32;
|
|
10
|
+
builderIndex: BuilderIndex;
|
|
11
|
+
feeRecipient: ExecutionAddress;
|
|
12
|
+
/** Bid value in gwei */
|
|
13
|
+
value: number;
|
|
14
|
+
payload: BuiltPayload & {
|
|
15
|
+
fork: F;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type GloasBidInput = CommonBidInput<ForkName.gloas>;
|
|
19
|
+
export type HezeBidInput = CommonBidInput<ForkName.heze> & {
|
|
20
|
+
inclusionListBits: heze.ExecutionPayloadBid["inclusionListBits"];
|
|
21
|
+
};
|
|
22
|
+
export type ExecutionPayloadBidInput = GloasBidInput | HezeBidInput;
|
|
23
|
+
export declare enum ExecutionPayloadBidErrorCode {
|
|
24
|
+
INVALID_VALUE = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_VALUE",
|
|
25
|
+
INVALID_GAS_LIMIT = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_GAS_LIMIT",
|
|
26
|
+
SLOT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_SLOT_MISMATCH",
|
|
27
|
+
BLOCK_HASH_EQUALS_PARENT = "EXECUTION_PAYLOAD_BID_ERROR_BLOCK_HASH_EQUALS_PARENT",
|
|
28
|
+
INVALID_INCLUSION_LIST_BITS = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_INCLUSION_LIST_BITS",
|
|
29
|
+
PREV_RANDAO_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PREV_RANDAO_MISMATCH"
|
|
30
|
+
}
|
|
31
|
+
export type ExecutionPayloadBidErrorType = {
|
|
32
|
+
code: ExecutionPayloadBidErrorCode.INVALID_GAS_LIMIT;
|
|
33
|
+
gasLimit: number;
|
|
34
|
+
} | {
|
|
35
|
+
code: ExecutionPayloadBidErrorCode.SLOT_MISMATCH;
|
|
36
|
+
slot: Slot;
|
|
37
|
+
payloadSlot: Slot;
|
|
38
|
+
} | {
|
|
39
|
+
code: ExecutionPayloadBidErrorCode.BLOCK_HASH_EQUALS_PARENT;
|
|
40
|
+
} | {
|
|
41
|
+
code: ExecutionPayloadBidErrorCode.INVALID_INCLUSION_LIST_BITS;
|
|
42
|
+
bitLen: number | undefined;
|
|
43
|
+
} | {
|
|
44
|
+
code: ExecutionPayloadBidErrorCode.PREV_RANDAO_MISMATCH;
|
|
45
|
+
expectedPrevRandao: RootHex;
|
|
46
|
+
payloadPrevRandao: RootHex;
|
|
47
|
+
} | {
|
|
48
|
+
code: ExecutionPayloadBidErrorCode.INVALID_VALUE;
|
|
49
|
+
value: number;
|
|
50
|
+
};
|
|
51
|
+
export declare class ExecutionPayloadBidError extends LodestarError<ExecutionPayloadBidErrorType> {
|
|
52
|
+
}
|
|
53
|
+
export declare function createExecutionPayloadBid(input: GloasBidInput): gloas.ExecutionPayloadBid;
|
|
54
|
+
export declare function createExecutionPayloadBid(input: HezeBidInput): heze.ExecutionPayloadBid;
|
|
55
|
+
export declare function createExecutionPayloadBid(input: ExecutionPayloadBidInput): ExecutionPayloadBid;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=executionPayloadBid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executionPayloadBid.d.ts","sourceRoot":"","sources":["../../src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,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,GACxE;IAAC,IAAI,EAAE,4BAA4B,CAAC,aAAa,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,WAAW,EAAE,IAAI,CAAA;CAAC,GACjF;IAAC,IAAI,EAAE,4BAA4B,CAAC,wBAAwB,CAAA;CAAC,GAC7D;IAAC,IAAI,EAAE,4BAA4B,CAAC,2BAA2B,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,GAC5F;IACE,IAAI,EAAE,4BAA4B,CAAC,oBAAoB,CAAC;IACxD,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,4BAA4B,CAAC,aAAa,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,qBAAa,wBAAyB,SAAQ,aAAa,CAAC,4BAA4B,CAAC;CAAG;AAE5F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,CAAC,mBAAmB,CAAC;AAC3F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC;AACzF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,wBAAwB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { INCLUSION_LIST_COMMITTEE_SIZE, isForkPostHeze } from "@lodestar/params";
|
|
2
|
+
import { sszTypesFor } from "@lodestar/types";
|
|
3
|
+
import { LodestarError, byteArrayEquals, toRootHex } from "@lodestar/utils";
|
|
4
|
+
export var ExecutionPayloadBidErrorCode;
|
|
5
|
+
(function (ExecutionPayloadBidErrorCode) {
|
|
6
|
+
ExecutionPayloadBidErrorCode["INVALID_VALUE"] = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_VALUE";
|
|
7
|
+
ExecutionPayloadBidErrorCode["INVALID_GAS_LIMIT"] = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_GAS_LIMIT";
|
|
8
|
+
ExecutionPayloadBidErrorCode["SLOT_MISMATCH"] = "EXECUTION_PAYLOAD_BID_ERROR_SLOT_MISMATCH";
|
|
9
|
+
ExecutionPayloadBidErrorCode["BLOCK_HASH_EQUALS_PARENT"] = "EXECUTION_PAYLOAD_BID_ERROR_BLOCK_HASH_EQUALS_PARENT";
|
|
10
|
+
ExecutionPayloadBidErrorCode["INVALID_INCLUSION_LIST_BITS"] = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_INCLUSION_LIST_BITS";
|
|
11
|
+
ExecutionPayloadBidErrorCode["PREV_RANDAO_MISMATCH"] = "EXECUTION_PAYLOAD_BID_ERROR_PREV_RANDAO_MISMATCH";
|
|
12
|
+
})(ExecutionPayloadBidErrorCode || (ExecutionPayloadBidErrorCode = {}));
|
|
13
|
+
export class ExecutionPayloadBidError extends LodestarError {
|
|
14
|
+
}
|
|
15
|
+
export function createExecutionPayloadBid(input) {
|
|
16
|
+
if (!Number.isSafeInteger(input.value) || input.value < 0) {
|
|
17
|
+
throw new ExecutionPayloadBidError({ code: ExecutionPayloadBidErrorCode.INVALID_VALUE, value: input.value }, `Invalid bid value value=${input.value}`);
|
|
18
|
+
}
|
|
19
|
+
const { fork, executionPayload, executionRequests, blobsBundle } = input.payload;
|
|
20
|
+
if (executionPayload.gasLimit > Number.MAX_SAFE_INTEGER) {
|
|
21
|
+
throw new ExecutionPayloadBidError({
|
|
22
|
+
code: ExecutionPayloadBidErrorCode.INVALID_GAS_LIMIT,
|
|
23
|
+
gasLimit: executionPayload.gasLimit,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (executionPayload.slotNumber !== input.slot) {
|
|
27
|
+
throw new ExecutionPayloadBidError({
|
|
28
|
+
code: ExecutionPayloadBidErrorCode.SLOT_MISMATCH,
|
|
29
|
+
slot: input.slot,
|
|
30
|
+
payloadSlot: executionPayload.slotNumber,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (byteArrayEquals(executionPayload.blockHash, executionPayload.parentHash)) {
|
|
34
|
+
throw new ExecutionPayloadBidError({ code: ExecutionPayloadBidErrorCode.BLOCK_HASH_EQUALS_PARENT });
|
|
35
|
+
}
|
|
36
|
+
if (!byteArrayEquals(executionPayload.prevRandao, input.prevRandao)) {
|
|
37
|
+
throw new ExecutionPayloadBidError({
|
|
38
|
+
code: ExecutionPayloadBidErrorCode.PREV_RANDAO_MISMATCH,
|
|
39
|
+
expectedPrevRandao: toRootHex(input.prevRandao),
|
|
40
|
+
payloadPrevRandao: toRootHex(executionPayload.prevRandao),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const bid = {
|
|
44
|
+
parentBlockHash: executionPayload.parentHash,
|
|
45
|
+
parentBlockRoot: input.parentBlockRoot,
|
|
46
|
+
blockHash: executionPayload.blockHash,
|
|
47
|
+
prevRandao: input.prevRandao,
|
|
48
|
+
feeRecipient: input.feeRecipient,
|
|
49
|
+
gasLimit: BigInt(executionPayload.gasLimit),
|
|
50
|
+
builderIndex: input.builderIndex,
|
|
51
|
+
slot: input.slot,
|
|
52
|
+
value: input.value,
|
|
53
|
+
executionPayment: 0n,
|
|
54
|
+
blobKzgCommitments: blobsBundle.commitments,
|
|
55
|
+
executionRequestsRoot: sszTypesFor(fork).ExecutionRequests.hashTreeRoot(executionRequests),
|
|
56
|
+
};
|
|
57
|
+
if (isForkPostHeze(fork)) {
|
|
58
|
+
const inclusionListBits = "inclusionListBits" in input ? input.inclusionListBits : undefined;
|
|
59
|
+
if (inclusionListBits?.bitLen !== INCLUSION_LIST_COMMITTEE_SIZE) {
|
|
60
|
+
throw new ExecutionPayloadBidError({
|
|
61
|
+
code: ExecutionPayloadBidErrorCode.INVALID_INCLUSION_LIST_BITS,
|
|
62
|
+
bitLen: inclusionListBits?.bitLen,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return { ...bid, inclusionListBits };
|
|
66
|
+
}
|
|
67
|
+
return bid;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=executionPayloadBid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executionPayloadBid.js","sourceRoot":"","sources":["../../src/services/executionPayloadBid.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,6BAA6B,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAY7G,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAE,eAAe,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAuB1E,MAAM,CAAN,IAAY,4BAOX;AAPD,WAAY,4BAA4B;IACtC,2FAA2D,CAAA;IAC3D,mGAAmE,CAAA;IACnE,2FAA2D,CAAA;IAC3D,iHAAiF,CAAA;IACjF,uHAAuF,CAAA;IACvF,yGAAyE,CAAA;AAC3E,CAAC,EAPW,4BAA4B,KAA5B,4BAA4B,QAOvC;AAiBD,MAAM,OAAO,wBAAyB,SAAQ,aAA2C;CAAG;AAK5F,MAAM,UAAU,yBAAyB,CAAC,KAA+B;IACvE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,wBAAwB,CAChC,EAAC,IAAI,EAAE,4BAA4B,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAC,EACtE,2BAA2B,KAAK,CAAC,KAAK,EAAE,CACzC,CAAC;IACJ,CAAC;IAED,MAAM,EAAC,IAAI,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC,OAAO,CAAC;IAC/E,IAAI,gBAAgB,CAAC,QAAQ,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QACxD,MAAM,IAAI,wBAAwB,CAAC;YACjC,IAAI,EAAE,4BAA4B,CAAC,iBA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B,kBAAkB,EAAE,WAAW,CAAC,WAAW;QAC3C,qBAAqB,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,YAAY,CAAC,iBAAiB,CAAC;KAC3F,CAAC;IAEF,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,iBAAiB,GAAG,mBAAmB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7F,IAAI,iBAAiB,EAAE,MAAM,KAAK,6BAA6B,EAAE,CAAC;YAChE,MAAM,IAAI,wBAAwB,CAAC;gBACjC,IAAI,EAAE,4BAA4B,CAAC,2BAA2B;gBAC9D,MAAM,EAAE,iBAAiB,EAAE,MAAM;aAClC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAC,GAAG,GAAG,EAAE,iBAAiB,EAAC,CAAC;IACrC,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { ApiClient } from "@lodestar/api";
|
|
2
1
|
import type { RootHex, Slot, gloas } from "@lodestar/types";
|
|
3
|
-
import { Logger } from "@lodestar/utils";
|
|
4
2
|
/** Retains validated proposer preferences by the branch-specific identity used for bid validation. */
|
|
5
3
|
export declare class ProposerPreferencesTracker {
|
|
6
|
-
private readonly api;
|
|
7
|
-
private readonly logger;
|
|
8
4
|
private readonly byDependentRootBySlot;
|
|
9
|
-
constructor(api: ApiClient, logger: Logger);
|
|
10
|
-
start(signal: AbortSignal): void;
|
|
11
5
|
onProposerPreferences(signedProposerPreferences: gloas.SignedProposerPreferences): boolean;
|
|
12
6
|
get(slot: Slot, dependentRoot: RootHex): gloas.SignedProposerPreferences | null;
|
|
13
7
|
prune(currentSlot: Slot): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposerPreferencesTracker.d.ts","sourceRoot":"","sources":["../../src/services/proposerPreferencesTracker.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"proposerPreferencesTracker.d.ts","sourceRoot":"","sources":["../../src/services/proposerPreferencesTracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAG1D,sGAAsG;AACtG,qBAAa,0BAA0B;IACrC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAEpC;IAEF,qBAAqB,CAAC,yBAAyB,EAAE,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAWzF;IAED,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,GAAG,KAAK,CAAC,yBAAyB,GAAG,IAAI,CAE9E;IAED,KAAK,CAAC,WAAW,EAAE,IAAI,GAAG,MAAM,CAW/B;CACF"}
|
|
@@ -1,45 +1,7 @@
|
|
|
1
|
-
import { routes } from "@lodestar/api";
|
|
2
1
|
import { MapDef, toRootHex } from "@lodestar/utils";
|
|
3
2
|
/** Retains validated proposer preferences by the branch-specific identity used for bid validation. */
|
|
4
3
|
export class ProposerPreferencesTracker {
|
|
5
|
-
api;
|
|
6
|
-
logger;
|
|
7
4
|
byDependentRootBySlot = new MapDef(() => new Map());
|
|
8
|
-
constructor(api, logger) {
|
|
9
|
-
this.api = api;
|
|
10
|
-
this.logger = logger;
|
|
11
|
-
}
|
|
12
|
-
start(signal) {
|
|
13
|
-
if (signal.aborted)
|
|
14
|
-
return;
|
|
15
|
-
this.logger.verbose("Subscribing to proposer preferences");
|
|
16
|
-
this.api.events
|
|
17
|
-
.eventstream({
|
|
18
|
-
topics: [routes.events.EventType.proposerPreferences],
|
|
19
|
-
signal,
|
|
20
|
-
onEvent: (event) => {
|
|
21
|
-
if (!signal.aborted && event.type === routes.events.EventType.proposerPreferences) {
|
|
22
|
-
this.onProposerPreferences(event.message.data);
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
onError: (error) => {
|
|
26
|
-
if (!signal.aborted)
|
|
27
|
-
this.logger.error("Failed to receive proposer preferences", {}, error);
|
|
28
|
-
},
|
|
29
|
-
onClose: () => {
|
|
30
|
-
if (signal.aborted) {
|
|
31
|
-
this.logger.verbose("Closed proposer preferences stream");
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
this.logger.error("Proposer preferences stream closed unexpectedly", {});
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
.catch((error) => {
|
|
39
|
-
if (!signal.aborted)
|
|
40
|
-
this.logger.error("Failed to subscribe to proposer preferences", {}, error);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
5
|
onProposerPreferences(signedProposerPreferences) {
|
|
44
6
|
const { proposalSlot, dependentRoot } = signedProposerPreferences.message;
|
|
45
7
|
const dependentRootHex = toRootHex(dependentRoot);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposerPreferencesTracker.js","sourceRoot":"","sources":["../../src/services/proposerPreferencesTracker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proposerPreferencesTracker.js","sourceRoot":"","sources":["../../src/services/proposerPreferencesTracker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAElD,sGAAsG;AACtG,MAAM,OAAO,0BAA0B;IACpB,qBAAqB,GAAG,IAAI,MAAM,CACjD,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAChB,CAAC;IAEF,qBAAqB,CAAC,yBAA0D;QAC9E,MAAM,EAAC,YAAY,EAAE,aAAa,EAAC,GAAG,yBAAyB,CAAC,OAAO,CAAC;QACxE,MAAM,gBAAgB,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC;QAClD,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAE9E,IAAI,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC1C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,eAAe,CAAC,GAAG,CAAC,gBAAgB,EAAE,yBAAyB,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,IAAU,EAAE,aAAsB;QACpC,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,WAAiB;QACrB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,KAAK,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YACjE,IAAI,IAAI,IAAI,WAAW,EAAE,CAAC;gBACxB,SAAS;YACX,CAAC;YAED,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC;YAChC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1C,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.50.0-dev.
|
|
3
|
+
"version": "1.50.0-dev.be50566b7e",
|
|
4
4
|
"description": "A Typescript implementation of the builder client",
|
|
5
5
|
"author": "ChainSafe Systems",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@chainsafe/lodestar-z": "catalog:",
|
|
50
50
|
"@chainsafe/ssz": "^1.8.0",
|
|
51
|
-
"@lodestar/api": "^1.50.0-dev.
|
|
52
|
-
"@lodestar/config": "^1.50.0-dev.
|
|
53
|
-
"@lodestar/params": "^1.50.0-dev.
|
|
54
|
-
"@lodestar/state-transition": "^1.50.0-dev.
|
|
55
|
-
"@lodestar/types": "^1.50.0-dev.
|
|
56
|
-
"@lodestar/utils": "^1.50.0-dev.
|
|
51
|
+
"@lodestar/api": "^1.50.0-dev.be50566b7e",
|
|
52
|
+
"@lodestar/config": "^1.50.0-dev.be50566b7e",
|
|
53
|
+
"@lodestar/params": "^1.50.0-dev.be50566b7e",
|
|
54
|
+
"@lodestar/state-transition": "^1.50.0-dev.be50566b7e",
|
|
55
|
+
"@lodestar/types": "^1.50.0-dev.be50566b7e",
|
|
56
|
+
"@lodestar/utils": "^1.50.0-dev.be50566b7e"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@lodestar/logger": "^1.50.0-dev.
|
|
60
|
-
"@lodestar/test-utils": "^1.50.0-dev.
|
|
59
|
+
"@lodestar/logger": "^1.50.0-dev.be50566b7e",
|
|
60
|
+
"@lodestar/test-utils": "^1.50.0-dev.be50566b7e"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "b3a06e92493998a129ab959e8b221cd1f4cf47dc"
|
|
63
63
|
}
|
package/src/builder.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {ApiClient} from "@lodestar/api";
|
|
1
|
+
import {ApiClient, routes} from "@lodestar/api";
|
|
2
2
|
import {ChainForkConfig, assertEqualParams, createBeaconConfig} from "@lodestar/config";
|
|
3
3
|
import {Clock, ClockOptions, IClock} from "@lodestar/state-transition";
|
|
4
4
|
import {BuilderIndex, ExecutionAddress} from "@lodestar/types";
|
|
5
|
-
import {Logger, toHex, toRootHex} from "@lodestar/utils";
|
|
5
|
+
import {Logger, isErrorAborted, toHex, toRootHex} from "@lodestar/utils";
|
|
6
6
|
import {waitForGenesis} from "./genesis.js";
|
|
7
7
|
import {resolveBuilderIdentity} from "./identity.js";
|
|
8
8
|
import {Metrics} from "./metrics.js";
|
|
@@ -75,8 +75,7 @@ export class Builder {
|
|
|
75
75
|
this.clock.runEverySlot(async (slot) => this.onSlot(slot));
|
|
76
76
|
this.clock.runEveryEpoch((epoch) => this.builderStatusTracker.poll(epoch));
|
|
77
77
|
this.clock.start(this.controller.signal);
|
|
78
|
-
this.
|
|
79
|
-
this.proposerPreferencesTracker.start(this.controller.signal);
|
|
78
|
+
this.subscribeToEvents(opts.api);
|
|
80
79
|
|
|
81
80
|
this.logger.info("Builder client initialized", {
|
|
82
81
|
index: this.index,
|
|
@@ -114,7 +113,7 @@ export class Builder {
|
|
|
114
113
|
|
|
115
114
|
const builderStatusTracker = new BuilderStatusTracker(api, logger, index, opts.metrics);
|
|
116
115
|
const blockObserver = new BlockObserver(config, logger, api);
|
|
117
|
-
const proposerPreferencesTracker = new ProposerPreferencesTracker(
|
|
116
|
+
const proposerPreferencesTracker = new ProposerPreferencesTracker();
|
|
118
117
|
|
|
119
118
|
const payloadStore = new PayloadStore();
|
|
120
119
|
|
|
@@ -135,6 +134,65 @@ export class Builder {
|
|
|
135
134
|
this.proposerPreferencesTracker.prune(slot);
|
|
136
135
|
}
|
|
137
136
|
|
|
137
|
+
private subscribeToEvents(api: ApiClient): void {
|
|
138
|
+
const signal = this.controller.signal;
|
|
139
|
+
if (signal.aborted) return;
|
|
140
|
+
|
|
141
|
+
const topics = [routes.events.EventType.block, routes.events.EventType.proposerPreferences];
|
|
142
|
+
this.logger.verbose("Subscribing to builder events", {topics: topics.join(",")});
|
|
143
|
+
api.events
|
|
144
|
+
.eventstream({
|
|
145
|
+
topics,
|
|
146
|
+
signal,
|
|
147
|
+
onEvent: (event) => {
|
|
148
|
+
void this.onEvent(event);
|
|
149
|
+
},
|
|
150
|
+
onError: (error) => {
|
|
151
|
+
if (!signal.aborted) this.logger.error("Failed to receive builder event", {topics: topics.join(",")}, error);
|
|
152
|
+
},
|
|
153
|
+
onClose: () => {
|
|
154
|
+
if (signal.aborted) {
|
|
155
|
+
this.logger.verbose("Closed builder event stream", {topics: topics.join(",")});
|
|
156
|
+
} else {
|
|
157
|
+
this.logger.error("Builder event stream closed unexpectedly", {topics: topics.join(",")});
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
.catch((error: unknown) => {
|
|
162
|
+
if (!signal.aborted && !isErrorAborted(error)) {
|
|
163
|
+
this.logger.error(
|
|
164
|
+
"Failed to subscribe to builder events",
|
|
165
|
+
{topics: topics.join(",")},
|
|
166
|
+
error instanceof Error ? error : Error(String(error))
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private async onEvent(event: routes.events.BeaconEvent): Promise<void> {
|
|
173
|
+
const signal = this.controller.signal;
|
|
174
|
+
if (signal.aborted) return;
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
switch (event.type) {
|
|
178
|
+
case routes.events.EventType.block:
|
|
179
|
+
await this.blockObserver.processBlockEvent(event.message, signal);
|
|
180
|
+
break;
|
|
181
|
+
case routes.events.EventType.proposerPreferences:
|
|
182
|
+
this.proposerPreferencesTracker.onProposerPreferences(event.message.data);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (!signal.aborted && !isErrorAborted(error)) {
|
|
187
|
+
this.logger.warn(
|
|
188
|
+
"Failed to process builder event",
|
|
189
|
+
{eventType: event.type},
|
|
190
|
+
error instanceof Error ? error : Error(String(error))
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
138
196
|
async close(): Promise<void> {
|
|
139
197
|
this.controller.abort();
|
|
140
198
|
}
|
|
@@ -32,6 +32,7 @@ type MutableBidLedgerRecord = SubmittedBid & {
|
|
|
32
32
|
export enum BidLedgerErrorCode {
|
|
33
33
|
INVALID_BID_VALUE = "BID_LEDGER_ERROR_INVALID_BID_VALUE",
|
|
34
34
|
DUPLICATE_BID = "BID_LEDGER_ERROR_DUPLICATE_BID",
|
|
35
|
+
BID_TOO_OLD = "BID_LEDGER_ERROR_BID_TOO_OLD",
|
|
35
36
|
REVEAL_CONFLICT = "BID_LEDGER_ERROR_REVEAL_CONFLICT",
|
|
36
37
|
UNSETTLED_VALUE_OVERFLOW = "BID_LEDGER_ERROR_UNSETTLED_VALUE_OVERFLOW",
|
|
37
38
|
}
|
|
@@ -47,6 +48,11 @@ export type BidLedgerErrorType =
|
|
|
47
48
|
parentBlockHash: RootHex;
|
|
48
49
|
parentBlockRoot: RootHex;
|
|
49
50
|
}
|
|
51
|
+
| {
|
|
52
|
+
code: BidLedgerErrorCode.BID_TOO_OLD;
|
|
53
|
+
slot: Slot;
|
|
54
|
+
pruneCutoffSlot: Slot;
|
|
55
|
+
}
|
|
50
56
|
| {
|
|
51
57
|
code: BidLedgerErrorCode.REVEAL_CONFLICT;
|
|
52
58
|
blockRoot: RootHex;
|
|
@@ -69,11 +75,28 @@ const KEEP_SLOTS = RECORD_RETENTION_EPOCHS * SLOTS_PER_EPOCH;
|
|
|
69
75
|
export class BidLedger {
|
|
70
76
|
private readonly bidsBySlot = new Map<Slot, Map<string, MutableBidLedgerRecord>>();
|
|
71
77
|
private readonly revealedPayloadByBlockRoot = new Map<RootHex, RevealedPayload>();
|
|
78
|
+
private pruneCutoffSlot = 0;
|
|
72
79
|
|
|
73
80
|
hasSubmitted(slot: Slot, parentBlockHash: RootHex, parentBlockRoot: RootHex): boolean {
|
|
74
81
|
return this.bidsBySlot.get(slot)?.has(tupleKey(parentBlockHash, parentBlockRoot)) ?? false;
|
|
75
82
|
}
|
|
76
83
|
|
|
84
|
+
assertCanRecordBid({
|
|
85
|
+
slot,
|
|
86
|
+
parentBlockHash,
|
|
87
|
+
parentBlockRoot,
|
|
88
|
+
}: Pick<SubmittedBid, "slot" | "parentBlockHash" | "parentBlockRoot">): void {
|
|
89
|
+
if (slot < this.pruneCutoffSlot) {
|
|
90
|
+
throw new BidLedgerError({code: BidLedgerErrorCode.BID_TOO_OLD, slot, pruneCutoffSlot: this.pruneCutoffSlot});
|
|
91
|
+
}
|
|
92
|
+
if (this.hasSubmitted(slot, parentBlockHash, parentBlockRoot)) {
|
|
93
|
+
throw new BidLedgerError(
|
|
94
|
+
{code: BidLedgerErrorCode.DUPLICATE_BID, slot, parentBlockHash, parentBlockRoot},
|
|
95
|
+
`Bid already recorded slot=${slot} parentBlockHash=${parentBlockHash} parentBlockRoot=${parentBlockRoot}`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
77
100
|
recordBid(bid: SubmittedBid): BidLedgerRecord {
|
|
78
101
|
if (!Number.isSafeInteger(bid.valueGwei) || bid.valueGwei < 0) {
|
|
79
102
|
throw new BidLedgerError(
|
|
@@ -82,6 +105,7 @@ export class BidLedger {
|
|
|
82
105
|
);
|
|
83
106
|
}
|
|
84
107
|
|
|
108
|
+
this.assertCanRecordBid(bid);
|
|
85
109
|
let bidsForSlot = this.bidsBySlot.get(bid.slot);
|
|
86
110
|
if (bidsForSlot === undefined) {
|
|
87
111
|
bidsForSlot = new Map();
|
|
@@ -89,18 +113,6 @@ export class BidLedger {
|
|
|
89
113
|
}
|
|
90
114
|
|
|
91
115
|
const key = tupleKey(bid.parentBlockHash, bid.parentBlockRoot);
|
|
92
|
-
if (bidsForSlot.has(key)) {
|
|
93
|
-
throw new BidLedgerError(
|
|
94
|
-
{
|
|
95
|
-
code: BidLedgerErrorCode.DUPLICATE_BID,
|
|
96
|
-
slot: bid.slot,
|
|
97
|
-
parentBlockHash: bid.parentBlockHash,
|
|
98
|
-
parentBlockRoot: bid.parentBlockRoot,
|
|
99
|
-
},
|
|
100
|
-
`Bid already recorded slot=${bid.slot} parentBlockHash=${bid.parentBlockHash} parentBlockRoot=${bid.parentBlockRoot}`
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
116
|
const record = {...bid, wonBlockRoots: new Set<RootHex>(), paymentSettled: false};
|
|
105
117
|
bidsForSlot.set(key, record);
|
|
106
118
|
return toRecord(record);
|
|
@@ -198,9 +210,11 @@ export class BidLedger {
|
|
|
198
210
|
}
|
|
199
211
|
|
|
200
212
|
prune(currentSlot: Slot): number {
|
|
213
|
+
// Pruning must not make an expired slot eligible for another submission.
|
|
214
|
+
this.pruneCutoffSlot = Math.max(this.pruneCutoffSlot, currentSlot - KEEP_SLOTS);
|
|
201
215
|
let removed = 0;
|
|
202
216
|
for (const [slot, bidsForSlot] of this.bidsBySlot) {
|
|
203
|
-
if (slot >=
|
|
217
|
+
if (slot >= this.pruneCutoffSlot) {
|
|
204
218
|
continue;
|
|
205
219
|
}
|
|
206
220
|
|
|
@@ -216,7 +230,7 @@ export class BidLedger {
|
|
|
216
230
|
}
|
|
217
231
|
|
|
218
232
|
for (const [blockRoot, revealedPayload] of this.revealedPayloadByBlockRoot) {
|
|
219
|
-
if (revealedPayload.slot <
|
|
233
|
+
if (revealedPayload.slot < this.pruneCutoffSlot) {
|
|
220
234
|
this.revealedPayloadByBlockRoot.delete(blockRoot);
|
|
221
235
|
}
|
|
222
236
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type {ApiClient} from "@lodestar/api";
|
|
2
|
+
import type {ChainForkConfig} from "@lodestar/config";
|
|
3
|
+
import {isForkPostGloas} from "@lodestar/params";
|
|
4
|
+
import type {BuilderIndex, RootHex, Slot, gloas, heze} from "@lodestar/types";
|
|
5
|
+
import {sszTypesFor} from "@lodestar/types";
|
|
6
|
+
import {LodestarError, toRootHex} from "@lodestar/utils";
|
|
7
|
+
import type {BidIdentity, BidLedger} from "./bidLedger.js";
|
|
8
|
+
import type {BuilderSigner} from "./builderSigner.js";
|
|
9
|
+
|
|
10
|
+
export type BidPublisherModules = {
|
|
11
|
+
api: ApiClient;
|
|
12
|
+
config: ChainForkConfig;
|
|
13
|
+
signer: BuilderSigner;
|
|
14
|
+
ledger: BidLedger;
|
|
15
|
+
builderIndex: BuilderIndex;
|
|
16
|
+
hasPayload: (identity: BidIdentity) => boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export enum BidPublisherErrorCode {
|
|
20
|
+
BUILDER_INDEX_MISMATCH = "BID_PUBLISHER_ERROR_BUILDER_INDEX_MISMATCH",
|
|
21
|
+
PAYLOAD_NOT_RETAINED = "BID_PUBLISHER_ERROR_PAYLOAD_NOT_RETAINED",
|
|
22
|
+
PRE_GLOAS_BID = "BID_PUBLISHER_ERROR_PRE_GLOAS_BID",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type BidPublisherErrorType =
|
|
26
|
+
| {
|
|
27
|
+
code: BidPublisherErrorCode.PRE_GLOAS_BID;
|
|
28
|
+
slot: Slot;
|
|
29
|
+
}
|
|
30
|
+
| {
|
|
31
|
+
code: BidPublisherErrorCode.BUILDER_INDEX_MISMATCH;
|
|
32
|
+
builderIndex: BuilderIndex;
|
|
33
|
+
bidBuilderIndex: BuilderIndex;
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
code: BidPublisherErrorCode.PAYLOAD_NOT_RETAINED;
|
|
37
|
+
slot: Slot;
|
|
38
|
+
parentBlockHash: RootHex;
|
|
39
|
+
parentBlockRoot: RootHex;
|
|
40
|
+
blockHash: RootHex;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export class BidPublisherError extends LodestarError<BidPublisherErrorType> {}
|
|
44
|
+
|
|
45
|
+
/** Signs and submits a bid only if its payload is retained locally. */
|
|
46
|
+
export class BidPublisher {
|
|
47
|
+
constructor(private readonly modules: BidPublisherModules) {}
|
|
48
|
+
|
|
49
|
+
publish(bid: heze.ExecutionPayloadBid, signal: AbortSignal): Promise<heze.SignedExecutionPayloadBid>;
|
|
50
|
+
publish(bid: gloas.ExecutionPayloadBid, signal: AbortSignal): Promise<gloas.SignedExecutionPayloadBid>;
|
|
51
|
+
async publish(bid: gloas.ExecutionPayloadBid, signal: AbortSignal): Promise<gloas.SignedExecutionPayloadBid> {
|
|
52
|
+
signal.throwIfAborted();
|
|
53
|
+
|
|
54
|
+
const {api, config, builderIndex, hasPayload, ledger, signer} = this.modules;
|
|
55
|
+
const fork = config.getForkName(bid.slot);
|
|
56
|
+
if (!isForkPostGloas(fork)) {
|
|
57
|
+
throw new BidPublisherError({code: BidPublisherErrorCode.PRE_GLOAS_BID, slot: bid.slot});
|
|
58
|
+
}
|
|
59
|
+
if (bid.builderIndex !== builderIndex) {
|
|
60
|
+
throw new BidPublisherError(
|
|
61
|
+
{
|
|
62
|
+
code: BidPublisherErrorCode.BUILDER_INDEX_MISMATCH,
|
|
63
|
+
builderIndex,
|
|
64
|
+
bidBuilderIndex: bid.builderIndex,
|
|
65
|
+
},
|
|
66
|
+
`Bid builder index does not match local builder index builderIndex=${builderIndex} bidBuilderIndex=${bid.builderIndex}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const identity: BidIdentity = {
|
|
71
|
+
slot: bid.slot,
|
|
72
|
+
parentBlockHash: toRootHex(bid.parentBlockHash),
|
|
73
|
+
parentBlockRoot: toRootHex(bid.parentBlockRoot),
|
|
74
|
+
blockHash: toRootHex(bid.blockHash),
|
|
75
|
+
};
|
|
76
|
+
if (!hasPayload(identity)) {
|
|
77
|
+
throw new BidPublisherError(
|
|
78
|
+
{code: BidPublisherErrorCode.PAYLOAD_NOT_RETAINED, ...identity},
|
|
79
|
+
`Bid payload is not retained slot=${identity.slot} parentBlockHash=${identity.parentBlockHash} parentBlockRoot=${identity.parentBlockRoot} blockHash=${identity.blockHash}`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
ledger.assertCanRecordBid(identity);
|
|
84
|
+
|
|
85
|
+
const signedExecutionPayloadBid = signer.signExecutionPayloadBid(bid);
|
|
86
|
+
const signedBidRoot = toRootHex(
|
|
87
|
+
sszTypesFor(fork, "SignedExecutionPayloadBid").hashTreeRoot(signedExecutionPayloadBid)
|
|
88
|
+
);
|
|
89
|
+
ledger.recordBid({...identity, valueGwei: bid.value, signedBidRoot});
|
|
90
|
+
|
|
91
|
+
const response = await api.beacon.publishExecutionPayloadBid({signedExecutionPayloadBid}, {signal});
|
|
92
|
+
response.assertOk();
|
|
93
|
+
return signedExecutionPayloadBid;
|
|
94
|
+
}
|
|
95
|
+
}
|