@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/browser/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,27 +1138,24 @@ 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
|
|
|
1217
1148
|
// src/neutral/config/locators/basicRemoteRunnerLocator.ts
|
|
1218
1149
|
import { basicRemoteRunnerLocator as sdkBasicRemoteRunnerLocator } from "@xyo-network/xl1-sdk";
|
|
1219
1150
|
function basicRemoteRunnerLocator(name, remoteConfig, signerTransport, dataLakeEndpoint, validators) {
|
|
1220
|
-
return sdkBasicRemoteRunnerLocator(name, remoteConfig, signerTransport, dataLakeEndpoint, {
|
|
1221
|
-
validators
|
|
1222
|
-
});
|
|
1151
|
+
return sdkBasicRemoteRunnerLocator(name, remoteConfig, signerTransport, dataLakeEndpoint, { validators });
|
|
1223
1152
|
}
|
|
1224
|
-
__name(basicRemoteRunnerLocator, "basicRemoteRunnerLocator");
|
|
1225
1153
|
|
|
1226
1154
|
// src/neutral/config/locators/basicRemoteViewerLocator.ts
|
|
1227
1155
|
import { basicRemoteViewerLocator as sdkBasicRemoteViewerLocator } from "@xyo-network/xl1-sdk";
|
|
1228
1156
|
function basicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, validators) {
|
|
1229
|
-
return sdkBasicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, {
|
|
1230
|
-
validators
|
|
1231
|
-
});
|
|
1157
|
+
return sdkBasicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, { validators });
|
|
1232
1158
|
}
|
|
1233
|
-
__name(basicRemoteViewerLocator, "basicRemoteViewerLocator");
|
|
1234
1159
|
|
|
1235
1160
|
// src/neutral/config/locators/rootLocatorFromConfig.ts
|
|
1236
1161
|
import { assertEx as assertEx5 } from "@xylabs/sdk-js";
|
|
@@ -1238,11 +1163,13 @@ import { commonLocatorFromConfig, remoteLocatorFromConfig } from "@xyo-network/x
|
|
|
1238
1163
|
async function rootLocatorFromConfig(context, validateDepsOnRegister = false) {
|
|
1239
1164
|
const { config } = context;
|
|
1240
1165
|
await commonLocatorFromConfig(context, validateDepsOnRegister);
|
|
1241
|
-
const locator = assertEx5(
|
|
1166
|
+
const locator = assertEx5(
|
|
1167
|
+
await (config.remote.rpc ? remoteLocatorFromConfig(context, validateDepsOnRegister) : void 0),
|
|
1168
|
+
() => "Root locator could not be created from config. No supported configuration found."
|
|
1169
|
+
);
|
|
1242
1170
|
locator.freeze();
|
|
1243
1171
|
return locator;
|
|
1244
1172
|
}
|
|
1245
|
-
__name(rootLocatorFromConfig, "rootLocatorFromConfig");
|
|
1246
1173
|
export {
|
|
1247
1174
|
Actor,
|
|
1248
1175
|
ActorMnemonicNotAllowedError,
|
|
@@ -1258,6 +1185,8 @@ export {
|
|
|
1258
1185
|
DEFAULT_ACTOR_ACCOUNT_PATH,
|
|
1259
1186
|
DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL,
|
|
1260
1187
|
DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL,
|
|
1188
|
+
DEFAULT_MEMPOOL_DEMOTION_THRESHOLD,
|
|
1189
|
+
DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS,
|
|
1261
1190
|
DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL,
|
|
1262
1191
|
DefaultServiceProvider,
|
|
1263
1192
|
DerivationPathCollisionError,
|
|
@@ -1344,4 +1273,4 @@ export {
|
|
|
1344
1273
|
toRewardRedemptionConfig,
|
|
1345
1274
|
toRewardRedemptionConfigContext
|
|
1346
1275
|
};
|
|
1347
|
-
//# sourceMappingURL=index.mjs.map
|
|
1276
|
+
//# sourceMappingURL=index.mjs.map
|