@xyo-network/chain-orchestration 1.23.0 → 2.0.0
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/dist/browser/index.mjs +316 -382
- package/dist/browser/index.mjs.map +7 -1
- package/dist/browser/node/config/tryParseConfig.d.ts +0 -1
- package/dist/browser/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/browser/shared/actor/v3/ActorV3.d.ts +7 -7
- package/dist/browser/shared/actor/v3/ActorV3.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Api.d.ts +57 -61
- package/dist/browser/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Bridge.d.ts +86 -86
- package/dist/browser/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Finalizer.d.ts +55 -61
- package/dist/browser/shared/config/actors/Finalizer.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Mempool.d.ts +57 -63
- package/dist/browser/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Producer.d.ts +56 -62
- package/dist/browser/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/RewardRedemption.d.ts +52 -58
- package/dist/browser/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/dist/neutral/index.mjs +316 -382
- package/dist/neutral/index.mjs.map +7 -1
- package/dist/neutral/node/config/tryParseConfig.d.ts +0 -1
- package/dist/neutral/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/neutral/shared/actor/v3/ActorV3.d.ts +7 -7
- package/dist/neutral/shared/actor/v3/ActorV3.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Api.d.ts +57 -61
- package/dist/neutral/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Bridge.d.ts +86 -86
- package/dist/neutral/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Finalizer.d.ts +55 -61
- package/dist/neutral/shared/config/actors/Finalizer.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Mempool.d.ts +57 -63
- package/dist/neutral/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Producer.d.ts +56 -62
- package/dist/neutral/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/RewardRedemption.d.ts +52 -58
- package/dist/neutral/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/dist/node/index.mjs +863 -890
- package/dist/node/index.mjs.map +7 -1
- package/dist/node/node/config/tryParseConfig.d.ts +0 -1
- package/dist/node/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/node/shared/actor/v3/ActorV3.d.ts +7 -7
- package/dist/node/shared/actor/v3/ActorV3.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Api.d.ts +57 -61
- package/dist/node/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Bridge.d.ts +86 -86
- package/dist/node/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Finalizer.d.ts +55 -61
- package/dist/node/shared/config/actors/Finalizer.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Mempool.d.ts +57 -63
- package/dist/node/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Producer.d.ts +56 -62
- package/dist/node/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/node/shared/config/actors/RewardRedemption.d.ts +52 -58
- package/dist/node/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/package.json +92 -92
package/dist/node/index.mjs
CHANGED
|
@@ -1,34 +1,45 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
if (decorator = decorators[i])
|
|
8
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
+
if (kind && result) __defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3
13
|
|
|
4
14
|
// src/shared/actor/v3/ActorV3.ts
|
|
5
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
AbstractCreatable,
|
|
17
|
+
assertEx,
|
|
18
|
+
delay,
|
|
19
|
+
IdLogger
|
|
20
|
+
} from "@xylabs/sdk-js";
|
|
6
21
|
import { Semaphore } from "async-mutex";
|
|
7
|
-
import z from "zod";
|
|
8
|
-
var noopCounter = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
var noopGauge = {
|
|
17
|
-
record: /* @__PURE__ */ __name(() => {
|
|
18
|
-
}, "record")
|
|
19
|
-
};
|
|
20
|
-
var noopHistogram = {
|
|
21
|
-
record: /* @__PURE__ */ __name(() => {
|
|
22
|
-
}, "record")
|
|
23
|
-
};
|
|
22
|
+
import { z } from "zod/mini";
|
|
23
|
+
var noopCounter = { add: () => {
|
|
24
|
+
} };
|
|
25
|
+
var noopUpDownCounter = { add: () => {
|
|
26
|
+
} };
|
|
27
|
+
var noopGauge = { record: () => {
|
|
28
|
+
} };
|
|
29
|
+
var noopHistogram = { record: () => {
|
|
30
|
+
} };
|
|
24
31
|
var CreatableNameZod = z.custom((val) => typeof val === "string" && val.length > 0);
|
|
25
|
-
var StatusReporterInstanceZod = z.custom(
|
|
26
|
-
|
|
32
|
+
var StatusReporterInstanceZod = z.custom(
|
|
33
|
+
(val) => val !== null && typeof val === "object" && "report" in val
|
|
34
|
+
);
|
|
35
|
+
var AccountInstanceZod = z.custom(
|
|
36
|
+
(val) => val !== null && typeof val === "object" && "address" in val
|
|
37
|
+
);
|
|
27
38
|
var ActorParamsV3Zod = z.object({
|
|
28
39
|
account: AccountInstanceZod,
|
|
29
40
|
locator: z.unknown(),
|
|
30
41
|
name: CreatableNameZod,
|
|
31
|
-
statusReporter:
|
|
42
|
+
statusReporter: z.optional(StatusReporterInstanceZod)
|
|
32
43
|
});
|
|
33
44
|
function createDeferred() {
|
|
34
45
|
let resolve;
|
|
@@ -43,11 +54,7 @@ function createDeferred() {
|
|
|
43
54
|
reject
|
|
44
55
|
};
|
|
45
56
|
}
|
|
46
|
-
__name(createDeferred, "createDeferred");
|
|
47
57
|
var ActorV3 = class extends AbstractCreatable {
|
|
48
|
-
static {
|
|
49
|
-
__name(this, "ActorV3");
|
|
50
|
-
}
|
|
51
58
|
_intervals = /* @__PURE__ */ new Map();
|
|
52
59
|
_semaphores = /* @__PURE__ */ new Map();
|
|
53
60
|
_timeouts = /* @__PURE__ */ new Map();
|
|
@@ -56,7 +63,10 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
56
63
|
_readyError;
|
|
57
64
|
_readyState = "pending";
|
|
58
65
|
get logger() {
|
|
59
|
-
this._logger = new IdLogger(
|
|
66
|
+
this._logger = new IdLogger(
|
|
67
|
+
assertEx(this.context.logger, () => `Logger is required in context for actor ${this.name}.`),
|
|
68
|
+
() => this.name
|
|
69
|
+
);
|
|
60
70
|
return this._logger;
|
|
61
71
|
}
|
|
62
72
|
get readyError() {
|
|
@@ -75,10 +85,9 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
75
85
|
return this.params.locator;
|
|
76
86
|
}
|
|
77
87
|
static async paramsHandler(params) {
|
|
78
|
-
const baseParams = await super.paramsHandler(
|
|
79
|
-
...params,
|
|
80
|
-
|
|
81
|
-
});
|
|
88
|
+
const baseParams = await super.paramsHandler(
|
|
89
|
+
{ ...params, name: params.name ?? "UnknownActor" }
|
|
90
|
+
);
|
|
82
91
|
const account = assertEx(params.account, () => `params.account is required for actor ${baseParams.name}.`);
|
|
83
92
|
const locator = assertEx(params.locator, () => `params.locator is required for actor ${baseParams.name}.`);
|
|
84
93
|
return {
|
|
@@ -88,8 +97,8 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
88
97
|
};
|
|
89
98
|
}
|
|
90
99
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
* The timer runs until the actor is deactivated (or you manually stop it).
|
|
101
|
+
*/
|
|
93
102
|
registerTimer(timerName, callback, dueTimeMs, periodMs) {
|
|
94
103
|
if (this.status !== "starting") {
|
|
95
104
|
this.logger?.warn(`Cannot register timer '${timerName}' because actor is not starting.`);
|
|
@@ -134,10 +143,10 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
134
143
|
this.logger?.debug(`Timer '${this.name}:${timerName}' registered: first call after ${dueTimeMs}ms, recurring every ${periodMs}ms.`);
|
|
135
144
|
}
|
|
136
145
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
146
|
+
* Invoked by the Orchestrator after `start()` to run the warm-pass.
|
|
147
|
+
* Idempotent: returns immediately if already invoked.
|
|
148
|
+
* Throws if `readyHandler` throws; resolves once `readyHandler` resolves.
|
|
149
|
+
*/
|
|
141
150
|
async runReadyHandler() {
|
|
142
151
|
if (this._readyState !== "pending") return;
|
|
143
152
|
try {
|
|
@@ -155,15 +164,15 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
155
164
|
async stopHandler() {
|
|
156
165
|
await super.stopHandler();
|
|
157
166
|
this.logger?.debug("Stopping all timers...");
|
|
158
|
-
await Promise.all(
|
|
159
|
-
...this._semaphores.values()
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
await Promise.all(
|
|
168
|
+
[...this._semaphores.values()].map(async (semaphore) => {
|
|
169
|
+
while (semaphore.isLocked()) {
|
|
170
|
+
this.logger?.debug("Waiting for running timer task to complete...");
|
|
171
|
+
await delay(500);
|
|
172
|
+
}
|
|
173
|
+
await semaphore.acquire();
|
|
174
|
+
})
|
|
175
|
+
);
|
|
167
176
|
this._semaphores.clear();
|
|
168
177
|
for (const [, timeoutRef] of this._timeouts.entries()) {
|
|
169
178
|
clearTimeout(timeoutRef);
|
|
@@ -187,58 +196,44 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
187
196
|
}, timeoutMs);
|
|
188
197
|
});
|
|
189
198
|
try {
|
|
190
|
-
await Promise.race([
|
|
191
|
-
this._readyDeferred.promise,
|
|
192
|
-
timeout
|
|
193
|
-
]);
|
|
199
|
+
await Promise.race([this._readyDeferred.promise, timeout]);
|
|
194
200
|
} finally {
|
|
195
201
|
if (timer) clearTimeout(timer);
|
|
196
202
|
}
|
|
197
203
|
}
|
|
198
204
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
* Create a `Counter` instrument bound to this actor's meter, or a no-op
|
|
206
|
+
* stub if telemetry is not wired. Always returns a non-undefined value so
|
|
207
|
+
* call sites can drop the optional-chain on `.add()`.
|
|
208
|
+
*
|
|
209
|
+
* TODO: in a future pass, consider folding these single-instrument helpers
|
|
210
|
+
* into a declarative `createActorMeters({ counters: {...}, gauges: {...} })`
|
|
211
|
+
* spec API for actors with many instruments.
|
|
212
|
+
*/
|
|
207
213
|
counter(name, description) {
|
|
208
|
-
return this.meter?.createCounter(name, {
|
|
209
|
-
description
|
|
210
|
-
}) ?? noopCounter;
|
|
214
|
+
return this.meter?.createCounter(name, { description }) ?? noopCounter;
|
|
211
215
|
}
|
|
212
216
|
/** Create a synchronous `Gauge` instrument, or a no-op stub if telemetry is not wired. */
|
|
213
217
|
gauge(name, description) {
|
|
214
|
-
return this.meter?.createGauge(name, {
|
|
215
|
-
description
|
|
216
|
-
}) ?? noopGauge;
|
|
218
|
+
return this.meter?.createGauge(name, { description }) ?? noopGauge;
|
|
217
219
|
}
|
|
218
220
|
/** Create a `Histogram` instrument, or a no-op stub if telemetry is not wired. */
|
|
219
221
|
histogram(name, description) {
|
|
220
|
-
return this.meter?.createHistogram(name, {
|
|
221
|
-
description
|
|
222
|
-
}) ?? noopHistogram;
|
|
222
|
+
return this.meter?.createHistogram(name, { description }) ?? noopHistogram;
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
* Override in subclasses to prove the actor can do useful work.
|
|
226
|
+
* Default: no-op (the actor declares itself ready as soon as `start()` returns).
|
|
227
|
+
*/
|
|
228
228
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
229
229
|
async readyHandler() {
|
|
230
230
|
}
|
|
231
231
|
/** Create an `UpDownCounter` instrument, or a no-op stub if telemetry is not wired. */
|
|
232
232
|
upDownCounter(name, description) {
|
|
233
|
-
return this.meter?.createUpDownCounter(name, {
|
|
234
|
-
description
|
|
235
|
-
}) ?? noopUpDownCounter;
|
|
233
|
+
return this.meter?.createUpDownCounter(name, { description }) ?? noopUpDownCounter;
|
|
236
234
|
}
|
|
237
235
|
};
|
|
238
236
|
var Actor = class extends ActorV3 {
|
|
239
|
-
static {
|
|
240
|
-
__name(this, "Actor");
|
|
241
|
-
}
|
|
242
237
|
};
|
|
243
238
|
|
|
244
239
|
// src/shared/buildTelemetryConfig.ts
|
|
@@ -246,89 +241,96 @@ function buildTelemetryConfig(config, serviceName, serviceVersion, defaultMetric
|
|
|
246
241
|
const { otlpEndpoint } = config.telemetry?.otel ?? {};
|
|
247
242
|
const { path: endpoint = "/metrics", port = defaultMetricsScrapePort } = config.telemetry?.metrics?.scrape ?? {};
|
|
248
243
|
const telemetryConfig = {
|
|
249
|
-
attributes: {
|
|
250
|
-
serviceName,
|
|
251
|
-
serviceVersion
|
|
252
|
-
},
|
|
244
|
+
attributes: { serviceName, serviceVersion },
|
|
253
245
|
otlpEndpoint,
|
|
254
|
-
metricsConfig: {
|
|
255
|
-
endpoint,
|
|
256
|
-
port
|
|
257
|
-
}
|
|
246
|
+
metricsConfig: { endpoint, port }
|
|
258
247
|
};
|
|
259
248
|
return telemetryConfig;
|
|
260
249
|
}
|
|
261
|
-
__name(buildTelemetryConfig, "buildTelemetryConfig");
|
|
262
250
|
|
|
263
251
|
// src/shared/config/actors/Api.ts
|
|
264
|
-
import {
|
|
252
|
+
import {
|
|
253
|
+
zodAsFactory,
|
|
254
|
+
zodIsFactory,
|
|
255
|
+
zodToFactory
|
|
256
|
+
} from "@xylabs/sdk-js";
|
|
265
257
|
import { BaseConfigContextZod, HostActorConfigZod } from "@xyo-network/xl1-sdk";
|
|
266
|
-
import { globalRegistry, z as z2 } from "zod";
|
|
267
|
-
var
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
z2.boolean()
|
|
272
|
-
|
|
258
|
+
import { globalRegistry, z as z2 } from "zod/mini";
|
|
259
|
+
var toBooleanDefaultTrue = (v) => v !== "0" && v !== "false" && v !== false && v !== 0;
|
|
260
|
+
var toBooleanDefaultFalse = (v) => v === "1" || v === "true" || v === true || v === 1;
|
|
261
|
+
var ApiConfigZod = z2.extend(HostActorConfigZod, {
|
|
262
|
+
initRewardsCache: z2._default(
|
|
263
|
+
z2.pipe(z2.union([z2.number(), z2.string(), z2.boolean()]), z2.transform(toBooleanDefaultTrue)),
|
|
264
|
+
true
|
|
265
|
+
).register(globalRegistry, {
|
|
273
266
|
description: "Whether to initialize the rewards cache on startup",
|
|
274
267
|
title: "api.initRewardsCache",
|
|
275
268
|
type: "boolean"
|
|
276
269
|
}),
|
|
277
270
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
stateless: z2.
|
|
286
|
-
z2.number(),
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
]).transform((v) => v === "1" || v === "true" || v === true || v == 1).default(false).register(globalRegistry, {
|
|
271
|
+
* When `true`, the API actor runs in stateless mode: it holds no local
|
|
272
|
+
* backing-store ownership, never loads the local LMDB/MongoDB node, and
|
|
273
|
+
* federates every JSON-RPC request to upstream owner-actors via `JsonRpc*`
|
|
274
|
+
* providers. Multiple stateless API instances can run behind a load
|
|
275
|
+
* balancer for horizontal scaling. Requires `remote.rpc` to point at the
|
|
276
|
+
* upstream API/Finalizer/Mempool/Indexer surfaces.
|
|
277
|
+
*/
|
|
278
|
+
stateless: z2._default(
|
|
279
|
+
z2.pipe(z2.union([z2.number(), z2.string(), z2.boolean()]), z2.transform(toBooleanDefaultFalse)),
|
|
280
|
+
false
|
|
281
|
+
).register(globalRegistry, {
|
|
290
282
|
description: "Run the API actor as a stateless federation node (availableBackings: [network])",
|
|
291
283
|
title: "api.stateless",
|
|
292
284
|
type: "boolean"
|
|
293
285
|
}),
|
|
294
286
|
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
legacyMixedRpc: z2.
|
|
309
|
-
z2.number(),
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
]).transform((v) => v !== "0" && v !== "false" && v !== false && v != 0).default(true).register(globalRegistry, {
|
|
287
|
+
* Back-compat for the surface-aware route split. When `true`, `POST /rpc`
|
|
288
|
+
* serves the full `XyoConnection` (both node-surface and indexed-surface
|
|
289
|
+
* methods), preserving pre-Phase-7 behavior for clients that haven't yet
|
|
290
|
+
* migrated to `POST /rpc/indexed`. When `false`, `/rpc` is strictly
|
|
291
|
+
* node-surface only and indexed methods are 404 at `/rpc`.
|
|
292
|
+
*
|
|
293
|
+
* `/rpc/indexed` mounts independently of this flag whenever the locator's
|
|
294
|
+
* connection has any indexed branch.
|
|
295
|
+
*
|
|
296
|
+
* Default `true` for the first release that includes Phase 7 — flip to
|
|
297
|
+
* `false` per environment once external clients (explorers, wallets, dApps)
|
|
298
|
+
* have moved their indexed-method calls to `/rpc/indexed`.
|
|
299
|
+
*/
|
|
300
|
+
legacyMixedRpc: z2._default(
|
|
301
|
+
z2.pipe(z2.union([z2.number(), z2.string(), z2.boolean()]), z2.transform(toBooleanDefaultTrue)),
|
|
302
|
+
true
|
|
303
|
+
).register(globalRegistry, {
|
|
313
304
|
description: "Serve the full XyoConnection at POST /rpc (no surface filter). Set false to enforce node-surface-only at /rpc; indexed methods always available at /rpc/indexed regardless.",
|
|
314
305
|
title: "api.legacyMixedRpc",
|
|
315
306
|
type: "boolean"
|
|
316
307
|
})
|
|
317
|
-
})
|
|
308
|
+
});
|
|
318
309
|
var isApiConfig = zodIsFactory(ApiConfigZod);
|
|
319
310
|
var asApiConfig = zodAsFactory(ApiConfigZod, "asApiConfig");
|
|
320
311
|
var toApiConfig = zodToFactory(ApiConfigZod, "toApiConfig");
|
|
321
|
-
var ApiConfigContext =
|
|
322
|
-
config: ApiConfigZod
|
|
323
|
-
});
|
|
312
|
+
var ApiConfigContext = z2.extend(BaseConfigContextZod, { config: ApiConfigZod });
|
|
324
313
|
var isApiConfigContext = zodIsFactory(ApiConfigContext);
|
|
325
314
|
var asApiConfigContext = zodAsFactory(ApiConfigContext, "asApiConfigContext");
|
|
326
315
|
var toApiConfigContext = zodToFactory(ApiConfigContext, "toApiConfigContext");
|
|
327
316
|
|
|
328
317
|
// src/shared/config/actors/Bridge.ts
|
|
329
|
-
import {
|
|
330
|
-
|
|
331
|
-
|
|
318
|
+
import {
|
|
319
|
+
AddressZod,
|
|
320
|
+
HexZod,
|
|
321
|
+
toAddress,
|
|
322
|
+
toHex,
|
|
323
|
+
zodAsFactory as zodAsFactory2,
|
|
324
|
+
zodIsFactory as zodIsFactory2,
|
|
325
|
+
zodToFactory as zodToFactory2
|
|
326
|
+
} from "@xylabs/sdk-js";
|
|
327
|
+
import {
|
|
328
|
+
AttoXL1ConvertFactor,
|
|
329
|
+
BaseConfigContextZod as BaseConfigContextZod2,
|
|
330
|
+
HostActorConfigZod as HostActorConfigZod2,
|
|
331
|
+
XL1
|
|
332
|
+
} from "@xyo-network/xl1-sdk";
|
|
333
|
+
import { globalRegistry as globalRegistry2, z as z3 } from "zod/mini";
|
|
332
334
|
var DEFAULT_FIXED_FEE = toHex(XL1(1000n) * AttoXL1ConvertFactor.xl1);
|
|
333
335
|
var DEFAULT_VARIABLE_FEE_BASIS_POINTS = 300;
|
|
334
336
|
var DEFAULT_HARDHAT_BRIDGE_CONTRACT = toAddress("2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6");
|
|
@@ -338,103 +340,108 @@ var DEFAULT_HARDHAT_TOKEN_CONTRACT = toAddress("5FbDB2315678afecb367f032d93F642f
|
|
|
338
340
|
var DEFAULT_MAX_BRIDGE_AMOUNT = toHex(XL1(1000000n) * AttoXL1ConvertFactor.xl1);
|
|
339
341
|
var DEFAULT_MIN_BRIDGE_AMOUNT = toHex(XL1(1500n) * AttoXL1ConvertFactor.xl1);
|
|
340
342
|
var DEFAULT_SCANNER_INTERVAL_MS = 3e4;
|
|
341
|
-
var BasisPointsZod = z3.coerce.number().
|
|
342
|
-
var BridgeConfigZod =
|
|
343
|
-
escrowAddress:
|
|
343
|
+
var BasisPointsZod = z3.coerce.number().check(z3.multipleOf(1), z3.nonnegative(), z3.maximum(1e4));
|
|
344
|
+
var BridgeConfigZod = z3.extend(HostActorConfigZod2, {
|
|
345
|
+
escrowAddress: z3.optional(AddressZod).register(globalRegistry2, {
|
|
344
346
|
description: "Address to which bridge escrow will be sent",
|
|
345
347
|
title: "bridge.escrowAddress",
|
|
346
348
|
type: "string"
|
|
347
349
|
}),
|
|
348
|
-
feesAddress:
|
|
350
|
+
feesAddress: z3.optional(AddressZod).register(globalRegistry2, {
|
|
349
351
|
description: "Address to which bridge fees will be sent",
|
|
350
352
|
title: "bridge.feesAddress",
|
|
351
353
|
type: "string"
|
|
352
354
|
}),
|
|
353
|
-
feeFixed:
|
|
355
|
+
feeFixed: z3._default(HexZod, DEFAULT_FIXED_FEE).register(globalRegistry2, {
|
|
354
356
|
default: DEFAULT_FIXED_FEE,
|
|
355
357
|
description: "Fixed fee (in AttoXL1) applied to bridge transfers",
|
|
356
358
|
title: "bridge.feeFixed",
|
|
357
359
|
type: "bigint"
|
|
358
360
|
}),
|
|
359
|
-
feeRateBasisPoints:
|
|
361
|
+
feeRateBasisPoints: z3._default(BasisPointsZod, DEFAULT_VARIABLE_FEE_BASIS_POINTS).register(globalRegistry2, {
|
|
360
362
|
default: DEFAULT_VARIABLE_FEE_BASIS_POINTS,
|
|
361
363
|
description: "Variable rate fee (in basis points where 1 bps = 0.01%) applied to bridge transfers",
|
|
362
364
|
title: "bridge.feeRateBasisPoints",
|
|
363
365
|
type: "number"
|
|
364
366
|
}),
|
|
365
|
-
maxBridgeAmount:
|
|
367
|
+
maxBridgeAmount: z3._default(HexZod, DEFAULT_MAX_BRIDGE_AMOUNT).register(globalRegistry2, {
|
|
366
368
|
default: DEFAULT_MAX_BRIDGE_AMOUNT,
|
|
367
369
|
description: "Maximum amount allowed for a bridge transfer",
|
|
368
370
|
title: "bridge.maxBridgeAmount",
|
|
369
371
|
type: "string"
|
|
370
372
|
}),
|
|
371
|
-
minBridgeAmount:
|
|
373
|
+
minBridgeAmount: z3._default(HexZod, DEFAULT_MIN_BRIDGE_AMOUNT).register(globalRegistry2, {
|
|
372
374
|
default: DEFAULT_MIN_BRIDGE_AMOUNT,
|
|
373
375
|
description: "Minimum amount required for a bridge transfer",
|
|
374
376
|
title: "bridge.minBridgeAmount",
|
|
375
377
|
type: "string"
|
|
376
378
|
}),
|
|
377
|
-
redisHost: z3.string()
|
|
379
|
+
redisHost: z3._default(z3.string(), "localhost").register(globalRegistry2, {
|
|
378
380
|
default: "localhost",
|
|
379
381
|
description: "Host for the Bridge Redis instance",
|
|
380
382
|
title: "bridge.redisHost",
|
|
381
383
|
type: "string"
|
|
382
384
|
}),
|
|
383
|
-
redisPort: z3.coerce.number().
|
|
385
|
+
redisPort: z3._default(z3.coerce.number().check(z3.multipleOf(1), z3.positive()), 6379).register(globalRegistry2, {
|
|
384
386
|
default: 6379,
|
|
385
387
|
description: "Port for the Bridge Redis instance",
|
|
386
388
|
title: "bridge.redisPort",
|
|
387
389
|
type: "number"
|
|
388
390
|
}),
|
|
389
|
-
scannerIntervalMs: z3.coerce.number().
|
|
391
|
+
scannerIntervalMs: z3._default(z3.coerce.number().check(z3.multipleOf(1), z3.positive()), DEFAULT_SCANNER_INTERVAL_MS).register(globalRegistry2, {
|
|
390
392
|
default: DEFAULT_SCANNER_INTERVAL_MS,
|
|
391
393
|
description: "How often (ms) the EVM->XL1 scanner polls the remote bridge contract for new BridgedToRemote ids confirmed at depth.",
|
|
392
394
|
title: "bridge.scannerIntervalMs",
|
|
393
395
|
type: "number"
|
|
394
396
|
}),
|
|
395
|
-
remoteBridgeContractAddress:
|
|
397
|
+
remoteBridgeContractAddress: z3._default(AddressZod, DEFAULT_HARDHAT_BRIDGE_CONTRACT).register(globalRegistry2, {
|
|
396
398
|
default: DEFAULT_HARDHAT_BRIDGE_CONTRACT,
|
|
397
399
|
description: "Hex representation of remote token address used for bridging",
|
|
398
400
|
title: "bridge.remoteBridgeContractAddress",
|
|
399
401
|
type: "string"
|
|
400
402
|
}),
|
|
401
|
-
|
|
403
|
+
remoteBridgeContractDeployBlock: z3.optional(z3.coerce.number().check(z3.multipleOf(1), z3.nonnegative())).register(globalRegistry2, {
|
|
404
|
+
description: "EVM block at which the remote bridge contract was deployed. When unset, the bridge actor probes the chain via eth_getCode at actor startup. Setting this avoids the probe and is cheaper for chains with high heads; it must be at or before the actual deploy block.",
|
|
405
|
+
title: "bridge.remoteBridgeContractDeployBlock",
|
|
406
|
+
type: "number"
|
|
407
|
+
}),
|
|
408
|
+
remoteChainId: z3._default(HexZod, DEFAULT_HARDHAT_CHAIN_ID).register(globalRegistry2, {
|
|
402
409
|
default: DEFAULT_HARDHAT_CHAIN_ID,
|
|
403
410
|
description: "Remote chain ID",
|
|
404
411
|
title: "bridge.remoteChainId",
|
|
405
412
|
type: "string"
|
|
406
413
|
}),
|
|
407
|
-
remoteConfirmationDepth: z3.union([
|
|
408
|
-
z3.coerce.number().
|
|
414
|
+
remoteConfirmationDepth: z3.optional(z3.union([
|
|
415
|
+
z3.coerce.number().check(z3.multipleOf(1), z3.nonnegative()),
|
|
409
416
|
z3.literal("finalized")
|
|
410
|
-
])
|
|
417
|
+
])).register(globalRegistry2, {
|
|
411
418
|
description: "Block depth or BlockTag at which the remote (EVM) chain is read as canonical. Numeric: number of confirmations behind head. 'finalized': Casper FFG finalized block. Resolved per-chain by getRemoteConfirmationDepth when unset.",
|
|
412
419
|
title: "bridge.remoteConfirmationDepth",
|
|
413
420
|
type: "string"
|
|
414
421
|
}),
|
|
415
|
-
remoteTokenAddress:
|
|
422
|
+
remoteTokenAddress: z3._default(HexZod, DEFAULT_HARDHAT_TOKEN_CONTRACT).register(globalRegistry2, {
|
|
416
423
|
default: DEFAULT_HARDHAT_TOKEN_CONTRACT,
|
|
417
424
|
description: "Hex representation of remote token address used for bridging",
|
|
418
425
|
title: "bridge.remoteTokenAddress",
|
|
419
426
|
type: "string"
|
|
420
427
|
}),
|
|
421
|
-
remoteChainWalletPrivateKey:
|
|
428
|
+
remoteChainWalletPrivateKey: z3._default(HexZod, DEFAULT_HARDHAT_REMOTE_CHAIN_WALLET_PRIVATE_KEY).register(globalRegistry2, {
|
|
422
429
|
description: "Private key for the wallet to use for the remote chain wallet",
|
|
423
430
|
title: "bridge.remoteChainWalletPrivateKey",
|
|
424
431
|
type: "string"
|
|
425
432
|
}),
|
|
426
|
-
xl1ChainId:
|
|
433
|
+
xl1ChainId: z3.optional(HexZod).register(globalRegistry2, {
|
|
427
434
|
description: "XL1 chain id used for bridging",
|
|
428
435
|
title: "bridge.xl1ChainId",
|
|
429
436
|
type: "string"
|
|
430
437
|
}),
|
|
431
|
-
xl1TokenAddress:
|
|
438
|
+
xl1TokenAddress: z3.optional(HexZod).register(globalRegistry2, {
|
|
432
439
|
description: "XL1 token address used for bridging",
|
|
433
440
|
title: "bridge.xl1TokenAddress",
|
|
434
441
|
type: "string"
|
|
435
442
|
})
|
|
436
443
|
});
|
|
437
|
-
var BridgeSettingsZod =
|
|
444
|
+
var BridgeSettingsZod = z3.required(z3.pick(BridgeConfigZod, {
|
|
438
445
|
feeFixed: true,
|
|
439
446
|
feeRateBasisPoints: true,
|
|
440
447
|
feesAddress: true,
|
|
@@ -445,94 +452,98 @@ var BridgeSettingsZod = BridgeConfigZod.pick({
|
|
|
445
452
|
remoteTokenAddress: true,
|
|
446
453
|
xl1TokenAddress: true,
|
|
447
454
|
xl1ChainId: true
|
|
448
|
-
})
|
|
455
|
+
}));
|
|
449
456
|
var isBridgeConfig = zodIsFactory2(BridgeConfigZod);
|
|
450
457
|
var asBridgeConfig = zodAsFactory2(BridgeConfigZod, "asBridgeConfig");
|
|
451
458
|
var toBridgeConfig = zodToFactory2(BridgeConfigZod, "toBridgeConfig");
|
|
452
|
-
var BridgeConfigContext =
|
|
453
|
-
config: BridgeConfigZod
|
|
454
|
-
});
|
|
459
|
+
var BridgeConfigContext = z3.extend(BaseConfigContextZod2, { config: BridgeConfigZod });
|
|
455
460
|
var isBridgeConfigContext = zodIsFactory2(BridgeConfigContext);
|
|
456
461
|
var asBridgeConfigContext = zodAsFactory2(BridgeConfigContext, "asBridgeConfigContext");
|
|
457
462
|
var toBridgeConfigContext = zodToFactory2(BridgeConfigContext, "toBridgeConfigContext");
|
|
458
463
|
|
|
459
464
|
// src/shared/config/actors/Finalizer.ts
|
|
460
|
-
import {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
+
import {
|
|
466
|
+
AddressZod as AddressZod2,
|
|
467
|
+
zodAsFactory as zodAsFactory3,
|
|
468
|
+
zodIsFactory as zodIsFactory3,
|
|
469
|
+
zodToFactory as zodToFactory3
|
|
470
|
+
} from "@xylabs/sdk-js";
|
|
471
|
+
import {
|
|
472
|
+
BaseConfigContextZod as BaseConfigContextZod3,
|
|
473
|
+
DEFAULT_MIN_CANDIDATES,
|
|
474
|
+
HostActorConfigZod as HostActorConfigZod3
|
|
475
|
+
} from "@xyo-network/xl1-sdk";
|
|
476
|
+
import { z as z4 } from "zod/mini";
|
|
477
|
+
var FinalizerConfigZod = z4.extend(HostActorConfigZod3, {
|
|
478
|
+
allowedProducers: z4.optional(z4.array(AddressZod2)),
|
|
465
479
|
// Period (ms) between finalizer ticks. Default matches the historical
|
|
466
480
|
// hardcoded value in FinalizerActor; tests can lower it to drive faster
|
|
467
481
|
// block finalization.
|
|
468
|
-
finalizationCheckInterval: z4.coerce.number()
|
|
469
|
-
minCandidates: z4.number().
|
|
482
|
+
finalizationCheckInterval: z4._default(z4.coerce.number(), 500),
|
|
483
|
+
minCandidates: z4._default(z4.number().check(z4.multipleOf(1), z4.nonnegative()), DEFAULT_MIN_CANDIDATES)
|
|
470
484
|
});
|
|
471
485
|
var isFinalizerConfig = zodIsFactory3(FinalizerConfigZod);
|
|
472
486
|
var asFinalizerConfig = zodAsFactory3(FinalizerConfigZod, "asFinalizerConfig");
|
|
473
487
|
var toFinalizerConfig = zodToFactory3(FinalizerConfigZod, "toFinalizerConfig");
|
|
474
|
-
var FinalizerConfigContext =
|
|
475
|
-
config: FinalizerConfigZod
|
|
476
|
-
});
|
|
488
|
+
var FinalizerConfigContext = z4.extend(BaseConfigContextZod3, { config: FinalizerConfigZod });
|
|
477
489
|
var isFinalizerConfigContext = zodIsFactory3(FinalizerConfigContext);
|
|
478
490
|
var asFinalizerConfigContext = zodAsFactory3(FinalizerConfigContext, "asFinalizerConfigContext");
|
|
479
491
|
var toFinalizerConfigContext = zodToFactory3(FinalizerConfigContext, "toFinalizerConfigContext");
|
|
480
492
|
|
|
481
493
|
// src/shared/config/actors/Mempool.ts
|
|
482
|
-
import {
|
|
494
|
+
import {
|
|
495
|
+
zodAsFactory as zodAsFactory4,
|
|
496
|
+
zodIsFactory as zodIsFactory4,
|
|
497
|
+
zodToFactory as zodToFactory4
|
|
498
|
+
} from "@xylabs/sdk-js";
|
|
483
499
|
import { BaseConfigContextZod as BaseConfigContextZod4, HostActorConfigZod as HostActorConfigZod4 } from "@xyo-network/xl1-sdk";
|
|
484
|
-
import { globalRegistry as globalRegistry3, z as z5 } from "zod";
|
|
500
|
+
import { globalRegistry as globalRegistry3, z as z5 } from "zod/mini";
|
|
485
501
|
var DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL = 1e3;
|
|
486
502
|
var DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL = 1e3;
|
|
487
503
|
var DEFAULT_MEMPOOL_DEMOTION_THRESHOLD = 3;
|
|
488
504
|
var DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS = 0;
|
|
489
|
-
var
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (typeof val === "boolean") return val;
|
|
505
|
+
var TRUE_VALUES = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
|
|
506
|
+
var FALSE_VALUES = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
|
|
507
|
+
var FlexibleBooleanZod = z5.pipe(
|
|
508
|
+
z5.union([z5.string(), z5.boolean()]).check(z5.refine((val) => {
|
|
509
|
+
if (typeof val === "boolean") return true;
|
|
495
510
|
const normalized = val.toLowerCase().trim();
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
"off"
|
|
507
|
-
].includes(normalized)) return false;
|
|
508
|
-
ctx.addIssue({
|
|
509
|
-
code: "invalid_type",
|
|
510
|
-
expected: "boolean",
|
|
511
|
-
message: `Invalid boolean value: "${val}". Use true/false, 1/0, yes/no.`
|
|
512
|
-
});
|
|
513
|
-
return z5.NEVER;
|
|
514
|
-
}).register(globalRegistry3, {
|
|
515
|
-
default: "false",
|
|
511
|
+
return TRUE_VALUES.has(normalized) || FALSE_VALUES.has(normalized);
|
|
512
|
+
}, { error: "Invalid boolean value. Use true/false, 1/0, yes/no." })),
|
|
513
|
+
z5.transform((val) => {
|
|
514
|
+
if (typeof val === "boolean") return val;
|
|
515
|
+
return TRUE_VALUES.has(val.toLowerCase().trim());
|
|
516
|
+
})
|
|
517
|
+
);
|
|
518
|
+
var MempoolConfigZod = z5.extend(HostActorConfigZod4, {
|
|
519
|
+
enabled: z5._default(FlexibleBooleanZod, false).register(globalRegistry3, {
|
|
520
|
+
default: false,
|
|
516
521
|
description: "Enable the Mempool",
|
|
517
522
|
title: "mempool.enabled",
|
|
518
523
|
type: "boolean"
|
|
519
524
|
}),
|
|
520
|
-
blockPruneInterval: z5.coerce.number()
|
|
525
|
+
blockPruneInterval: z5._default(z5.coerce.number(), DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL).register(globalRegistry3, {
|
|
521
526
|
description: "The interval time (in milliseconds) between pending block prune attempts",
|
|
522
527
|
title: "mempool.blockPruneInterval",
|
|
523
528
|
type: "number"
|
|
524
529
|
}),
|
|
525
|
-
demotionThreshold: z5.
|
|
530
|
+
demotionThreshold: z5._default(
|
|
531
|
+
z5.coerce.number().check(z5.multipleOf(1), z5.positive()),
|
|
532
|
+
DEFAULT_MEMPOOL_DEMOTION_THRESHOLD
|
|
533
|
+
).register(globalRegistry3, {
|
|
526
534
|
description: "Number of times a transaction may be handed out to producers without being included in a block before it is considered demoted",
|
|
527
535
|
title: "mempool.demotionThreshold",
|
|
528
536
|
type: "number"
|
|
529
537
|
}),
|
|
530
|
-
maxPendingTransactions: z5.
|
|
538
|
+
maxPendingTransactions: z5._default(
|
|
539
|
+
z5.coerce.number().check(z5.multipleOf(1), z5.nonnegative()),
|
|
540
|
+
DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS
|
|
541
|
+
).register(globalRegistry3, {
|
|
531
542
|
description: "Maximum number of pending transactions in the pool. When exceeded, demoted transactions are evicted first, then oldest by sequence. 0 disables the cap.",
|
|
532
543
|
title: "mempool.maxPendingTransactions",
|
|
533
544
|
type: "number"
|
|
534
545
|
}),
|
|
535
|
-
transactionPruneInterval: z5.coerce.number()
|
|
546
|
+
transactionPruneInterval: z5._default(z5.coerce.number(), DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL).register(globalRegistry3, {
|
|
536
547
|
description: "The interval time (in milliseconds) between pending transaction prune attempts",
|
|
537
548
|
title: "mempool.transactionPruneInterval",
|
|
538
549
|
type: "number"
|
|
@@ -541,72 +552,76 @@ var MempoolConfigZod = HostActorConfigZod4.extend({
|
|
|
541
552
|
var isMempoolConfig = zodIsFactory4(MempoolConfigZod);
|
|
542
553
|
var asMempoolConfig = zodAsFactory4(MempoolConfigZod, "asMempoolConfig");
|
|
543
554
|
var toMempoolConfig = zodToFactory4(MempoolConfigZod, "toMempoolConfig");
|
|
544
|
-
var MempoolConfigContext =
|
|
545
|
-
config: MempoolConfigZod
|
|
546
|
-
});
|
|
555
|
+
var MempoolConfigContext = z5.extend(BaseConfigContextZod4, { config: MempoolConfigZod });
|
|
547
556
|
var isMempoolConfigContext = zodIsFactory4(MempoolConfigContext);
|
|
548
557
|
var asMempoolConfigContext = zodAsFactory4(MempoolConfigContext, "asMempoolConfigContext");
|
|
549
558
|
var toMempoolConfigContext = zodToFactory4(MempoolConfigContext, "toMempoolConfigContext");
|
|
550
559
|
|
|
551
560
|
// src/shared/config/actors/Producer.ts
|
|
552
|
-
import {
|
|
561
|
+
import {
|
|
562
|
+
AddressZod as AddressZod3,
|
|
563
|
+
zodAsFactory as zodAsFactory5,
|
|
564
|
+
zodIsFactory as zodIsFactory5,
|
|
565
|
+
zodToFactory as zodToFactory5
|
|
566
|
+
} from "@xylabs/sdk-js";
|
|
553
567
|
import { ActorConfigZod, BaseConfigContextZod as BaseConfigContextZod5 } from "@xyo-network/xl1-sdk";
|
|
554
|
-
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
568
|
+
import { globalRegistry as globalRegistry4, z as z6 } from "zod/mini";
|
|
555
569
|
var DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL = 1e4;
|
|
556
|
-
var ProducerConfigZod =
|
|
557
|
-
allowlist: z6.array(AddressZod3)
|
|
570
|
+
var ProducerConfigZod = z6.extend(ActorConfigZod, {
|
|
571
|
+
allowlist: z6.optional(z6.array(AddressZod3)).register(globalRegistry4, {
|
|
558
572
|
description: "List of allowed producer addresses, if undefined anyone can participate",
|
|
559
573
|
title: "allowlist",
|
|
560
574
|
type: "array"
|
|
561
575
|
}),
|
|
562
|
-
blockProductionCheckInterval: z6.coerce.number()
|
|
576
|
+
blockProductionCheckInterval: z6._default(z6.coerce.number(), DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL).register(globalRegistry4, {
|
|
563
577
|
description: "The interval time (in milliseconds) between block production attempts",
|
|
564
578
|
title: "producer.blockProductionCheckInterval",
|
|
565
579
|
type: "number"
|
|
566
580
|
}),
|
|
567
|
-
disableIntentRedeclaration: z6.
|
|
581
|
+
disableIntentRedeclaration: z6.optional(z6.boolean()).register(globalRegistry4, {
|
|
568
582
|
description: "Should the producer skip redeclaring their intent to continue producing blocks",
|
|
569
583
|
title: "producer.disableIntentRedeclaration",
|
|
570
584
|
type: "boolean"
|
|
571
585
|
}),
|
|
572
|
-
heartbeatInterval: z6.coerce.number()
|
|
586
|
+
heartbeatInterval: z6._default(z6.coerce.number(), 36e5).register(globalRegistry4, {
|
|
573
587
|
description: "The number of milliseconds between heartbeats if no blocks are produced",
|
|
574
588
|
title: "producer.heartbeatInterval",
|
|
575
589
|
type: "number"
|
|
576
590
|
}),
|
|
577
591
|
// TODO: BigInt schema
|
|
578
|
-
minStake: z6.coerce.number()
|
|
592
|
+
minStake: z6._default(z6.coerce.number(), 1).register(globalRegistry4, {
|
|
579
593
|
description: "Minimum stake required to be a Producer",
|
|
580
594
|
title: "producer.minStake",
|
|
581
595
|
type: "number"
|
|
582
596
|
}),
|
|
583
597
|
// TODO: Address schema
|
|
584
|
-
rewardAddress: z6.
|
|
598
|
+
rewardAddress: z6.optional(z6.string()).register(globalRegistry4, {
|
|
585
599
|
description: "Address to receive block rewards",
|
|
586
600
|
title: "producer.rewardAddress",
|
|
587
601
|
type: "string"
|
|
588
602
|
})
|
|
589
|
-
})
|
|
603
|
+
});
|
|
590
604
|
var isProducerConfig = zodIsFactory5(ProducerConfigZod);
|
|
591
605
|
var asProducerConfig = zodAsFactory5(ProducerConfigZod, "asProducerConfig");
|
|
592
606
|
var toProducerConfig = zodToFactory5(ProducerConfigZod, "toProducerConfig");
|
|
593
|
-
var ProducerConfigContext =
|
|
594
|
-
config: ProducerConfigZod
|
|
595
|
-
});
|
|
607
|
+
var ProducerConfigContext = z6.extend(BaseConfigContextZod5, { config: ProducerConfigZod });
|
|
596
608
|
var isProducerConfigContext = zodIsFactory5(ProducerConfigContext);
|
|
597
609
|
var asProducerConfigContext = zodAsFactory5(ProducerConfigContext, "asProducerConfigContext");
|
|
598
610
|
var toProducerConfigContext = zodToFactory5(ProducerConfigContext, "toProducerConfigContext");
|
|
599
611
|
|
|
600
612
|
// src/shared/config/actors/RewardRedemption.ts
|
|
601
|
-
import {
|
|
613
|
+
import {
|
|
614
|
+
zodAsFactory as zodAsFactory6,
|
|
615
|
+
zodIsFactory as zodIsFactory6,
|
|
616
|
+
zodToFactory as zodToFactory6
|
|
617
|
+
} from "@xylabs/sdk-js";
|
|
602
618
|
import { BaseConfigContextZod as BaseConfigContextZod6, HostActorConfigZod as HostActorConfigZod5 } from "@xyo-network/xl1-sdk";
|
|
603
|
-
|
|
619
|
+
import { z as z7 } from "zod/mini";
|
|
620
|
+
var RewardRedemptionConfigZod = z7.extend(HostActorConfigZod5, {});
|
|
604
621
|
var isRewardRedemptionConfig = zodIsFactory6(RewardRedemptionConfigZod);
|
|
605
622
|
var asRewardRedemptionConfig = zodAsFactory6(RewardRedemptionConfigZod, "asRewardRedemptionConfig");
|
|
606
623
|
var toRewardRedemptionConfig = zodToFactory6(RewardRedemptionConfigZod, "toRewardRedemptionConfig");
|
|
607
|
-
var RewardRedemptionConfigContext =
|
|
608
|
-
config: RewardRedemptionConfigZod
|
|
609
|
-
});
|
|
624
|
+
var RewardRedemptionConfigContext = z7.extend(BaseConfigContextZod6, { config: RewardRedemptionConfigZod });
|
|
610
625
|
var isRewardRedemptionConfigContext = zodIsFactory6(RewardRedemptionConfigContext);
|
|
611
626
|
var asRewardRedemptionConfigContext = zodAsFactory6(RewardRedemptionConfigContext, "asRewardRedemptionConfigContext");
|
|
612
627
|
var toRewardRedemptionConfigContext = zodToFactory6(RewardRedemptionConfigContext, "toRewardRedemptionConfigContext");
|
|
@@ -621,26 +636,27 @@ function mergeConfig({ actors, ...baseConfig }) {
|
|
|
621
636
|
})
|
|
622
637
|
};
|
|
623
638
|
}
|
|
624
|
-
__name(mergeConfig, "mergeConfig");
|
|
625
639
|
|
|
626
640
|
// src/shared/createDeclarationIntentBlock.ts
|
|
627
641
|
import { buildNextBlock } from "@xyo-network/chain-sdk";
|
|
628
642
|
import { createDeclarationIntent } from "@xyo-network/xl1-sdk";
|
|
629
643
|
async function createProducerChainStakeIntentBlock(prevBlock, producerAccount, range) {
|
|
630
|
-
const producerDeclarationPayload = createDeclarationIntent(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
644
|
+
const producerDeclarationPayload = createDeclarationIntent(
|
|
645
|
+
producerAccount.address,
|
|
646
|
+
"producer",
|
|
647
|
+
range[0],
|
|
648
|
+
range[1]
|
|
649
|
+
);
|
|
650
|
+
return await buildNextBlock(
|
|
651
|
+
prevBlock,
|
|
652
|
+
[],
|
|
653
|
+
[producerDeclarationPayload],
|
|
654
|
+
[producerAccount]
|
|
655
|
+
);
|
|
636
656
|
}
|
|
637
|
-
__name(createProducerChainStakeIntentBlock, "createProducerChainStakeIntentBlock");
|
|
638
657
|
|
|
639
658
|
// src/shared/host/implementation/DefaultHost.ts
|
|
640
659
|
var GenericHost = class {
|
|
641
|
-
static {
|
|
642
|
-
__name(this, "GenericHost");
|
|
643
|
-
}
|
|
644
660
|
services;
|
|
645
661
|
constructor(services) {
|
|
646
662
|
this.services = services;
|
|
@@ -657,9 +673,6 @@ var GenericHost = class {
|
|
|
657
673
|
|
|
658
674
|
// src/shared/host/implementation/DefaultServiceProvider.ts
|
|
659
675
|
var DefaultServiceProvider = class {
|
|
660
|
-
static {
|
|
661
|
-
__name(this, "DefaultServiceProvider");
|
|
662
|
-
}
|
|
663
676
|
_services;
|
|
664
677
|
constructor(services) {
|
|
665
678
|
this._services = services;
|
|
@@ -709,24 +722,19 @@ var activeWalletReport;
|
|
|
709
722
|
function getAccountLabel(actorName) {
|
|
710
723
|
return ACTOR_LABELS[actorName] ?? actorName;
|
|
711
724
|
}
|
|
712
|
-
__name(getAccountLabel, "getAccountLabel");
|
|
713
725
|
function clearResolvedWalletReport() {
|
|
714
726
|
activeWalletReport = void 0;
|
|
715
727
|
}
|
|
716
|
-
__name(clearResolvedWalletReport, "clearResolvedWalletReport");
|
|
717
728
|
function resolveActorAccountPath(actorName, actorConfig) {
|
|
718
729
|
if (actorConfig?.accountPath !== void 0) return actorConfig.accountPath;
|
|
719
730
|
return DEFAULT_ACTOR_ACCOUNT_PATH[actorName] ?? "0";
|
|
720
731
|
}
|
|
721
|
-
__name(resolveActorAccountPath, "resolveActorAccountPath");
|
|
722
732
|
function isAbsoluteAccountPath(accountPath) {
|
|
723
733
|
return accountPath.startsWith("m/");
|
|
724
734
|
}
|
|
725
|
-
__name(isAbsoluteAccountPath, "isAbsoluteAccountPath");
|
|
726
735
|
function expandAccountPath(accountPath, basePath = DEFAULT_WALLET_PATH) {
|
|
727
736
|
return isAbsoluteAccountPath(accountPath) ? accountPath : `${basePath}/${accountPath}`;
|
|
728
737
|
}
|
|
729
|
-
__name(expandAccountPath, "expandAccountPath");
|
|
730
738
|
async function deriveWalletAtPath(mnemonic, accountPath) {
|
|
731
739
|
if (isAbsoluteAccountPath(accountPath)) {
|
|
732
740
|
const seed = Mnemonic.fromPhrase(mnemonic).computeSeed();
|
|
@@ -737,15 +745,12 @@ async function deriveWalletAtPath(mnemonic, accountPath) {
|
|
|
737
745
|
const baseWallet = await generateXyoBaseWalletFromPhrase(mnemonic);
|
|
738
746
|
return await baseWallet.derivePath(accountPath);
|
|
739
747
|
}
|
|
740
|
-
__name(deriveWalletAtPath, "deriveWalletAtPath");
|
|
741
748
|
function getBuiltInDevMnemonic() {
|
|
742
749
|
return BUILT_IN_DEV_MNEMONIC;
|
|
743
750
|
}
|
|
744
|
-
__name(getBuiltInDevMnemonic, "getBuiltInDevMnemonic");
|
|
745
751
|
function getInsecureGenesisRewardMnemonic() {
|
|
746
752
|
return INSECURE_GENESIS_REWARD_MNEMONIC;
|
|
747
753
|
}
|
|
748
|
-
__name(getInsecureGenesisRewardMnemonic, "getInsecureGenesisRewardMnemonic");
|
|
749
754
|
function resolveRootWallet(configuration) {
|
|
750
755
|
const isConfigured = configuration.mnemonic !== void 0;
|
|
751
756
|
const mnemonic = configuration.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
@@ -758,8 +763,12 @@ function resolveRootWallet(configuration) {
|
|
|
758
763
|
mnemonicKind: isBuiltInDevMnemonic ? "built-in-dev" : "configured-root"
|
|
759
764
|
};
|
|
760
765
|
}
|
|
761
|
-
|
|
762
|
-
|
|
766
|
+
async function resolveWalletMetadata({
|
|
767
|
+
accountPath,
|
|
768
|
+
actorName,
|
|
769
|
+
mnemonic,
|
|
770
|
+
mnemonicKind
|
|
771
|
+
}) {
|
|
763
772
|
const account = await deriveWalletAtPath(mnemonic, accountPath);
|
|
764
773
|
return {
|
|
765
774
|
accountPath,
|
|
@@ -773,7 +782,6 @@ async function resolveWalletMetadata({ accountPath, actorName, mnemonic, mnemoni
|
|
|
773
782
|
usesBuiltInDevMnemonic: mnemonic === BUILT_IN_DEV_MNEMONIC
|
|
774
783
|
};
|
|
775
784
|
}
|
|
776
|
-
__name(resolveWalletMetadata, "resolveWalletMetadata");
|
|
777
785
|
async function resolveActorWallet(actorName, actorConfig, root) {
|
|
778
786
|
return await resolveWalletMetadata({
|
|
779
787
|
accountPath: resolveActorAccountPath(actorName, actorConfig),
|
|
@@ -782,11 +790,7 @@ async function resolveActorWallet(actorName, actorConfig, root) {
|
|
|
782
790
|
mnemonicKind: root.mnemonicKind
|
|
783
791
|
});
|
|
784
792
|
}
|
|
785
|
-
__name(resolveActorWallet, "resolveActorWallet");
|
|
786
793
|
var ActorMnemonicNotAllowedError = class extends Error {
|
|
787
|
-
static {
|
|
788
|
-
__name(this, "ActorMnemonicNotAllowedError");
|
|
789
|
-
}
|
|
790
794
|
actors;
|
|
791
795
|
constructor(actors) {
|
|
792
796
|
super([
|
|
@@ -801,14 +805,12 @@ function assertNoActorMnemonics(configuration) {
|
|
|
801
805
|
const offenders = configuration.actors.filter((actor) => typeof actor.mnemonic === "string").map((actor) => actor.name);
|
|
802
806
|
if (offenders.length > 0) throw new ActorMnemonicNotAllowedError(offenders);
|
|
803
807
|
}
|
|
804
|
-
__name(assertNoActorMnemonics, "assertNoActorMnemonics");
|
|
805
808
|
var DerivationPathCollisionError = class extends Error {
|
|
806
|
-
static {
|
|
807
|
-
__name(this, "DerivationPathCollisionError");
|
|
808
|
-
}
|
|
809
809
|
collisions;
|
|
810
810
|
constructor(collisions) {
|
|
811
|
-
const lines = Object.entries(collisions).map(
|
|
811
|
+
const lines = Object.entries(collisions).map(
|
|
812
|
+
([path, actors]) => ` - ${actors.join(", ")} \u2192 ${path}`
|
|
813
|
+
);
|
|
812
814
|
super([
|
|
813
815
|
"Two or more actors resolve to the same wallet derivation path:",
|
|
814
816
|
...lines,
|
|
@@ -819,10 +821,7 @@ var DerivationPathCollisionError = class extends Error {
|
|
|
819
821
|
}
|
|
820
822
|
};
|
|
821
823
|
function detectDerivationPathCollisions(requestedActors, configuration) {
|
|
822
|
-
const actorConfigMap = new Map(configuration.actors.map((actor) => [
|
|
823
|
-
actor.name,
|
|
824
|
-
actor
|
|
825
|
-
]));
|
|
824
|
+
const actorConfigMap = new Map(configuration.actors.map((actor) => [actor.name, actor]));
|
|
826
825
|
const bucketsByPath = /* @__PURE__ */ new Map();
|
|
827
826
|
for (const actorName of requestedActors) {
|
|
828
827
|
const accountPath = resolveActorAccountPath(actorName, actorConfigMap.get(actorName));
|
|
@@ -838,71 +837,57 @@ function detectDerivationPathCollisions(requestedActors, configuration) {
|
|
|
838
837
|
if (Object.keys(collisions).length === 0) return void 0;
|
|
839
838
|
return new DerivationPathCollisionError(collisions);
|
|
840
839
|
}
|
|
841
|
-
__name(detectDerivationPathCollisions, "detectDerivationPathCollisions");
|
|
842
840
|
async function resolveWalletReport(requestedActors, configuration) {
|
|
843
841
|
const root = resolveRootWallet(configuration);
|
|
844
|
-
const actorConfigMap = new Map(configuration.actors.map((actor) => [
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
const resolvedActors = await Promise.all(requestedActors.map(async (actorName) => await resolveActorWallet(actorName, actorConfigMap.get(actorName), root)));
|
|
842
|
+
const actorConfigMap = new Map(configuration.actors.map((actor) => [actor.name, actor]));
|
|
843
|
+
const resolvedActors = await Promise.all(
|
|
844
|
+
requestedActors.map(async (actorName) => await resolveActorWallet(actorName, actorConfigMap.get(actorName), root))
|
|
845
|
+
);
|
|
849
846
|
const labelMap = /* @__PURE__ */ new Map();
|
|
850
847
|
for (const actor of resolvedActors) {
|
|
851
848
|
const labels = labelMap.get(actor.derivationPath) ?? [];
|
|
852
849
|
labels.push(actor.label);
|
|
853
850
|
labelMap.set(actor.derivationPath, labels);
|
|
854
851
|
}
|
|
855
|
-
const sharedAccounts = await Promise.all(
|
|
856
|
-
length: SHARED_ACCOUNT_REPORT_COUNT
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
label: labels?.join(", ") ?? `shared[${sharedIndex}]`
|
|
868
|
-
};
|
|
869
|
-
}));
|
|
852
|
+
const sharedAccounts = await Promise.all(
|
|
853
|
+
Array.from({ length: SHARED_ACCOUNT_REPORT_COUNT }, (_, index) => index).map(async (sharedIndex) => {
|
|
854
|
+
const account = await resolveWalletMetadata({
|
|
855
|
+
accountPath: `${sharedIndex}`,
|
|
856
|
+
actorName: ROOT_WALLET_RUNTIME_ID,
|
|
857
|
+
mnemonic: root.mnemonic,
|
|
858
|
+
mnemonicKind: root.mnemonicKind
|
|
859
|
+
});
|
|
860
|
+
const labels = labelMap.get(account.derivationPath);
|
|
861
|
+
return { ...account, label: labels?.join(", ") ?? `shared[${sharedIndex}]` };
|
|
862
|
+
})
|
|
863
|
+
);
|
|
870
864
|
return {
|
|
871
|
-
requestedActors: [
|
|
872
|
-
...requestedActors
|
|
873
|
-
],
|
|
865
|
+
requestedActors: [...requestedActors],
|
|
874
866
|
root,
|
|
875
867
|
sharedAccounts
|
|
876
868
|
};
|
|
877
869
|
}
|
|
878
|
-
__name(resolveWalletReport, "resolveWalletReport");
|
|
879
870
|
async function buildInsecureGenesisRewardAccounts() {
|
|
880
|
-
const accounts = await Promise.all(
|
|
881
|
-
length: SHARED_ACCOUNT_REPORT_COUNT
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
label: sharedIndex === 0 ? "genesisRewardAddress" : `genesisReward[${sharedIndex}]`
|
|
892
|
-
};
|
|
893
|
-
}));
|
|
871
|
+
const accounts = await Promise.all(
|
|
872
|
+
Array.from({ length: SHARED_ACCOUNT_REPORT_COUNT }, (_, index) => index).map(async (sharedIndex) => {
|
|
873
|
+
const account = await resolveWalletMetadata({
|
|
874
|
+
accountPath: `${sharedIndex}`,
|
|
875
|
+
actorName: "genesisReward",
|
|
876
|
+
mnemonic: INSECURE_GENESIS_REWARD_MNEMONIC,
|
|
877
|
+
mnemonicKind: "insecure-genesis-reward"
|
|
878
|
+
});
|
|
879
|
+
return { ...account, label: sharedIndex === 0 ? "genesisRewardAddress" : `genesisReward[${sharedIndex}]` };
|
|
880
|
+
})
|
|
881
|
+
);
|
|
894
882
|
return accounts;
|
|
895
883
|
}
|
|
896
|
-
__name(buildInsecureGenesisRewardAccounts, "buildInsecureGenesisRewardAccounts");
|
|
897
884
|
async function initializeResolvedWalletReport(requestedActors, configuration) {
|
|
898
885
|
activeWalletReport = await resolveWalletReport(requestedActors, configuration);
|
|
899
886
|
return activeWalletReport;
|
|
900
887
|
}
|
|
901
|
-
__name(initializeResolvedWalletReport, "initializeResolvedWalletReport");
|
|
902
888
|
function getResolvedWalletReport() {
|
|
903
889
|
return activeWalletReport;
|
|
904
890
|
}
|
|
905
|
-
__name(getResolvedWalletReport, "getResolvedWalletReport");
|
|
906
891
|
function formatSharedAccount(account, showPrivateKey) {
|
|
907
892
|
const lines = [
|
|
908
893
|
`[${account.accountPath}] ${account.label}`,
|
|
@@ -913,7 +898,6 @@ function formatSharedAccount(account, showPrivateKey) {
|
|
|
913
898
|
if (showPrivateKey) lines.push(`privateKey: ${account.privateKey ?? "unavailable"}`);
|
|
914
899
|
return lines.join("\n");
|
|
915
900
|
}
|
|
916
|
-
__name(formatSharedAccount, "formatSharedAccount");
|
|
917
901
|
function formatGenesisRewardAccount(account) {
|
|
918
902
|
const balance = account.accountPath === "0" ? GENESIS_REWARD_AMOUNT / ATTO_XL1_PER_XL1 : 0n;
|
|
919
903
|
return [
|
|
@@ -924,7 +908,6 @@ function formatGenesisRewardAccount(account) {
|
|
|
924
908
|
`balance: ${balance.toString()} XL1`
|
|
925
909
|
].join("\n");
|
|
926
910
|
}
|
|
927
|
-
__name(formatGenesisRewardAccount, "formatGenesisRewardAccount");
|
|
928
911
|
function formatWalletReport(report) {
|
|
929
912
|
const sections = [];
|
|
930
913
|
const showSecrets = report.root.isBuiltInDevMnemonic;
|
|
@@ -949,7 +932,6 @@ function formatWalletReport(report) {
|
|
|
949
932
|
].join("\n"));
|
|
950
933
|
return sections.join("\n\n");
|
|
951
934
|
}
|
|
952
|
-
__name(formatWalletReport, "formatWalletReport");
|
|
953
935
|
function formatInsecureGenesisRewardWarning(accounts) {
|
|
954
936
|
return [
|
|
955
937
|
"INSECURE GENESIS REWARD WALLET WARNING",
|
|
@@ -968,21 +950,18 @@ function formatInsecureGenesisRewardWarning(accounts) {
|
|
|
968
950
|
accounts.map((account) => formatGenesisRewardAccount(account)).join("\n\n")
|
|
969
951
|
].join("\n");
|
|
970
952
|
}
|
|
971
|
-
__name(formatInsecureGenesisRewardWarning, "formatInsecureGenesisRewardWarning");
|
|
972
953
|
async function resolveGenesisRewardAddress(config) {
|
|
973
954
|
if (config.chain.genesisRewardAddress) return config.chain.genesisRewardAddress;
|
|
974
955
|
const wallet = await generateXyoBaseWalletFromPhrase(INSECURE_GENESIS_REWARD_MNEMONIC);
|
|
975
956
|
const account = await wallet.derivePath("0");
|
|
976
957
|
return account.address;
|
|
977
958
|
}
|
|
978
|
-
__name(resolveGenesisRewardAddress, "resolveGenesisRewardAddress");
|
|
979
959
|
async function resolveWalletForActor(actorName, accountPath) {
|
|
980
960
|
const report = activeWalletReport;
|
|
981
961
|
const mnemonic = report?.root.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
982
962
|
const resolvedAccountPath = accountPath ?? resolveActorAccountPath(actorName);
|
|
983
963
|
return await deriveWalletAtPath(mnemonic, resolvedAccountPath);
|
|
984
964
|
}
|
|
985
|
-
__name(resolveWalletForActor, "resolveWalletForActor");
|
|
986
965
|
|
|
987
966
|
// src/shared/init/initActorSeedPhrase.ts
|
|
988
967
|
async function initActorSeedPhrase(context, bios) {
|
|
@@ -995,7 +974,6 @@ async function initActorSeedPhrase(context, bios) {
|
|
|
995
974
|
logger?.debug(`[${walletKind}] Falling back to built-in development mnemonic`);
|
|
996
975
|
return assertEx2(fallback, () => "Unable to resolve mnemonic");
|
|
997
976
|
}
|
|
998
|
-
__name(initActorSeedPhrase, "initActorSeedPhrase");
|
|
999
977
|
|
|
1000
978
|
// src/shared/init/initBridgedModule.ts
|
|
1001
979
|
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
@@ -1018,33 +996,26 @@ async function initBridgedModule({ bridge, moduleName }) {
|
|
|
1018
996
|
return moduleInstance;
|
|
1019
997
|
});
|
|
1020
998
|
}
|
|
1021
|
-
__name(initBridgedModule, "initBridgedModule");
|
|
1022
999
|
async function initBridgedArchivistModule({ bridge, moduleName }) {
|
|
1023
|
-
return assertEx3(
|
|
1024
|
-
bridge,
|
|
1025
|
-
moduleName
|
|
1026
|
-
|
|
1000
|
+
return assertEx3(
|
|
1001
|
+
asAttachableArchivistInstance(await initBridgedModule({ bridge, moduleName })),
|
|
1002
|
+
() => `Could not convert ${moduleName} to attachable archivist instance`
|
|
1003
|
+
);
|
|
1027
1004
|
}
|
|
1028
|
-
__name(initBridgedArchivistModule, "initBridgedArchivistModule");
|
|
1029
1005
|
|
|
1030
1006
|
// src/shared/init/initStatusReporter.ts
|
|
1031
1007
|
import { RuntimeStatusMonitor } from "@xyo-network/xl1-sdk";
|
|
1032
1008
|
function initStatusReporter({ logger }) {
|
|
1033
1009
|
const statusReporter = new RuntimeStatusMonitor(logger);
|
|
1034
|
-
statusReporter.onGlobalTransition({
|
|
1035
|
-
to: "started"
|
|
1036
|
-
}, () => {
|
|
1010
|
+
statusReporter.onGlobalTransition({ to: "started" }, () => {
|
|
1037
1011
|
logger.log("All services started.");
|
|
1038
1012
|
});
|
|
1039
|
-
statusReporter.onGlobalTransition({
|
|
1040
|
-
to: "error"
|
|
1041
|
-
}, () => {
|
|
1013
|
+
statusReporter.onGlobalTransition({ to: "error" }, () => {
|
|
1042
1014
|
logger.error("Producer encountered an unhandled error!");
|
|
1043
1015
|
process.exit(1);
|
|
1044
1016
|
});
|
|
1045
1017
|
return statusReporter;
|
|
1046
1018
|
}
|
|
1047
|
-
__name(initStatusReporter, "initStatusReporter");
|
|
1048
1019
|
|
|
1049
1020
|
// src/shared/init/initWallet.ts
|
|
1050
1021
|
import { isDefined } from "@xylabs/sdk-js";
|
|
@@ -1058,21 +1029,10 @@ async function initActorWallet(context) {
|
|
|
1058
1029
|
actorAccountSingletons[actorName] = account;
|
|
1059
1030
|
return actorAccountSingletons[actorName];
|
|
1060
1031
|
}
|
|
1061
|
-
__name(initActorWallet, "initActorWallet");
|
|
1062
1032
|
|
|
1063
1033
|
// src/shared/orchestrator/Orchestrator.ts
|
|
1064
1034
|
import { AbstractCreatable as AbstractCreatable2, creatable } from "@xylabs/sdk-js";
|
|
1065
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
1066
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1067
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1068
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1069
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1070
|
-
}
|
|
1071
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
1072
1035
|
var Orchestrator = class extends AbstractCreatable2 {
|
|
1073
|
-
static {
|
|
1074
|
-
__name(this, "Orchestrator");
|
|
1075
|
-
}
|
|
1076
1036
|
actors = [];
|
|
1077
1037
|
running = false;
|
|
1078
1038
|
shuttingDown = false;
|
|
@@ -1089,9 +1049,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1089
1049
|
return this.shuttingDown;
|
|
1090
1050
|
}
|
|
1091
1051
|
/**
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1052
|
+
* Registers an actor.
|
|
1053
|
+
* (We won't activate the actor until `start()` is called.)
|
|
1054
|
+
*/
|
|
1095
1055
|
async registerActor(actor) {
|
|
1096
1056
|
this.actors.push(actor);
|
|
1097
1057
|
if (this.running) {
|
|
@@ -1104,9 +1064,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1104
1064
|
}
|
|
1105
1065
|
}
|
|
1106
1066
|
/**
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1067
|
+
* Starts the orchestrator: activates all actors in parallel and kicks off their warm-pass.
|
|
1068
|
+
* `whenReady()` resolves once every actor's `readyHandler` has succeeded.
|
|
1069
|
+
*/
|
|
1110
1070
|
async startHandler() {
|
|
1111
1071
|
await super.startHandler();
|
|
1112
1072
|
if (this.running) {
|
|
@@ -1116,12 +1076,7 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1116
1076
|
this.logger?.log(`[Orchestrator] Starting ${this.actors.length} actor(s) in parallel...`);
|
|
1117
1077
|
this.running = true;
|
|
1118
1078
|
const startResults = await Promise.allSettled(this.actors.map((a) => a.start()));
|
|
1119
|
-
const startFailures = startResults.flatMap((r, i) => r.status === "rejected" ? [
|
|
1120
|
-
{
|
|
1121
|
-
actor: this.actors[i],
|
|
1122
|
-
reason: r.reason
|
|
1123
|
-
}
|
|
1124
|
-
] : []);
|
|
1079
|
+
const startFailures = startResults.flatMap((r, i) => r.status === "rejected" ? [{ actor: this.actors[i], reason: r.reason }] : []);
|
|
1125
1080
|
if (startFailures.length > 0) {
|
|
1126
1081
|
for (const f of startFailures) this.logger?.error(`[Orchestrator] Actor [${f.actor?.name ?? "?"}] failed to start: ${formatError(f.reason)}`);
|
|
1127
1082
|
throw new Error(`[Orchestrator] ${startFailures.length} actor(s) failed to start`);
|
|
@@ -1135,8 +1090,8 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1135
1090
|
}
|
|
1136
1091
|
}
|
|
1137
1092
|
/**
|
|
1138
|
-
|
|
1139
|
-
|
|
1093
|
+
* Stops the orchestrator: deactivates all actors.
|
|
1094
|
+
*/
|
|
1140
1095
|
async stopHandler() {
|
|
1141
1096
|
await super.stopHandler();
|
|
1142
1097
|
if (!this.running) {
|
|
@@ -1151,9 +1106,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1151
1106
|
this.logger?.log("[Orchestrator] Stopped.");
|
|
1152
1107
|
}
|
|
1153
1108
|
/**
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1109
|
+
* Resolves once every actor reports ready. Rejects if any actor's `readyHandler` throws,
|
|
1110
|
+
* or after `timeoutMs` if provided.
|
|
1111
|
+
*/
|
|
1157
1112
|
async whenReady(timeoutMs) {
|
|
1158
1113
|
const localActors = this.actors.filter(isLocalActor);
|
|
1159
1114
|
if (localActors.length === 0) return;
|
|
@@ -1168,50 +1123,30 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1168
1123
|
}, timeoutMs);
|
|
1169
1124
|
});
|
|
1170
1125
|
try {
|
|
1171
|
-
await Promise.race([
|
|
1172
|
-
Promise.all(localActors.map((a) => a.whenReady())),
|
|
1173
|
-
timeout
|
|
1174
|
-
]);
|
|
1126
|
+
await Promise.race([Promise.all(localActors.map((a) => a.whenReady())), timeout]);
|
|
1175
1127
|
} finally {
|
|
1176
1128
|
if (timer) clearTimeout(timer);
|
|
1177
1129
|
}
|
|
1178
1130
|
}
|
|
1179
1131
|
};
|
|
1180
|
-
Orchestrator =
|
|
1132
|
+
Orchestrator = __decorateClass([
|
|
1181
1133
|
creatable()
|
|
1182
1134
|
], Orchestrator);
|
|
1183
1135
|
function isLocalActor(actor) {
|
|
1184
1136
|
return actor instanceof ActorV3;
|
|
1185
1137
|
}
|
|
1186
|
-
__name(isLocalActor, "isLocalActor");
|
|
1187
1138
|
function formatError(err) {
|
|
1188
1139
|
if (err instanceof Error) return `${err.message}${err.stack ? `
|
|
1189
1140
|
${err.stack}` : ""}`;
|
|
1190
1141
|
return String(err);
|
|
1191
1142
|
}
|
|
1192
|
-
__name(formatError, "formatError");
|
|
1193
1143
|
|
|
1194
1144
|
// src/shared/provider/SimpleRejectedTransactionsArchivistProvider.ts
|
|
1195
1145
|
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
1196
1146
|
import { AbstractCreatableProvider, creatableProvider } from "@xyo-network/xl1-sdk";
|
|
1197
|
-
function _ts_decorate2(decorators, target, key, desc) {
|
|
1198
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1199
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1200
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1201
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1202
|
-
}
|
|
1203
|
-
__name(_ts_decorate2, "_ts_decorate");
|
|
1204
1147
|
var RejectedTransactionsArchivistProviderMoniker = "RejectedTransactionsArchivistProvider";
|
|
1205
|
-
var SimpleRejectedTransactionsArchivistProvider = class
|
|
1206
|
-
|
|
1207
|
-
__name(this, "SimpleRejectedTransactionsArchivistProvider");
|
|
1208
|
-
}
|
|
1209
|
-
static defaultMoniker = RejectedTransactionsArchivistProviderMoniker;
|
|
1210
|
-
static dependencies = [];
|
|
1211
|
-
static monikers = [
|
|
1212
|
-
RejectedTransactionsArchivistProviderMoniker
|
|
1213
|
-
];
|
|
1214
|
-
moniker = _SimpleRejectedTransactionsArchivistProvider.defaultMoniker;
|
|
1148
|
+
var SimpleRejectedTransactionsArchivistProvider = class extends AbstractCreatableProvider {
|
|
1149
|
+
moniker = SimpleRejectedTransactionsArchivistProvider.defaultMoniker;
|
|
1215
1150
|
get archivist() {
|
|
1216
1151
|
return this.params.archivist;
|
|
1217
1152
|
}
|
|
@@ -1222,7 +1157,10 @@ var SimpleRejectedTransactionsArchivistProvider = class _SimpleRejectedTransacti
|
|
|
1222
1157
|
};
|
|
1223
1158
|
}
|
|
1224
1159
|
};
|
|
1225
|
-
SimpleRejectedTransactionsArchivistProvider
|
|
1160
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "defaultMoniker", RejectedTransactionsArchivistProviderMoniker);
|
|
1161
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "dependencies", []);
|
|
1162
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "monikers", [RejectedTransactionsArchivistProviderMoniker]);
|
|
1163
|
+
SimpleRejectedTransactionsArchivistProvider = __decorateClass([
|
|
1226
1164
|
creatableProvider()
|
|
1227
1165
|
], SimpleRejectedTransactionsArchivistProvider);
|
|
1228
1166
|
|
|
@@ -1233,7 +1171,25 @@ import { backingsSatisfied, unmetBackings } from "@xyo-network/xl1-protocol-sdk"
|
|
|
1233
1171
|
import { createCapabilityRegistry } from "@xyo-network/xl1-protocol-sdk";
|
|
1234
1172
|
|
|
1235
1173
|
// src/node/config/capabilities/defaultCapabilityRegistry.ts
|
|
1236
|
-
import {
|
|
1174
|
+
import {
|
|
1175
|
+
AccountBalanceViewerMoniker,
|
|
1176
|
+
BlockRunnerMoniker,
|
|
1177
|
+
BlockValidationViewerMoniker,
|
|
1178
|
+
BlockViewerMoniker,
|
|
1179
|
+
ChainContractViewerMoniker,
|
|
1180
|
+
DeadLetterQueueRunnerMoniker,
|
|
1181
|
+
DeadLetterQueueViewerMoniker,
|
|
1182
|
+
FinalizationRunnerMoniker,
|
|
1183
|
+
FinalizationViewerMoniker,
|
|
1184
|
+
MempoolRunnerMoniker,
|
|
1185
|
+
MempoolViewerMoniker,
|
|
1186
|
+
StakeTotalsViewerMoniker,
|
|
1187
|
+
TimeSyncViewerMoniker,
|
|
1188
|
+
TransactionValidationViewerMoniker,
|
|
1189
|
+
TransactionViewerMoniker,
|
|
1190
|
+
WindowedBlockViewerMoniker,
|
|
1191
|
+
XyoViewerMoniker
|
|
1192
|
+
} from "@xyo-network/xl1-sdk";
|
|
1237
1193
|
var XyoConnectionMoniker = "XyoConnection";
|
|
1238
1194
|
var XyoGatewayRunnerMoniker = "XyoGatewayRunner";
|
|
1239
1195
|
var capabilities = [
|
|
@@ -1254,12 +1210,22 @@ var capabilities = [
|
|
|
1254
1210
|
label: "Mempool viewer",
|
|
1255
1211
|
kind: "viewer",
|
|
1256
1212
|
surface: "node"
|
|
1213
|
+
// Note: `SimpleMempoolViewer.dependencies` lists `WindowedBlockViewer`,
|
|
1214
|
+
// but the runtime constructor does NOT actually resolve it — the
|
|
1215
|
+
// dependencies field is informational for `validateDepsOnRegister`.
|
|
1216
|
+
// Adding `implies: [WindowedBlockViewerMoniker]` here would over-provision
|
|
1217
|
+
// (selected by `locatorPlan.spec.ts`); leave it off intentionally.
|
|
1257
1218
|
},
|
|
1258
1219
|
{
|
|
1259
1220
|
id: MempoolRunnerMoniker,
|
|
1260
1221
|
label: "Mempool runner",
|
|
1261
1222
|
kind: "runner",
|
|
1262
1223
|
surface: "node"
|
|
1224
|
+
// Note: `SimpleMempoolRunner.dependencies` lists BlockValidationViewer,
|
|
1225
|
+
// ChainContractViewer, FinalizationViewer, TransactionValidationViewer —
|
|
1226
|
+
// but the same "informational deps" principle applies: the runtime
|
|
1227
|
+
// constructor does not eagerly resolve them. Adding them as `implies`
|
|
1228
|
+
// would over-provision (selected by `locatorPlan.spec.ts`).
|
|
1263
1229
|
},
|
|
1264
1230
|
{
|
|
1265
1231
|
id: AccountBalanceViewerMoniker,
|
|
@@ -1372,10 +1338,24 @@ function createDefaultCapabilityRegistry() {
|
|
|
1372
1338
|
for (const cap of capabilities) registry.register(cap);
|
|
1373
1339
|
return registry;
|
|
1374
1340
|
}
|
|
1375
|
-
__name(createDefaultCapabilityRegistry, "createDefaultCapabilityRegistry");
|
|
1376
1341
|
|
|
1377
1342
|
// src/node/config/capabilities/descriptors.ts
|
|
1378
|
-
import {
|
|
1343
|
+
import {
|
|
1344
|
+
SimpleAccountBalanceViewer,
|
|
1345
|
+
SimpleBlockValidationViewer,
|
|
1346
|
+
SimpleBlockViewer,
|
|
1347
|
+
SimpleDeadLetterQueueRunner,
|
|
1348
|
+
SimpleDeadLetterQueueViewer,
|
|
1349
|
+
SimpleFinalizationRunner,
|
|
1350
|
+
SimpleFinalizationViewer,
|
|
1351
|
+
SimpleMempoolRunner,
|
|
1352
|
+
SimpleMempoolViewer,
|
|
1353
|
+
SimpleTransactionValidationViewer,
|
|
1354
|
+
SimpleTransactionViewer,
|
|
1355
|
+
SimpleWindowedBlockViewer,
|
|
1356
|
+
SimpleXyoConnectionViewer,
|
|
1357
|
+
SimpleXyoViewer
|
|
1358
|
+
} from "@xyo-network/xl1-sdk";
|
|
1379
1359
|
function readMempoolTuning(ctx) {
|
|
1380
1360
|
const cfg = ctx.actorContext.config;
|
|
1381
1361
|
return {
|
|
@@ -1383,258 +1363,207 @@ function readMempoolTuning(ctx) {
|
|
|
1383
1363
|
maxPendingTransactions: cfg?.mempool?.maxPendingTransactions
|
|
1384
1364
|
};
|
|
1385
1365
|
}
|
|
1386
|
-
|
|
1387
|
-
var passes = /* @__PURE__ */ __name(() => true, "passes");
|
|
1366
|
+
var passes = () => true;
|
|
1388
1367
|
var localTier1Descriptors = [
|
|
1389
1368
|
{
|
|
1390
1369
|
id: "SimpleMempoolViewer",
|
|
1391
|
-
satisfies: [
|
|
1392
|
-
SimpleMempoolViewer.defaultMoniker
|
|
1393
|
-
],
|
|
1370
|
+
satisfies: [SimpleMempoolViewer.defaultMoniker],
|
|
1394
1371
|
tier: 1,
|
|
1395
|
-
backings: [
|
|
1396
|
-
{
|
|
1397
|
-
backing: "mempool-store",
|
|
1398
|
-
mode: "read"
|
|
1399
|
-
}
|
|
1400
|
-
],
|
|
1372
|
+
backings: [{ backing: "mempool-store", mode: "read" }],
|
|
1401
1373
|
surface: "node",
|
|
1402
1374
|
preconditions: passes,
|
|
1403
|
-
build:
|
|
1375
|
+
build: (ctx) => {
|
|
1404
1376
|
const { demotionThreshold } = readMempoolTuning(ctx);
|
|
1405
|
-
return SimpleMempoolViewer.factory(
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1377
|
+
return SimpleMempoolViewer.factory(
|
|
1378
|
+
SimpleMempoolViewer.dependencies,
|
|
1379
|
+
{
|
|
1380
|
+
pendingTransactionsArchivist: ctx.process.pendingTransactionsArchivist,
|
|
1381
|
+
pendingBlocksArchivist: ctx.process.pendingBlocksArchivist,
|
|
1382
|
+
demotionThreshold
|
|
1383
|
+
}
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1411
1386
|
},
|
|
1412
1387
|
{
|
|
1413
1388
|
id: "SimpleMempoolRunner",
|
|
1414
|
-
satisfies: [
|
|
1415
|
-
SimpleMempoolRunner.defaultMoniker
|
|
1416
|
-
],
|
|
1389
|
+
satisfies: [SimpleMempoolRunner.defaultMoniker],
|
|
1417
1390
|
tier: 1,
|
|
1418
|
-
backings: [
|
|
1419
|
-
{
|
|
1420
|
-
backing: "mempool-store",
|
|
1421
|
-
mode: "write"
|
|
1422
|
-
}
|
|
1423
|
-
],
|
|
1391
|
+
backings: [{ backing: "mempool-store", mode: "write" }],
|
|
1424
1392
|
surface: "node",
|
|
1425
1393
|
preconditions: passes,
|
|
1426
|
-
build:
|
|
1394
|
+
build: (ctx) => {
|
|
1427
1395
|
const { maxPendingTransactions } = readMempoolTuning(ctx);
|
|
1428
|
-
return SimpleMempoolRunner.factory(
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1396
|
+
return SimpleMempoolRunner.factory(
|
|
1397
|
+
SimpleMempoolRunner.dependencies,
|
|
1398
|
+
{
|
|
1399
|
+
pendingTransactionsArchivist: ctx.process.pendingTransactionsArchivist,
|
|
1400
|
+
pendingBlocksArchivist: ctx.process.pendingBlocksArchivist,
|
|
1401
|
+
maxPendingTransactions
|
|
1402
|
+
}
|
|
1403
|
+
);
|
|
1404
|
+
}
|
|
1434
1405
|
},
|
|
1435
1406
|
{
|
|
1436
1407
|
id: "SimpleAccountBalanceViewer",
|
|
1437
|
-
satisfies: [
|
|
1438
|
-
SimpleAccountBalanceViewer.defaultMoniker
|
|
1439
|
-
],
|
|
1408
|
+
satisfies: [SimpleAccountBalanceViewer.defaultMoniker],
|
|
1440
1409
|
tier: 1,
|
|
1441
|
-
backings: [
|
|
1442
|
-
{
|
|
1443
|
-
backing: "indexer-store",
|
|
1444
|
-
mode: "read"
|
|
1445
|
-
}
|
|
1446
|
-
],
|
|
1410
|
+
backings: [{ backing: "indexer-store", mode: "read" }],
|
|
1447
1411
|
surface: "node",
|
|
1448
1412
|
preconditions: passes,
|
|
1449
|
-
build:
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1413
|
+
build: (ctx) => SimpleAccountBalanceViewer.factory(
|
|
1414
|
+
SimpleAccountBalanceViewer.dependencies,
|
|
1415
|
+
{
|
|
1416
|
+
balancesSummaryMap: ctx.process.balancesSummaryMap,
|
|
1417
|
+
transfersSummaryMap: ctx.process.transfersSummaryMap
|
|
1418
|
+
}
|
|
1419
|
+
)
|
|
1453
1420
|
},
|
|
1454
1421
|
{
|
|
1455
1422
|
id: "SimpleFinalizationViewer",
|
|
1456
|
-
satisfies: [
|
|
1457
|
-
SimpleFinalizationViewer.defaultMoniker
|
|
1458
|
-
],
|
|
1423
|
+
satisfies: [SimpleFinalizationViewer.defaultMoniker],
|
|
1459
1424
|
tier: 1,
|
|
1460
|
-
backings: [
|
|
1461
|
-
{
|
|
1462
|
-
backing: "chain-store",
|
|
1463
|
-
mode: "read"
|
|
1464
|
-
}
|
|
1465
|
-
],
|
|
1425
|
+
backings: [{ backing: "chain-store", mode: "read" }],
|
|
1466
1426
|
surface: "node",
|
|
1467
1427
|
preconditions: passes,
|
|
1468
|
-
build:
|
|
1469
|
-
|
|
1470
|
-
|
|
1428
|
+
build: (ctx) => SimpleFinalizationViewer.factory(
|
|
1429
|
+
SimpleFinalizationViewer.dependencies,
|
|
1430
|
+
{ finalizedArchivist: ctx.process.readonlyChainArchivist }
|
|
1431
|
+
)
|
|
1471
1432
|
},
|
|
1472
1433
|
{
|
|
1473
1434
|
id: "SimpleBlockViewer",
|
|
1474
|
-
satisfies: [
|
|
1475
|
-
SimpleBlockViewer.defaultMoniker
|
|
1476
|
-
],
|
|
1435
|
+
satisfies: [SimpleBlockViewer.defaultMoniker],
|
|
1477
1436
|
tier: 1,
|
|
1478
|
-
backings: [
|
|
1479
|
-
{
|
|
1480
|
-
backing: "chain-store",
|
|
1481
|
-
mode: "read"
|
|
1482
|
-
}
|
|
1483
|
-
],
|
|
1437
|
+
backings: [{ backing: "chain-store", mode: "read" }],
|
|
1484
1438
|
surface: "node",
|
|
1485
1439
|
preconditions: passes,
|
|
1486
|
-
build:
|
|
1487
|
-
|
|
1488
|
-
|
|
1440
|
+
build: (ctx) => SimpleBlockViewer.factory(
|
|
1441
|
+
SimpleBlockViewer.dependencies,
|
|
1442
|
+
{ finalizedArchivist: ctx.process.readonlyChainArchivist }
|
|
1443
|
+
)
|
|
1489
1444
|
},
|
|
1490
1445
|
{
|
|
1491
1446
|
id: "SimpleWindowedBlockViewer",
|
|
1492
|
-
satisfies: [
|
|
1493
|
-
SimpleWindowedBlockViewer.defaultMoniker
|
|
1494
|
-
],
|
|
1447
|
+
satisfies: [SimpleWindowedBlockViewer.defaultMoniker],
|
|
1495
1448
|
tier: 1,
|
|
1496
1449
|
backings: [],
|
|
1497
1450
|
surface: "node",
|
|
1498
1451
|
preconditions: passes,
|
|
1499
|
-
build:
|
|
1500
|
-
|
|
1501
|
-
syncInterval: 1e4
|
|
1502
|
-
|
|
1452
|
+
build: () => SimpleWindowedBlockViewer.factory(
|
|
1453
|
+
SimpleWindowedBlockViewer.dependencies,
|
|
1454
|
+
{ maxWindowSize: 1e3, syncInterval: 1e4 }
|
|
1455
|
+
)
|
|
1503
1456
|
},
|
|
1504
1457
|
{
|
|
1505
1458
|
id: "SimpleXyoConnectionViewer",
|
|
1506
|
-
satisfies: [
|
|
1507
|
-
SimpleXyoConnectionViewer.defaultMoniker
|
|
1508
|
-
],
|
|
1459
|
+
satisfies: [SimpleXyoConnectionViewer.defaultMoniker],
|
|
1509
1460
|
tier: 1,
|
|
1510
1461
|
backings: [],
|
|
1511
1462
|
surface: "node",
|
|
1512
1463
|
preconditions: passes,
|
|
1513
|
-
build:
|
|
1464
|
+
build: () => SimpleXyoConnectionViewer.factory(SimpleXyoConnectionViewer.dependencies, {})
|
|
1514
1465
|
},
|
|
1515
1466
|
{
|
|
1516
1467
|
id: "SimpleTransactionViewer",
|
|
1517
|
-
satisfies: [
|
|
1518
|
-
SimpleTransactionViewer.defaultMoniker
|
|
1519
|
-
],
|
|
1468
|
+
satisfies: [SimpleTransactionViewer.defaultMoniker],
|
|
1520
1469
|
tier: 1,
|
|
1521
1470
|
backings: [],
|
|
1522
1471
|
surface: "node",
|
|
1523
1472
|
preconditions: passes,
|
|
1524
|
-
build:
|
|
1473
|
+
build: () => SimpleTransactionViewer.factory(SimpleTransactionViewer.dependencies, {})
|
|
1525
1474
|
},
|
|
1526
1475
|
{
|
|
1527
1476
|
id: "SimpleXyoViewer",
|
|
1528
|
-
satisfies: [
|
|
1529
|
-
SimpleXyoViewer.defaultMoniker
|
|
1530
|
-
],
|
|
1477
|
+
satisfies: [SimpleXyoViewer.defaultMoniker],
|
|
1531
1478
|
tier: 1,
|
|
1532
1479
|
backings: [],
|
|
1533
1480
|
surface: "node",
|
|
1534
1481
|
preconditions: passes,
|
|
1535
|
-
build:
|
|
1482
|
+
build: () => SimpleXyoViewer.factory(SimpleXyoViewer.dependencies, {})
|
|
1536
1483
|
},
|
|
1537
1484
|
{
|
|
1538
1485
|
id: "SimpleFinalizationRunner",
|
|
1539
|
-
satisfies: [
|
|
1540
|
-
SimpleFinalizationRunner.defaultMoniker
|
|
1541
|
-
],
|
|
1486
|
+
satisfies: [SimpleFinalizationRunner.defaultMoniker],
|
|
1542
1487
|
tier: 1,
|
|
1543
|
-
backings: [
|
|
1544
|
-
{
|
|
1545
|
-
backing: "chain-store",
|
|
1546
|
-
mode: "write"
|
|
1547
|
-
}
|
|
1548
|
-
],
|
|
1488
|
+
backings: [{ backing: "chain-store", mode: "write" }],
|
|
1549
1489
|
surface: "node",
|
|
1550
1490
|
preconditions: passes,
|
|
1551
|
-
build:
|
|
1552
|
-
|
|
1553
|
-
|
|
1491
|
+
build: (ctx) => SimpleFinalizationRunner.factory(
|
|
1492
|
+
SimpleFinalizationRunner.dependencies,
|
|
1493
|
+
{ finalizedArchivist: ctx.process.writableChainArchivist }
|
|
1494
|
+
)
|
|
1554
1495
|
},
|
|
1555
1496
|
{
|
|
1556
1497
|
id: "SimpleBlockValidationViewer",
|
|
1557
|
-
satisfies: [
|
|
1558
|
-
SimpleBlockValidationViewer.defaultMoniker
|
|
1559
|
-
],
|
|
1498
|
+
satisfies: [SimpleBlockValidationViewer.defaultMoniker],
|
|
1560
1499
|
tier: 1,
|
|
1561
1500
|
backings: [],
|
|
1562
1501
|
surface: "node",
|
|
1563
1502
|
preconditions: passes,
|
|
1564
|
-
build:
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1503
|
+
build: (ctx) => SimpleBlockValidationViewer.factory(
|
|
1504
|
+
SimpleBlockValidationViewer.dependencies,
|
|
1505
|
+
{
|
|
1506
|
+
state: ctx.process.blockStateValidator,
|
|
1507
|
+
protocol: ctx.process.blockProtocolValidator
|
|
1508
|
+
}
|
|
1509
|
+
)
|
|
1568
1510
|
},
|
|
1569
1511
|
{
|
|
1570
1512
|
id: "SimpleTransactionValidationViewer",
|
|
1571
|
-
satisfies: [
|
|
1572
|
-
SimpleTransactionValidationViewer.defaultMoniker
|
|
1573
|
-
],
|
|
1513
|
+
satisfies: [SimpleTransactionValidationViewer.defaultMoniker],
|
|
1574
1514
|
tier: 1,
|
|
1575
1515
|
backings: [],
|
|
1576
1516
|
surface: "node",
|
|
1577
1517
|
preconditions: passes,
|
|
1578
|
-
build:
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1518
|
+
build: (ctx) => SimpleTransactionValidationViewer.factory(
|
|
1519
|
+
SimpleTransactionValidationViewer.dependencies,
|
|
1520
|
+
{
|
|
1521
|
+
protocol: ctx.process.transactionProtocolValidator,
|
|
1522
|
+
state: ctx.process.transactionStateValidator
|
|
1523
|
+
}
|
|
1524
|
+
)
|
|
1582
1525
|
},
|
|
1583
1526
|
{
|
|
1584
1527
|
id: "SimpleDeadLetterQueueRunner",
|
|
1585
|
-
satisfies: [
|
|
1586
|
-
SimpleDeadLetterQueueRunner.defaultMoniker
|
|
1587
|
-
],
|
|
1528
|
+
satisfies: [SimpleDeadLetterQueueRunner.defaultMoniker],
|
|
1588
1529
|
tier: 1,
|
|
1589
|
-
backings: [
|
|
1590
|
-
{
|
|
1591
|
-
backing: "dlq-store",
|
|
1592
|
-
mode: "write"
|
|
1593
|
-
}
|
|
1594
|
-
],
|
|
1530
|
+
backings: [{ backing: "dlq-store", mode: "write" }],
|
|
1595
1531
|
surface: "node",
|
|
1596
1532
|
preconditions: passes,
|
|
1597
|
-
build:
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1533
|
+
build: (ctx) => SimpleDeadLetterQueueRunner.factory(
|
|
1534
|
+
SimpleDeadLetterQueueRunner.dependencies,
|
|
1535
|
+
{
|
|
1536
|
+
rejectedBlocksArchivist: ctx.process.rejectedBlocksArchivist,
|
|
1537
|
+
rejectedTransactionsArchivist: ctx.process.rejectedTransactionsArchivist
|
|
1538
|
+
}
|
|
1539
|
+
)
|
|
1601
1540
|
},
|
|
1602
1541
|
{
|
|
1603
1542
|
id: "SimpleDeadLetterQueueViewer",
|
|
1604
|
-
satisfies: [
|
|
1605
|
-
SimpleDeadLetterQueueViewer.defaultMoniker
|
|
1606
|
-
],
|
|
1543
|
+
satisfies: [SimpleDeadLetterQueueViewer.defaultMoniker],
|
|
1607
1544
|
tier: 1,
|
|
1608
|
-
backings: [
|
|
1609
|
-
{
|
|
1610
|
-
backing: "dlq-store",
|
|
1611
|
-
mode: "read"
|
|
1612
|
-
}
|
|
1613
|
-
],
|
|
1545
|
+
backings: [{ backing: "dlq-store", mode: "read" }],
|
|
1614
1546
|
surface: "node",
|
|
1615
1547
|
preconditions: passes,
|
|
1616
|
-
build:
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1548
|
+
build: (ctx) => SimpleDeadLetterQueueViewer.factory(
|
|
1549
|
+
SimpleDeadLetterQueueViewer.dependencies,
|
|
1550
|
+
{
|
|
1551
|
+
rejectedBlocksArchivist: ctx.process.rejectedBlocksArchivist,
|
|
1552
|
+
rejectedTransactionsArchivist: ctx.process.rejectedTransactionsArchivist
|
|
1553
|
+
}
|
|
1554
|
+
)
|
|
1620
1555
|
},
|
|
1621
1556
|
{
|
|
1622
1557
|
id: "SimpleRejectedTransactionsArchivistProvider",
|
|
1623
|
-
satisfies: [
|
|
1624
|
-
SimpleRejectedTransactionsArchivistProvider.defaultMoniker
|
|
1625
|
-
],
|
|
1558
|
+
satisfies: [SimpleRejectedTransactionsArchivistProvider.defaultMoniker],
|
|
1626
1559
|
tier: 1,
|
|
1627
|
-
backings: [
|
|
1628
|
-
{
|
|
1629
|
-
backing: "dlq-store",
|
|
1630
|
-
mode: "read"
|
|
1631
|
-
}
|
|
1632
|
-
],
|
|
1560
|
+
backings: [{ backing: "dlq-store", mode: "read" }],
|
|
1633
1561
|
surface: "node",
|
|
1634
1562
|
preconditions: passes,
|
|
1635
|
-
build:
|
|
1636
|
-
|
|
1637
|
-
|
|
1563
|
+
build: (ctx) => SimpleRejectedTransactionsArchivistProvider.factory(
|
|
1564
|
+
SimpleRejectedTransactionsArchivistProvider.dependencies,
|
|
1565
|
+
{ archivist: ctx.process.rejectedTransactionsArchivist }
|
|
1566
|
+
)
|
|
1638
1567
|
}
|
|
1639
1568
|
];
|
|
1640
1569
|
|
|
@@ -1642,7 +1571,11 @@ var localTier1Descriptors = [
|
|
|
1642
1571
|
import { ProviderFactoryLocator } from "@xyo-network/xl1-sdk";
|
|
1643
1572
|
|
|
1644
1573
|
// src/node/config/capabilities/networkTier3Descriptors.ts
|
|
1645
|
-
import {
|
|
1574
|
+
import {
|
|
1575
|
+
indexedNetworkDescriptors,
|
|
1576
|
+
networkTier3Descriptors,
|
|
1577
|
+
nodeNetworkDescriptors
|
|
1578
|
+
} from "@xyo-network/xl1-sdk";
|
|
1646
1579
|
|
|
1647
1580
|
// src/node/init/initBalanceSummaryMap.ts
|
|
1648
1581
|
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
@@ -1652,7 +1585,13 @@ import { hasMongoConfig, MemoryMap } from "@xyo-network/xl1-sdk";
|
|
|
1652
1585
|
async function initBalanceSummaryMap({ logger, config }) {
|
|
1653
1586
|
const mongoConfig = config.storage?.mongo;
|
|
1654
1587
|
if (hasMongoConfig(mongoConfig)) {
|
|
1655
|
-
const {
|
|
1588
|
+
const {
|
|
1589
|
+
connectionString: dbConnectionString,
|
|
1590
|
+
database: dbName,
|
|
1591
|
+
domain: dbDomain,
|
|
1592
|
+
password: dbPassword,
|
|
1593
|
+
username: dbUserName
|
|
1594
|
+
} = mongoConfig;
|
|
1656
1595
|
const payloadSdkConfig = {
|
|
1657
1596
|
dbConnectionString,
|
|
1658
1597
|
dbDomain,
|
|
@@ -1660,16 +1599,10 @@ async function initBalanceSummaryMap({ logger, config }) {
|
|
|
1660
1599
|
dbPassword,
|
|
1661
1600
|
dbUserName
|
|
1662
1601
|
};
|
|
1663
|
-
const sdkBalanceSummaryMap = new BaseMongoSdk({
|
|
1664
|
-
...payloadSdkConfig,
|
|
1665
|
-
collection: "balance_summary_map"
|
|
1666
|
-
});
|
|
1602
|
+
const sdkBalanceSummaryMap = new BaseMongoSdk({ ...payloadSdkConfig, collection: "balance_summary_map" });
|
|
1667
1603
|
const result = await MongoMap.create({
|
|
1668
1604
|
sdk: sdkBalanceSummaryMap,
|
|
1669
|
-
getCache: {
|
|
1670
|
-
enabled: true,
|
|
1671
|
-
maxEntries: 5e3
|
|
1672
|
-
}
|
|
1605
|
+
getCache: { enabled: true, maxEntries: 5e3 }
|
|
1673
1606
|
});
|
|
1674
1607
|
assertEx5(await result.start(), () => "Failed to start transfer summary map");
|
|
1675
1608
|
return result;
|
|
@@ -1678,13 +1611,24 @@ async function initBalanceSummaryMap({ logger, config }) {
|
|
|
1678
1611
|
return new MemoryMap();
|
|
1679
1612
|
}
|
|
1680
1613
|
}
|
|
1681
|
-
__name(initBalanceSummaryMap, "initBalanceSummaryMap");
|
|
1682
1614
|
|
|
1683
1615
|
// src/node/init/initEvmProvidersIfAvailable.ts
|
|
1684
1616
|
import { asEthAddress } from "@xylabs/sdk-js";
|
|
1685
|
-
import {
|
|
1617
|
+
import {
|
|
1618
|
+
EvmChainContractViewer,
|
|
1619
|
+
EvmStakeEventsViewer,
|
|
1620
|
+
EvmStakeTotalsViewer,
|
|
1621
|
+
EvmStakeViewer
|
|
1622
|
+
} from "@xyo-network/chain-ethereum";
|
|
1686
1623
|
import { canUseEvmProvider, initEvmProvider } from "@xyo-network/chain-orchestration-evm";
|
|
1687
|
-
import {
|
|
1624
|
+
import {
|
|
1625
|
+
SimpleChainContractViewer,
|
|
1626
|
+
SimpleStakeEventsViewer,
|
|
1627
|
+
SimpleStakeTotalsViewer,
|
|
1628
|
+
SimpleStakeViewer,
|
|
1629
|
+
SimpleTimeSyncViewer,
|
|
1630
|
+
XYO_ZERO_ADDRESS
|
|
1631
|
+
} from "@xyo-network/xl1-sdk";
|
|
1688
1632
|
async function initEvmProvidersIfAvailable(locator) {
|
|
1689
1633
|
const context = locator.context;
|
|
1690
1634
|
const { logger } = context;
|
|
@@ -1692,51 +1636,66 @@ async function initEvmProvidersIfAvailable(locator) {
|
|
|
1692
1636
|
const chainId = context.config.chain.id;
|
|
1693
1637
|
const provider = await initEvmProvider(context);
|
|
1694
1638
|
const address = asEthAddress(chainId, true);
|
|
1695
|
-
locator.register(EvmStakeEventsViewer.factory(
|
|
1696
|
-
|
|
1697
|
-
provider
|
|
1698
|
-
|
|
1699
|
-
locator.register(EvmStakeViewer.factory(
|
|
1700
|
-
|
|
1701
|
-
provider
|
|
1702
|
-
|
|
1703
|
-
locator.register(EvmStakeTotalsViewer.factory(
|
|
1704
|
-
|
|
1705
|
-
provider
|
|
1706
|
-
|
|
1707
|
-
locator.register(EvmChainContractViewer.factory(
|
|
1708
|
-
|
|
1709
|
-
provider
|
|
1710
|
-
|
|
1711
|
-
locator.register(SimpleTimeSyncViewer.factory(
|
|
1712
|
-
|
|
1713
|
-
|
|
1639
|
+
locator.register(EvmStakeEventsViewer.factory(
|
|
1640
|
+
EvmStakeEventsViewer.dependencies,
|
|
1641
|
+
{ address, provider }
|
|
1642
|
+
));
|
|
1643
|
+
locator.register(EvmStakeViewer.factory(
|
|
1644
|
+
EvmStakeViewer.dependencies,
|
|
1645
|
+
{ address, provider }
|
|
1646
|
+
));
|
|
1647
|
+
locator.register(EvmStakeTotalsViewer.factory(
|
|
1648
|
+
EvmStakeTotalsViewer.dependencies,
|
|
1649
|
+
{ address, provider }
|
|
1650
|
+
));
|
|
1651
|
+
locator.register(EvmChainContractViewer.factory(
|
|
1652
|
+
EvmChainContractViewer.dependencies,
|
|
1653
|
+
{ address, provider }
|
|
1654
|
+
));
|
|
1655
|
+
locator.register(SimpleTimeSyncViewer.factory(
|
|
1656
|
+
SimpleTimeSyncViewer.dependencies,
|
|
1657
|
+
{ ethProvider: provider }
|
|
1658
|
+
));
|
|
1714
1659
|
} else {
|
|
1715
1660
|
logger?.warn("EVM provider not available - running with memory based contract/stake viewers");
|
|
1716
1661
|
const positions = [];
|
|
1717
|
-
locator.register(SimpleStakeEventsViewer.factory(
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
locator.register(
|
|
1662
|
+
locator.register(SimpleStakeEventsViewer.factory(
|
|
1663
|
+
SimpleStakeEventsViewer.dependencies,
|
|
1664
|
+
{ positions }
|
|
1665
|
+
));
|
|
1666
|
+
locator.register(SimpleStakeViewer.factory(
|
|
1667
|
+
SimpleStakeViewer.dependencies,
|
|
1668
|
+
{ positions }
|
|
1669
|
+
));
|
|
1670
|
+
locator.register(SimpleStakeTotalsViewer.factory(
|
|
1671
|
+
SimpleStakeTotalsViewer.dependencies,
|
|
1672
|
+
{}
|
|
1673
|
+
));
|
|
1674
|
+
locator.register(SimpleChainContractViewer.factory(
|
|
1675
|
+
SimpleChainContractViewer.dependencies,
|
|
1676
|
+
{
|
|
1677
|
+
minWithdrawalBlocks: 10,
|
|
1678
|
+
stakingTokenAddress: XYO_ZERO_ADDRESS,
|
|
1679
|
+
rewardsContract: XYO_ZERO_ADDRESS
|
|
1680
|
+
}
|
|
1681
|
+
));
|
|
1682
|
+
locator.register(SimpleTimeSyncViewer.factory(
|
|
1683
|
+
SimpleTimeSyncViewer.dependencies,
|
|
1684
|
+
{}
|
|
1685
|
+
));
|
|
1730
1686
|
}
|
|
1731
1687
|
return locator;
|
|
1732
1688
|
}
|
|
1733
|
-
__name(initEvmProvidersIfAvailable, "initEvmProvidersIfAvailable");
|
|
1734
1689
|
|
|
1735
1690
|
// src/node/init/initFinalizationArchivistIfNeeded.ts
|
|
1736
1691
|
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
1737
1692
|
import { createBootstrapHead } from "@xyo-network/chain-sdk";
|
|
1738
1693
|
import { Account } from "@xyo-network/sdk-js";
|
|
1739
|
-
import {
|
|
1694
|
+
import {
|
|
1695
|
+
asAttoXL1,
|
|
1696
|
+
findMostRecentBlock,
|
|
1697
|
+
flattenHydratedBlock
|
|
1698
|
+
} from "@xyo-network/xl1-sdk";
|
|
1740
1699
|
async function initFinalizationArchivistIfNeeded(archivist, config, account, options = {}) {
|
|
1741
1700
|
const configuredChainId = config.chain.id;
|
|
1742
1701
|
const possibleHead = await findMostRecentBlock(archivist);
|
|
@@ -1752,18 +1711,19 @@ async function initFinalizationArchivistIfNeeded(archivist, config, account, opt
|
|
|
1752
1711
|
if (options.onInsecureGenesisConfirm) await options.onInsecureGenesisConfirm();
|
|
1753
1712
|
}
|
|
1754
1713
|
const genesisRewardAddress = await resolveGenesisRewardAddress(config);
|
|
1755
|
-
const chain = await createBootstrapHead(
|
|
1714
|
+
const chain = await createBootstrapHead(
|
|
1715
|
+
account,
|
|
1716
|
+
possibleChainId,
|
|
1717
|
+
asAttoXL1(GENESIS_REWARD_AMOUNT),
|
|
1718
|
+
genesisRewardAddress
|
|
1719
|
+
);
|
|
1756
1720
|
const payloads = chain.flatMap((block) => flattenHydratedBlock(block));
|
|
1757
1721
|
await archivist.insert(payloads);
|
|
1758
1722
|
}
|
|
1759
1723
|
const head = possibleHead ?? assertEx6(await findMostRecentBlock(archivist), () => "No blocks found in chain archivist");
|
|
1760
1724
|
const chainId = assertEx6(possibleChainId, () => "Chain ID could not be determined");
|
|
1761
|
-
return [
|
|
1762
|
-
head,
|
|
1763
|
-
chainId
|
|
1764
|
-
];
|
|
1725
|
+
return [head, chainId];
|
|
1765
1726
|
}
|
|
1766
|
-
__name(initFinalizationArchivistIfNeeded, "initFinalizationArchivistIfNeeded");
|
|
1767
1727
|
|
|
1768
1728
|
// src/node/init/initFinalizedArchivist.ts
|
|
1769
1729
|
import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
|
|
@@ -1772,16 +1732,12 @@ async function initMongoFinalizedArchivist(config) {
|
|
|
1772
1732
|
...config.storage.mongo,
|
|
1773
1733
|
collection: "chain_validated"
|
|
1774
1734
|
};
|
|
1775
|
-
return await MongoDBArchivistV2.create({
|
|
1776
|
-
payloadSdkConfig
|
|
1777
|
-
});
|
|
1735
|
+
return await MongoDBArchivistV2.create({ payloadSdkConfig });
|
|
1778
1736
|
}
|
|
1779
|
-
__name(initMongoFinalizedArchivist, "initMongoFinalizedArchivist");
|
|
1780
1737
|
async function initFinalizedArchivist(config) {
|
|
1781
1738
|
const finalizedArchivist = await initMongoFinalizedArchivist(config);
|
|
1782
1739
|
return finalizedArchivist;
|
|
1783
1740
|
}
|
|
1784
|
-
__name(initFinalizedArchivist, "initFinalizedArchivist");
|
|
1785
1741
|
|
|
1786
1742
|
// src/node/init/initServerNode.ts
|
|
1787
1743
|
import { assertEx as assertEx7 } from "@xylabs/sdk-js";
|
|
@@ -1792,15 +1748,18 @@ import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
|
1792
1748
|
import { LmdbArchivistConfigSchema } from "@xyo-network/archivist-lmdb";
|
|
1793
1749
|
import { MongoDBArchivistV2 as MongoDBArchivistV22, MongoDBArchivistV2Deletable } from "@xyo-network/archivist-mongodb";
|
|
1794
1750
|
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
1795
|
-
import {
|
|
1751
|
+
import {
|
|
1752
|
+
AbstractModule,
|
|
1753
|
+
LoggerModuleStatusReporter,
|
|
1754
|
+
MemoryArchivist,
|
|
1755
|
+
MemorySentinel,
|
|
1756
|
+
ModuleFactoryLocator
|
|
1757
|
+
} from "@xyo-network/sdk-js";
|
|
1796
1758
|
import { hasMongoConfig as hasMongoConfig2 } from "@xyo-network/xl1-sdk";
|
|
1797
1759
|
|
|
1798
1760
|
// src/node/manifest/NamedLmdbArchivist.ts
|
|
1799
1761
|
import { LmdbArchivist } from "@xyo-network/archivist-lmdb";
|
|
1800
1762
|
var NamedLmdbArchivist = class extends LmdbArchivist {
|
|
1801
|
-
static {
|
|
1802
|
-
__name(this, "NamedLmdbArchivist");
|
|
1803
|
-
}
|
|
1804
1763
|
get dbName() {
|
|
1805
1764
|
return this.config.dbName ?? "xyo-chain";
|
|
1806
1765
|
}
|
|
@@ -1820,13 +1779,24 @@ var NamedLmdbArchivist = class extends LmdbArchivist {
|
|
|
1820
1779
|
};
|
|
1821
1780
|
|
|
1822
1781
|
// src/node/manifest/getLocator.ts
|
|
1823
|
-
var getLocator =
|
|
1782
|
+
var getLocator = async ({
|
|
1783
|
+
logger,
|
|
1784
|
+
traceProvider,
|
|
1785
|
+
meterProvider,
|
|
1786
|
+
config
|
|
1787
|
+
}) => {
|
|
1824
1788
|
if (isDefined2(logger)) AbstractModule.defaultLogger = logger;
|
|
1825
1789
|
const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : void 0;
|
|
1826
1790
|
const locator = new ModuleFactoryLocator();
|
|
1827
1791
|
const mongoConfig = config.storage?.mongo;
|
|
1828
1792
|
if (hasMongoConfig2(mongoConfig)) {
|
|
1829
|
-
const {
|
|
1793
|
+
const {
|
|
1794
|
+
connectionString: dbConnectionString,
|
|
1795
|
+
database: dbName,
|
|
1796
|
+
domain: dbDomain,
|
|
1797
|
+
password: dbPassword,
|
|
1798
|
+
username: dbUserName
|
|
1799
|
+
} = mongoConfig;
|
|
1830
1800
|
const payloadSdkConfig = {
|
|
1831
1801
|
dbConnectionString,
|
|
1832
1802
|
dbDomain,
|
|
@@ -1841,9 +1811,7 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1841
1811
|
traceProvider
|
|
1842
1812
|
};
|
|
1843
1813
|
locator.register(MongoDBArchivistV22.factory(params), void 0, true);
|
|
1844
|
-
locator.register(MongoDBArchivistV2Deletable.factory(params), {
|
|
1845
|
-
"network.xyo.storage.capabilities.delete": "enabled"
|
|
1846
|
-
}, false);
|
|
1814
|
+
locator.register(MongoDBArchivistV2Deletable.factory(params), { "network.xyo.storage.capabilities.delete": "enabled" }, false);
|
|
1847
1815
|
} else if (isDefined2(config.storage?.root)) {
|
|
1848
1816
|
const lmdbLocation = config.storage.root;
|
|
1849
1817
|
const lmdbConfig = {
|
|
@@ -1851,12 +1819,16 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1851
1819
|
location: lmdbLocation,
|
|
1852
1820
|
schema: LmdbArchivistConfigSchema
|
|
1853
1821
|
};
|
|
1854
|
-
locator.register(
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1822
|
+
locator.register(
|
|
1823
|
+
NamedLmdbArchivist.factory({
|
|
1824
|
+
config: lmdbConfig,
|
|
1825
|
+
meterProvider,
|
|
1826
|
+
statusReporter,
|
|
1827
|
+
traceProvider
|
|
1828
|
+
}),
|
|
1829
|
+
void 0,
|
|
1830
|
+
true
|
|
1831
|
+
);
|
|
1860
1832
|
}
|
|
1861
1833
|
locator.register(MemoryArchivist.factory({
|
|
1862
1834
|
traceProvider,
|
|
@@ -1874,7 +1846,7 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1874
1846
|
statusReporter
|
|
1875
1847
|
}));
|
|
1876
1848
|
return locator;
|
|
1877
|
-
}
|
|
1849
|
+
};
|
|
1878
1850
|
|
|
1879
1851
|
// src/node/manifest/loadNode.ts
|
|
1880
1852
|
import { ManifestWrapper } from "@xyo-network/sdk-js";
|
|
@@ -2078,7 +2050,7 @@ var PublicChildManifests = [
|
|
|
2078
2050
|
];
|
|
2079
2051
|
|
|
2080
2052
|
// src/node/manifest/loadNode.ts
|
|
2081
|
-
var loadNode =
|
|
2053
|
+
var loadNode = async (context, wallet) => {
|
|
2082
2054
|
const locator = await getLocator(context);
|
|
2083
2055
|
const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests);
|
|
2084
2056
|
const [node, ...childNodes] = await wrapper.loadNodes();
|
|
@@ -2087,45 +2059,45 @@ var loadNode = /* @__PURE__ */ __name(async (context, wallet) => {
|
|
|
2087
2059
|
await Promise.all(childNodes.map((childNode) => node.attach(childNode.address, true)));
|
|
2088
2060
|
}
|
|
2089
2061
|
return node;
|
|
2090
|
-
}
|
|
2062
|
+
};
|
|
2091
2063
|
|
|
2092
2064
|
// src/node/init/initServerNode.ts
|
|
2093
2065
|
async function writableChainArchivistFromNode(node) {
|
|
2094
|
-
return asArchivistInstance(
|
|
2095
|
-
|
|
2096
|
-
|
|
2066
|
+
return asArchivistInstance(
|
|
2067
|
+
await node.resolve("Chain:Validated"),
|
|
2068
|
+
{ required: true }
|
|
2069
|
+
);
|
|
2097
2070
|
}
|
|
2098
|
-
__name(writableChainArchivistFromNode, "writableChainArchivistFromNode");
|
|
2099
2071
|
async function readonlyChainArchivistFromNode(node) {
|
|
2100
|
-
return assertEx7(asArchivistInstance(
|
|
2101
|
-
|
|
2102
|
-
|
|
2072
|
+
return assertEx7(asArchivistInstance(
|
|
2073
|
+
await node.resolve("Chain:Validated"),
|
|
2074
|
+
{ required: true }
|
|
2075
|
+
));
|
|
2103
2076
|
}
|
|
2104
|
-
__name(readonlyChainArchivistFromNode, "readonlyChainArchivistFromNode");
|
|
2105
2077
|
async function pendingTransactionsArchivistFromNode(node) {
|
|
2106
|
-
return asArchivistInstance(
|
|
2107
|
-
|
|
2108
|
-
|
|
2078
|
+
return asArchivistInstance(
|
|
2079
|
+
await node.resolve("XYOChain:Pending:Transactions"),
|
|
2080
|
+
{ required: true }
|
|
2081
|
+
);
|
|
2109
2082
|
}
|
|
2110
|
-
__name(pendingTransactionsArchivistFromNode, "pendingTransactionsArchivistFromNode");
|
|
2111
2083
|
async function pendingBlocksArchivistFromNode(node) {
|
|
2112
|
-
return asArchivistInstance(
|
|
2113
|
-
|
|
2114
|
-
|
|
2084
|
+
return asArchivistInstance(
|
|
2085
|
+
await node.resolve("XYOChain:Pending:Blocks"),
|
|
2086
|
+
{ required: true }
|
|
2087
|
+
);
|
|
2115
2088
|
}
|
|
2116
|
-
__name(pendingBlocksArchivistFromNode, "pendingBlocksArchivistFromNode");
|
|
2117
2089
|
async function rejectedBlocksArchivistFromNode(node) {
|
|
2118
|
-
return asArchivistInstance(
|
|
2119
|
-
|
|
2120
|
-
|
|
2090
|
+
return asArchivistInstance(
|
|
2091
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedBlocks"),
|
|
2092
|
+
{ required: true }
|
|
2093
|
+
);
|
|
2121
2094
|
}
|
|
2122
|
-
__name(rejectedBlocksArchivistFromNode, "rejectedBlocksArchivistFromNode");
|
|
2123
2095
|
async function rejectedTransactionsArchivistFromNode(node) {
|
|
2124
|
-
return asArchivistInstance(
|
|
2125
|
-
|
|
2126
|
-
|
|
2096
|
+
return asArchivistInstance(
|
|
2097
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedTransactions"),
|
|
2098
|
+
{ required: true }
|
|
2099
|
+
);
|
|
2127
2100
|
}
|
|
2128
|
-
__name(rejectedTransactionsArchivistFromNode, "rejectedTransactionsArchivistFromNode");
|
|
2129
2101
|
async function initServerNode(context, wallet, providedNode) {
|
|
2130
2102
|
const node = providedNode ?? await loadNode(context, wallet);
|
|
2131
2103
|
assertEx7(await node.start(), () => "Failed to start node");
|
|
@@ -2145,7 +2117,6 @@ async function initServerNode(context, wallet, providedNode) {
|
|
|
2145
2117
|
rejectedTransactionsArchivist
|
|
2146
2118
|
};
|
|
2147
2119
|
}
|
|
2148
|
-
__name(initServerNode, "initServerNode");
|
|
2149
2120
|
|
|
2150
2121
|
// src/node/init/initTransferSummaryMap.ts
|
|
2151
2122
|
import { BaseMongoSdk as BaseMongoSdk2 } from "@xylabs/mongo";
|
|
@@ -2155,7 +2126,13 @@ import { hasMongoConfig as hasMongoConfig3, MemoryMap as MemoryMap2 } from "@xyo
|
|
|
2155
2126
|
async function initTransferSummaryMap({ logger, config }) {
|
|
2156
2127
|
const mongoConfig = config.storage?.mongo;
|
|
2157
2128
|
if (hasMongoConfig3(mongoConfig)) {
|
|
2158
|
-
const {
|
|
2129
|
+
const {
|
|
2130
|
+
connectionString: dbConnectionString,
|
|
2131
|
+
database: dbName,
|
|
2132
|
+
domain: dbDomain,
|
|
2133
|
+
password: dbPassword,
|
|
2134
|
+
username: dbUserName
|
|
2135
|
+
} = mongoConfig;
|
|
2159
2136
|
const payloadSdkConfig = {
|
|
2160
2137
|
dbConnectionString,
|
|
2161
2138
|
dbDomain,
|
|
@@ -2163,16 +2140,10 @@ async function initTransferSummaryMap({ logger, config }) {
|
|
|
2163
2140
|
dbPassword,
|
|
2164
2141
|
dbUserName
|
|
2165
2142
|
};
|
|
2166
|
-
const sdkTransferSummaryMap = new BaseMongoSdk2({
|
|
2167
|
-
...payloadSdkConfig,
|
|
2168
|
-
collection: "transfer_summary_map"
|
|
2169
|
-
});
|
|
2143
|
+
const sdkTransferSummaryMap = new BaseMongoSdk2({ ...payloadSdkConfig, collection: "transfer_summary_map" });
|
|
2170
2144
|
const result = await MongoMap2.create({
|
|
2171
2145
|
sdk: sdkTransferSummaryMap,
|
|
2172
|
-
getCache: {
|
|
2173
|
-
enabled: true,
|
|
2174
|
-
maxEntries: 5e3
|
|
2175
|
-
}
|
|
2146
|
+
getCache: { enabled: true, maxEntries: 5e3 }
|
|
2176
2147
|
});
|
|
2177
2148
|
assertEx8(await result.start(), () => "Failed to start transfer summary map");
|
|
2178
2149
|
return result;
|
|
@@ -2181,26 +2152,24 @@ async function initTransferSummaryMap({ logger, config }) {
|
|
|
2181
2152
|
return new MemoryMap2();
|
|
2182
2153
|
}
|
|
2183
2154
|
}
|
|
2184
|
-
__name(initTransferSummaryMap, "initTransferSummaryMap");
|
|
2185
2155
|
|
|
2186
2156
|
// src/node/config/capabilities/backings/buildChainStoreBacking.ts
|
|
2187
2157
|
import { asArchivistInstance as asArchivistInstance2 } from "@xyo-network/sdk-js";
|
|
2188
2158
|
async function buildChainStoreBacking(node, mode, options) {
|
|
2189
|
-
const readonlyArchivist = asArchivistInstance2(
|
|
2190
|
-
|
|
2191
|
-
|
|
2159
|
+
const readonlyArchivist = asArchivistInstance2(
|
|
2160
|
+
await node.resolve("Chain:Validated"),
|
|
2161
|
+
{ required: true }
|
|
2162
|
+
);
|
|
2192
2163
|
if (mode === "read") {
|
|
2193
|
-
return {
|
|
2194
|
-
mode,
|
|
2195
|
-
readonlyArchivist
|
|
2196
|
-
};
|
|
2164
|
+
return { mode, readonlyArchivist };
|
|
2197
2165
|
}
|
|
2198
2166
|
if (!options) {
|
|
2199
2167
|
throw new Error("buildChainStoreBacking(write) requires options { actorConfig, wallet }");
|
|
2200
2168
|
}
|
|
2201
|
-
const writableArchivist = asArchivistInstance2(
|
|
2202
|
-
|
|
2203
|
-
|
|
2169
|
+
const writableArchivist = asArchivistInstance2(
|
|
2170
|
+
await node.resolve("Chain:Validated"),
|
|
2171
|
+
{ required: true }
|
|
2172
|
+
);
|
|
2204
2173
|
await initFinalizationArchivistIfNeeded(writableArchivist, options.actorConfig, options.wallet, {
|
|
2205
2174
|
logger: options.logger,
|
|
2206
2175
|
onInsecureGenesisConfirm: options.onInsecureGenesisConfirm
|
|
@@ -2211,24 +2180,24 @@ async function buildChainStoreBacking(node, mode, options) {
|
|
|
2211
2180
|
writableArchivist
|
|
2212
2181
|
};
|
|
2213
2182
|
}
|
|
2214
|
-
__name(buildChainStoreBacking, "buildChainStoreBacking");
|
|
2215
2183
|
|
|
2216
2184
|
// src/node/config/capabilities/backings/buildDlqStoreBacking.ts
|
|
2217
2185
|
import { asArchivistInstance as asArchivistInstance3 } from "@xyo-network/sdk-js";
|
|
2218
2186
|
async function buildDlqStoreBacking(node, mode) {
|
|
2219
|
-
const rejectedBlocksArchivist = asArchivistInstance3(
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2187
|
+
const rejectedBlocksArchivist = asArchivistInstance3(
|
|
2188
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedBlocks"),
|
|
2189
|
+
{ required: true }
|
|
2190
|
+
);
|
|
2191
|
+
const rejectedTransactionsArchivist = asArchivistInstance3(
|
|
2192
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedTransactions"),
|
|
2193
|
+
{ required: true }
|
|
2194
|
+
);
|
|
2225
2195
|
return {
|
|
2226
2196
|
mode,
|
|
2227
2197
|
rejectedBlocksArchivist,
|
|
2228
2198
|
rejectedTransactionsArchivist
|
|
2229
2199
|
};
|
|
2230
2200
|
}
|
|
2231
|
-
__name(buildDlqStoreBacking, "buildDlqStoreBacking");
|
|
2232
2201
|
|
|
2233
2202
|
// src/node/config/capabilities/backings/buildIndexerStoreBacking.ts
|
|
2234
2203
|
import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
@@ -2241,39 +2210,40 @@ async function buildIndexerStoreBacking(context, mode) {
|
|
|
2241
2210
|
transfersSummaryMap
|
|
2242
2211
|
};
|
|
2243
2212
|
}
|
|
2244
|
-
__name(buildIndexerStoreBacking, "buildIndexerStoreBacking");
|
|
2245
2213
|
|
|
2246
2214
|
// src/node/config/capabilities/backings/buildMempoolStoreBacking.ts
|
|
2247
2215
|
import { asArchivistInstance as asArchivistInstance4 } from "@xyo-network/sdk-js";
|
|
2248
2216
|
async function buildMempoolStoreBacking(node, mode) {
|
|
2249
|
-
const pendingTransactionsArchivist = asArchivistInstance4(
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2217
|
+
const pendingTransactionsArchivist = asArchivistInstance4(
|
|
2218
|
+
await node.resolve("XYOChain:Pending:Transactions"),
|
|
2219
|
+
{ required: true }
|
|
2220
|
+
);
|
|
2221
|
+
const pendingBlocksArchivist = asArchivistInstance4(
|
|
2222
|
+
await node.resolve("XYOChain:Pending:Blocks"),
|
|
2223
|
+
{ required: true }
|
|
2224
|
+
);
|
|
2255
2225
|
return {
|
|
2256
2226
|
mode,
|
|
2257
2227
|
pendingBlocksArchivist,
|
|
2258
2228
|
pendingTransactionsArchivist
|
|
2259
2229
|
};
|
|
2260
2230
|
}
|
|
2261
|
-
__name(buildMempoolStoreBacking, "buildMempoolStoreBacking");
|
|
2262
2231
|
|
|
2263
2232
|
// src/node/config/capabilities/backings/buildValidators.ts
|
|
2264
|
-
import {
|
|
2233
|
+
import {
|
|
2234
|
+
validateHydratedBlock,
|
|
2235
|
+
validateHydratedBlockState,
|
|
2236
|
+
validateHydratedTransactionState
|
|
2237
|
+
} from "@xyo-network/chain-validation";
|
|
2265
2238
|
import { BlockCumulativeBalanceValidatorFactory, validateTransaction } from "@xyo-network/xl1-sdk";
|
|
2266
2239
|
var cumulativeBalanceValidator = BlockCumulativeBalanceValidatorFactory();
|
|
2267
|
-
var validateHydratedBlockStateWithCumulativeBalance =
|
|
2240
|
+
var validateHydratedBlockStateWithCumulativeBalance = async (context, block) => {
|
|
2268
2241
|
const [stateErrors, cumulativeErrors] = await Promise.all([
|
|
2269
2242
|
validateHydratedBlockState(context, block),
|
|
2270
2243
|
cumulativeBalanceValidator(context, block)
|
|
2271
2244
|
]);
|
|
2272
|
-
return [
|
|
2273
|
-
|
|
2274
|
-
...cumulativeErrors
|
|
2275
|
-
];
|
|
2276
|
-
}, "validateHydratedBlockStateWithCumulativeBalance");
|
|
2245
|
+
return [...stateErrors, ...cumulativeErrors];
|
|
2246
|
+
};
|
|
2277
2247
|
function buildValidators() {
|
|
2278
2248
|
return {
|
|
2279
2249
|
blockProtocolValidator: validateHydratedBlock,
|
|
@@ -2282,7 +2252,6 @@ function buildValidators() {
|
|
|
2282
2252
|
transactionStateValidator: validateHydratedTransactionState
|
|
2283
2253
|
};
|
|
2284
2254
|
}
|
|
2285
|
-
__name(buildValidators, "buildValidators");
|
|
2286
2255
|
|
|
2287
2256
|
// src/node/config/capabilities/ProcessSharedResources.ts
|
|
2288
2257
|
async function buildProcessSharedResources(context, options) {
|
|
@@ -2318,7 +2287,6 @@ async function buildProcessSharedResources(context, options) {
|
|
|
2318
2287
|
writableChainArchivist: chainStore.writableArchivist
|
|
2319
2288
|
};
|
|
2320
2289
|
}
|
|
2321
|
-
__name(buildProcessSharedResources, "buildProcessSharedResources");
|
|
2322
2290
|
|
|
2323
2291
|
// src/node/config/capabilities/resolveProviders.ts
|
|
2324
2292
|
import { MissingCapabilityError, resolveProviders } from "@xyo-network/xl1-protocol-sdk";
|
|
@@ -2338,9 +2306,12 @@ async function locatorFromActorNeeds(context, actorNeeds, options = {}) {
|
|
|
2338
2306
|
...networkTier3Descriptors,
|
|
2339
2307
|
...options.extraDescriptors ?? []
|
|
2340
2308
|
];
|
|
2341
|
-
const plan = resolveProviders(
|
|
2342
|
-
|
|
2343
|
-
|
|
2309
|
+
const plan = resolveProviders(
|
|
2310
|
+
needs,
|
|
2311
|
+
candidates,
|
|
2312
|
+
resolutionContext,
|
|
2313
|
+
{ availableBackings: options.availableBackings }
|
|
2314
|
+
);
|
|
2344
2315
|
const locator = new ProviderFactoryLocator(context, {}, options.validateDepsOnRegister ?? false);
|
|
2345
2316
|
const factories = plan.selected.map((d) => d.build(resolutionContext)).filter((f) => f !== void 0);
|
|
2346
2317
|
locator.registerMany(factories);
|
|
@@ -2350,7 +2321,6 @@ async function locatorFromActorNeeds(context, actorNeeds, options = {}) {
|
|
|
2350
2321
|
process: process2
|
|
2351
2322
|
};
|
|
2352
2323
|
}
|
|
2353
|
-
__name(locatorFromActorNeeds, "locatorFromActorNeeds");
|
|
2354
2324
|
function unionNeeds(actorNeeds) {
|
|
2355
2325
|
const result = /* @__PURE__ */ new Set();
|
|
2356
2326
|
for (const needs of actorNeeds) {
|
|
@@ -2359,53 +2329,56 @@ function unionNeeds(actorNeeds) {
|
|
|
2359
2329
|
}
|
|
2360
2330
|
return result;
|
|
2361
2331
|
}
|
|
2362
|
-
__name(unionNeeds, "unionNeeds");
|
|
2363
2332
|
|
|
2364
2333
|
// src/node/config/locators/basicRemoteRunnerLocator.ts
|
|
2365
2334
|
import { isAccountInstance } from "@xyo-network/sdk-js";
|
|
2366
|
-
import {
|
|
2335
|
+
import {
|
|
2336
|
+
basicRemoteRunnerLocator as sdkBasicRemoteRunnerLocator,
|
|
2337
|
+
JsonRpcAccountBalanceViewer,
|
|
2338
|
+
JsonRpcXyoSigner,
|
|
2339
|
+
SimpleXyoSigner
|
|
2340
|
+
} from "@xyo-network/xl1-sdk";
|
|
2367
2341
|
function signerFactoryFromParam(signer) {
|
|
2368
2342
|
if (isAccountInstance(signer)) {
|
|
2369
|
-
return SimpleXyoSigner.factory(SimpleXyoSigner.dependencies, {
|
|
2370
|
-
account: signer
|
|
2371
|
-
});
|
|
2343
|
+
return SimpleXyoSigner.factory(SimpleXyoSigner.dependencies, { account: signer });
|
|
2372
2344
|
}
|
|
2373
|
-
return JsonRpcXyoSigner.factory(JsonRpcXyoSigner.dependencies, {
|
|
2374
|
-
transport: signer
|
|
2375
|
-
});
|
|
2345
|
+
return JsonRpcXyoSigner.factory(JsonRpcXyoSigner.dependencies, { transport: signer });
|
|
2376
2346
|
}
|
|
2377
|
-
__name(signerFactoryFromParam, "signerFactoryFromParam");
|
|
2378
2347
|
function basicRemoteRunnerLocator(name, remoteConfig, signer, dataLakeEndpoint, validators) {
|
|
2379
2348
|
const transport = isAccountInstance(signer) ? void 0 : signer;
|
|
2380
2349
|
return sdkBasicRemoteRunnerLocator(name, remoteConfig, transport, dataLakeEndpoint, {
|
|
2381
2350
|
additionalProviders: [
|
|
2382
|
-
JsonRpcAccountBalanceViewer.factory(
|
|
2351
|
+
JsonRpcAccountBalanceViewer.factory(
|
|
2352
|
+
JsonRpcAccountBalanceViewer.dependencies,
|
|
2353
|
+
{}
|
|
2354
|
+
)
|
|
2383
2355
|
],
|
|
2384
2356
|
signerFactory: signerFactoryFromParam(signer),
|
|
2385
2357
|
skipGatewayRunner: true,
|
|
2386
2358
|
validators
|
|
2387
2359
|
});
|
|
2388
2360
|
}
|
|
2389
|
-
__name(basicRemoteRunnerLocator, "basicRemoteRunnerLocator");
|
|
2390
2361
|
|
|
2391
2362
|
// src/node/config/locators/basicRemoteViewerLocator.ts
|
|
2392
|
-
import {
|
|
2363
|
+
import {
|
|
2364
|
+
basicRemoteViewerLocator as sdkBasicRemoteViewerLocator,
|
|
2365
|
+
JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer2
|
|
2366
|
+
} from "@xyo-network/xl1-sdk";
|
|
2393
2367
|
function basicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, validators) {
|
|
2394
2368
|
return sdkBasicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, {
|
|
2395
2369
|
additionalProviders: [
|
|
2396
|
-
JsonRpcAccountBalanceViewer2.factory(
|
|
2370
|
+
JsonRpcAccountBalanceViewer2.factory(
|
|
2371
|
+
JsonRpcAccountBalanceViewer2.dependencies,
|
|
2372
|
+
{}
|
|
2373
|
+
)
|
|
2397
2374
|
],
|
|
2398
2375
|
validators
|
|
2399
2376
|
});
|
|
2400
2377
|
}
|
|
2401
|
-
__name(basicRemoteViewerLocator, "basicRemoteViewerLocator");
|
|
2402
2378
|
|
|
2403
2379
|
// src/node/config/locators/buildStatelessApiLocator.ts
|
|
2404
2380
|
var STATELESS_BACKINGS = [
|
|
2405
|
-
{
|
|
2406
|
-
backing: "network",
|
|
2407
|
-
mode: "read"
|
|
2408
|
-
}
|
|
2381
|
+
{ backing: "network", mode: "read" }
|
|
2409
2382
|
];
|
|
2410
2383
|
async function buildStatelessApiLocator(context, needs) {
|
|
2411
2384
|
const stubProcess = {};
|
|
@@ -2415,7 +2388,6 @@ async function buildStatelessApiLocator(context, needs) {
|
|
|
2415
2388
|
});
|
|
2416
2389
|
return result.locator;
|
|
2417
2390
|
}
|
|
2418
|
-
__name(buildStatelessApiLocator, "buildStatelessApiLocator");
|
|
2419
2391
|
|
|
2420
2392
|
// src/node/config/locators/telemetryContextFromConfig.ts
|
|
2421
2393
|
import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
@@ -2428,22 +2400,16 @@ async function telemetryContextFromConfig(config, serviceName, serviceVersion, d
|
|
|
2428
2400
|
serviceVersion
|
|
2429
2401
|
},
|
|
2430
2402
|
otlpEndpoint,
|
|
2431
|
-
metricsConfig: {
|
|
2432
|
-
endpoint,
|
|
2433
|
-
port
|
|
2434
|
-
}
|
|
2403
|
+
metricsConfig: { endpoint, port }
|
|
2435
2404
|
});
|
|
2436
2405
|
}
|
|
2437
|
-
__name(telemetryContextFromConfig, "telemetryContextFromConfig");
|
|
2438
2406
|
|
|
2439
2407
|
// src/node/config/locators/contextFromConfigWithoutLocator.ts
|
|
2440
2408
|
async function contextFromConfigWithoutLocator(config, logger, serviceName, serviceVersion, defaultScrapePort) {
|
|
2441
2409
|
const singletons = {};
|
|
2442
2410
|
const caches = {};
|
|
2443
2411
|
const telemetryConfig = await telemetryContextFromConfig(config, serviceName, serviceVersion, defaultScrapePort);
|
|
2444
|
-
const statusReporter = initStatusReporter({
|
|
2445
|
-
logger
|
|
2446
|
-
});
|
|
2412
|
+
const statusReporter = initStatusReporter({ logger });
|
|
2447
2413
|
return {
|
|
2448
2414
|
...telemetryConfig,
|
|
2449
2415
|
config,
|
|
@@ -2453,10 +2419,23 @@ async function contextFromConfigWithoutLocator(config, logger, serviceName, serv
|
|
|
2453
2419
|
statusReporter
|
|
2454
2420
|
};
|
|
2455
2421
|
}
|
|
2456
|
-
__name(contextFromConfigWithoutLocator, "contextFromConfigWithoutLocator");
|
|
2457
2422
|
|
|
2458
2423
|
// src/node/config/locators/localLocatorFromConfig.ts
|
|
2459
|
-
import {
|
|
2424
|
+
import {
|
|
2425
|
+
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
2426
|
+
BlockValidationViewerMoniker as BlockValidationViewerMoniker2,
|
|
2427
|
+
BlockViewerMoniker as BlockViewerMoniker2,
|
|
2428
|
+
DeadLetterQueueRunnerMoniker as DeadLetterQueueRunnerMoniker2,
|
|
2429
|
+
DeadLetterQueueViewerMoniker as DeadLetterQueueViewerMoniker2,
|
|
2430
|
+
FinalizationRunnerMoniker as FinalizationRunnerMoniker2,
|
|
2431
|
+
FinalizationViewerMoniker as FinalizationViewerMoniker2,
|
|
2432
|
+
MempoolRunnerMoniker as MempoolRunnerMoniker2,
|
|
2433
|
+
MempoolViewerMoniker as MempoolViewerMoniker2,
|
|
2434
|
+
TransactionValidationViewerMoniker as TransactionValidationViewerMoniker2,
|
|
2435
|
+
TransactionViewerMoniker as TransactionViewerMoniker2,
|
|
2436
|
+
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker2,
|
|
2437
|
+
XyoViewerMoniker as XyoViewerMoniker2
|
|
2438
|
+
} from "@xyo-network/xl1-sdk";
|
|
2460
2439
|
var XyoConnectionMoniker2 = "XyoConnection";
|
|
2461
2440
|
var LOCAL_LEGACY_NEEDS = {
|
|
2462
2441
|
required: [
|
|
@@ -2478,21 +2457,30 @@ var LOCAL_LEGACY_NEEDS = {
|
|
|
2478
2457
|
]
|
|
2479
2458
|
};
|
|
2480
2459
|
async function localLocatorFromConfig(context, validateDepsOnRegister = false, onInsecureGenesisConfirm) {
|
|
2481
|
-
const result = await locatorFromActorNeeds(context, [
|
|
2482
|
-
LOCAL_LEGACY_NEEDS
|
|
2483
|
-
], {
|
|
2460
|
+
const result = await locatorFromActorNeeds(context, [LOCAL_LEGACY_NEEDS], {
|
|
2484
2461
|
onInsecureGenesisConfirm,
|
|
2485
2462
|
validateDepsOnRegister
|
|
2486
2463
|
});
|
|
2487
2464
|
return result.locator;
|
|
2488
2465
|
}
|
|
2489
|
-
__name(localLocatorFromConfig, "localLocatorFromConfig");
|
|
2490
2466
|
|
|
2491
2467
|
// src/node/config/locators/locatorsFromConfig.ts
|
|
2492
2468
|
import { deepMerge as deepMerge3 } from "@xylabs/sdk-js";
|
|
2493
2469
|
|
|
2494
2470
|
// src/node/config/locators/actors/apiLocatorFromConfig.ts
|
|
2495
|
-
import {
|
|
2471
|
+
import {
|
|
2472
|
+
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
2473
|
+
BlockViewerMoniker as BlockViewerMoniker3,
|
|
2474
|
+
FinalizationViewerMoniker as FinalizationViewerMoniker3,
|
|
2475
|
+
MempoolViewerMoniker as MempoolViewerMoniker3,
|
|
2476
|
+
ProviderFactoryLocator as ProviderFactoryLocator2,
|
|
2477
|
+
SimpleXyoConnectionRunner,
|
|
2478
|
+
SimpleXyoGateway,
|
|
2479
|
+
SimpleXyoRunner,
|
|
2480
|
+
TransactionViewerMoniker as TransactionViewerMoniker3,
|
|
2481
|
+
XyoConnectionMoniker as XyoConnectionMoniker3,
|
|
2482
|
+
XyoViewerMoniker as XyoViewerMoniker3
|
|
2483
|
+
} from "@xyo-network/xl1-sdk";
|
|
2496
2484
|
var API_NEEDS = {
|
|
2497
2485
|
required: [
|
|
2498
2486
|
AccountBalanceViewerMoniker3,
|
|
@@ -2506,9 +2494,7 @@ var API_NEEDS = {
|
|
|
2506
2494
|
};
|
|
2507
2495
|
async function apiLocatorFromConfig(context, parent) {
|
|
2508
2496
|
if (context.config.stateless) {
|
|
2509
|
-
const locator2 = await buildStatelessApiLocator(context, [
|
|
2510
|
-
API_NEEDS
|
|
2511
|
-
]);
|
|
2497
|
+
const locator2 = await buildStatelessApiLocator(context, [API_NEEDS]);
|
|
2512
2498
|
locator2.registerMany([
|
|
2513
2499
|
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
2514
2500
|
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
@@ -2517,10 +2503,7 @@ async function apiLocatorFromConfig(context, parent) {
|
|
|
2517
2503
|
locator2.freeze();
|
|
2518
2504
|
return locator2;
|
|
2519
2505
|
}
|
|
2520
|
-
const locator = new ProviderFactoryLocator2({
|
|
2521
|
-
...context,
|
|
2522
|
-
locator: parent
|
|
2523
|
-
});
|
|
2506
|
+
const locator = new ProviderFactoryLocator2({ ...context, locator: parent });
|
|
2524
2507
|
locator.registerMany([
|
|
2525
2508
|
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
2526
2509
|
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
@@ -2529,16 +2512,28 @@ async function apiLocatorFromConfig(context, parent) {
|
|
|
2529
2512
|
locator.freeze();
|
|
2530
2513
|
return locator;
|
|
2531
2514
|
}
|
|
2532
|
-
__name(apiLocatorFromConfig, "apiLocatorFromConfig");
|
|
2533
2515
|
|
|
2534
2516
|
// src/node/config/locators/actors/bridgeLocatorFromConfig.ts
|
|
2535
2517
|
import { isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
2536
|
-
import {
|
|
2518
|
+
import {
|
|
2519
|
+
JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer3,
|
|
2520
|
+
JsonRpcBlockViewer,
|
|
2521
|
+
JsonRpcFinalizationViewer,
|
|
2522
|
+
JsonRpcMempoolRunner,
|
|
2523
|
+
JsonRpcMempoolViewer,
|
|
2524
|
+
JsonRpcXyoRunner,
|
|
2525
|
+
JsonRpcXyoViewer,
|
|
2526
|
+
ProviderFactoryLocator as ProviderFactoryLocator3,
|
|
2527
|
+
RestDataLakeRunner,
|
|
2528
|
+
RestDataLakeViewer,
|
|
2529
|
+
SimpleStakeEventsViewer as SimpleStakeEventsViewer2,
|
|
2530
|
+
SimpleXyoConnectionRunner as SimpleXyoConnectionRunner2,
|
|
2531
|
+
SimpleXyoGatewayRunner,
|
|
2532
|
+
SimpleXyoRunner as SimpleXyoRunner2,
|
|
2533
|
+
SimpleXyoSigner as SimpleXyoSigner2
|
|
2534
|
+
} from "@xyo-network/xl1-sdk";
|
|
2537
2535
|
async function bridgeLocatorFromConfig(context, parent) {
|
|
2538
|
-
const locator = new ProviderFactoryLocator3({
|
|
2539
|
-
...context,
|
|
2540
|
-
locator: parent
|
|
2541
|
-
});
|
|
2536
|
+
const locator = new ProviderFactoryLocator3({ ...context, locator: parent });
|
|
2542
2537
|
const { config } = context;
|
|
2543
2538
|
const { dataLake } = config;
|
|
2544
2539
|
const signerAccount = await initActorWallet(context);
|
|
@@ -2546,8 +2541,14 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2546
2541
|
locator.registerMany([
|
|
2547
2542
|
JsonRpcMempoolViewer.factory(JsonRpcMempoolViewer.dependencies, {}),
|
|
2548
2543
|
JsonRpcMempoolRunner.factory(JsonRpcMempoolRunner.dependencies, {}),
|
|
2549
|
-
JsonRpcAccountBalanceViewer3.factory(
|
|
2550
|
-
|
|
2544
|
+
JsonRpcAccountBalanceViewer3.factory(
|
|
2545
|
+
JsonRpcAccountBalanceViewer3.dependencies,
|
|
2546
|
+
{}
|
|
2547
|
+
),
|
|
2548
|
+
JsonRpcFinalizationViewer.factory(
|
|
2549
|
+
JsonRpcFinalizationViewer.dependencies,
|
|
2550
|
+
{}
|
|
2551
|
+
),
|
|
2551
2552
|
JsonRpcBlockViewer.factory(JsonRpcBlockViewer.dependencies, {}),
|
|
2552
2553
|
JsonRpcXyoRunner.factory(JsonRpcXyoRunner.dependencies, {}),
|
|
2553
2554
|
JsonRpcXyoViewer.factory(JsonRpcXyoViewer.dependencies, {})
|
|
@@ -2559,12 +2560,8 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2559
2560
|
case "rest": {
|
|
2560
2561
|
const { url: endpoint } = dataLake;
|
|
2561
2562
|
locator.registerMany([
|
|
2562
|
-
RestDataLakeRunner.factory(RestDataLakeRunner.dependencies, {
|
|
2563
|
-
|
|
2564
|
-
}),
|
|
2565
|
-
RestDataLakeViewer.factory(RestDataLakeViewer.dependencies, {
|
|
2566
|
-
endpoint
|
|
2567
|
-
})
|
|
2563
|
+
RestDataLakeRunner.factory(RestDataLakeRunner.dependencies, { endpoint }),
|
|
2564
|
+
RestDataLakeViewer.factory(RestDataLakeViewer.dependencies, { endpoint })
|
|
2568
2565
|
]);
|
|
2569
2566
|
break;
|
|
2570
2567
|
}
|
|
@@ -2574,12 +2571,8 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2574
2571
|
}
|
|
2575
2572
|
}
|
|
2576
2573
|
locator.registerMany([
|
|
2577
|
-
SimpleStakeEventsViewer2.factory(SimpleStakeEventsViewer2.dependencies, {
|
|
2578
|
-
|
|
2579
|
-
}),
|
|
2580
|
-
SimpleXyoSigner2.factory(SimpleXyoSigner2.dependencies, {
|
|
2581
|
-
account: signerAccount
|
|
2582
|
-
}),
|
|
2574
|
+
SimpleStakeEventsViewer2.factory(SimpleStakeEventsViewer2.dependencies, { positions: [] }),
|
|
2575
|
+
SimpleXyoSigner2.factory(SimpleXyoSigner2.dependencies, { account: signerAccount }),
|
|
2583
2576
|
SimpleXyoRunner2.factory(SimpleXyoRunner2.dependencies, {}),
|
|
2584
2577
|
SimpleXyoConnectionRunner2.factory(SimpleXyoConnectionRunner2.dependencies, {}),
|
|
2585
2578
|
SimpleXyoGatewayRunner.factory(SimpleXyoGatewayRunner.dependencies, {})
|
|
@@ -2587,33 +2580,24 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2587
2580
|
locator.freeze();
|
|
2588
2581
|
return locator;
|
|
2589
2582
|
}
|
|
2590
|
-
__name(bridgeLocatorFromConfig, "bridgeLocatorFromConfig");
|
|
2591
2583
|
|
|
2592
2584
|
// src/node/config/locators/actors/finalizerLocatorFromConfig.ts
|
|
2593
2585
|
import { ProviderFactoryLocator as ProviderFactoryLocator4 } from "@xyo-network/xl1-sdk";
|
|
2594
2586
|
function finalizerLocatorFromConfig(context, parent) {
|
|
2595
|
-
const locator = new ProviderFactoryLocator4({
|
|
2596
|
-
...context,
|
|
2597
|
-
locator: parent
|
|
2598
|
-
});
|
|
2587
|
+
const locator = new ProviderFactoryLocator4({ ...context, locator: parent });
|
|
2599
2588
|
locator.registerMany([]);
|
|
2600
2589
|
locator.freeze();
|
|
2601
2590
|
return locator;
|
|
2602
2591
|
}
|
|
2603
|
-
__name(finalizerLocatorFromConfig, "finalizerLocatorFromConfig");
|
|
2604
2592
|
|
|
2605
2593
|
// src/node/config/locators/actors/mempoolLocatorFromConfig.ts
|
|
2606
2594
|
import { ProviderFactoryLocator as ProviderFactoryLocator5 } from "@xyo-network/xl1-sdk";
|
|
2607
2595
|
function mempoolLocatorFromConfig(context, parent) {
|
|
2608
|
-
const locator = new ProviderFactoryLocator5({
|
|
2609
|
-
...context,
|
|
2610
|
-
locator: parent
|
|
2611
|
-
});
|
|
2596
|
+
const locator = new ProviderFactoryLocator5({ ...context, locator: parent });
|
|
2612
2597
|
locator.registerMany([]);
|
|
2613
2598
|
locator.freeze();
|
|
2614
2599
|
return locator;
|
|
2615
2600
|
}
|
|
2616
|
-
__name(mempoolLocatorFromConfig, "mempoolLocatorFromConfig");
|
|
2617
2601
|
|
|
2618
2602
|
// src/node/config/locators/actors/producerLocatorFromConfig.ts
|
|
2619
2603
|
import { asAddress } from "@xylabs/sdk-js";
|
|
@@ -2622,57 +2606,72 @@ import { ProviderFactoryLocator as ProviderFactoryLocator6 } from "@xyo-network/
|
|
|
2622
2606
|
async function producerLocatorFromConfig(context, parent) {
|
|
2623
2607
|
const { logger, config } = context;
|
|
2624
2608
|
const account = await initActorWallet(context);
|
|
2625
|
-
const locator = new ProviderFactoryLocator6({
|
|
2626
|
-
...context,
|
|
2627
|
-
locator: parent
|
|
2628
|
-
});
|
|
2609
|
+
const locator = new ProviderFactoryLocator6({ ...context, locator: parent });
|
|
2629
2610
|
const rewardAddress = asAddress(config.rewardAddress ?? account.address, true);
|
|
2630
2611
|
logger?.info(`Using reward address ${rewardAddress}`);
|
|
2631
2612
|
if (rewardAddress === account.address) {
|
|
2632
2613
|
logger?.warn(`Using producer account address as reward address: ${account.address}`);
|
|
2633
2614
|
}
|
|
2634
|
-
const rejectedTransactionsProvider = await parent?.tryGetInstance(
|
|
2615
|
+
const rejectedTransactionsProvider = await parent?.tryGetInstance(
|
|
2616
|
+
RejectedTransactionsArchivistProviderMoniker
|
|
2617
|
+
);
|
|
2635
2618
|
const rejectedTransactionsArchivist = rejectedTransactionsProvider?.archivist;
|
|
2636
2619
|
locator.registerMany([
|
|
2637
|
-
SimpleBlockRunner.factory(
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2620
|
+
SimpleBlockRunner.factory(
|
|
2621
|
+
SimpleBlockRunner.dependencies,
|
|
2622
|
+
{
|
|
2623
|
+
account,
|
|
2624
|
+
rewardAddress,
|
|
2625
|
+
rejectedTransactionsArchivist,
|
|
2626
|
+
// ProducerConfigZod has always exposed `heartbeatInterval`, but until now
|
|
2627
|
+
// it was not wired anywhere. Threading it into the BlockRunner lets tests
|
|
2628
|
+
// (and operators who want denser heartbeat blocks) override the 1-h default.
|
|
2629
|
+
heartbeatInterval: config.heartbeatInterval
|
|
2630
|
+
}
|
|
2631
|
+
)
|
|
2646
2632
|
]);
|
|
2647
2633
|
locator.freeze();
|
|
2648
2634
|
return locator;
|
|
2649
2635
|
}
|
|
2650
|
-
__name(producerLocatorFromConfig, "producerLocatorFromConfig");
|
|
2651
2636
|
|
|
2652
2637
|
// src/node/config/locators/actors/rewardRedemptionLocatorFromConfig.ts
|
|
2653
|
-
import {
|
|
2638
|
+
import {
|
|
2639
|
+
JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer4,
|
|
2640
|
+
JsonRpcBlockViewer as JsonRpcBlockViewer2,
|
|
2641
|
+
JsonRpcFinalizationViewer as JsonRpcFinalizationViewer2,
|
|
2642
|
+
JsonRpcMempoolRunner as JsonRpcMempoolRunner2,
|
|
2643
|
+
JsonRpcMempoolViewer as JsonRpcMempoolViewer2,
|
|
2644
|
+
JsonRpcXyoRunner as JsonRpcXyoRunner2,
|
|
2645
|
+
JsonRpcXyoViewer as JsonRpcXyoViewer2,
|
|
2646
|
+
ProviderFactoryLocator as ProviderFactoryLocator7,
|
|
2647
|
+
SimpleXyoConnectionRunner as SimpleXyoConnectionRunner3,
|
|
2648
|
+
SimpleXyoGatewayRunner as SimpleXyoGatewayRunner2,
|
|
2649
|
+
SimpleXyoRunner as SimpleXyoRunner3,
|
|
2650
|
+
SimpleXyoSigner as SimpleXyoSigner3
|
|
2651
|
+
} from "@xyo-network/xl1-sdk";
|
|
2654
2652
|
async function rewardRedemptionLocatorFromConfig(context, parent) {
|
|
2655
|
-
const locator = new ProviderFactoryLocator7({
|
|
2656
|
-
...context,
|
|
2657
|
-
locator: parent
|
|
2658
|
-
});
|
|
2653
|
+
const locator = new ProviderFactoryLocator7({ ...context, locator: parent });
|
|
2659
2654
|
const { config } = context;
|
|
2660
2655
|
const account = await initActorWallet(context);
|
|
2661
2656
|
if (config.remote.rpc) {
|
|
2662
2657
|
locator.registerMany([
|
|
2663
2658
|
JsonRpcMempoolViewer2.factory(JsonRpcMempoolViewer2.dependencies, {}),
|
|
2664
2659
|
JsonRpcMempoolRunner2.factory(JsonRpcMempoolRunner2.dependencies, {}),
|
|
2665
|
-
JsonRpcAccountBalanceViewer4.factory(
|
|
2666
|
-
|
|
2660
|
+
JsonRpcAccountBalanceViewer4.factory(
|
|
2661
|
+
JsonRpcAccountBalanceViewer4.dependencies,
|
|
2662
|
+
{}
|
|
2663
|
+
),
|
|
2664
|
+
JsonRpcFinalizationViewer2.factory(
|
|
2665
|
+
JsonRpcFinalizationViewer2.dependencies,
|
|
2666
|
+
{}
|
|
2667
|
+
),
|
|
2667
2668
|
JsonRpcBlockViewer2.factory(JsonRpcBlockViewer2.dependencies, {}),
|
|
2668
2669
|
JsonRpcXyoRunner2.factory(JsonRpcXyoRunner2.dependencies, {}),
|
|
2669
2670
|
JsonRpcXyoViewer2.factory(JsonRpcXyoViewer2.dependencies, {})
|
|
2670
2671
|
]);
|
|
2671
2672
|
}
|
|
2672
2673
|
locator.registerMany([
|
|
2673
|
-
SimpleXyoSigner3.factory(SimpleXyoSigner3.dependencies, {
|
|
2674
|
-
account
|
|
2675
|
-
}),
|
|
2674
|
+
SimpleXyoSigner3.factory(SimpleXyoSigner3.dependencies, { account }),
|
|
2676
2675
|
SimpleXyoRunner3.factory(SimpleXyoRunner3.dependencies, {}),
|
|
2677
2676
|
SimpleXyoConnectionRunner3.factory(SimpleXyoConnectionRunner3.dependencies, {}),
|
|
2678
2677
|
SimpleXyoGatewayRunner2.factory(SimpleXyoGatewayRunner2.dependencies, {})
|
|
@@ -2680,30 +2679,47 @@ async function rewardRedemptionLocatorFromConfig(context, parent) {
|
|
|
2680
2679
|
locator.freeze();
|
|
2681
2680
|
return locator;
|
|
2682
2681
|
}
|
|
2683
|
-
__name(rewardRedemptionLocatorFromConfig, "rewardRedemptionLocatorFromConfig");
|
|
2684
2682
|
|
|
2685
2683
|
// src/node/config/locators/rootLocatorFromConfig.ts
|
|
2686
2684
|
import { commonLocatorFromConfig, remoteLocatorFromConfig } from "@xyo-network/xl1-sdk";
|
|
2687
2685
|
async function rootLocatorFromConfig(context, validateDepsOnRegister = false, onInsecureGenesisConfirm) {
|
|
2688
2686
|
const { config } = context;
|
|
2689
2687
|
let locator = await commonLocatorFromConfig(context, validateDepsOnRegister);
|
|
2690
|
-
const newLocator = await (config.remote.rpc ? remoteLocatorFromConfig(locator.context, validateDepsOnRegister) : localLocatorFromConfig(
|
|
2691
|
-
...locator.context,
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
}
|
|
2696
|
-
}, validateDepsOnRegister, onInsecureGenesisConfirm));
|
|
2688
|
+
const newLocator = await (config.remote.rpc ? remoteLocatorFromConfig(locator.context, validateDepsOnRegister) : localLocatorFromConfig(
|
|
2689
|
+
{ ...locator.context, config: { ...locator.context.config, ...context.config } },
|
|
2690
|
+
validateDepsOnRegister,
|
|
2691
|
+
onInsecureGenesisConfirm
|
|
2692
|
+
));
|
|
2697
2693
|
locator = newLocator;
|
|
2698
2694
|
locator = await initEvmProvidersIfAvailable(locator);
|
|
2699
2695
|
locator.freeze();
|
|
2700
2696
|
return locator;
|
|
2701
2697
|
}
|
|
2702
|
-
__name(rootLocatorFromConfig, "rootLocatorFromConfig");
|
|
2703
2698
|
|
|
2704
2699
|
// src/node/config/locators/sharedLocatorFromConfig.ts
|
|
2705
2700
|
import { deepMerge as deepMerge2 } from "@xylabs/sdk-js";
|
|
2706
|
-
import {
|
|
2701
|
+
import {
|
|
2702
|
+
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker4,
|
|
2703
|
+
BlockValidationViewerMoniker as BlockValidationViewerMoniker3,
|
|
2704
|
+
BlockViewerMoniker as BlockViewerMoniker4,
|
|
2705
|
+
commonLocatorFromConfig as commonLocatorFromConfig2,
|
|
2706
|
+
DeadLetterQueueRunnerMoniker as DeadLetterQueueRunnerMoniker3,
|
|
2707
|
+
FinalizationRunnerMoniker as FinalizationRunnerMoniker3,
|
|
2708
|
+
FinalizationViewerMoniker as FinalizationViewerMoniker4,
|
|
2709
|
+
MempoolRunnerMoniker as MempoolRunnerMoniker3,
|
|
2710
|
+
MempoolViewerMoniker as MempoolViewerMoniker4,
|
|
2711
|
+
ProviderFactoryLocator as ProviderFactoryLocator8,
|
|
2712
|
+
SimpleXyoConnectionRunner as SimpleXyoConnectionRunner4,
|
|
2713
|
+
SimpleXyoGateway as SimpleXyoGateway2,
|
|
2714
|
+
SimpleXyoRunner as SimpleXyoRunner4,
|
|
2715
|
+
TransactionValidationViewerMoniker as TransactionValidationViewerMoniker3,
|
|
2716
|
+
TransactionViewerMoniker as TransactionViewerMoniker4,
|
|
2717
|
+
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker3,
|
|
2718
|
+
XyoConnectionMoniker as XyoConnectionMoniker4,
|
|
2719
|
+
XyoGatewayMoniker,
|
|
2720
|
+
XyoRunnerMoniker,
|
|
2721
|
+
XyoViewerMoniker as XyoViewerMoniker4
|
|
2722
|
+
} from "@xyo-network/xl1-sdk";
|
|
2707
2723
|
var apiNeeds = {
|
|
2708
2724
|
required: [
|
|
2709
2725
|
AccountBalanceViewerMoniker4,
|
|
@@ -2735,9 +2751,7 @@ var finalizerNeeds = {
|
|
|
2735
2751
|
FinalizationRunnerMoniker3,
|
|
2736
2752
|
MempoolViewerMoniker4
|
|
2737
2753
|
],
|
|
2738
|
-
optional: [
|
|
2739
|
-
DeadLetterQueueRunnerMoniker3
|
|
2740
|
-
]
|
|
2754
|
+
optional: [DeadLetterQueueRunnerMoniker3]
|
|
2741
2755
|
};
|
|
2742
2756
|
var ACTOR_MIRRORS = {
|
|
2743
2757
|
api: apiNeeds,
|
|
@@ -2747,54 +2761,42 @@ var ACTOR_MIRRORS = {
|
|
|
2747
2761
|
var apiExtraDescriptors = [
|
|
2748
2762
|
{
|
|
2749
2763
|
id: "SimpleXyoRunner",
|
|
2750
|
-
satisfies: [
|
|
2751
|
-
XyoRunnerMoniker
|
|
2752
|
-
],
|
|
2764
|
+
satisfies: [XyoRunnerMoniker],
|
|
2753
2765
|
tier: 1,
|
|
2754
2766
|
backings: [],
|
|
2755
2767
|
surface: "node",
|
|
2756
|
-
preconditions:
|
|
2757
|
-
build:
|
|
2768
|
+
preconditions: () => true,
|
|
2769
|
+
build: () => SimpleXyoRunner4.factory(SimpleXyoRunner4.dependencies, {})
|
|
2758
2770
|
},
|
|
2759
2771
|
{
|
|
2760
2772
|
id: "SimpleXyoConnectionRunner",
|
|
2761
|
-
satisfies: [
|
|
2762
|
-
XyoConnectionMoniker4
|
|
2763
|
-
],
|
|
2773
|
+
satisfies: [XyoConnectionMoniker4],
|
|
2764
2774
|
// Same tier as `SimpleXyoConnectionViewer`; higher priority wins the
|
|
2765
2775
|
// `XyoConnection` moniker in any actor mix that includes the API.
|
|
2766
2776
|
tier: 1,
|
|
2767
2777
|
priority: 100,
|
|
2768
2778
|
backings: [],
|
|
2769
2779
|
surface: "node",
|
|
2770
|
-
preconditions:
|
|
2771
|
-
build:
|
|
2780
|
+
preconditions: () => true,
|
|
2781
|
+
build: () => SimpleXyoConnectionRunner4.factory(SimpleXyoConnectionRunner4.dependencies, {})
|
|
2772
2782
|
},
|
|
2773
2783
|
{
|
|
2774
2784
|
id: "SimpleXyoGateway",
|
|
2775
|
-
satisfies: [
|
|
2776
|
-
XyoGatewayMoniker
|
|
2777
|
-
],
|
|
2785
|
+
satisfies: [XyoGatewayMoniker],
|
|
2778
2786
|
tier: 1,
|
|
2779
2787
|
backings: [],
|
|
2780
2788
|
surface: "node",
|
|
2781
|
-
preconditions:
|
|
2782
|
-
build:
|
|
2789
|
+
preconditions: () => true,
|
|
2790
|
+
build: () => SimpleXyoGateway2.factory(SimpleXyoGateway2.dependencies, {})
|
|
2783
2791
|
}
|
|
2784
2792
|
];
|
|
2785
|
-
var ACTOR_EXTRA_DESCRIPTORS = {
|
|
2786
|
-
api: apiExtraDescriptors
|
|
2787
|
-
};
|
|
2793
|
+
var ACTOR_EXTRA_DESCRIPTORS = { api: apiExtraDescriptors };
|
|
2788
2794
|
var ACTOR_CONFIG_PARSERS = {
|
|
2789
2795
|
api: ApiConfigZod,
|
|
2790
2796
|
mempool: MempoolConfigZod,
|
|
2791
2797
|
finalizer: FinalizerConfigZod
|
|
2792
2798
|
};
|
|
2793
|
-
var SHARED_LOCATOR_SUPPORTED_ACTORS = [
|
|
2794
|
-
"api",
|
|
2795
|
-
"mempool",
|
|
2796
|
-
"finalizer"
|
|
2797
|
-
];
|
|
2799
|
+
var SHARED_LOCATOR_SUPPORTED_ACTORS = ["api", "mempool", "finalizer"];
|
|
2798
2800
|
function canUseSharedLocator(actors, config) {
|
|
2799
2801
|
if (actors.length === 0) return false;
|
|
2800
2802
|
if (config.remote?.rpc) return false;
|
|
@@ -2810,31 +2812,19 @@ function canUseSharedLocator(actors, config) {
|
|
|
2810
2812
|
return true;
|
|
2811
2813
|
});
|
|
2812
2814
|
}
|
|
2813
|
-
__name(canUseSharedLocator, "canUseSharedLocator");
|
|
2814
2815
|
async function sharedLocatorFromConfig(context, actors, config, options = {}) {
|
|
2815
2816
|
const unionNeeds2 = {
|
|
2816
2817
|
required: dedupe(actors.flatMap((a) => ACTOR_MIRRORS[a.name]?.required ?? [])),
|
|
2817
2818
|
optional: dedupe(actors.flatMap((a) => ACTOR_MIRRORS[a.name]?.optional ?? []))
|
|
2818
2819
|
};
|
|
2819
2820
|
const extraDescriptors = actors.flatMap((a) => ACTOR_EXTRA_DESCRIPTORS[a.name] ?? []);
|
|
2820
|
-
const commonContext = {
|
|
2821
|
-
...context,
|
|
2822
|
-
config: {
|
|
2823
|
-
...config,
|
|
2824
|
-
name: "_shared_common"
|
|
2825
|
-
}
|
|
2826
|
-
};
|
|
2821
|
+
const commonContext = { ...context, config: { ...config, name: "_shared_common" } };
|
|
2827
2822
|
const commonLocator = await commonLocatorFromConfig2(commonContext);
|
|
2828
2823
|
const sharedContext = {
|
|
2829
2824
|
...commonLocator.context,
|
|
2830
|
-
config: {
|
|
2831
|
-
...config,
|
|
2832
|
-
name: "_shared"
|
|
2833
|
-
}
|
|
2825
|
+
config: { ...config, name: "_shared" }
|
|
2834
2826
|
};
|
|
2835
|
-
const result = await locatorFromActorNeeds(sharedContext, [
|
|
2836
|
-
unionNeeds2
|
|
2837
|
-
], {
|
|
2827
|
+
const result = await locatorFromActorNeeds(sharedContext, [unionNeeds2], {
|
|
2838
2828
|
extraDescriptors,
|
|
2839
2829
|
onInsecureGenesisConfirm: options.onInsecureGenesisConfirm,
|
|
2840
2830
|
validateDepsOnRegister: false
|
|
@@ -2853,18 +2843,11 @@ async function sharedLocatorFromConfig(context, actors, config, options = {}) {
|
|
|
2853
2843
|
view.freeze();
|
|
2854
2844
|
perActor[actor.name] = view;
|
|
2855
2845
|
}
|
|
2856
|
-
return {
|
|
2857
|
-
shared: sharedWithEvm,
|
|
2858
|
-
perActor
|
|
2859
|
-
};
|
|
2846
|
+
return { shared: sharedWithEvm, perActor };
|
|
2860
2847
|
}
|
|
2861
|
-
__name(sharedLocatorFromConfig, "sharedLocatorFromConfig");
|
|
2862
2848
|
function dedupe(items) {
|
|
2863
|
-
return [
|
|
2864
|
-
...new Set(items)
|
|
2865
|
-
];
|
|
2849
|
+
return [...new Set(items)];
|
|
2866
2850
|
}
|
|
2867
|
-
__name(dedupe, "dedupe");
|
|
2868
2851
|
|
|
2869
2852
|
// src/node/config/locators/locatorsFromConfig.ts
|
|
2870
2853
|
function allActorsAreSelfSufficient(actors, config) {
|
|
@@ -2875,104 +2858,98 @@ function allActorsAreSelfSufficient(actors, config) {
|
|
|
2875
2858
|
return merged.stateless === true;
|
|
2876
2859
|
});
|
|
2877
2860
|
}
|
|
2878
|
-
__name(allActorsAreSelfSufficient, "allActorsAreSelfSufficient");
|
|
2879
2861
|
async function locatorsFromConfig(context, { actors, ...config }, onInsecureGenesisConfirm) {
|
|
2880
2862
|
const result = {};
|
|
2881
2863
|
if (canUseSharedLocator(actors, config)) {
|
|
2882
|
-
const { perActor } = await sharedLocatorFromConfig(context, actors, config, {
|
|
2883
|
-
onInsecureGenesisConfirm
|
|
2884
|
-
});
|
|
2864
|
+
const { perActor } = await sharedLocatorFromConfig(context, actors, config, { onInsecureGenesisConfirm });
|
|
2885
2865
|
return perActor;
|
|
2886
2866
|
}
|
|
2887
2867
|
const skipRoot = allActorsAreSelfSufficient(actors, config);
|
|
2888
2868
|
if (!skipRoot) {
|
|
2889
|
-
const rootContext = {
|
|
2890
|
-
...context,
|
|
2891
|
-
config: {
|
|
2892
|
-
...config,
|
|
2893
|
-
name: "_root"
|
|
2894
|
-
}
|
|
2895
|
-
};
|
|
2869
|
+
const rootContext = { ...context, config: { ...config, name: "_root" } };
|
|
2896
2870
|
result._root = await rootLocatorFromConfig(rootContext, false, onInsecureGenesisConfirm);
|
|
2897
2871
|
}
|
|
2898
2872
|
for (const actorConfig of actors) {
|
|
2899
2873
|
switch (actorConfig.name) {
|
|
2900
2874
|
case "producer": {
|
|
2901
|
-
result[actorConfig.name] = await producerLocatorFromConfig(
|
|
2902
|
-
...context,
|
|
2903
|
-
|
|
2904
|
-
|
|
2875
|
+
result[actorConfig.name] = await producerLocatorFromConfig(
|
|
2876
|
+
{ ...context, config: ProducerConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2877
|
+
result._root
|
|
2878
|
+
);
|
|
2905
2879
|
break;
|
|
2906
2880
|
}
|
|
2907
2881
|
case "api": {
|
|
2908
|
-
result[actorConfig.name] = await apiLocatorFromConfig(
|
|
2909
|
-
...context,
|
|
2910
|
-
|
|
2911
|
-
|
|
2882
|
+
result[actorConfig.name] = await apiLocatorFromConfig(
|
|
2883
|
+
{ ...context, config: ApiConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2884
|
+
result._root
|
|
2885
|
+
);
|
|
2912
2886
|
break;
|
|
2913
2887
|
}
|
|
2914
2888
|
case "mempool": {
|
|
2915
|
-
result[actorConfig.name] = await mempoolLocatorFromConfig(
|
|
2916
|
-
...context,
|
|
2917
|
-
|
|
2918
|
-
|
|
2889
|
+
result[actorConfig.name] = await mempoolLocatorFromConfig(
|
|
2890
|
+
{ ...context, config: MempoolConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2891
|
+
result._root
|
|
2892
|
+
);
|
|
2919
2893
|
break;
|
|
2920
2894
|
}
|
|
2921
2895
|
case "finalizer": {
|
|
2922
|
-
result[actorConfig.name] = await finalizerLocatorFromConfig(
|
|
2923
|
-
...context,
|
|
2924
|
-
|
|
2925
|
-
|
|
2896
|
+
result[actorConfig.name] = await finalizerLocatorFromConfig(
|
|
2897
|
+
{ ...context, config: FinalizerConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2898
|
+
result._root
|
|
2899
|
+
);
|
|
2926
2900
|
break;
|
|
2927
2901
|
}
|
|
2928
2902
|
case "bridge": {
|
|
2929
|
-
result[actorConfig.name] = await bridgeLocatorFromConfig(
|
|
2930
|
-
...context,
|
|
2931
|
-
|
|
2932
|
-
|
|
2903
|
+
result[actorConfig.name] = await bridgeLocatorFromConfig(
|
|
2904
|
+
{ ...context, config: BridgeConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2905
|
+
result._root
|
|
2906
|
+
);
|
|
2933
2907
|
break;
|
|
2934
2908
|
}
|
|
2935
2909
|
case "rewardRedemption": {
|
|
2936
|
-
result[actorConfig.name] = await rewardRedemptionLocatorFromConfig(
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2910
|
+
result[actorConfig.name] = await rewardRedemptionLocatorFromConfig(
|
|
2911
|
+
{
|
|
2912
|
+
...context,
|
|
2913
|
+
config: RewardRedemptionConfigZod.parse(deepMerge3(config, actorConfig))
|
|
2914
|
+
},
|
|
2915
|
+
result._root
|
|
2916
|
+
);
|
|
2940
2917
|
break;
|
|
2941
2918
|
}
|
|
2942
2919
|
}
|
|
2943
2920
|
}
|
|
2944
2921
|
return result;
|
|
2945
2922
|
}
|
|
2946
|
-
__name(locatorsFromConfig, "locatorsFromConfig");
|
|
2947
2923
|
|
|
2948
2924
|
// src/node/config/tryParseConfig.ts
|
|
2949
2925
|
import { isDefined as isDefined4, isNull } from "@xylabs/sdk-js";
|
|
2950
2926
|
import { ConfigZod } from "@xyo-network/xl1-sdk";
|
|
2951
2927
|
import { cosmiconfig } from "cosmiconfig";
|
|
2928
|
+
import { z as z8 } from "zod/mini";
|
|
2952
2929
|
var configName = "xyo";
|
|
2953
2930
|
var configSection = "xl1";
|
|
2954
2931
|
var ConfigFileNotFoundError = class extends Error {
|
|
2955
|
-
static {
|
|
2956
|
-
__name(this, "ConfigFileNotFoundError");
|
|
2957
|
-
}
|
|
2958
2932
|
constructor(configPath) {
|
|
2959
2933
|
super(`Config file not found: ${configPath}`);
|
|
2960
2934
|
this.name = "ConfigFileNotFoundError";
|
|
2961
2935
|
}
|
|
2962
2936
|
};
|
|
2963
|
-
var isMissingFileError =
|
|
2937
|
+
var isMissingFileError = (error) => {
|
|
2964
2938
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
2965
|
-
}
|
|
2966
|
-
var isRecord =
|
|
2939
|
+
};
|
|
2940
|
+
var isRecord = (value) => {
|
|
2967
2941
|
return typeof value === "object" && value !== null;
|
|
2968
|
-
}
|
|
2942
|
+
};
|
|
2969
2943
|
async function tryParseConfig(options) {
|
|
2970
2944
|
const { configPath, searchPlaces } = options ?? {};
|
|
2971
|
-
const explorer = cosmiconfig(
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2945
|
+
const explorer = cosmiconfig(
|
|
2946
|
+
configName,
|
|
2947
|
+
{
|
|
2948
|
+
cache: true,
|
|
2949
|
+
// loaders: { '.ts': TypeScriptLoader() },
|
|
2950
|
+
searchPlaces
|
|
2951
|
+
}
|
|
2952
|
+
);
|
|
2976
2953
|
let result;
|
|
2977
2954
|
if (isDefined4(configPath)) {
|
|
2978
2955
|
try {
|
|
@@ -2992,16 +2969,12 @@ async function tryParseConfig(options) {
|
|
|
2992
2969
|
if (isRecord(result)) {
|
|
2993
2970
|
const section = result[configSection];
|
|
2994
2971
|
if (isRecord(section)) {
|
|
2995
|
-
const parsed = ConfigZod.
|
|
2996
|
-
return typeof section.mnemonic === "string" ? {
|
|
2997
|
-
...parsed,
|
|
2998
|
-
mnemonic: section.mnemonic
|
|
2999
|
-
} : parsed;
|
|
2972
|
+
const parsed = z8.looseObject(ConfigZod.shape).parse(section);
|
|
2973
|
+
return typeof section.mnemonic === "string" ? { ...parsed, mnemonic: section.mnemonic } : parsed;
|
|
3000
2974
|
}
|
|
3001
2975
|
}
|
|
3002
2976
|
return ConfigZod.parse({});
|
|
3003
2977
|
}
|
|
3004
|
-
__name(tryParseConfig, "tryParseConfig");
|
|
3005
2978
|
|
|
3006
2979
|
// src/node/index.ts
|
|
3007
2980
|
export * from "@xyo-network/chain-orchestration-evm";
|
|
@@ -3143,4 +3116,4 @@ export {
|
|
|
3143
3116
|
tryParseConfig,
|
|
3144
3117
|
unmetBackings
|
|
3145
3118
|
};
|
|
3146
|
-
//# sourceMappingURL=index.mjs.map
|
|
3119
|
+
//# sourceMappingURL=index.mjs.map
|