@xyo-network/chain-orchestration 1.23.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.mjs +316 -382
- package/dist/browser/index.mjs.map +7 -1
- package/dist/browser/node/config/tryParseConfig.d.ts +0 -1
- package/dist/browser/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/browser/shared/actor/v3/ActorV3.d.ts +7 -7
- package/dist/browser/shared/actor/v3/ActorV3.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Api.d.ts +57 -61
- package/dist/browser/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Bridge.d.ts +86 -86
- package/dist/browser/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Finalizer.d.ts +55 -61
- package/dist/browser/shared/config/actors/Finalizer.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Mempool.d.ts +57 -63
- package/dist/browser/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/Producer.d.ts +56 -62
- package/dist/browser/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/browser/shared/config/actors/RewardRedemption.d.ts +52 -58
- package/dist/browser/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/dist/neutral/index.mjs +316 -382
- package/dist/neutral/index.mjs.map +7 -1
- package/dist/neutral/node/config/tryParseConfig.d.ts +0 -1
- package/dist/neutral/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/neutral/shared/actor/v3/ActorV3.d.ts +7 -7
- package/dist/neutral/shared/actor/v3/ActorV3.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Api.d.ts +57 -61
- package/dist/neutral/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Bridge.d.ts +86 -86
- package/dist/neutral/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Finalizer.d.ts +55 -61
- package/dist/neutral/shared/config/actors/Finalizer.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Mempool.d.ts +57 -63
- package/dist/neutral/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/Producer.d.ts +56 -62
- package/dist/neutral/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/neutral/shared/config/actors/RewardRedemption.d.ts +52 -58
- package/dist/neutral/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/dist/node/index.mjs +863 -890
- package/dist/node/index.mjs.map +7 -1
- package/dist/node/node/config/tryParseConfig.d.ts +0 -1
- package/dist/node/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/node/shared/actor/v3/ActorV3.d.ts +7 -7
- package/dist/node/shared/actor/v3/ActorV3.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Api.d.ts +57 -61
- package/dist/node/shared/config/actors/Api.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Bridge.d.ts +86 -86
- package/dist/node/shared/config/actors/Bridge.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Finalizer.d.ts +55 -61
- package/dist/node/shared/config/actors/Finalizer.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Mempool.d.ts +57 -63
- package/dist/node/shared/config/actors/Mempool.d.ts.map +1 -1
- package/dist/node/shared/config/actors/Producer.d.ts +56 -62
- package/dist/node/shared/config/actors/Producer.d.ts.map +1 -1
- package/dist/node/shared/config/actors/RewardRedemption.d.ts +52 -58
- package/dist/node/shared/config/actors/RewardRedemption.d.ts.map +1 -1
- package/package.json +92 -92
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,34 +1,45 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
if (decorator = decorators[i])
|
|
8
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
+
if (kind && result) __defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3
13
|
|
|
4
14
|
// src/shared/actor/v3/ActorV3.ts
|
|
5
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
AbstractCreatable,
|
|
17
|
+
assertEx,
|
|
18
|
+
delay,
|
|
19
|
+
IdLogger
|
|
20
|
+
} from "@xylabs/sdk-js";
|
|
6
21
|
import { Semaphore } from "async-mutex";
|
|
7
|
-
import z from "zod";
|
|
8
|
-
var noopCounter = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
var noopGauge = {
|
|
17
|
-
record: /* @__PURE__ */ __name(() => {
|
|
18
|
-
}, "record")
|
|
19
|
-
};
|
|
20
|
-
var noopHistogram = {
|
|
21
|
-
record: /* @__PURE__ */ __name(() => {
|
|
22
|
-
}, "record")
|
|
23
|
-
};
|
|
22
|
+
import { z } from "zod/mini";
|
|
23
|
+
var noopCounter = { add: () => {
|
|
24
|
+
} };
|
|
25
|
+
var noopUpDownCounter = { add: () => {
|
|
26
|
+
} };
|
|
27
|
+
var noopGauge = { record: () => {
|
|
28
|
+
} };
|
|
29
|
+
var noopHistogram = { record: () => {
|
|
30
|
+
} };
|
|
24
31
|
var CreatableNameZod = z.custom((val) => typeof val === "string" && val.length > 0);
|
|
25
|
-
var StatusReporterInstanceZod = z.custom(
|
|
26
|
-
|
|
32
|
+
var StatusReporterInstanceZod = z.custom(
|
|
33
|
+
(val) => val !== null && typeof val === "object" && "report" in val
|
|
34
|
+
);
|
|
35
|
+
var AccountInstanceZod = z.custom(
|
|
36
|
+
(val) => val !== null && typeof val === "object" && "address" in val
|
|
37
|
+
);
|
|
27
38
|
var ActorParamsV3Zod = z.object({
|
|
28
39
|
account: AccountInstanceZod,
|
|
29
40
|
locator: z.unknown(),
|
|
30
41
|
name: CreatableNameZod,
|
|
31
|
-
statusReporter:
|
|
42
|
+
statusReporter: z.optional(StatusReporterInstanceZod)
|
|
32
43
|
});
|
|
33
44
|
function createDeferred() {
|
|
34
45
|
let resolve;
|
|
@@ -43,11 +54,7 @@ function createDeferred() {
|
|
|
43
54
|
reject
|
|
44
55
|
};
|
|
45
56
|
}
|
|
46
|
-
__name(createDeferred, "createDeferred");
|
|
47
57
|
var ActorV3 = class extends AbstractCreatable {
|
|
48
|
-
static {
|
|
49
|
-
__name(this, "ActorV3");
|
|
50
|
-
}
|
|
51
58
|
_intervals = /* @__PURE__ */ new Map();
|
|
52
59
|
_semaphores = /* @__PURE__ */ new Map();
|
|
53
60
|
_timeouts = /* @__PURE__ */ new Map();
|
|
@@ -56,7 +63,10 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
56
63
|
_readyError;
|
|
57
64
|
_readyState = "pending";
|
|
58
65
|
get logger() {
|
|
59
|
-
this._logger = new IdLogger(
|
|
66
|
+
this._logger = new IdLogger(
|
|
67
|
+
assertEx(this.context.logger, () => `Logger is required in context for actor ${this.name}.`),
|
|
68
|
+
() => this.name
|
|
69
|
+
);
|
|
60
70
|
return this._logger;
|
|
61
71
|
}
|
|
62
72
|
get readyError() {
|
|
@@ -75,10 +85,9 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
75
85
|
return this.params.locator;
|
|
76
86
|
}
|
|
77
87
|
static async paramsHandler(params) {
|
|
78
|
-
const baseParams = await super.paramsHandler(
|
|
79
|
-
...params,
|
|
80
|
-
|
|
81
|
-
});
|
|
88
|
+
const baseParams = await super.paramsHandler(
|
|
89
|
+
{ ...params, name: params.name ?? "UnknownActor" }
|
|
90
|
+
);
|
|
82
91
|
const account = assertEx(params.account, () => `params.account is required for actor ${baseParams.name}.`);
|
|
83
92
|
const locator = assertEx(params.locator, () => `params.locator is required for actor ${baseParams.name}.`);
|
|
84
93
|
return {
|
|
@@ -88,8 +97,8 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
88
97
|
};
|
|
89
98
|
}
|
|
90
99
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
* The timer runs until the actor is deactivated (or you manually stop it).
|
|
101
|
+
*/
|
|
93
102
|
registerTimer(timerName, callback, dueTimeMs, periodMs) {
|
|
94
103
|
if (this.status !== "starting") {
|
|
95
104
|
this.logger?.warn(`Cannot register timer '${timerName}' because actor is not starting.`);
|
|
@@ -134,10 +143,10 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
134
143
|
this.logger?.debug(`Timer '${this.name}:${timerName}' registered: first call after ${dueTimeMs}ms, recurring every ${periodMs}ms.`);
|
|
135
144
|
}
|
|
136
145
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
146
|
+
* Invoked by the Orchestrator after `start()` to run the warm-pass.
|
|
147
|
+
* Idempotent: returns immediately if already invoked.
|
|
148
|
+
* Throws if `readyHandler` throws; resolves once `readyHandler` resolves.
|
|
149
|
+
*/
|
|
141
150
|
async runReadyHandler() {
|
|
142
151
|
if (this._readyState !== "pending") return;
|
|
143
152
|
try {
|
|
@@ -155,15 +164,15 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
155
164
|
async stopHandler() {
|
|
156
165
|
await super.stopHandler();
|
|
157
166
|
this.logger?.debug("Stopping all timers...");
|
|
158
|
-
await Promise.all(
|
|
159
|
-
...this._semaphores.values()
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
await Promise.all(
|
|
168
|
+
[...this._semaphores.values()].map(async (semaphore) => {
|
|
169
|
+
while (semaphore.isLocked()) {
|
|
170
|
+
this.logger?.debug("Waiting for running timer task to complete...");
|
|
171
|
+
await delay(500);
|
|
172
|
+
}
|
|
173
|
+
await semaphore.acquire();
|
|
174
|
+
})
|
|
175
|
+
);
|
|
167
176
|
this._semaphores.clear();
|
|
168
177
|
for (const [, timeoutRef] of this._timeouts.entries()) {
|
|
169
178
|
clearTimeout(timeoutRef);
|
|
@@ -187,58 +196,44 @@ var ActorV3 = class extends AbstractCreatable {
|
|
|
187
196
|
}, timeoutMs);
|
|
188
197
|
});
|
|
189
198
|
try {
|
|
190
|
-
await Promise.race([
|
|
191
|
-
this._readyDeferred.promise,
|
|
192
|
-
timeout
|
|
193
|
-
]);
|
|
199
|
+
await Promise.race([this._readyDeferred.promise, timeout]);
|
|
194
200
|
} finally {
|
|
195
201
|
if (timer) clearTimeout(timer);
|
|
196
202
|
}
|
|
197
203
|
}
|
|
198
204
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
* Create a `Counter` instrument bound to this actor's meter, or a no-op
|
|
206
|
+
* stub if telemetry is not wired. Always returns a non-undefined value so
|
|
207
|
+
* call sites can drop the optional-chain on `.add()`.
|
|
208
|
+
*
|
|
209
|
+
* TODO: in a future pass, consider folding these single-instrument helpers
|
|
210
|
+
* into a declarative `createActorMeters({ counters: {...}, gauges: {...} })`
|
|
211
|
+
* spec API for actors with many instruments.
|
|
212
|
+
*/
|
|
207
213
|
counter(name, description) {
|
|
208
|
-
return this.meter?.createCounter(name, {
|
|
209
|
-
description
|
|
210
|
-
}) ?? noopCounter;
|
|
214
|
+
return this.meter?.createCounter(name, { description }) ?? noopCounter;
|
|
211
215
|
}
|
|
212
216
|
/** Create a synchronous `Gauge` instrument, or a no-op stub if telemetry is not wired. */
|
|
213
217
|
gauge(name, description) {
|
|
214
|
-
return this.meter?.createGauge(name, {
|
|
215
|
-
description
|
|
216
|
-
}) ?? noopGauge;
|
|
218
|
+
return this.meter?.createGauge(name, { description }) ?? noopGauge;
|
|
217
219
|
}
|
|
218
220
|
/** Create a `Histogram` instrument, or a no-op stub if telemetry is not wired. */
|
|
219
221
|
histogram(name, description) {
|
|
220
|
-
return this.meter?.createHistogram(name, {
|
|
221
|
-
description
|
|
222
|
-
}) ?? noopHistogram;
|
|
222
|
+
return this.meter?.createHistogram(name, { description }) ?? noopHistogram;
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
* Override in subclasses to prove the actor can do useful work.
|
|
226
|
+
* Default: no-op (the actor declares itself ready as soon as `start()` returns).
|
|
227
|
+
*/
|
|
228
228
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
229
229
|
async readyHandler() {
|
|
230
230
|
}
|
|
231
231
|
/** Create an `UpDownCounter` instrument, or a no-op stub if telemetry is not wired. */
|
|
232
232
|
upDownCounter(name, description) {
|
|
233
|
-
return this.meter?.createUpDownCounter(name, {
|
|
234
|
-
description
|
|
235
|
-
}) ?? noopUpDownCounter;
|
|
233
|
+
return this.meter?.createUpDownCounter(name, { description }) ?? noopUpDownCounter;
|
|
236
234
|
}
|
|
237
235
|
};
|
|
238
236
|
var Actor = class extends ActorV3 {
|
|
239
|
-
static {
|
|
240
|
-
__name(this, "Actor");
|
|
241
|
-
}
|
|
242
237
|
};
|
|
243
238
|
|
|
244
239
|
// src/shared/buildTelemetryConfig.ts
|
|
@@ -246,89 +241,96 @@ function buildTelemetryConfig(config, serviceName, serviceVersion, defaultMetric
|
|
|
246
241
|
const { otlpEndpoint } = config.telemetry?.otel ?? {};
|
|
247
242
|
const { path: endpoint = "/metrics", port = defaultMetricsScrapePort } = config.telemetry?.metrics?.scrape ?? {};
|
|
248
243
|
const telemetryConfig = {
|
|
249
|
-
attributes: {
|
|
250
|
-
serviceName,
|
|
251
|
-
serviceVersion
|
|
252
|
-
},
|
|
244
|
+
attributes: { serviceName, serviceVersion },
|
|
253
245
|
otlpEndpoint,
|
|
254
|
-
metricsConfig: {
|
|
255
|
-
endpoint,
|
|
256
|
-
port
|
|
257
|
-
}
|
|
246
|
+
metricsConfig: { endpoint, port }
|
|
258
247
|
};
|
|
259
248
|
return telemetryConfig;
|
|
260
249
|
}
|
|
261
|
-
__name(buildTelemetryConfig, "buildTelemetryConfig");
|
|
262
250
|
|
|
263
251
|
// src/shared/config/actors/Api.ts
|
|
264
|
-
import {
|
|
252
|
+
import {
|
|
253
|
+
zodAsFactory,
|
|
254
|
+
zodIsFactory,
|
|
255
|
+
zodToFactory
|
|
256
|
+
} from "@xylabs/sdk-js";
|
|
265
257
|
import { BaseConfigContextZod, HostActorConfigZod } from "@xyo-network/xl1-sdk";
|
|
266
|
-
import { globalRegistry, z as z2 } from "zod";
|
|
267
|
-
var
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
z2.boolean()
|
|
272
|
-
|
|
258
|
+
import { globalRegistry, z as z2 } from "zod/mini";
|
|
259
|
+
var toBooleanDefaultTrue = (v) => v !== "0" && v !== "false" && v !== false && v !== 0;
|
|
260
|
+
var toBooleanDefaultFalse = (v) => v === "1" || v === "true" || v === true || v === 1;
|
|
261
|
+
var ApiConfigZod = z2.extend(HostActorConfigZod, {
|
|
262
|
+
initRewardsCache: z2._default(
|
|
263
|
+
z2.pipe(z2.union([z2.number(), z2.string(), z2.boolean()]), z2.transform(toBooleanDefaultTrue)),
|
|
264
|
+
true
|
|
265
|
+
).register(globalRegistry, {
|
|
273
266
|
description: "Whether to initialize the rewards cache on startup",
|
|
274
267
|
title: "api.initRewardsCache",
|
|
275
268
|
type: "boolean"
|
|
276
269
|
}),
|
|
277
270
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
stateless: z2.
|
|
286
|
-
z2.number(),
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
]).transform((v) => v === "1" || v === "true" || v === true || v == 1).default(false).register(globalRegistry, {
|
|
271
|
+
* When `true`, the API actor runs in stateless mode: it holds no local
|
|
272
|
+
* backing-store ownership, never loads the local LMDB/MongoDB node, and
|
|
273
|
+
* federates every JSON-RPC request to upstream owner-actors via `JsonRpc*`
|
|
274
|
+
* providers. Multiple stateless API instances can run behind a load
|
|
275
|
+
* balancer for horizontal scaling. Requires `remote.rpc` to point at the
|
|
276
|
+
* upstream API/Finalizer/Mempool/Indexer surfaces.
|
|
277
|
+
*/
|
|
278
|
+
stateless: z2._default(
|
|
279
|
+
z2.pipe(z2.union([z2.number(), z2.string(), z2.boolean()]), z2.transform(toBooleanDefaultFalse)),
|
|
280
|
+
false
|
|
281
|
+
).register(globalRegistry, {
|
|
290
282
|
description: "Run the API actor as a stateless federation node (availableBackings: [network])",
|
|
291
283
|
title: "api.stateless",
|
|
292
284
|
type: "boolean"
|
|
293
285
|
}),
|
|
294
286
|
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
legacyMixedRpc: z2.
|
|
309
|
-
z2.number(),
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
]).transform((v) => v !== "0" && v !== "false" && v !== false && v != 0).default(true).register(globalRegistry, {
|
|
287
|
+
* Back-compat for the surface-aware route split. When `true`, `POST /rpc`
|
|
288
|
+
* serves the full `XyoConnection` (both node-surface and indexed-surface
|
|
289
|
+
* methods), preserving pre-Phase-7 behavior for clients that haven't yet
|
|
290
|
+
* migrated to `POST /rpc/indexed`. When `false`, `/rpc` is strictly
|
|
291
|
+
* node-surface only and indexed methods are 404 at `/rpc`.
|
|
292
|
+
*
|
|
293
|
+
* `/rpc/indexed` mounts independently of this flag whenever the locator's
|
|
294
|
+
* connection has any indexed branch.
|
|
295
|
+
*
|
|
296
|
+
* Default `true` for the first release that includes Phase 7 — flip to
|
|
297
|
+
* `false` per environment once external clients (explorers, wallets, dApps)
|
|
298
|
+
* have moved their indexed-method calls to `/rpc/indexed`.
|
|
299
|
+
*/
|
|
300
|
+
legacyMixedRpc: z2._default(
|
|
301
|
+
z2.pipe(z2.union([z2.number(), z2.string(), z2.boolean()]), z2.transform(toBooleanDefaultTrue)),
|
|
302
|
+
true
|
|
303
|
+
).register(globalRegistry, {
|
|
313
304
|
description: "Serve the full XyoConnection at POST /rpc (no surface filter). Set false to enforce node-surface-only at /rpc; indexed methods always available at /rpc/indexed regardless.",
|
|
314
305
|
title: "api.legacyMixedRpc",
|
|
315
306
|
type: "boolean"
|
|
316
307
|
})
|
|
317
|
-
})
|
|
308
|
+
});
|
|
318
309
|
var isApiConfig = zodIsFactory(ApiConfigZod);
|
|
319
310
|
var asApiConfig = zodAsFactory(ApiConfigZod, "asApiConfig");
|
|
320
311
|
var toApiConfig = zodToFactory(ApiConfigZod, "toApiConfig");
|
|
321
|
-
var ApiConfigContext =
|
|
322
|
-
config: ApiConfigZod
|
|
323
|
-
});
|
|
312
|
+
var ApiConfigContext = z2.extend(BaseConfigContextZod, { config: ApiConfigZod });
|
|
324
313
|
var isApiConfigContext = zodIsFactory(ApiConfigContext);
|
|
325
314
|
var asApiConfigContext = zodAsFactory(ApiConfigContext, "asApiConfigContext");
|
|
326
315
|
var toApiConfigContext = zodToFactory(ApiConfigContext, "toApiConfigContext");
|
|
327
316
|
|
|
328
317
|
// src/shared/config/actors/Bridge.ts
|
|
329
|
-
import {
|
|
330
|
-
|
|
331
|
-
|
|
318
|
+
import {
|
|
319
|
+
AddressZod,
|
|
320
|
+
HexZod,
|
|
321
|
+
toAddress,
|
|
322
|
+
toHex,
|
|
323
|
+
zodAsFactory as zodAsFactory2,
|
|
324
|
+
zodIsFactory as zodIsFactory2,
|
|
325
|
+
zodToFactory as zodToFactory2
|
|
326
|
+
} from "@xylabs/sdk-js";
|
|
327
|
+
import {
|
|
328
|
+
AttoXL1ConvertFactor,
|
|
329
|
+
BaseConfigContextZod as BaseConfigContextZod2,
|
|
330
|
+
HostActorConfigZod as HostActorConfigZod2,
|
|
331
|
+
XL1
|
|
332
|
+
} from "@xyo-network/xl1-sdk";
|
|
333
|
+
import { globalRegistry as globalRegistry2, z as z3 } from "zod/mini";
|
|
332
334
|
var DEFAULT_FIXED_FEE = toHex(XL1(1000n) * AttoXL1ConvertFactor.xl1);
|
|
333
335
|
var DEFAULT_VARIABLE_FEE_BASIS_POINTS = 300;
|
|
334
336
|
var DEFAULT_HARDHAT_BRIDGE_CONTRACT = toAddress("2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6");
|
|
@@ -338,103 +340,108 @@ var DEFAULT_HARDHAT_TOKEN_CONTRACT = toAddress("5FbDB2315678afecb367f032d93F642f
|
|
|
338
340
|
var DEFAULT_MAX_BRIDGE_AMOUNT = toHex(XL1(1000000n) * AttoXL1ConvertFactor.xl1);
|
|
339
341
|
var DEFAULT_MIN_BRIDGE_AMOUNT = toHex(XL1(1500n) * AttoXL1ConvertFactor.xl1);
|
|
340
342
|
var DEFAULT_SCANNER_INTERVAL_MS = 3e4;
|
|
341
|
-
var BasisPointsZod = z3.coerce.number().
|
|
342
|
-
var BridgeConfigZod =
|
|
343
|
-
escrowAddress:
|
|
343
|
+
var BasisPointsZod = z3.coerce.number().check(z3.multipleOf(1), z3.nonnegative(), z3.maximum(1e4));
|
|
344
|
+
var BridgeConfigZod = z3.extend(HostActorConfigZod2, {
|
|
345
|
+
escrowAddress: z3.optional(AddressZod).register(globalRegistry2, {
|
|
344
346
|
description: "Address to which bridge escrow will be sent",
|
|
345
347
|
title: "bridge.escrowAddress",
|
|
346
348
|
type: "string"
|
|
347
349
|
}),
|
|
348
|
-
feesAddress:
|
|
350
|
+
feesAddress: z3.optional(AddressZod).register(globalRegistry2, {
|
|
349
351
|
description: "Address to which bridge fees will be sent",
|
|
350
352
|
title: "bridge.feesAddress",
|
|
351
353
|
type: "string"
|
|
352
354
|
}),
|
|
353
|
-
feeFixed:
|
|
355
|
+
feeFixed: z3._default(HexZod, DEFAULT_FIXED_FEE).register(globalRegistry2, {
|
|
354
356
|
default: DEFAULT_FIXED_FEE,
|
|
355
357
|
description: "Fixed fee (in AttoXL1) applied to bridge transfers",
|
|
356
358
|
title: "bridge.feeFixed",
|
|
357
359
|
type: "bigint"
|
|
358
360
|
}),
|
|
359
|
-
feeRateBasisPoints:
|
|
361
|
+
feeRateBasisPoints: z3._default(BasisPointsZod, DEFAULT_VARIABLE_FEE_BASIS_POINTS).register(globalRegistry2, {
|
|
360
362
|
default: DEFAULT_VARIABLE_FEE_BASIS_POINTS,
|
|
361
363
|
description: "Variable rate fee (in basis points where 1 bps = 0.01%) applied to bridge transfers",
|
|
362
364
|
title: "bridge.feeRateBasisPoints",
|
|
363
365
|
type: "number"
|
|
364
366
|
}),
|
|
365
|
-
maxBridgeAmount:
|
|
367
|
+
maxBridgeAmount: z3._default(HexZod, DEFAULT_MAX_BRIDGE_AMOUNT).register(globalRegistry2, {
|
|
366
368
|
default: DEFAULT_MAX_BRIDGE_AMOUNT,
|
|
367
369
|
description: "Maximum amount allowed for a bridge transfer",
|
|
368
370
|
title: "bridge.maxBridgeAmount",
|
|
369
371
|
type: "string"
|
|
370
372
|
}),
|
|
371
|
-
minBridgeAmount:
|
|
373
|
+
minBridgeAmount: z3._default(HexZod, DEFAULT_MIN_BRIDGE_AMOUNT).register(globalRegistry2, {
|
|
372
374
|
default: DEFAULT_MIN_BRIDGE_AMOUNT,
|
|
373
375
|
description: "Minimum amount required for a bridge transfer",
|
|
374
376
|
title: "bridge.minBridgeAmount",
|
|
375
377
|
type: "string"
|
|
376
378
|
}),
|
|
377
|
-
redisHost: z3.string()
|
|
379
|
+
redisHost: z3._default(z3.string(), "localhost").register(globalRegistry2, {
|
|
378
380
|
default: "localhost",
|
|
379
381
|
description: "Host for the Bridge Redis instance",
|
|
380
382
|
title: "bridge.redisHost",
|
|
381
383
|
type: "string"
|
|
382
384
|
}),
|
|
383
|
-
redisPort: z3.coerce.number().
|
|
385
|
+
redisPort: z3._default(z3.coerce.number().check(z3.multipleOf(1), z3.positive()), 6379).register(globalRegistry2, {
|
|
384
386
|
default: 6379,
|
|
385
387
|
description: "Port for the Bridge Redis instance",
|
|
386
388
|
title: "bridge.redisPort",
|
|
387
389
|
type: "number"
|
|
388
390
|
}),
|
|
389
|
-
scannerIntervalMs: z3.coerce.number().
|
|
391
|
+
scannerIntervalMs: z3._default(z3.coerce.number().check(z3.multipleOf(1), z3.positive()), DEFAULT_SCANNER_INTERVAL_MS).register(globalRegistry2, {
|
|
390
392
|
default: DEFAULT_SCANNER_INTERVAL_MS,
|
|
391
393
|
description: "How often (ms) the EVM->XL1 scanner polls the remote bridge contract for new BridgedToRemote ids confirmed at depth.",
|
|
392
394
|
title: "bridge.scannerIntervalMs",
|
|
393
395
|
type: "number"
|
|
394
396
|
}),
|
|
395
|
-
remoteBridgeContractAddress:
|
|
397
|
+
remoteBridgeContractAddress: z3._default(AddressZod, DEFAULT_HARDHAT_BRIDGE_CONTRACT).register(globalRegistry2, {
|
|
396
398
|
default: DEFAULT_HARDHAT_BRIDGE_CONTRACT,
|
|
397
399
|
description: "Hex representation of remote token address used for bridging",
|
|
398
400
|
title: "bridge.remoteBridgeContractAddress",
|
|
399
401
|
type: "string"
|
|
400
402
|
}),
|
|
401
|
-
|
|
403
|
+
remoteBridgeContractDeployBlock: z3.optional(z3.coerce.number().check(z3.multipleOf(1), z3.nonnegative())).register(globalRegistry2, {
|
|
404
|
+
description: "EVM block at which the remote bridge contract was deployed. When unset, the bridge actor probes the chain via eth_getCode at actor startup. Setting this avoids the probe and is cheaper for chains with high heads; it must be at or before the actual deploy block.",
|
|
405
|
+
title: "bridge.remoteBridgeContractDeployBlock",
|
|
406
|
+
type: "number"
|
|
407
|
+
}),
|
|
408
|
+
remoteChainId: z3._default(HexZod, DEFAULT_HARDHAT_CHAIN_ID).register(globalRegistry2, {
|
|
402
409
|
default: DEFAULT_HARDHAT_CHAIN_ID,
|
|
403
410
|
description: "Remote chain ID",
|
|
404
411
|
title: "bridge.remoteChainId",
|
|
405
412
|
type: "string"
|
|
406
413
|
}),
|
|
407
|
-
remoteConfirmationDepth: z3.union([
|
|
408
|
-
z3.coerce.number().
|
|
414
|
+
remoteConfirmationDepth: z3.optional(z3.union([
|
|
415
|
+
z3.coerce.number().check(z3.multipleOf(1), z3.nonnegative()),
|
|
409
416
|
z3.literal("finalized")
|
|
410
|
-
])
|
|
417
|
+
])).register(globalRegistry2, {
|
|
411
418
|
description: "Block depth or BlockTag at which the remote (EVM) chain is read as canonical. Numeric: number of confirmations behind head. 'finalized': Casper FFG finalized block. Resolved per-chain by getRemoteConfirmationDepth when unset.",
|
|
412
419
|
title: "bridge.remoteConfirmationDepth",
|
|
413
420
|
type: "string"
|
|
414
421
|
}),
|
|
415
|
-
remoteTokenAddress:
|
|
422
|
+
remoteTokenAddress: z3._default(HexZod, DEFAULT_HARDHAT_TOKEN_CONTRACT).register(globalRegistry2, {
|
|
416
423
|
default: DEFAULT_HARDHAT_TOKEN_CONTRACT,
|
|
417
424
|
description: "Hex representation of remote token address used for bridging",
|
|
418
425
|
title: "bridge.remoteTokenAddress",
|
|
419
426
|
type: "string"
|
|
420
427
|
}),
|
|
421
|
-
remoteChainWalletPrivateKey:
|
|
428
|
+
remoteChainWalletPrivateKey: z3._default(HexZod, DEFAULT_HARDHAT_REMOTE_CHAIN_WALLET_PRIVATE_KEY).register(globalRegistry2, {
|
|
422
429
|
description: "Private key for the wallet to use for the remote chain wallet",
|
|
423
430
|
title: "bridge.remoteChainWalletPrivateKey",
|
|
424
431
|
type: "string"
|
|
425
432
|
}),
|
|
426
|
-
xl1ChainId:
|
|
433
|
+
xl1ChainId: z3.optional(HexZod).register(globalRegistry2, {
|
|
427
434
|
description: "XL1 chain id used for bridging",
|
|
428
435
|
title: "bridge.xl1ChainId",
|
|
429
436
|
type: "string"
|
|
430
437
|
}),
|
|
431
|
-
xl1TokenAddress:
|
|
438
|
+
xl1TokenAddress: z3.optional(HexZod).register(globalRegistry2, {
|
|
432
439
|
description: "XL1 token address used for bridging",
|
|
433
440
|
title: "bridge.xl1TokenAddress",
|
|
434
441
|
type: "string"
|
|
435
442
|
})
|
|
436
443
|
});
|
|
437
|
-
var BridgeSettingsZod =
|
|
444
|
+
var BridgeSettingsZod = z3.required(z3.pick(BridgeConfigZod, {
|
|
438
445
|
feeFixed: true,
|
|
439
446
|
feeRateBasisPoints: true,
|
|
440
447
|
feesAddress: true,
|
|
@@ -445,94 +452,98 @@ var BridgeSettingsZod = BridgeConfigZod.pick({
|
|
|
445
452
|
remoteTokenAddress: true,
|
|
446
453
|
xl1TokenAddress: true,
|
|
447
454
|
xl1ChainId: true
|
|
448
|
-
})
|
|
455
|
+
}));
|
|
449
456
|
var isBridgeConfig = zodIsFactory2(BridgeConfigZod);
|
|
450
457
|
var asBridgeConfig = zodAsFactory2(BridgeConfigZod, "asBridgeConfig");
|
|
451
458
|
var toBridgeConfig = zodToFactory2(BridgeConfigZod, "toBridgeConfig");
|
|
452
|
-
var BridgeConfigContext =
|
|
453
|
-
config: BridgeConfigZod
|
|
454
|
-
});
|
|
459
|
+
var BridgeConfigContext = z3.extend(BaseConfigContextZod2, { config: BridgeConfigZod });
|
|
455
460
|
var isBridgeConfigContext = zodIsFactory2(BridgeConfigContext);
|
|
456
461
|
var asBridgeConfigContext = zodAsFactory2(BridgeConfigContext, "asBridgeConfigContext");
|
|
457
462
|
var toBridgeConfigContext = zodToFactory2(BridgeConfigContext, "toBridgeConfigContext");
|
|
458
463
|
|
|
459
464
|
// src/shared/config/actors/Finalizer.ts
|
|
460
|
-
import {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
+
import {
|
|
466
|
+
AddressZod as AddressZod2,
|
|
467
|
+
zodAsFactory as zodAsFactory3,
|
|
468
|
+
zodIsFactory as zodIsFactory3,
|
|
469
|
+
zodToFactory as zodToFactory3
|
|
470
|
+
} from "@xylabs/sdk-js";
|
|
471
|
+
import {
|
|
472
|
+
BaseConfigContextZod as BaseConfigContextZod3,
|
|
473
|
+
DEFAULT_MIN_CANDIDATES,
|
|
474
|
+
HostActorConfigZod as HostActorConfigZod3
|
|
475
|
+
} from "@xyo-network/xl1-sdk";
|
|
476
|
+
import { z as z4 } from "zod/mini";
|
|
477
|
+
var FinalizerConfigZod = z4.extend(HostActorConfigZod3, {
|
|
478
|
+
allowedProducers: z4.optional(z4.array(AddressZod2)),
|
|
465
479
|
// Period (ms) between finalizer ticks. Default matches the historical
|
|
466
480
|
// hardcoded value in FinalizerActor; tests can lower it to drive faster
|
|
467
481
|
// block finalization.
|
|
468
|
-
finalizationCheckInterval: z4.coerce.number()
|
|
469
|
-
minCandidates: z4.number().
|
|
482
|
+
finalizationCheckInterval: z4._default(z4.coerce.number(), 500),
|
|
483
|
+
minCandidates: z4._default(z4.number().check(z4.multipleOf(1), z4.nonnegative()), DEFAULT_MIN_CANDIDATES)
|
|
470
484
|
});
|
|
471
485
|
var isFinalizerConfig = zodIsFactory3(FinalizerConfigZod);
|
|
472
486
|
var asFinalizerConfig = zodAsFactory3(FinalizerConfigZod, "asFinalizerConfig");
|
|
473
487
|
var toFinalizerConfig = zodToFactory3(FinalizerConfigZod, "toFinalizerConfig");
|
|
474
|
-
var FinalizerConfigContext =
|
|
475
|
-
config: FinalizerConfigZod
|
|
476
|
-
});
|
|
488
|
+
var FinalizerConfigContext = z4.extend(BaseConfigContextZod3, { config: FinalizerConfigZod });
|
|
477
489
|
var isFinalizerConfigContext = zodIsFactory3(FinalizerConfigContext);
|
|
478
490
|
var asFinalizerConfigContext = zodAsFactory3(FinalizerConfigContext, "asFinalizerConfigContext");
|
|
479
491
|
var toFinalizerConfigContext = zodToFactory3(FinalizerConfigContext, "toFinalizerConfigContext");
|
|
480
492
|
|
|
481
493
|
// src/shared/config/actors/Mempool.ts
|
|
482
|
-
import {
|
|
494
|
+
import {
|
|
495
|
+
zodAsFactory as zodAsFactory4,
|
|
496
|
+
zodIsFactory as zodIsFactory4,
|
|
497
|
+
zodToFactory as zodToFactory4
|
|
498
|
+
} from "@xylabs/sdk-js";
|
|
483
499
|
import { BaseConfigContextZod as BaseConfigContextZod4, HostActorConfigZod as HostActorConfigZod4 } from "@xyo-network/xl1-sdk";
|
|
484
|
-
import { globalRegistry as globalRegistry3, z as z5 } from "zod";
|
|
500
|
+
import { globalRegistry as globalRegistry3, z as z5 } from "zod/mini";
|
|
485
501
|
var DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL = 1e3;
|
|
486
502
|
var DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL = 1e3;
|
|
487
503
|
var DEFAULT_MEMPOOL_DEMOTION_THRESHOLD = 3;
|
|
488
504
|
var DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS = 0;
|
|
489
|
-
var
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (typeof val === "boolean") return val;
|
|
505
|
+
var TRUE_VALUES = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
|
|
506
|
+
var FALSE_VALUES = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
|
|
507
|
+
var FlexibleBooleanZod = z5.pipe(
|
|
508
|
+
z5.union([z5.string(), z5.boolean()]).check(z5.refine((val) => {
|
|
509
|
+
if (typeof val === "boolean") return true;
|
|
495
510
|
const normalized = val.toLowerCase().trim();
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
"off"
|
|
507
|
-
].includes(normalized)) return false;
|
|
508
|
-
ctx.addIssue({
|
|
509
|
-
code: "invalid_type",
|
|
510
|
-
expected: "boolean",
|
|
511
|
-
message: `Invalid boolean value: "${val}". Use true/false, 1/0, yes/no.`
|
|
512
|
-
});
|
|
513
|
-
return z5.NEVER;
|
|
514
|
-
}).register(globalRegistry3, {
|
|
515
|
-
default: "false",
|
|
511
|
+
return TRUE_VALUES.has(normalized) || FALSE_VALUES.has(normalized);
|
|
512
|
+
}, { error: "Invalid boolean value. Use true/false, 1/0, yes/no." })),
|
|
513
|
+
z5.transform((val) => {
|
|
514
|
+
if (typeof val === "boolean") return val;
|
|
515
|
+
return TRUE_VALUES.has(val.toLowerCase().trim());
|
|
516
|
+
})
|
|
517
|
+
);
|
|
518
|
+
var MempoolConfigZod = z5.extend(HostActorConfigZod4, {
|
|
519
|
+
enabled: z5._default(FlexibleBooleanZod, false).register(globalRegistry3, {
|
|
520
|
+
default: false,
|
|
516
521
|
description: "Enable the Mempool",
|
|
517
522
|
title: "mempool.enabled",
|
|
518
523
|
type: "boolean"
|
|
519
524
|
}),
|
|
520
|
-
blockPruneInterval: z5.coerce.number()
|
|
525
|
+
blockPruneInterval: z5._default(z5.coerce.number(), DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL).register(globalRegistry3, {
|
|
521
526
|
description: "The interval time (in milliseconds) between pending block prune attempts",
|
|
522
527
|
title: "mempool.blockPruneInterval",
|
|
523
528
|
type: "number"
|
|
524
529
|
}),
|
|
525
|
-
demotionThreshold: z5.
|
|
530
|
+
demotionThreshold: z5._default(
|
|
531
|
+
z5.coerce.number().check(z5.multipleOf(1), z5.positive()),
|
|
532
|
+
DEFAULT_MEMPOOL_DEMOTION_THRESHOLD
|
|
533
|
+
).register(globalRegistry3, {
|
|
526
534
|
description: "Number of times a transaction may be handed out to producers without being included in a block before it is considered demoted",
|
|
527
535
|
title: "mempool.demotionThreshold",
|
|
528
536
|
type: "number"
|
|
529
537
|
}),
|
|
530
|
-
maxPendingTransactions: z5.
|
|
538
|
+
maxPendingTransactions: z5._default(
|
|
539
|
+
z5.coerce.number().check(z5.multipleOf(1), z5.nonnegative()),
|
|
540
|
+
DEFAULT_MEMPOOL_MAX_PENDING_TRANSACTIONS
|
|
541
|
+
).register(globalRegistry3, {
|
|
531
542
|
description: "Maximum number of pending transactions in the pool. When exceeded, demoted transactions are evicted first, then oldest by sequence. 0 disables the cap.",
|
|
532
543
|
title: "mempool.maxPendingTransactions",
|
|
533
544
|
type: "number"
|
|
534
545
|
}),
|
|
535
|
-
transactionPruneInterval: z5.coerce.number()
|
|
546
|
+
transactionPruneInterval: z5._default(z5.coerce.number(), DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL).register(globalRegistry3, {
|
|
536
547
|
description: "The interval time (in milliseconds) between pending transaction prune attempts",
|
|
537
548
|
title: "mempool.transactionPruneInterval",
|
|
538
549
|
type: "number"
|
|
@@ -541,72 +552,76 @@ var MempoolConfigZod = HostActorConfigZod4.extend({
|
|
|
541
552
|
var isMempoolConfig = zodIsFactory4(MempoolConfigZod);
|
|
542
553
|
var asMempoolConfig = zodAsFactory4(MempoolConfigZod, "asMempoolConfig");
|
|
543
554
|
var toMempoolConfig = zodToFactory4(MempoolConfigZod, "toMempoolConfig");
|
|
544
|
-
var MempoolConfigContext =
|
|
545
|
-
config: MempoolConfigZod
|
|
546
|
-
});
|
|
555
|
+
var MempoolConfigContext = z5.extend(BaseConfigContextZod4, { config: MempoolConfigZod });
|
|
547
556
|
var isMempoolConfigContext = zodIsFactory4(MempoolConfigContext);
|
|
548
557
|
var asMempoolConfigContext = zodAsFactory4(MempoolConfigContext, "asMempoolConfigContext");
|
|
549
558
|
var toMempoolConfigContext = zodToFactory4(MempoolConfigContext, "toMempoolConfigContext");
|
|
550
559
|
|
|
551
560
|
// src/shared/config/actors/Producer.ts
|
|
552
|
-
import {
|
|
561
|
+
import {
|
|
562
|
+
AddressZod as AddressZod3,
|
|
563
|
+
zodAsFactory as zodAsFactory5,
|
|
564
|
+
zodIsFactory as zodIsFactory5,
|
|
565
|
+
zodToFactory as zodToFactory5
|
|
566
|
+
} from "@xylabs/sdk-js";
|
|
553
567
|
import { ActorConfigZod, BaseConfigContextZod as BaseConfigContextZod5 } from "@xyo-network/xl1-sdk";
|
|
554
|
-
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
568
|
+
import { globalRegistry as globalRegistry4, z as z6 } from "zod/mini";
|
|
555
569
|
var DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL = 1e4;
|
|
556
|
-
var ProducerConfigZod =
|
|
557
|
-
allowlist: z6.array(AddressZod3)
|
|
570
|
+
var ProducerConfigZod = z6.extend(ActorConfigZod, {
|
|
571
|
+
allowlist: z6.optional(z6.array(AddressZod3)).register(globalRegistry4, {
|
|
558
572
|
description: "List of allowed producer addresses, if undefined anyone can participate",
|
|
559
573
|
title: "allowlist",
|
|
560
574
|
type: "array"
|
|
561
575
|
}),
|
|
562
|
-
blockProductionCheckInterval: z6.coerce.number()
|
|
576
|
+
blockProductionCheckInterval: z6._default(z6.coerce.number(), DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL).register(globalRegistry4, {
|
|
563
577
|
description: "The interval time (in milliseconds) between block production attempts",
|
|
564
578
|
title: "producer.blockProductionCheckInterval",
|
|
565
579
|
type: "number"
|
|
566
580
|
}),
|
|
567
|
-
disableIntentRedeclaration: z6.
|
|
581
|
+
disableIntentRedeclaration: z6.optional(z6.boolean()).register(globalRegistry4, {
|
|
568
582
|
description: "Should the producer skip redeclaring their intent to continue producing blocks",
|
|
569
583
|
title: "producer.disableIntentRedeclaration",
|
|
570
584
|
type: "boolean"
|
|
571
585
|
}),
|
|
572
|
-
heartbeatInterval: z6.coerce.number()
|
|
586
|
+
heartbeatInterval: z6._default(z6.coerce.number(), 36e5).register(globalRegistry4, {
|
|
573
587
|
description: "The number of milliseconds between heartbeats if no blocks are produced",
|
|
574
588
|
title: "producer.heartbeatInterval",
|
|
575
589
|
type: "number"
|
|
576
590
|
}),
|
|
577
591
|
// TODO: BigInt schema
|
|
578
|
-
minStake: z6.coerce.number()
|
|
592
|
+
minStake: z6._default(z6.coerce.number(), 1).register(globalRegistry4, {
|
|
579
593
|
description: "Minimum stake required to be a Producer",
|
|
580
594
|
title: "producer.minStake",
|
|
581
595
|
type: "number"
|
|
582
596
|
}),
|
|
583
597
|
// TODO: Address schema
|
|
584
|
-
rewardAddress: z6.
|
|
598
|
+
rewardAddress: z6.optional(z6.string()).register(globalRegistry4, {
|
|
585
599
|
description: "Address to receive block rewards",
|
|
586
600
|
title: "producer.rewardAddress",
|
|
587
601
|
type: "string"
|
|
588
602
|
})
|
|
589
|
-
})
|
|
603
|
+
});
|
|
590
604
|
var isProducerConfig = zodIsFactory5(ProducerConfigZod);
|
|
591
605
|
var asProducerConfig = zodAsFactory5(ProducerConfigZod, "asProducerConfig");
|
|
592
606
|
var toProducerConfig = zodToFactory5(ProducerConfigZod, "toProducerConfig");
|
|
593
|
-
var ProducerConfigContext =
|
|
594
|
-
config: ProducerConfigZod
|
|
595
|
-
});
|
|
607
|
+
var ProducerConfigContext = z6.extend(BaseConfigContextZod5, { config: ProducerConfigZod });
|
|
596
608
|
var isProducerConfigContext = zodIsFactory5(ProducerConfigContext);
|
|
597
609
|
var asProducerConfigContext = zodAsFactory5(ProducerConfigContext, "asProducerConfigContext");
|
|
598
610
|
var toProducerConfigContext = zodToFactory5(ProducerConfigContext, "toProducerConfigContext");
|
|
599
611
|
|
|
600
612
|
// src/shared/config/actors/RewardRedemption.ts
|
|
601
|
-
import {
|
|
613
|
+
import {
|
|
614
|
+
zodAsFactory as zodAsFactory6,
|
|
615
|
+
zodIsFactory as zodIsFactory6,
|
|
616
|
+
zodToFactory as zodToFactory6
|
|
617
|
+
} from "@xylabs/sdk-js";
|
|
602
618
|
import { BaseConfigContextZod as BaseConfigContextZod6, HostActorConfigZod as HostActorConfigZod5 } from "@xyo-network/xl1-sdk";
|
|
603
|
-
|
|
619
|
+
import { z as z7 } from "zod/mini";
|
|
620
|
+
var RewardRedemptionConfigZod = z7.extend(HostActorConfigZod5, {});
|
|
604
621
|
var isRewardRedemptionConfig = zodIsFactory6(RewardRedemptionConfigZod);
|
|
605
622
|
var asRewardRedemptionConfig = zodAsFactory6(RewardRedemptionConfigZod, "asRewardRedemptionConfig");
|
|
606
623
|
var toRewardRedemptionConfig = zodToFactory6(RewardRedemptionConfigZod, "toRewardRedemptionConfig");
|
|
607
|
-
var RewardRedemptionConfigContext =
|
|
608
|
-
config: RewardRedemptionConfigZod
|
|
609
|
-
});
|
|
624
|
+
var RewardRedemptionConfigContext = z7.extend(BaseConfigContextZod6, { config: RewardRedemptionConfigZod });
|
|
610
625
|
var isRewardRedemptionConfigContext = zodIsFactory6(RewardRedemptionConfigContext);
|
|
611
626
|
var asRewardRedemptionConfigContext = zodAsFactory6(RewardRedemptionConfigContext, "asRewardRedemptionConfigContext");
|
|
612
627
|
var toRewardRedemptionConfigContext = zodToFactory6(RewardRedemptionConfigContext, "toRewardRedemptionConfigContext");
|
|
@@ -621,26 +636,27 @@ function mergeConfig({ actors, ...baseConfig }) {
|
|
|
621
636
|
})
|
|
622
637
|
};
|
|
623
638
|
}
|
|
624
|
-
__name(mergeConfig, "mergeConfig");
|
|
625
639
|
|
|
626
640
|
// src/shared/createDeclarationIntentBlock.ts
|
|
627
641
|
import { buildNextBlock } from "@xyo-network/chain-sdk";
|
|
628
642
|
import { createDeclarationIntent } from "@xyo-network/xl1-sdk";
|
|
629
643
|
async function createProducerChainStakeIntentBlock(prevBlock, producerAccount, range) {
|
|
630
|
-
const producerDeclarationPayload = createDeclarationIntent(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
644
|
+
const producerDeclarationPayload = createDeclarationIntent(
|
|
645
|
+
producerAccount.address,
|
|
646
|
+
"producer",
|
|
647
|
+
range[0],
|
|
648
|
+
range[1]
|
|
649
|
+
);
|
|
650
|
+
return await buildNextBlock(
|
|
651
|
+
prevBlock,
|
|
652
|
+
[],
|
|
653
|
+
[producerDeclarationPayload],
|
|
654
|
+
[producerAccount]
|
|
655
|
+
);
|
|
636
656
|
}
|
|
637
|
-
__name(createProducerChainStakeIntentBlock, "createProducerChainStakeIntentBlock");
|
|
638
657
|
|
|
639
658
|
// src/shared/host/implementation/DefaultHost.ts
|
|
640
659
|
var GenericHost = class {
|
|
641
|
-
static {
|
|
642
|
-
__name(this, "GenericHost");
|
|
643
|
-
}
|
|
644
660
|
services;
|
|
645
661
|
constructor(services) {
|
|
646
662
|
this.services = services;
|
|
@@ -657,9 +673,6 @@ var GenericHost = class {
|
|
|
657
673
|
|
|
658
674
|
// src/shared/host/implementation/DefaultServiceProvider.ts
|
|
659
675
|
var DefaultServiceProvider = class {
|
|
660
|
-
static {
|
|
661
|
-
__name(this, "DefaultServiceProvider");
|
|
662
|
-
}
|
|
663
676
|
_services;
|
|
664
677
|
constructor(services) {
|
|
665
678
|
this._services = services;
|
|
@@ -709,24 +722,19 @@ var activeWalletReport;
|
|
|
709
722
|
function getAccountLabel(actorName) {
|
|
710
723
|
return ACTOR_LABELS[actorName] ?? actorName;
|
|
711
724
|
}
|
|
712
|
-
__name(getAccountLabel, "getAccountLabel");
|
|
713
725
|
function clearResolvedWalletReport() {
|
|
714
726
|
activeWalletReport = void 0;
|
|
715
727
|
}
|
|
716
|
-
__name(clearResolvedWalletReport, "clearResolvedWalletReport");
|
|
717
728
|
function resolveActorAccountPath(actorName, actorConfig) {
|
|
718
729
|
if (actorConfig?.accountPath !== void 0) return actorConfig.accountPath;
|
|
719
730
|
return DEFAULT_ACTOR_ACCOUNT_PATH[actorName] ?? "0";
|
|
720
731
|
}
|
|
721
|
-
__name(resolveActorAccountPath, "resolveActorAccountPath");
|
|
722
732
|
function isAbsoluteAccountPath(accountPath) {
|
|
723
733
|
return accountPath.startsWith("m/");
|
|
724
734
|
}
|
|
725
|
-
__name(isAbsoluteAccountPath, "isAbsoluteAccountPath");
|
|
726
735
|
function expandAccountPath(accountPath, basePath = DEFAULT_WALLET_PATH) {
|
|
727
736
|
return isAbsoluteAccountPath(accountPath) ? accountPath : `${basePath}/${accountPath}`;
|
|
728
737
|
}
|
|
729
|
-
__name(expandAccountPath, "expandAccountPath");
|
|
730
738
|
async function deriveWalletAtPath(mnemonic, accountPath) {
|
|
731
739
|
if (isAbsoluteAccountPath(accountPath)) {
|
|
732
740
|
const seed = Mnemonic.fromPhrase(mnemonic).computeSeed();
|
|
@@ -737,15 +745,12 @@ async function deriveWalletAtPath(mnemonic, accountPath) {
|
|
|
737
745
|
const baseWallet = await generateXyoBaseWalletFromPhrase(mnemonic);
|
|
738
746
|
return await baseWallet.derivePath(accountPath);
|
|
739
747
|
}
|
|
740
|
-
__name(deriveWalletAtPath, "deriveWalletAtPath");
|
|
741
748
|
function getBuiltInDevMnemonic() {
|
|
742
749
|
return BUILT_IN_DEV_MNEMONIC;
|
|
743
750
|
}
|
|
744
|
-
__name(getBuiltInDevMnemonic, "getBuiltInDevMnemonic");
|
|
745
751
|
function getInsecureGenesisRewardMnemonic() {
|
|
746
752
|
return INSECURE_GENESIS_REWARD_MNEMONIC;
|
|
747
753
|
}
|
|
748
|
-
__name(getInsecureGenesisRewardMnemonic, "getInsecureGenesisRewardMnemonic");
|
|
749
754
|
function resolveRootWallet(configuration) {
|
|
750
755
|
const isConfigured = configuration.mnemonic !== void 0;
|
|
751
756
|
const mnemonic = configuration.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
@@ -758,8 +763,12 @@ function resolveRootWallet(configuration) {
|
|
|
758
763
|
mnemonicKind: isBuiltInDevMnemonic ? "built-in-dev" : "configured-root"
|
|
759
764
|
};
|
|
760
765
|
}
|
|
761
|
-
|
|
762
|
-
|
|
766
|
+
async function resolveWalletMetadata({
|
|
767
|
+
accountPath,
|
|
768
|
+
actorName,
|
|
769
|
+
mnemonic,
|
|
770
|
+
mnemonicKind
|
|
771
|
+
}) {
|
|
763
772
|
const account = await deriveWalletAtPath(mnemonic, accountPath);
|
|
764
773
|
return {
|
|
765
774
|
accountPath,
|
|
@@ -773,7 +782,6 @@ async function resolveWalletMetadata({ accountPath, actorName, mnemonic, mnemoni
|
|
|
773
782
|
usesBuiltInDevMnemonic: mnemonic === BUILT_IN_DEV_MNEMONIC
|
|
774
783
|
};
|
|
775
784
|
}
|
|
776
|
-
__name(resolveWalletMetadata, "resolveWalletMetadata");
|
|
777
785
|
async function resolveActorWallet(actorName, actorConfig, root) {
|
|
778
786
|
return await resolveWalletMetadata({
|
|
779
787
|
accountPath: resolveActorAccountPath(actorName, actorConfig),
|
|
@@ -782,11 +790,7 @@ async function resolveActorWallet(actorName, actorConfig, root) {
|
|
|
782
790
|
mnemonicKind: root.mnemonicKind
|
|
783
791
|
});
|
|
784
792
|
}
|
|
785
|
-
__name(resolveActorWallet, "resolveActorWallet");
|
|
786
793
|
var ActorMnemonicNotAllowedError = class extends Error {
|
|
787
|
-
static {
|
|
788
|
-
__name(this, "ActorMnemonicNotAllowedError");
|
|
789
|
-
}
|
|
790
794
|
actors;
|
|
791
795
|
constructor(actors) {
|
|
792
796
|
super([
|
|
@@ -801,14 +805,12 @@ function assertNoActorMnemonics(configuration) {
|
|
|
801
805
|
const offenders = configuration.actors.filter((actor) => typeof actor.mnemonic === "string").map((actor) => actor.name);
|
|
802
806
|
if (offenders.length > 0) throw new ActorMnemonicNotAllowedError(offenders);
|
|
803
807
|
}
|
|
804
|
-
__name(assertNoActorMnemonics, "assertNoActorMnemonics");
|
|
805
808
|
var DerivationPathCollisionError = class extends Error {
|
|
806
|
-
static {
|
|
807
|
-
__name(this, "DerivationPathCollisionError");
|
|
808
|
-
}
|
|
809
809
|
collisions;
|
|
810
810
|
constructor(collisions) {
|
|
811
|
-
const lines = Object.entries(collisions).map(
|
|
811
|
+
const lines = Object.entries(collisions).map(
|
|
812
|
+
([path, actors]) => ` - ${actors.join(", ")} \u2192 ${path}`
|
|
813
|
+
);
|
|
812
814
|
super([
|
|
813
815
|
"Two or more actors resolve to the same wallet derivation path:",
|
|
814
816
|
...lines,
|
|
@@ -819,10 +821,7 @@ var DerivationPathCollisionError = class extends Error {
|
|
|
819
821
|
}
|
|
820
822
|
};
|
|
821
823
|
function detectDerivationPathCollisions(requestedActors, configuration) {
|
|
822
|
-
const actorConfigMap = new Map(configuration.actors.map((actor) => [
|
|
823
|
-
actor.name,
|
|
824
|
-
actor
|
|
825
|
-
]));
|
|
824
|
+
const actorConfigMap = new Map(configuration.actors.map((actor) => [actor.name, actor]));
|
|
826
825
|
const bucketsByPath = /* @__PURE__ */ new Map();
|
|
827
826
|
for (const actorName of requestedActors) {
|
|
828
827
|
const accountPath = resolveActorAccountPath(actorName, actorConfigMap.get(actorName));
|
|
@@ -838,71 +837,57 @@ function detectDerivationPathCollisions(requestedActors, configuration) {
|
|
|
838
837
|
if (Object.keys(collisions).length === 0) return void 0;
|
|
839
838
|
return new DerivationPathCollisionError(collisions);
|
|
840
839
|
}
|
|
841
|
-
__name(detectDerivationPathCollisions, "detectDerivationPathCollisions");
|
|
842
840
|
async function resolveWalletReport(requestedActors, configuration) {
|
|
843
841
|
const root = resolveRootWallet(configuration);
|
|
844
|
-
const actorConfigMap = new Map(configuration.actors.map((actor) => [
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
const resolvedActors = await Promise.all(requestedActors.map(async (actorName) => await resolveActorWallet(actorName, actorConfigMap.get(actorName), root)));
|
|
842
|
+
const actorConfigMap = new Map(configuration.actors.map((actor) => [actor.name, actor]));
|
|
843
|
+
const resolvedActors = await Promise.all(
|
|
844
|
+
requestedActors.map(async (actorName) => await resolveActorWallet(actorName, actorConfigMap.get(actorName), root))
|
|
845
|
+
);
|
|
849
846
|
const labelMap = /* @__PURE__ */ new Map();
|
|
850
847
|
for (const actor of resolvedActors) {
|
|
851
848
|
const labels = labelMap.get(actor.derivationPath) ?? [];
|
|
852
849
|
labels.push(actor.label);
|
|
853
850
|
labelMap.set(actor.derivationPath, labels);
|
|
854
851
|
}
|
|
855
|
-
const sharedAccounts = await Promise.all(
|
|
856
|
-
length: SHARED_ACCOUNT_REPORT_COUNT
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
label: labels?.join(", ") ?? `shared[${sharedIndex}]`
|
|
868
|
-
};
|
|
869
|
-
}));
|
|
852
|
+
const sharedAccounts = await Promise.all(
|
|
853
|
+
Array.from({ length: SHARED_ACCOUNT_REPORT_COUNT }, (_, index) => index).map(async (sharedIndex) => {
|
|
854
|
+
const account = await resolveWalletMetadata({
|
|
855
|
+
accountPath: `${sharedIndex}`,
|
|
856
|
+
actorName: ROOT_WALLET_RUNTIME_ID,
|
|
857
|
+
mnemonic: root.mnemonic,
|
|
858
|
+
mnemonicKind: root.mnemonicKind
|
|
859
|
+
});
|
|
860
|
+
const labels = labelMap.get(account.derivationPath);
|
|
861
|
+
return { ...account, label: labels?.join(", ") ?? `shared[${sharedIndex}]` };
|
|
862
|
+
})
|
|
863
|
+
);
|
|
870
864
|
return {
|
|
871
|
-
requestedActors: [
|
|
872
|
-
...requestedActors
|
|
873
|
-
],
|
|
865
|
+
requestedActors: [...requestedActors],
|
|
874
866
|
root,
|
|
875
867
|
sharedAccounts
|
|
876
868
|
};
|
|
877
869
|
}
|
|
878
|
-
__name(resolveWalletReport, "resolveWalletReport");
|
|
879
870
|
async function buildInsecureGenesisRewardAccounts() {
|
|
880
|
-
const accounts = await Promise.all(
|
|
881
|
-
length: SHARED_ACCOUNT_REPORT_COUNT
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
label: sharedIndex === 0 ? "genesisRewardAddress" : `genesisReward[${sharedIndex}]`
|
|
892
|
-
};
|
|
893
|
-
}));
|
|
871
|
+
const accounts = await Promise.all(
|
|
872
|
+
Array.from({ length: SHARED_ACCOUNT_REPORT_COUNT }, (_, index) => index).map(async (sharedIndex) => {
|
|
873
|
+
const account = await resolveWalletMetadata({
|
|
874
|
+
accountPath: `${sharedIndex}`,
|
|
875
|
+
actorName: "genesisReward",
|
|
876
|
+
mnemonic: INSECURE_GENESIS_REWARD_MNEMONIC,
|
|
877
|
+
mnemonicKind: "insecure-genesis-reward"
|
|
878
|
+
});
|
|
879
|
+
return { ...account, label: sharedIndex === 0 ? "genesisRewardAddress" : `genesisReward[${sharedIndex}]` };
|
|
880
|
+
})
|
|
881
|
+
);
|
|
894
882
|
return accounts;
|
|
895
883
|
}
|
|
896
|
-
__name(buildInsecureGenesisRewardAccounts, "buildInsecureGenesisRewardAccounts");
|
|
897
884
|
async function initializeResolvedWalletReport(requestedActors, configuration) {
|
|
898
885
|
activeWalletReport = await resolveWalletReport(requestedActors, configuration);
|
|
899
886
|
return activeWalletReport;
|
|
900
887
|
}
|
|
901
|
-
__name(initializeResolvedWalletReport, "initializeResolvedWalletReport");
|
|
902
888
|
function getResolvedWalletReport() {
|
|
903
889
|
return activeWalletReport;
|
|
904
890
|
}
|
|
905
|
-
__name(getResolvedWalletReport, "getResolvedWalletReport");
|
|
906
891
|
function formatSharedAccount(account, showPrivateKey) {
|
|
907
892
|
const lines = [
|
|
908
893
|
`[${account.accountPath}] ${account.label}`,
|
|
@@ -913,7 +898,6 @@ function formatSharedAccount(account, showPrivateKey) {
|
|
|
913
898
|
if (showPrivateKey) lines.push(`privateKey: ${account.privateKey ?? "unavailable"}`);
|
|
914
899
|
return lines.join("\n");
|
|
915
900
|
}
|
|
916
|
-
__name(formatSharedAccount, "formatSharedAccount");
|
|
917
901
|
function formatGenesisRewardAccount(account) {
|
|
918
902
|
const balance = account.accountPath === "0" ? GENESIS_REWARD_AMOUNT / ATTO_XL1_PER_XL1 : 0n;
|
|
919
903
|
return [
|
|
@@ -924,7 +908,6 @@ function formatGenesisRewardAccount(account) {
|
|
|
924
908
|
`balance: ${balance.toString()} XL1`
|
|
925
909
|
].join("\n");
|
|
926
910
|
}
|
|
927
|
-
__name(formatGenesisRewardAccount, "formatGenesisRewardAccount");
|
|
928
911
|
function formatWalletReport(report) {
|
|
929
912
|
const sections = [];
|
|
930
913
|
const showSecrets = report.root.isBuiltInDevMnemonic;
|
|
@@ -949,7 +932,6 @@ function formatWalletReport(report) {
|
|
|
949
932
|
].join("\n"));
|
|
950
933
|
return sections.join("\n\n");
|
|
951
934
|
}
|
|
952
|
-
__name(formatWalletReport, "formatWalletReport");
|
|
953
935
|
function formatInsecureGenesisRewardWarning(accounts) {
|
|
954
936
|
return [
|
|
955
937
|
"INSECURE GENESIS REWARD WALLET WARNING",
|
|
@@ -968,21 +950,18 @@ function formatInsecureGenesisRewardWarning(accounts) {
|
|
|
968
950
|
accounts.map((account) => formatGenesisRewardAccount(account)).join("\n\n")
|
|
969
951
|
].join("\n");
|
|
970
952
|
}
|
|
971
|
-
__name(formatInsecureGenesisRewardWarning, "formatInsecureGenesisRewardWarning");
|
|
972
953
|
async function resolveGenesisRewardAddress(config) {
|
|
973
954
|
if (config.chain.genesisRewardAddress) return config.chain.genesisRewardAddress;
|
|
974
955
|
const wallet = await generateXyoBaseWalletFromPhrase(INSECURE_GENESIS_REWARD_MNEMONIC);
|
|
975
956
|
const account = await wallet.derivePath("0");
|
|
976
957
|
return account.address;
|
|
977
958
|
}
|
|
978
|
-
__name(resolveGenesisRewardAddress, "resolveGenesisRewardAddress");
|
|
979
959
|
async function resolveWalletForActor(actorName, accountPath) {
|
|
980
960
|
const report = activeWalletReport;
|
|
981
961
|
const mnemonic = report?.root.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
982
962
|
const resolvedAccountPath = accountPath ?? resolveActorAccountPath(actorName);
|
|
983
963
|
return await deriveWalletAtPath(mnemonic, resolvedAccountPath);
|
|
984
964
|
}
|
|
985
|
-
__name(resolveWalletForActor, "resolveWalletForActor");
|
|
986
965
|
|
|
987
966
|
// src/shared/init/initActorSeedPhrase.ts
|
|
988
967
|
async function initActorSeedPhrase(context, bios) {
|
|
@@ -995,7 +974,6 @@ async function initActorSeedPhrase(context, bios) {
|
|
|
995
974
|
logger?.debug(`[${walletKind}] Falling back to built-in development mnemonic`);
|
|
996
975
|
return assertEx2(fallback, () => "Unable to resolve mnemonic");
|
|
997
976
|
}
|
|
998
|
-
__name(initActorSeedPhrase, "initActorSeedPhrase");
|
|
999
977
|
|
|
1000
978
|
// src/shared/init/initBridgedModule.ts
|
|
1001
979
|
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
@@ -1018,33 +996,26 @@ async function initBridgedModule({ bridge, moduleName }) {
|
|
|
1018
996
|
return moduleInstance;
|
|
1019
997
|
});
|
|
1020
998
|
}
|
|
1021
|
-
__name(initBridgedModule, "initBridgedModule");
|
|
1022
999
|
async function initBridgedArchivistModule({ bridge, moduleName }) {
|
|
1023
|
-
return assertEx3(
|
|
1024
|
-
bridge,
|
|
1025
|
-
moduleName
|
|
1026
|
-
|
|
1000
|
+
return assertEx3(
|
|
1001
|
+
asAttachableArchivistInstance(await initBridgedModule({ bridge, moduleName })),
|
|
1002
|
+
() => `Could not convert ${moduleName} to attachable archivist instance`
|
|
1003
|
+
);
|
|
1027
1004
|
}
|
|
1028
|
-
__name(initBridgedArchivistModule, "initBridgedArchivistModule");
|
|
1029
1005
|
|
|
1030
1006
|
// src/shared/init/initStatusReporter.ts
|
|
1031
1007
|
import { RuntimeStatusMonitor } from "@xyo-network/xl1-sdk";
|
|
1032
1008
|
function initStatusReporter({ logger }) {
|
|
1033
1009
|
const statusReporter = new RuntimeStatusMonitor(logger);
|
|
1034
|
-
statusReporter.onGlobalTransition({
|
|
1035
|
-
to: "started"
|
|
1036
|
-
}, () => {
|
|
1010
|
+
statusReporter.onGlobalTransition({ to: "started" }, () => {
|
|
1037
1011
|
logger.log("All services started.");
|
|
1038
1012
|
});
|
|
1039
|
-
statusReporter.onGlobalTransition({
|
|
1040
|
-
to: "error"
|
|
1041
|
-
}, () => {
|
|
1013
|
+
statusReporter.onGlobalTransition({ to: "error" }, () => {
|
|
1042
1014
|
logger.error("Producer encountered an unhandled error!");
|
|
1043
1015
|
process.exit(1);
|
|
1044
1016
|
});
|
|
1045
1017
|
return statusReporter;
|
|
1046
1018
|
}
|
|
1047
|
-
__name(initStatusReporter, "initStatusReporter");
|
|
1048
1019
|
|
|
1049
1020
|
// src/shared/init/initWallet.ts
|
|
1050
1021
|
import { isDefined } from "@xylabs/sdk-js";
|
|
@@ -1058,21 +1029,10 @@ async function initActorWallet(context) {
|
|
|
1058
1029
|
actorAccountSingletons[actorName] = account;
|
|
1059
1030
|
return actorAccountSingletons[actorName];
|
|
1060
1031
|
}
|
|
1061
|
-
__name(initActorWallet, "initActorWallet");
|
|
1062
1032
|
|
|
1063
1033
|
// src/shared/orchestrator/Orchestrator.ts
|
|
1064
1034
|
import { AbstractCreatable as AbstractCreatable2, creatable } from "@xylabs/sdk-js";
|
|
1065
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
1066
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1067
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1068
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1069
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1070
|
-
}
|
|
1071
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
1072
1035
|
var Orchestrator = class extends AbstractCreatable2 {
|
|
1073
|
-
static {
|
|
1074
|
-
__name(this, "Orchestrator");
|
|
1075
|
-
}
|
|
1076
1036
|
actors = [];
|
|
1077
1037
|
running = false;
|
|
1078
1038
|
shuttingDown = false;
|
|
@@ -1089,9 +1049,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1089
1049
|
return this.shuttingDown;
|
|
1090
1050
|
}
|
|
1091
1051
|
/**
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1052
|
+
* Registers an actor.
|
|
1053
|
+
* (We won't activate the actor until `start()` is called.)
|
|
1054
|
+
*/
|
|
1095
1055
|
async registerActor(actor) {
|
|
1096
1056
|
this.actors.push(actor);
|
|
1097
1057
|
if (this.running) {
|
|
@@ -1104,9 +1064,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1104
1064
|
}
|
|
1105
1065
|
}
|
|
1106
1066
|
/**
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1067
|
+
* Starts the orchestrator: activates all actors in parallel and kicks off their warm-pass.
|
|
1068
|
+
* `whenReady()` resolves once every actor's `readyHandler` has succeeded.
|
|
1069
|
+
*/
|
|
1110
1070
|
async startHandler() {
|
|
1111
1071
|
await super.startHandler();
|
|
1112
1072
|
if (this.running) {
|
|
@@ -1116,12 +1076,7 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1116
1076
|
this.logger?.log(`[Orchestrator] Starting ${this.actors.length} actor(s) in parallel...`);
|
|
1117
1077
|
this.running = true;
|
|
1118
1078
|
const startResults = await Promise.allSettled(this.actors.map((a) => a.start()));
|
|
1119
|
-
const startFailures = startResults.flatMap((r, i) => r.status === "rejected" ? [
|
|
1120
|
-
{
|
|
1121
|
-
actor: this.actors[i],
|
|
1122
|
-
reason: r.reason
|
|
1123
|
-
}
|
|
1124
|
-
] : []);
|
|
1079
|
+
const startFailures = startResults.flatMap((r, i) => r.status === "rejected" ? [{ actor: this.actors[i], reason: r.reason }] : []);
|
|
1125
1080
|
if (startFailures.length > 0) {
|
|
1126
1081
|
for (const f of startFailures) this.logger?.error(`[Orchestrator] Actor [${f.actor?.name ?? "?"}] failed to start: ${formatError(f.reason)}`);
|
|
1127
1082
|
throw new Error(`[Orchestrator] ${startFailures.length} actor(s) failed to start`);
|
|
@@ -1135,8 +1090,8 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1135
1090
|
}
|
|
1136
1091
|
}
|
|
1137
1092
|
/**
|
|
1138
|
-
|
|
1139
|
-
|
|
1093
|
+
* Stops the orchestrator: deactivates all actors.
|
|
1094
|
+
*/
|
|
1140
1095
|
async stopHandler() {
|
|
1141
1096
|
await super.stopHandler();
|
|
1142
1097
|
if (!this.running) {
|
|
@@ -1151,9 +1106,9 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1151
1106
|
this.logger?.log("[Orchestrator] Stopped.");
|
|
1152
1107
|
}
|
|
1153
1108
|
/**
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1109
|
+
* Resolves once every actor reports ready. Rejects if any actor's `readyHandler` throws,
|
|
1110
|
+
* or after `timeoutMs` if provided.
|
|
1111
|
+
*/
|
|
1157
1112
|
async whenReady(timeoutMs) {
|
|
1158
1113
|
const localActors = this.actors.filter(isLocalActor);
|
|
1159
1114
|
if (localActors.length === 0) return;
|
|
@@ -1168,50 +1123,30 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1168
1123
|
}, timeoutMs);
|
|
1169
1124
|
});
|
|
1170
1125
|
try {
|
|
1171
|
-
await Promise.race([
|
|
1172
|
-
Promise.all(localActors.map((a) => a.whenReady())),
|
|
1173
|
-
timeout
|
|
1174
|
-
]);
|
|
1126
|
+
await Promise.race([Promise.all(localActors.map((a) => a.whenReady())), timeout]);
|
|
1175
1127
|
} finally {
|
|
1176
1128
|
if (timer) clearTimeout(timer);
|
|
1177
1129
|
}
|
|
1178
1130
|
}
|
|
1179
1131
|
};
|
|
1180
|
-
Orchestrator =
|
|
1132
|
+
Orchestrator = __decorateClass([
|
|
1181
1133
|
creatable()
|
|
1182
1134
|
], Orchestrator);
|
|
1183
1135
|
function isLocalActor(actor) {
|
|
1184
1136
|
return actor instanceof ActorV3;
|
|
1185
1137
|
}
|
|
1186
|
-
__name(isLocalActor, "isLocalActor");
|
|
1187
1138
|
function formatError(err) {
|
|
1188
1139
|
if (err instanceof Error) return `${err.message}${err.stack ? `
|
|
1189
1140
|
${err.stack}` : ""}`;
|
|
1190
1141
|
return String(err);
|
|
1191
1142
|
}
|
|
1192
|
-
__name(formatError, "formatError");
|
|
1193
1143
|
|
|
1194
1144
|
// src/shared/provider/SimpleRejectedTransactionsArchivistProvider.ts
|
|
1195
1145
|
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
1196
1146
|
import { AbstractCreatableProvider, creatableProvider } from "@xyo-network/xl1-sdk";
|
|
1197
|
-
function _ts_decorate2(decorators, target, key, desc) {
|
|
1198
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1199
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1200
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1201
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1202
|
-
}
|
|
1203
|
-
__name(_ts_decorate2, "_ts_decorate");
|
|
1204
1147
|
var RejectedTransactionsArchivistProviderMoniker = "RejectedTransactionsArchivistProvider";
|
|
1205
|
-
var SimpleRejectedTransactionsArchivistProvider = class
|
|
1206
|
-
|
|
1207
|
-
__name(this, "SimpleRejectedTransactionsArchivistProvider");
|
|
1208
|
-
}
|
|
1209
|
-
static defaultMoniker = RejectedTransactionsArchivistProviderMoniker;
|
|
1210
|
-
static dependencies = [];
|
|
1211
|
-
static monikers = [
|
|
1212
|
-
RejectedTransactionsArchivistProviderMoniker
|
|
1213
|
-
];
|
|
1214
|
-
moniker = _SimpleRejectedTransactionsArchivistProvider.defaultMoniker;
|
|
1148
|
+
var SimpleRejectedTransactionsArchivistProvider = class extends AbstractCreatableProvider {
|
|
1149
|
+
moniker = SimpleRejectedTransactionsArchivistProvider.defaultMoniker;
|
|
1215
1150
|
get archivist() {
|
|
1216
1151
|
return this.params.archivist;
|
|
1217
1152
|
}
|
|
@@ -1222,27 +1157,24 @@ var SimpleRejectedTransactionsArchivistProvider = class _SimpleRejectedTransacti
|
|
|
1222
1157
|
};
|
|
1223
1158
|
}
|
|
1224
1159
|
};
|
|
1225
|
-
SimpleRejectedTransactionsArchivistProvider
|
|
1160
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "defaultMoniker", RejectedTransactionsArchivistProviderMoniker);
|
|
1161
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "dependencies", []);
|
|
1162
|
+
__publicField(SimpleRejectedTransactionsArchivistProvider, "monikers", [RejectedTransactionsArchivistProviderMoniker]);
|
|
1163
|
+
SimpleRejectedTransactionsArchivistProvider = __decorateClass([
|
|
1226
1164
|
creatableProvider()
|
|
1227
1165
|
], SimpleRejectedTransactionsArchivistProvider);
|
|
1228
1166
|
|
|
1229
1167
|
// src/neutral/config/locators/basicRemoteRunnerLocator.ts
|
|
1230
1168
|
import { basicRemoteRunnerLocator as sdkBasicRemoteRunnerLocator } from "@xyo-network/xl1-sdk";
|
|
1231
1169
|
function basicRemoteRunnerLocator(name, remoteConfig, signerTransport, dataLakeEndpoint, validators) {
|
|
1232
|
-
return sdkBasicRemoteRunnerLocator(name, remoteConfig, signerTransport, dataLakeEndpoint, {
|
|
1233
|
-
validators
|
|
1234
|
-
});
|
|
1170
|
+
return sdkBasicRemoteRunnerLocator(name, remoteConfig, signerTransport, dataLakeEndpoint, { validators });
|
|
1235
1171
|
}
|
|
1236
|
-
__name(basicRemoteRunnerLocator, "basicRemoteRunnerLocator");
|
|
1237
1172
|
|
|
1238
1173
|
// src/neutral/config/locators/basicRemoteViewerLocator.ts
|
|
1239
1174
|
import { basicRemoteViewerLocator as sdkBasicRemoteViewerLocator } from "@xyo-network/xl1-sdk";
|
|
1240
1175
|
function basicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, validators) {
|
|
1241
|
-
return sdkBasicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, {
|
|
1242
|
-
validators
|
|
1243
|
-
});
|
|
1176
|
+
return sdkBasicRemoteViewerLocator(name, remoteConfig, dataLakeEndpoint, { validators });
|
|
1244
1177
|
}
|
|
1245
|
-
__name(basicRemoteViewerLocator, "basicRemoteViewerLocator");
|
|
1246
1178
|
|
|
1247
1179
|
// src/neutral/config/locators/rootLocatorFromConfig.ts
|
|
1248
1180
|
import { assertEx as assertEx5 } from "@xylabs/sdk-js";
|
|
@@ -1250,11 +1182,13 @@ import { commonLocatorFromConfig, remoteLocatorFromConfig } from "@xyo-network/x
|
|
|
1250
1182
|
async function rootLocatorFromConfig(context, validateDepsOnRegister = false) {
|
|
1251
1183
|
const { config } = context;
|
|
1252
1184
|
await commonLocatorFromConfig(context, validateDepsOnRegister);
|
|
1253
|
-
const locator = assertEx5(
|
|
1185
|
+
const locator = assertEx5(
|
|
1186
|
+
await (config.remote.rpc ? remoteLocatorFromConfig(context, validateDepsOnRegister) : void 0),
|
|
1187
|
+
() => "Root locator could not be created from config. No supported configuration found."
|
|
1188
|
+
);
|
|
1254
1189
|
locator.freeze();
|
|
1255
1190
|
return locator;
|
|
1256
1191
|
}
|
|
1257
|
-
__name(rootLocatorFromConfig, "rootLocatorFromConfig");
|
|
1258
1192
|
export {
|
|
1259
1193
|
Actor,
|
|
1260
1194
|
ActorMnemonicNotAllowedError,
|
|
@@ -1358,4 +1292,4 @@ export {
|
|
|
1358
1292
|
toRewardRedemptionConfig,
|
|
1359
1293
|
toRewardRedemptionConfigContext
|
|
1360
1294
|
};
|
|
1361
|
-
//# sourceMappingURL=index.mjs.map
|
|
1295
|
+
//# sourceMappingURL=index.mjs.map
|