@xyo-network/chain-orchestration 1.23.0 → 1.23.2
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 +239 -324
- package/dist/browser/index.mjs.map +7 -1
- package/dist/neutral/index.mjs +239 -324
- package/dist/neutral/index.mjs.map +7 -1
- package/dist/node/index.mjs +784 -831
- package/dist/node/index.mjs.map +7 -1
- package/package.json +24 -24
package/dist/node/index.mjs
CHANGED
|
@@ -1,29 +1,40 @@
|
|
|
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
22
|
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
|
-
};
|
|
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(),
|
|
@@ -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,70 +241,61 @@ 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
258
|
import { globalRegistry, z as z2 } from "zod";
|
|
267
259
|
var ApiConfigZod = HostActorConfigZod.extend(z2.object({
|
|
268
|
-
initRewardsCache: z2.union([
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
z2.boolean()
|
|
272
|
-
]).transform((v) => v !== "0" && v !== "false" && v !== false && v != 0).default(true).register(globalRegistry, {
|
|
260
|
+
initRewardsCache: z2.union([z2.number(), z2.string(), z2.boolean()]).transform(
|
|
261
|
+
(v) => v !== "0" && v !== "false" && v !== false && v != 0
|
|
262
|
+
).default(true).register(globalRegistry, {
|
|
273
263
|
description: "Whether to initialize the rewards cache on startup",
|
|
274
264
|
title: "api.initRewardsCache",
|
|
275
265
|
type: "boolean"
|
|
276
266
|
}),
|
|
277
267
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
stateless: z2.union([
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
z2.boolean()
|
|
289
|
-
]).transform((v) => v === "1" || v === "true" || v === true || v == 1).default(false).register(globalRegistry, {
|
|
268
|
+
* When `true`, the API actor runs in stateless mode: it holds no local
|
|
269
|
+
* backing-store ownership, never loads the local LMDB/MongoDB node, and
|
|
270
|
+
* federates every JSON-RPC request to upstream owner-actors via `JsonRpc*`
|
|
271
|
+
* providers. Multiple stateless API instances can run behind a load
|
|
272
|
+
* balancer for horizontal scaling. Requires `remote.rpc` to point at the
|
|
273
|
+
* upstream API/Finalizer/Mempool/Indexer surfaces.
|
|
274
|
+
*/
|
|
275
|
+
stateless: z2.union([z2.number(), z2.string(), z2.boolean()]).transform(
|
|
276
|
+
(v) => v === "1" || v === "true" || v === true || v == 1
|
|
277
|
+
).default(false).register(globalRegistry, {
|
|
290
278
|
description: "Run the API actor as a stateless federation node (availableBackings: [network])",
|
|
291
279
|
title: "api.stateless",
|
|
292
280
|
type: "boolean"
|
|
293
281
|
}),
|
|
294
282
|
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
legacyMixedRpc: z2.union([
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
z2.boolean()
|
|
312
|
-
]).transform((v) => v !== "0" && v !== "false" && v !== false && v != 0).default(true).register(globalRegistry, {
|
|
283
|
+
* Back-compat for the surface-aware route split. When `true`, `POST /rpc`
|
|
284
|
+
* serves the full `XyoConnection` (both node-surface and indexed-surface
|
|
285
|
+
* methods), preserving pre-Phase-7 behavior for clients that haven't yet
|
|
286
|
+
* migrated to `POST /rpc/indexed`. When `false`, `/rpc` is strictly
|
|
287
|
+
* node-surface only and indexed methods are 404 at `/rpc`.
|
|
288
|
+
*
|
|
289
|
+
* `/rpc/indexed` mounts independently of this flag whenever the locator's
|
|
290
|
+
* connection has any indexed branch.
|
|
291
|
+
*
|
|
292
|
+
* Default `true` for the first release that includes Phase 7 — flip to
|
|
293
|
+
* `false` per environment once external clients (explorers, wallets, dApps)
|
|
294
|
+
* have moved their indexed-method calls to `/rpc/indexed`.
|
|
295
|
+
*/
|
|
296
|
+
legacyMixedRpc: z2.union([z2.number(), z2.string(), z2.boolean()]).transform(
|
|
297
|
+
(v) => v !== "0" && v !== "false" && v !== false && v != 0
|
|
298
|
+
).default(true).register(globalRegistry, {
|
|
313
299
|
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
300
|
title: "api.legacyMixedRpc",
|
|
315
301
|
type: "boolean"
|
|
@@ -318,16 +304,27 @@ var ApiConfigZod = HostActorConfigZod.extend(z2.object({
|
|
|
318
304
|
var isApiConfig = zodIsFactory(ApiConfigZod);
|
|
319
305
|
var asApiConfig = zodAsFactory(ApiConfigZod, "asApiConfig");
|
|
320
306
|
var toApiConfig = zodToFactory(ApiConfigZod, "toApiConfig");
|
|
321
|
-
var ApiConfigContext = BaseConfigContextZod.extend({
|
|
322
|
-
config: ApiConfigZod
|
|
323
|
-
});
|
|
307
|
+
var ApiConfigContext = BaseConfigContextZod.extend({ config: ApiConfigZod });
|
|
324
308
|
var isApiConfigContext = zodIsFactory(ApiConfigContext);
|
|
325
309
|
var asApiConfigContext = zodAsFactory(ApiConfigContext, "asApiConfigContext");
|
|
326
310
|
var toApiConfigContext = zodToFactory(ApiConfigContext, "toApiConfigContext");
|
|
327
311
|
|
|
328
312
|
// src/shared/config/actors/Bridge.ts
|
|
329
|
-
import {
|
|
330
|
-
|
|
313
|
+
import {
|
|
314
|
+
AddressZod,
|
|
315
|
+
HexZod,
|
|
316
|
+
toAddress,
|
|
317
|
+
toHex,
|
|
318
|
+
zodAsFactory as zodAsFactory2,
|
|
319
|
+
zodIsFactory as zodIsFactory2,
|
|
320
|
+
zodToFactory as zodToFactory2
|
|
321
|
+
} from "@xylabs/sdk-js";
|
|
322
|
+
import {
|
|
323
|
+
AttoXL1ConvertFactor,
|
|
324
|
+
BaseConfigContextZod as BaseConfigContextZod2,
|
|
325
|
+
HostActorConfigZod as HostActorConfigZod2,
|
|
326
|
+
XL1
|
|
327
|
+
} from "@xyo-network/xl1-sdk";
|
|
331
328
|
import { globalRegistry as globalRegistry2, z as z3 } from "zod";
|
|
332
329
|
var DEFAULT_FIXED_FEE = toHex(XL1(1000n) * AttoXL1ConvertFactor.xl1);
|
|
333
330
|
var DEFAULT_VARIABLE_FEE_BASIS_POINTS = 300;
|
|
@@ -449,16 +446,23 @@ var BridgeSettingsZod = BridgeConfigZod.pick({
|
|
|
449
446
|
var isBridgeConfig = zodIsFactory2(BridgeConfigZod);
|
|
450
447
|
var asBridgeConfig = zodAsFactory2(BridgeConfigZod, "asBridgeConfig");
|
|
451
448
|
var toBridgeConfig = zodToFactory2(BridgeConfigZod, "toBridgeConfig");
|
|
452
|
-
var BridgeConfigContext = BaseConfigContextZod2.extend({
|
|
453
|
-
config: BridgeConfigZod
|
|
454
|
-
});
|
|
449
|
+
var BridgeConfigContext = BaseConfigContextZod2.extend({ config: BridgeConfigZod });
|
|
455
450
|
var isBridgeConfigContext = zodIsFactory2(BridgeConfigContext);
|
|
456
451
|
var asBridgeConfigContext = zodAsFactory2(BridgeConfigContext, "asBridgeConfigContext");
|
|
457
452
|
var toBridgeConfigContext = zodToFactory2(BridgeConfigContext, "toBridgeConfigContext");
|
|
458
453
|
|
|
459
454
|
// src/shared/config/actors/Finalizer.ts
|
|
460
|
-
import {
|
|
461
|
-
|
|
455
|
+
import {
|
|
456
|
+
AddressZod as AddressZod2,
|
|
457
|
+
zodAsFactory as zodAsFactory3,
|
|
458
|
+
zodIsFactory as zodIsFactory3,
|
|
459
|
+
zodToFactory as zodToFactory3
|
|
460
|
+
} from "@xylabs/sdk-js";
|
|
461
|
+
import {
|
|
462
|
+
BaseConfigContextZod as BaseConfigContextZod3,
|
|
463
|
+
DEFAULT_MIN_CANDIDATES,
|
|
464
|
+
HostActorConfigZod as HostActorConfigZod3
|
|
465
|
+
} from "@xyo-network/xl1-sdk";
|
|
462
466
|
import { z as z4 } from "zod";
|
|
463
467
|
var FinalizerConfigZod = HostActorConfigZod3.extend({
|
|
464
468
|
allowedProducers: z4.array(AddressZod2).optional(),
|
|
@@ -471,15 +475,17 @@ var FinalizerConfigZod = HostActorConfigZod3.extend({
|
|
|
471
475
|
var isFinalizerConfig = zodIsFactory3(FinalizerConfigZod);
|
|
472
476
|
var asFinalizerConfig = zodAsFactory3(FinalizerConfigZod, "asFinalizerConfig");
|
|
473
477
|
var toFinalizerConfig = zodToFactory3(FinalizerConfigZod, "toFinalizerConfig");
|
|
474
|
-
var FinalizerConfigContext = BaseConfigContextZod3.extend({
|
|
475
|
-
config: FinalizerConfigZod
|
|
476
|
-
});
|
|
478
|
+
var FinalizerConfigContext = BaseConfigContextZod3.extend({ config: FinalizerConfigZod });
|
|
477
479
|
var isFinalizerConfigContext = zodIsFactory3(FinalizerConfigContext);
|
|
478
480
|
var asFinalizerConfigContext = zodAsFactory3(FinalizerConfigContext, "asFinalizerConfigContext");
|
|
479
481
|
var toFinalizerConfigContext = zodToFactory3(FinalizerConfigContext, "toFinalizerConfigContext");
|
|
480
482
|
|
|
481
483
|
// src/shared/config/actors/Mempool.ts
|
|
482
|
-
import {
|
|
484
|
+
import {
|
|
485
|
+
zodAsFactory as zodAsFactory4,
|
|
486
|
+
zodIsFactory as zodIsFactory4,
|
|
487
|
+
zodToFactory as zodToFactory4
|
|
488
|
+
} from "@xylabs/sdk-js";
|
|
483
489
|
import { BaseConfigContextZod as BaseConfigContextZod4, HostActorConfigZod as HostActorConfigZod4 } from "@xyo-network/xl1-sdk";
|
|
484
490
|
import { globalRegistry as globalRegistry3, z as z5 } from "zod";
|
|
485
491
|
var DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL = 1e3;
|
|
@@ -487,24 +493,11 @@ var DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL = 1e3;
|
|
|
487
493
|
var DEFAULT_MEMPOOL_DEMOTION_THRESHOLD = 3;
|
|
488
494
|
var DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS = 0;
|
|
489
495
|
var MempoolConfigZod = HostActorConfigZod4.extend({
|
|
490
|
-
enabled: z5.union([
|
|
491
|
-
z5.string(),
|
|
492
|
-
z5.boolean()
|
|
493
|
-
]).default("false").transform((val, ctx) => {
|
|
496
|
+
enabled: z5.union([z5.string(), z5.boolean()]).default("false").transform((val, ctx) => {
|
|
494
497
|
if (typeof val === "boolean") return val;
|
|
495
498
|
const normalized = val.toLowerCase().trim();
|
|
496
|
-
if ([
|
|
497
|
-
|
|
498
|
-
"1",
|
|
499
|
-
"yes",
|
|
500
|
-
"on"
|
|
501
|
-
].includes(normalized)) return true;
|
|
502
|
-
if ([
|
|
503
|
-
"false",
|
|
504
|
-
"0",
|
|
505
|
-
"no",
|
|
506
|
-
"off"
|
|
507
|
-
].includes(normalized)) return false;
|
|
499
|
+
if (["true", "1", "yes", "on"].includes(normalized)) return true;
|
|
500
|
+
if (["false", "0", "no", "off"].includes(normalized)) return false;
|
|
508
501
|
ctx.addIssue({
|
|
509
502
|
code: "invalid_type",
|
|
510
503
|
expected: "boolean",
|
|
@@ -541,15 +534,18 @@ var MempoolConfigZod = HostActorConfigZod4.extend({
|
|
|
541
534
|
var isMempoolConfig = zodIsFactory4(MempoolConfigZod);
|
|
542
535
|
var asMempoolConfig = zodAsFactory4(MempoolConfigZod, "asMempoolConfig");
|
|
543
536
|
var toMempoolConfig = zodToFactory4(MempoolConfigZod, "toMempoolConfig");
|
|
544
|
-
var MempoolConfigContext = BaseConfigContextZod4.extend({
|
|
545
|
-
config: MempoolConfigZod
|
|
546
|
-
});
|
|
537
|
+
var MempoolConfigContext = BaseConfigContextZod4.extend({ config: MempoolConfigZod });
|
|
547
538
|
var isMempoolConfigContext = zodIsFactory4(MempoolConfigContext);
|
|
548
539
|
var asMempoolConfigContext = zodAsFactory4(MempoolConfigContext, "asMempoolConfigContext");
|
|
549
540
|
var toMempoolConfigContext = zodToFactory4(MempoolConfigContext, "toMempoolConfigContext");
|
|
550
541
|
|
|
551
542
|
// src/shared/config/actors/Producer.ts
|
|
552
|
-
import {
|
|
543
|
+
import {
|
|
544
|
+
AddressZod as AddressZod3,
|
|
545
|
+
zodAsFactory as zodAsFactory5,
|
|
546
|
+
zodIsFactory as zodIsFactory5,
|
|
547
|
+
zodToFactory as zodToFactory5
|
|
548
|
+
} from "@xylabs/sdk-js";
|
|
553
549
|
import { ActorConfigZod, BaseConfigContextZod as BaseConfigContextZod5 } from "@xyo-network/xl1-sdk";
|
|
554
550
|
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
555
551
|
var DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL = 1e4;
|
|
@@ -590,23 +586,23 @@ var ProducerConfigZod = ActorConfigZod.extend(z6.object({
|
|
|
590
586
|
var isProducerConfig = zodIsFactory5(ProducerConfigZod);
|
|
591
587
|
var asProducerConfig = zodAsFactory5(ProducerConfigZod, "asProducerConfig");
|
|
592
588
|
var toProducerConfig = zodToFactory5(ProducerConfigZod, "toProducerConfig");
|
|
593
|
-
var ProducerConfigContext = BaseConfigContextZod5.extend({
|
|
594
|
-
config: ProducerConfigZod
|
|
595
|
-
});
|
|
589
|
+
var ProducerConfigContext = BaseConfigContextZod5.extend({ config: ProducerConfigZod });
|
|
596
590
|
var isProducerConfigContext = zodIsFactory5(ProducerConfigContext);
|
|
597
591
|
var asProducerConfigContext = zodAsFactory5(ProducerConfigContext, "asProducerConfigContext");
|
|
598
592
|
var toProducerConfigContext = zodToFactory5(ProducerConfigContext, "toProducerConfigContext");
|
|
599
593
|
|
|
600
594
|
// src/shared/config/actors/RewardRedemption.ts
|
|
601
|
-
import {
|
|
595
|
+
import {
|
|
596
|
+
zodAsFactory as zodAsFactory6,
|
|
597
|
+
zodIsFactory as zodIsFactory6,
|
|
598
|
+
zodToFactory as zodToFactory6
|
|
599
|
+
} from "@xylabs/sdk-js";
|
|
602
600
|
import { BaseConfigContextZod as BaseConfigContextZod6, HostActorConfigZod as HostActorConfigZod5 } from "@xyo-network/xl1-sdk";
|
|
603
601
|
var RewardRedemptionConfigZod = HostActorConfigZod5.extend({});
|
|
604
602
|
var isRewardRedemptionConfig = zodIsFactory6(RewardRedemptionConfigZod);
|
|
605
603
|
var asRewardRedemptionConfig = zodAsFactory6(RewardRedemptionConfigZod, "asRewardRedemptionConfig");
|
|
606
604
|
var toRewardRedemptionConfig = zodToFactory6(RewardRedemptionConfigZod, "toRewardRedemptionConfig");
|
|
607
|
-
var RewardRedemptionConfigContext = BaseConfigContextZod6.extend({
|
|
608
|
-
config: RewardRedemptionConfigZod
|
|
609
|
-
});
|
|
605
|
+
var RewardRedemptionConfigContext = BaseConfigContextZod6.extend({ config: RewardRedemptionConfigZod });
|
|
610
606
|
var isRewardRedemptionConfigContext = zodIsFactory6(RewardRedemptionConfigContext);
|
|
611
607
|
var asRewardRedemptionConfigContext = zodAsFactory6(RewardRedemptionConfigContext, "asRewardRedemptionConfigContext");
|
|
612
608
|
var toRewardRedemptionConfigContext = zodToFactory6(RewardRedemptionConfigContext, "toRewardRedemptionConfigContext");
|
|
@@ -621,26 +617,27 @@ function mergeConfig({ actors, ...baseConfig }) {
|
|
|
621
617
|
})
|
|
622
618
|
};
|
|
623
619
|
}
|
|
624
|
-
__name(mergeConfig, "mergeConfig");
|
|
625
620
|
|
|
626
621
|
// src/shared/createDeclarationIntentBlock.ts
|
|
627
622
|
import { buildNextBlock } from "@xyo-network/chain-sdk";
|
|
628
623
|
import { createDeclarationIntent } from "@xyo-network/xl1-sdk";
|
|
629
624
|
async function createProducerChainStakeIntentBlock(prevBlock, producerAccount, range) {
|
|
630
|
-
const producerDeclarationPayload = createDeclarationIntent(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
625
|
+
const producerDeclarationPayload = createDeclarationIntent(
|
|
626
|
+
producerAccount.address,
|
|
627
|
+
"producer",
|
|
628
|
+
range[0],
|
|
629
|
+
range[1]
|
|
630
|
+
);
|
|
631
|
+
return await buildNextBlock(
|
|
632
|
+
prevBlock,
|
|
633
|
+
[],
|
|
634
|
+
[producerDeclarationPayload],
|
|
635
|
+
[producerAccount]
|
|
636
|
+
);
|
|
636
637
|
}
|
|
637
|
-
__name(createProducerChainStakeIntentBlock, "createProducerChainStakeIntentBlock");
|
|
638
638
|
|
|
639
639
|
// src/shared/host/implementation/DefaultHost.ts
|
|
640
640
|
var GenericHost = class {
|
|
641
|
-
static {
|
|
642
|
-
__name(this, "GenericHost");
|
|
643
|
-
}
|
|
644
641
|
services;
|
|
645
642
|
constructor(services) {
|
|
646
643
|
this.services = services;
|
|
@@ -657,9 +654,6 @@ var GenericHost = class {
|
|
|
657
654
|
|
|
658
655
|
// src/shared/host/implementation/DefaultServiceProvider.ts
|
|
659
656
|
var DefaultServiceProvider = class {
|
|
660
|
-
static {
|
|
661
|
-
__name(this, "DefaultServiceProvider");
|
|
662
|
-
}
|
|
663
657
|
_services;
|
|
664
658
|
constructor(services) {
|
|
665
659
|
this._services = services;
|
|
@@ -709,24 +703,19 @@ var activeWalletReport;
|
|
|
709
703
|
function getAccountLabel(actorName) {
|
|
710
704
|
return ACTOR_LABELS[actorName] ?? actorName;
|
|
711
705
|
}
|
|
712
|
-
__name(getAccountLabel, "getAccountLabel");
|
|
713
706
|
function clearResolvedWalletReport() {
|
|
714
707
|
activeWalletReport = void 0;
|
|
715
708
|
}
|
|
716
|
-
__name(clearResolvedWalletReport, "clearResolvedWalletReport");
|
|
717
709
|
function resolveActorAccountPath(actorName, actorConfig) {
|
|
718
710
|
if (actorConfig?.accountPath !== void 0) return actorConfig.accountPath;
|
|
719
711
|
return DEFAULT_ACTOR_ACCOUNT_PATH[actorName] ?? "0";
|
|
720
712
|
}
|
|
721
|
-
__name(resolveActorAccountPath, "resolveActorAccountPath");
|
|
722
713
|
function isAbsoluteAccountPath(accountPath) {
|
|
723
714
|
return accountPath.startsWith("m/");
|
|
724
715
|
}
|
|
725
|
-
__name(isAbsoluteAccountPath, "isAbsoluteAccountPath");
|
|
726
716
|
function expandAccountPath(accountPath, basePath = DEFAULT_WALLET_PATH) {
|
|
727
717
|
return isAbsoluteAccountPath(accountPath) ? accountPath : `${basePath}/${accountPath}`;
|
|
728
718
|
}
|
|
729
|
-
__name(expandAccountPath, "expandAccountPath");
|
|
730
719
|
async function deriveWalletAtPath(mnemonic, accountPath) {
|
|
731
720
|
if (isAbsoluteAccountPath(accountPath)) {
|
|
732
721
|
const seed = Mnemonic.fromPhrase(mnemonic).computeSeed();
|
|
@@ -737,15 +726,12 @@ async function deriveWalletAtPath(mnemonic, accountPath) {
|
|
|
737
726
|
const baseWallet = await generateXyoBaseWalletFromPhrase(mnemonic);
|
|
738
727
|
return await baseWallet.derivePath(accountPath);
|
|
739
728
|
}
|
|
740
|
-
__name(deriveWalletAtPath, "deriveWalletAtPath");
|
|
741
729
|
function getBuiltInDevMnemonic() {
|
|
742
730
|
return BUILT_IN_DEV_MNEMONIC;
|
|
743
731
|
}
|
|
744
|
-
__name(getBuiltInDevMnemonic, "getBuiltInDevMnemonic");
|
|
745
732
|
function getInsecureGenesisRewardMnemonic() {
|
|
746
733
|
return INSECURE_GENESIS_REWARD_MNEMONIC;
|
|
747
734
|
}
|
|
748
|
-
__name(getInsecureGenesisRewardMnemonic, "getInsecureGenesisRewardMnemonic");
|
|
749
735
|
function resolveRootWallet(configuration) {
|
|
750
736
|
const isConfigured = configuration.mnemonic !== void 0;
|
|
751
737
|
const mnemonic = configuration.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
@@ -758,8 +744,12 @@ function resolveRootWallet(configuration) {
|
|
|
758
744
|
mnemonicKind: isBuiltInDevMnemonic ? "built-in-dev" : "configured-root"
|
|
759
745
|
};
|
|
760
746
|
}
|
|
761
|
-
|
|
762
|
-
|
|
747
|
+
async function resolveWalletMetadata({
|
|
748
|
+
accountPath,
|
|
749
|
+
actorName,
|
|
750
|
+
mnemonic,
|
|
751
|
+
mnemonicKind
|
|
752
|
+
}) {
|
|
763
753
|
const account = await deriveWalletAtPath(mnemonic, accountPath);
|
|
764
754
|
return {
|
|
765
755
|
accountPath,
|
|
@@ -773,7 +763,6 @@ async function resolveWalletMetadata({ accountPath, actorName, mnemonic, mnemoni
|
|
|
773
763
|
usesBuiltInDevMnemonic: mnemonic === BUILT_IN_DEV_MNEMONIC
|
|
774
764
|
};
|
|
775
765
|
}
|
|
776
|
-
__name(resolveWalletMetadata, "resolveWalletMetadata");
|
|
777
766
|
async function resolveActorWallet(actorName, actorConfig, root) {
|
|
778
767
|
return await resolveWalletMetadata({
|
|
779
768
|
accountPath: resolveActorAccountPath(actorName, actorConfig),
|
|
@@ -782,11 +771,7 @@ async function resolveActorWallet(actorName, actorConfig, root) {
|
|
|
782
771
|
mnemonicKind: root.mnemonicKind
|
|
783
772
|
});
|
|
784
773
|
}
|
|
785
|
-
__name(resolveActorWallet, "resolveActorWallet");
|
|
786
774
|
var ActorMnemonicNotAllowedError = class extends Error {
|
|
787
|
-
static {
|
|
788
|
-
__name(this, "ActorMnemonicNotAllowedError");
|
|
789
|
-
}
|
|
790
775
|
actors;
|
|
791
776
|
constructor(actors) {
|
|
792
777
|
super([
|
|
@@ -801,14 +786,12 @@ function assertNoActorMnemonics(configuration) {
|
|
|
801
786
|
const offenders = configuration.actors.filter((actor) => typeof actor.mnemonic === "string").map((actor) => actor.name);
|
|
802
787
|
if (offenders.length > 0) throw new ActorMnemonicNotAllowedError(offenders);
|
|
803
788
|
}
|
|
804
|
-
__name(assertNoActorMnemonics, "assertNoActorMnemonics");
|
|
805
789
|
var DerivationPathCollisionError = class extends Error {
|
|
806
|
-
static {
|
|
807
|
-
__name(this, "DerivationPathCollisionError");
|
|
808
|
-
}
|
|
809
790
|
collisions;
|
|
810
791
|
constructor(collisions) {
|
|
811
|
-
const lines = Object.entries(collisions).map(
|
|
792
|
+
const lines = Object.entries(collisions).map(
|
|
793
|
+
([path, actors]) => ` - ${actors.join(", ")} \u2192 ${path}`
|
|
794
|
+
);
|
|
812
795
|
super([
|
|
813
796
|
"Two or more actors resolve to the same wallet derivation path:",
|
|
814
797
|
...lines,
|
|
@@ -819,10 +802,7 @@ var DerivationPathCollisionError = class extends Error {
|
|
|
819
802
|
}
|
|
820
803
|
};
|
|
821
804
|
function detectDerivationPathCollisions(requestedActors, configuration) {
|
|
822
|
-
const actorConfigMap = new Map(configuration.actors.map((actor) => [
|
|
823
|
-
actor.name,
|
|
824
|
-
actor
|
|
825
|
-
]));
|
|
805
|
+
const actorConfigMap = new Map(configuration.actors.map((actor) => [actor.name, actor]));
|
|
826
806
|
const bucketsByPath = /* @__PURE__ */ new Map();
|
|
827
807
|
for (const actorName of requestedActors) {
|
|
828
808
|
const accountPath = resolveActorAccountPath(actorName, actorConfigMap.get(actorName));
|
|
@@ -838,71 +818,57 @@ function detectDerivationPathCollisions(requestedActors, configuration) {
|
|
|
838
818
|
if (Object.keys(collisions).length === 0) return void 0;
|
|
839
819
|
return new DerivationPathCollisionError(collisions);
|
|
840
820
|
}
|
|
841
|
-
__name(detectDerivationPathCollisions, "detectDerivationPathCollisions");
|
|
842
821
|
async function resolveWalletReport(requestedActors, configuration) {
|
|
843
822
|
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)));
|
|
823
|
+
const actorConfigMap = new Map(configuration.actors.map((actor) => [actor.name, actor]));
|
|
824
|
+
const resolvedActors = await Promise.all(
|
|
825
|
+
requestedActors.map(async (actorName) => await resolveActorWallet(actorName, actorConfigMap.get(actorName), root))
|
|
826
|
+
);
|
|
849
827
|
const labelMap = /* @__PURE__ */ new Map();
|
|
850
828
|
for (const actor of resolvedActors) {
|
|
851
829
|
const labels = labelMap.get(actor.derivationPath) ?? [];
|
|
852
830
|
labels.push(actor.label);
|
|
853
831
|
labelMap.set(actor.derivationPath, labels);
|
|
854
832
|
}
|
|
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
|
-
}));
|
|
833
|
+
const sharedAccounts = await Promise.all(
|
|
834
|
+
Array.from({ length: SHARED_ACCOUNT_REPORT_COUNT }, (_, index) => index).map(async (sharedIndex) => {
|
|
835
|
+
const account = await resolveWalletMetadata({
|
|
836
|
+
accountPath: `${sharedIndex}`,
|
|
837
|
+
actorName: ROOT_WALLET_RUNTIME_ID,
|
|
838
|
+
mnemonic: root.mnemonic,
|
|
839
|
+
mnemonicKind: root.mnemonicKind
|
|
840
|
+
});
|
|
841
|
+
const labels = labelMap.get(account.derivationPath);
|
|
842
|
+
return { ...account, label: labels?.join(", ") ?? `shared[${sharedIndex}]` };
|
|
843
|
+
})
|
|
844
|
+
);
|
|
870
845
|
return {
|
|
871
|
-
requestedActors: [
|
|
872
|
-
...requestedActors
|
|
873
|
-
],
|
|
846
|
+
requestedActors: [...requestedActors],
|
|
874
847
|
root,
|
|
875
848
|
sharedAccounts
|
|
876
849
|
};
|
|
877
850
|
}
|
|
878
|
-
__name(resolveWalletReport, "resolveWalletReport");
|
|
879
851
|
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
|
-
}));
|
|
852
|
+
const accounts = 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: "genesisReward",
|
|
857
|
+
mnemonic: INSECURE_GENESIS_REWARD_MNEMONIC,
|
|
858
|
+
mnemonicKind: "insecure-genesis-reward"
|
|
859
|
+
});
|
|
860
|
+
return { ...account, label: sharedIndex === 0 ? "genesisRewardAddress" : `genesisReward[${sharedIndex}]` };
|
|
861
|
+
})
|
|
862
|
+
);
|
|
894
863
|
return accounts;
|
|
895
864
|
}
|
|
896
|
-
__name(buildInsecureGenesisRewardAccounts, "buildInsecureGenesisRewardAccounts");
|
|
897
865
|
async function initializeResolvedWalletReport(requestedActors, configuration) {
|
|
898
866
|
activeWalletReport = await resolveWalletReport(requestedActors, configuration);
|
|
899
867
|
return activeWalletReport;
|
|
900
868
|
}
|
|
901
|
-
__name(initializeResolvedWalletReport, "initializeResolvedWalletReport");
|
|
902
869
|
function getResolvedWalletReport() {
|
|
903
870
|
return activeWalletReport;
|
|
904
871
|
}
|
|
905
|
-
__name(getResolvedWalletReport, "getResolvedWalletReport");
|
|
906
872
|
function formatSharedAccount(account, showPrivateKey) {
|
|
907
873
|
const lines = [
|
|
908
874
|
`[${account.accountPath}] ${account.label}`,
|
|
@@ -913,7 +879,6 @@ function formatSharedAccount(account, showPrivateKey) {
|
|
|
913
879
|
if (showPrivateKey) lines.push(`privateKey: ${account.privateKey ?? "unavailable"}`);
|
|
914
880
|
return lines.join("\n");
|
|
915
881
|
}
|
|
916
|
-
__name(formatSharedAccount, "formatSharedAccount");
|
|
917
882
|
function formatGenesisRewardAccount(account) {
|
|
918
883
|
const balance = account.accountPath === "0" ? GENESIS_REWARD_AMOUNT / ATTO_XL1_PER_XL1 : 0n;
|
|
919
884
|
return [
|
|
@@ -924,7 +889,6 @@ function formatGenesisRewardAccount(account) {
|
|
|
924
889
|
`balance: ${balance.toString()} XL1`
|
|
925
890
|
].join("\n");
|
|
926
891
|
}
|
|
927
|
-
__name(formatGenesisRewardAccount, "formatGenesisRewardAccount");
|
|
928
892
|
function formatWalletReport(report) {
|
|
929
893
|
const sections = [];
|
|
930
894
|
const showSecrets = report.root.isBuiltInDevMnemonic;
|
|
@@ -949,7 +913,6 @@ function formatWalletReport(report) {
|
|
|
949
913
|
].join("\n"));
|
|
950
914
|
return sections.join("\n\n");
|
|
951
915
|
}
|
|
952
|
-
__name(formatWalletReport, "formatWalletReport");
|
|
953
916
|
function formatInsecureGenesisRewardWarning(accounts) {
|
|
954
917
|
return [
|
|
955
918
|
"INSECURE GENESIS REWARD WALLET WARNING",
|
|
@@ -968,21 +931,18 @@ function formatInsecureGenesisRewardWarning(accounts) {
|
|
|
968
931
|
accounts.map((account) => formatGenesisRewardAccount(account)).join("\n\n")
|
|
969
932
|
].join("\n");
|
|
970
933
|
}
|
|
971
|
-
__name(formatInsecureGenesisRewardWarning, "formatInsecureGenesisRewardWarning");
|
|
972
934
|
async function resolveGenesisRewardAddress(config) {
|
|
973
935
|
if (config.chain.genesisRewardAddress) return config.chain.genesisRewardAddress;
|
|
974
936
|
const wallet = await generateXyoBaseWalletFromPhrase(INSECURE_GENESIS_REWARD_MNEMONIC);
|
|
975
937
|
const account = await wallet.derivePath("0");
|
|
976
938
|
return account.address;
|
|
977
939
|
}
|
|
978
|
-
__name(resolveGenesisRewardAddress, "resolveGenesisRewardAddress");
|
|
979
940
|
async function resolveWalletForActor(actorName, accountPath) {
|
|
980
941
|
const report = activeWalletReport;
|
|
981
942
|
const mnemonic = report?.root.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
982
943
|
const resolvedAccountPath = accountPath ?? resolveActorAccountPath(actorName);
|
|
983
944
|
return await deriveWalletAtPath(mnemonic, resolvedAccountPath);
|
|
984
945
|
}
|
|
985
|
-
__name(resolveWalletForActor, "resolveWalletForActor");
|
|
986
946
|
|
|
987
947
|
// src/shared/init/initActorSeedPhrase.ts
|
|
988
948
|
async function initActorSeedPhrase(context, bios) {
|
|
@@ -995,7 +955,6 @@ async function initActorSeedPhrase(context, bios) {
|
|
|
995
955
|
logger?.debug(`[${walletKind}] Falling back to built-in development mnemonic`);
|
|
996
956
|
return assertEx2(fallback, () => "Unable to resolve mnemonic");
|
|
997
957
|
}
|
|
998
|
-
__name(initActorSeedPhrase, "initActorSeedPhrase");
|
|
999
958
|
|
|
1000
959
|
// src/shared/init/initBridgedModule.ts
|
|
1001
960
|
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
@@ -1018,33 +977,26 @@ async function initBridgedModule({ bridge, moduleName }) {
|
|
|
1018
977
|
return moduleInstance;
|
|
1019
978
|
});
|
|
1020
979
|
}
|
|
1021
|
-
__name(initBridgedModule, "initBridgedModule");
|
|
1022
980
|
async function initBridgedArchivistModule({ bridge, moduleName }) {
|
|
1023
|
-
return assertEx3(
|
|
1024
|
-
bridge,
|
|
1025
|
-
moduleName
|
|
1026
|
-
|
|
981
|
+
return assertEx3(
|
|
982
|
+
asAttachableArchivistInstance(await initBridgedModule({ bridge, moduleName })),
|
|
983
|
+
() => `Could not convert ${moduleName} to attachable archivist instance`
|
|
984
|
+
);
|
|
1027
985
|
}
|
|
1028
|
-
__name(initBridgedArchivistModule, "initBridgedArchivistModule");
|
|
1029
986
|
|
|
1030
987
|
// src/shared/init/initStatusReporter.ts
|
|
1031
988
|
import { RuntimeStatusMonitor } from "@xyo-network/xl1-sdk";
|
|
1032
989
|
function initStatusReporter({ logger }) {
|
|
1033
990
|
const statusReporter = new RuntimeStatusMonitor(logger);
|
|
1034
|
-
statusReporter.onGlobalTransition({
|
|
1035
|
-
to: "started"
|
|
1036
|
-
}, () => {
|
|
991
|
+
statusReporter.onGlobalTransition({ to: "started" }, () => {
|
|
1037
992
|
logger.log("All services started.");
|
|
1038
993
|
});
|
|
1039
|
-
statusReporter.onGlobalTransition({
|
|
1040
|
-
to: "error"
|
|
1041
|
-
}, () => {
|
|
994
|
+
statusReporter.onGlobalTransition({ to: "error" }, () => {
|
|
1042
995
|
logger.error("Producer encountered an unhandled error!");
|
|
1043
996
|
process.exit(1);
|
|
1044
997
|
});
|
|
1045
998
|
return statusReporter;
|
|
1046
999
|
}
|
|
1047
|
-
__name(initStatusReporter, "initStatusReporter");
|
|
1048
1000
|
|
|
1049
1001
|
// src/shared/init/initWallet.ts
|
|
1050
1002
|
import { isDefined } from "@xylabs/sdk-js";
|
|
@@ -1058,21 +1010,10 @@ async function initActorWallet(context) {
|
|
|
1058
1010
|
actorAccountSingletons[actorName] = account;
|
|
1059
1011
|
return actorAccountSingletons[actorName];
|
|
1060
1012
|
}
|
|
1061
|
-
__name(initActorWallet, "initActorWallet");
|
|
1062
1013
|
|
|
1063
1014
|
// src/shared/orchestrator/Orchestrator.ts
|
|
1064
1015
|
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
1016
|
var Orchestrator = class extends AbstractCreatable2 {
|
|
1073
|
-
static {
|
|
1074
|
-
__name(this, "Orchestrator");
|
|
1075
|
-
}
|
|
1076
1017
|
actors = [];
|
|
1077
1018
|
running = false;
|
|
1078
1019
|
shuttingDown = false;
|
|
@@ -1089,9 +1030,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1089
1030
|
return this.shuttingDown;
|
|
1090
1031
|
}
|
|
1091
1032
|
/**
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1033
|
+
* Registers an actor.
|
|
1034
|
+
* (We won't activate the actor until `start()` is called.)
|
|
1035
|
+
*/
|
|
1095
1036
|
async registerActor(actor) {
|
|
1096
1037
|
this.actors.push(actor);
|
|
1097
1038
|
if (this.running) {
|
|
@@ -1104,9 +1045,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1104
1045
|
}
|
|
1105
1046
|
}
|
|
1106
1047
|
/**
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1048
|
+
* Starts the orchestrator: activates all actors in parallel and kicks off their warm-pass.
|
|
1049
|
+
* `whenReady()` resolves once every actor's `readyHandler` has succeeded.
|
|
1050
|
+
*/
|
|
1110
1051
|
async startHandler() {
|
|
1111
1052
|
await super.startHandler();
|
|
1112
1053
|
if (this.running) {
|
|
@@ -1116,12 +1057,7 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1116
1057
|
this.logger?.log(`[Orchestrator] Starting ${this.actors.length} actor(s) in parallel...`);
|
|
1117
1058
|
this.running = true;
|
|
1118
1059
|
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
|
-
] : []);
|
|
1060
|
+
const startFailures = startResults.flatMap((r, i) => r.status === "rejected" ? [{ actor: this.actors[i], reason: r.reason }] : []);
|
|
1125
1061
|
if (startFailures.length > 0) {
|
|
1126
1062
|
for (const f of startFailures) this.logger?.error(`[Orchestrator] Actor [${f.actor?.name ?? "?"}] failed to start: ${formatError(f.reason)}`);
|
|
1127
1063
|
throw new Error(`[Orchestrator] ${startFailures.length} actor(s) failed to start`);
|
|
@@ -1135,8 +1071,8 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1135
1071
|
}
|
|
1136
1072
|
}
|
|
1137
1073
|
/**
|
|
1138
|
-
|
|
1139
|
-
|
|
1074
|
+
* Stops the orchestrator: deactivates all actors.
|
|
1075
|
+
*/
|
|
1140
1076
|
async stopHandler() {
|
|
1141
1077
|
await super.stopHandler();
|
|
1142
1078
|
if (!this.running) {
|
|
@@ -1151,9 +1087,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1151
1087
|
this.logger?.log("[Orchestrator] Stopped.");
|
|
1152
1088
|
}
|
|
1153
1089
|
/**
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1090
|
+
* Resolves once every actor reports ready. Rejects if any actor's `readyHandler` throws,
|
|
1091
|
+
* or after `timeoutMs` if provided.
|
|
1092
|
+
*/
|
|
1157
1093
|
async whenReady(timeoutMs) {
|
|
1158
1094
|
const localActors = this.actors.filter(isLocalActor);
|
|
1159
1095
|
if (localActors.length === 0) return;
|
|
@@ -1168,50 +1104,30 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1168
1104
|
}, timeoutMs);
|
|
1169
1105
|
});
|
|
1170
1106
|
try {
|
|
1171
|
-
await Promise.race([
|
|
1172
|
-
Promise.all(localActors.map((a) => a.whenReady())),
|
|
1173
|
-
timeout
|
|
1174
|
-
]);
|
|
1107
|
+
await Promise.race([Promise.all(localActors.map((a) => a.whenReady())), timeout]);
|
|
1175
1108
|
} finally {
|
|
1176
1109
|
if (timer) clearTimeout(timer);
|
|
1177
1110
|
}
|
|
1178
1111
|
}
|
|
1179
1112
|
};
|
|
1180
|
-
Orchestrator =
|
|
1113
|
+
Orchestrator = __decorateClass([
|
|
1181
1114
|
creatable()
|
|
1182
1115
|
], Orchestrator);
|
|
1183
1116
|
function isLocalActor(actor) {
|
|
1184
1117
|
return actor instanceof ActorV3;
|
|
1185
1118
|
}
|
|
1186
|
-
__name(isLocalActor, "isLocalActor");
|
|
1187
1119
|
function formatError(err) {
|
|
1188
1120
|
if (err instanceof Error) return `${err.message}${err.stack ? `
|
|
1189
1121
|
${err.stack}` : ""}`;
|
|
1190
1122
|
return String(err);
|
|
1191
1123
|
}
|
|
1192
|
-
__name(formatError, "formatError");
|
|
1193
1124
|
|
|
1194
1125
|
// src/shared/provider/SimpleRejectedTransactionsArchivistProvider.ts
|
|
1195
1126
|
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
1196
1127
|
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
1128
|
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;
|
|
1129
|
+
var SimpleRejectedTransactionsArchivistProvider = class extends AbstractCreatableProvider {
|
|
1130
|
+
moniker = SimpleRejectedTransactionsArchivistProvider.defaultMoniker;
|
|
1215
1131
|
get archivist() {
|
|
1216
1132
|
return this.params.archivist;
|
|
1217
1133
|
}
|
|
@@ -1222,7 +1138,10 @@ var SimpleRejectedTransactionsArchivistProvider = class _SimpleRejectedTransacti
|
|
|
1222
1138
|
};
|
|
1223
1139
|
}
|
|
1224
1140
|
};
|
|
1225
|
-
SimpleRejectedTransactionsArchivistProvider
|
|
1141
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "defaultMoniker", RejectedTransactionsArchivistProviderMoniker);
|
|
1142
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "dependencies", []);
|
|
1143
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "monikers", [RejectedTransactionsArchivistProviderMoniker]);
|
|
1144
|
+
SimpleRejectedTransactionsArchivistProvider = __decorateClass([
|
|
1226
1145
|
creatableProvider()
|
|
1227
1146
|
], SimpleRejectedTransactionsArchivistProvider);
|
|
1228
1147
|
|
|
@@ -1233,7 +1152,25 @@ import { backingsSatisfied, unmetBackings } from "@xyo-network/xl1-protocol-sdk"
|
|
|
1233
1152
|
import { createCapabilityRegistry } from "@xyo-network/xl1-protocol-sdk";
|
|
1234
1153
|
|
|
1235
1154
|
// src/node/config/capabilities/defaultCapabilityRegistry.ts
|
|
1236
|
-
import {
|
|
1155
|
+
import {
|
|
1156
|
+
AccountBalanceViewerMoniker,
|
|
1157
|
+
BlockRunnerMoniker,
|
|
1158
|
+
BlockValidationViewerMoniker,
|
|
1159
|
+
BlockViewerMoniker,
|
|
1160
|
+
ChainContractViewerMoniker,
|
|
1161
|
+
DeadLetterQueueRunnerMoniker,
|
|
1162
|
+
DeadLetterQueueViewerMoniker,
|
|
1163
|
+
FinalizationRunnerMoniker,
|
|
1164
|
+
FinalizationViewerMoniker,
|
|
1165
|
+
MempoolRunnerMoniker,
|
|
1166
|
+
MempoolViewerMoniker,
|
|
1167
|
+
StakeTotalsViewerMoniker,
|
|
1168
|
+
TimeSyncViewerMoniker,
|
|
1169
|
+
TransactionValidationViewerMoniker,
|
|
1170
|
+
TransactionViewerMoniker,
|
|
1171
|
+
WindowedBlockViewerMoniker,
|
|
1172
|
+
XyoViewerMoniker
|
|
1173
|
+
} from "@xyo-network/xl1-sdk";
|
|
1237
1174
|
var XyoConnectionMoniker = "XyoConnection";
|
|
1238
1175
|
var XyoGatewayRunnerMoniker = "XyoGatewayRunner";
|
|
1239
1176
|
var capabilities = [
|
|
@@ -1254,12 +1191,22 @@ var capabilities = [
|
|
|
1254
1191
|
label: "Mempool viewer",
|
|
1255
1192
|
kind: "viewer",
|
|
1256
1193
|
surface: "node"
|
|
1194
|
+
// Note: `SimpleMempoolViewer.dependencies` lists `WindowedBlockViewer`,
|
|
1195
|
+
// but the runtime constructor does NOT actually resolve it — the
|
|
1196
|
+
// dependencies field is informational for `validateDepsOnRegister`.
|
|
1197
|
+
// Adding `implies: [WindowedBlockViewerMoniker]` here would over-provision
|
|
1198
|
+
// (selected by `locatorPlan.spec.ts`); leave it off intentionally.
|
|
1257
1199
|
},
|
|
1258
1200
|
{
|
|
1259
1201
|
id: MempoolRunnerMoniker,
|
|
1260
1202
|
label: "Mempool runner",
|
|
1261
1203
|
kind: "runner",
|
|
1262
1204
|
surface: "node"
|
|
1205
|
+
// Note: `SimpleMempoolRunner.dependencies` lists BlockValidationViewer,
|
|
1206
|
+
// ChainContractViewer, FinalizationViewer, TransactionValidationViewer —
|
|
1207
|
+
// but the same "informational deps" principle applies: the runtime
|
|
1208
|
+
// constructor does not eagerly resolve them. Adding them as `implies`
|
|
1209
|
+
// would over-provision (selected by `locatorPlan.spec.ts`).
|
|
1263
1210
|
},
|
|
1264
1211
|
{
|
|
1265
1212
|
id: AccountBalanceViewerMoniker,
|
|
@@ -1372,10 +1319,24 @@ function createDefaultCapabilityRegistry() {
|
|
|
1372
1319
|
for (const cap of capabilities) registry.register(cap);
|
|
1373
1320
|
return registry;
|
|
1374
1321
|
}
|
|
1375
|
-
__name(createDefaultCapabilityRegistry, "createDefaultCapabilityRegistry");
|
|
1376
1322
|
|
|
1377
1323
|
// src/node/config/capabilities/descriptors.ts
|
|
1378
|
-
import {
|
|
1324
|
+
import {
|
|
1325
|
+
SimpleAccountBalanceViewer,
|
|
1326
|
+
SimpleBlockValidationViewer,
|
|
1327
|
+
SimpleBlockViewer,
|
|
1328
|
+
SimpleDeadLetterQueueRunner,
|
|
1329
|
+
SimpleDeadLetterQueueViewer,
|
|
1330
|
+
SimpleFinalizationRunner,
|
|
1331
|
+
SimpleFinalizationViewer,
|
|
1332
|
+
SimpleMempoolRunner,
|
|
1333
|
+
SimpleMempoolViewer,
|
|
1334
|
+
SimpleTransactionValidationViewer,
|
|
1335
|
+
SimpleTransactionViewer,
|
|
1336
|
+
SimpleWindowedBlockViewer,
|
|
1337
|
+
SimpleXyoConnectionViewer,
|
|
1338
|
+
SimpleXyoViewer
|
|
1339
|
+
} from "@xyo-network/xl1-sdk";
|
|
1379
1340
|
function readMempoolTuning(ctx) {
|
|
1380
1341
|
const cfg = ctx.actorContext.config;
|
|
1381
1342
|
return {
|
|
@@ -1383,258 +1344,207 @@ function readMempoolTuning(ctx) {
|
|
|
1383
1344
|
maxPendingTransactions: cfg?.mempool?.maxPendingTransactions
|
|
1384
1345
|
};
|
|
1385
1346
|
}
|
|
1386
|
-
|
|
1387
|
-
var passes = /* @__PURE__ */ __name(() => true, "passes");
|
|
1347
|
+
var passes = () => true;
|
|
1388
1348
|
var localTier1Descriptors = [
|
|
1389
1349
|
{
|
|
1390
1350
|
id: "SimpleMempoolViewer",
|
|
1391
|
-
satisfies: [
|
|
1392
|
-
SimpleMempoolViewer.defaultMoniker
|
|
1393
|
-
],
|
|
1351
|
+
satisfies: [SimpleMempoolViewer.defaultMoniker],
|
|
1394
1352
|
tier: 1,
|
|
1395
|
-
backings: [
|
|
1396
|
-
{
|
|
1397
|
-
backing: "mempool-store",
|
|
1398
|
-
mode: "read"
|
|
1399
|
-
}
|
|
1400
|
-
],
|
|
1353
|
+
backings: [{ backing: "mempool-store", mode: "read" }],
|
|
1401
1354
|
surface: "node",
|
|
1402
1355
|
preconditions: passes,
|
|
1403
|
-
build:
|
|
1356
|
+
build: (ctx) => {
|
|
1404
1357
|
const { demotionThreshold } = readMempoolTuning(ctx);
|
|
1405
|
-
return SimpleMempoolViewer.factory(
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1358
|
+
return SimpleMempoolViewer.factory(
|
|
1359
|
+
SimpleMempoolViewer.dependencies,
|
|
1360
|
+
{
|
|
1361
|
+
pendingTransactionsArchivist: ctx.process.pendingTransactionsArchivist,
|
|
1362
|
+
pendingBlocksArchivist: ctx.process.pendingBlocksArchivist,
|
|
1363
|
+
demotionThreshold
|
|
1364
|
+
}
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1411
1367
|
},
|
|
1412
1368
|
{
|
|
1413
1369
|
id: "SimpleMempoolRunner",
|
|
1414
|
-
satisfies: [
|
|
1415
|
-
SimpleMempoolRunner.defaultMoniker
|
|
1416
|
-
],
|
|
1370
|
+
satisfies: [SimpleMempoolRunner.defaultMoniker],
|
|
1417
1371
|
tier: 1,
|
|
1418
|
-
backings: [
|
|
1419
|
-
{
|
|
1420
|
-
backing: "mempool-store",
|
|
1421
|
-
mode: "write"
|
|
1422
|
-
}
|
|
1423
|
-
],
|
|
1372
|
+
backings: [{ backing: "mempool-store", mode: "write" }],
|
|
1424
1373
|
surface: "node",
|
|
1425
1374
|
preconditions: passes,
|
|
1426
|
-
build:
|
|
1375
|
+
build: (ctx) => {
|
|
1427
1376
|
const { maxPendingTransactions } = readMempoolTuning(ctx);
|
|
1428
|
-
return SimpleMempoolRunner.factory(
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1377
|
+
return SimpleMempoolRunner.factory(
|
|
1378
|
+
SimpleMempoolRunner.dependencies,
|
|
1379
|
+
{
|
|
1380
|
+
pendingTransactionsArchivist: ctx.process.pendingTransactionsArchivist,
|
|
1381
|
+
pendingBlocksArchivist: ctx.process.pendingBlocksArchivist,
|
|
1382
|
+
maxPendingTransactions
|
|
1383
|
+
}
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1434
1386
|
},
|
|
1435
1387
|
{
|
|
1436
1388
|
id: "SimpleAccountBalanceViewer",
|
|
1437
|
-
satisfies: [
|
|
1438
|
-
SimpleAccountBalanceViewer.defaultMoniker
|
|
1439
|
-
],
|
|
1389
|
+
satisfies: [SimpleAccountBalanceViewer.defaultMoniker],
|
|
1440
1390
|
tier: 1,
|
|
1441
|
-
backings: [
|
|
1442
|
-
{
|
|
1443
|
-
backing: "indexer-store",
|
|
1444
|
-
mode: "read"
|
|
1445
|
-
}
|
|
1446
|
-
],
|
|
1391
|
+
backings: [{ backing: "indexer-store", mode: "read" }],
|
|
1447
1392
|
surface: "node",
|
|
1448
1393
|
preconditions: passes,
|
|
1449
|
-
build:
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1394
|
+
build: (ctx) => SimpleAccountBalanceViewer.factory(
|
|
1395
|
+
SimpleAccountBalanceViewer.dependencies,
|
|
1396
|
+
{
|
|
1397
|
+
balancesSummaryMap: ctx.process.balancesSummaryMap,
|
|
1398
|
+
transfersSummaryMap: ctx.process.transfersSummaryMap
|
|
1399
|
+
}
|
|
1400
|
+
)
|
|
1453
1401
|
},
|
|
1454
1402
|
{
|
|
1455
1403
|
id: "SimpleFinalizationViewer",
|
|
1456
|
-
satisfies: [
|
|
1457
|
-
SimpleFinalizationViewer.defaultMoniker
|
|
1458
|
-
],
|
|
1404
|
+
satisfies: [SimpleFinalizationViewer.defaultMoniker],
|
|
1459
1405
|
tier: 1,
|
|
1460
|
-
backings: [
|
|
1461
|
-
{
|
|
1462
|
-
backing: "chain-store",
|
|
1463
|
-
mode: "read"
|
|
1464
|
-
}
|
|
1465
|
-
],
|
|
1406
|
+
backings: [{ backing: "chain-store", mode: "read" }],
|
|
1466
1407
|
surface: "node",
|
|
1467
1408
|
preconditions: passes,
|
|
1468
|
-
build:
|
|
1469
|
-
|
|
1470
|
-
|
|
1409
|
+
build: (ctx) => SimpleFinalizationViewer.factory(
|
|
1410
|
+
SimpleFinalizationViewer.dependencies,
|
|
1411
|
+
{ finalizedArchivist: ctx.process.readonlyChainArchivist }
|
|
1412
|
+
)
|
|
1471
1413
|
},
|
|
1472
1414
|
{
|
|
1473
1415
|
id: "SimpleBlockViewer",
|
|
1474
|
-
satisfies: [
|
|
1475
|
-
SimpleBlockViewer.defaultMoniker
|
|
1476
|
-
],
|
|
1416
|
+
satisfies: [SimpleBlockViewer.defaultMoniker],
|
|
1477
1417
|
tier: 1,
|
|
1478
|
-
backings: [
|
|
1479
|
-
{
|
|
1480
|
-
backing: "chain-store",
|
|
1481
|
-
mode: "read"
|
|
1482
|
-
}
|
|
1483
|
-
],
|
|
1418
|
+
backings: [{ backing: "chain-store", mode: "read" }],
|
|
1484
1419
|
surface: "node",
|
|
1485
1420
|
preconditions: passes,
|
|
1486
|
-
build:
|
|
1487
|
-
|
|
1488
|
-
|
|
1421
|
+
build: (ctx) => SimpleBlockViewer.factory(
|
|
1422
|
+
SimpleBlockViewer.dependencies,
|
|
1423
|
+
{ finalizedArchivist: ctx.process.readonlyChainArchivist }
|
|
1424
|
+
)
|
|
1489
1425
|
},
|
|
1490
1426
|
{
|
|
1491
1427
|
id: "SimpleWindowedBlockViewer",
|
|
1492
|
-
satisfies: [
|
|
1493
|
-
SimpleWindowedBlockViewer.defaultMoniker
|
|
1494
|
-
],
|
|
1428
|
+
satisfies: [SimpleWindowedBlockViewer.defaultMoniker],
|
|
1495
1429
|
tier: 1,
|
|
1496
1430
|
backings: [],
|
|
1497
1431
|
surface: "node",
|
|
1498
1432
|
preconditions: passes,
|
|
1499
|
-
build:
|
|
1500
|
-
|
|
1501
|
-
syncInterval: 1e4
|
|
1502
|
-
|
|
1433
|
+
build: () => SimpleWindowedBlockViewer.factory(
|
|
1434
|
+
SimpleWindowedBlockViewer.dependencies,
|
|
1435
|
+
{ maxWindowSize: 1e3, syncInterval: 1e4 }
|
|
1436
|
+
)
|
|
1503
1437
|
},
|
|
1504
1438
|
{
|
|
1505
1439
|
id: "SimpleXyoConnectionViewer",
|
|
1506
|
-
satisfies: [
|
|
1507
|
-
SimpleXyoConnectionViewer.defaultMoniker
|
|
1508
|
-
],
|
|
1440
|
+
satisfies: [SimpleXyoConnectionViewer.defaultMoniker],
|
|
1509
1441
|
tier: 1,
|
|
1510
1442
|
backings: [],
|
|
1511
1443
|
surface: "node",
|
|
1512
1444
|
preconditions: passes,
|
|
1513
|
-
build:
|
|
1445
|
+
build: () => SimpleXyoConnectionViewer.factory(SimpleXyoConnectionViewer.dependencies, {})
|
|
1514
1446
|
},
|
|
1515
1447
|
{
|
|
1516
1448
|
id: "SimpleTransactionViewer",
|
|
1517
|
-
satisfies: [
|
|
1518
|
-
SimpleTransactionViewer.defaultMoniker
|
|
1519
|
-
],
|
|
1449
|
+
satisfies: [SimpleTransactionViewer.defaultMoniker],
|
|
1520
1450
|
tier: 1,
|
|
1521
1451
|
backings: [],
|
|
1522
1452
|
surface: "node",
|
|
1523
1453
|
preconditions: passes,
|
|
1524
|
-
build:
|
|
1454
|
+
build: () => SimpleTransactionViewer.factory(SimpleTransactionViewer.dependencies, {})
|
|
1525
1455
|
},
|
|
1526
1456
|
{
|
|
1527
1457
|
id: "SimpleXyoViewer",
|
|
1528
|
-
satisfies: [
|
|
1529
|
-
SimpleXyoViewer.defaultMoniker
|
|
1530
|
-
],
|
|
1458
|
+
satisfies: [SimpleXyoViewer.defaultMoniker],
|
|
1531
1459
|
tier: 1,
|
|
1532
1460
|
backings: [],
|
|
1533
1461
|
surface: "node",
|
|
1534
1462
|
preconditions: passes,
|
|
1535
|
-
build:
|
|
1463
|
+
build: () => SimpleXyoViewer.factory(SimpleXyoViewer.dependencies, {})
|
|
1536
1464
|
},
|
|
1537
1465
|
{
|
|
1538
1466
|
id: "SimpleFinalizationRunner",
|
|
1539
|
-
satisfies: [
|
|
1540
|
-
SimpleFinalizationRunner.defaultMoniker
|
|
1541
|
-
],
|
|
1467
|
+
satisfies: [SimpleFinalizationRunner.defaultMoniker],
|
|
1542
1468
|
tier: 1,
|
|
1543
|
-
backings: [
|
|
1544
|
-
{
|
|
1545
|
-
backing: "chain-store",
|
|
1546
|
-
mode: "write"
|
|
1547
|
-
}
|
|
1548
|
-
],
|
|
1469
|
+
backings: [{ backing: "chain-store", mode: "write" }],
|
|
1549
1470
|
surface: "node",
|
|
1550
1471
|
preconditions: passes,
|
|
1551
|
-
build:
|
|
1552
|
-
|
|
1553
|
-
|
|
1472
|
+
build: (ctx) => SimpleFinalizationRunner.factory(
|
|
1473
|
+
SimpleFinalizationRunner.dependencies,
|
|
1474
|
+
{ finalizedArchivist: ctx.process.writableChainArchivist }
|
|
1475
|
+
)
|
|
1554
1476
|
},
|
|
1555
1477
|
{
|
|
1556
1478
|
id: "SimpleBlockValidationViewer",
|
|
1557
|
-
satisfies: [
|
|
1558
|
-
SimpleBlockValidationViewer.defaultMoniker
|
|
1559
|
-
],
|
|
1479
|
+
satisfies: [SimpleBlockValidationViewer.defaultMoniker],
|
|
1560
1480
|
tier: 1,
|
|
1561
1481
|
backings: [],
|
|
1562
1482
|
surface: "node",
|
|
1563
1483
|
preconditions: passes,
|
|
1564
|
-
build:
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1484
|
+
build: (ctx) => SimpleBlockValidationViewer.factory(
|
|
1485
|
+
SimpleBlockValidationViewer.dependencies,
|
|
1486
|
+
{
|
|
1487
|
+
state: ctx.process.blockStateValidator,
|
|
1488
|
+
protocol: ctx.process.blockProtocolValidator
|
|
1489
|
+
}
|
|
1490
|
+
)
|
|
1568
1491
|
},
|
|
1569
1492
|
{
|
|
1570
1493
|
id: "SimpleTransactionValidationViewer",
|
|
1571
|
-
satisfies: [
|
|
1572
|
-
SimpleTransactionValidationViewer.defaultMoniker
|
|
1573
|
-
],
|
|
1494
|
+
satisfies: [SimpleTransactionValidationViewer.defaultMoniker],
|
|
1574
1495
|
tier: 1,
|
|
1575
1496
|
backings: [],
|
|
1576
1497
|
surface: "node",
|
|
1577
1498
|
preconditions: passes,
|
|
1578
|
-
build:
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1499
|
+
build: (ctx) => SimpleTransactionValidationViewer.factory(
|
|
1500
|
+
SimpleTransactionValidationViewer.dependencies,
|
|
1501
|
+
{
|
|
1502
|
+
protocol: ctx.process.transactionProtocolValidator,
|
|
1503
|
+
state: ctx.process.transactionStateValidator
|
|
1504
|
+
}
|
|
1505
|
+
)
|
|
1582
1506
|
},
|
|
1583
1507
|
{
|
|
1584
1508
|
id: "SimpleDeadLetterQueueRunner",
|
|
1585
|
-
satisfies: [
|
|
1586
|
-
SimpleDeadLetterQueueRunner.defaultMoniker
|
|
1587
|
-
],
|
|
1509
|
+
satisfies: [SimpleDeadLetterQueueRunner.defaultMoniker],
|
|
1588
1510
|
tier: 1,
|
|
1589
|
-
backings: [
|
|
1590
|
-
{
|
|
1591
|
-
backing: "dlq-store",
|
|
1592
|
-
mode: "write"
|
|
1593
|
-
}
|
|
1594
|
-
],
|
|
1511
|
+
backings: [{ backing: "dlq-store", mode: "write" }],
|
|
1595
1512
|
surface: "node",
|
|
1596
1513
|
preconditions: passes,
|
|
1597
|
-
build:
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1514
|
+
build: (ctx) => SimpleDeadLetterQueueRunner.factory(
|
|
1515
|
+
SimpleDeadLetterQueueRunner.dependencies,
|
|
1516
|
+
{
|
|
1517
|
+
rejectedBlocksArchivist: ctx.process.rejectedBlocksArchivist,
|
|
1518
|
+
rejectedTransactionsArchivist: ctx.process.rejectedTransactionsArchivist
|
|
1519
|
+
}
|
|
1520
|
+
)
|
|
1601
1521
|
},
|
|
1602
1522
|
{
|
|
1603
1523
|
id: "SimpleDeadLetterQueueViewer",
|
|
1604
|
-
satisfies: [
|
|
1605
|
-
SimpleDeadLetterQueueViewer.defaultMoniker
|
|
1606
|
-
],
|
|
1524
|
+
satisfies: [SimpleDeadLetterQueueViewer.defaultMoniker],
|
|
1607
1525
|
tier: 1,
|
|
1608
|
-
backings: [
|
|
1609
|
-
{
|
|
1610
|
-
backing: "dlq-store",
|
|
1611
|
-
mode: "read"
|
|
1612
|
-
}
|
|
1613
|
-
],
|
|
1526
|
+
backings: [{ backing: "dlq-store", mode: "read" }],
|
|
1614
1527
|
surface: "node",
|
|
1615
1528
|
preconditions: passes,
|
|
1616
|
-
build:
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1529
|
+
build: (ctx) => SimpleDeadLetterQueueViewer.factory(
|
|
1530
|
+
SimpleDeadLetterQueueViewer.dependencies,
|
|
1531
|
+
{
|
|
1532
|
+
rejectedBlocksArchivist: ctx.process.rejectedBlocksArchivist,
|
|
1533
|
+
rejectedTransactionsArchivist: ctx.process.rejectedTransactionsArchivist
|
|
1534
|
+
}
|
|
1535
|
+
)
|
|
1620
1536
|
},
|
|
1621
1537
|
{
|
|
1622
1538
|
id: "SimpleRejectedTransactionsArchivistProvider",
|
|
1623
|
-
satisfies: [
|
|
1624
|
-
SimpleRejectedTransactionsArchivistProvider.defaultMoniker
|
|
1625
|
-
],
|
|
1539
|
+
satisfies: [SimpleRejectedTransactionsArchivistProvider.defaultMoniker],
|
|
1626
1540
|
tier: 1,
|
|
1627
|
-
backings: [
|
|
1628
|
-
{
|
|
1629
|
-
backing: "dlq-store",
|
|
1630
|
-
mode: "read"
|
|
1631
|
-
}
|
|
1632
|
-
],
|
|
1541
|
+
backings: [{ backing: "dlq-store", mode: "read" }],
|
|
1633
1542
|
surface: "node",
|
|
1634
1543
|
preconditions: passes,
|
|
1635
|
-
build:
|
|
1636
|
-
|
|
1637
|
-
|
|
1544
|
+
build: (ctx) => SimpleRejectedTransactionsArchivistProvider.factory(
|
|
1545
|
+
SimpleRejectedTransactionsArchivistProvider.dependencies,
|
|
1546
|
+
{ archivist: ctx.process.rejectedTransactionsArchivist }
|
|
1547
|
+
)
|
|
1638
1548
|
}
|
|
1639
1549
|
];
|
|
1640
1550
|
|
|
@@ -1642,7 +1552,11 @@ var localTier1Descriptors = [
|
|
|
1642
1552
|
import { ProviderFactoryLocator } from "@xyo-network/xl1-sdk";
|
|
1643
1553
|
|
|
1644
1554
|
// src/node/config/capabilities/networkTier3Descriptors.ts
|
|
1645
|
-
import {
|
|
1555
|
+
import {
|
|
1556
|
+
indexedNetworkDescriptors,
|
|
1557
|
+
networkTier3Descriptors,
|
|
1558
|
+
nodeNetworkDescriptors
|
|
1559
|
+
} from "@xyo-network/xl1-sdk";
|
|
1646
1560
|
|
|
1647
1561
|
// src/node/init/initBalanceSummaryMap.ts
|
|
1648
1562
|
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
@@ -1652,7 +1566,13 @@ import { hasMongoConfig, MemoryMap } from "@xyo-network/xl1-sdk";
|
|
|
1652
1566
|
async function initBalanceSummaryMap({ logger, config }) {
|
|
1653
1567
|
const mongoConfig = config.storage?.mongo;
|
|
1654
1568
|
if (hasMongoConfig(mongoConfig)) {
|
|
1655
|
-
const {
|
|
1569
|
+
const {
|
|
1570
|
+
connectionString: dbConnectionString,
|
|
1571
|
+
database: dbName,
|
|
1572
|
+
domain: dbDomain,
|
|
1573
|
+
password: dbPassword,
|
|
1574
|
+
username: dbUserName
|
|
1575
|
+
} = mongoConfig;
|
|
1656
1576
|
const payloadSdkConfig = {
|
|
1657
1577
|
dbConnectionString,
|
|
1658
1578
|
dbDomain,
|
|
@@ -1660,16 +1580,10 @@ async function initBalanceSummaryMap({ logger, config }) {
|
|
|
1660
1580
|
dbPassword,
|
|
1661
1581
|
dbUserName
|
|
1662
1582
|
};
|
|
1663
|
-
const sdkBalanceSummaryMap = new BaseMongoSdk({
|
|
1664
|
-
...payloadSdkConfig,
|
|
1665
|
-
collection: "balance_summary_map"
|
|
1666
|
-
});
|
|
1583
|
+
const sdkBalanceSummaryMap = new BaseMongoSdk({ ...payloadSdkConfig, collection: "balance_summary_map" });
|
|
1667
1584
|
const result = await MongoMap.create({
|
|
1668
1585
|
sdk: sdkBalanceSummaryMap,
|
|
1669
|
-
getCache: {
|
|
1670
|
-
enabled: true,
|
|
1671
|
-
maxEntries: 5e3
|
|
1672
|
-
}
|
|
1586
|
+
getCache: { enabled: true, maxEntries: 5e3 }
|
|
1673
1587
|
});
|
|
1674
1588
|
assertEx5(await result.start(), () => "Failed to start transfer summary map");
|
|
1675
1589
|
return result;
|
|
@@ -1678,13 +1592,24 @@ async function initBalanceSummaryMap({ logger, config }) {
|
|
|
1678
1592
|
return new MemoryMap();
|
|
1679
1593
|
}
|
|
1680
1594
|
}
|
|
1681
|
-
__name(initBalanceSummaryMap, "initBalanceSummaryMap");
|
|
1682
1595
|
|
|
1683
1596
|
// src/node/init/initEvmProvidersIfAvailable.ts
|
|
1684
1597
|
import { asEthAddress } from "@xylabs/sdk-js";
|
|
1685
|
-
import {
|
|
1598
|
+
import {
|
|
1599
|
+
EvmChainContractViewer,
|
|
1600
|
+
EvmStakeEventsViewer,
|
|
1601
|
+
EvmStakeTotalsViewer,
|
|
1602
|
+
EvmStakeViewer
|
|
1603
|
+
} from "@xyo-network/chain-ethereum";
|
|
1686
1604
|
import { canUseEvmProvider, initEvmProvider } from "@xyo-network/chain-orchestration-evm";
|
|
1687
|
-
import {
|
|
1605
|
+
import {
|
|
1606
|
+
SimpleChainContractViewer,
|
|
1607
|
+
SimpleStakeEventsViewer,
|
|
1608
|
+
SimpleStakeTotalsViewer,
|
|
1609
|
+
SimpleStakeViewer,
|
|
1610
|
+
SimpleTimeSyncViewer,
|
|
1611
|
+
XYO_ZERO_ADDRESS
|
|
1612
|
+
} from "@xyo-network/xl1-sdk";
|
|
1688
1613
|
async function initEvmProvidersIfAvailable(locator) {
|
|
1689
1614
|
const context = locator.context;
|
|
1690
1615
|
const { logger } = context;
|
|
@@ -1692,51 +1617,66 @@ async function initEvmProvidersIfAvailable(locator) {
|
|
|
1692
1617
|
const chainId = context.config.chain.id;
|
|
1693
1618
|
const provider = await initEvmProvider(context);
|
|
1694
1619
|
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
|
-
|
|
1620
|
+
locator.register(EvmStakeEventsViewer.factory(
|
|
1621
|
+
EvmStakeEventsViewer.dependencies,
|
|
1622
|
+
{ address, provider }
|
|
1623
|
+
));
|
|
1624
|
+
locator.register(EvmStakeViewer.factory(
|
|
1625
|
+
EvmStakeViewer.dependencies,
|
|
1626
|
+
{ address, provider }
|
|
1627
|
+
));
|
|
1628
|
+
locator.register(EvmStakeTotalsViewer.factory(
|
|
1629
|
+
EvmStakeTotalsViewer.dependencies,
|
|
1630
|
+
{ address, provider }
|
|
1631
|
+
));
|
|
1632
|
+
locator.register(EvmChainContractViewer.factory(
|
|
1633
|
+
EvmChainContractViewer.dependencies,
|
|
1634
|
+
{ address, provider }
|
|
1635
|
+
));
|
|
1636
|
+
locator.register(SimpleTimeSyncViewer.factory(
|
|
1637
|
+
SimpleTimeSyncViewer.dependencies,
|
|
1638
|
+
{ ethProvider: provider }
|
|
1639
|
+
));
|
|
1714
1640
|
} else {
|
|
1715
1641
|
logger?.warn("EVM provider not available - running with memory based contract/stake viewers");
|
|
1716
1642
|
const positions = [];
|
|
1717
|
-
locator.register(SimpleStakeEventsViewer.factory(
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
locator.register(
|
|
1643
|
+
locator.register(SimpleStakeEventsViewer.factory(
|
|
1644
|
+
SimpleStakeEventsViewer.dependencies,
|
|
1645
|
+
{ positions }
|
|
1646
|
+
));
|
|
1647
|
+
locator.register(SimpleStakeViewer.factory(
|
|
1648
|
+
SimpleStakeViewer.dependencies,
|
|
1649
|
+
{ positions }
|
|
1650
|
+
));
|
|
1651
|
+
locator.register(SimpleStakeTotalsViewer.factory(
|
|
1652
|
+
SimpleStakeTotalsViewer.dependencies,
|
|
1653
|
+
{}
|
|
1654
|
+
));
|
|
1655
|
+
locator.register(SimpleChainContractViewer.factory(
|
|
1656
|
+
SimpleChainContractViewer.dependencies,
|
|
1657
|
+
{
|
|
1658
|
+
minWithdrawalBlocks: 10,
|
|
1659
|
+
stakingTokenAddress: XYO_ZERO_ADDRESS,
|
|
1660
|
+
rewardsContract: XYO_ZERO_ADDRESS
|
|
1661
|
+
}
|
|
1662
|
+
));
|
|
1663
|
+
locator.register(SimpleTimeSyncViewer.factory(
|
|
1664
|
+
SimpleTimeSyncViewer.dependencies,
|
|
1665
|
+
{}
|
|
1666
|
+
));
|
|
1730
1667
|
}
|
|
1731
1668
|
return locator;
|
|
1732
1669
|
}
|
|
1733
|
-
__name(initEvmProvidersIfAvailable, "initEvmProvidersIfAvailable");
|
|
1734
1670
|
|
|
1735
1671
|
// src/node/init/initFinalizationArchivistIfNeeded.ts
|
|
1736
1672
|
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
1737
1673
|
import { createBootstrapHead } from "@xyo-network/chain-sdk";
|
|
1738
1674
|
import { Account } from "@xyo-network/sdk-js";
|
|
1739
|
-
import {
|
|
1675
|
+
import {
|
|
1676
|
+
asAttoXL1,
|
|
1677
|
+
findMostRecentBlock,
|
|
1678
|
+
flattenHydratedBlock
|
|
1679
|
+
} from "@xyo-network/xl1-sdk";
|
|
1740
1680
|
async function initFinalizationArchivistIfNeeded(archivist, config, account, options = {}) {
|
|
1741
1681
|
const configuredChainId = config.chain.id;
|
|
1742
1682
|
const possibleHead = await findMostRecentBlock(archivist);
|
|
@@ -1752,18 +1692,19 @@ async function initFinalizationArchivistIfNeeded(archivist, config, account, opt
|
|
|
1752
1692
|
if (options.onInsecureGenesisConfirm) await options.onInsecureGenesisConfirm();
|
|
1753
1693
|
}
|
|
1754
1694
|
const genesisRewardAddress = await resolveGenesisRewardAddress(config);
|
|
1755
|
-
const chain = await createBootstrapHead(
|
|
1695
|
+
const chain = await createBootstrapHead(
|
|
1696
|
+
account,
|
|
1697
|
+
possibleChainId,
|
|
1698
|
+
asAttoXL1(GENESIS_REWARD_AMOUNT),
|
|
1699
|
+
genesisRewardAddress
|
|
1700
|
+
);
|
|
1756
1701
|
const payloads = chain.flatMap((block) => flattenHydratedBlock(block));
|
|
1757
1702
|
await archivist.insert(payloads);
|
|
1758
1703
|
}
|
|
1759
1704
|
const head = possibleHead ?? assertEx6(await findMostRecentBlock(archivist), () => "No blocks found in chain archivist");
|
|
1760
1705
|
const chainId = assertEx6(possibleChainId, () => "Chain ID could not be determined");
|
|
1761
|
-
return [
|
|
1762
|
-
head,
|
|
1763
|
-
chainId
|
|
1764
|
-
];
|
|
1706
|
+
return [head, chainId];
|
|
1765
1707
|
}
|
|
1766
|
-
__name(initFinalizationArchivistIfNeeded, "initFinalizationArchivistIfNeeded");
|
|
1767
1708
|
|
|
1768
1709
|
// src/node/init/initFinalizedArchivist.ts
|
|
1769
1710
|
import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
|
|
@@ -1772,16 +1713,12 @@ async function initMongoFinalizedArchivist(config) {
|
|
|
1772
1713
|
...config.storage.mongo,
|
|
1773
1714
|
collection: "chain_validated"
|
|
1774
1715
|
};
|
|
1775
|
-
return await MongoDBArchivistV2.create({
|
|
1776
|
-
payloadSdkConfig
|
|
1777
|
-
});
|
|
1716
|
+
return await MongoDBArchivistV2.create({ payloadSdkConfig });
|
|
1778
1717
|
}
|
|
1779
|
-
__name(initMongoFinalizedArchivist, "initMongoFinalizedArchivist");
|
|
1780
1718
|
async function initFinalizedArchivist(config) {
|
|
1781
1719
|
const finalizedArchivist = await initMongoFinalizedArchivist(config);
|
|
1782
1720
|
return finalizedArchivist;
|
|
1783
1721
|
}
|
|
1784
|
-
__name(initFinalizedArchivist, "initFinalizedArchivist");
|
|
1785
1722
|
|
|
1786
1723
|
// src/node/init/initServerNode.ts
|
|
1787
1724
|
import { assertEx as assertEx7 } from "@xylabs/sdk-js";
|
|
@@ -1792,15 +1729,18 @@ import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
|
1792
1729
|
import { LmdbArchivistConfigSchema } from "@xyo-network/archivist-lmdb";
|
|
1793
1730
|
import { MongoDBArchivistV2 as MongoDBArchivistV22, MongoDBArchivistV2Deletable } from "@xyo-network/archivist-mongodb";
|
|
1794
1731
|
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
1795
|
-
import {
|
|
1732
|
+
import {
|
|
1733
|
+
AbstractModule,
|
|
1734
|
+
LoggerModuleStatusReporter,
|
|
1735
|
+
MemoryArchivist,
|
|
1736
|
+
MemorySentinel,
|
|
1737
|
+
ModuleFactoryLocator
|
|
1738
|
+
} from "@xyo-network/sdk-js";
|
|
1796
1739
|
import { hasMongoConfig as hasMongoConfig2 } from "@xyo-network/xl1-sdk";
|
|
1797
1740
|
|
|
1798
1741
|
// src/node/manifest/NamedLmdbArchivist.ts
|
|
1799
1742
|
import { LmdbArchivist } from "@xyo-network/archivist-lmdb";
|
|
1800
1743
|
var NamedLmdbArchivist = class extends LmdbArchivist {
|
|
1801
|
-
static {
|
|
1802
|
-
__name(this, "NamedLmdbArchivist");
|
|
1803
|
-
}
|
|
1804
1744
|
get dbName() {
|
|
1805
1745
|
return this.config.dbName ?? "xyo-chain";
|
|
1806
1746
|
}
|
|
@@ -1820,13 +1760,24 @@ var NamedLmdbArchivist = class extends LmdbArchivist {
|
|
|
1820
1760
|
};
|
|
1821
1761
|
|
|
1822
1762
|
// src/node/manifest/getLocator.ts
|
|
1823
|
-
var getLocator =
|
|
1763
|
+
var getLocator = async ({
|
|
1764
|
+
logger,
|
|
1765
|
+
traceProvider,
|
|
1766
|
+
meterProvider,
|
|
1767
|
+
config
|
|
1768
|
+
}) => {
|
|
1824
1769
|
if (isDefined2(logger)) AbstractModule.defaultLogger = logger;
|
|
1825
1770
|
const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : void 0;
|
|
1826
1771
|
const locator = new ModuleFactoryLocator();
|
|
1827
1772
|
const mongoConfig = config.storage?.mongo;
|
|
1828
1773
|
if (hasMongoConfig2(mongoConfig)) {
|
|
1829
|
-
const {
|
|
1774
|
+
const {
|
|
1775
|
+
connectionString: dbConnectionString,
|
|
1776
|
+
database: dbName,
|
|
1777
|
+
domain: dbDomain,
|
|
1778
|
+
password: dbPassword,
|
|
1779
|
+
username: dbUserName
|
|
1780
|
+
} = mongoConfig;
|
|
1830
1781
|
const payloadSdkConfig = {
|
|
1831
1782
|
dbConnectionString,
|
|
1832
1783
|
dbDomain,
|
|
@@ -1841,9 +1792,7 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1841
1792
|
traceProvider
|
|
1842
1793
|
};
|
|
1843
1794
|
locator.register(MongoDBArchivistV22.factory(params), void 0, true);
|
|
1844
|
-
locator.register(MongoDBArchivistV2Deletable.factory(params), {
|
|
1845
|
-
"network.xyo.storage.capabilities.delete": "enabled"
|
|
1846
|
-
}, false);
|
|
1795
|
+
locator.register(MongoDBArchivistV2Deletable.factory(params), { "network.xyo.storage.capabilities.delete": "enabled" }, false);
|
|
1847
1796
|
} else if (isDefined2(config.storage?.root)) {
|
|
1848
1797
|
const lmdbLocation = config.storage.root;
|
|
1849
1798
|
const lmdbConfig = {
|
|
@@ -1851,12 +1800,16 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1851
1800
|
location: lmdbLocation,
|
|
1852
1801
|
schema: LmdbArchivistConfigSchema
|
|
1853
1802
|
};
|
|
1854
|
-
locator.register(
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1803
|
+
locator.register(
|
|
1804
|
+
NamedLmdbArchivist.factory({
|
|
1805
|
+
config: lmdbConfig,
|
|
1806
|
+
meterProvider,
|
|
1807
|
+
statusReporter,
|
|
1808
|
+
traceProvider
|
|
1809
|
+
}),
|
|
1810
|
+
void 0,
|
|
1811
|
+
true
|
|
1812
|
+
);
|
|
1860
1813
|
}
|
|
1861
1814
|
locator.register(MemoryArchivist.factory({
|
|
1862
1815
|
traceProvider,
|
|
@@ -1874,7 +1827,7 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1874
1827
|
statusReporter
|
|
1875
1828
|
}));
|
|
1876
1829
|
return locator;
|
|
1877
|
-
}
|
|
1830
|
+
};
|
|
1878
1831
|
|
|
1879
1832
|
// src/node/manifest/loadNode.ts
|
|
1880
1833
|
import { ManifestWrapper } from "@xyo-network/sdk-js";
|
|
@@ -2078,7 +2031,7 @@ var PublicChildManifests = [
|
|
|
2078
2031
|
];
|
|
2079
2032
|
|
|
2080
2033
|
// src/node/manifest/loadNode.ts
|
|
2081
|
-
var loadNode =
|
|
2034
|
+
var loadNode = async (context, wallet) => {
|
|
2082
2035
|
const locator = await getLocator(context);
|
|
2083
2036
|
const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests);
|
|
2084
2037
|
const [node, ...childNodes] = await wrapper.loadNodes();
|
|
@@ -2087,45 +2040,45 @@ var loadNode = /* @__PURE__ */ __name(async (context, wallet) => {
|
|
|
2087
2040
|
await Promise.all(childNodes.map((childNode) => node.attach(childNode.address, true)));
|
|
2088
2041
|
}
|
|
2089
2042
|
return node;
|
|
2090
|
-
}
|
|
2043
|
+
};
|
|
2091
2044
|
|
|
2092
2045
|
// src/node/init/initServerNode.ts
|
|
2093
2046
|
async function writableChainArchivistFromNode(node) {
|
|
2094
|
-
return asArchivistInstance(
|
|
2095
|
-
|
|
2096
|
-
|
|
2047
|
+
return asArchivistInstance(
|
|
2048
|
+
await node.resolve("Chain:Validated"),
|
|
2049
|
+
{ required: true }
|
|
2050
|
+
);
|
|
2097
2051
|
}
|
|
2098
|
-
__name(writableChainArchivistFromNode, "writableChainArchivistFromNode");
|
|
2099
2052
|
async function readonlyChainArchivistFromNode(node) {
|
|
2100
|
-
return assertEx7(asArchivistInstance(
|
|
2101
|
-
|
|
2102
|
-
|
|
2053
|
+
return assertEx7(asArchivistInstance(
|
|
2054
|
+
await node.resolve("Chain:Validated"),
|
|
2055
|
+
{ required: true }
|
|
2056
|
+
));
|
|
2103
2057
|
}
|
|
2104
|
-
__name(readonlyChainArchivistFromNode, "readonlyChainArchivistFromNode");
|
|
2105
2058
|
async function pendingTransactionsArchivistFromNode(node) {
|
|
2106
|
-
return asArchivistInstance(
|
|
2107
|
-
|
|
2108
|
-
|
|
2059
|
+
return asArchivistInstance(
|
|
2060
|
+
await node.resolve("XYOChain:Pending:Transactions"),
|
|
2061
|
+
{ required: true }
|
|
2062
|
+
);
|
|
2109
2063
|
}
|
|
2110
|
-
__name(pendingTransactionsArchivistFromNode, "pendingTransactionsArchivistFromNode");
|
|
2111
2064
|
async function pendingBlocksArchivistFromNode(node) {
|
|
2112
|
-
return asArchivistInstance(
|
|
2113
|
-
|
|
2114
|
-
|
|
2065
|
+
return asArchivistInstance(
|
|
2066
|
+
await node.resolve("XYOChain:Pending:Blocks"),
|
|
2067
|
+
{ required: true }
|
|
2068
|
+
);
|
|
2115
2069
|
}
|
|
2116
|
-
__name(pendingBlocksArchivistFromNode, "pendingBlocksArchivistFromNode");
|
|
2117
2070
|
async function rejectedBlocksArchivistFromNode(node) {
|
|
2118
|
-
return asArchivistInstance(
|
|
2119
|
-
|
|
2120
|
-
|
|
2071
|
+
return asArchivistInstance(
|
|
2072
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedBlocks"),
|
|
2073
|
+
{ required: true }
|
|
2074
|
+
);
|
|
2121
2075
|
}
|
|
2122
|
-
__name(rejectedBlocksArchivistFromNode, "rejectedBlocksArchivistFromNode");
|
|
2123
2076
|
async function rejectedTransactionsArchivistFromNode(node) {
|
|
2124
|
-
return asArchivistInstance(
|
|
2125
|
-
|
|
2126
|
-
|
|
2077
|
+
return asArchivistInstance(
|
|
2078
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedTransactions"),
|
|
2079
|
+
{ required: true }
|
|
2080
|
+
);
|
|
2127
2081
|
}
|
|
2128
|
-
__name(rejectedTransactionsArchivistFromNode, "rejectedTransactionsArchivistFromNode");
|
|
2129
2082
|
async function initServerNode(context, wallet, providedNode) {
|
|
2130
2083
|
const node = providedNode ?? await loadNode(context, wallet);
|
|
2131
2084
|
assertEx7(await node.start(), () => "Failed to start node");
|
|
@@ -2145,7 +2098,6 @@ async function initServerNode(context, wallet, providedNode) {
|
|
|
2145
2098
|
rejectedTransactionsArchivist
|
|
2146
2099
|
};
|
|
2147
2100
|
}
|
|
2148
|
-
__name(initServerNode, "initServerNode");
|
|
2149
2101
|
|
|
2150
2102
|
// src/node/init/initTransferSummaryMap.ts
|
|
2151
2103
|
import { BaseMongoSdk as BaseMongoSdk2 } from "@xylabs/mongo";
|
|
@@ -2155,7 +2107,13 @@ import { hasMongoConfig as hasMongoConfig3, MemoryMap as MemoryMap2 } from "@xyo
|
|
|
2155
2107
|
async function initTransferSummaryMap({ logger, config }) {
|
|
2156
2108
|
const mongoConfig = config.storage?.mongo;
|
|
2157
2109
|
if (hasMongoConfig3(mongoConfig)) {
|
|
2158
|
-
const {
|
|
2110
|
+
const {
|
|
2111
|
+
connectionString: dbConnectionString,
|
|
2112
|
+
database: dbName,
|
|
2113
|
+
domain: dbDomain,
|
|
2114
|
+
password: dbPassword,
|
|
2115
|
+
username: dbUserName
|
|
2116
|
+
} = mongoConfig;
|
|
2159
2117
|
const payloadSdkConfig = {
|
|
2160
2118
|
dbConnectionString,
|
|
2161
2119
|
dbDomain,
|
|
@@ -2163,16 +2121,10 @@ async function initTransferSummaryMap({ logger, config }) {
|
|
|
2163
2121
|
dbPassword,
|
|
2164
2122
|
dbUserName
|
|
2165
2123
|
};
|
|
2166
|
-
const sdkTransferSummaryMap = new BaseMongoSdk2({
|
|
2167
|
-
...payloadSdkConfig,
|
|
2168
|
-
collection: "transfer_summary_map"
|
|
2169
|
-
});
|
|
2124
|
+
const sdkTransferSummaryMap = new BaseMongoSdk2({ ...payloadSdkConfig, collection: "transfer_summary_map" });
|
|
2170
2125
|
const result = await MongoMap2.create({
|
|
2171
2126
|
sdk: sdkTransferSummaryMap,
|
|
2172
|
-
getCache: {
|
|
2173
|
-
enabled: true,
|
|
2174
|
-
maxEntries: 5e3
|
|
2175
|
-
}
|
|
2127
|
+
getCache: { enabled: true, maxEntries: 5e3 }
|
|
2176
2128
|
});
|
|
2177
2129
|
assertEx8(await result.start(), () => "Failed to start transfer summary map");
|
|
2178
2130
|
return result;
|
|
@@ -2181,26 +2133,24 @@ async function initTransferSummaryMap({ logger, config }) {
|
|
|
2181
2133
|
return new MemoryMap2();
|
|
2182
2134
|
}
|
|
2183
2135
|
}
|
|
2184
|
-
__name(initTransferSummaryMap, "initTransferSummaryMap");
|
|
2185
2136
|
|
|
2186
2137
|
// src/node/config/capabilities/backings/buildChainStoreBacking.ts
|
|
2187
2138
|
import { asArchivistInstance as asArchivistInstance2 } from "@xyo-network/sdk-js";
|
|
2188
2139
|
async function buildChainStoreBacking(node, mode, options) {
|
|
2189
|
-
const readonlyArchivist = asArchivistInstance2(
|
|
2190
|
-
|
|
2191
|
-
|
|
2140
|
+
const readonlyArchivist = asArchivistInstance2(
|
|
2141
|
+
await node.resolve("Chain:Validated"),
|
|
2142
|
+
{ required: true }
|
|
2143
|
+
);
|
|
2192
2144
|
if (mode === "read") {
|
|
2193
|
-
return {
|
|
2194
|
-
mode,
|
|
2195
|
-
readonlyArchivist
|
|
2196
|
-
};
|
|
2145
|
+
return { mode, readonlyArchivist };
|
|
2197
2146
|
}
|
|
2198
2147
|
if (!options) {
|
|
2199
2148
|
throw new Error("buildChainStoreBacking(write) requires options { actorConfig, wallet }");
|
|
2200
2149
|
}
|
|
2201
|
-
const writableArchivist = asArchivistInstance2(
|
|
2202
|
-
|
|
2203
|
-
|
|
2150
|
+
const writableArchivist = asArchivistInstance2(
|
|
2151
|
+
await node.resolve("Chain:Validated"),
|
|
2152
|
+
{ required: true }
|
|
2153
|
+
);
|
|
2204
2154
|
await initFinalizationArchivistIfNeeded(writableArchivist, options.actorConfig, options.wallet, {
|
|
2205
2155
|
logger: options.logger,
|
|
2206
2156
|
onInsecureGenesisConfirm: options.onInsecureGenesisConfirm
|
|
@@ -2211,24 +2161,24 @@ async function buildChainStoreBacking(node, mode, options) {
|
|
|
2211
2161
|
writableArchivist
|
|
2212
2162
|
};
|
|
2213
2163
|
}
|
|
2214
|
-
__name(buildChainStoreBacking, "buildChainStoreBacking");
|
|
2215
2164
|
|
|
2216
2165
|
// src/node/config/capabilities/backings/buildDlqStoreBacking.ts
|
|
2217
2166
|
import { asArchivistInstance as asArchivistInstance3 } from "@xyo-network/sdk-js";
|
|
2218
2167
|
async function buildDlqStoreBacking(node, mode) {
|
|
2219
|
-
const rejectedBlocksArchivist = asArchivistInstance3(
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2168
|
+
const rejectedBlocksArchivist = asArchivistInstance3(
|
|
2169
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedBlocks"),
|
|
2170
|
+
{ required: true }
|
|
2171
|
+
);
|
|
2172
|
+
const rejectedTransactionsArchivist = asArchivistInstance3(
|
|
2173
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedTransactions"),
|
|
2174
|
+
{ required: true }
|
|
2175
|
+
);
|
|
2225
2176
|
return {
|
|
2226
2177
|
mode,
|
|
2227
2178
|
rejectedBlocksArchivist,
|
|
2228
2179
|
rejectedTransactionsArchivist
|
|
2229
2180
|
};
|
|
2230
2181
|
}
|
|
2231
|
-
__name(buildDlqStoreBacking, "buildDlqStoreBacking");
|
|
2232
2182
|
|
|
2233
2183
|
// src/node/config/capabilities/backings/buildIndexerStoreBacking.ts
|
|
2234
2184
|
import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
@@ -2241,39 +2191,40 @@ async function buildIndexerStoreBacking(context, mode) {
|
|
|
2241
2191
|
transfersSummaryMap
|
|
2242
2192
|
};
|
|
2243
2193
|
}
|
|
2244
|
-
__name(buildIndexerStoreBacking, "buildIndexerStoreBacking");
|
|
2245
2194
|
|
|
2246
2195
|
// src/node/config/capabilities/backings/buildMempoolStoreBacking.ts
|
|
2247
2196
|
import { asArchivistInstance as asArchivistInstance4 } from "@xyo-network/sdk-js";
|
|
2248
2197
|
async function buildMempoolStoreBacking(node, mode) {
|
|
2249
|
-
const pendingTransactionsArchivist = asArchivistInstance4(
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2198
|
+
const pendingTransactionsArchivist = asArchivistInstance4(
|
|
2199
|
+
await node.resolve("XYOChain:Pending:Transactions"),
|
|
2200
|
+
{ required: true }
|
|
2201
|
+
);
|
|
2202
|
+
const pendingBlocksArchivist = asArchivistInstance4(
|
|
2203
|
+
await node.resolve("XYOChain:Pending:Blocks"),
|
|
2204
|
+
{ required: true }
|
|
2205
|
+
);
|
|
2255
2206
|
return {
|
|
2256
2207
|
mode,
|
|
2257
2208
|
pendingBlocksArchivist,
|
|
2258
2209
|
pendingTransactionsArchivist
|
|
2259
2210
|
};
|
|
2260
2211
|
}
|
|
2261
|
-
__name(buildMempoolStoreBacking, "buildMempoolStoreBacking");
|
|
2262
2212
|
|
|
2263
2213
|
// src/node/config/capabilities/backings/buildValidators.ts
|
|
2264
|
-
import {
|
|
2214
|
+
import {
|
|
2215
|
+
validateHydratedBlock,
|
|
2216
|
+
validateHydratedBlockState,
|
|
2217
|
+
validateHydratedTransactionState
|
|
2218
|
+
} from "@xyo-network/chain-validation";
|
|
2265
2219
|
import { BlockCumulativeBalanceValidatorFactory, validateTransaction } from "@xyo-network/xl1-sdk";
|
|
2266
2220
|
var cumulativeBalanceValidator = BlockCumulativeBalanceValidatorFactory();
|
|
2267
|
-
var validateHydratedBlockStateWithCumulativeBalance =
|
|
2221
|
+
var validateHydratedBlockStateWithCumulativeBalance = async (context, block) => {
|
|
2268
2222
|
const [stateErrors, cumulativeErrors] = await Promise.all([
|
|
2269
2223
|
validateHydratedBlockState(context, block),
|
|
2270
2224
|
cumulativeBalanceValidator(context, block)
|
|
2271
2225
|
]);
|
|
2272
|
-
return [
|
|
2273
|
-
|
|
2274
|
-
...cumulativeErrors
|
|
2275
|
-
];
|
|
2276
|
-
}, "validateHydratedBlockStateWithCumulativeBalance");
|
|
2226
|
+
return [...stateErrors, ...cumulativeErrors];
|
|
2227
|
+
};
|
|
2277
2228
|
function buildValidators() {
|
|
2278
2229
|
return {
|
|
2279
2230
|
blockProtocolValidator: validateHydratedBlock,
|
|
@@ -2282,7 +2233,6 @@ function buildValidators() {
|
|
|
2282
2233
|
transactionStateValidator: validateHydratedTransactionState
|
|
2283
2234
|
};
|
|
2284
2235
|
}
|
|
2285
|
-
__name(buildValidators, "buildValidators");
|
|
2286
2236
|
|
|
2287
2237
|
// src/node/config/capabilities/ProcessSharedResources.ts
|
|
2288
2238
|
async function buildProcessSharedResources(context, options) {
|
|
@@ -2318,7 +2268,6 @@ async function buildProcessSharedResources(context, options) {
|
|
|
2318
2268
|
writableChainArchivist: chainStore.writableArchivist
|
|
2319
2269
|
};
|
|
2320
2270
|
}
|
|
2321
|
-
__name(buildProcessSharedResources, "buildProcessSharedResources");
|
|
2322
2271
|
|
|
2323
2272
|
// src/node/config/capabilities/resolveProviders.ts
|
|
2324
2273
|
import { MissingCapabilityError, resolveProviders } from "@xyo-network/xl1-protocol-sdk";
|
|
@@ -2338,9 +2287,12 @@ async function locatorFromActorNeeds(context, actorNeeds, options = {}) {
|
|
|
2338
2287
|
...networkTier3Descriptors,
|
|
2339
2288
|
...options.extraDescriptors ?? []
|
|
2340
2289
|
];
|
|
2341
|
-
const plan = resolveProviders(
|
|
2342
|
-
|
|
2343
|
-
|
|
2290
|
+
const plan = resolveProviders(
|
|
2291
|
+
needs,
|
|
2292
|
+
candidates,
|
|
2293
|
+
resolutionContext,
|
|
2294
|
+
{ availableBackings: options.availableBackings }
|
|
2295
|
+
);
|
|
2344
2296
|
const locator = new ProviderFactoryLocator(context, {}, options.validateDepsOnRegister ?? false);
|
|
2345
2297
|
const factories = plan.selected.map((d) => d.build(resolutionContext)).filter((f) => f !== void 0);
|
|
2346
2298
|
locator.registerMany(factories);
|
|
@@ -2350,7 +2302,6 @@ async function locatorFromActorNeeds(context, actorNeeds, options = {}) {
|
|
|
2350
2302
|
process: process2
|
|
2351
2303
|
};
|
|
2352
2304
|
}
|
|
2353
|
-
__name(locatorFromActorNeeds, "locatorFromActorNeeds");
|
|
2354
2305
|
function unionNeeds(actorNeeds) {
|
|
2355
2306
|
const result = /* @__PURE__ */ new Set();
|
|
2356
2307
|
for (const needs of actorNeeds) {
|
|
@@ -2359,53 +2310,56 @@ function unionNeeds(actorNeeds) {
|
|
|
2359
2310
|
}
|
|
2360
2311
|
return result;
|
|
2361
2312
|
}
|
|
2362
|
-
__name(unionNeeds, "unionNeeds");
|
|
2363
2313
|
|
|
2364
2314
|
// src/node/config/locators/basicRemoteRunnerLocator.ts
|
|
2365
2315
|
import { isAccountInstance } from "@xyo-network/sdk-js";
|
|
2366
|
-
import {
|
|
2316
|
+
import {
|
|
2317
|
+
basicRemoteRunnerLocator as sdkBasicRemoteRunnerLocator,
|
|
2318
|
+
JsonRpcAccountBalanceViewer,
|
|
2319
|
+
JsonRpcXyoSigner,
|
|
2320
|
+
SimpleXyoSigner
|
|
2321
|
+
} from "@xyo-network/xl1-sdk";
|
|
2367
2322
|
function signerFactoryFromParam(signer) {
|
|
2368
2323
|
if (isAccountInstance(signer)) {
|
|
2369
|
-
return SimpleXyoSigner.factory(SimpleXyoSigner.dependencies, {
|
|
2370
|
-
account: signer
|
|
2371
|
-
});
|
|
2324
|
+
return SimpleXyoSigner.factory(SimpleXyoSigner.dependencies, { account: signer });
|
|
2372
2325
|
}
|
|
2373
|
-
return JsonRpcXyoSigner.factory(JsonRpcXyoSigner.dependencies, {
|
|
2374
|
-
transport: signer
|
|
2375
|
-
});
|
|
2326
|
+
return JsonRpcXyoSigner.factory(JsonRpcXyoSigner.dependencies, { transport: signer });
|
|
2376
2327
|
}
|
|
2377
|
-
__name(signerFactoryFromParam, "signerFactoryFromParam");
|
|
2378
2328
|
function basicRemoteRunnerLocator(name, remoteConfig, signer, dataLakeEndpoint, validators) {
|
|
2379
2329
|
const transport = isAccountInstance(signer) ? void 0 : signer;
|
|
2380
2330
|
return sdkBasicRemoteRunnerLocator(name, remoteConfig, transport, dataLakeEndpoint, {
|
|
2381
2331
|
additionalProviders: [
|
|
2382
|
-
JsonRpcAccountBalanceViewer.factory(
|
|
2332
|
+
JsonRpcAccountBalanceViewer.factory(
|
|
2333
|
+
JsonRpcAccountBalanceViewer.dependencies,
|
|
2334
|
+
{}
|
|
2335
|
+
)
|
|
2383
2336
|
],
|
|
2384
2337
|
signerFactory: signerFactoryFromParam(signer),
|
|
2385
2338
|
skipGatewayRunner: true,
|
|
2386
2339
|
validators
|
|
2387
2340
|
});
|
|
2388
2341
|
}
|
|
2389
|
-
__name(basicRemoteRunnerLocator, "basicRemoteRunnerLocator");
|
|
2390
2342
|
|
|
2391
2343
|
// src/node/config/locators/basicRemoteViewerLocator.ts
|
|
2392
|
-
import {
|
|
2344
|
+
import {
|
|
2345
|
+
basicRemoteViewerLocator as sdkBasicRemoteViewerLocator,
|
|
2346
|
+
JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer2
|
|
2347
|
+
} from "@xyo-network/xl1-sdk";
|
|
2393
2348
|
function basicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, validators) {
|
|
2394
2349
|
return sdkBasicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, {
|
|
2395
2350
|
additionalProviders: [
|
|
2396
|
-
JsonRpcAccountBalanceViewer2.factory(
|
|
2351
|
+
JsonRpcAccountBalanceViewer2.factory(
|
|
2352
|
+
JsonRpcAccountBalanceViewer2.dependencies,
|
|
2353
|
+
{}
|
|
2354
|
+
)
|
|
2397
2355
|
],
|
|
2398
2356
|
validators
|
|
2399
2357
|
});
|
|
2400
2358
|
}
|
|
2401
|
-
__name(basicRemoteViewerLocator, "basicRemoteViewerLocator");
|
|
2402
2359
|
|
|
2403
2360
|
// src/node/config/locators/buildStatelessApiLocator.ts
|
|
2404
2361
|
var STATELESS_BACKINGS = [
|
|
2405
|
-
{
|
|
2406
|
-
backing: "network",
|
|
2407
|
-
mode: "read"
|
|
2408
|
-
}
|
|
2362
|
+
{ backing: "network", mode: "read" }
|
|
2409
2363
|
];
|
|
2410
2364
|
async function buildStatelessApiLocator(context, needs) {
|
|
2411
2365
|
const stubProcess = {};
|
|
@@ -2415,7 +2369,6 @@ async function buildStatelessApiLocator(context, needs) {
|
|
|
2415
2369
|
});
|
|
2416
2370
|
return result.locator;
|
|
2417
2371
|
}
|
|
2418
|
-
__name(buildStatelessApiLocator, "buildStatelessApiLocator");
|
|
2419
2372
|
|
|
2420
2373
|
// src/node/config/locators/telemetryContextFromConfig.ts
|
|
2421
2374
|
import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
@@ -2428,22 +2381,16 @@ async function telemetryContextFromConfig(config, serviceName, serviceVersion, d
|
|
|
2428
2381
|
serviceVersion
|
|
2429
2382
|
},
|
|
2430
2383
|
otlpEndpoint,
|
|
2431
|
-
metricsConfig: {
|
|
2432
|
-
endpoint,
|
|
2433
|
-
port
|
|
2434
|
-
}
|
|
2384
|
+
metricsConfig: { endpoint, port }
|
|
2435
2385
|
});
|
|
2436
2386
|
}
|
|
2437
|
-
__name(telemetryContextFromConfig, "telemetryContextFromConfig");
|
|
2438
2387
|
|
|
2439
2388
|
// src/node/config/locators/contextFromConfigWithoutLocator.ts
|
|
2440
2389
|
async function contextFromConfigWithoutLocator(config, logger, serviceName, serviceVersion, defaultScrapePort) {
|
|
2441
2390
|
const singletons = {};
|
|
2442
2391
|
const caches = {};
|
|
2443
2392
|
const telemetryConfig = await telemetryContextFromConfig(config, serviceName, serviceVersion, defaultScrapePort);
|
|
2444
|
-
const statusReporter = initStatusReporter({
|
|
2445
|
-
logger
|
|
2446
|
-
});
|
|
2393
|
+
const statusReporter = initStatusReporter({ logger });
|
|
2447
2394
|
return {
|
|
2448
2395
|
...telemetryConfig,
|
|
2449
2396
|
config,
|
|
@@ -2453,10 +2400,23 @@ async function contextFromConfigWithoutLocator(config, logger, serviceName, serv
|
|
|
2453
2400
|
statusReporter
|
|
2454
2401
|
};
|
|
2455
2402
|
}
|
|
2456
|
-
__name(contextFromConfigWithoutLocator, "contextFromConfigWithoutLocator");
|
|
2457
2403
|
|
|
2458
2404
|
// src/node/config/locators/localLocatorFromConfig.ts
|
|
2459
|
-
import {
|
|
2405
|
+
import {
|
|
2406
|
+
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
2407
|
+
BlockValidationViewerMoniker as BlockValidationViewerMoniker2,
|
|
2408
|
+
BlockViewerMoniker as BlockViewerMoniker2,
|
|
2409
|
+
DeadLetterQueueRunnerMoniker as DeadLetterQueueRunnerMoniker2,
|
|
2410
|
+
DeadLetterQueueViewerMoniker as DeadLetterQueueViewerMoniker2,
|
|
2411
|
+
FinalizationRunnerMoniker as FinalizationRunnerMoniker2,
|
|
2412
|
+
FinalizationViewerMoniker as FinalizationViewerMoniker2,
|
|
2413
|
+
MempoolRunnerMoniker as MempoolRunnerMoniker2,
|
|
2414
|
+
MempoolViewerMoniker as MempoolViewerMoniker2,
|
|
2415
|
+
TransactionValidationViewerMoniker as TransactionValidationViewerMoniker2,
|
|
2416
|
+
TransactionViewerMoniker as TransactionViewerMoniker2,
|
|
2417
|
+
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker2,
|
|
2418
|
+
XyoViewerMoniker as XyoViewerMoniker2
|
|
2419
|
+
} from "@xyo-network/xl1-sdk";
|
|
2460
2420
|
var XyoConnectionMoniker2 = "XyoConnection";
|
|
2461
2421
|
var LOCAL_LEGACY_NEEDS = {
|
|
2462
2422
|
required: [
|
|
@@ -2478,21 +2438,30 @@ var LOCAL_LEGACY_NEEDS = {
|
|
|
2478
2438
|
]
|
|
2479
2439
|
};
|
|
2480
2440
|
async function localLocatorFromConfig(context, validateDepsOnRegister = false, onInsecureGenesisConfirm) {
|
|
2481
|
-
const result = await locatorFromActorNeeds(context, [
|
|
2482
|
-
LOCAL_LEGACY_NEEDS
|
|
2483
|
-
], {
|
|
2441
|
+
const result = await locatorFromActorNeeds(context, [LOCAL_LEGACY_NEEDS], {
|
|
2484
2442
|
onInsecureGenesisConfirm,
|
|
2485
2443
|
validateDepsOnRegister
|
|
2486
2444
|
});
|
|
2487
2445
|
return result.locator;
|
|
2488
2446
|
}
|
|
2489
|
-
__name(localLocatorFromConfig, "localLocatorFromConfig");
|
|
2490
2447
|
|
|
2491
2448
|
// src/node/config/locators/locatorsFromConfig.ts
|
|
2492
2449
|
import { deepMerge as deepMerge3 } from "@xylabs/sdk-js";
|
|
2493
2450
|
|
|
2494
2451
|
// src/node/config/locators/actors/apiLocatorFromConfig.ts
|
|
2495
|
-
import {
|
|
2452
|
+
import {
|
|
2453
|
+
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
2454
|
+
BlockViewerMoniker as BlockViewerMoniker3,
|
|
2455
|
+
FinalizationViewerMoniker as FinalizationViewerMoniker3,
|
|
2456
|
+
MempoolViewerMoniker as MempoolViewerMoniker3,
|
|
2457
|
+
ProviderFactoryLocator as ProviderFactoryLocator2,
|
|
2458
|
+
SimpleXyoConnectionRunner,
|
|
2459
|
+
SimpleXyoGateway,
|
|
2460
|
+
SimpleXyoRunner,
|
|
2461
|
+
TransactionViewerMoniker as TransactionViewerMoniker3,
|
|
2462
|
+
XyoConnectionMoniker as XyoConnectionMoniker3,
|
|
2463
|
+
XyoViewerMoniker as XyoViewerMoniker3
|
|
2464
|
+
} from "@xyo-network/xl1-sdk";
|
|
2496
2465
|
var API_NEEDS = {
|
|
2497
2466
|
required: [
|
|
2498
2467
|
AccountBalanceViewerMoniker3,
|
|
@@ -2506,9 +2475,7 @@ var API_NEEDS = {
|
|
|
2506
2475
|
};
|
|
2507
2476
|
async function apiLocatorFromConfig(context, parent) {
|
|
2508
2477
|
if (context.config.stateless) {
|
|
2509
|
-
const locator2 = await buildStatelessApiLocator(context, [
|
|
2510
|
-
API_NEEDS
|
|
2511
|
-
]);
|
|
2478
|
+
const locator2 = await buildStatelessApiLocator(context, [API_NEEDS]);
|
|
2512
2479
|
locator2.registerMany([
|
|
2513
2480
|
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
2514
2481
|
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
@@ -2517,10 +2484,7 @@ async function apiLocatorFromConfig(context, parent) {
|
|
|
2517
2484
|
locator2.freeze();
|
|
2518
2485
|
return locator2;
|
|
2519
2486
|
}
|
|
2520
|
-
const locator = new ProviderFactoryLocator2({
|
|
2521
|
-
...context,
|
|
2522
|
-
locator: parent
|
|
2523
|
-
});
|
|
2487
|
+
const locator = new ProviderFactoryLocator2({ ...context, locator: parent });
|
|
2524
2488
|
locator.registerMany([
|
|
2525
2489
|
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
2526
2490
|
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
@@ -2529,16 +2493,28 @@ async function apiLocatorFromConfig(context, parent) {
|
|
|
2529
2493
|
locator.freeze();
|
|
2530
2494
|
return locator;
|
|
2531
2495
|
}
|
|
2532
|
-
__name(apiLocatorFromConfig, "apiLocatorFromConfig");
|
|
2533
2496
|
|
|
2534
2497
|
// src/node/config/locators/actors/bridgeLocatorFromConfig.ts
|
|
2535
2498
|
import { isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
2536
|
-
import {
|
|
2499
|
+
import {
|
|
2500
|
+
JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer3,
|
|
2501
|
+
JsonRpcBlockViewer,
|
|
2502
|
+
JsonRpcFinalizationViewer,
|
|
2503
|
+
JsonRpcMempoolRunner,
|
|
2504
|
+
JsonRpcMempoolViewer,
|
|
2505
|
+
JsonRpcXyoRunner,
|
|
2506
|
+
JsonRpcXyoViewer,
|
|
2507
|
+
ProviderFactoryLocator as ProviderFactoryLocator3,
|
|
2508
|
+
RestDataLakeRunner,
|
|
2509
|
+
RestDataLakeViewer,
|
|
2510
|
+
SimpleStakeEventsViewer as SimpleStakeEventsViewer2,
|
|
2511
|
+
SimpleXyoConnectionRunner as SimpleXyoConnectionRunner2,
|
|
2512
|
+
SimpleXyoGatewayRunner,
|
|
2513
|
+
SimpleXyoRunner as SimpleXyoRunner2,
|
|
2514
|
+
SimpleXyoSigner as SimpleXyoSigner2
|
|
2515
|
+
} from "@xyo-network/xl1-sdk";
|
|
2537
2516
|
async function bridgeLocatorFromConfig(context, parent) {
|
|
2538
|
-
const locator = new ProviderFactoryLocator3({
|
|
2539
|
-
...context,
|
|
2540
|
-
locator: parent
|
|
2541
|
-
});
|
|
2517
|
+
const locator = new ProviderFactoryLocator3({ ...context, locator: parent });
|
|
2542
2518
|
const { config } = context;
|
|
2543
2519
|
const { dataLake } = config;
|
|
2544
2520
|
const signerAccount = await initActorWallet(context);
|
|
@@ -2546,8 +2522,14 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2546
2522
|
locator.registerMany([
|
|
2547
2523
|
JsonRpcMempoolViewer.factory(JsonRpcMempoolViewer.dependencies, {}),
|
|
2548
2524
|
JsonRpcMempoolRunner.factory(JsonRpcMempoolRunner.dependencies, {}),
|
|
2549
|
-
JsonRpcAccountBalanceViewer3.factory(
|
|
2550
|
-
|
|
2525
|
+
JsonRpcAccountBalanceViewer3.factory(
|
|
2526
|
+
JsonRpcAccountBalanceViewer3.dependencies,
|
|
2527
|
+
{}
|
|
2528
|
+
),
|
|
2529
|
+
JsonRpcFinalizationViewer.factory(
|
|
2530
|
+
JsonRpcFinalizationViewer.dependencies,
|
|
2531
|
+
{}
|
|
2532
|
+
),
|
|
2551
2533
|
JsonRpcBlockViewer.factory(JsonRpcBlockViewer.dependencies, {}),
|
|
2552
2534
|
JsonRpcXyoRunner.factory(JsonRpcXyoRunner.dependencies, {}),
|
|
2553
2535
|
JsonRpcXyoViewer.factory(JsonRpcXyoViewer.dependencies, {})
|
|
@@ -2559,12 +2541,8 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2559
2541
|
case "rest": {
|
|
2560
2542
|
const { url: endpoint } = dataLake;
|
|
2561
2543
|
locator.registerMany([
|
|
2562
|
-
RestDataLakeRunner.factory(RestDataLakeRunner.dependencies, {
|
|
2563
|
-
|
|
2564
|
-
}),
|
|
2565
|
-
RestDataLakeViewer.factory(RestDataLakeViewer.dependencies, {
|
|
2566
|
-
endpoint
|
|
2567
|
-
})
|
|
2544
|
+
RestDataLakeRunner.factory(RestDataLakeRunner.dependencies, { endpoint }),
|
|
2545
|
+
RestDataLakeViewer.factory(RestDataLakeViewer.dependencies, { endpoint })
|
|
2568
2546
|
]);
|
|
2569
2547
|
break;
|
|
2570
2548
|
}
|
|
@@ -2574,12 +2552,8 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2574
2552
|
}
|
|
2575
2553
|
}
|
|
2576
2554
|
locator.registerMany([
|
|
2577
|
-
SimpleStakeEventsViewer2.factory(SimpleStakeEventsViewer2.dependencies, {
|
|
2578
|
-
|
|
2579
|
-
}),
|
|
2580
|
-
SimpleXyoSigner2.factory(SimpleXyoSigner2.dependencies, {
|
|
2581
|
-
account: signerAccount
|
|
2582
|
-
}),
|
|
2555
|
+
SimpleStakeEventsViewer2.factory(SimpleStakeEventsViewer2.dependencies, { positions: [] }),
|
|
2556
|
+
SimpleXyoSigner2.factory(SimpleXyoSigner2.dependencies, { account: signerAccount }),
|
|
2583
2557
|
SimpleXyoRunner2.factory(SimpleXyoRunner2.dependencies, {}),
|
|
2584
2558
|
SimpleXyoConnectionRunner2.factory(SimpleXyoConnectionRunner2.dependencies, {}),
|
|
2585
2559
|
SimpleXyoGatewayRunner.factory(SimpleXyoGatewayRunner.dependencies, {})
|
|
@@ -2587,33 +2561,24 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2587
2561
|
locator.freeze();
|
|
2588
2562
|
return locator;
|
|
2589
2563
|
}
|
|
2590
|
-
__name(bridgeLocatorFromConfig, "bridgeLocatorFromConfig");
|
|
2591
2564
|
|
|
2592
2565
|
// src/node/config/locators/actors/finalizerLocatorFromConfig.ts
|
|
2593
2566
|
import { ProviderFactoryLocator as ProviderFactoryLocator4 } from "@xyo-network/xl1-sdk";
|
|
2594
2567
|
function finalizerLocatorFromConfig(context, parent) {
|
|
2595
|
-
const locator = new ProviderFactoryLocator4({
|
|
2596
|
-
...context,
|
|
2597
|
-
locator: parent
|
|
2598
|
-
});
|
|
2568
|
+
const locator = new ProviderFactoryLocator4({ ...context, locator: parent });
|
|
2599
2569
|
locator.registerMany([]);
|
|
2600
2570
|
locator.freeze();
|
|
2601
2571
|
return locator;
|
|
2602
2572
|
}
|
|
2603
|
-
__name(finalizerLocatorFromConfig, "finalizerLocatorFromConfig");
|
|
2604
2573
|
|
|
2605
2574
|
// src/node/config/locators/actors/mempoolLocatorFromConfig.ts
|
|
2606
2575
|
import { ProviderFactoryLocator as ProviderFactoryLocator5 } from "@xyo-network/xl1-sdk";
|
|
2607
2576
|
function mempoolLocatorFromConfig(context, parent) {
|
|
2608
|
-
const locator = new ProviderFactoryLocator5({
|
|
2609
|
-
...context,
|
|
2610
|
-
locator: parent
|
|
2611
|
-
});
|
|
2577
|
+
const locator = new ProviderFactoryLocator5({ ...context, locator: parent });
|
|
2612
2578
|
locator.registerMany([]);
|
|
2613
2579
|
locator.freeze();
|
|
2614
2580
|
return locator;
|
|
2615
2581
|
}
|
|
2616
|
-
__name(mempoolLocatorFromConfig, "mempoolLocatorFromConfig");
|
|
2617
2582
|
|
|
2618
2583
|
// src/node/config/locators/actors/producerLocatorFromConfig.ts
|
|
2619
2584
|
import { asAddress } from "@xylabs/sdk-js";
|
|
@@ -2622,57 +2587,72 @@ import { ProviderFactoryLocator as ProviderFactoryLocator6 } from "@xyo-network/
|
|
|
2622
2587
|
async function producerLocatorFromConfig(context, parent) {
|
|
2623
2588
|
const { logger, config } = context;
|
|
2624
2589
|
const account = await initActorWallet(context);
|
|
2625
|
-
const locator = new ProviderFactoryLocator6({
|
|
2626
|
-
...context,
|
|
2627
|
-
locator: parent
|
|
2628
|
-
});
|
|
2590
|
+
const locator = new ProviderFactoryLocator6({ ...context, locator: parent });
|
|
2629
2591
|
const rewardAddress = asAddress(config.rewardAddress ?? account.address, true);
|
|
2630
2592
|
logger?.info(`Using reward address ${rewardAddress}`);
|
|
2631
2593
|
if (rewardAddress === account.address) {
|
|
2632
2594
|
logger?.warn(`Using producer account address as reward address: ${account.address}`);
|
|
2633
2595
|
}
|
|
2634
|
-
const rejectedTransactionsProvider = await parent?.tryGetInstance(
|
|
2596
|
+
const rejectedTransactionsProvider = await parent?.tryGetInstance(
|
|
2597
|
+
RejectedTransactionsArchivistProviderMoniker
|
|
2598
|
+
);
|
|
2635
2599
|
const rejectedTransactionsArchivist = rejectedTransactionsProvider?.archivist;
|
|
2636
2600
|
locator.registerMany([
|
|
2637
|
-
SimpleBlockRunner.factory(
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2601
|
+
SimpleBlockRunner.factory(
|
|
2602
|
+
SimpleBlockRunner.dependencies,
|
|
2603
|
+
{
|
|
2604
|
+
account,
|
|
2605
|
+
rewardAddress,
|
|
2606
|
+
rejectedTransactionsArchivist,
|
|
2607
|
+
// ProducerConfigZod has always exposed `heartbeatInterval`, but until now
|
|
2608
|
+
// it was not wired anywhere. Threading it into the BlockRunner lets tests
|
|
2609
|
+
// (and operators who want denser heartbeat blocks) override the 1-h default.
|
|
2610
|
+
heartbeatInterval: config.heartbeatInterval
|
|
2611
|
+
}
|
|
2612
|
+
)
|
|
2646
2613
|
]);
|
|
2647
2614
|
locator.freeze();
|
|
2648
2615
|
return locator;
|
|
2649
2616
|
}
|
|
2650
|
-
__name(producerLocatorFromConfig, "producerLocatorFromConfig");
|
|
2651
2617
|
|
|
2652
2618
|
// src/node/config/locators/actors/rewardRedemptionLocatorFromConfig.ts
|
|
2653
|
-
import {
|
|
2619
|
+
import {
|
|
2620
|
+
JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer4,
|
|
2621
|
+
JsonRpcBlockViewer as JsonRpcBlockViewer2,
|
|
2622
|
+
JsonRpcFinalizationViewer as JsonRpcFinalizationViewer2,
|
|
2623
|
+
JsonRpcMempoolRunner as JsonRpcMempoolRunner2,
|
|
2624
|
+
JsonRpcMempoolViewer as JsonRpcMempoolViewer2,
|
|
2625
|
+
JsonRpcXyoRunner as JsonRpcXyoRunner2,
|
|
2626
|
+
JsonRpcXyoViewer as JsonRpcXyoViewer2,
|
|
2627
|
+
ProviderFactoryLocator as ProviderFactoryLocator7,
|
|
2628
|
+
SimpleXyoConnectionRunner as SimpleXyoConnectionRunner3,
|
|
2629
|
+
SimpleXyoGatewayRunner as SimpleXyoGatewayRunner2,
|
|
2630
|
+
SimpleXyoRunner as SimpleXyoRunner3,
|
|
2631
|
+
SimpleXyoSigner as SimpleXyoSigner3
|
|
2632
|
+
} from "@xyo-network/xl1-sdk";
|
|
2654
2633
|
async function rewardRedemptionLocatorFromConfig(context, parent) {
|
|
2655
|
-
const locator = new ProviderFactoryLocator7({
|
|
2656
|
-
...context,
|
|
2657
|
-
locator: parent
|
|
2658
|
-
});
|
|
2634
|
+
const locator = new ProviderFactoryLocator7({ ...context, locator: parent });
|
|
2659
2635
|
const { config } = context;
|
|
2660
2636
|
const account = await initActorWallet(context);
|
|
2661
2637
|
if (config.remote.rpc) {
|
|
2662
2638
|
locator.registerMany([
|
|
2663
2639
|
JsonRpcMempoolViewer2.factory(JsonRpcMempoolViewer2.dependencies, {}),
|
|
2664
2640
|
JsonRpcMempoolRunner2.factory(JsonRpcMempoolRunner2.dependencies, {}),
|
|
2665
|
-
JsonRpcAccountBalanceViewer4.factory(
|
|
2666
|
-
|
|
2641
|
+
JsonRpcAccountBalanceViewer4.factory(
|
|
2642
|
+
JsonRpcAccountBalanceViewer4.dependencies,
|
|
2643
|
+
{}
|
|
2644
|
+
),
|
|
2645
|
+
JsonRpcFinalizationViewer2.factory(
|
|
2646
|
+
JsonRpcFinalizationViewer2.dependencies,
|
|
2647
|
+
{}
|
|
2648
|
+
),
|
|
2667
2649
|
JsonRpcBlockViewer2.factory(JsonRpcBlockViewer2.dependencies, {}),
|
|
2668
2650
|
JsonRpcXyoRunner2.factory(JsonRpcXyoRunner2.dependencies, {}),
|
|
2669
2651
|
JsonRpcXyoViewer2.factory(JsonRpcXyoViewer2.dependencies, {})
|
|
2670
2652
|
]);
|
|
2671
2653
|
}
|
|
2672
2654
|
locator.registerMany([
|
|
2673
|
-
SimpleXyoSigner3.factory(SimpleXyoSigner3.dependencies, {
|
|
2674
|
-
account
|
|
2675
|
-
}),
|
|
2655
|
+
SimpleXyoSigner3.factory(SimpleXyoSigner3.dependencies, { account }),
|
|
2676
2656
|
SimpleXyoRunner3.factory(SimpleXyoRunner3.dependencies, {}),
|
|
2677
2657
|
SimpleXyoConnectionRunner3.factory(SimpleXyoConnectionRunner3.dependencies, {}),
|
|
2678
2658
|
SimpleXyoGatewayRunner2.factory(SimpleXyoGatewayRunner2.dependencies, {})
|
|
@@ -2680,30 +2660,47 @@ async function rewardRedemptionLocatorFromConfig(context, parent) {
|
|
|
2680
2660
|
locator.freeze();
|
|
2681
2661
|
return locator;
|
|
2682
2662
|
}
|
|
2683
|
-
__name(rewardRedemptionLocatorFromConfig, "rewardRedemptionLocatorFromConfig");
|
|
2684
2663
|
|
|
2685
2664
|
// src/node/config/locators/rootLocatorFromConfig.ts
|
|
2686
2665
|
import { commonLocatorFromConfig, remoteLocatorFromConfig } from "@xyo-network/xl1-sdk";
|
|
2687
2666
|
async function rootLocatorFromConfig(context, validateDepsOnRegister = false, onInsecureGenesisConfirm) {
|
|
2688
2667
|
const { config } = context;
|
|
2689
2668
|
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));
|
|
2669
|
+
const newLocator = await (config.remote.rpc ? remoteLocatorFromConfig(locator.context, validateDepsOnRegister) : localLocatorFromConfig(
|
|
2670
|
+
{ ...locator.context, config: { ...locator.context.config, ...context.config } },
|
|
2671
|
+
validateDepsOnRegister,
|
|
2672
|
+
onInsecureGenesisConfirm
|
|
2673
|
+
));
|
|
2697
2674
|
locator = newLocator;
|
|
2698
2675
|
locator = await initEvmProvidersIfAvailable(locator);
|
|
2699
2676
|
locator.freeze();
|
|
2700
2677
|
return locator;
|
|
2701
2678
|
}
|
|
2702
|
-
__name(rootLocatorFromConfig, "rootLocatorFromConfig");
|
|
2703
2679
|
|
|
2704
2680
|
// src/node/config/locators/sharedLocatorFromConfig.ts
|
|
2705
2681
|
import { deepMerge as deepMerge2 } from "@xylabs/sdk-js";
|
|
2706
|
-
import {
|
|
2682
|
+
import {
|
|
2683
|
+
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker4,
|
|
2684
|
+
BlockValidationViewerMoniker as BlockValidationViewerMoniker3,
|
|
2685
|
+
BlockViewerMoniker as BlockViewerMoniker4,
|
|
2686
|
+
commonLocatorFromConfig as commonLocatorFromConfig2,
|
|
2687
|
+
DeadLetterQueueRunnerMoniker as DeadLetterQueueRunnerMoniker3,
|
|
2688
|
+
FinalizationRunnerMoniker as FinalizationRunnerMoniker3,
|
|
2689
|
+
FinalizationViewerMoniker as FinalizationViewerMoniker4,
|
|
2690
|
+
MempoolRunnerMoniker as MempoolRunnerMoniker3,
|
|
2691
|
+
MempoolViewerMoniker as MempoolViewerMoniker4,
|
|
2692
|
+
ProviderFactoryLocator as ProviderFactoryLocator8,
|
|
2693
|
+
SimpleXyoConnectionRunner as SimpleXyoConnectionRunner4,
|
|
2694
|
+
SimpleXyoGateway as SimpleXyoGateway2,
|
|
2695
|
+
SimpleXyoRunner as SimpleXyoRunner4,
|
|
2696
|
+
TransactionValidationViewerMoniker as TransactionValidationViewerMoniker3,
|
|
2697
|
+
TransactionViewerMoniker as TransactionViewerMoniker4,
|
|
2698
|
+
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker3,
|
|
2699
|
+
XyoConnectionMoniker as XyoConnectionMoniker4,
|
|
2700
|
+
XyoGatewayMoniker,
|
|
2701
|
+
XyoRunnerMoniker,
|
|
2702
|
+
XyoViewerMoniker as XyoViewerMoniker4
|
|
2703
|
+
} from "@xyo-network/xl1-sdk";
|
|
2707
2704
|
var apiNeeds = {
|
|
2708
2705
|
required: [
|
|
2709
2706
|
AccountBalanceViewerMoniker4,
|
|
@@ -2735,9 +2732,7 @@ var finalizerNeeds = {
|
|
|
2735
2732
|
FinalizationRunnerMoniker3,
|
|
2736
2733
|
MempoolViewerMoniker4
|
|
2737
2734
|
],
|
|
2738
|
-
optional: [
|
|
2739
|
-
DeadLetterQueueRunnerMoniker3
|
|
2740
|
-
]
|
|
2735
|
+
optional: [DeadLetterQueueRunnerMoniker3]
|
|
2741
2736
|
};
|
|
2742
2737
|
var ACTOR_MIRRORS = {
|
|
2743
2738
|
api: apiNeeds,
|
|
@@ -2747,54 +2742,42 @@ var ACTOR_MIRRORS = {
|
|
|
2747
2742
|
var apiExtraDescriptors = [
|
|
2748
2743
|
{
|
|
2749
2744
|
id: "SimpleXyoRunner",
|
|
2750
|
-
satisfies: [
|
|
2751
|
-
XyoRunnerMoniker
|
|
2752
|
-
],
|
|
2745
|
+
satisfies: [XyoRunnerMoniker],
|
|
2753
2746
|
tier: 1,
|
|
2754
2747
|
backings: [],
|
|
2755
2748
|
surface: "node",
|
|
2756
|
-
preconditions:
|
|
2757
|
-
build:
|
|
2749
|
+
preconditions: () => true,
|
|
2750
|
+
build: () => SimpleXyoRunner4.factory(SimpleXyoRunner4.dependencies, {})
|
|
2758
2751
|
},
|
|
2759
2752
|
{
|
|
2760
2753
|
id: "SimpleXyoConnectionRunner",
|
|
2761
|
-
satisfies: [
|
|
2762
|
-
XyoConnectionMoniker4
|
|
2763
|
-
],
|
|
2754
|
+
satisfies: [XyoConnectionMoniker4],
|
|
2764
2755
|
// Same tier as `SimpleXyoConnectionViewer`; higher priority wins the
|
|
2765
2756
|
// `XyoConnection` moniker in any actor mix that includes the API.
|
|
2766
2757
|
tier: 1,
|
|
2767
2758
|
priority: 100,
|
|
2768
2759
|
backings: [],
|
|
2769
2760
|
surface: "node",
|
|
2770
|
-
preconditions:
|
|
2771
|
-
build:
|
|
2761
|
+
preconditions: () => true,
|
|
2762
|
+
build: () => SimpleXyoConnectionRunner4.factory(SimpleXyoConnectionRunner4.dependencies, {})
|
|
2772
2763
|
},
|
|
2773
2764
|
{
|
|
2774
2765
|
id: "SimpleXyoGateway",
|
|
2775
|
-
satisfies: [
|
|
2776
|
-
XyoGatewayMoniker
|
|
2777
|
-
],
|
|
2766
|
+
satisfies: [XyoGatewayMoniker],
|
|
2778
2767
|
tier: 1,
|
|
2779
2768
|
backings: [],
|
|
2780
2769
|
surface: "node",
|
|
2781
|
-
preconditions:
|
|
2782
|
-
build:
|
|
2770
|
+
preconditions: () => true,
|
|
2771
|
+
build: () => SimpleXyoGateway2.factory(SimpleXyoGateway2.dependencies, {})
|
|
2783
2772
|
}
|
|
2784
2773
|
];
|
|
2785
|
-
var ACTOR_EXTRA_DESCRIPTORS = {
|
|
2786
|
-
api: apiExtraDescriptors
|
|
2787
|
-
};
|
|
2774
|
+
var ACTOR_EXTRA_DESCRIPTORS = { api: apiExtraDescriptors };
|
|
2788
2775
|
var ACTOR_CONFIG_PARSERS = {
|
|
2789
2776
|
api: ApiConfigZod,
|
|
2790
2777
|
mempool: MempoolConfigZod,
|
|
2791
2778
|
finalizer: FinalizerConfigZod
|
|
2792
2779
|
};
|
|
2793
|
-
var SHARED_LOCATOR_SUPPORTED_ACTORS = [
|
|
2794
|
-
"api",
|
|
2795
|
-
"mempool",
|
|
2796
|
-
"finalizer"
|
|
2797
|
-
];
|
|
2780
|
+
var SHARED_LOCATOR_SUPPORTED_ACTORS = ["api", "mempool", "finalizer"];
|
|
2798
2781
|
function canUseSharedLocator(actors, config) {
|
|
2799
2782
|
if (actors.length === 0) return false;
|
|
2800
2783
|
if (config.remote?.rpc) return false;
|
|
@@ -2810,31 +2793,19 @@ function canUseSharedLocator(actors, config) {
|
|
|
2810
2793
|
return true;
|
|
2811
2794
|
});
|
|
2812
2795
|
}
|
|
2813
|
-
__name(canUseSharedLocator, "canUseSharedLocator");
|
|
2814
2796
|
async function sharedLocatorFromConfig(context, actors, config, options = {}) {
|
|
2815
2797
|
const unionNeeds2 = {
|
|
2816
2798
|
required: dedupe(actors.flatMap((a) => ACTOR_MIRRORS[a.name]?.required ?? [])),
|
|
2817
2799
|
optional: dedupe(actors.flatMap((a) => ACTOR_MIRRORS[a.name]?.optional ?? []))
|
|
2818
2800
|
};
|
|
2819
2801
|
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
|
-
};
|
|
2802
|
+
const commonContext = { ...context, config: { ...config, name: "_shared_common" } };
|
|
2827
2803
|
const commonLocator = await commonLocatorFromConfig2(commonContext);
|
|
2828
2804
|
const sharedContext = {
|
|
2829
2805
|
...commonLocator.context,
|
|
2830
|
-
config: {
|
|
2831
|
-
...config,
|
|
2832
|
-
name: "_shared"
|
|
2833
|
-
}
|
|
2806
|
+
config: { ...config, name: "_shared" }
|
|
2834
2807
|
};
|
|
2835
|
-
const result = await locatorFromActorNeeds(sharedContext, [
|
|
2836
|
-
unionNeeds2
|
|
2837
|
-
], {
|
|
2808
|
+
const result = await locatorFromActorNeeds(sharedContext, [unionNeeds2], {
|
|
2838
2809
|
extraDescriptors,
|
|
2839
2810
|
onInsecureGenesisConfirm: options.onInsecureGenesisConfirm,
|
|
2840
2811
|
validateDepsOnRegister: false
|
|
@@ -2853,18 +2824,11 @@ async function sharedLocatorFromConfig(context, actors, config, options = {}) {
|
|
|
2853
2824
|
view.freeze();
|
|
2854
2825
|
perActor[actor.name] = view;
|
|
2855
2826
|
}
|
|
2856
|
-
return {
|
|
2857
|
-
shared: sharedWithEvm,
|
|
2858
|
-
perActor
|
|
2859
|
-
};
|
|
2827
|
+
return { shared: sharedWithEvm, perActor };
|
|
2860
2828
|
}
|
|
2861
|
-
__name(sharedLocatorFromConfig, "sharedLocatorFromConfig");
|
|
2862
2829
|
function dedupe(items) {
|
|
2863
|
-
return [
|
|
2864
|
-
...new Set(items)
|
|
2865
|
-
];
|
|
2830
|
+
return [...new Set(items)];
|
|
2866
2831
|
}
|
|
2867
|
-
__name(dedupe, "dedupe");
|
|
2868
2832
|
|
|
2869
2833
|
// src/node/config/locators/locatorsFromConfig.ts
|
|
2870
2834
|
function allActorsAreSelfSufficient(actors, config) {
|
|
@@ -2875,75 +2839,68 @@ function allActorsAreSelfSufficient(actors, config) {
|
|
|
2875
2839
|
return merged.stateless === true;
|
|
2876
2840
|
});
|
|
2877
2841
|
}
|
|
2878
|
-
__name(allActorsAreSelfSufficient, "allActorsAreSelfSufficient");
|
|
2879
2842
|
async function locatorsFromConfig(context, { actors, ...config }, onInsecureGenesisConfirm) {
|
|
2880
2843
|
const result = {};
|
|
2881
2844
|
if (canUseSharedLocator(actors, config)) {
|
|
2882
|
-
const { perActor } = await sharedLocatorFromConfig(context, actors, config, {
|
|
2883
|
-
onInsecureGenesisConfirm
|
|
2884
|
-
});
|
|
2845
|
+
const { perActor } = await sharedLocatorFromConfig(context, actors, config, { onInsecureGenesisConfirm });
|
|
2885
2846
|
return perActor;
|
|
2886
2847
|
}
|
|
2887
2848
|
const skipRoot = allActorsAreSelfSufficient(actors, config);
|
|
2888
2849
|
if (!skipRoot) {
|
|
2889
|
-
const rootContext = {
|
|
2890
|
-
...context,
|
|
2891
|
-
config: {
|
|
2892
|
-
...config,
|
|
2893
|
-
name: "_root"
|
|
2894
|
-
}
|
|
2895
|
-
};
|
|
2850
|
+
const rootContext = { ...context, config: { ...config, name: "_root" } };
|
|
2896
2851
|
result._root = await rootLocatorFromConfig(rootContext, false, onInsecureGenesisConfirm);
|
|
2897
2852
|
}
|
|
2898
2853
|
for (const actorConfig of actors) {
|
|
2899
2854
|
switch (actorConfig.name) {
|
|
2900
2855
|
case "producer": {
|
|
2901
|
-
result[actorConfig.name] = await producerLocatorFromConfig(
|
|
2902
|
-
...context,
|
|
2903
|
-
|
|
2904
|
-
|
|
2856
|
+
result[actorConfig.name] = await producerLocatorFromConfig(
|
|
2857
|
+
{ ...context, config: ProducerConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2858
|
+
result._root
|
|
2859
|
+
);
|
|
2905
2860
|
break;
|
|
2906
2861
|
}
|
|
2907
2862
|
case "api": {
|
|
2908
|
-
result[actorConfig.name] = await apiLocatorFromConfig(
|
|
2909
|
-
...context,
|
|
2910
|
-
|
|
2911
|
-
|
|
2863
|
+
result[actorConfig.name] = await apiLocatorFromConfig(
|
|
2864
|
+
{ ...context, config: ApiConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2865
|
+
result._root
|
|
2866
|
+
);
|
|
2912
2867
|
break;
|
|
2913
2868
|
}
|
|
2914
2869
|
case "mempool": {
|
|
2915
|
-
result[actorConfig.name] = await mempoolLocatorFromConfig(
|
|
2916
|
-
...context,
|
|
2917
|
-
|
|
2918
|
-
|
|
2870
|
+
result[actorConfig.name] = await mempoolLocatorFromConfig(
|
|
2871
|
+
{ ...context, config: MempoolConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2872
|
+
result._root
|
|
2873
|
+
);
|
|
2919
2874
|
break;
|
|
2920
2875
|
}
|
|
2921
2876
|
case "finalizer": {
|
|
2922
|
-
result[actorConfig.name] = await finalizerLocatorFromConfig(
|
|
2923
|
-
...context,
|
|
2924
|
-
|
|
2925
|
-
|
|
2877
|
+
result[actorConfig.name] = await finalizerLocatorFromConfig(
|
|
2878
|
+
{ ...context, config: FinalizerConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2879
|
+
result._root
|
|
2880
|
+
);
|
|
2926
2881
|
break;
|
|
2927
2882
|
}
|
|
2928
2883
|
case "bridge": {
|
|
2929
|
-
result[actorConfig.name] = await bridgeLocatorFromConfig(
|
|
2930
|
-
...context,
|
|
2931
|
-
|
|
2932
|
-
|
|
2884
|
+
result[actorConfig.name] = await bridgeLocatorFromConfig(
|
|
2885
|
+
{ ...context, config: BridgeConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2886
|
+
result._root
|
|
2887
|
+
);
|
|
2933
2888
|
break;
|
|
2934
2889
|
}
|
|
2935
2890
|
case "rewardRedemption": {
|
|
2936
|
-
result[actorConfig.name] = await rewardRedemptionLocatorFromConfig(
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2891
|
+
result[actorConfig.name] = await rewardRedemptionLocatorFromConfig(
|
|
2892
|
+
{
|
|
2893
|
+
...context,
|
|
2894
|
+
config: RewardRedemptionConfigZod.parse(deepMerge3(config, actorConfig))
|
|
2895
|
+
},
|
|
2896
|
+
result._root
|
|
2897
|
+
);
|
|
2940
2898
|
break;
|
|
2941
2899
|
}
|
|
2942
2900
|
}
|
|
2943
2901
|
}
|
|
2944
2902
|
return result;
|
|
2945
2903
|
}
|
|
2946
|
-
__name(locatorsFromConfig, "locatorsFromConfig");
|
|
2947
2904
|
|
|
2948
2905
|
// src/node/config/tryParseConfig.ts
|
|
2949
2906
|
import { isDefined as isDefined4, isNull } from "@xylabs/sdk-js";
|
|
@@ -2952,27 +2909,27 @@ import { cosmiconfig } from "cosmiconfig";
|
|
|
2952
2909
|
var configName = "xyo";
|
|
2953
2910
|
var configSection = "xl1";
|
|
2954
2911
|
var ConfigFileNotFoundError = class extends Error {
|
|
2955
|
-
static {
|
|
2956
|
-
__name(this, "ConfigFileNotFoundError");
|
|
2957
|
-
}
|
|
2958
2912
|
constructor(configPath) {
|
|
2959
2913
|
super(`Config file not found: ${configPath}`);
|
|
2960
2914
|
this.name = "ConfigFileNotFoundError";
|
|
2961
2915
|
}
|
|
2962
2916
|
};
|
|
2963
|
-
var isMissingFileError =
|
|
2917
|
+
var isMissingFileError = (error) => {
|
|
2964
2918
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
2965
|
-
}
|
|
2966
|
-
var isRecord =
|
|
2919
|
+
};
|
|
2920
|
+
var isRecord = (value) => {
|
|
2967
2921
|
return typeof value === "object" && value !== null;
|
|
2968
|
-
}
|
|
2922
|
+
};
|
|
2969
2923
|
async function tryParseConfig(options) {
|
|
2970
2924
|
const { configPath, searchPlaces } = options ?? {};
|
|
2971
|
-
const explorer = cosmiconfig(
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2925
|
+
const explorer = cosmiconfig(
|
|
2926
|
+
configName,
|
|
2927
|
+
{
|
|
2928
|
+
cache: true,
|
|
2929
|
+
// loaders: { '.ts': TypeScriptLoader() },
|
|
2930
|
+
searchPlaces
|
|
2931
|
+
}
|
|
2932
|
+
);
|
|
2976
2933
|
let result;
|
|
2977
2934
|
if (isDefined4(configPath)) {
|
|
2978
2935
|
try {
|
|
@@ -2993,15 +2950,11 @@ async function tryParseConfig(options) {
|
|
|
2993
2950
|
const section = result[configSection];
|
|
2994
2951
|
if (isRecord(section)) {
|
|
2995
2952
|
const parsed = ConfigZod.loose().parse(section);
|
|
2996
|
-
return typeof section.mnemonic === "string" ? {
|
|
2997
|
-
...parsed,
|
|
2998
|
-
mnemonic: section.mnemonic
|
|
2999
|
-
} : parsed;
|
|
2953
|
+
return typeof section.mnemonic === "string" ? { ...parsed, mnemonic: section.mnemonic } : parsed;
|
|
3000
2954
|
}
|
|
3001
2955
|
}
|
|
3002
2956
|
return ConfigZod.parse({});
|
|
3003
2957
|
}
|
|
3004
|
-
__name(tryParseConfig, "tryParseConfig");
|
|
3005
2958
|
|
|
3006
2959
|
// src/node/index.ts
|
|
3007
2960
|
export * from "@xyo-network/chain-orchestration-evm";
|
|
@@ -3143,4 +3096,4 @@ export {
|
|
|
3143
3096
|
tryParseConfig,
|
|
3144
3097
|
unmetBackings
|
|
3145
3098
|
};
|
|
3146
|
-
//# sourceMappingURL=index.mjs.map
|
|
3099
|
+
//# sourceMappingURL=index.mjs.map
|