@xyo-network/chain-orchestration 1.22.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 +253 -324
- package/dist/browser/index.mjs.map +7 -1
- package/dist/browser/node/config/capabilities/defaultCapabilityRegistry.d.ts.map +1 -1
- package/dist/browser/node/config/capabilities/descriptors.d.ts.map +1 -1
- package/dist/browser/node/config/locators/index.d.ts +1 -0
- package/dist/browser/node/config/locators/index.d.ts.map +1 -1
- package/dist/browser/node/config/locators/locatorsFromConfig.d.ts.map +1 -1
- package/dist/browser/node/config/locators/sharedLocatorFromConfig.d.ts +68 -0
- package/dist/browser/node/config/locators/sharedLocatorFromConfig.d.ts.map +1 -0
- package/dist/browser/shared/config/actors/Mempool.d.ts +14 -0
- package/dist/browser/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/neutral/index.mjs +253 -324
- package/dist/neutral/index.mjs.map +7 -1
- package/dist/neutral/node/config/capabilities/defaultCapabilityRegistry.d.ts.map +1 -1
- package/dist/neutral/node/config/capabilities/descriptors.d.ts.map +1 -1
- package/dist/neutral/node/config/locators/index.d.ts +1 -0
- package/dist/neutral/node/config/locators/index.d.ts.map +1 -1
- package/dist/neutral/node/config/locators/locatorsFromConfig.d.ts.map +1 -1
- package/dist/neutral/node/config/locators/sharedLocatorFromConfig.d.ts +68 -0
- package/dist/neutral/node/config/locators/sharedLocatorFromConfig.d.ts.map +1 -0
- package/dist/neutral/shared/config/actors/Mempool.d.ts +14 -0
- package/dist/neutral/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/node/index.mjs +929 -772
- package/dist/node/index.mjs.map +7 -1
- package/dist/node/node/config/capabilities/defaultCapabilityRegistry.d.ts.map +1 -1
- package/dist/node/node/config/capabilities/descriptors.d.ts.map +1 -1
- package/dist/node/node/config/locators/index.d.ts +1 -0
- package/dist/node/node/config/locators/index.d.ts.map +1 -1
- package/dist/node/node/config/locators/locatorsFromConfig.d.ts.map +1 -1
- package/dist/node/node/config/locators/sharedLocatorFromConfig.d.ts +68 -0
- package/dist/node/node/config/locators/sharedLocatorFromConfig.d.ts.map +1 -0
- package/dist/node/shared/config/actors/Mempool.d.ts +14 -0
- package/dist/node/shared/config/actors/Mempool.d.ts.map +1 -1
- package/package.json +31 -40
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,38 +475,29 @@ 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;
|
|
486
492
|
var DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL = 1e3;
|
|
493
|
+
var DEFAULT_MEMPOOL_DEMOTION_THRESHOLD = 3;
|
|
494
|
+
var DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS = 0;
|
|
487
495
|
var MempoolConfigZod = HostActorConfigZod4.extend({
|
|
488
|
-
enabled: z5.union([
|
|
489
|
-
z5.string(),
|
|
490
|
-
z5.boolean()
|
|
491
|
-
]).default("false").transform((val, ctx) => {
|
|
496
|
+
enabled: z5.union([z5.string(), z5.boolean()]).default("false").transform((val, ctx) => {
|
|
492
497
|
if (typeof val === "boolean") return val;
|
|
493
498
|
const normalized = val.toLowerCase().trim();
|
|
494
|
-
if ([
|
|
495
|
-
|
|
496
|
-
"1",
|
|
497
|
-
"yes",
|
|
498
|
-
"on"
|
|
499
|
-
].includes(normalized)) return true;
|
|
500
|
-
if ([
|
|
501
|
-
"false",
|
|
502
|
-
"0",
|
|
503
|
-
"no",
|
|
504
|
-
"off"
|
|
505
|
-
].includes(normalized)) return false;
|
|
499
|
+
if (["true", "1", "yes", "on"].includes(normalized)) return true;
|
|
500
|
+
if (["false", "0", "no", "off"].includes(normalized)) return false;
|
|
506
501
|
ctx.addIssue({
|
|
507
502
|
code: "invalid_type",
|
|
508
503
|
expected: "boolean",
|
|
@@ -520,6 +515,16 @@ var MempoolConfigZod = HostActorConfigZod4.extend({
|
|
|
520
515
|
title: "mempool.blockPruneInterval",
|
|
521
516
|
type: "number"
|
|
522
517
|
}),
|
|
518
|
+
demotionThreshold: z5.coerce.number().int().positive().default(DEFAULT_MEMPOOL_DEMOTION_THRESHOLD).register(globalRegistry3, {
|
|
519
|
+
description: "Number of times a transaction may be handed out to producers without being included in a block before it is considered demoted",
|
|
520
|
+
title: "mempool.demotionThreshold",
|
|
521
|
+
type: "number"
|
|
522
|
+
}),
|
|
523
|
+
maxPendingTransactions: z5.coerce.number().int().nonnegative().default(DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS).register(globalRegistry3, {
|
|
524
|
+
description: "Maximum number of pending transactions in the pool. When exceeded, demoted transactions are evicted first, then oldest by sequence. 0 disables the cap.",
|
|
525
|
+
title: "mempool.maxPendingTransactions",
|
|
526
|
+
type: "number"
|
|
527
|
+
}),
|
|
523
528
|
transactionPruneInterval: z5.coerce.number().default(DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL).register(globalRegistry3, {
|
|
524
529
|
description: "The interval time (in milliseconds) between pending transaction prune attempts",
|
|
525
530
|
title: "mempool.transactionPruneInterval",
|
|
@@ -529,15 +534,18 @@ var MempoolConfigZod = HostActorConfigZod4.extend({
|
|
|
529
534
|
var isMempoolConfig = zodIsFactory4(MempoolConfigZod);
|
|
530
535
|
var asMempoolConfig = zodAsFactory4(MempoolConfigZod, "asMempoolConfig");
|
|
531
536
|
var toMempoolConfig = zodToFactory4(MempoolConfigZod, "toMempoolConfig");
|
|
532
|
-
var MempoolConfigContext = BaseConfigContextZod4.extend({
|
|
533
|
-
config: MempoolConfigZod
|
|
534
|
-
});
|
|
537
|
+
var MempoolConfigContext = BaseConfigContextZod4.extend({ config: MempoolConfigZod });
|
|
535
538
|
var isMempoolConfigContext = zodIsFactory4(MempoolConfigContext);
|
|
536
539
|
var asMempoolConfigContext = zodAsFactory4(MempoolConfigContext, "asMempoolConfigContext");
|
|
537
540
|
var toMempoolConfigContext = zodToFactory4(MempoolConfigContext, "toMempoolConfigContext");
|
|
538
541
|
|
|
539
542
|
// src/shared/config/actors/Producer.ts
|
|
540
|
-
import {
|
|
543
|
+
import {
|
|
544
|
+
AddressZod as AddressZod3,
|
|
545
|
+
zodAsFactory as zodAsFactory5,
|
|
546
|
+
zodIsFactory as zodIsFactory5,
|
|
547
|
+
zodToFactory as zodToFactory5
|
|
548
|
+
} from "@xylabs/sdk-js";
|
|
541
549
|
import { ActorConfigZod, BaseConfigContextZod as BaseConfigContextZod5 } from "@xyo-network/xl1-sdk";
|
|
542
550
|
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
543
551
|
var DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL = 1e4;
|
|
@@ -578,23 +586,23 @@ var ProducerConfigZod = ActorConfigZod.extend(z6.object({
|
|
|
578
586
|
var isProducerConfig = zodIsFactory5(ProducerConfigZod);
|
|
579
587
|
var asProducerConfig = zodAsFactory5(ProducerConfigZod, "asProducerConfig");
|
|
580
588
|
var toProducerConfig = zodToFactory5(ProducerConfigZod, "toProducerConfig");
|
|
581
|
-
var ProducerConfigContext = BaseConfigContextZod5.extend({
|
|
582
|
-
config: ProducerConfigZod
|
|
583
|
-
});
|
|
589
|
+
var ProducerConfigContext = BaseConfigContextZod5.extend({ config: ProducerConfigZod });
|
|
584
590
|
var isProducerConfigContext = zodIsFactory5(ProducerConfigContext);
|
|
585
591
|
var asProducerConfigContext = zodAsFactory5(ProducerConfigContext, "asProducerConfigContext");
|
|
586
592
|
var toProducerConfigContext = zodToFactory5(ProducerConfigContext, "toProducerConfigContext");
|
|
587
593
|
|
|
588
594
|
// src/shared/config/actors/RewardRedemption.ts
|
|
589
|
-
import {
|
|
595
|
+
import {
|
|
596
|
+
zodAsFactory as zodAsFactory6,
|
|
597
|
+
zodIsFactory as zodIsFactory6,
|
|
598
|
+
zodToFactory as zodToFactory6
|
|
599
|
+
} from "@xylabs/sdk-js";
|
|
590
600
|
import { BaseConfigContextZod as BaseConfigContextZod6, HostActorConfigZod as HostActorConfigZod5 } from "@xyo-network/xl1-sdk";
|
|
591
601
|
var RewardRedemptionConfigZod = HostActorConfigZod5.extend({});
|
|
592
602
|
var isRewardRedemptionConfig = zodIsFactory6(RewardRedemptionConfigZod);
|
|
593
603
|
var asRewardRedemptionConfig = zodAsFactory6(RewardRedemptionConfigZod, "asRewardRedemptionConfig");
|
|
594
604
|
var toRewardRedemptionConfig = zodToFactory6(RewardRedemptionConfigZod, "toRewardRedemptionConfig");
|
|
595
|
-
var RewardRedemptionConfigContext = BaseConfigContextZod6.extend({
|
|
596
|
-
config: RewardRedemptionConfigZod
|
|
597
|
-
});
|
|
605
|
+
var RewardRedemptionConfigContext = BaseConfigContextZod6.extend({ config: RewardRedemptionConfigZod });
|
|
598
606
|
var isRewardRedemptionConfigContext = zodIsFactory6(RewardRedemptionConfigContext);
|
|
599
607
|
var asRewardRedemptionConfigContext = zodAsFactory6(RewardRedemptionConfigContext, "asRewardRedemptionConfigContext");
|
|
600
608
|
var toRewardRedemptionConfigContext = zodToFactory6(RewardRedemptionConfigContext, "toRewardRedemptionConfigContext");
|
|
@@ -609,26 +617,27 @@ function mergeConfig({ actors, ...baseConfig }) {
|
|
|
609
617
|
})
|
|
610
618
|
};
|
|
611
619
|
}
|
|
612
|
-
__name(mergeConfig, "mergeConfig");
|
|
613
620
|
|
|
614
621
|
// src/shared/createDeclarationIntentBlock.ts
|
|
615
622
|
import { buildNextBlock } from "@xyo-network/chain-sdk";
|
|
616
623
|
import { createDeclarationIntent } from "@xyo-network/xl1-sdk";
|
|
617
624
|
async function createProducerChainStakeIntentBlock(prevBlock, producerAccount, range) {
|
|
618
|
-
const producerDeclarationPayload = createDeclarationIntent(
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
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
|
+
);
|
|
624
637
|
}
|
|
625
|
-
__name(createProducerChainStakeIntentBlock, "createProducerChainStakeIntentBlock");
|
|
626
638
|
|
|
627
639
|
// src/shared/host/implementation/DefaultHost.ts
|
|
628
640
|
var GenericHost = class {
|
|
629
|
-
static {
|
|
630
|
-
__name(this, "GenericHost");
|
|
631
|
-
}
|
|
632
641
|
services;
|
|
633
642
|
constructor(services) {
|
|
634
643
|
this.services = services;
|
|
@@ -645,9 +654,6 @@ var GenericHost = class {
|
|
|
645
654
|
|
|
646
655
|
// src/shared/host/implementation/DefaultServiceProvider.ts
|
|
647
656
|
var DefaultServiceProvider = class {
|
|
648
|
-
static {
|
|
649
|
-
__name(this, "DefaultServiceProvider");
|
|
650
|
-
}
|
|
651
657
|
_services;
|
|
652
658
|
constructor(services) {
|
|
653
659
|
this._services = services;
|
|
@@ -697,24 +703,19 @@ var activeWalletReport;
|
|
|
697
703
|
function getAccountLabel(actorName) {
|
|
698
704
|
return ACTOR_LABELS[actorName] ?? actorName;
|
|
699
705
|
}
|
|
700
|
-
__name(getAccountLabel, "getAccountLabel");
|
|
701
706
|
function clearResolvedWalletReport() {
|
|
702
707
|
activeWalletReport = void 0;
|
|
703
708
|
}
|
|
704
|
-
__name(clearResolvedWalletReport, "clearResolvedWalletReport");
|
|
705
709
|
function resolveActorAccountPath(actorName, actorConfig) {
|
|
706
710
|
if (actorConfig?.accountPath !== void 0) return actorConfig.accountPath;
|
|
707
711
|
return DEFAULT_ACTOR_ACCOUNT_PATH[actorName] ?? "0";
|
|
708
712
|
}
|
|
709
|
-
__name(resolveActorAccountPath, "resolveActorAccountPath");
|
|
710
713
|
function isAbsoluteAccountPath(accountPath) {
|
|
711
714
|
return accountPath.startsWith("m/");
|
|
712
715
|
}
|
|
713
|
-
__name(isAbsoluteAccountPath, "isAbsoluteAccountPath");
|
|
714
716
|
function expandAccountPath(accountPath, basePath = DEFAULT_WALLET_PATH) {
|
|
715
717
|
return isAbsoluteAccountPath(accountPath) ? accountPath : `${basePath}/${accountPath}`;
|
|
716
718
|
}
|
|
717
|
-
__name(expandAccountPath, "expandAccountPath");
|
|
718
719
|
async function deriveWalletAtPath(mnemonic, accountPath) {
|
|
719
720
|
if (isAbsoluteAccountPath(accountPath)) {
|
|
720
721
|
const seed = Mnemonic.fromPhrase(mnemonic).computeSeed();
|
|
@@ -725,15 +726,12 @@ async function deriveWalletAtPath(mnemonic, accountPath) {
|
|
|
725
726
|
const baseWallet = await generateXyoBaseWalletFromPhrase(mnemonic);
|
|
726
727
|
return await baseWallet.derivePath(accountPath);
|
|
727
728
|
}
|
|
728
|
-
__name(deriveWalletAtPath, "deriveWalletAtPath");
|
|
729
729
|
function getBuiltInDevMnemonic() {
|
|
730
730
|
return BUILT_IN_DEV_MNEMONIC;
|
|
731
731
|
}
|
|
732
|
-
__name(getBuiltInDevMnemonic, "getBuiltInDevMnemonic");
|
|
733
732
|
function getInsecureGenesisRewardMnemonic() {
|
|
734
733
|
return INSECURE_GENESIS_REWARD_MNEMONIC;
|
|
735
734
|
}
|
|
736
|
-
__name(getInsecureGenesisRewardMnemonic, "getInsecureGenesisRewardMnemonic");
|
|
737
735
|
function resolveRootWallet(configuration) {
|
|
738
736
|
const isConfigured = configuration.mnemonic !== void 0;
|
|
739
737
|
const mnemonic = configuration.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
@@ -746,8 +744,12 @@ function resolveRootWallet(configuration) {
|
|
|
746
744
|
mnemonicKind: isBuiltInDevMnemonic ? "built-in-dev" : "configured-root"
|
|
747
745
|
};
|
|
748
746
|
}
|
|
749
|
-
|
|
750
|
-
|
|
747
|
+
async function resolveWalletMetadata({
|
|
748
|
+
accountPath,
|
|
749
|
+
actorName,
|
|
750
|
+
mnemonic,
|
|
751
|
+
mnemonicKind
|
|
752
|
+
}) {
|
|
751
753
|
const account = await deriveWalletAtPath(mnemonic, accountPath);
|
|
752
754
|
return {
|
|
753
755
|
accountPath,
|
|
@@ -761,7 +763,6 @@ async function resolveWalletMetadata({ accountPath, actorName, mnemonic, mnemoni
|
|
|
761
763
|
usesBuiltInDevMnemonic: mnemonic === BUILT_IN_DEV_MNEMONIC
|
|
762
764
|
};
|
|
763
765
|
}
|
|
764
|
-
__name(resolveWalletMetadata, "resolveWalletMetadata");
|
|
765
766
|
async function resolveActorWallet(actorName, actorConfig, root) {
|
|
766
767
|
return await resolveWalletMetadata({
|
|
767
768
|
accountPath: resolveActorAccountPath(actorName, actorConfig),
|
|
@@ -770,11 +771,7 @@ async function resolveActorWallet(actorName, actorConfig, root) {
|
|
|
770
771
|
mnemonicKind: root.mnemonicKind
|
|
771
772
|
});
|
|
772
773
|
}
|
|
773
|
-
__name(resolveActorWallet, "resolveActorWallet");
|
|
774
774
|
var ActorMnemonicNotAllowedError = class extends Error {
|
|
775
|
-
static {
|
|
776
|
-
__name(this, "ActorMnemonicNotAllowedError");
|
|
777
|
-
}
|
|
778
775
|
actors;
|
|
779
776
|
constructor(actors) {
|
|
780
777
|
super([
|
|
@@ -789,14 +786,12 @@ function assertNoActorMnemonics(configuration) {
|
|
|
789
786
|
const offenders = configuration.actors.filter((actor) => typeof actor.mnemonic === "string").map((actor) => actor.name);
|
|
790
787
|
if (offenders.length > 0) throw new ActorMnemonicNotAllowedError(offenders);
|
|
791
788
|
}
|
|
792
|
-
__name(assertNoActorMnemonics, "assertNoActorMnemonics");
|
|
793
789
|
var DerivationPathCollisionError = class extends Error {
|
|
794
|
-
static {
|
|
795
|
-
__name(this, "DerivationPathCollisionError");
|
|
796
|
-
}
|
|
797
790
|
collisions;
|
|
798
791
|
constructor(collisions) {
|
|
799
|
-
const lines = Object.entries(collisions).map(
|
|
792
|
+
const lines = Object.entries(collisions).map(
|
|
793
|
+
([path, actors]) => ` - ${actors.join(", ")} \u2192 ${path}`
|
|
794
|
+
);
|
|
800
795
|
super([
|
|
801
796
|
"Two or more actors resolve to the same wallet derivation path:",
|
|
802
797
|
...lines,
|
|
@@ -807,10 +802,7 @@ var DerivationPathCollisionError = class extends Error {
|
|
|
807
802
|
}
|
|
808
803
|
};
|
|
809
804
|
function detectDerivationPathCollisions(requestedActors, configuration) {
|
|
810
|
-
const actorConfigMap = new Map(configuration.actors.map((actor) => [
|
|
811
|
-
actor.name,
|
|
812
|
-
actor
|
|
813
|
-
]));
|
|
805
|
+
const actorConfigMap = new Map(configuration.actors.map((actor) => [actor.name, actor]));
|
|
814
806
|
const bucketsByPath = /* @__PURE__ */ new Map();
|
|
815
807
|
for (const actorName of requestedActors) {
|
|
816
808
|
const accountPath = resolveActorAccountPath(actorName, actorConfigMap.get(actorName));
|
|
@@ -826,71 +818,57 @@ function detectDerivationPathCollisions(requestedActors, configuration) {
|
|
|
826
818
|
if (Object.keys(collisions).length === 0) return void 0;
|
|
827
819
|
return new DerivationPathCollisionError(collisions);
|
|
828
820
|
}
|
|
829
|
-
__name(detectDerivationPathCollisions, "detectDerivationPathCollisions");
|
|
830
821
|
async function resolveWalletReport(requestedActors, configuration) {
|
|
831
822
|
const root = resolveRootWallet(configuration);
|
|
832
|
-
const actorConfigMap = new Map(configuration.actors.map((actor) => [
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
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
|
+
);
|
|
837
827
|
const labelMap = /* @__PURE__ */ new Map();
|
|
838
828
|
for (const actor of resolvedActors) {
|
|
839
829
|
const labels = labelMap.get(actor.derivationPath) ?? [];
|
|
840
830
|
labels.push(actor.label);
|
|
841
831
|
labelMap.set(actor.derivationPath, labels);
|
|
842
832
|
}
|
|
843
|
-
const sharedAccounts = await Promise.all(
|
|
844
|
-
length: SHARED_ACCOUNT_REPORT_COUNT
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
label: labels?.join(", ") ?? `shared[${sharedIndex}]`
|
|
856
|
-
};
|
|
857
|
-
}));
|
|
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
|
+
);
|
|
858
845
|
return {
|
|
859
|
-
requestedActors: [
|
|
860
|
-
...requestedActors
|
|
861
|
-
],
|
|
846
|
+
requestedActors: [...requestedActors],
|
|
862
847
|
root,
|
|
863
848
|
sharedAccounts
|
|
864
849
|
};
|
|
865
850
|
}
|
|
866
|
-
__name(resolveWalletReport, "resolveWalletReport");
|
|
867
851
|
async function buildInsecureGenesisRewardAccounts() {
|
|
868
|
-
const accounts = await Promise.all(
|
|
869
|
-
length: SHARED_ACCOUNT_REPORT_COUNT
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
label: sharedIndex === 0 ? "genesisRewardAddress" : `genesisReward[${sharedIndex}]`
|
|
880
|
-
};
|
|
881
|
-
}));
|
|
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
|
+
);
|
|
882
863
|
return accounts;
|
|
883
864
|
}
|
|
884
|
-
__name(buildInsecureGenesisRewardAccounts, "buildInsecureGenesisRewardAccounts");
|
|
885
865
|
async function initializeResolvedWalletReport(requestedActors, configuration) {
|
|
886
866
|
activeWalletReport = await resolveWalletReport(requestedActors, configuration);
|
|
887
867
|
return activeWalletReport;
|
|
888
868
|
}
|
|
889
|
-
__name(initializeResolvedWalletReport, "initializeResolvedWalletReport");
|
|
890
869
|
function getResolvedWalletReport() {
|
|
891
870
|
return activeWalletReport;
|
|
892
871
|
}
|
|
893
|
-
__name(getResolvedWalletReport, "getResolvedWalletReport");
|
|
894
872
|
function formatSharedAccount(account, showPrivateKey) {
|
|
895
873
|
const lines = [
|
|
896
874
|
`[${account.accountPath}] ${account.label}`,
|
|
@@ -901,7 +879,6 @@ function formatSharedAccount(account, showPrivateKey) {
|
|
|
901
879
|
if (showPrivateKey) lines.push(`privateKey: ${account.privateKey ?? "unavailable"}`);
|
|
902
880
|
return lines.join("\n");
|
|
903
881
|
}
|
|
904
|
-
__name(formatSharedAccount, "formatSharedAccount");
|
|
905
882
|
function formatGenesisRewardAccount(account) {
|
|
906
883
|
const balance = account.accountPath === "0" ? GENESIS_REWARD_AMOUNT / ATTO_XL1_PER_XL1 : 0n;
|
|
907
884
|
return [
|
|
@@ -912,7 +889,6 @@ function formatGenesisRewardAccount(account) {
|
|
|
912
889
|
`balance: ${balance.toString()} XL1`
|
|
913
890
|
].join("\n");
|
|
914
891
|
}
|
|
915
|
-
__name(formatGenesisRewardAccount, "formatGenesisRewardAccount");
|
|
916
892
|
function formatWalletReport(report) {
|
|
917
893
|
const sections = [];
|
|
918
894
|
const showSecrets = report.root.isBuiltInDevMnemonic;
|
|
@@ -937,7 +913,6 @@ function formatWalletReport(report) {
|
|
|
937
913
|
].join("\n"));
|
|
938
914
|
return sections.join("\n\n");
|
|
939
915
|
}
|
|
940
|
-
__name(formatWalletReport, "formatWalletReport");
|
|
941
916
|
function formatInsecureGenesisRewardWarning(accounts) {
|
|
942
917
|
return [
|
|
943
918
|
"INSECURE GENESIS REWARD WALLET WARNING",
|
|
@@ -956,21 +931,18 @@ function formatInsecureGenesisRewardWarning(accounts) {
|
|
|
956
931
|
accounts.map((account) => formatGenesisRewardAccount(account)).join("\n\n")
|
|
957
932
|
].join("\n");
|
|
958
933
|
}
|
|
959
|
-
__name(formatInsecureGenesisRewardWarning, "formatInsecureGenesisRewardWarning");
|
|
960
934
|
async function resolveGenesisRewardAddress(config) {
|
|
961
935
|
if (config.chain.genesisRewardAddress) return config.chain.genesisRewardAddress;
|
|
962
936
|
const wallet = await generateXyoBaseWalletFromPhrase(INSECURE_GENESIS_REWARD_MNEMONIC);
|
|
963
937
|
const account = await wallet.derivePath("0");
|
|
964
938
|
return account.address;
|
|
965
939
|
}
|
|
966
|
-
__name(resolveGenesisRewardAddress, "resolveGenesisRewardAddress");
|
|
967
940
|
async function resolveWalletForActor(actorName, accountPath) {
|
|
968
941
|
const report = activeWalletReport;
|
|
969
942
|
const mnemonic = report?.root.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
970
943
|
const resolvedAccountPath = accountPath ?? resolveActorAccountPath(actorName);
|
|
971
944
|
return await deriveWalletAtPath(mnemonic, resolvedAccountPath);
|
|
972
945
|
}
|
|
973
|
-
__name(resolveWalletForActor, "resolveWalletForActor");
|
|
974
946
|
|
|
975
947
|
// src/shared/init/initActorSeedPhrase.ts
|
|
976
948
|
async function initActorSeedPhrase(context, bios) {
|
|
@@ -983,7 +955,6 @@ async function initActorSeedPhrase(context, bios) {
|
|
|
983
955
|
logger?.debug(`[${walletKind}] Falling back to built-in development mnemonic`);
|
|
984
956
|
return assertEx2(fallback, () => "Unable to resolve mnemonic");
|
|
985
957
|
}
|
|
986
|
-
__name(initActorSeedPhrase, "initActorSeedPhrase");
|
|
987
958
|
|
|
988
959
|
// src/shared/init/initBridgedModule.ts
|
|
989
960
|
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
@@ -1006,33 +977,26 @@ async function initBridgedModule({ bridge, moduleName }) {
|
|
|
1006
977
|
return moduleInstance;
|
|
1007
978
|
});
|
|
1008
979
|
}
|
|
1009
|
-
__name(initBridgedModule, "initBridgedModule");
|
|
1010
980
|
async function initBridgedArchivistModule({ bridge, moduleName }) {
|
|
1011
|
-
return assertEx3(
|
|
1012
|
-
bridge,
|
|
1013
|
-
moduleName
|
|
1014
|
-
|
|
981
|
+
return assertEx3(
|
|
982
|
+
asAttachableArchivistInstance(await initBridgedModule({ bridge, moduleName })),
|
|
983
|
+
() => `Could not convert ${moduleName} to attachable archivist instance`
|
|
984
|
+
);
|
|
1015
985
|
}
|
|
1016
|
-
__name(initBridgedArchivistModule, "initBridgedArchivistModule");
|
|
1017
986
|
|
|
1018
987
|
// src/shared/init/initStatusReporter.ts
|
|
1019
988
|
import { RuntimeStatusMonitor } from "@xyo-network/xl1-sdk";
|
|
1020
989
|
function initStatusReporter({ logger }) {
|
|
1021
990
|
const statusReporter = new RuntimeStatusMonitor(logger);
|
|
1022
|
-
statusReporter.onGlobalTransition({
|
|
1023
|
-
to: "started"
|
|
1024
|
-
}, () => {
|
|
991
|
+
statusReporter.onGlobalTransition({ to: "started" }, () => {
|
|
1025
992
|
logger.log("All services started.");
|
|
1026
993
|
});
|
|
1027
|
-
statusReporter.onGlobalTransition({
|
|
1028
|
-
to: "error"
|
|
1029
|
-
}, () => {
|
|
994
|
+
statusReporter.onGlobalTransition({ to: "error" }, () => {
|
|
1030
995
|
logger.error("Producer encountered an unhandled error!");
|
|
1031
996
|
process.exit(1);
|
|
1032
997
|
});
|
|
1033
998
|
return statusReporter;
|
|
1034
999
|
}
|
|
1035
|
-
__name(initStatusReporter, "initStatusReporter");
|
|
1036
1000
|
|
|
1037
1001
|
// src/shared/init/initWallet.ts
|
|
1038
1002
|
import { isDefined } from "@xylabs/sdk-js";
|
|
@@ -1046,21 +1010,10 @@ async function initActorWallet(context) {
|
|
|
1046
1010
|
actorAccountSingletons[actorName] = account;
|
|
1047
1011
|
return actorAccountSingletons[actorName];
|
|
1048
1012
|
}
|
|
1049
|
-
__name(initActorWallet, "initActorWallet");
|
|
1050
1013
|
|
|
1051
1014
|
// src/shared/orchestrator/Orchestrator.ts
|
|
1052
1015
|
import { AbstractCreatable as AbstractCreatable2, creatable } from "@xylabs/sdk-js";
|
|
1053
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
1054
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1055
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1056
|
-
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;
|
|
1057
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1058
|
-
}
|
|
1059
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
1060
1016
|
var Orchestrator = class extends AbstractCreatable2 {
|
|
1061
|
-
static {
|
|
1062
|
-
__name(this, "Orchestrator");
|
|
1063
|
-
}
|
|
1064
1017
|
actors = [];
|
|
1065
1018
|
running = false;
|
|
1066
1019
|
shuttingDown = false;
|
|
@@ -1077,9 +1030,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1077
1030
|
return this.shuttingDown;
|
|
1078
1031
|
}
|
|
1079
1032
|
/**
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1033
|
+
* Registers an actor.
|
|
1034
|
+
* (We won't activate the actor until `start()` is called.)
|
|
1035
|
+
*/
|
|
1083
1036
|
async registerActor(actor) {
|
|
1084
1037
|
this.actors.push(actor);
|
|
1085
1038
|
if (this.running) {
|
|
@@ -1092,9 +1045,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1092
1045
|
}
|
|
1093
1046
|
}
|
|
1094
1047
|
/**
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
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
|
+
*/
|
|
1098
1051
|
async startHandler() {
|
|
1099
1052
|
await super.startHandler();
|
|
1100
1053
|
if (this.running) {
|
|
@@ -1104,12 +1057,7 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1104
1057
|
this.logger?.log(`[Orchestrator] Starting ${this.actors.length} actor(s) in parallel...`);
|
|
1105
1058
|
this.running = true;
|
|
1106
1059
|
const startResults = await Promise.allSettled(this.actors.map((a) => a.start()));
|
|
1107
|
-
const startFailures = startResults.flatMap((r, i) => r.status === "rejected" ? [
|
|
1108
|
-
{
|
|
1109
|
-
actor: this.actors[i],
|
|
1110
|
-
reason: r.reason
|
|
1111
|
-
}
|
|
1112
|
-
] : []);
|
|
1060
|
+
const startFailures = startResults.flatMap((r, i) => r.status === "rejected" ? [{ actor: this.actors[i], reason: r.reason }] : []);
|
|
1113
1061
|
if (startFailures.length > 0) {
|
|
1114
1062
|
for (const f of startFailures) this.logger?.error(`[Orchestrator] Actor [${f.actor?.name ?? "?"}] failed to start: ${formatError(f.reason)}`);
|
|
1115
1063
|
throw new Error(`[Orchestrator] ${startFailures.length} actor(s) failed to start`);
|
|
@@ -1123,8 +1071,8 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1123
1071
|
}
|
|
1124
1072
|
}
|
|
1125
1073
|
/**
|
|
1126
|
-
|
|
1127
|
-
|
|
1074
|
+
* Stops the orchestrator: deactivates all actors.
|
|
1075
|
+
*/
|
|
1128
1076
|
async stopHandler() {
|
|
1129
1077
|
await super.stopHandler();
|
|
1130
1078
|
if (!this.running) {
|
|
@@ -1139,9 +1087,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1139
1087
|
this.logger?.log("[Orchestrator] Stopped.");
|
|
1140
1088
|
}
|
|
1141
1089
|
/**
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1090
|
+
* Resolves once every actor reports ready. Rejects if any actor's `readyHandler` throws,
|
|
1091
|
+
* or after `timeoutMs` if provided.
|
|
1092
|
+
*/
|
|
1145
1093
|
async whenReady(timeoutMs) {
|
|
1146
1094
|
const localActors = this.actors.filter(isLocalActor);
|
|
1147
1095
|
if (localActors.length === 0) return;
|
|
@@ -1156,50 +1104,30 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1156
1104
|
}, timeoutMs);
|
|
1157
1105
|
});
|
|
1158
1106
|
try {
|
|
1159
|
-
await Promise.race([
|
|
1160
|
-
Promise.all(localActors.map((a) => a.whenReady())),
|
|
1161
|
-
timeout
|
|
1162
|
-
]);
|
|
1107
|
+
await Promise.race([Promise.all(localActors.map((a) => a.whenReady())), timeout]);
|
|
1163
1108
|
} finally {
|
|
1164
1109
|
if (timer) clearTimeout(timer);
|
|
1165
1110
|
}
|
|
1166
1111
|
}
|
|
1167
1112
|
};
|
|
1168
|
-
Orchestrator =
|
|
1113
|
+
Orchestrator = __decorateClass([
|
|
1169
1114
|
creatable()
|
|
1170
1115
|
], Orchestrator);
|
|
1171
1116
|
function isLocalActor(actor) {
|
|
1172
1117
|
return actor instanceof ActorV3;
|
|
1173
1118
|
}
|
|
1174
|
-
__name(isLocalActor, "isLocalActor");
|
|
1175
1119
|
function formatError(err) {
|
|
1176
1120
|
if (err instanceof Error) return `${err.message}${err.stack ? `
|
|
1177
1121
|
${err.stack}` : ""}`;
|
|
1178
1122
|
return String(err);
|
|
1179
1123
|
}
|
|
1180
|
-
__name(formatError, "formatError");
|
|
1181
1124
|
|
|
1182
1125
|
// src/shared/provider/SimpleRejectedTransactionsArchivistProvider.ts
|
|
1183
1126
|
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
1184
1127
|
import { AbstractCreatableProvider, creatableProvider } from "@xyo-network/xl1-sdk";
|
|
1185
|
-
function _ts_decorate2(decorators, target, key, desc) {
|
|
1186
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1187
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1188
|
-
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;
|
|
1189
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1190
|
-
}
|
|
1191
|
-
__name(_ts_decorate2, "_ts_decorate");
|
|
1192
1128
|
var RejectedTransactionsArchivistProviderMoniker = "RejectedTransactionsArchivistProvider";
|
|
1193
|
-
var SimpleRejectedTransactionsArchivistProvider = class
|
|
1194
|
-
|
|
1195
|
-
__name(this, "SimpleRejectedTransactionsArchivistProvider");
|
|
1196
|
-
}
|
|
1197
|
-
static defaultMoniker = RejectedTransactionsArchivistProviderMoniker;
|
|
1198
|
-
static dependencies = [];
|
|
1199
|
-
static monikers = [
|
|
1200
|
-
RejectedTransactionsArchivistProviderMoniker
|
|
1201
|
-
];
|
|
1202
|
-
moniker = _SimpleRejectedTransactionsArchivistProvider.defaultMoniker;
|
|
1129
|
+
var SimpleRejectedTransactionsArchivistProvider = class extends AbstractCreatableProvider {
|
|
1130
|
+
moniker = SimpleRejectedTransactionsArchivistProvider.defaultMoniker;
|
|
1203
1131
|
get archivist() {
|
|
1204
1132
|
return this.params.archivist;
|
|
1205
1133
|
}
|
|
@@ -1210,7 +1138,10 @@ var SimpleRejectedTransactionsArchivistProvider = class _SimpleRejectedTransacti
|
|
|
1210
1138
|
};
|
|
1211
1139
|
}
|
|
1212
1140
|
};
|
|
1213
|
-
SimpleRejectedTransactionsArchivistProvider
|
|
1141
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "defaultMoniker", RejectedTransactionsArchivistProviderMoniker);
|
|
1142
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "dependencies", []);
|
|
1143
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "monikers", [RejectedTransactionsArchivistProviderMoniker]);
|
|
1144
|
+
SimpleRejectedTransactionsArchivistProvider = __decorateClass([
|
|
1214
1145
|
creatableProvider()
|
|
1215
1146
|
], SimpleRejectedTransactionsArchivistProvider);
|
|
1216
1147
|
|
|
@@ -1221,7 +1152,25 @@ import { backingsSatisfied, unmetBackings } from "@xyo-network/xl1-protocol-sdk"
|
|
|
1221
1152
|
import { createCapabilityRegistry } from "@xyo-network/xl1-protocol-sdk";
|
|
1222
1153
|
|
|
1223
1154
|
// src/node/config/capabilities/defaultCapabilityRegistry.ts
|
|
1224
|
-
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";
|
|
1225
1174
|
var XyoConnectionMoniker = "XyoConnection";
|
|
1226
1175
|
var XyoGatewayRunnerMoniker = "XyoGatewayRunner";
|
|
1227
1176
|
var capabilities = [
|
|
@@ -1242,12 +1191,22 @@ var capabilities = [
|
|
|
1242
1191
|
label: "Mempool viewer",
|
|
1243
1192
|
kind: "viewer",
|
|
1244
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.
|
|
1245
1199
|
},
|
|
1246
1200
|
{
|
|
1247
1201
|
id: MempoolRunnerMoniker,
|
|
1248
1202
|
label: "Mempool runner",
|
|
1249
1203
|
kind: "runner",
|
|
1250
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`).
|
|
1251
1210
|
},
|
|
1252
1211
|
{
|
|
1253
1212
|
id: AccountBalanceViewerMoniker,
|
|
@@ -1360,253 +1319,232 @@ function createDefaultCapabilityRegistry() {
|
|
|
1360
1319
|
for (const cap of capabilities) registry.register(cap);
|
|
1361
1320
|
return registry;
|
|
1362
1321
|
}
|
|
1363
|
-
__name(createDefaultCapabilityRegistry, "createDefaultCapabilityRegistry");
|
|
1364
1322
|
|
|
1365
1323
|
// src/node/config/capabilities/descriptors.ts
|
|
1366
|
-
import {
|
|
1367
|
-
|
|
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";
|
|
1340
|
+
function readMempoolTuning(ctx) {
|
|
1341
|
+
const cfg = ctx.actorContext.config;
|
|
1342
|
+
return {
|
|
1343
|
+
demotionThreshold: cfg?.mempool?.demotionThreshold,
|
|
1344
|
+
maxPendingTransactions: cfg?.mempool?.maxPendingTransactions
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
var passes = () => true;
|
|
1368
1348
|
var localTier1Descriptors = [
|
|
1369
1349
|
{
|
|
1370
1350
|
id: "SimpleMempoolViewer",
|
|
1371
|
-
satisfies: [
|
|
1372
|
-
SimpleMempoolViewer.defaultMoniker
|
|
1373
|
-
],
|
|
1351
|
+
satisfies: [SimpleMempoolViewer.defaultMoniker],
|
|
1374
1352
|
tier: 1,
|
|
1375
|
-
backings: [
|
|
1376
|
-
{
|
|
1377
|
-
backing: "mempool-store",
|
|
1378
|
-
mode: "read"
|
|
1379
|
-
}
|
|
1380
|
-
],
|
|
1353
|
+
backings: [{ backing: "mempool-store", mode: "read" }],
|
|
1381
1354
|
surface: "node",
|
|
1382
1355
|
preconditions: passes,
|
|
1383
|
-
build:
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1356
|
+
build: (ctx) => {
|
|
1357
|
+
const { demotionThreshold } = readMempoolTuning(ctx);
|
|
1358
|
+
return SimpleMempoolViewer.factory(
|
|
1359
|
+
SimpleMempoolViewer.dependencies,
|
|
1360
|
+
{
|
|
1361
|
+
pendingTransactionsArchivist: ctx.process.pendingTransactionsArchivist,
|
|
1362
|
+
pendingBlocksArchivist: ctx.process.pendingBlocksArchivist,
|
|
1363
|
+
demotionThreshold
|
|
1364
|
+
}
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1387
1367
|
},
|
|
1388
1368
|
{
|
|
1389
1369
|
id: "SimpleMempoolRunner",
|
|
1390
|
-
satisfies: [
|
|
1391
|
-
SimpleMempoolRunner.defaultMoniker
|
|
1392
|
-
],
|
|
1370
|
+
satisfies: [SimpleMempoolRunner.defaultMoniker],
|
|
1393
1371
|
tier: 1,
|
|
1394
|
-
backings: [
|
|
1395
|
-
{
|
|
1396
|
-
backing: "mempool-store",
|
|
1397
|
-
mode: "write"
|
|
1398
|
-
}
|
|
1399
|
-
],
|
|
1372
|
+
backings: [{ backing: "mempool-store", mode: "write" }],
|
|
1400
1373
|
surface: "node",
|
|
1401
1374
|
preconditions: passes,
|
|
1402
|
-
build:
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1375
|
+
build: (ctx) => {
|
|
1376
|
+
const { maxPendingTransactions } = readMempoolTuning(ctx);
|
|
1377
|
+
return SimpleMempoolRunner.factory(
|
|
1378
|
+
SimpleMempoolRunner.dependencies,
|
|
1379
|
+
{
|
|
1380
|
+
pendingTransactionsArchivist: ctx.process.pendingTransactionsArchivist,
|
|
1381
|
+
pendingBlocksArchivist: ctx.process.pendingBlocksArchivist,
|
|
1382
|
+
maxPendingTransactions
|
|
1383
|
+
}
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1406
1386
|
},
|
|
1407
1387
|
{
|
|
1408
1388
|
id: "SimpleAccountBalanceViewer",
|
|
1409
|
-
satisfies: [
|
|
1410
|
-
SimpleAccountBalanceViewer.defaultMoniker
|
|
1411
|
-
],
|
|
1389
|
+
satisfies: [SimpleAccountBalanceViewer.defaultMoniker],
|
|
1412
1390
|
tier: 1,
|
|
1413
|
-
backings: [
|
|
1414
|
-
{
|
|
1415
|
-
backing: "indexer-store",
|
|
1416
|
-
mode: "read"
|
|
1417
|
-
}
|
|
1418
|
-
],
|
|
1391
|
+
backings: [{ backing: "indexer-store", mode: "read" }],
|
|
1419
1392
|
surface: "node",
|
|
1420
1393
|
preconditions: passes,
|
|
1421
|
-
build:
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1394
|
+
build: (ctx) => SimpleAccountBalanceViewer.factory(
|
|
1395
|
+
SimpleAccountBalanceViewer.dependencies,
|
|
1396
|
+
{
|
|
1397
|
+
balancesSummaryMap: ctx.process.balancesSummaryMap,
|
|
1398
|
+
transfersSummaryMap: ctx.process.transfersSummaryMap
|
|
1399
|
+
}
|
|
1400
|
+
)
|
|
1425
1401
|
},
|
|
1426
1402
|
{
|
|
1427
1403
|
id: "SimpleFinalizationViewer",
|
|
1428
|
-
satisfies: [
|
|
1429
|
-
SimpleFinalizationViewer.defaultMoniker
|
|
1430
|
-
],
|
|
1404
|
+
satisfies: [SimpleFinalizationViewer.defaultMoniker],
|
|
1431
1405
|
tier: 1,
|
|
1432
|
-
backings: [
|
|
1433
|
-
{
|
|
1434
|
-
backing: "chain-store",
|
|
1435
|
-
mode: "read"
|
|
1436
|
-
}
|
|
1437
|
-
],
|
|
1406
|
+
backings: [{ backing: "chain-store", mode: "read" }],
|
|
1438
1407
|
surface: "node",
|
|
1439
1408
|
preconditions: passes,
|
|
1440
|
-
build:
|
|
1441
|
-
|
|
1442
|
-
|
|
1409
|
+
build: (ctx) => SimpleFinalizationViewer.factory(
|
|
1410
|
+
SimpleFinalizationViewer.dependencies,
|
|
1411
|
+
{ finalizedArchivist: ctx.process.readonlyChainArchivist }
|
|
1412
|
+
)
|
|
1443
1413
|
},
|
|
1444
1414
|
{
|
|
1445
1415
|
id: "SimpleBlockViewer",
|
|
1446
|
-
satisfies: [
|
|
1447
|
-
SimpleBlockViewer.defaultMoniker
|
|
1448
|
-
],
|
|
1416
|
+
satisfies: [SimpleBlockViewer.defaultMoniker],
|
|
1449
1417
|
tier: 1,
|
|
1450
|
-
backings: [
|
|
1451
|
-
{
|
|
1452
|
-
backing: "chain-store",
|
|
1453
|
-
mode: "read"
|
|
1454
|
-
}
|
|
1455
|
-
],
|
|
1418
|
+
backings: [{ backing: "chain-store", mode: "read" }],
|
|
1456
1419
|
surface: "node",
|
|
1457
1420
|
preconditions: passes,
|
|
1458
|
-
build:
|
|
1459
|
-
|
|
1460
|
-
|
|
1421
|
+
build: (ctx) => SimpleBlockViewer.factory(
|
|
1422
|
+
SimpleBlockViewer.dependencies,
|
|
1423
|
+
{ finalizedArchivist: ctx.process.readonlyChainArchivist }
|
|
1424
|
+
)
|
|
1461
1425
|
},
|
|
1462
1426
|
{
|
|
1463
1427
|
id: "SimpleWindowedBlockViewer",
|
|
1464
|
-
satisfies: [
|
|
1465
|
-
SimpleWindowedBlockViewer.defaultMoniker
|
|
1466
|
-
],
|
|
1428
|
+
satisfies: [SimpleWindowedBlockViewer.defaultMoniker],
|
|
1467
1429
|
tier: 1,
|
|
1468
1430
|
backings: [],
|
|
1469
1431
|
surface: "node",
|
|
1470
1432
|
preconditions: passes,
|
|
1471
|
-
build:
|
|
1472
|
-
|
|
1473
|
-
syncInterval: 1e4
|
|
1474
|
-
|
|
1433
|
+
build: () => SimpleWindowedBlockViewer.factory(
|
|
1434
|
+
SimpleWindowedBlockViewer.dependencies,
|
|
1435
|
+
{ maxWindowSize: 1e3, syncInterval: 1e4 }
|
|
1436
|
+
)
|
|
1475
1437
|
},
|
|
1476
1438
|
{
|
|
1477
1439
|
id: "SimpleXyoConnectionViewer",
|
|
1478
|
-
satisfies: [
|
|
1479
|
-
SimpleXyoConnectionViewer.defaultMoniker
|
|
1480
|
-
],
|
|
1440
|
+
satisfies: [SimpleXyoConnectionViewer.defaultMoniker],
|
|
1481
1441
|
tier: 1,
|
|
1482
1442
|
backings: [],
|
|
1483
1443
|
surface: "node",
|
|
1484
1444
|
preconditions: passes,
|
|
1485
|
-
build:
|
|
1445
|
+
build: () => SimpleXyoConnectionViewer.factory(SimpleXyoConnectionViewer.dependencies, {})
|
|
1486
1446
|
},
|
|
1487
1447
|
{
|
|
1488
1448
|
id: "SimpleTransactionViewer",
|
|
1489
|
-
satisfies: [
|
|
1490
|
-
SimpleTransactionViewer.defaultMoniker
|
|
1491
|
-
],
|
|
1449
|
+
satisfies: [SimpleTransactionViewer.defaultMoniker],
|
|
1492
1450
|
tier: 1,
|
|
1493
1451
|
backings: [],
|
|
1494
1452
|
surface: "node",
|
|
1495
1453
|
preconditions: passes,
|
|
1496
|
-
build:
|
|
1454
|
+
build: () => SimpleTransactionViewer.factory(SimpleTransactionViewer.dependencies, {})
|
|
1497
1455
|
},
|
|
1498
1456
|
{
|
|
1499
1457
|
id: "SimpleXyoViewer",
|
|
1500
|
-
satisfies: [
|
|
1501
|
-
SimpleXyoViewer.defaultMoniker
|
|
1502
|
-
],
|
|
1458
|
+
satisfies: [SimpleXyoViewer.defaultMoniker],
|
|
1503
1459
|
tier: 1,
|
|
1504
1460
|
backings: [],
|
|
1505
1461
|
surface: "node",
|
|
1506
1462
|
preconditions: passes,
|
|
1507
|
-
build:
|
|
1463
|
+
build: () => SimpleXyoViewer.factory(SimpleXyoViewer.dependencies, {})
|
|
1508
1464
|
},
|
|
1509
1465
|
{
|
|
1510
1466
|
id: "SimpleFinalizationRunner",
|
|
1511
|
-
satisfies: [
|
|
1512
|
-
SimpleFinalizationRunner.defaultMoniker
|
|
1513
|
-
],
|
|
1467
|
+
satisfies: [SimpleFinalizationRunner.defaultMoniker],
|
|
1514
1468
|
tier: 1,
|
|
1515
|
-
backings: [
|
|
1516
|
-
{
|
|
1517
|
-
backing: "chain-store",
|
|
1518
|
-
mode: "write"
|
|
1519
|
-
}
|
|
1520
|
-
],
|
|
1469
|
+
backings: [{ backing: "chain-store", mode: "write" }],
|
|
1521
1470
|
surface: "node",
|
|
1522
1471
|
preconditions: passes,
|
|
1523
|
-
build:
|
|
1524
|
-
|
|
1525
|
-
|
|
1472
|
+
build: (ctx) => SimpleFinalizationRunner.factory(
|
|
1473
|
+
SimpleFinalizationRunner.dependencies,
|
|
1474
|
+
{ finalizedArchivist: ctx.process.writableChainArchivist }
|
|
1475
|
+
)
|
|
1526
1476
|
},
|
|
1527
1477
|
{
|
|
1528
1478
|
id: "SimpleBlockValidationViewer",
|
|
1529
|
-
satisfies: [
|
|
1530
|
-
SimpleBlockValidationViewer.defaultMoniker
|
|
1531
|
-
],
|
|
1479
|
+
satisfies: [SimpleBlockValidationViewer.defaultMoniker],
|
|
1532
1480
|
tier: 1,
|
|
1533
1481
|
backings: [],
|
|
1534
1482
|
surface: "node",
|
|
1535
1483
|
preconditions: passes,
|
|
1536
|
-
build:
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1484
|
+
build: (ctx) => SimpleBlockValidationViewer.factory(
|
|
1485
|
+
SimpleBlockValidationViewer.dependencies,
|
|
1486
|
+
{
|
|
1487
|
+
state: ctx.process.blockStateValidator,
|
|
1488
|
+
protocol: ctx.process.blockProtocolValidator
|
|
1489
|
+
}
|
|
1490
|
+
)
|
|
1540
1491
|
},
|
|
1541
1492
|
{
|
|
1542
1493
|
id: "SimpleTransactionValidationViewer",
|
|
1543
|
-
satisfies: [
|
|
1544
|
-
SimpleTransactionValidationViewer.defaultMoniker
|
|
1545
|
-
],
|
|
1494
|
+
satisfies: [SimpleTransactionValidationViewer.defaultMoniker],
|
|
1546
1495
|
tier: 1,
|
|
1547
1496
|
backings: [],
|
|
1548
1497
|
surface: "node",
|
|
1549
1498
|
preconditions: passes,
|
|
1550
|
-
build:
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1499
|
+
build: (ctx) => SimpleTransactionValidationViewer.factory(
|
|
1500
|
+
SimpleTransactionValidationViewer.dependencies,
|
|
1501
|
+
{
|
|
1502
|
+
protocol: ctx.process.transactionProtocolValidator,
|
|
1503
|
+
state: ctx.process.transactionStateValidator
|
|
1504
|
+
}
|
|
1505
|
+
)
|
|
1554
1506
|
},
|
|
1555
1507
|
{
|
|
1556
1508
|
id: "SimpleDeadLetterQueueRunner",
|
|
1557
|
-
satisfies: [
|
|
1558
|
-
SimpleDeadLetterQueueRunner.defaultMoniker
|
|
1559
|
-
],
|
|
1509
|
+
satisfies: [SimpleDeadLetterQueueRunner.defaultMoniker],
|
|
1560
1510
|
tier: 1,
|
|
1561
|
-
backings: [
|
|
1562
|
-
{
|
|
1563
|
-
backing: "dlq-store",
|
|
1564
|
-
mode: "write"
|
|
1565
|
-
}
|
|
1566
|
-
],
|
|
1511
|
+
backings: [{ backing: "dlq-store", mode: "write" }],
|
|
1567
1512
|
surface: "node",
|
|
1568
1513
|
preconditions: passes,
|
|
1569
|
-
build:
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1514
|
+
build: (ctx) => SimpleDeadLetterQueueRunner.factory(
|
|
1515
|
+
SimpleDeadLetterQueueRunner.dependencies,
|
|
1516
|
+
{
|
|
1517
|
+
rejectedBlocksArchivist: ctx.process.rejectedBlocksArchivist,
|
|
1518
|
+
rejectedTransactionsArchivist: ctx.process.rejectedTransactionsArchivist
|
|
1519
|
+
}
|
|
1520
|
+
)
|
|
1573
1521
|
},
|
|
1574
1522
|
{
|
|
1575
1523
|
id: "SimpleDeadLetterQueueViewer",
|
|
1576
|
-
satisfies: [
|
|
1577
|
-
SimpleDeadLetterQueueViewer.defaultMoniker
|
|
1578
|
-
],
|
|
1524
|
+
satisfies: [SimpleDeadLetterQueueViewer.defaultMoniker],
|
|
1579
1525
|
tier: 1,
|
|
1580
|
-
backings: [
|
|
1581
|
-
{
|
|
1582
|
-
backing: "dlq-store",
|
|
1583
|
-
mode: "read"
|
|
1584
|
-
}
|
|
1585
|
-
],
|
|
1526
|
+
backings: [{ backing: "dlq-store", mode: "read" }],
|
|
1586
1527
|
surface: "node",
|
|
1587
1528
|
preconditions: passes,
|
|
1588
|
-
build:
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1529
|
+
build: (ctx) => SimpleDeadLetterQueueViewer.factory(
|
|
1530
|
+
SimpleDeadLetterQueueViewer.dependencies,
|
|
1531
|
+
{
|
|
1532
|
+
rejectedBlocksArchivist: ctx.process.rejectedBlocksArchivist,
|
|
1533
|
+
rejectedTransactionsArchivist: ctx.process.rejectedTransactionsArchivist
|
|
1534
|
+
}
|
|
1535
|
+
)
|
|
1592
1536
|
},
|
|
1593
1537
|
{
|
|
1594
1538
|
id: "SimpleRejectedTransactionsArchivistProvider",
|
|
1595
|
-
satisfies: [
|
|
1596
|
-
SimpleRejectedTransactionsArchivistProvider.defaultMoniker
|
|
1597
|
-
],
|
|
1539
|
+
satisfies: [SimpleRejectedTransactionsArchivistProvider.defaultMoniker],
|
|
1598
1540
|
tier: 1,
|
|
1599
|
-
backings: [
|
|
1600
|
-
{
|
|
1601
|
-
backing: "dlq-store",
|
|
1602
|
-
mode: "read"
|
|
1603
|
-
}
|
|
1604
|
-
],
|
|
1541
|
+
backings: [{ backing: "dlq-store", mode: "read" }],
|
|
1605
1542
|
surface: "node",
|
|
1606
1543
|
preconditions: passes,
|
|
1607
|
-
build:
|
|
1608
|
-
|
|
1609
|
-
|
|
1544
|
+
build: (ctx) => SimpleRejectedTransactionsArchivistProvider.factory(
|
|
1545
|
+
SimpleRejectedTransactionsArchivistProvider.dependencies,
|
|
1546
|
+
{ archivist: ctx.process.rejectedTransactionsArchivist }
|
|
1547
|
+
)
|
|
1610
1548
|
}
|
|
1611
1549
|
];
|
|
1612
1550
|
|
|
@@ -1614,7 +1552,11 @@ var localTier1Descriptors = [
|
|
|
1614
1552
|
import { ProviderFactoryLocator } from "@xyo-network/xl1-sdk";
|
|
1615
1553
|
|
|
1616
1554
|
// src/node/config/capabilities/networkTier3Descriptors.ts
|
|
1617
|
-
import {
|
|
1555
|
+
import {
|
|
1556
|
+
indexedNetworkDescriptors,
|
|
1557
|
+
networkTier3Descriptors,
|
|
1558
|
+
nodeNetworkDescriptors
|
|
1559
|
+
} from "@xyo-network/xl1-sdk";
|
|
1618
1560
|
|
|
1619
1561
|
// src/node/init/initBalanceSummaryMap.ts
|
|
1620
1562
|
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
@@ -1624,7 +1566,13 @@ import { hasMongoConfig, MemoryMap } from "@xyo-network/xl1-sdk";
|
|
|
1624
1566
|
async function initBalanceSummaryMap({ logger, config }) {
|
|
1625
1567
|
const mongoConfig = config.storage?.mongo;
|
|
1626
1568
|
if (hasMongoConfig(mongoConfig)) {
|
|
1627
|
-
const {
|
|
1569
|
+
const {
|
|
1570
|
+
connectionString: dbConnectionString,
|
|
1571
|
+
database: dbName,
|
|
1572
|
+
domain: dbDomain,
|
|
1573
|
+
password: dbPassword,
|
|
1574
|
+
username: dbUserName
|
|
1575
|
+
} = mongoConfig;
|
|
1628
1576
|
const payloadSdkConfig = {
|
|
1629
1577
|
dbConnectionString,
|
|
1630
1578
|
dbDomain,
|
|
@@ -1632,16 +1580,10 @@ async function initBalanceSummaryMap({ logger, config }) {
|
|
|
1632
1580
|
dbPassword,
|
|
1633
1581
|
dbUserName
|
|
1634
1582
|
};
|
|
1635
|
-
const sdkBalanceSummaryMap = new BaseMongoSdk({
|
|
1636
|
-
...payloadSdkConfig,
|
|
1637
|
-
collection: "balance_summary_map"
|
|
1638
|
-
});
|
|
1583
|
+
const sdkBalanceSummaryMap = new BaseMongoSdk({ ...payloadSdkConfig, collection: "balance_summary_map" });
|
|
1639
1584
|
const result = await MongoMap.create({
|
|
1640
1585
|
sdk: sdkBalanceSummaryMap,
|
|
1641
|
-
getCache: {
|
|
1642
|
-
enabled: true,
|
|
1643
|
-
maxEntries: 5e3
|
|
1644
|
-
}
|
|
1586
|
+
getCache: { enabled: true, maxEntries: 5e3 }
|
|
1645
1587
|
});
|
|
1646
1588
|
assertEx5(await result.start(), () => "Failed to start transfer summary map");
|
|
1647
1589
|
return result;
|
|
@@ -1650,13 +1592,24 @@ async function initBalanceSummaryMap({ logger, config }) {
|
|
|
1650
1592
|
return new MemoryMap();
|
|
1651
1593
|
}
|
|
1652
1594
|
}
|
|
1653
|
-
__name(initBalanceSummaryMap, "initBalanceSummaryMap");
|
|
1654
1595
|
|
|
1655
1596
|
// src/node/init/initEvmProvidersIfAvailable.ts
|
|
1656
1597
|
import { asEthAddress } from "@xylabs/sdk-js";
|
|
1657
|
-
import {
|
|
1598
|
+
import {
|
|
1599
|
+
EvmChainContractViewer,
|
|
1600
|
+
EvmStakeEventsViewer,
|
|
1601
|
+
EvmStakeTotalsViewer,
|
|
1602
|
+
EvmStakeViewer
|
|
1603
|
+
} from "@xyo-network/chain-ethereum";
|
|
1658
1604
|
import { canUseEvmProvider, initEvmProvider } from "@xyo-network/chain-orchestration-evm";
|
|
1659
|
-
import {
|
|
1605
|
+
import {
|
|
1606
|
+
SimpleChainContractViewer,
|
|
1607
|
+
SimpleStakeEventsViewer,
|
|
1608
|
+
SimpleStakeTotalsViewer,
|
|
1609
|
+
SimpleStakeViewer,
|
|
1610
|
+
SimpleTimeSyncViewer,
|
|
1611
|
+
XYO_ZERO_ADDRESS
|
|
1612
|
+
} from "@xyo-network/xl1-sdk";
|
|
1660
1613
|
async function initEvmProvidersIfAvailable(locator) {
|
|
1661
1614
|
const context = locator.context;
|
|
1662
1615
|
const { logger } = context;
|
|
@@ -1664,51 +1617,66 @@ async function initEvmProvidersIfAvailable(locator) {
|
|
|
1664
1617
|
const chainId = context.config.chain.id;
|
|
1665
1618
|
const provider = await initEvmProvider(context);
|
|
1666
1619
|
const address = asEthAddress(chainId, true);
|
|
1667
|
-
locator.register(EvmStakeEventsViewer.factory(
|
|
1668
|
-
|
|
1669
|
-
provider
|
|
1670
|
-
|
|
1671
|
-
locator.register(EvmStakeViewer.factory(
|
|
1672
|
-
|
|
1673
|
-
provider
|
|
1674
|
-
|
|
1675
|
-
locator.register(EvmStakeTotalsViewer.factory(
|
|
1676
|
-
|
|
1677
|
-
provider
|
|
1678
|
-
|
|
1679
|
-
locator.register(EvmChainContractViewer.factory(
|
|
1680
|
-
|
|
1681
|
-
provider
|
|
1682
|
-
|
|
1683
|
-
locator.register(SimpleTimeSyncViewer.factory(
|
|
1684
|
-
|
|
1685
|
-
|
|
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
|
+
));
|
|
1686
1640
|
} else {
|
|
1687
1641
|
logger?.warn("EVM provider not available - running with memory based contract/stake viewers");
|
|
1688
1642
|
const positions = [];
|
|
1689
|
-
locator.register(SimpleStakeEventsViewer.factory(
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
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
|
+
));
|
|
1702
1667
|
}
|
|
1703
1668
|
return locator;
|
|
1704
1669
|
}
|
|
1705
|
-
__name(initEvmProvidersIfAvailable, "initEvmProvidersIfAvailable");
|
|
1706
1670
|
|
|
1707
1671
|
// src/node/init/initFinalizationArchivistIfNeeded.ts
|
|
1708
1672
|
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
1709
1673
|
import { createBootstrapHead } from "@xyo-network/chain-sdk";
|
|
1710
1674
|
import { Account } from "@xyo-network/sdk-js";
|
|
1711
|
-
import {
|
|
1675
|
+
import {
|
|
1676
|
+
asAttoXL1,
|
|
1677
|
+
findMostRecentBlock,
|
|
1678
|
+
flattenHydratedBlock
|
|
1679
|
+
} from "@xyo-network/xl1-sdk";
|
|
1712
1680
|
async function initFinalizationArchivistIfNeeded(archivist, config, account, options = {}) {
|
|
1713
1681
|
const configuredChainId = config.chain.id;
|
|
1714
1682
|
const possibleHead = await findMostRecentBlock(archivist);
|
|
@@ -1724,18 +1692,19 @@ async function initFinalizationArchivistIfNeeded(archivist, config, account, opt
|
|
|
1724
1692
|
if (options.onInsecureGenesisConfirm) await options.onInsecureGenesisConfirm();
|
|
1725
1693
|
}
|
|
1726
1694
|
const genesisRewardAddress = await resolveGenesisRewardAddress(config);
|
|
1727
|
-
const chain = await createBootstrapHead(
|
|
1695
|
+
const chain = await createBootstrapHead(
|
|
1696
|
+
account,
|
|
1697
|
+
possibleChainId,
|
|
1698
|
+
asAttoXL1(GENESIS_REWARD_AMOUNT),
|
|
1699
|
+
genesisRewardAddress
|
|
1700
|
+
);
|
|
1728
1701
|
const payloads = chain.flatMap((block) => flattenHydratedBlock(block));
|
|
1729
1702
|
await archivist.insert(payloads);
|
|
1730
1703
|
}
|
|
1731
1704
|
const head = possibleHead ?? assertEx6(await findMostRecentBlock(archivist), () => "No blocks found in chain archivist");
|
|
1732
1705
|
const chainId = assertEx6(possibleChainId, () => "Chain ID could not be determined");
|
|
1733
|
-
return [
|
|
1734
|
-
head,
|
|
1735
|
-
chainId
|
|
1736
|
-
];
|
|
1706
|
+
return [head, chainId];
|
|
1737
1707
|
}
|
|
1738
|
-
__name(initFinalizationArchivistIfNeeded, "initFinalizationArchivistIfNeeded");
|
|
1739
1708
|
|
|
1740
1709
|
// src/node/init/initFinalizedArchivist.ts
|
|
1741
1710
|
import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
|
|
@@ -1744,16 +1713,12 @@ async function initMongoFinalizedArchivist(config) {
|
|
|
1744
1713
|
...config.storage.mongo,
|
|
1745
1714
|
collection: "chain_validated"
|
|
1746
1715
|
};
|
|
1747
|
-
return await MongoDBArchivistV2.create({
|
|
1748
|
-
payloadSdkConfig
|
|
1749
|
-
});
|
|
1716
|
+
return await MongoDBArchivistV2.create({ payloadSdkConfig });
|
|
1750
1717
|
}
|
|
1751
|
-
__name(initMongoFinalizedArchivist, "initMongoFinalizedArchivist");
|
|
1752
1718
|
async function initFinalizedArchivist(config) {
|
|
1753
1719
|
const finalizedArchivist = await initMongoFinalizedArchivist(config);
|
|
1754
1720
|
return finalizedArchivist;
|
|
1755
1721
|
}
|
|
1756
|
-
__name(initFinalizedArchivist, "initFinalizedArchivist");
|
|
1757
1722
|
|
|
1758
1723
|
// src/node/init/initServerNode.ts
|
|
1759
1724
|
import { assertEx as assertEx7 } from "@xylabs/sdk-js";
|
|
@@ -1764,15 +1729,18 @@ import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
|
1764
1729
|
import { LmdbArchivistConfigSchema } from "@xyo-network/archivist-lmdb";
|
|
1765
1730
|
import { MongoDBArchivistV2 as MongoDBArchivistV22, MongoDBArchivistV2Deletable } from "@xyo-network/archivist-mongodb";
|
|
1766
1731
|
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
1767
|
-
import {
|
|
1732
|
+
import {
|
|
1733
|
+
AbstractModule,
|
|
1734
|
+
LoggerModuleStatusReporter,
|
|
1735
|
+
MemoryArchivist,
|
|
1736
|
+
MemorySentinel,
|
|
1737
|
+
ModuleFactoryLocator
|
|
1738
|
+
} from "@xyo-network/sdk-js";
|
|
1768
1739
|
import { hasMongoConfig as hasMongoConfig2 } from "@xyo-network/xl1-sdk";
|
|
1769
1740
|
|
|
1770
1741
|
// src/node/manifest/NamedLmdbArchivist.ts
|
|
1771
1742
|
import { LmdbArchivist } from "@xyo-network/archivist-lmdb";
|
|
1772
1743
|
var NamedLmdbArchivist = class extends LmdbArchivist {
|
|
1773
|
-
static {
|
|
1774
|
-
__name(this, "NamedLmdbArchivist");
|
|
1775
|
-
}
|
|
1776
1744
|
get dbName() {
|
|
1777
1745
|
return this.config.dbName ?? "xyo-chain";
|
|
1778
1746
|
}
|
|
@@ -1792,13 +1760,24 @@ var NamedLmdbArchivist = class extends LmdbArchivist {
|
|
|
1792
1760
|
};
|
|
1793
1761
|
|
|
1794
1762
|
// src/node/manifest/getLocator.ts
|
|
1795
|
-
var getLocator =
|
|
1763
|
+
var getLocator = async ({
|
|
1764
|
+
logger,
|
|
1765
|
+
traceProvider,
|
|
1766
|
+
meterProvider,
|
|
1767
|
+
config
|
|
1768
|
+
}) => {
|
|
1796
1769
|
if (isDefined2(logger)) AbstractModule.defaultLogger = logger;
|
|
1797
1770
|
const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : void 0;
|
|
1798
1771
|
const locator = new ModuleFactoryLocator();
|
|
1799
1772
|
const mongoConfig = config.storage?.mongo;
|
|
1800
1773
|
if (hasMongoConfig2(mongoConfig)) {
|
|
1801
|
-
const {
|
|
1774
|
+
const {
|
|
1775
|
+
connectionString: dbConnectionString,
|
|
1776
|
+
database: dbName,
|
|
1777
|
+
domain: dbDomain,
|
|
1778
|
+
password: dbPassword,
|
|
1779
|
+
username: dbUserName
|
|
1780
|
+
} = mongoConfig;
|
|
1802
1781
|
const payloadSdkConfig = {
|
|
1803
1782
|
dbConnectionString,
|
|
1804
1783
|
dbDomain,
|
|
@@ -1813,9 +1792,7 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1813
1792
|
traceProvider
|
|
1814
1793
|
};
|
|
1815
1794
|
locator.register(MongoDBArchivistV22.factory(params), void 0, true);
|
|
1816
|
-
locator.register(MongoDBArchivistV2Deletable.factory(params), {
|
|
1817
|
-
"network.xyo.storage.capabilities.delete": "enabled"
|
|
1818
|
-
}, false);
|
|
1795
|
+
locator.register(MongoDBArchivistV2Deletable.factory(params), { "network.xyo.storage.capabilities.delete": "enabled" }, false);
|
|
1819
1796
|
} else if (isDefined2(config.storage?.root)) {
|
|
1820
1797
|
const lmdbLocation = config.storage.root;
|
|
1821
1798
|
const lmdbConfig = {
|
|
@@ -1823,12 +1800,16 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1823
1800
|
location: lmdbLocation,
|
|
1824
1801
|
schema: LmdbArchivistConfigSchema
|
|
1825
1802
|
};
|
|
1826
|
-
locator.register(
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1803
|
+
locator.register(
|
|
1804
|
+
NamedLmdbArchivist.factory({
|
|
1805
|
+
config: lmdbConfig,
|
|
1806
|
+
meterProvider,
|
|
1807
|
+
statusReporter,
|
|
1808
|
+
traceProvider
|
|
1809
|
+
}),
|
|
1810
|
+
void 0,
|
|
1811
|
+
true
|
|
1812
|
+
);
|
|
1832
1813
|
}
|
|
1833
1814
|
locator.register(MemoryArchivist.factory({
|
|
1834
1815
|
traceProvider,
|
|
@@ -1846,7 +1827,7 @@ var getLocator = /* @__PURE__ */ __name(async ({ logger, traceProvider, meterPro
|
|
|
1846
1827
|
statusReporter
|
|
1847
1828
|
}));
|
|
1848
1829
|
return locator;
|
|
1849
|
-
}
|
|
1830
|
+
};
|
|
1850
1831
|
|
|
1851
1832
|
// src/node/manifest/loadNode.ts
|
|
1852
1833
|
import { ManifestWrapper } from "@xyo-network/sdk-js";
|
|
@@ -2050,7 +2031,7 @@ var PublicChildManifests = [
|
|
|
2050
2031
|
];
|
|
2051
2032
|
|
|
2052
2033
|
// src/node/manifest/loadNode.ts
|
|
2053
|
-
var loadNode =
|
|
2034
|
+
var loadNode = async (context, wallet) => {
|
|
2054
2035
|
const locator = await getLocator(context);
|
|
2055
2036
|
const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests);
|
|
2056
2037
|
const [node, ...childNodes] = await wrapper.loadNodes();
|
|
@@ -2059,45 +2040,45 @@ var loadNode = /* @__PURE__ */ __name(async (context, wallet) => {
|
|
|
2059
2040
|
await Promise.all(childNodes.map((childNode) => node.attach(childNode.address, true)));
|
|
2060
2041
|
}
|
|
2061
2042
|
return node;
|
|
2062
|
-
}
|
|
2043
|
+
};
|
|
2063
2044
|
|
|
2064
2045
|
// src/node/init/initServerNode.ts
|
|
2065
2046
|
async function writableChainArchivistFromNode(node) {
|
|
2066
|
-
return asArchivistInstance(
|
|
2067
|
-
|
|
2068
|
-
|
|
2047
|
+
return asArchivistInstance(
|
|
2048
|
+
await node.resolve("Chain:Validated"),
|
|
2049
|
+
{ required: true }
|
|
2050
|
+
);
|
|
2069
2051
|
}
|
|
2070
|
-
__name(writableChainArchivistFromNode, "writableChainArchivistFromNode");
|
|
2071
2052
|
async function readonlyChainArchivistFromNode(node) {
|
|
2072
|
-
return assertEx7(asArchivistInstance(
|
|
2073
|
-
|
|
2074
|
-
|
|
2053
|
+
return assertEx7(asArchivistInstance(
|
|
2054
|
+
await node.resolve("Chain:Validated"),
|
|
2055
|
+
{ required: true }
|
|
2056
|
+
));
|
|
2075
2057
|
}
|
|
2076
|
-
__name(readonlyChainArchivistFromNode, "readonlyChainArchivistFromNode");
|
|
2077
2058
|
async function pendingTransactionsArchivistFromNode(node) {
|
|
2078
|
-
return asArchivistInstance(
|
|
2079
|
-
|
|
2080
|
-
|
|
2059
|
+
return asArchivistInstance(
|
|
2060
|
+
await node.resolve("XYOChain:Pending:Transactions"),
|
|
2061
|
+
{ required: true }
|
|
2062
|
+
);
|
|
2081
2063
|
}
|
|
2082
|
-
__name(pendingTransactionsArchivistFromNode, "pendingTransactionsArchivistFromNode");
|
|
2083
2064
|
async function pendingBlocksArchivistFromNode(node) {
|
|
2084
|
-
return asArchivistInstance(
|
|
2085
|
-
|
|
2086
|
-
|
|
2065
|
+
return asArchivistInstance(
|
|
2066
|
+
await node.resolve("XYOChain:Pending:Blocks"),
|
|
2067
|
+
{ required: true }
|
|
2068
|
+
);
|
|
2087
2069
|
}
|
|
2088
|
-
__name(pendingBlocksArchivistFromNode, "pendingBlocksArchivistFromNode");
|
|
2089
2070
|
async function rejectedBlocksArchivistFromNode(node) {
|
|
2090
|
-
return asArchivistInstance(
|
|
2091
|
-
|
|
2092
|
-
|
|
2071
|
+
return asArchivistInstance(
|
|
2072
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedBlocks"),
|
|
2073
|
+
{ required: true }
|
|
2074
|
+
);
|
|
2093
2075
|
}
|
|
2094
|
-
__name(rejectedBlocksArchivistFromNode, "rejectedBlocksArchivistFromNode");
|
|
2095
2076
|
async function rejectedTransactionsArchivistFromNode(node) {
|
|
2096
|
-
return asArchivistInstance(
|
|
2097
|
-
|
|
2098
|
-
|
|
2077
|
+
return asArchivistInstance(
|
|
2078
|
+
await node.resolve("XYOChain:DeadLetterQueue:RejectedTransactions"),
|
|
2079
|
+
{ required: true }
|
|
2080
|
+
);
|
|
2099
2081
|
}
|
|
2100
|
-
__name(rejectedTransactionsArchivistFromNode, "rejectedTransactionsArchivistFromNode");
|
|
2101
2082
|
async function initServerNode(context, wallet, providedNode) {
|
|
2102
2083
|
const node = providedNode ?? await loadNode(context, wallet);
|
|
2103
2084
|
assertEx7(await node.start(), () => "Failed to start node");
|
|
@@ -2117,7 +2098,6 @@ async function initServerNode(context, wallet, providedNode) {
|
|
|
2117
2098
|
rejectedTransactionsArchivist
|
|
2118
2099
|
};
|
|
2119
2100
|
}
|
|
2120
|
-
__name(initServerNode, "initServerNode");
|
|
2121
2101
|
|
|
2122
2102
|
// src/node/init/initTransferSummaryMap.ts
|
|
2123
2103
|
import { BaseMongoSdk as BaseMongoSdk2 } from "@xylabs/mongo";
|
|
@@ -2127,7 +2107,13 @@ import { hasMongoConfig as hasMongoConfig3, MemoryMap as MemoryMap2 } from "@xyo
|
|
|
2127
2107
|
async function initTransferSummaryMap({ logger, config }) {
|
|
2128
2108
|
const mongoConfig = config.storage?.mongo;
|
|
2129
2109
|
if (hasMongoConfig3(mongoConfig)) {
|
|
2130
|
-
const {
|
|
2110
|
+
const {
|
|
2111
|
+
connectionString: dbConnectionString,
|
|
2112
|
+
database: dbName,
|
|
2113
|
+
domain: dbDomain,
|
|
2114
|
+
password: dbPassword,
|
|
2115
|
+
username: dbUserName
|
|
2116
|
+
} = mongoConfig;
|
|
2131
2117
|
const payloadSdkConfig = {
|
|
2132
2118
|
dbConnectionString,
|
|
2133
2119
|
dbDomain,
|
|
@@ -2135,16 +2121,10 @@ async function initTransferSummaryMap({ logger, config }) {
|
|
|
2135
2121
|
dbPassword,
|
|
2136
2122
|
dbUserName
|
|
2137
2123
|
};
|
|
2138
|
-
const sdkTransferSummaryMap = new BaseMongoSdk2({
|
|
2139
|
-
...payloadSdkConfig,
|
|
2140
|
-
collection: "transfer_summary_map"
|
|
2141
|
-
});
|
|
2124
|
+
const sdkTransferSummaryMap = new BaseMongoSdk2({ ...payloadSdkConfig, collection: "transfer_summary_map" });
|
|
2142
2125
|
const result = await MongoMap2.create({
|
|
2143
2126
|
sdk: sdkTransferSummaryMap,
|
|
2144
|
-
getCache: {
|
|
2145
|
-
enabled: true,
|
|
2146
|
-
maxEntries: 5e3
|
|
2147
|
-
}
|
|
2127
|
+
getCache: { enabled: true, maxEntries: 5e3 }
|
|
2148
2128
|
});
|
|
2149
2129
|
assertEx8(await result.start(), () => "Failed to start transfer summary map");
|
|
2150
2130
|
return result;
|
|
@@ -2153,26 +2133,24 @@ async function initTransferSummaryMap({ logger, config }) {
|
|
|
2153
2133
|
return new MemoryMap2();
|
|
2154
2134
|
}
|
|
2155
2135
|
}
|
|
2156
|
-
__name(initTransferSummaryMap, "initTransferSummaryMap");
|
|
2157
2136
|
|
|
2158
2137
|
// src/node/config/capabilities/backings/buildChainStoreBacking.ts
|
|
2159
2138
|
import { asArchivistInstance as asArchivistInstance2 } from "@xyo-network/sdk-js";
|
|
2160
2139
|
async function buildChainStoreBacking(node, mode, options) {
|
|
2161
|
-
const readonlyArchivist = asArchivistInstance2(
|
|
2162
|
-
|
|
2163
|
-
|
|
2140
|
+
const readonlyArchivist = asArchivistInstance2(
|
|
2141
|
+
await node.resolve("Chain:Validated"),
|
|
2142
|
+
{ required: true }
|
|
2143
|
+
);
|
|
2164
2144
|
if (mode === "read") {
|
|
2165
|
-
return {
|
|
2166
|
-
mode,
|
|
2167
|
-
readonlyArchivist
|
|
2168
|
-
};
|
|
2145
|
+
return { mode, readonlyArchivist };
|
|
2169
2146
|
}
|
|
2170
2147
|
if (!options) {
|
|
2171
2148
|
throw new Error("buildChainStoreBacking(write) requires options { actorConfig, wallet }");
|
|
2172
2149
|
}
|
|
2173
|
-
const writableArchivist = asArchivistInstance2(
|
|
2174
|
-
|
|
2175
|
-
|
|
2150
|
+
const writableArchivist = asArchivistInstance2(
|
|
2151
|
+
await node.resolve("Chain:Validated"),
|
|
2152
|
+
{ required: true }
|
|
2153
|
+
);
|
|
2176
2154
|
await initFinalizationArchivistIfNeeded(writableArchivist, options.actorConfig, options.wallet, {
|
|
2177
2155
|
logger: options.logger,
|
|
2178
2156
|
onInsecureGenesisConfirm: options.onInsecureGenesisConfirm
|
|
@@ -2183,24 +2161,24 @@ async function buildChainStoreBacking(node, mode, options) {
|
|
|
2183
2161
|
writableArchivist
|
|
2184
2162
|
};
|
|
2185
2163
|
}
|
|
2186
|
-
__name(buildChainStoreBacking, "buildChainStoreBacking");
|
|
2187
2164
|
|
|
2188
2165
|
// src/node/config/capabilities/backings/buildDlqStoreBacking.ts
|
|
2189
2166
|
import { asArchivistInstance as asArchivistInstance3 } from "@xyo-network/sdk-js";
|
|
2190
2167
|
async function buildDlqStoreBacking(node, mode) {
|
|
2191
|
-
const rejectedBlocksArchivist = asArchivistInstance3(
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
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
|
+
);
|
|
2197
2176
|
return {
|
|
2198
2177
|
mode,
|
|
2199
2178
|
rejectedBlocksArchivist,
|
|
2200
2179
|
rejectedTransactionsArchivist
|
|
2201
2180
|
};
|
|
2202
2181
|
}
|
|
2203
|
-
__name(buildDlqStoreBacking, "buildDlqStoreBacking");
|
|
2204
2182
|
|
|
2205
2183
|
// src/node/config/capabilities/backings/buildIndexerStoreBacking.ts
|
|
2206
2184
|
import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
@@ -2213,39 +2191,40 @@ async function buildIndexerStoreBacking(context, mode) {
|
|
|
2213
2191
|
transfersSummaryMap
|
|
2214
2192
|
};
|
|
2215
2193
|
}
|
|
2216
|
-
__name(buildIndexerStoreBacking, "buildIndexerStoreBacking");
|
|
2217
2194
|
|
|
2218
2195
|
// src/node/config/capabilities/backings/buildMempoolStoreBacking.ts
|
|
2219
2196
|
import { asArchivistInstance as asArchivistInstance4 } from "@xyo-network/sdk-js";
|
|
2220
2197
|
async function buildMempoolStoreBacking(node, mode) {
|
|
2221
|
-
const pendingTransactionsArchivist = asArchivistInstance4(
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
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
|
+
);
|
|
2227
2206
|
return {
|
|
2228
2207
|
mode,
|
|
2229
2208
|
pendingBlocksArchivist,
|
|
2230
2209
|
pendingTransactionsArchivist
|
|
2231
2210
|
};
|
|
2232
2211
|
}
|
|
2233
|
-
__name(buildMempoolStoreBacking, "buildMempoolStoreBacking");
|
|
2234
2212
|
|
|
2235
2213
|
// src/node/config/capabilities/backings/buildValidators.ts
|
|
2236
|
-
import {
|
|
2214
|
+
import {
|
|
2215
|
+
validateHydratedBlock,
|
|
2216
|
+
validateHydratedBlockState,
|
|
2217
|
+
validateHydratedTransactionState
|
|
2218
|
+
} from "@xyo-network/chain-validation";
|
|
2237
2219
|
import { BlockCumulativeBalanceValidatorFactory, validateTransaction } from "@xyo-network/xl1-sdk";
|
|
2238
2220
|
var cumulativeBalanceValidator = BlockCumulativeBalanceValidatorFactory();
|
|
2239
|
-
var validateHydratedBlockStateWithCumulativeBalance =
|
|
2221
|
+
var validateHydratedBlockStateWithCumulativeBalance = async (context, block) => {
|
|
2240
2222
|
const [stateErrors, cumulativeErrors] = await Promise.all([
|
|
2241
2223
|
validateHydratedBlockState(context, block),
|
|
2242
2224
|
cumulativeBalanceValidator(context, block)
|
|
2243
2225
|
]);
|
|
2244
|
-
return [
|
|
2245
|
-
|
|
2246
|
-
...cumulativeErrors
|
|
2247
|
-
];
|
|
2248
|
-
}, "validateHydratedBlockStateWithCumulativeBalance");
|
|
2226
|
+
return [...stateErrors, ...cumulativeErrors];
|
|
2227
|
+
};
|
|
2249
2228
|
function buildValidators() {
|
|
2250
2229
|
return {
|
|
2251
2230
|
blockProtocolValidator: validateHydratedBlock,
|
|
@@ -2254,7 +2233,6 @@ function buildValidators() {
|
|
|
2254
2233
|
transactionStateValidator: validateHydratedTransactionState
|
|
2255
2234
|
};
|
|
2256
2235
|
}
|
|
2257
|
-
__name(buildValidators, "buildValidators");
|
|
2258
2236
|
|
|
2259
2237
|
// src/node/config/capabilities/ProcessSharedResources.ts
|
|
2260
2238
|
async function buildProcessSharedResources(context, options) {
|
|
@@ -2290,7 +2268,6 @@ async function buildProcessSharedResources(context, options) {
|
|
|
2290
2268
|
writableChainArchivist: chainStore.writableArchivist
|
|
2291
2269
|
};
|
|
2292
2270
|
}
|
|
2293
|
-
__name(buildProcessSharedResources, "buildProcessSharedResources");
|
|
2294
2271
|
|
|
2295
2272
|
// src/node/config/capabilities/resolveProviders.ts
|
|
2296
2273
|
import { MissingCapabilityError, resolveProviders } from "@xyo-network/xl1-protocol-sdk";
|
|
@@ -2310,9 +2287,12 @@ async function locatorFromActorNeeds(context, actorNeeds, options = {}) {
|
|
|
2310
2287
|
...networkTier3Descriptors,
|
|
2311
2288
|
...options.extraDescriptors ?? []
|
|
2312
2289
|
];
|
|
2313
|
-
const plan = resolveProviders(
|
|
2314
|
-
|
|
2315
|
-
|
|
2290
|
+
const plan = resolveProviders(
|
|
2291
|
+
needs,
|
|
2292
|
+
candidates,
|
|
2293
|
+
resolutionContext,
|
|
2294
|
+
{ availableBackings: options.availableBackings }
|
|
2295
|
+
);
|
|
2316
2296
|
const locator = new ProviderFactoryLocator(context, {}, options.validateDepsOnRegister ?? false);
|
|
2317
2297
|
const factories = plan.selected.map((d) => d.build(resolutionContext)).filter((f) => f !== void 0);
|
|
2318
2298
|
locator.registerMany(factories);
|
|
@@ -2322,7 +2302,6 @@ async function locatorFromActorNeeds(context, actorNeeds, options = {}) {
|
|
|
2322
2302
|
process: process2
|
|
2323
2303
|
};
|
|
2324
2304
|
}
|
|
2325
|
-
__name(locatorFromActorNeeds, "locatorFromActorNeeds");
|
|
2326
2305
|
function unionNeeds(actorNeeds) {
|
|
2327
2306
|
const result = /* @__PURE__ */ new Set();
|
|
2328
2307
|
for (const needs of actorNeeds) {
|
|
@@ -2331,53 +2310,56 @@ function unionNeeds(actorNeeds) {
|
|
|
2331
2310
|
}
|
|
2332
2311
|
return result;
|
|
2333
2312
|
}
|
|
2334
|
-
__name(unionNeeds, "unionNeeds");
|
|
2335
2313
|
|
|
2336
2314
|
// src/node/config/locators/basicRemoteRunnerLocator.ts
|
|
2337
2315
|
import { isAccountInstance } from "@xyo-network/sdk-js";
|
|
2338
|
-
import {
|
|
2316
|
+
import {
|
|
2317
|
+
basicRemoteRunnerLocator as sdkBasicRemoteRunnerLocator,
|
|
2318
|
+
JsonRpcAccountBalanceViewer,
|
|
2319
|
+
JsonRpcXyoSigner,
|
|
2320
|
+
SimpleXyoSigner
|
|
2321
|
+
} from "@xyo-network/xl1-sdk";
|
|
2339
2322
|
function signerFactoryFromParam(signer) {
|
|
2340
2323
|
if (isAccountInstance(signer)) {
|
|
2341
|
-
return SimpleXyoSigner.factory(SimpleXyoSigner.dependencies, {
|
|
2342
|
-
account: signer
|
|
2343
|
-
});
|
|
2324
|
+
return SimpleXyoSigner.factory(SimpleXyoSigner.dependencies, { account: signer });
|
|
2344
2325
|
}
|
|
2345
|
-
return JsonRpcXyoSigner.factory(JsonRpcXyoSigner.dependencies, {
|
|
2346
|
-
transport: signer
|
|
2347
|
-
});
|
|
2326
|
+
return JsonRpcXyoSigner.factory(JsonRpcXyoSigner.dependencies, { transport: signer });
|
|
2348
2327
|
}
|
|
2349
|
-
__name(signerFactoryFromParam, "signerFactoryFromParam");
|
|
2350
2328
|
function basicRemoteRunnerLocator(name, remoteConfig, signer, dataLakeEndpoint, validators) {
|
|
2351
2329
|
const transport = isAccountInstance(signer) ? void 0 : signer;
|
|
2352
2330
|
return sdkBasicRemoteRunnerLocator(name, remoteConfig, transport, dataLakeEndpoint, {
|
|
2353
2331
|
additionalProviders: [
|
|
2354
|
-
JsonRpcAccountBalanceViewer.factory(
|
|
2332
|
+
JsonRpcAccountBalanceViewer.factory(
|
|
2333
|
+
JsonRpcAccountBalanceViewer.dependencies,
|
|
2334
|
+
{}
|
|
2335
|
+
)
|
|
2355
2336
|
],
|
|
2356
2337
|
signerFactory: signerFactoryFromParam(signer),
|
|
2357
2338
|
skipGatewayRunner: true,
|
|
2358
2339
|
validators
|
|
2359
2340
|
});
|
|
2360
2341
|
}
|
|
2361
|
-
__name(basicRemoteRunnerLocator, "basicRemoteRunnerLocator");
|
|
2362
2342
|
|
|
2363
2343
|
// src/node/config/locators/basicRemoteViewerLocator.ts
|
|
2364
|
-
import {
|
|
2344
|
+
import {
|
|
2345
|
+
basicRemoteViewerLocator as sdkBasicRemoteViewerLocator,
|
|
2346
|
+
JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer2
|
|
2347
|
+
} from "@xyo-network/xl1-sdk";
|
|
2365
2348
|
function basicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, validators) {
|
|
2366
2349
|
return sdkBasicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, {
|
|
2367
2350
|
additionalProviders: [
|
|
2368
|
-
JsonRpcAccountBalanceViewer2.factory(
|
|
2351
|
+
JsonRpcAccountBalanceViewer2.factory(
|
|
2352
|
+
JsonRpcAccountBalanceViewer2.dependencies,
|
|
2353
|
+
{}
|
|
2354
|
+
)
|
|
2369
2355
|
],
|
|
2370
2356
|
validators
|
|
2371
2357
|
});
|
|
2372
2358
|
}
|
|
2373
|
-
__name(basicRemoteViewerLocator, "basicRemoteViewerLocator");
|
|
2374
2359
|
|
|
2375
2360
|
// src/node/config/locators/buildStatelessApiLocator.ts
|
|
2376
2361
|
var STATELESS_BACKINGS = [
|
|
2377
|
-
{
|
|
2378
|
-
backing: "network",
|
|
2379
|
-
mode: "read"
|
|
2380
|
-
}
|
|
2362
|
+
{ backing: "network", mode: "read" }
|
|
2381
2363
|
];
|
|
2382
2364
|
async function buildStatelessApiLocator(context, needs) {
|
|
2383
2365
|
const stubProcess = {};
|
|
@@ -2387,7 +2369,6 @@ async function buildStatelessApiLocator(context, needs) {
|
|
|
2387
2369
|
});
|
|
2388
2370
|
return result.locator;
|
|
2389
2371
|
}
|
|
2390
|
-
__name(buildStatelessApiLocator, "buildStatelessApiLocator");
|
|
2391
2372
|
|
|
2392
2373
|
// src/node/config/locators/telemetryContextFromConfig.ts
|
|
2393
2374
|
import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
@@ -2400,22 +2381,16 @@ async function telemetryContextFromConfig(config, serviceName, serviceVersion, d
|
|
|
2400
2381
|
serviceVersion
|
|
2401
2382
|
},
|
|
2402
2383
|
otlpEndpoint,
|
|
2403
|
-
metricsConfig: {
|
|
2404
|
-
endpoint,
|
|
2405
|
-
port
|
|
2406
|
-
}
|
|
2384
|
+
metricsConfig: { endpoint, port }
|
|
2407
2385
|
});
|
|
2408
2386
|
}
|
|
2409
|
-
__name(telemetryContextFromConfig, "telemetryContextFromConfig");
|
|
2410
2387
|
|
|
2411
2388
|
// src/node/config/locators/contextFromConfigWithoutLocator.ts
|
|
2412
2389
|
async function contextFromConfigWithoutLocator(config, logger, serviceName, serviceVersion, defaultScrapePort) {
|
|
2413
2390
|
const singletons = {};
|
|
2414
2391
|
const caches = {};
|
|
2415
2392
|
const telemetryConfig = await telemetryContextFromConfig(config, serviceName, serviceVersion, defaultScrapePort);
|
|
2416
|
-
const statusReporter = initStatusReporter({
|
|
2417
|
-
logger
|
|
2418
|
-
});
|
|
2393
|
+
const statusReporter = initStatusReporter({ logger });
|
|
2419
2394
|
return {
|
|
2420
2395
|
...telemetryConfig,
|
|
2421
2396
|
config,
|
|
@@ -2425,10 +2400,23 @@ async function contextFromConfigWithoutLocator(config, logger, serviceName, serv
|
|
|
2425
2400
|
statusReporter
|
|
2426
2401
|
};
|
|
2427
2402
|
}
|
|
2428
|
-
__name(contextFromConfigWithoutLocator, "contextFromConfigWithoutLocator");
|
|
2429
2403
|
|
|
2430
2404
|
// src/node/config/locators/localLocatorFromConfig.ts
|
|
2431
|
-
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";
|
|
2432
2420
|
var XyoConnectionMoniker2 = "XyoConnection";
|
|
2433
2421
|
var LOCAL_LEGACY_NEEDS = {
|
|
2434
2422
|
required: [
|
|
@@ -2450,21 +2438,30 @@ var LOCAL_LEGACY_NEEDS = {
|
|
|
2450
2438
|
]
|
|
2451
2439
|
};
|
|
2452
2440
|
async function localLocatorFromConfig(context, validateDepsOnRegister = false, onInsecureGenesisConfirm) {
|
|
2453
|
-
const result = await locatorFromActorNeeds(context, [
|
|
2454
|
-
LOCAL_LEGACY_NEEDS
|
|
2455
|
-
], {
|
|
2441
|
+
const result = await locatorFromActorNeeds(context, [LOCAL_LEGACY_NEEDS], {
|
|
2456
2442
|
onInsecureGenesisConfirm,
|
|
2457
2443
|
validateDepsOnRegister
|
|
2458
2444
|
});
|
|
2459
2445
|
return result.locator;
|
|
2460
2446
|
}
|
|
2461
|
-
__name(localLocatorFromConfig, "localLocatorFromConfig");
|
|
2462
2447
|
|
|
2463
2448
|
// src/node/config/locators/locatorsFromConfig.ts
|
|
2464
|
-
import { deepMerge as
|
|
2449
|
+
import { deepMerge as deepMerge3 } from "@xylabs/sdk-js";
|
|
2465
2450
|
|
|
2466
2451
|
// src/node/config/locators/actors/apiLocatorFromConfig.ts
|
|
2467
|
-
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";
|
|
2468
2465
|
var API_NEEDS = {
|
|
2469
2466
|
required: [
|
|
2470
2467
|
AccountBalanceViewerMoniker3,
|
|
@@ -2478,9 +2475,7 @@ var API_NEEDS = {
|
|
|
2478
2475
|
};
|
|
2479
2476
|
async function apiLocatorFromConfig(context, parent) {
|
|
2480
2477
|
if (context.config.stateless) {
|
|
2481
|
-
const locator2 = await buildStatelessApiLocator(context, [
|
|
2482
|
-
API_NEEDS
|
|
2483
|
-
]);
|
|
2478
|
+
const locator2 = await buildStatelessApiLocator(context, [API_NEEDS]);
|
|
2484
2479
|
locator2.registerMany([
|
|
2485
2480
|
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
2486
2481
|
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
@@ -2489,10 +2484,7 @@ async function apiLocatorFromConfig(context, parent) {
|
|
|
2489
2484
|
locator2.freeze();
|
|
2490
2485
|
return locator2;
|
|
2491
2486
|
}
|
|
2492
|
-
const locator = new ProviderFactoryLocator2({
|
|
2493
|
-
...context,
|
|
2494
|
-
locator: parent
|
|
2495
|
-
});
|
|
2487
|
+
const locator = new ProviderFactoryLocator2({ ...context, locator: parent });
|
|
2496
2488
|
locator.registerMany([
|
|
2497
2489
|
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
2498
2490
|
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
@@ -2501,16 +2493,28 @@ async function apiLocatorFromConfig(context, parent) {
|
|
|
2501
2493
|
locator.freeze();
|
|
2502
2494
|
return locator;
|
|
2503
2495
|
}
|
|
2504
|
-
__name(apiLocatorFromConfig, "apiLocatorFromConfig");
|
|
2505
2496
|
|
|
2506
2497
|
// src/node/config/locators/actors/bridgeLocatorFromConfig.ts
|
|
2507
2498
|
import { isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
2508
|
-
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";
|
|
2509
2516
|
async function bridgeLocatorFromConfig(context, parent) {
|
|
2510
|
-
const locator = new ProviderFactoryLocator3({
|
|
2511
|
-
...context,
|
|
2512
|
-
locator: parent
|
|
2513
|
-
});
|
|
2517
|
+
const locator = new ProviderFactoryLocator3({ ...context, locator: parent });
|
|
2514
2518
|
const { config } = context;
|
|
2515
2519
|
const { dataLake } = config;
|
|
2516
2520
|
const signerAccount = await initActorWallet(context);
|
|
@@ -2518,8 +2522,14 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2518
2522
|
locator.registerMany([
|
|
2519
2523
|
JsonRpcMempoolViewer.factory(JsonRpcMempoolViewer.dependencies, {}),
|
|
2520
2524
|
JsonRpcMempoolRunner.factory(JsonRpcMempoolRunner.dependencies, {}),
|
|
2521
|
-
JsonRpcAccountBalanceViewer3.factory(
|
|
2522
|
-
|
|
2525
|
+
JsonRpcAccountBalanceViewer3.factory(
|
|
2526
|
+
JsonRpcAccountBalanceViewer3.dependencies,
|
|
2527
|
+
{}
|
|
2528
|
+
),
|
|
2529
|
+
JsonRpcFinalizationViewer.factory(
|
|
2530
|
+
JsonRpcFinalizationViewer.dependencies,
|
|
2531
|
+
{}
|
|
2532
|
+
),
|
|
2523
2533
|
JsonRpcBlockViewer.factory(JsonRpcBlockViewer.dependencies, {}),
|
|
2524
2534
|
JsonRpcXyoRunner.factory(JsonRpcXyoRunner.dependencies, {}),
|
|
2525
2535
|
JsonRpcXyoViewer.factory(JsonRpcXyoViewer.dependencies, {})
|
|
@@ -2531,12 +2541,8 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2531
2541
|
case "rest": {
|
|
2532
2542
|
const { url: endpoint } = dataLake;
|
|
2533
2543
|
locator.registerMany([
|
|
2534
|
-
RestDataLakeRunner.factory(RestDataLakeRunner.dependencies, {
|
|
2535
|
-
|
|
2536
|
-
}),
|
|
2537
|
-
RestDataLakeViewer.factory(RestDataLakeViewer.dependencies, {
|
|
2538
|
-
endpoint
|
|
2539
|
-
})
|
|
2544
|
+
RestDataLakeRunner.factory(RestDataLakeRunner.dependencies, { endpoint }),
|
|
2545
|
+
RestDataLakeViewer.factory(RestDataLakeViewer.dependencies, { endpoint })
|
|
2540
2546
|
]);
|
|
2541
2547
|
break;
|
|
2542
2548
|
}
|
|
@@ -2546,12 +2552,8 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2546
2552
|
}
|
|
2547
2553
|
}
|
|
2548
2554
|
locator.registerMany([
|
|
2549
|
-
SimpleStakeEventsViewer2.factory(SimpleStakeEventsViewer2.dependencies, {
|
|
2550
|
-
|
|
2551
|
-
}),
|
|
2552
|
-
SimpleXyoSigner2.factory(SimpleXyoSigner2.dependencies, {
|
|
2553
|
-
account: signerAccount
|
|
2554
|
-
}),
|
|
2555
|
+
SimpleStakeEventsViewer2.factory(SimpleStakeEventsViewer2.dependencies, { positions: [] }),
|
|
2556
|
+
SimpleXyoSigner2.factory(SimpleXyoSigner2.dependencies, { account: signerAccount }),
|
|
2555
2557
|
SimpleXyoRunner2.factory(SimpleXyoRunner2.dependencies, {}),
|
|
2556
2558
|
SimpleXyoConnectionRunner2.factory(SimpleXyoConnectionRunner2.dependencies, {}),
|
|
2557
2559
|
SimpleXyoGatewayRunner.factory(SimpleXyoGatewayRunner.dependencies, {})
|
|
@@ -2559,33 +2561,24 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
2559
2561
|
locator.freeze();
|
|
2560
2562
|
return locator;
|
|
2561
2563
|
}
|
|
2562
|
-
__name(bridgeLocatorFromConfig, "bridgeLocatorFromConfig");
|
|
2563
2564
|
|
|
2564
2565
|
// src/node/config/locators/actors/finalizerLocatorFromConfig.ts
|
|
2565
2566
|
import { ProviderFactoryLocator as ProviderFactoryLocator4 } from "@xyo-network/xl1-sdk";
|
|
2566
2567
|
function finalizerLocatorFromConfig(context, parent) {
|
|
2567
|
-
const locator = new ProviderFactoryLocator4({
|
|
2568
|
-
...context,
|
|
2569
|
-
locator: parent
|
|
2570
|
-
});
|
|
2568
|
+
const locator = new ProviderFactoryLocator4({ ...context, locator: parent });
|
|
2571
2569
|
locator.registerMany([]);
|
|
2572
2570
|
locator.freeze();
|
|
2573
2571
|
return locator;
|
|
2574
2572
|
}
|
|
2575
|
-
__name(finalizerLocatorFromConfig, "finalizerLocatorFromConfig");
|
|
2576
2573
|
|
|
2577
2574
|
// src/node/config/locators/actors/mempoolLocatorFromConfig.ts
|
|
2578
2575
|
import { ProviderFactoryLocator as ProviderFactoryLocator5 } from "@xyo-network/xl1-sdk";
|
|
2579
2576
|
function mempoolLocatorFromConfig(context, parent) {
|
|
2580
|
-
const locator = new ProviderFactoryLocator5({
|
|
2581
|
-
...context,
|
|
2582
|
-
locator: parent
|
|
2583
|
-
});
|
|
2577
|
+
const locator = new ProviderFactoryLocator5({ ...context, locator: parent });
|
|
2584
2578
|
locator.registerMany([]);
|
|
2585
2579
|
locator.freeze();
|
|
2586
2580
|
return locator;
|
|
2587
2581
|
}
|
|
2588
|
-
__name(mempoolLocatorFromConfig, "mempoolLocatorFromConfig");
|
|
2589
2582
|
|
|
2590
2583
|
// src/node/config/locators/actors/producerLocatorFromConfig.ts
|
|
2591
2584
|
import { asAddress } from "@xylabs/sdk-js";
|
|
@@ -2594,57 +2587,72 @@ import { ProviderFactoryLocator as ProviderFactoryLocator6 } from "@xyo-network/
|
|
|
2594
2587
|
async function producerLocatorFromConfig(context, parent) {
|
|
2595
2588
|
const { logger, config } = context;
|
|
2596
2589
|
const account = await initActorWallet(context);
|
|
2597
|
-
const locator = new ProviderFactoryLocator6({
|
|
2598
|
-
...context,
|
|
2599
|
-
locator: parent
|
|
2600
|
-
});
|
|
2590
|
+
const locator = new ProviderFactoryLocator6({ ...context, locator: parent });
|
|
2601
2591
|
const rewardAddress = asAddress(config.rewardAddress ?? account.address, true);
|
|
2602
2592
|
logger?.info(`Using reward address ${rewardAddress}`);
|
|
2603
2593
|
if (rewardAddress === account.address) {
|
|
2604
2594
|
logger?.warn(`Using producer account address as reward address: ${account.address}`);
|
|
2605
2595
|
}
|
|
2606
|
-
const rejectedTransactionsProvider = await parent?.tryGetInstance(
|
|
2596
|
+
const rejectedTransactionsProvider = await parent?.tryGetInstance(
|
|
2597
|
+
RejectedTransactionsArchivistProviderMoniker
|
|
2598
|
+
);
|
|
2607
2599
|
const rejectedTransactionsArchivist = rejectedTransactionsProvider?.archivist;
|
|
2608
2600
|
locator.registerMany([
|
|
2609
|
-
SimpleBlockRunner.factory(
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
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
|
+
)
|
|
2618
2613
|
]);
|
|
2619
2614
|
locator.freeze();
|
|
2620
2615
|
return locator;
|
|
2621
2616
|
}
|
|
2622
|
-
__name(producerLocatorFromConfig, "producerLocatorFromConfig");
|
|
2623
2617
|
|
|
2624
2618
|
// src/node/config/locators/actors/rewardRedemptionLocatorFromConfig.ts
|
|
2625
|
-
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";
|
|
2626
2633
|
async function rewardRedemptionLocatorFromConfig(context, parent) {
|
|
2627
|
-
const locator = new ProviderFactoryLocator7({
|
|
2628
|
-
...context,
|
|
2629
|
-
locator: parent
|
|
2630
|
-
});
|
|
2634
|
+
const locator = new ProviderFactoryLocator7({ ...context, locator: parent });
|
|
2631
2635
|
const { config } = context;
|
|
2632
2636
|
const account = await initActorWallet(context);
|
|
2633
2637
|
if (config.remote.rpc) {
|
|
2634
2638
|
locator.registerMany([
|
|
2635
2639
|
JsonRpcMempoolViewer2.factory(JsonRpcMempoolViewer2.dependencies, {}),
|
|
2636
2640
|
JsonRpcMempoolRunner2.factory(JsonRpcMempoolRunner2.dependencies, {}),
|
|
2637
|
-
JsonRpcAccountBalanceViewer4.factory(
|
|
2638
|
-
|
|
2641
|
+
JsonRpcAccountBalanceViewer4.factory(
|
|
2642
|
+
JsonRpcAccountBalanceViewer4.dependencies,
|
|
2643
|
+
{}
|
|
2644
|
+
),
|
|
2645
|
+
JsonRpcFinalizationViewer2.factory(
|
|
2646
|
+
JsonRpcFinalizationViewer2.dependencies,
|
|
2647
|
+
{}
|
|
2648
|
+
),
|
|
2639
2649
|
JsonRpcBlockViewer2.factory(JsonRpcBlockViewer2.dependencies, {}),
|
|
2640
2650
|
JsonRpcXyoRunner2.factory(JsonRpcXyoRunner2.dependencies, {}),
|
|
2641
2651
|
JsonRpcXyoViewer2.factory(JsonRpcXyoViewer2.dependencies, {})
|
|
2642
2652
|
]);
|
|
2643
2653
|
}
|
|
2644
2654
|
locator.registerMany([
|
|
2645
|
-
SimpleXyoSigner3.factory(SimpleXyoSigner3.dependencies, {
|
|
2646
|
-
account
|
|
2647
|
-
}),
|
|
2655
|
+
SimpleXyoSigner3.factory(SimpleXyoSigner3.dependencies, { account }),
|
|
2648
2656
|
SimpleXyoRunner3.factory(SimpleXyoRunner3.dependencies, {}),
|
|
2649
2657
|
SimpleXyoConnectionRunner3.factory(SimpleXyoConnectionRunner3.dependencies, {}),
|
|
2650
2658
|
SimpleXyoGatewayRunner2.factory(SimpleXyoGatewayRunner2.dependencies, {})
|
|
@@ -2652,99 +2660,247 @@ async function rewardRedemptionLocatorFromConfig(context, parent) {
|
|
|
2652
2660
|
locator.freeze();
|
|
2653
2661
|
return locator;
|
|
2654
2662
|
}
|
|
2655
|
-
__name(rewardRedemptionLocatorFromConfig, "rewardRedemptionLocatorFromConfig");
|
|
2656
2663
|
|
|
2657
2664
|
// src/node/config/locators/rootLocatorFromConfig.ts
|
|
2658
2665
|
import { commonLocatorFromConfig, remoteLocatorFromConfig } from "@xyo-network/xl1-sdk";
|
|
2659
2666
|
async function rootLocatorFromConfig(context, validateDepsOnRegister = false, onInsecureGenesisConfirm) {
|
|
2660
2667
|
const { config } = context;
|
|
2661
2668
|
let locator = await commonLocatorFromConfig(context, validateDepsOnRegister);
|
|
2662
|
-
const newLocator = await (config.remote.rpc ? remoteLocatorFromConfig(locator.context, validateDepsOnRegister) : localLocatorFromConfig(
|
|
2663
|
-
...locator.context,
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
}
|
|
2668
|
-
}, 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
|
+
));
|
|
2669
2674
|
locator = newLocator;
|
|
2670
2675
|
locator = await initEvmProvidersIfAvailable(locator);
|
|
2671
2676
|
locator.freeze();
|
|
2672
2677
|
return locator;
|
|
2673
2678
|
}
|
|
2674
|
-
|
|
2679
|
+
|
|
2680
|
+
// src/node/config/locators/sharedLocatorFromConfig.ts
|
|
2681
|
+
import { deepMerge as deepMerge2 } from "@xylabs/sdk-js";
|
|
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";
|
|
2704
|
+
var apiNeeds = {
|
|
2705
|
+
required: [
|
|
2706
|
+
AccountBalanceViewerMoniker4,
|
|
2707
|
+
BlockViewerMoniker4,
|
|
2708
|
+
FinalizationViewerMoniker4,
|
|
2709
|
+
MempoolViewerMoniker4,
|
|
2710
|
+
TransactionViewerMoniker4,
|
|
2711
|
+
XyoConnectionMoniker4,
|
|
2712
|
+
XyoGatewayMoniker,
|
|
2713
|
+
XyoRunnerMoniker,
|
|
2714
|
+
XyoViewerMoniker4
|
|
2715
|
+
]
|
|
2716
|
+
};
|
|
2717
|
+
var mempoolNeeds = {
|
|
2718
|
+
required: [
|
|
2719
|
+
MempoolRunnerMoniker3,
|
|
2720
|
+
// SimpleMempoolRunner.dependencies includes TransactionValidationViewer
|
|
2721
|
+
// — not resolved by the actor directly but pulled in at construction.
|
|
2722
|
+
TransactionValidationViewerMoniker3,
|
|
2723
|
+
// SimpleMempoolViewer.dependencies includes WindowedBlockViewer — the
|
|
2724
|
+
// mempool viewer is built when api/finalizer resolve MempoolViewer.
|
|
2725
|
+
WindowedBlockViewerMoniker3
|
|
2726
|
+
]
|
|
2727
|
+
};
|
|
2728
|
+
var finalizerNeeds = {
|
|
2729
|
+
required: [
|
|
2730
|
+
BlockValidationViewerMoniker3,
|
|
2731
|
+
BlockViewerMoniker4,
|
|
2732
|
+
FinalizationRunnerMoniker3,
|
|
2733
|
+
MempoolViewerMoniker4
|
|
2734
|
+
],
|
|
2735
|
+
optional: [DeadLetterQueueRunnerMoniker3]
|
|
2736
|
+
};
|
|
2737
|
+
var ACTOR_MIRRORS = {
|
|
2738
|
+
api: apiNeeds,
|
|
2739
|
+
mempool: mempoolNeeds,
|
|
2740
|
+
finalizer: finalizerNeeds
|
|
2741
|
+
};
|
|
2742
|
+
var apiExtraDescriptors = [
|
|
2743
|
+
{
|
|
2744
|
+
id: "SimpleXyoRunner",
|
|
2745
|
+
satisfies: [XyoRunnerMoniker],
|
|
2746
|
+
tier: 1,
|
|
2747
|
+
backings: [],
|
|
2748
|
+
surface: "node",
|
|
2749
|
+
preconditions: () => true,
|
|
2750
|
+
build: () => SimpleXyoRunner4.factory(SimpleXyoRunner4.dependencies, {})
|
|
2751
|
+
},
|
|
2752
|
+
{
|
|
2753
|
+
id: "SimpleXyoConnectionRunner",
|
|
2754
|
+
satisfies: [XyoConnectionMoniker4],
|
|
2755
|
+
// Same tier as `SimpleXyoConnectionViewer`; higher priority wins the
|
|
2756
|
+
// `XyoConnection` moniker in any actor mix that includes the API.
|
|
2757
|
+
tier: 1,
|
|
2758
|
+
priority: 100,
|
|
2759
|
+
backings: [],
|
|
2760
|
+
surface: "node",
|
|
2761
|
+
preconditions: () => true,
|
|
2762
|
+
build: () => SimpleXyoConnectionRunner4.factory(SimpleXyoConnectionRunner4.dependencies, {})
|
|
2763
|
+
},
|
|
2764
|
+
{
|
|
2765
|
+
id: "SimpleXyoGateway",
|
|
2766
|
+
satisfies: [XyoGatewayMoniker],
|
|
2767
|
+
tier: 1,
|
|
2768
|
+
backings: [],
|
|
2769
|
+
surface: "node",
|
|
2770
|
+
preconditions: () => true,
|
|
2771
|
+
build: () => SimpleXyoGateway2.factory(SimpleXyoGateway2.dependencies, {})
|
|
2772
|
+
}
|
|
2773
|
+
];
|
|
2774
|
+
var ACTOR_EXTRA_DESCRIPTORS = { api: apiExtraDescriptors };
|
|
2775
|
+
var ACTOR_CONFIG_PARSERS = {
|
|
2776
|
+
api: ApiConfigZod,
|
|
2777
|
+
mempool: MempoolConfigZod,
|
|
2778
|
+
finalizer: FinalizerConfigZod
|
|
2779
|
+
};
|
|
2780
|
+
var SHARED_LOCATOR_SUPPORTED_ACTORS = ["api", "mempool", "finalizer"];
|
|
2781
|
+
function canUseSharedLocator(actors, config) {
|
|
2782
|
+
if (actors.length === 0) return false;
|
|
2783
|
+
if (config.remote?.rpc) return false;
|
|
2784
|
+
const names = new Set(actors.map((a) => a.name));
|
|
2785
|
+
const fullCanary = SHARED_LOCATOR_SUPPORTED_ACTORS.every((name) => names.has(name));
|
|
2786
|
+
if (!fullCanary) return false;
|
|
2787
|
+
return actors.every((actor) => {
|
|
2788
|
+
if (!SHARED_LOCATOR_SUPPORTED_ACTORS.includes(actor.name)) return false;
|
|
2789
|
+
if (actor.name === "api") {
|
|
2790
|
+
const merged = ApiConfigZod.parse(deepMerge2(config, actor));
|
|
2791
|
+
if (merged.stateless === true) return false;
|
|
2792
|
+
}
|
|
2793
|
+
return true;
|
|
2794
|
+
});
|
|
2795
|
+
}
|
|
2796
|
+
async function sharedLocatorFromConfig(context, actors, config, options = {}) {
|
|
2797
|
+
const unionNeeds2 = {
|
|
2798
|
+
required: dedupe(actors.flatMap((a) => ACTOR_MIRRORS[a.name]?.required ?? [])),
|
|
2799
|
+
optional: dedupe(actors.flatMap((a) => ACTOR_MIRRORS[a.name]?.optional ?? []))
|
|
2800
|
+
};
|
|
2801
|
+
const extraDescriptors = actors.flatMap((a) => ACTOR_EXTRA_DESCRIPTORS[a.name] ?? []);
|
|
2802
|
+
const commonContext = { ...context, config: { ...config, name: "_shared_common" } };
|
|
2803
|
+
const commonLocator = await commonLocatorFromConfig2(commonContext);
|
|
2804
|
+
const sharedContext = {
|
|
2805
|
+
...commonLocator.context,
|
|
2806
|
+
config: { ...config, name: "_shared" }
|
|
2807
|
+
};
|
|
2808
|
+
const result = await locatorFromActorNeeds(sharedContext, [unionNeeds2], {
|
|
2809
|
+
extraDescriptors,
|
|
2810
|
+
onInsecureGenesisConfirm: options.onInsecureGenesisConfirm,
|
|
2811
|
+
validateDepsOnRegister: false
|
|
2812
|
+
});
|
|
2813
|
+
const sharedWithEvm = await initEvmProvidersIfAvailable(result.locator);
|
|
2814
|
+
sharedWithEvm.freeze();
|
|
2815
|
+
const perActor = {};
|
|
2816
|
+
for (const actor of actors) {
|
|
2817
|
+
const parser = ACTOR_CONFIG_PARSERS[actor.name];
|
|
2818
|
+
const actorConfig = parser ? parser.parse(deepMerge2(config, actor)) : actor;
|
|
2819
|
+
const actorContext = {
|
|
2820
|
+
...sharedWithEvm.context,
|
|
2821
|
+
config: actorConfig
|
|
2822
|
+
};
|
|
2823
|
+
const view = new ProviderFactoryLocator8(actorContext, sharedWithEvm.registry);
|
|
2824
|
+
view.freeze();
|
|
2825
|
+
perActor[actor.name] = view;
|
|
2826
|
+
}
|
|
2827
|
+
return { shared: sharedWithEvm, perActor };
|
|
2828
|
+
}
|
|
2829
|
+
function dedupe(items) {
|
|
2830
|
+
return [...new Set(items)];
|
|
2831
|
+
}
|
|
2675
2832
|
|
|
2676
2833
|
// src/node/config/locators/locatorsFromConfig.ts
|
|
2677
2834
|
function allActorsAreSelfSufficient(actors, config) {
|
|
2678
2835
|
if (actors.length === 0) return false;
|
|
2679
2836
|
return actors.every((actor) => {
|
|
2680
2837
|
if (actor.name !== "api") return false;
|
|
2681
|
-
const merged = ApiConfigZod.parse(
|
|
2838
|
+
const merged = ApiConfigZod.parse(deepMerge3(config, actor));
|
|
2682
2839
|
return merged.stateless === true;
|
|
2683
2840
|
});
|
|
2684
2841
|
}
|
|
2685
|
-
__name(allActorsAreSelfSufficient, "allActorsAreSelfSufficient");
|
|
2686
2842
|
async function locatorsFromConfig(context, { actors, ...config }, onInsecureGenesisConfirm) {
|
|
2687
2843
|
const result = {};
|
|
2844
|
+
if (canUseSharedLocator(actors, config)) {
|
|
2845
|
+
const { perActor } = await sharedLocatorFromConfig(context, actors, config, { onInsecureGenesisConfirm });
|
|
2846
|
+
return perActor;
|
|
2847
|
+
}
|
|
2688
2848
|
const skipRoot = allActorsAreSelfSufficient(actors, config);
|
|
2689
2849
|
if (!skipRoot) {
|
|
2690
|
-
const rootContext = {
|
|
2691
|
-
...context,
|
|
2692
|
-
config: {
|
|
2693
|
-
...config,
|
|
2694
|
-
name: "_root"
|
|
2695
|
-
}
|
|
2696
|
-
};
|
|
2850
|
+
const rootContext = { ...context, config: { ...config, name: "_root" } };
|
|
2697
2851
|
result._root = await rootLocatorFromConfig(rootContext, false, onInsecureGenesisConfirm);
|
|
2698
2852
|
}
|
|
2699
2853
|
for (const actorConfig of actors) {
|
|
2700
2854
|
switch (actorConfig.name) {
|
|
2701
2855
|
case "producer": {
|
|
2702
|
-
result[actorConfig.name] = await producerLocatorFromConfig(
|
|
2703
|
-
...context,
|
|
2704
|
-
|
|
2705
|
-
|
|
2856
|
+
result[actorConfig.name] = await producerLocatorFromConfig(
|
|
2857
|
+
{ ...context, config: ProducerConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2858
|
+
result._root
|
|
2859
|
+
);
|
|
2706
2860
|
break;
|
|
2707
2861
|
}
|
|
2708
2862
|
case "api": {
|
|
2709
|
-
result[actorConfig.name] = await apiLocatorFromConfig(
|
|
2710
|
-
...context,
|
|
2711
|
-
|
|
2712
|
-
|
|
2863
|
+
result[actorConfig.name] = await apiLocatorFromConfig(
|
|
2864
|
+
{ ...context, config: ApiConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2865
|
+
result._root
|
|
2866
|
+
);
|
|
2713
2867
|
break;
|
|
2714
2868
|
}
|
|
2715
2869
|
case "mempool": {
|
|
2716
|
-
result[actorConfig.name] = await mempoolLocatorFromConfig(
|
|
2717
|
-
...context,
|
|
2718
|
-
|
|
2719
|
-
|
|
2870
|
+
result[actorConfig.name] = await mempoolLocatorFromConfig(
|
|
2871
|
+
{ ...context, config: MempoolConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2872
|
+
result._root
|
|
2873
|
+
);
|
|
2720
2874
|
break;
|
|
2721
2875
|
}
|
|
2722
2876
|
case "finalizer": {
|
|
2723
|
-
result[actorConfig.name] = await finalizerLocatorFromConfig(
|
|
2724
|
-
...context,
|
|
2725
|
-
|
|
2726
|
-
|
|
2877
|
+
result[actorConfig.name] = await finalizerLocatorFromConfig(
|
|
2878
|
+
{ ...context, config: FinalizerConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2879
|
+
result._root
|
|
2880
|
+
);
|
|
2727
2881
|
break;
|
|
2728
2882
|
}
|
|
2729
2883
|
case "bridge": {
|
|
2730
|
-
result[actorConfig.name] = await bridgeLocatorFromConfig(
|
|
2731
|
-
...context,
|
|
2732
|
-
|
|
2733
|
-
|
|
2884
|
+
result[actorConfig.name] = await bridgeLocatorFromConfig(
|
|
2885
|
+
{ ...context, config: BridgeConfigZod.parse(deepMerge3(config, actorConfig)) },
|
|
2886
|
+
result._root
|
|
2887
|
+
);
|
|
2734
2888
|
break;
|
|
2735
2889
|
}
|
|
2736
2890
|
case "rewardRedemption": {
|
|
2737
|
-
result[actorConfig.name] = await rewardRedemptionLocatorFromConfig(
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2891
|
+
result[actorConfig.name] = await rewardRedemptionLocatorFromConfig(
|
|
2892
|
+
{
|
|
2893
|
+
...context,
|
|
2894
|
+
config: RewardRedemptionConfigZod.parse(deepMerge3(config, actorConfig))
|
|
2895
|
+
},
|
|
2896
|
+
result._root
|
|
2897
|
+
);
|
|
2741
2898
|
break;
|
|
2742
2899
|
}
|
|
2743
2900
|
}
|
|
2744
2901
|
}
|
|
2745
2902
|
return result;
|
|
2746
2903
|
}
|
|
2747
|
-
__name(locatorsFromConfig, "locatorsFromConfig");
|
|
2748
2904
|
|
|
2749
2905
|
// src/node/config/tryParseConfig.ts
|
|
2750
2906
|
import { isDefined as isDefined4, isNull } from "@xylabs/sdk-js";
|
|
@@ -2753,27 +2909,27 @@ import { cosmiconfig } from "cosmiconfig";
|
|
|
2753
2909
|
var configName = "xyo";
|
|
2754
2910
|
var configSection = "xl1";
|
|
2755
2911
|
var ConfigFileNotFoundError = class extends Error {
|
|
2756
|
-
static {
|
|
2757
|
-
__name(this, "ConfigFileNotFoundError");
|
|
2758
|
-
}
|
|
2759
2912
|
constructor(configPath) {
|
|
2760
2913
|
super(`Config file not found: ${configPath}`);
|
|
2761
2914
|
this.name = "ConfigFileNotFoundError";
|
|
2762
2915
|
}
|
|
2763
2916
|
};
|
|
2764
|
-
var isMissingFileError =
|
|
2917
|
+
var isMissingFileError = (error) => {
|
|
2765
2918
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
2766
|
-
}
|
|
2767
|
-
var isRecord =
|
|
2919
|
+
};
|
|
2920
|
+
var isRecord = (value) => {
|
|
2768
2921
|
return typeof value === "object" && value !== null;
|
|
2769
|
-
}
|
|
2922
|
+
};
|
|
2770
2923
|
async function tryParseConfig(options) {
|
|
2771
2924
|
const { configPath, searchPlaces } = options ?? {};
|
|
2772
|
-
const explorer = cosmiconfig(
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2925
|
+
const explorer = cosmiconfig(
|
|
2926
|
+
configName,
|
|
2927
|
+
{
|
|
2928
|
+
cache: true,
|
|
2929
|
+
// loaders: { '.ts': TypeScriptLoader() },
|
|
2930
|
+
searchPlaces
|
|
2931
|
+
}
|
|
2932
|
+
);
|
|
2777
2933
|
let result;
|
|
2778
2934
|
if (isDefined4(configPath)) {
|
|
2779
2935
|
try {
|
|
@@ -2794,15 +2950,11 @@ async function tryParseConfig(options) {
|
|
|
2794
2950
|
const section = result[configSection];
|
|
2795
2951
|
if (isRecord(section)) {
|
|
2796
2952
|
const parsed = ConfigZod.loose().parse(section);
|
|
2797
|
-
return typeof section.mnemonic === "string" ? {
|
|
2798
|
-
...parsed,
|
|
2799
|
-
mnemonic: section.mnemonic
|
|
2800
|
-
} : parsed;
|
|
2953
|
+
return typeof section.mnemonic === "string" ? { ...parsed, mnemonic: section.mnemonic } : parsed;
|
|
2801
2954
|
}
|
|
2802
2955
|
}
|
|
2803
2956
|
return ConfigZod.parse({});
|
|
2804
2957
|
}
|
|
2805
|
-
__name(tryParseConfig, "tryParseConfig");
|
|
2806
2958
|
|
|
2807
2959
|
// src/node/index.ts
|
|
2808
2960
|
export * from "@xyo-network/chain-orchestration-evm";
|
|
@@ -2824,6 +2976,8 @@ export {
|
|
|
2824
2976
|
DEFAULT_ACTOR_ACCOUNT_PATH,
|
|
2825
2977
|
DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL,
|
|
2826
2978
|
DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL,
|
|
2979
|
+
DEFAULT_MEMPOOL_DEMOTION_THRESHOLD,
|
|
2980
|
+
DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS,
|
|
2827
2981
|
DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL,
|
|
2828
2982
|
DefaultServiceProvider,
|
|
2829
2983
|
DerivationPathCollisionError,
|
|
@@ -2846,6 +3000,7 @@ export {
|
|
|
2846
3000
|
RewardRedemptionConfigContext,
|
|
2847
3001
|
RewardRedemptionConfigZod,
|
|
2848
3002
|
SHARED_ACCOUNT_REPORT_COUNT,
|
|
3003
|
+
SHARED_LOCATOR_SUPPORTED_ACTORS,
|
|
2849
3004
|
ServiceLifetime,
|
|
2850
3005
|
SimpleRejectedTransactionsArchivistProvider,
|
|
2851
3006
|
asApiConfig,
|
|
@@ -2868,6 +3023,7 @@ export {
|
|
|
2868
3023
|
buildProcessSharedResources,
|
|
2869
3024
|
buildStatelessApiLocator,
|
|
2870
3025
|
buildTelemetryConfig,
|
|
3026
|
+
canUseSharedLocator,
|
|
2871
3027
|
clearResolvedWalletReport,
|
|
2872
3028
|
contextFromConfigWithoutLocator,
|
|
2873
3029
|
createCapabilityRegistry,
|
|
@@ -2923,6 +3079,7 @@ export {
|
|
|
2923
3079
|
resolveWalletForActor,
|
|
2924
3080
|
resolveWalletReport,
|
|
2925
3081
|
rootLocatorFromConfig,
|
|
3082
|
+
sharedLocatorFromConfig,
|
|
2926
3083
|
telemetryContextFromConfig,
|
|
2927
3084
|
toApiConfig,
|
|
2928
3085
|
toApiConfigContext,
|
|
@@ -2939,4 +3096,4 @@ export {
|
|
|
2939
3096
|
tryParseConfig,
|
|
2940
3097
|
unmetBackings
|
|
2941
3098
|
};
|
|
2942
|
-
//# sourceMappingURL=index.mjs.map
|
|
3099
|
+
//# sourceMappingURL=index.mjs.map
|