@lodestar/builder 1.48.0-dev.59456ca330 → 1.48.0-dev.5f5feafbc4
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 +1 -8
- package/lib/builder.d.ts.map +1 -1
- package/lib/builder.js +2 -15
- package/lib/builder.js.map +1 -1
- package/lib/identity.d.ts +1 -0
- package/lib/identity.d.ts.map +1 -1
- package/lib/identity.js +4 -11
- package/lib/identity.js.map +1 -1
- package/package.json +11 -11
- package/src/builder.ts +2 -19
- package/src/identity.ts +6 -13
- package/lib/services/bidLedger.d.ts +0 -61
- package/lib/services/bidLedger.d.ts.map +0 -1
- package/lib/services/bidLedger.js +0 -154
- package/lib/services/bidLedger.js.map +0 -1
- package/lib/services/bidPolicy.d.ts +0 -30
- package/lib/services/bidPolicy.d.ts.map +0 -1
- package/lib/services/bidPolicy.js +0 -37
- package/lib/services/bidPolicy.js.map +0 -1
- package/lib/services/blockObserver.d.ts +0 -48
- package/lib/services/blockObserver.d.ts.map +0 -1
- package/lib/services/blockObserver.js +0 -172
- package/lib/services/blockObserver.js.map +0 -1
- package/lib/services/payloadStore.d.ts +0 -25
- package/lib/services/payloadStore.d.ts.map +0 -1
- package/lib/services/payloadStore.js +0 -25
- package/lib/services/payloadStore.js.map +0 -1
- package/src/services/bidLedger.ts +0 -245
- package/src/services/bidPolicy.ts +0 -65
- package/src/services/blockObserver.ts +0 -231
- package/src/services/payloadStore.ts +0 -51
package/lib/builder.d.ts
CHANGED
|
@@ -4,18 +4,14 @@ import { ClockOptions, IClock } from "@lodestar/state-transition";
|
|
|
4
4
|
import { BuilderIndex, ExecutionAddress } from "@lodestar/types";
|
|
5
5
|
import { Logger } from "@lodestar/utils";
|
|
6
6
|
import { Metrics } from "./metrics.js";
|
|
7
|
-
import { BlockObserver } from "./services/blockObserver.js";
|
|
8
7
|
import { BuilderSigner, Keypair } from "./services/builderSigner.js";
|
|
9
8
|
import { BuilderStatusTracker } from "./services/builderStatusTracker.js";
|
|
10
|
-
import { PayloadStore } from "./services/payloadStore.js";
|
|
11
9
|
export type BuilderModules = {
|
|
12
10
|
opts: BuilderOptions;
|
|
13
11
|
builderSigner: BuilderSigner;
|
|
14
|
-
blockObserver: BlockObserver;
|
|
15
12
|
builderStatusTracker: BuilderStatusTracker;
|
|
16
13
|
clock: IClock;
|
|
17
14
|
index: BuilderIndex;
|
|
18
|
-
store: PayloadStore;
|
|
19
15
|
};
|
|
20
16
|
export type BuilderOptions = {
|
|
21
17
|
logger: Logger;
|
|
@@ -32,17 +28,14 @@ export type BuilderOptions = {
|
|
|
32
28
|
*/
|
|
33
29
|
export declare class Builder {
|
|
34
30
|
readonly builderSigner: BuilderSigner;
|
|
35
|
-
private readonly blockObserver;
|
|
36
31
|
private readonly builderStatusTracker;
|
|
37
32
|
private readonly controller;
|
|
38
33
|
private readonly clock;
|
|
39
34
|
private readonly index;
|
|
40
35
|
private readonly logger;
|
|
41
36
|
private readonly executionFeeRecipient;
|
|
42
|
-
|
|
43
|
-
constructor({ opts, builderSigner, blockObserver, builderStatusTracker, clock, index, store }: BuilderModules);
|
|
37
|
+
constructor({ opts, builderSigner, builderStatusTracker, clock, index }: BuilderModules);
|
|
44
38
|
static init(opts: BuilderOptions): Promise<Builder>;
|
|
45
|
-
private onSlot;
|
|
46
39
|
close(): Promise<void>;
|
|
47
40
|
}
|
|
48
41
|
//# sourceMappingURL=builder.d.ts.map
|
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,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,EAAC,eAAe,EAAwC,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAQ,YAAY,EAAE,MAAM,EAAC,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MA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,aAAa,CAAC;IACtC,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;IAEzD,YAAY,EAAC,IAAI,EAAE,aAAa,EAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAC,EAAE,cAAc,EAiBpF;IAED,OAAa,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CA+BxD;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;CACF"}
|
package/lib/builder.js
CHANGED
|
@@ -4,37 +4,29 @@ import { toHex, toRootHex } from "@lodestar/utils";
|
|
|
4
4
|
import { waitForGenesis } from "./genesis.js";
|
|
5
5
|
import { resolveBuilderIdentity } from "./identity.js";
|
|
6
6
|
import { logNodeVersion, waitForNodeReady } from "./readiness.js";
|
|
7
|
-
import { BlockObserver } from "./services/blockObserver.js";
|
|
8
7
|
import { BuilderSigner } from "./services/builderSigner.js";
|
|
9
8
|
import { BuilderStatusTracker } from "./services/builderStatusTracker.js";
|
|
10
|
-
import { PayloadStore } from "./services/payloadStore.js";
|
|
11
9
|
/**
|
|
12
10
|
* Main class for the Builder client.
|
|
13
11
|
*/
|
|
14
12
|
export class Builder {
|
|
15
13
|
builderSigner;
|
|
16
|
-
blockObserver;
|
|
17
14
|
builderStatusTracker;
|
|
18
15
|
controller;
|
|
19
16
|
clock;
|
|
20
17
|
index;
|
|
21
18
|
logger;
|
|
22
19
|
executionFeeRecipient;
|
|
23
|
-
|
|
24
|
-
constructor({ opts, builderSigner, blockObserver, builderStatusTracker, clock, index, store }) {
|
|
20
|
+
constructor({ opts, builderSigner, builderStatusTracker, clock, index }) {
|
|
25
21
|
this.builderSigner = builderSigner;
|
|
26
|
-
this.blockObserver = blockObserver;
|
|
27
22
|
this.builderStatusTracker = builderStatusTracker;
|
|
28
23
|
this.clock = clock;
|
|
29
24
|
this.controller = opts.abortController;
|
|
30
25
|
this.logger = opts.logger;
|
|
31
26
|
this.index = index;
|
|
32
|
-
this.store = store;
|
|
33
27
|
this.executionFeeRecipient = opts.executionFeeRecipient;
|
|
34
|
-
this.clock.runEverySlot(async (slot) => this.onSlot(slot));
|
|
35
28
|
this.clock.runEveryEpoch((epoch) => this.builderStatusTracker.poll(epoch));
|
|
36
29
|
this.clock.start(this.controller.signal);
|
|
37
|
-
this.blockObserver.start(this.controller.signal);
|
|
38
30
|
this.logger.info("Builder client initialized", {
|
|
39
31
|
index: this.index,
|
|
40
32
|
executionFeeRecipient: toHex(this.executionFeeRecipient),
|
|
@@ -56,12 +48,7 @@ export class Builder {
|
|
|
56
48
|
const clock = new Clock(config, logger, { genesisTime: Number(genesis.genesisTime), ...opts.clock });
|
|
57
49
|
const index = await resolveBuilderIdentity(api, logger, builderSigner.getPubkeyHex(), opts.abortController.signal, clock, config);
|
|
58
50
|
const builderStatusTracker = new BuilderStatusTracker(api, logger, index, opts.metrics);
|
|
59
|
-
|
|
60
|
-
const store = new PayloadStore();
|
|
61
|
-
return new Builder({ opts, builderSigner, blockObserver, builderStatusTracker, clock, index, store });
|
|
62
|
-
}
|
|
63
|
-
async onSlot(slot) {
|
|
64
|
-
this.store.prune(slot);
|
|
51
|
+
return new Builder({ opts, builderSigner, builderStatusTracker, clock, index });
|
|
65
52
|
}
|
|
66
53
|
async close() {
|
|
67
54
|
this.controller.abort();
|
package/lib/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACxF,OAAO,E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,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAE9D,MAAM,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACjE,MAAM,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAElC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAC,CAAC,CAAC;QAEnG,MAAM,KAAK,GAAG,MAAM,sBAAsB,CACxC,GAAG,EACH,MAAM,EACN,aAAa,CAAC,YAAY,EAAE,EAC5B,IAAI,CAAC,eAAe,CAAC,MAAM,EAC3B,KAAK,EACL,MAAM,CACP,CAAC;QAEF,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAExF,OAAO,IAAI,OAAO,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
package/lib/identity.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ChainForkConfig } from "@lodestar/config";
|
|
|
3
3
|
import { IClock } from "@lodestar/state-transition";
|
|
4
4
|
import { BuilderIndex, BuilderStatus } from "@lodestar/types";
|
|
5
5
|
import { Logger } from "@lodestar/utils";
|
|
6
|
+
export declare const WAITING_FOR_BUILDER_POLL_MS: number;
|
|
6
7
|
export declare function resolveBuilderIdentity(api: ApiClient, logger: Logger, id: routes.beacon.BuilderId, signal: AbortSignal, clock: IClock, config: ChainForkConfig): Promise<BuilderIndex>;
|
|
7
8
|
export declare function getBuilderStatus(api: ApiClient, logger: Logger, id: routes.beacon.BuilderId): Promise<{
|
|
8
9
|
status: BuilderStatus;
|
package/lib/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA4B,MAAM,EAAC,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAA4B,MAAM,EAAC,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,MAAM,EAAC,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAe,MAAM,EAA2C,MAAM,iBAAiB,CAAC;AAE/F,eAAO,MAAM,2BAA2B,QAAY,CAAC;AAErD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,EAC3B,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,YAAY,CAAC,CAgBvB;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,GAC1B,OAAO,CAAC;IAAC,MAAM,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAAC,CAe1D"}
|
package/lib/identity.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiError, HttpStatusCode } from "@lodestar/api";
|
|
2
2
|
import { PAYLOAD_BUILDER_VERSION } from "@lodestar/params";
|
|
3
|
-
import { computeStartSlotAtEpoch } from "@lodestar/state-transition";
|
|
4
3
|
import { ErrorAborted, TimeoutError, isFetchError, sleep, toHex } from "@lodestar/utils";
|
|
4
|
+
export const WAITING_FOR_BUILDER_POLL_MS = 10 * 1000;
|
|
5
5
|
export async function resolveBuilderIdentity(api, logger, id, signal, clock, config) {
|
|
6
6
|
const builderEntry = await waitForBuilder(api, logger, id, signal, clock, config);
|
|
7
7
|
if (builderEntry.builder.version !== PAYLOAD_BUILDER_VERSION) {
|
|
@@ -44,7 +44,7 @@ async function waitForBuilder(api, logger, id, signal, clock, config) {
|
|
|
44
44
|
currentEpoch,
|
|
45
45
|
slot: clock.getCurrentSlot(),
|
|
46
46
|
});
|
|
47
|
-
await sleep(
|
|
47
|
+
await sleep(WAITING_FOR_BUILDER_POLL_MS, signal);
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
50
|
let builder = null;
|
|
@@ -60,7 +60,7 @@ async function waitForBuilder(api, logger, id, signal, clock, config) {
|
|
|
60
60
|
currentEpoch,
|
|
61
61
|
slot: clock.getCurrentSlot(),
|
|
62
62
|
});
|
|
63
|
-
await sleep(
|
|
63
|
+
await sleep(WAITING_FOR_BUILDER_POLL_MS, signal);
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
66
|
throw e;
|
|
@@ -73,12 +73,11 @@ async function waitForBuilder(api, logger, id, signal, clock, config) {
|
|
|
73
73
|
}
|
|
74
74
|
if (builder?.status === "pending") {
|
|
75
75
|
logger.info("Waiting for builder deposit to be finalized", { id, slot: clock.getCurrentSlot() });
|
|
76
|
-
await sleep(msToNextEpochPoll(clock), signal);
|
|
77
76
|
}
|
|
78
77
|
else {
|
|
79
78
|
logger.info("Waiting for builder to be known to the beacon node", { id, slot: clock.getCurrentSlot() });
|
|
80
|
-
await sleep(msToNextSlotPoll(clock), signal);
|
|
81
79
|
}
|
|
80
|
+
await sleep(WAITING_FOR_BUILDER_POLL_MS, signal);
|
|
82
81
|
}
|
|
83
82
|
throw new ErrorAborted("waitForBuilder");
|
|
84
83
|
}
|
|
@@ -111,10 +110,4 @@ async function fetchBuilder(api, logger, id) {
|
|
|
111
110
|
throw e;
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
|
-
function msToNextEpochPoll(clock) {
|
|
115
|
-
return clock.msToSlot(computeStartSlotAtEpoch(clock.getCurrentEpoch() + 1));
|
|
116
|
-
}
|
|
117
|
-
function msToNextSlotPoll(clock) {
|
|
118
|
-
return clock.msToSlot(clock.getCurrentSlot() + 1);
|
|
119
|
-
}
|
|
120
113
|
//# sourceMappingURL=identity.js.map
|
package/lib/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,cAAc,EAAS,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAC,uBAAuB,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,cAAc,EAAS,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAC,uBAAuB,EAAC,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAC,YAAY,EAAU,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAE/F,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,CAAC;AAErD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAc,EACd,MAAc,EACd,EAA2B,EAC3B,MAAmB,EACnB,KAAa,EACb,MAAuB;IAEvB,MAAM,YAAY,GAAG,MAAM,cA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M,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACtF,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,YAAY,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,CAAC;YACzE,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAC,CAAC,CAAC;YAC7D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodestar/builder",
|
|
3
|
-
"version": "1.48.0-dev.
|
|
3
|
+
"version": "1.48.0-dev.5f5feafbc4",
|
|
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/lodestar-z": "catalog:",
|
|
50
|
-
"@chainsafe/ssz": "^1.
|
|
51
|
-
"@lodestar/api": "^1.48.0-dev.
|
|
52
|
-
"@lodestar/config": "^1.48.0-dev.
|
|
53
|
-
"@lodestar/params": "^1.48.0-dev.
|
|
54
|
-
"@lodestar/state-transition": "^1.48.0-dev.
|
|
55
|
-
"@lodestar/types": "^1.48.0-dev.
|
|
56
|
-
"@lodestar/utils": "^1.48.0-dev.
|
|
50
|
+
"@chainsafe/ssz": "^1.6.3",
|
|
51
|
+
"@lodestar/api": "^1.48.0-dev.5f5feafbc4",
|
|
52
|
+
"@lodestar/config": "^1.48.0-dev.5f5feafbc4",
|
|
53
|
+
"@lodestar/params": "^1.48.0-dev.5f5feafbc4",
|
|
54
|
+
"@lodestar/state-transition": "^1.48.0-dev.5f5feafbc4",
|
|
55
|
+
"@lodestar/types": "^1.48.0-dev.5f5feafbc4",
|
|
56
|
+
"@lodestar/utils": "^1.48.0-dev.5f5feafbc4"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@lodestar/logger": "^1.48.0-dev.
|
|
60
|
-
"@lodestar/test-utils": "^1.48.0-dev.
|
|
59
|
+
"@lodestar/logger": "^1.48.0-dev.5f5feafbc4",
|
|
60
|
+
"@lodestar/test-utils": "^1.48.0-dev.5f5feafbc4"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "95f51bbf89f983570afc4c268ab82565bd9c5443"
|
|
63
63
|
}
|
package/src/builder.ts
CHANGED
|
@@ -7,19 +7,15 @@ import {waitForGenesis} from "./genesis.js";
|
|
|
7
7
|
import {resolveBuilderIdentity} from "./identity.js";
|
|
8
8
|
import {Metrics} from "./metrics.js";
|
|
9
9
|
import {logNodeVersion, waitForNodeReady} from "./readiness.js";
|
|
10
|
-
import {BlockObserver} from "./services/blockObserver.js";
|
|
11
10
|
import {BuilderSigner, Keypair} from "./services/builderSigner.js";
|
|
12
11
|
import {BuilderStatusTracker} from "./services/builderStatusTracker.js";
|
|
13
|
-
import {PayloadStore} from "./services/payloadStore.js";
|
|
14
12
|
|
|
15
13
|
export type BuilderModules = {
|
|
16
14
|
opts: BuilderOptions;
|
|
17
15
|
builderSigner: BuilderSigner;
|
|
18
|
-
blockObserver: BlockObserver;
|
|
19
16
|
builderStatusTracker: BuilderStatusTracker;
|
|
20
17
|
clock: IClock;
|
|
21
18
|
index: BuilderIndex;
|
|
22
|
-
store: PayloadStore;
|
|
23
19
|
};
|
|
24
20
|
|
|
25
21
|
export type BuilderOptions = {
|
|
@@ -38,31 +34,25 @@ export type BuilderOptions = {
|
|
|
38
34
|
*/
|
|
39
35
|
export class Builder {
|
|
40
36
|
readonly builderSigner: BuilderSigner;
|
|
41
|
-
private readonly blockObserver: BlockObserver;
|
|
42
37
|
private readonly builderStatusTracker: BuilderStatusTracker;
|
|
43
38
|
private readonly controller: AbortController;
|
|
44
39
|
private readonly clock: IClock;
|
|
45
40
|
private readonly index: BuilderIndex;
|
|
46
41
|
private readonly logger: Logger;
|
|
47
42
|
private readonly executionFeeRecipient: ExecutionAddress;
|
|
48
|
-
private readonly store: PayloadStore;
|
|
49
43
|
|
|
50
|
-
constructor({opts, builderSigner,
|
|
44
|
+
constructor({opts, builderSigner, builderStatusTracker, clock, index}: BuilderModules) {
|
|
51
45
|
this.builderSigner = builderSigner;
|
|
52
|
-
this.blockObserver = blockObserver;
|
|
53
46
|
this.builderStatusTracker = builderStatusTracker;
|
|
54
47
|
this.clock = clock;
|
|
55
48
|
this.controller = opts.abortController;
|
|
56
49
|
this.logger = opts.logger;
|
|
57
50
|
this.index = index;
|
|
58
|
-
this.store = store;
|
|
59
51
|
|
|
60
52
|
this.executionFeeRecipient = opts.executionFeeRecipient;
|
|
61
53
|
|
|
62
|
-
this.clock.runEverySlot(async (slot) => this.onSlot(slot));
|
|
63
54
|
this.clock.runEveryEpoch((epoch) => this.builderStatusTracker.poll(epoch));
|
|
64
55
|
this.clock.start(this.controller.signal);
|
|
65
|
-
this.blockObserver.start(this.controller.signal);
|
|
66
56
|
|
|
67
57
|
this.logger.info("Builder client initialized", {
|
|
68
58
|
index: this.index,
|
|
@@ -99,15 +89,8 @@ export class Builder {
|
|
|
99
89
|
);
|
|
100
90
|
|
|
101
91
|
const builderStatusTracker = new BuilderStatusTracker(api, logger, index, opts.metrics);
|
|
102
|
-
const blockObserver = new BlockObserver(config, logger, api);
|
|
103
92
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return new Builder({opts, builderSigner, blockObserver, builderStatusTracker, clock, index, store});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private async onSlot(slot: number): Promise<void> {
|
|
110
|
-
this.store.prune(slot);
|
|
93
|
+
return new Builder({opts, builderSigner, builderStatusTracker, clock, index});
|
|
111
94
|
}
|
|
112
95
|
|
|
113
96
|
async close(): Promise<void> {
|
package/src/identity.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {ApiClient, ApiError, HttpStatusCode, routes} from "@lodestar/api";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
3
|
import {PAYLOAD_BUILDER_VERSION} from "@lodestar/params";
|
|
4
|
-
import {IClock
|
|
4
|
+
import {IClock} from "@lodestar/state-transition";
|
|
5
5
|
import {BuilderIndex, BuilderStatus} from "@lodestar/types";
|
|
6
6
|
import {ErrorAborted, Logger, TimeoutError, isFetchError, sleep, toHex} from "@lodestar/utils";
|
|
7
7
|
|
|
8
|
+
export const WAITING_FOR_BUILDER_POLL_MS = 10 * 1000;
|
|
9
|
+
|
|
8
10
|
export async function resolveBuilderIdentity(
|
|
9
11
|
api: ApiClient,
|
|
10
12
|
logger: Logger,
|
|
@@ -69,7 +71,7 @@ async function waitForBuilder(
|
|
|
69
71
|
currentEpoch,
|
|
70
72
|
slot: clock.getCurrentSlot(),
|
|
71
73
|
});
|
|
72
|
-
await sleep(
|
|
74
|
+
await sleep(WAITING_FOR_BUILDER_POLL_MS, signal);
|
|
73
75
|
continue;
|
|
74
76
|
}
|
|
75
77
|
|
|
@@ -85,7 +87,7 @@ async function waitForBuilder(
|
|
|
85
87
|
currentEpoch,
|
|
86
88
|
slot: clock.getCurrentSlot(),
|
|
87
89
|
});
|
|
88
|
-
await sleep(
|
|
90
|
+
await sleep(WAITING_FOR_BUILDER_POLL_MS, signal);
|
|
89
91
|
continue;
|
|
90
92
|
}
|
|
91
93
|
throw e;
|
|
@@ -99,11 +101,10 @@ async function waitForBuilder(
|
|
|
99
101
|
}
|
|
100
102
|
if (builder?.status === "pending") {
|
|
101
103
|
logger.info("Waiting for builder deposit to be finalized", {id, slot: clock.getCurrentSlot()});
|
|
102
|
-
await sleep(msToNextEpochPoll(clock), signal);
|
|
103
104
|
} else {
|
|
104
105
|
logger.info("Waiting for builder to be known to the beacon node", {id, slot: clock.getCurrentSlot()});
|
|
105
|
-
await sleep(msToNextSlotPoll(clock), signal);
|
|
106
106
|
}
|
|
107
|
+
await sleep(WAITING_FOR_BUILDER_POLL_MS, signal);
|
|
107
108
|
}
|
|
108
109
|
throw new ErrorAborted("waitForBuilder");
|
|
109
110
|
}
|
|
@@ -144,11 +145,3 @@ async function fetchBuilder(
|
|
|
144
145
|
throw e;
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
|
-
|
|
148
|
-
function msToNextEpochPoll(clock: IClock): number {
|
|
149
|
-
return clock.msToSlot(computeStartSlotAtEpoch(clock.getCurrentEpoch() + 1));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function msToNextSlotPoll(clock: IClock): number {
|
|
153
|
-
return clock.msToSlot(clock.getCurrentSlot() + 1);
|
|
154
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Epoch, RootHex, Slot } from "@lodestar/types";
|
|
2
|
-
import { LodestarError } from "@lodestar/utils";
|
|
3
|
-
export type SubmittedBid = {
|
|
4
|
-
slot: Slot;
|
|
5
|
-
parentBlockHash: RootHex;
|
|
6
|
-
parentBlockRoot: RootHex;
|
|
7
|
-
blockHash: RootHex;
|
|
8
|
-
valueGwei: number;
|
|
9
|
-
signedBidRoot: RootHex;
|
|
10
|
-
};
|
|
11
|
-
export type BidIdentity = Pick<SubmittedBid, "slot" | "parentBlockHash" | "parentBlockRoot" | "blockHash">;
|
|
12
|
-
export type BidLedgerRecord = SubmittedBid & {
|
|
13
|
-
wonBlockRoots: RootHex[];
|
|
14
|
-
};
|
|
15
|
-
export declare enum BidLedgerErrorCode {
|
|
16
|
-
INVALID_BID_VALUE = "BID_LEDGER_ERROR_INVALID_BID_VALUE",
|
|
17
|
-
DUPLICATE_BID = "BID_LEDGER_ERROR_DUPLICATE_BID",
|
|
18
|
-
REVEAL_CONFLICT = "BID_LEDGER_ERROR_REVEAL_CONFLICT",
|
|
19
|
-
UNSETTLED_VALUE_OVERFLOW = "BID_LEDGER_ERROR_UNSETTLED_VALUE_OVERFLOW"
|
|
20
|
-
}
|
|
21
|
-
export type BidLedgerErrorType = {
|
|
22
|
-
code: BidLedgerErrorCode.INVALID_BID_VALUE;
|
|
23
|
-
valueGwei: number;
|
|
24
|
-
} | {
|
|
25
|
-
code: BidLedgerErrorCode.DUPLICATE_BID;
|
|
26
|
-
slot: Slot;
|
|
27
|
-
parentBlockHash: RootHex;
|
|
28
|
-
parentBlockRoot: RootHex;
|
|
29
|
-
} | {
|
|
30
|
-
code: BidLedgerErrorCode.REVEAL_CONFLICT;
|
|
31
|
-
blockRoot: RootHex;
|
|
32
|
-
blockHash: RootHex;
|
|
33
|
-
revealedBlockHash: RootHex;
|
|
34
|
-
envelopeRoot: RootHex;
|
|
35
|
-
revealedEnvelopeRoot: RootHex;
|
|
36
|
-
} | {
|
|
37
|
-
code: BidLedgerErrorCode.UNSETTLED_VALUE_OVERFLOW;
|
|
38
|
-
currentEpoch: Epoch;
|
|
39
|
-
};
|
|
40
|
-
export declare class BidLedgerError extends LodestarError<BidLedgerErrorType> {
|
|
41
|
-
}
|
|
42
|
-
/** Tracks at most one bid per (slot, parentBlockHash, parentBlockRoot) and its reveal obligations. */
|
|
43
|
-
export declare class BidLedger {
|
|
44
|
-
private readonly bidsBySlot;
|
|
45
|
-
private readonly revealedPayloadByBlockRoot;
|
|
46
|
-
hasSubmitted(slot: Slot, parentBlockHash: RootHex, parentBlockRoot: RootHex): boolean;
|
|
47
|
-
recordBid(bid: SubmittedBid): BidLedgerRecord;
|
|
48
|
-
recordWin(identity: BidIdentity & Pick<SubmittedBid, "signedBidRoot">, blockRoot: RootHex): BidLedgerRecord | null;
|
|
49
|
-
/** Release a winning bid liability only after its payment is known to be reflected in Builder balance. */
|
|
50
|
-
recordPaymentSettled(identity: BidIdentity): BidLedgerRecord | null;
|
|
51
|
-
canReveal(blockRoot: RootHex, blockHash: RootHex, envelopeRoot: RootHex): boolean;
|
|
52
|
-
hasRevealed(blockRoot: RootHex): boolean;
|
|
53
|
-
hasPublishedReveal(blockRoot: RootHex): boolean;
|
|
54
|
-
recordReveal(slot: Slot, blockRoot: RootHex, blockHash: RootHex, envelopeRoot: RootHex): void;
|
|
55
|
-
recordRevealPublished(slot: Slot, blockRoot: RootHex, blockHash: RootHex, envelopeRoot: RootHex): void;
|
|
56
|
-
getUnsettledValueGwei(currentEpoch: Epoch): number;
|
|
57
|
-
getBidsForSlot(slot: Slot): BidLedgerRecord[];
|
|
58
|
-
prune(currentSlot: Slot): number;
|
|
59
|
-
private getBid;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=bidLedger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAC1D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,WAAW,CAAC,CAAC;AAE3G,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG;IAC3C,aAAa,EAAE,OAAO,EAAE,CAAC;CAC1B,CAAC;AAcF,oBAAY,kBAAkB;IAC5B,iBAAiB,uCAAuC;IACxD,aAAa,mCAAmC;IAChD,eAAe,qCAAqC;IACpD,wBAAwB,8CAA8C;CACvE;AAED,MAAM,MAAM,kBAA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AAE,OAAO,GAAG,OAAO,CAEvC;IAED,kBAAkB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAE9C;IAED,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI,CAoB5F;IAED,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI,CAMrG;IAED,qBAAqB,CAAC,YAAY,EAAE,KAAK,GAAG,MAAM,CAkBjD;IAED,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,EAAE,CAE5C;IAED,KAAK,CAAC,WAAW,EAAE,IAAI,GAAG,MAAM,CAwB/B;IAED,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { SLOTS_PER_EPOCH } from "@lodestar/params";
|
|
2
|
-
import { LodestarError } from "@lodestar/utils";
|
|
3
|
-
export var BidLedgerErrorCode;
|
|
4
|
-
(function (BidLedgerErrorCode) {
|
|
5
|
-
BidLedgerErrorCode["INVALID_BID_VALUE"] = "BID_LEDGER_ERROR_INVALID_BID_VALUE";
|
|
6
|
-
BidLedgerErrorCode["DUPLICATE_BID"] = "BID_LEDGER_ERROR_DUPLICATE_BID";
|
|
7
|
-
BidLedgerErrorCode["REVEAL_CONFLICT"] = "BID_LEDGER_ERROR_REVEAL_CONFLICT";
|
|
8
|
-
BidLedgerErrorCode["UNSETTLED_VALUE_OVERFLOW"] = "BID_LEDGER_ERROR_UNSETTLED_VALUE_OVERFLOW";
|
|
9
|
-
})(BidLedgerErrorCode || (BidLedgerErrorCode = {}));
|
|
10
|
-
export class BidLedgerError extends LodestarError {
|
|
11
|
-
}
|
|
12
|
-
const RECORD_RETENTION_EPOCHS = 3;
|
|
13
|
-
const KEEP_SLOTS = RECORD_RETENTION_EPOCHS * SLOTS_PER_EPOCH;
|
|
14
|
-
/** Tracks at most one bid per (slot, parentBlockHash, parentBlockRoot) and its reveal obligations. */
|
|
15
|
-
export class BidLedger {
|
|
16
|
-
bidsBySlot = new Map();
|
|
17
|
-
revealedPayloadByBlockRoot = new Map();
|
|
18
|
-
hasSubmitted(slot, parentBlockHash, parentBlockRoot) {
|
|
19
|
-
return this.bidsBySlot.get(slot)?.has(tupleKey(parentBlockHash, parentBlockRoot)) ?? false;
|
|
20
|
-
}
|
|
21
|
-
recordBid(bid) {
|
|
22
|
-
if (!Number.isSafeInteger(bid.valueGwei) || bid.valueGwei < 0) {
|
|
23
|
-
throw new BidLedgerError({ code: BidLedgerErrorCode.INVALID_BID_VALUE, valueGwei: bid.valueGwei }, `Invalid bid value valueGwei=${bid.valueGwei}`);
|
|
24
|
-
}
|
|
25
|
-
let bidsForSlot = this.bidsBySlot.get(bid.slot);
|
|
26
|
-
if (bidsForSlot === undefined) {
|
|
27
|
-
bidsForSlot = new Map();
|
|
28
|
-
this.bidsBySlot.set(bid.slot, bidsForSlot);
|
|
29
|
-
}
|
|
30
|
-
const key = tupleKey(bid.parentBlockHash, bid.parentBlockRoot);
|
|
31
|
-
if (bidsForSlot.has(key)) {
|
|
32
|
-
throw new BidLedgerError({
|
|
33
|
-
code: BidLedgerErrorCode.DUPLICATE_BID,
|
|
34
|
-
slot: bid.slot,
|
|
35
|
-
parentBlockHash: bid.parentBlockHash,
|
|
36
|
-
parentBlockRoot: bid.parentBlockRoot,
|
|
37
|
-
}, `Bid already recorded slot=${bid.slot} parentBlockHash=${bid.parentBlockHash} parentBlockRoot=${bid.parentBlockRoot}`);
|
|
38
|
-
}
|
|
39
|
-
const record = { ...bid, wonBlockRoots: new Set(), paymentSettled: false };
|
|
40
|
-
bidsForSlot.set(key, record);
|
|
41
|
-
return toRecord(record);
|
|
42
|
-
}
|
|
43
|
-
recordWin(identity, blockRoot) {
|
|
44
|
-
const record = this.getBid(identity.slot, identity.parentBlockHash, identity.parentBlockRoot);
|
|
45
|
-
if (record === null || record.blockHash !== identity.blockHash || record.signedBidRoot !== identity.signedBidRoot) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
record.wonBlockRoots.add(blockRoot);
|
|
49
|
-
return toRecord(record);
|
|
50
|
-
}
|
|
51
|
-
/** Release a winning bid liability only after its payment is known to be reflected in Builder balance. */
|
|
52
|
-
recordPaymentSettled(identity) {
|
|
53
|
-
const record = this.getBid(identity.slot, identity.parentBlockHash, identity.parentBlockRoot);
|
|
54
|
-
if (record === null || record.blockHash !== identity.blockHash || record.wonBlockRoots.size === 0) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
record.paymentSettled = true;
|
|
58
|
-
return toRecord(record);
|
|
59
|
-
}
|
|
60
|
-
canReveal(blockRoot, blockHash, envelopeRoot) {
|
|
61
|
-
const revealedPayload = this.revealedPayloadByBlockRoot.get(blockRoot);
|
|
62
|
-
return (revealedPayload === undefined ||
|
|
63
|
-
(revealedPayload.blockHash === blockHash && revealedPayload.envelopeRoot === envelopeRoot));
|
|
64
|
-
}
|
|
65
|
-
hasRevealed(blockRoot) {
|
|
66
|
-
return this.revealedPayloadByBlockRoot.has(blockRoot);
|
|
67
|
-
}
|
|
68
|
-
hasPublishedReveal(blockRoot) {
|
|
69
|
-
return this.revealedPayloadByBlockRoot.get(blockRoot)?.published ?? false;
|
|
70
|
-
}
|
|
71
|
-
recordReveal(slot, blockRoot, blockHash, envelopeRoot) {
|
|
72
|
-
const revealedPayload = this.revealedPayloadByBlockRoot.get(blockRoot);
|
|
73
|
-
if (revealedPayload !== undefined) {
|
|
74
|
-
if (revealedPayload.blockHash !== blockHash || revealedPayload.envelopeRoot !== envelopeRoot) {
|
|
75
|
-
throw new BidLedgerError({
|
|
76
|
-
code: BidLedgerErrorCode.REVEAL_CONFLICT,
|
|
77
|
-
blockRoot,
|
|
78
|
-
blockHash,
|
|
79
|
-
revealedBlockHash: revealedPayload.blockHash,
|
|
80
|
-
envelopeRoot,
|
|
81
|
-
revealedEnvelopeRoot: revealedPayload.envelopeRoot,
|
|
82
|
-
}, `Different envelope already recorded blockRoot=${blockRoot} envelopeRoot=${revealedPayload.envelopeRoot}`);
|
|
83
|
-
}
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
this.revealedPayloadByBlockRoot.set(blockRoot, { slot, blockHash, envelopeRoot, published: false });
|
|
87
|
-
}
|
|
88
|
-
recordRevealPublished(slot, blockRoot, blockHash, envelopeRoot) {
|
|
89
|
-
this.recordReveal(slot, blockRoot, blockHash, envelopeRoot);
|
|
90
|
-
const revealedPayload = this.revealedPayloadByBlockRoot.get(blockRoot);
|
|
91
|
-
if (revealedPayload !== undefined) {
|
|
92
|
-
revealedPayload.published = true;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
getUnsettledValueGwei(currentEpoch) {
|
|
96
|
-
let total = 0;
|
|
97
|
-
for (const bidsForSlot of this.bidsBySlot.values()) {
|
|
98
|
-
for (const record of bidsForSlot.values()) {
|
|
99
|
-
if (record.wonBlockRoots.size === 0 || record.paymentSettled) {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
total += record.valueGwei;
|
|
103
|
-
if (!Number.isSafeInteger(total)) {
|
|
104
|
-
throw new BidLedgerError({ code: BidLedgerErrorCode.UNSETTLED_VALUE_OVERFLOW, currentEpoch }, `Unsettled bid value exceeds the safe integer range currentEpoch=${currentEpoch}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return total;
|
|
109
|
-
}
|
|
110
|
-
getBidsForSlot(slot) {
|
|
111
|
-
return Array.from(this.bidsBySlot.get(slot)?.values() ?? [], toRecord);
|
|
112
|
-
}
|
|
113
|
-
prune(currentSlot) {
|
|
114
|
-
let removed = 0;
|
|
115
|
-
for (const [slot, bidsForSlot] of this.bidsBySlot) {
|
|
116
|
-
if (slot >= currentSlot - KEEP_SLOTS) {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
for (const [key, record] of bidsForSlot) {
|
|
120
|
-
if (record.wonBlockRoots.size === 0 || record.paymentSettled) {
|
|
121
|
-
bidsForSlot.delete(key);
|
|
122
|
-
removed++;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (bidsForSlot.size === 0) {
|
|
126
|
-
this.bidsBySlot.delete(slot);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
for (const [blockRoot, revealedPayload] of this.revealedPayloadByBlockRoot) {
|
|
130
|
-
if (revealedPayload.slot < currentSlot - KEEP_SLOTS) {
|
|
131
|
-
this.revealedPayloadByBlockRoot.delete(blockRoot);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return removed;
|
|
135
|
-
}
|
|
136
|
-
getBid(slot, parentBlockHash, parentBlockRoot) {
|
|
137
|
-
return this.bidsBySlot.get(slot)?.get(tupleKey(parentBlockHash, parentBlockRoot)) ?? null;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function tupleKey(parentBlockHash, parentBlockRoot) {
|
|
141
|
-
return `${parentBlockHash}:${parentBlockRoot}`;
|
|
142
|
-
}
|
|
143
|
-
function toRecord(record) {
|
|
144
|
-
return {
|
|
145
|
-
slot: record.slot,
|
|
146
|
-
parentBlockHash: record.parentBlockHash,
|
|
147
|
-
parentBlockRoot: record.parentBlockRoot,
|
|
148
|
-
blockHash: record.blockHash,
|
|
149
|
-
valueGwei: record.valueGwei,
|
|
150
|
-
signedBidRoot: record.signedBidRoot,
|
|
151
|
-
wonBlockRoots: Array.from(record.wonBlockRoots),
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
//# sourceMappingURL=bidLedger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,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AAE,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,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,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"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export type BidContext = {
|
|
2
|
-
/** Value of the payload to the builder's fee recipient, as reported by the execution client */
|
|
3
|
-
payloadValueGwei: number;
|
|
4
|
-
/** Builder balance that can back a bid, excess over the minimum and unsettled payments */
|
|
5
|
-
coverableGwei: number;
|
|
6
|
-
};
|
|
7
|
-
/** Decides how much to pay the proposer for a payload, null means do not bid */
|
|
8
|
-
export interface BidPolicy {
|
|
9
|
-
computeValue(ctx: BidContext): number | null;
|
|
10
|
-
}
|
|
11
|
-
export type ProportionalBidPolicyOpts = {
|
|
12
|
-
/** Share of the payload value offered to the proposer, in basis points */
|
|
13
|
-
shareBps: number;
|
|
14
|
-
/** Fixed amount deducted from the share, e.g. to cover operating cost */
|
|
15
|
-
fixedCostGwei: number;
|
|
16
|
-
/** Never bid below this value */
|
|
17
|
-
minValueGwei: number;
|
|
18
|
-
/** Never bid above this value */
|
|
19
|
-
maxValueGwei?: number;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Offers a fixed share of the payload value, bounded by the configured limits and the
|
|
23
|
-
* builder's coverable balance. Independent of competing bids.
|
|
24
|
-
*/
|
|
25
|
-
export declare class ProportionalBidPolicy implements BidPolicy {
|
|
26
|
-
private readonly opts;
|
|
27
|
-
constructor(opts: ProportionalBidPolicyOpts);
|
|
28
|
-
computeValue({ payloadValueGwei, coverableGwei }: BidContext): number | null;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=bidPolicy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bidPolicy.d.ts","sourceRoot":"","sources":["../../src/services/bidPolicy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,+FAA+F;IAC/F,gBAAgB,EAAE,MAAM,CAAC;IACzB,0FAA0F;IAC1F,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;CAC9C;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,SAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,yBAAyB,EAqB3D;IAED,YAAY,CAAC,EAAC,gBAAgB,EAAE,aAAa,EAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAYzE;CACF"}
|