@xyo-network/chain-orchestration 1.20.21 → 1.20.22
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 +176 -124
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/node/config/locators/actors/{validatorLocatorFromConfig.d.ts → finalizerLocatorFromConfig.d.ts} +2 -2
- package/dist/{neutral/node/config/locators/actors/validatorLocatorFromConfig.d.ts.map → browser/node/config/locators/actors/finalizerLocatorFromConfig.d.ts.map} +1 -1
- package/dist/browser/node/config/locators/actors/index.d.ts +1 -1
- package/dist/browser/node/config/locators/actors/index.d.ts.map +1 -1
- package/dist/browser/node/config/locators/actors/producerLocatorFromConfig.d.ts.map +1 -1
- package/dist/browser/node/config/locators/localLocatorFromConfig.d.ts +1 -1
- package/dist/browser/node/config/locators/localLocatorFromConfig.d.ts.map +1 -1
- package/dist/browser/node/config/locators/locatorsFromConfig.d.ts +1 -1
- package/dist/browser/node/config/locators/locatorsFromConfig.d.ts.map +1 -1
- package/dist/browser/node/config/locators/rootLocatorFromConfig.d.ts +1 -1
- package/dist/browser/node/config/locators/rootLocatorFromConfig.d.ts.map +1 -1
- package/dist/browser/node/config/tryParseConfig.d.ts +3 -154
- package/dist/browser/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/browser/node/init/initFinalizationArchivistIfNeeded.d.ts +6 -1
- package/dist/browser/node/init/initFinalizationArchivistIfNeeded.d.ts.map +1 -1
- package/dist/{neutral/shared/actor/ValidatorActor.d.ts → browser/shared/actor/FinalizerActor.d.ts} +6 -9
- package/dist/browser/shared/actor/FinalizerActor.d.ts.map +1 -0
- package/dist/browser/shared/actor/index.d.ts +1 -1
- package/dist/browser/shared/config/actors/{Validator.d.ts → Finalizer.d.ts} +12 -12
- package/dist/browser/shared/config/actors/{Validator.d.ts.map → Finalizer.d.ts.map} +1 -1
- package/dist/browser/shared/config/actors/index.d.ts +1 -1
- package/dist/browser/shared/config/actors/index.d.ts.map +1 -1
- package/dist/browser/shared/index.d.ts +1 -0
- package/dist/browser/shared/index.d.ts.map +1 -1
- package/dist/browser/shared/init/walletResolution.d.ts +4 -1
- package/dist/browser/shared/init/walletResolution.d.ts.map +1 -1
- package/dist/browser/shared/provider/SimpleRejectedTransactionsArchivistProvider.d.ts +31 -0
- package/dist/browser/shared/provider/SimpleRejectedTransactionsArchivistProvider.d.ts.map +1 -0
- package/dist/browser/shared/provider/index.d.ts +2 -0
- package/dist/browser/shared/provider/index.d.ts.map +1 -0
- package/dist/neutral/index.mjs +176 -124
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/node/config/locators/actors/{validatorLocatorFromConfig.d.ts → finalizerLocatorFromConfig.d.ts} +2 -2
- package/dist/{browser/node/config/locators/actors/validatorLocatorFromConfig.d.ts.map → neutral/node/config/locators/actors/finalizerLocatorFromConfig.d.ts.map} +1 -1
- package/dist/neutral/node/config/locators/actors/index.d.ts +1 -1
- package/dist/neutral/node/config/locators/actors/index.d.ts.map +1 -1
- package/dist/neutral/node/config/locators/actors/producerLocatorFromConfig.d.ts.map +1 -1
- package/dist/neutral/node/config/locators/localLocatorFromConfig.d.ts +1 -1
- package/dist/neutral/node/config/locators/localLocatorFromConfig.d.ts.map +1 -1
- package/dist/neutral/node/config/locators/locatorsFromConfig.d.ts +1 -1
- package/dist/neutral/node/config/locators/locatorsFromConfig.d.ts.map +1 -1
- package/dist/neutral/node/config/locators/rootLocatorFromConfig.d.ts +1 -1
- package/dist/neutral/node/config/locators/rootLocatorFromConfig.d.ts.map +1 -1
- package/dist/neutral/node/config/tryParseConfig.d.ts +3 -154
- package/dist/neutral/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/neutral/node/init/initFinalizationArchivistIfNeeded.d.ts +6 -1
- package/dist/neutral/node/init/initFinalizationArchivistIfNeeded.d.ts.map +1 -1
- package/dist/{node/shared/actor/ValidatorActor.d.ts → neutral/shared/actor/FinalizerActor.d.ts} +6 -9
- package/dist/neutral/shared/actor/FinalizerActor.d.ts.map +1 -0
- package/dist/neutral/shared/actor/index.d.ts +1 -1
- package/dist/neutral/shared/config/actors/{Validator.d.ts → Finalizer.d.ts} +12 -12
- package/dist/neutral/shared/config/actors/{Validator.d.ts.map → Finalizer.d.ts.map} +1 -1
- package/dist/neutral/shared/config/actors/index.d.ts +1 -1
- package/dist/neutral/shared/config/actors/index.d.ts.map +1 -1
- package/dist/neutral/shared/index.d.ts +1 -0
- package/dist/neutral/shared/index.d.ts.map +1 -1
- package/dist/neutral/shared/init/walletResolution.d.ts +4 -1
- package/dist/neutral/shared/init/walletResolution.d.ts.map +1 -1
- package/dist/neutral/shared/provider/SimpleRejectedTransactionsArchivistProvider.d.ts +31 -0
- package/dist/neutral/shared/provider/SimpleRejectedTransactionsArchivistProvider.d.ts.map +1 -0
- package/dist/neutral/shared/provider/index.d.ts +2 -0
- package/dist/neutral/shared/provider/index.d.ts.map +1 -0
- package/dist/node/index.mjs +272 -173
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node/config/locators/actors/{validatorLocatorFromConfig.d.ts → finalizerLocatorFromConfig.d.ts} +2 -2
- package/dist/node/node/config/locators/actors/{validatorLocatorFromConfig.d.ts.map → finalizerLocatorFromConfig.d.ts.map} +1 -1
- package/dist/node/node/config/locators/actors/index.d.ts +1 -1
- package/dist/node/node/config/locators/actors/index.d.ts.map +1 -1
- package/dist/node/node/config/locators/actors/producerLocatorFromConfig.d.ts.map +1 -1
- package/dist/node/node/config/locators/localLocatorFromConfig.d.ts +1 -1
- package/dist/node/node/config/locators/localLocatorFromConfig.d.ts.map +1 -1
- package/dist/node/node/config/locators/locatorsFromConfig.d.ts +1 -1
- package/dist/node/node/config/locators/locatorsFromConfig.d.ts.map +1 -1
- package/dist/node/node/config/locators/rootLocatorFromConfig.d.ts +1 -1
- package/dist/node/node/config/locators/rootLocatorFromConfig.d.ts.map +1 -1
- package/dist/node/node/config/tryParseConfig.d.ts +3 -154
- package/dist/node/node/config/tryParseConfig.d.ts.map +1 -1
- package/dist/node/node/init/initFinalizationArchivistIfNeeded.d.ts +6 -1
- package/dist/node/node/init/initFinalizationArchivistIfNeeded.d.ts.map +1 -1
- package/dist/{browser/shared/actor/ValidatorActor.d.ts → node/shared/actor/FinalizerActor.d.ts} +6 -9
- package/dist/node/shared/actor/FinalizerActor.d.ts.map +1 -0
- package/dist/node/shared/actor/index.d.ts +1 -1
- package/dist/node/shared/config/actors/{Validator.d.ts → Finalizer.d.ts} +12 -12
- package/dist/node/shared/config/actors/{Validator.d.ts.map → Finalizer.d.ts.map} +1 -1
- package/dist/node/shared/config/actors/index.d.ts +1 -1
- package/dist/node/shared/config/actors/index.d.ts.map +1 -1
- package/dist/node/shared/index.d.ts +1 -0
- package/dist/node/shared/index.d.ts.map +1 -1
- package/dist/node/shared/init/walletResolution.d.ts +4 -1
- package/dist/node/shared/init/walletResolution.d.ts.map +1 -1
- package/dist/node/shared/provider/SimpleRejectedTransactionsArchivistProvider.d.ts +31 -0
- package/dist/node/shared/provider/SimpleRejectedTransactionsArchivistProvider.d.ts.map +1 -0
- package/dist/node/shared/provider/index.d.ts +2 -0
- package/dist/node/shared/provider/index.d.ts.map +1 -0
- package/package.json +20 -20
- package/dist/browser/shared/actor/ValidatorActor.d.ts.map +0 -1
- package/dist/neutral/shared/actor/ValidatorActor.d.ts.map +0 -1
- package/dist/node/shared/actor/ValidatorActor.d.ts.map +0 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
-
// src/shared/actor/
|
|
4
|
+
// src/shared/actor/FinalizerActor.ts
|
|
5
5
|
import { creatable } from "@xylabs/sdk-js";
|
|
6
6
|
import { processPendingBlocks } from "@xyo-network/chain-sdk";
|
|
7
7
|
import { ActorV3, BlockValidationViewerMoniker, BlockViewerMoniker, DeadLetterQueueRunnerMoniker, FinalizationRunnerMoniker, MempoolViewerMoniker } from "@xyo-network/xl1-sdk";
|
|
@@ -12,16 +12,14 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
12
12
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
13
|
}
|
|
14
14
|
__name(_ts_decorate, "_ts_decorate");
|
|
15
|
-
var
|
|
15
|
+
var FinalizerActor = class extends ActorV3 {
|
|
16
16
|
static {
|
|
17
|
-
__name(this, "
|
|
17
|
+
__name(this, "FinalizerActor");
|
|
18
18
|
}
|
|
19
19
|
_blockValidationViewer;
|
|
20
20
|
_blockViewer;
|
|
21
21
|
_deadLetterQueueRunner;
|
|
22
22
|
_finalizationRunner;
|
|
23
|
-
_lastValidatedBlock;
|
|
24
|
-
_lastValidatedBlockHash;
|
|
25
23
|
_mempoolViewer;
|
|
26
24
|
get allowedProducers() {
|
|
27
25
|
return this.params.config.allowedProducers ?? [];
|
|
@@ -51,9 +49,9 @@ var ValidatorActor = class extends ActorV3 {
|
|
|
51
49
|
}
|
|
52
50
|
async startHandler() {
|
|
53
51
|
await super.startHandler();
|
|
54
|
-
this.registerTimer("
|
|
52
|
+
this.registerTimer("FinalizerActor", async () => {
|
|
55
53
|
await this.spanAsync("processPendingBlocks", async () => {
|
|
56
|
-
this.logger?.debug("
|
|
54
|
+
this.logger?.debug("FinalizerActor: Processing pending blocks...");
|
|
57
55
|
await processPendingBlocks({
|
|
58
56
|
blockValidationViewer: this.blockValidationViewer,
|
|
59
57
|
context: this.context,
|
|
@@ -72,9 +70,9 @@ var ValidatorActor = class extends ActorV3 {
|
|
|
72
70
|
}, 2e3, 500);
|
|
73
71
|
}
|
|
74
72
|
};
|
|
75
|
-
|
|
73
|
+
FinalizerActor = _ts_decorate([
|
|
76
74
|
creatable()
|
|
77
|
-
],
|
|
75
|
+
], FinalizerActor);
|
|
78
76
|
|
|
79
77
|
// src/shared/buildTelemetryConfig.ts
|
|
80
78
|
function buildTelemetryConfig(config, serviceName, serviceVersion, defaultMetricsScrapePort = 9464) {
|
|
@@ -248,17 +246,36 @@ var isBridgeConfigContext = zodIsFactory2(BridgeConfigContext);
|
|
|
248
246
|
var asBridgeConfigContext = zodAsFactory2(BridgeConfigContext, "asBridgeConfigContext");
|
|
249
247
|
var toBridgeConfigContext = zodToFactory2(BridgeConfigContext, "toBridgeConfigContext");
|
|
250
248
|
|
|
251
|
-
// src/shared/config/actors/
|
|
252
|
-
import { zodAsFactory as zodAsFactory3, zodIsFactory as zodIsFactory3, zodToFactory as zodToFactory3 } from "@xylabs/sdk-js";
|
|
249
|
+
// src/shared/config/actors/Finalizer.ts
|
|
250
|
+
import { AddressZod as AddressZod2, zodAsFactory as zodAsFactory3, zodIsFactory as zodIsFactory3, zodToFactory as zodToFactory3 } from "@xylabs/sdk-js";
|
|
253
251
|
import { BaseConfigContextZod as BaseConfigContextZod3, HostActorConfigZod as HostActorConfigZod3 } from "@xyo-network/xl1-sdk";
|
|
254
|
-
import {
|
|
252
|
+
import { z as z4 } from "zod";
|
|
253
|
+
var FinalizerConfigZod = HostActorConfigZod3.extend({
|
|
254
|
+
accountIndex: ActorAccountIndexZod("finalizer.accountIndex"),
|
|
255
|
+
allowedProducers: z4.array(AddressZod2).optional(),
|
|
256
|
+
minCandidates: z4.number().int().min(0).default(1)
|
|
257
|
+
});
|
|
258
|
+
var isFinalizerConfig = zodIsFactory3(FinalizerConfigZod);
|
|
259
|
+
var asFinalizerConfig = zodAsFactory3(FinalizerConfigZod, "asFinalizerConfig");
|
|
260
|
+
var toFinalizerConfig = zodToFactory3(FinalizerConfigZod, "toFinalizerConfig");
|
|
261
|
+
var FinalizerConfigContext = BaseConfigContextZod3.extend({
|
|
262
|
+
config: FinalizerConfigZod
|
|
263
|
+
});
|
|
264
|
+
var isFinalizerConfigContext = zodIsFactory3(FinalizerConfigContext);
|
|
265
|
+
var asFinalizerConfigContext = zodAsFactory3(FinalizerConfigContext, "asFinalizerConfigContext");
|
|
266
|
+
var toFinalizerConfigContext = zodToFactory3(FinalizerConfigContext, "toFinalizerConfigContext");
|
|
267
|
+
|
|
268
|
+
// src/shared/config/actors/Mempool.ts
|
|
269
|
+
import { zodAsFactory as zodAsFactory4, zodIsFactory as zodIsFactory4, zodToFactory as zodToFactory4 } from "@xylabs/sdk-js";
|
|
270
|
+
import { BaseConfigContextZod as BaseConfigContextZod4, HostActorConfigZod as HostActorConfigZod4 } from "@xyo-network/xl1-sdk";
|
|
271
|
+
import { globalRegistry as globalRegistry4, z as z5 } from "zod";
|
|
255
272
|
var DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL = 1e3;
|
|
256
273
|
var DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL = 1e3;
|
|
257
|
-
var MempoolConfigZod =
|
|
274
|
+
var MempoolConfigZod = HostActorConfigZod4.extend({
|
|
258
275
|
accountIndex: ActorAccountIndexZod("mempool.accountIndex"),
|
|
259
|
-
enabled:
|
|
260
|
-
|
|
261
|
-
|
|
276
|
+
enabled: z5.union([
|
|
277
|
+
z5.string(),
|
|
278
|
+
z5.boolean()
|
|
262
279
|
]).default("false").transform((val, ctx) => {
|
|
263
280
|
if (typeof val === "boolean") return val;
|
|
264
281
|
const normalized = val.toLowerCase().trim();
|
|
@@ -279,123 +296,104 @@ var MempoolConfigZod = HostActorConfigZod3.extend({
|
|
|
279
296
|
expected: "boolean",
|
|
280
297
|
message: `Invalid boolean value: "${val}". Use true/false, 1/0, yes/no.`
|
|
281
298
|
});
|
|
282
|
-
return
|
|
299
|
+
return z5.NEVER;
|
|
283
300
|
}).register(globalRegistry4, {
|
|
284
301
|
default: "false",
|
|
285
302
|
description: "Enable the Mempool",
|
|
286
303
|
title: "mempool.enabled",
|
|
287
304
|
type: "boolean"
|
|
288
305
|
}),
|
|
289
|
-
blockPruneInterval:
|
|
306
|
+
blockPruneInterval: z5.coerce.number().default(DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL).register(globalRegistry4, {
|
|
290
307
|
description: "The interval time (in milliseconds) between pending block prune attempts",
|
|
291
308
|
title: "mempool.blockPruneInterval",
|
|
292
309
|
type: "number"
|
|
293
310
|
}),
|
|
294
|
-
transactionPruneInterval:
|
|
311
|
+
transactionPruneInterval: z5.coerce.number().default(DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL).register(globalRegistry4, {
|
|
295
312
|
description: "The interval time (in milliseconds) between pending transaction prune attempts",
|
|
296
313
|
title: "mempool.transactionPruneInterval",
|
|
297
314
|
type: "number"
|
|
298
315
|
})
|
|
299
316
|
});
|
|
300
|
-
var isMempoolConfig =
|
|
301
|
-
var asMempoolConfig =
|
|
302
|
-
var toMempoolConfig =
|
|
303
|
-
var MempoolConfigContext =
|
|
317
|
+
var isMempoolConfig = zodIsFactory4(MempoolConfigZod);
|
|
318
|
+
var asMempoolConfig = zodAsFactory4(MempoolConfigZod, "asMempoolConfig");
|
|
319
|
+
var toMempoolConfig = zodToFactory4(MempoolConfigZod, "toMempoolConfig");
|
|
320
|
+
var MempoolConfigContext = BaseConfigContextZod4.extend({
|
|
304
321
|
config: MempoolConfigZod
|
|
305
322
|
});
|
|
306
|
-
var isMempoolConfigContext =
|
|
307
|
-
var asMempoolConfigContext =
|
|
308
|
-
var toMempoolConfigContext =
|
|
323
|
+
var isMempoolConfigContext = zodIsFactory4(MempoolConfigContext);
|
|
324
|
+
var asMempoolConfigContext = zodAsFactory4(MempoolConfigContext, "asMempoolConfigContext");
|
|
325
|
+
var toMempoolConfigContext = zodToFactory4(MempoolConfigContext, "toMempoolConfigContext");
|
|
309
326
|
|
|
310
327
|
// src/shared/config/actors/Producer.ts
|
|
311
|
-
import { AddressZod as
|
|
312
|
-
import { ActorConfigZod, BaseConfigContextZod as
|
|
313
|
-
import { globalRegistry as globalRegistry5, z as
|
|
328
|
+
import { AddressZod as AddressZod3, asAddress, zodAsFactory as zodAsFactory5, zodIsFactory as zodIsFactory5, zodToFactory as zodToFactory5 } from "@xylabs/sdk-js";
|
|
329
|
+
import { ActorConfigZod, BaseConfigContextZod as BaseConfigContextZod5 } from "@xyo-network/xl1-sdk";
|
|
330
|
+
import { globalRegistry as globalRegistry5, z as z6 } from "zod";
|
|
314
331
|
var DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL = 1e4;
|
|
315
|
-
var ProducerConfigZod = ActorConfigZod.extend(
|
|
332
|
+
var ProducerConfigZod = ActorConfigZod.extend(z6.object({
|
|
316
333
|
accountIndex: ActorAccountIndexZod("producer.accountIndex"),
|
|
317
|
-
allowlist:
|
|
334
|
+
allowlist: z6.preprocess((val) => {
|
|
318
335
|
if (typeof val === "string") {
|
|
319
336
|
return val.split(",").map((s) => asAddress(s.trim()));
|
|
320
337
|
}
|
|
321
338
|
return val;
|
|
322
|
-
},
|
|
339
|
+
}, z6.array(AddressZod3).optional().register(globalRegistry5, {
|
|
323
340
|
description: "List of allowed producer addresses, if undefined anyone can participate",
|
|
324
341
|
title: "allowlist",
|
|
325
342
|
type: "array"
|
|
326
343
|
})),
|
|
327
|
-
blockProductionCheckInterval:
|
|
344
|
+
blockProductionCheckInterval: z6.coerce.number().default(DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL).register(globalRegistry5, {
|
|
328
345
|
description: "The interval time (in milliseconds) between block production attempts",
|
|
329
346
|
title: "producer.blockProductionCheckInterval",
|
|
330
347
|
type: "number"
|
|
331
348
|
}),
|
|
332
|
-
disableIntentRedeclaration:
|
|
349
|
+
disableIntentRedeclaration: z6.boolean().optional().register(globalRegistry5, {
|
|
333
350
|
description: "Should the producer skip redeclaring their intent to continue producing blocks",
|
|
334
351
|
title: "producer.disableIntentRedeclaration",
|
|
335
352
|
type: "boolean"
|
|
336
353
|
}),
|
|
337
|
-
heartbeatInterval:
|
|
354
|
+
heartbeatInterval: z6.coerce.number().default(36e5).register(globalRegistry5, {
|
|
338
355
|
description: "The number of milliseconds between heartbeats if no blocks are produced",
|
|
339
356
|
title: "producer.heartbeatInterval",
|
|
340
357
|
type: "number"
|
|
341
358
|
}),
|
|
342
359
|
// TODO: BigInt schema
|
|
343
|
-
minStake:
|
|
360
|
+
minStake: z6.coerce.number().default(1).register(globalRegistry5, {
|
|
344
361
|
description: "Minimum stake required to be a Producer",
|
|
345
362
|
title: "producer.minStake",
|
|
346
363
|
type: "number"
|
|
347
364
|
}),
|
|
348
365
|
// TODO: Address schema
|
|
349
|
-
rewardAddress:
|
|
366
|
+
rewardAddress: z6.string().optional().register(globalRegistry5, {
|
|
350
367
|
description: "Address to receive block rewards",
|
|
351
368
|
title: "producer.rewardAddress",
|
|
352
369
|
type: "string"
|
|
353
370
|
})
|
|
354
371
|
}).shape);
|
|
355
|
-
var isProducerConfig =
|
|
356
|
-
var asProducerConfig =
|
|
357
|
-
var toProducerConfig =
|
|
358
|
-
var ProducerConfigContext =
|
|
372
|
+
var isProducerConfig = zodIsFactory5(ProducerConfigZod);
|
|
373
|
+
var asProducerConfig = zodAsFactory5(ProducerConfigZod, "asProducerConfig");
|
|
374
|
+
var toProducerConfig = zodToFactory5(ProducerConfigZod, "toProducerConfig");
|
|
375
|
+
var ProducerConfigContext = BaseConfigContextZod5.extend({
|
|
359
376
|
config: ProducerConfigZod
|
|
360
377
|
});
|
|
361
|
-
var isProducerConfigContext =
|
|
362
|
-
var asProducerConfigContext =
|
|
363
|
-
var toProducerConfigContext =
|
|
378
|
+
var isProducerConfigContext = zodIsFactory5(ProducerConfigContext);
|
|
379
|
+
var asProducerConfigContext = zodAsFactory5(ProducerConfigContext, "asProducerConfigContext");
|
|
380
|
+
var toProducerConfigContext = zodToFactory5(ProducerConfigContext, "toProducerConfigContext");
|
|
364
381
|
|
|
365
382
|
// src/shared/config/actors/RewardRedemption.ts
|
|
366
|
-
import { zodAsFactory as
|
|
367
|
-
import { BaseConfigContextZod as
|
|
368
|
-
var RewardRedemptionConfigZod =
|
|
383
|
+
import { zodAsFactory as zodAsFactory6, zodIsFactory as zodIsFactory6, zodToFactory as zodToFactory6 } from "@xylabs/sdk-js";
|
|
384
|
+
import { BaseConfigContextZod as BaseConfigContextZod6, HostActorConfigZod as HostActorConfigZod5 } from "@xyo-network/xl1-sdk";
|
|
385
|
+
var RewardRedemptionConfigZod = HostActorConfigZod5.extend({
|
|
369
386
|
accountIndex: ActorAccountIndexZod("rewardRedemption.accountIndex")
|
|
370
387
|
});
|
|
371
|
-
var isRewardRedemptionConfig =
|
|
372
|
-
var asRewardRedemptionConfig =
|
|
373
|
-
var toRewardRedemptionConfig =
|
|
374
|
-
var RewardRedemptionConfigContext =
|
|
388
|
+
var isRewardRedemptionConfig = zodIsFactory6(RewardRedemptionConfigZod);
|
|
389
|
+
var asRewardRedemptionConfig = zodAsFactory6(RewardRedemptionConfigZod, "asRewardRedemptionConfig");
|
|
390
|
+
var toRewardRedemptionConfig = zodToFactory6(RewardRedemptionConfigZod, "toRewardRedemptionConfig");
|
|
391
|
+
var RewardRedemptionConfigContext = BaseConfigContextZod6.extend({
|
|
375
392
|
config: RewardRedemptionConfigZod
|
|
376
393
|
});
|
|
377
|
-
var isRewardRedemptionConfigContext =
|
|
378
|
-
var asRewardRedemptionConfigContext =
|
|
379
|
-
var toRewardRedemptionConfigContext =
|
|
380
|
-
|
|
381
|
-
// src/shared/config/actors/Validator.ts
|
|
382
|
-
import { AddressZod as AddressZod3, zodAsFactory as zodAsFactory6, zodIsFactory as zodIsFactory6, zodToFactory as zodToFactory6 } from "@xylabs/sdk-js";
|
|
383
|
-
import { BaseConfigContextZod as BaseConfigContextZod6, HostActorConfigZod as HostActorConfigZod5 } from "@xyo-network/xl1-sdk";
|
|
384
|
-
import { z as z6 } from "zod";
|
|
385
|
-
var ValidatorConfigZod = HostActorConfigZod5.extend({
|
|
386
|
-
accountIndex: ActorAccountIndexZod("validator.accountIndex"),
|
|
387
|
-
allowedProducers: z6.array(AddressZod3).optional(),
|
|
388
|
-
minCandidates: z6.number().int().min(0).default(1)
|
|
389
|
-
});
|
|
390
|
-
var isValidatorConfig = zodIsFactory6(ValidatorConfigZod);
|
|
391
|
-
var asValidatorConfig = zodAsFactory6(ValidatorConfigZod, "asValidatorConfig");
|
|
392
|
-
var toValidatorConfig = zodToFactory6(ValidatorConfigZod, "toValidatorConfig");
|
|
393
|
-
var ValidatorConfigContext = BaseConfigContextZod6.extend({
|
|
394
|
-
config: ValidatorConfigZod
|
|
395
|
-
});
|
|
396
|
-
var isValidatorConfigContext = zodIsFactory6(ValidatorConfigContext);
|
|
397
|
-
var asValidatorConfigContext = zodAsFactory6(ValidatorConfigContext, "asValidatorConfigContext");
|
|
398
|
-
var toValidatorConfigContext = zodToFactory6(ValidatorConfigContext, "toValidatorConfigContext");
|
|
394
|
+
var isRewardRedemptionConfigContext = zodIsFactory6(RewardRedemptionConfigContext);
|
|
395
|
+
var asRewardRedemptionConfigContext = zodAsFactory6(RewardRedemptionConfigContext, "asRewardRedemptionConfigContext");
|
|
396
|
+
var toRewardRedemptionConfigContext = zodToFactory6(RewardRedemptionConfigContext, "toRewardRedemptionConfigContext");
|
|
399
397
|
|
|
400
398
|
// src/shared/config/mergeConfig.ts
|
|
401
399
|
import { deepMerge } from "@xylabs/sdk-js";
|
|
@@ -476,19 +474,19 @@ var RESERVED_ACTOR_INDEX = {
|
|
|
476
474
|
[ROOT_WALLET_RUNTIME_ID]: 0,
|
|
477
475
|
api: 4,
|
|
478
476
|
bridge: 2,
|
|
477
|
+
finalizer: 6,
|
|
479
478
|
mempool: 5,
|
|
480
479
|
producer: 1,
|
|
481
|
-
rewardRedemption: 3
|
|
482
|
-
validator: 6
|
|
480
|
+
rewardRedemption: 3
|
|
483
481
|
};
|
|
484
482
|
var ACTOR_LABELS = {
|
|
485
483
|
[ROOT_WALLET_RUNTIME_ID]: "root/local-node",
|
|
486
484
|
api: "api",
|
|
487
485
|
bridge: "bridge",
|
|
486
|
+
finalizer: "finalizer",
|
|
488
487
|
mempool: "mempool",
|
|
489
488
|
producer: "producer",
|
|
490
|
-
rewardRedemption: "rewardRedemption"
|
|
491
|
-
validator: "validator"
|
|
489
|
+
rewardRedemption: "rewardRedemption"
|
|
492
490
|
};
|
|
493
491
|
var activeWalletReport;
|
|
494
492
|
function getAccountLabel(actorName) {
|
|
@@ -512,11 +510,13 @@ function getInsecureGenesisRewardMnemonic() {
|
|
|
512
510
|
}
|
|
513
511
|
__name(getInsecureGenesisRewardMnemonic, "getInsecureGenesisRewardMnemonic");
|
|
514
512
|
function resolveRootWallet(configuration) {
|
|
513
|
+
const isConfigured = configuration.mnemonic !== void 0;
|
|
515
514
|
const mnemonic = configuration.mnemonic ?? BUILT_IN_DEV_MNEMONIC;
|
|
516
515
|
const isBuiltInDevMnemonic = mnemonic === BUILT_IN_DEV_MNEMONIC;
|
|
517
516
|
return {
|
|
518
517
|
basePath: DEFAULT_WALLET_PATH,
|
|
519
518
|
isBuiltInDevMnemonic,
|
|
519
|
+
isConfigured,
|
|
520
520
|
mnemonic,
|
|
521
521
|
mnemonicKind: isBuiltInDevMnemonic ? "built-in-dev" : "configured-root"
|
|
522
522
|
};
|
|
@@ -564,6 +564,7 @@ async function resolveWalletReport(requestedActors, configuration) {
|
|
|
564
564
|
actor.name,
|
|
565
565
|
actor
|
|
566
566
|
]));
|
|
567
|
+
const isRootRequired = requestedActors.some((actorName) => !actorConfigMap.get(actorName)?.mnemonic);
|
|
567
568
|
const resolvedActors = await Promise.all(requestedActors.map(async (actorName) => await resolveActorWallet(actorName, actorConfigMap.get(actorName), root)));
|
|
568
569
|
const labelMap = /* @__PURE__ */ new Map([
|
|
569
570
|
[
|
|
@@ -595,7 +596,19 @@ async function resolveWalletReport(requestedActors, configuration) {
|
|
|
595
596
|
label: labels?.join(", ") ?? `shared[${accountIndex}]`
|
|
596
597
|
};
|
|
597
598
|
}));
|
|
598
|
-
|
|
599
|
+
return {
|
|
600
|
+
actorSpecificAccounts: resolvedActors.filter((actor) => actor.source === "actor"),
|
|
601
|
+
isRootRequired,
|
|
602
|
+
requestedActors: [
|
|
603
|
+
...requestedActors
|
|
604
|
+
],
|
|
605
|
+
root,
|
|
606
|
+
sharedAccounts
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
__name(resolveWalletReport, "resolveWalletReport");
|
|
610
|
+
async function buildInsecureGenesisRewardAccounts() {
|
|
611
|
+
const accounts = await Promise.all(Array.from({
|
|
599
612
|
length: SHARED_ACCOUNT_REPORT_COUNT
|
|
600
613
|
}, (_, index) => index).map(async (accountIndex) => {
|
|
601
614
|
const account = await resolveWalletMetadata({
|
|
@@ -610,17 +623,9 @@ async function resolveWalletReport(requestedActors, configuration) {
|
|
|
610
623
|
label: accountIndex === 0 ? "genesisRewardAddress" : `genesisReward[${accountIndex}]`
|
|
611
624
|
};
|
|
612
625
|
}));
|
|
613
|
-
return
|
|
614
|
-
actorSpecificAccounts: resolvedActors.filter((actor) => actor.source === "actor"),
|
|
615
|
-
insecureGenesisRewardAccounts,
|
|
616
|
-
requestedActors: [
|
|
617
|
-
...requestedActors
|
|
618
|
-
],
|
|
619
|
-
root,
|
|
620
|
-
sharedAccounts
|
|
621
|
-
};
|
|
626
|
+
return accounts;
|
|
622
627
|
}
|
|
623
|
-
__name(
|
|
628
|
+
__name(buildInsecureGenesisRewardAccounts, "buildInsecureGenesisRewardAccounts");
|
|
624
629
|
async function initializeResolvedWalletReport(requestedActors, configuration) {
|
|
625
630
|
activeWalletReport = await resolveWalletReport(requestedActors, configuration);
|
|
626
631
|
return activeWalletReport;
|
|
@@ -663,8 +668,13 @@ function formatGenesisRewardAccount(account) {
|
|
|
663
668
|
__name(formatGenesisRewardAccount, "formatGenesisRewardAccount");
|
|
664
669
|
function formatWalletReport(report) {
|
|
665
670
|
const sections = [];
|
|
666
|
-
const
|
|
667
|
-
|
|
671
|
+
const showRootSection = report.isRootRequired || report.root.isConfigured;
|
|
672
|
+
const showSecrets = report.root.isBuiltInDevMnemonic && showRootSection;
|
|
673
|
+
if (showRootSection) {
|
|
674
|
+
sections.push(showSecrets ? "Development wallet detected." : "Wallet summary");
|
|
675
|
+
} else {
|
|
676
|
+
sections.push("Wallet summary (root wallet not required \u2014 every requested actor has its own mnemonic)");
|
|
677
|
+
}
|
|
668
678
|
if (showSecrets) {
|
|
669
679
|
sections.push([
|
|
670
680
|
"DEVELOPMENT WALLET WARNING",
|
|
@@ -678,39 +688,42 @@ function formatWalletReport(report) {
|
|
|
678
688
|
report.root.mnemonic
|
|
679
689
|
].join("\n"));
|
|
680
690
|
}
|
|
681
|
-
|
|
682
|
-
`Shared wallet accounts from ${report.root.basePath}:`,
|
|
683
|
-
"",
|
|
684
|
-
report.sharedAccounts.map((account) => formatSharedAccount(account, showSecrets)).join("\n\n")
|
|
685
|
-
].join("\n"));
|
|
686
|
-
if (report.actorSpecificAccounts.length > 0) {
|
|
691
|
+
if (showRootSection) {
|
|
687
692
|
sections.push([
|
|
688
|
-
|
|
693
|
+
`Shared wallet accounts from ${report.root.basePath}:`,
|
|
689
694
|
"",
|
|
690
|
-
report.
|
|
695
|
+
report.sharedAccounts.map((account) => formatSharedAccount(account, showSecrets)).join("\n\n")
|
|
691
696
|
].join("\n"));
|
|
692
697
|
}
|
|
693
|
-
if (report.
|
|
698
|
+
if (report.actorSpecificAccounts.length > 0) {
|
|
694
699
|
sections.push([
|
|
695
|
-
"
|
|
696
|
-
"",
|
|
697
|
-
"XL1 is using a public, insecure fallback wallet for the genesis reward address.",
|
|
698
|
-
"This phrase is intentionally unsafe and must never be used for real funds, production systems, or shared environments.",
|
|
699
|
-
"Anyone with this information can fully control the genesis reward wallet.",
|
|
700
|
-
"",
|
|
701
|
-
"Genesis reward phrase:",
|
|
702
|
-
INSECURE_GENESIS_REWARD_MNEMONIC,
|
|
703
|
-
"",
|
|
704
|
-
`The genesis reward is sent to index 0 and starts with ${(GENESIS_REWARD_AMOUNT / ATTO_XL1_PER_XL1).toString()} XL1.`,
|
|
705
|
-
"",
|
|
706
|
-
`Genesis reward wallet accounts from ${DEFAULT_WALLET_PATH}:`,
|
|
700
|
+
"Actor-specific wallet accounts:",
|
|
707
701
|
"",
|
|
708
|
-
report.
|
|
702
|
+
report.actorSpecificAccounts.map((account) => formatActorSpecificAccount(account)).join("\n\n")
|
|
709
703
|
].join("\n"));
|
|
710
704
|
}
|
|
711
705
|
return sections.join("\n\n");
|
|
712
706
|
}
|
|
713
707
|
__name(formatWalletReport, "formatWalletReport");
|
|
708
|
+
function formatInsecureGenesisRewardWarning(accounts) {
|
|
709
|
+
return [
|
|
710
|
+
"INSECURE GENESIS REWARD WALLET WARNING",
|
|
711
|
+
"",
|
|
712
|
+
"XL1 is using a public, insecure fallback wallet for the genesis reward address.",
|
|
713
|
+
"This phrase is intentionally unsafe and must never be used for real funds, production systems, or shared environments.",
|
|
714
|
+
"Anyone with this information can fully control the genesis reward wallet.",
|
|
715
|
+
"",
|
|
716
|
+
"Genesis reward phrase:",
|
|
717
|
+
INSECURE_GENESIS_REWARD_MNEMONIC,
|
|
718
|
+
"",
|
|
719
|
+
`The genesis reward is sent to index 0 and starts with ${(GENESIS_REWARD_AMOUNT / ATTO_XL1_PER_XL1).toString()} XL1.`,
|
|
720
|
+
"",
|
|
721
|
+
`Genesis reward wallet accounts from ${DEFAULT_WALLET_PATH}:`,
|
|
722
|
+
"",
|
|
723
|
+
accounts.map((account) => formatGenesisRewardAccount(account)).join("\n\n")
|
|
724
|
+
].join("\n");
|
|
725
|
+
}
|
|
726
|
+
__name(formatInsecureGenesisRewardWarning, "formatInsecureGenesisRewardWarning");
|
|
714
727
|
async function resolveGenesisRewardAddress(config) {
|
|
715
728
|
if (config.chain.genesisRewardAddress) return config.chain.genesisRewardAddress;
|
|
716
729
|
const wallet = await generateXyoBaseWalletFromPhrase(INSECURE_GENESIS_REWARD_MNEMONIC);
|
|
@@ -879,6 +892,41 @@ Orchestrator = _ts_decorate2([
|
|
|
879
892
|
creatable2()
|
|
880
893
|
], Orchestrator);
|
|
881
894
|
|
|
895
|
+
// src/shared/provider/SimpleRejectedTransactionsArchivistProvider.ts
|
|
896
|
+
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
897
|
+
import { AbstractCreatableProvider, creatableProvider } from "@xyo-network/xl1-sdk";
|
|
898
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
899
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
900
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
901
|
+
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;
|
|
902
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
903
|
+
}
|
|
904
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
905
|
+
var RejectedTransactionsArchivistProviderMoniker = "RejectedTransactionsArchivistProvider";
|
|
906
|
+
var SimpleRejectedTransactionsArchivistProvider = class _SimpleRejectedTransactionsArchivistProvider extends AbstractCreatableProvider {
|
|
907
|
+
static {
|
|
908
|
+
__name(this, "SimpleRejectedTransactionsArchivistProvider");
|
|
909
|
+
}
|
|
910
|
+
static defaultMoniker = RejectedTransactionsArchivistProviderMoniker;
|
|
911
|
+
static dependencies = [];
|
|
912
|
+
static monikers = [
|
|
913
|
+
RejectedTransactionsArchivistProviderMoniker
|
|
914
|
+
];
|
|
915
|
+
moniker = _SimpleRejectedTransactionsArchivistProvider.defaultMoniker;
|
|
916
|
+
get archivist() {
|
|
917
|
+
return this.params.archivist;
|
|
918
|
+
}
|
|
919
|
+
static async paramsHandler(params) {
|
|
920
|
+
return {
|
|
921
|
+
...await super.paramsHandler(params),
|
|
922
|
+
archivist: assertEx3(params?.archivist, () => "archivist is required")
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
SimpleRejectedTransactionsArchivistProvider = _ts_decorate3([
|
|
927
|
+
creatableProvider()
|
|
928
|
+
], SimpleRejectedTransactionsArchivistProvider);
|
|
929
|
+
|
|
882
930
|
// src/node/config/locators/basicRemoteRunnerLocator.ts
|
|
883
931
|
import { isAccountInstance } from "@xyo-network/sdk-js";
|
|
884
932
|
import { basicRemoteRunnerLocator as sdkBasicRemoteRunnerLocator, JsonRpcAccountBalanceViewer, JsonRpcXyoSigner, SimpleXyoSigner } from "@xyo-network/xl1-sdk";
|
|
@@ -957,13 +1005,13 @@ async function contextFromConfigWithoutLocator(config, logger, serviceName, serv
|
|
|
957
1005
|
__name(contextFromConfigWithoutLocator, "contextFromConfigWithoutLocator");
|
|
958
1006
|
|
|
959
1007
|
// src/node/config/locators/localLocatorFromConfig.ts
|
|
960
|
-
import { assertEx as
|
|
1008
|
+
import { assertEx as assertEx8 } from "@xylabs/sdk-js";
|
|
961
1009
|
import { validateHydratedBlock, validateHydratedBlockState } from "@xyo-network/chain-validation";
|
|
962
1010
|
import { BlockCumulativeBalanceValidatorFactory, ProviderFactoryLocator, SimpleAccountBalanceViewer, SimpleBlockValidationViewer, SimpleBlockViewer, SimpleDeadLetterQueueRunner, SimpleDeadLetterQueueViewer, SimpleFinalizationRunner, SimpleFinalizationViewer, SimpleMempoolRunner, SimpleMempoolViewer, SimpleTransactionValidationViewer, SimpleTransactionViewer, SimpleWindowedBlockViewer, SimpleXyoConnectionViewer, SimpleXyoViewer, validateTransaction } from "@xyo-network/xl1-sdk";
|
|
963
1011
|
|
|
964
1012
|
// src/node/init/initBalanceSummaryMap.ts
|
|
965
1013
|
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
966
|
-
import { assertEx as
|
|
1014
|
+
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
967
1015
|
import { MongoMap } from "@xyo-network/chain-protocol-driver-mongodb";
|
|
968
1016
|
import { hasMongoConfig, MemoryMap } from "@xyo-network/xl1-sdk";
|
|
969
1017
|
async function initBalanceSummaryMap({ logger, config }) {
|
|
@@ -988,7 +1036,7 @@ async function initBalanceSummaryMap({ logger, config }) {
|
|
|
988
1036
|
maxEntries: 5e3
|
|
989
1037
|
}
|
|
990
1038
|
});
|
|
991
|
-
|
|
1039
|
+
assertEx4(await result.start(), () => "Failed to start transfer summary map");
|
|
992
1040
|
return result;
|
|
993
1041
|
} else {
|
|
994
1042
|
logger?.warn("[API] Mongo configuration not found. Using MemoryMap for BalanceSummaryMap.");
|
|
@@ -1050,11 +1098,11 @@ async function initEvmProvidersIfAvailable(locator) {
|
|
|
1050
1098
|
__name(initEvmProvidersIfAvailable, "initEvmProvidersIfAvailable");
|
|
1051
1099
|
|
|
1052
1100
|
// src/node/init/initFinalizationArchivistIfNeeded.ts
|
|
1053
|
-
import { assertEx as
|
|
1101
|
+
import { assertEx as assertEx5 } from "@xylabs/sdk-js";
|
|
1054
1102
|
import { createBootstrapHead } from "@xyo-network/chain-sdk";
|
|
1055
1103
|
import { Account } from "@xyo-network/sdk-js";
|
|
1056
1104
|
import { asAttoXL1, findMostRecentBlock, flattenHydratedBlock } from "@xyo-network/xl1-sdk";
|
|
1057
|
-
async function initFinalizationArchivistIfNeeded(archivist, config, account) {
|
|
1105
|
+
async function initFinalizationArchivistIfNeeded(archivist, config, account, options = {}) {
|
|
1058
1106
|
const configuredChainId = config.chain.id;
|
|
1059
1107
|
const possibleHead = await findMostRecentBlock(archivist);
|
|
1060
1108
|
if (configuredChainId && possibleHead && possibleHead.chain !== configuredChainId) {
|
|
@@ -1063,13 +1111,18 @@ async function initFinalizationArchivistIfNeeded(archivist, config, account) {
|
|
|
1063
1111
|
let possibleChainId = configuredChainId;
|
|
1064
1112
|
if (!possibleHead) {
|
|
1065
1113
|
possibleChainId = possibleChainId ?? (await Account.random()).address;
|
|
1114
|
+
if (!config.chain.genesisRewardAddress) {
|
|
1115
|
+
const accounts = await buildInsecureGenesisRewardAccounts();
|
|
1116
|
+
options.logger?.warn(formatInsecureGenesisRewardWarning(accounts));
|
|
1117
|
+
if (options.onInsecureGenesisConfirm) await options.onInsecureGenesisConfirm();
|
|
1118
|
+
}
|
|
1066
1119
|
const genesisRewardAddress = await resolveGenesisRewardAddress(config);
|
|
1067
1120
|
const chain = await createBootstrapHead(account, possibleChainId, asAttoXL1(GENESIS_REWARD_AMOUNT), genesisRewardAddress);
|
|
1068
1121
|
const payloads = chain.flatMap((block) => flattenHydratedBlock(block));
|
|
1069
1122
|
await archivist.insert(payloads);
|
|
1070
1123
|
}
|
|
1071
|
-
const head = possibleHead ??
|
|
1072
|
-
const chainId =
|
|
1124
|
+
const head = possibleHead ?? assertEx5(await findMostRecentBlock(archivist), () => "No blocks found in chain archivist");
|
|
1125
|
+
const chainId = assertEx5(possibleChainId, () => "Chain ID could not be determined");
|
|
1073
1126
|
return [
|
|
1074
1127
|
head,
|
|
1075
1128
|
chainId
|
|
@@ -1096,7 +1149,7 @@ async function initFinalizedArchivist(config) {
|
|
|
1096
1149
|
__name(initFinalizedArchivist, "initFinalizedArchivist");
|
|
1097
1150
|
|
|
1098
1151
|
// src/node/init/initServerNode.ts
|
|
1099
|
-
import { assertEx as
|
|
1152
|
+
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
1100
1153
|
import { asArchivistInstance } from "@xyo-network/sdk-js";
|
|
1101
1154
|
|
|
1102
1155
|
// src/node/manifest/getLocator.ts
|
|
@@ -1423,7 +1476,7 @@ async function writableChainArchivistFromNode(node) {
|
|
|
1423
1476
|
}
|
|
1424
1477
|
__name(writableChainArchivistFromNode, "writableChainArchivistFromNode");
|
|
1425
1478
|
async function readonlyChainArchivistFromNode(node) {
|
|
1426
|
-
return
|
|
1479
|
+
return assertEx6(asArchivistInstance(await node.resolve("Chain:Validated"), {
|
|
1427
1480
|
required: true
|
|
1428
1481
|
}));
|
|
1429
1482
|
}
|
|
@@ -1454,7 +1507,7 @@ async function rejectedTransactionsArchivistFromNode(node) {
|
|
|
1454
1507
|
__name(rejectedTransactionsArchivistFromNode, "rejectedTransactionsArchivistFromNode");
|
|
1455
1508
|
async function initServerNode(context, wallet, providedNode) {
|
|
1456
1509
|
const node = providedNode ?? await loadNode(context, wallet);
|
|
1457
|
-
|
|
1510
|
+
assertEx6(await node.start(), () => "Failed to start node");
|
|
1458
1511
|
const writableChainArchivist = await writableChainArchivistFromNode(node);
|
|
1459
1512
|
const readonlyChainArchivist = await readonlyChainArchivistFromNode(node);
|
|
1460
1513
|
const pendingTransactionsArchivist = await pendingTransactionsArchivistFromNode(node);
|
|
@@ -1475,7 +1528,7 @@ __name(initServerNode, "initServerNode");
|
|
|
1475
1528
|
|
|
1476
1529
|
// src/node/init/initTransferSummaryMap.ts
|
|
1477
1530
|
import { BaseMongoSdk as BaseMongoSdk2 } from "@xylabs/mongo";
|
|
1478
|
-
import { assertEx as
|
|
1531
|
+
import { assertEx as assertEx7 } from "@xylabs/sdk-js";
|
|
1479
1532
|
import { MongoMap as MongoMap2 } from "@xyo-network/chain-protocol-driver-mongodb";
|
|
1480
1533
|
import { hasMongoConfig as hasMongoConfig3, MemoryMap as MemoryMap2 } from "@xyo-network/xl1-sdk";
|
|
1481
1534
|
async function initTransferSummaryMap({ logger, config }) {
|
|
@@ -1500,7 +1553,7 @@ async function initTransferSummaryMap({ logger, config }) {
|
|
|
1500
1553
|
maxEntries: 5e3
|
|
1501
1554
|
}
|
|
1502
1555
|
});
|
|
1503
|
-
|
|
1556
|
+
assertEx7(await result.start(), () => "Failed to start transfer summary map");
|
|
1504
1557
|
return result;
|
|
1505
1558
|
} else {
|
|
1506
1559
|
logger?.warn("[API] Mongo configuration not found. Using MemoryMap for TransferSummaryMap.");
|
|
@@ -1521,12 +1574,15 @@ var validateHydratedBlockStateWithCumulativeBalance = /* @__PURE__ */ __name(asy
|
|
|
1521
1574
|
...cumulativeErrors
|
|
1522
1575
|
];
|
|
1523
1576
|
}, "validateHydratedBlockStateWithCumulativeBalance");
|
|
1524
|
-
async function localLocatorFromConfig(context, validateDepsOnRegister = false) {
|
|
1525
|
-
const balancesSummaryMap =
|
|
1526
|
-
const transfersSummaryMap =
|
|
1577
|
+
async function localLocatorFromConfig(context, validateDepsOnRegister = false, onInsecureGenesisConfirm) {
|
|
1578
|
+
const balancesSummaryMap = assertEx8(await initBalanceSummaryMap(context), () => "Balance Summary Map not initialized");
|
|
1579
|
+
const transfersSummaryMap = assertEx8(await initTransferSummaryMap(context), () => "Transfer Summary Map not initialized");
|
|
1527
1580
|
const wallet = await initActorWallet(context);
|
|
1528
1581
|
const { writableChainArchivist, readonlyChainArchivist, pendingTransactionsArchivist, pendingBlocksArchivist, rejectedBlocksArchivist, rejectedTransactionsArchivist } = await initServerNode(context, wallet);
|
|
1529
|
-
await initFinalizationArchivistIfNeeded(writableChainArchivist, context.config, wallet
|
|
1582
|
+
await initFinalizationArchivistIfNeeded(writableChainArchivist, context.config, wallet, {
|
|
1583
|
+
logger: context.logger,
|
|
1584
|
+
onInsecureGenesisConfirm
|
|
1585
|
+
});
|
|
1530
1586
|
const locator = new ProviderFactoryLocator(context, {}, validateDepsOnRegister);
|
|
1531
1587
|
locator.registerMany([
|
|
1532
1588
|
SimpleMempoolViewer.factory(SimpleMempoolViewer.dependencies, {
|
|
@@ -1574,6 +1630,9 @@ async function localLocatorFromConfig(context, validateDepsOnRegister = false) {
|
|
|
1574
1630
|
SimpleDeadLetterQueueViewer.factory(SimpleDeadLetterQueueViewer.dependencies, {
|
|
1575
1631
|
rejectedBlocksArchivist,
|
|
1576
1632
|
rejectedTransactionsArchivist
|
|
1633
|
+
}),
|
|
1634
|
+
SimpleRejectedTransactionsArchivistProvider.factory(SimpleRejectedTransactionsArchivistProvider.dependencies, {
|
|
1635
|
+
archivist: rejectedTransactionsArchivist
|
|
1577
1636
|
})
|
|
1578
1637
|
]);
|
|
1579
1638
|
return locator;
|
|
@@ -1658,9 +1717,9 @@ async function bridgeLocatorFromConfig(context, parent) {
|
|
|
1658
1717
|
}
|
|
1659
1718
|
__name(bridgeLocatorFromConfig, "bridgeLocatorFromConfig");
|
|
1660
1719
|
|
|
1661
|
-
// src/node/config/locators/actors/
|
|
1720
|
+
// src/node/config/locators/actors/finalizerLocatorFromConfig.ts
|
|
1662
1721
|
import { ProviderFactoryLocator as ProviderFactoryLocator4 } from "@xyo-network/xl1-sdk";
|
|
1663
|
-
function
|
|
1722
|
+
function finalizerLocatorFromConfig(context, parent) {
|
|
1664
1723
|
const locator = new ProviderFactoryLocator4({
|
|
1665
1724
|
...context,
|
|
1666
1725
|
locator: parent
|
|
@@ -1669,16 +1728,29 @@ function mempoolLocatorFromConfig(context, parent) {
|
|
|
1669
1728
|
locator.freeze();
|
|
1670
1729
|
return locator;
|
|
1671
1730
|
}
|
|
1731
|
+
__name(finalizerLocatorFromConfig, "finalizerLocatorFromConfig");
|
|
1732
|
+
|
|
1733
|
+
// src/node/config/locators/actors/mempoolLocatorFromConfig.ts
|
|
1734
|
+
import { ProviderFactoryLocator as ProviderFactoryLocator5 } from "@xyo-network/xl1-sdk";
|
|
1735
|
+
function mempoolLocatorFromConfig(context, parent) {
|
|
1736
|
+
const locator = new ProviderFactoryLocator5({
|
|
1737
|
+
...context,
|
|
1738
|
+
locator: parent
|
|
1739
|
+
});
|
|
1740
|
+
locator.registerMany([]);
|
|
1741
|
+
locator.freeze();
|
|
1742
|
+
return locator;
|
|
1743
|
+
}
|
|
1672
1744
|
__name(mempoolLocatorFromConfig, "mempoolLocatorFromConfig");
|
|
1673
1745
|
|
|
1674
1746
|
// src/node/config/locators/actors/producerLocatorFromConfig.ts
|
|
1675
1747
|
import { asAddress as asAddress2 } from "@xylabs/sdk-js";
|
|
1676
1748
|
import { SimpleBlockRunner } from "@xyo-network/chain-services";
|
|
1677
|
-
import { ProviderFactoryLocator as
|
|
1749
|
+
import { ProviderFactoryLocator as ProviderFactoryLocator6 } from "@xyo-network/xl1-sdk";
|
|
1678
1750
|
async function producerLocatorFromConfig(context, parent) {
|
|
1679
1751
|
const { logger, config } = context;
|
|
1680
1752
|
const account = await initActorAccount(context);
|
|
1681
|
-
const locator = new
|
|
1753
|
+
const locator = new ProviderFactoryLocator6({
|
|
1682
1754
|
...context,
|
|
1683
1755
|
locator: parent
|
|
1684
1756
|
});
|
|
@@ -1687,10 +1759,13 @@ async function producerLocatorFromConfig(context, parent) {
|
|
|
1687
1759
|
if (rewardAddress === account.address) {
|
|
1688
1760
|
logger?.warn(`Using producer account address as reward address: ${account.address}`);
|
|
1689
1761
|
}
|
|
1762
|
+
const rejectedTransactionsProvider = await parent?.tryGetInstance(RejectedTransactionsArchivistProviderMoniker);
|
|
1763
|
+
const rejectedTransactionsArchivist = rejectedTransactionsProvider?.archivist;
|
|
1690
1764
|
locator.registerMany([
|
|
1691
1765
|
SimpleBlockRunner.factory(SimpleBlockRunner.dependencies, {
|
|
1692
1766
|
account,
|
|
1693
|
-
rewardAddress
|
|
1767
|
+
rewardAddress,
|
|
1768
|
+
rejectedTransactionsArchivist
|
|
1694
1769
|
})
|
|
1695
1770
|
]);
|
|
1696
1771
|
locator.freeze();
|
|
@@ -1699,9 +1774,9 @@ async function producerLocatorFromConfig(context, parent) {
|
|
|
1699
1774
|
__name(producerLocatorFromConfig, "producerLocatorFromConfig");
|
|
1700
1775
|
|
|
1701
1776
|
// src/node/config/locators/actors/rewardRedemptionLocatorFromConfig.ts
|
|
1702
|
-
import { JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer4, JsonRpcBlockViewer as JsonRpcBlockViewer2, JsonRpcFinalizationViewer as JsonRpcFinalizationViewer2, JsonRpcMempoolRunner as JsonRpcMempoolRunner2, JsonRpcMempoolViewer as JsonRpcMempoolViewer2, JsonRpcXyoRunner as JsonRpcXyoRunner2, JsonRpcXyoViewer as JsonRpcXyoViewer2, ProviderFactoryLocator as
|
|
1777
|
+
import { JsonRpcAccountBalanceViewer as JsonRpcAccountBalanceViewer4, JsonRpcBlockViewer as JsonRpcBlockViewer2, JsonRpcFinalizationViewer as JsonRpcFinalizationViewer2, JsonRpcMempoolRunner as JsonRpcMempoolRunner2, JsonRpcMempoolViewer as JsonRpcMempoolViewer2, JsonRpcXyoRunner as JsonRpcXyoRunner2, JsonRpcXyoViewer as JsonRpcXyoViewer2, ProviderFactoryLocator as ProviderFactoryLocator7, SimpleXyoConnectionRunner as SimpleXyoConnectionRunner3, SimpleXyoGatewayRunner as SimpleXyoGatewayRunner2, SimpleXyoRunner as SimpleXyoRunner3, SimpleXyoSigner as SimpleXyoSigner3 } from "@xyo-network/xl1-sdk";
|
|
1703
1778
|
async function rewardRedemptionLocatorFromConfig(context, parent) {
|
|
1704
|
-
const locator = new
|
|
1779
|
+
const locator = new ProviderFactoryLocator7({
|
|
1705
1780
|
...context,
|
|
1706
1781
|
locator: parent
|
|
1707
1782
|
});
|
|
@@ -1731,22 +1806,9 @@ async function rewardRedemptionLocatorFromConfig(context, parent) {
|
|
|
1731
1806
|
}
|
|
1732
1807
|
__name(rewardRedemptionLocatorFromConfig, "rewardRedemptionLocatorFromConfig");
|
|
1733
1808
|
|
|
1734
|
-
// src/node/config/locators/actors/validatorLocatorFromConfig.ts
|
|
1735
|
-
import { ProviderFactoryLocator as ProviderFactoryLocator7 } from "@xyo-network/xl1-sdk";
|
|
1736
|
-
function validatorLocatorFromConfig(context, parent) {
|
|
1737
|
-
const locator = new ProviderFactoryLocator7({
|
|
1738
|
-
...context,
|
|
1739
|
-
locator: parent
|
|
1740
|
-
});
|
|
1741
|
-
locator.registerMany([]);
|
|
1742
|
-
locator.freeze();
|
|
1743
|
-
return locator;
|
|
1744
|
-
}
|
|
1745
|
-
__name(validatorLocatorFromConfig, "validatorLocatorFromConfig");
|
|
1746
|
-
|
|
1747
1809
|
// src/node/config/locators/rootLocatorFromConfig.ts
|
|
1748
1810
|
import { commonLocatorFromConfig, remoteLocatorFromConfig } from "@xyo-network/xl1-sdk";
|
|
1749
|
-
async function rootLocatorFromConfig(context, validateDepsOnRegister = false) {
|
|
1811
|
+
async function rootLocatorFromConfig(context, validateDepsOnRegister = false, onInsecureGenesisConfirm) {
|
|
1750
1812
|
const { config } = context;
|
|
1751
1813
|
let locator = await commonLocatorFromConfig(context, validateDepsOnRegister);
|
|
1752
1814
|
const newLocator = await (config.remote.rpc ? remoteLocatorFromConfig(locator.context, validateDepsOnRegister) : localLocatorFromConfig({
|
|
@@ -1755,7 +1817,7 @@ async function rootLocatorFromConfig(context, validateDepsOnRegister = false) {
|
|
|
1755
1817
|
...locator.context.config,
|
|
1756
1818
|
...context.config
|
|
1757
1819
|
}
|
|
1758
|
-
}, validateDepsOnRegister));
|
|
1820
|
+
}, validateDepsOnRegister, onInsecureGenesisConfirm));
|
|
1759
1821
|
locator = newLocator;
|
|
1760
1822
|
locator = await initEvmProvidersIfAvailable(locator);
|
|
1761
1823
|
locator.freeze();
|
|
@@ -1764,15 +1826,17 @@ async function rootLocatorFromConfig(context, validateDepsOnRegister = false) {
|
|
|
1764
1826
|
__name(rootLocatorFromConfig, "rootLocatorFromConfig");
|
|
1765
1827
|
|
|
1766
1828
|
// src/node/config/locators/locatorsFromConfig.ts
|
|
1767
|
-
async function locatorsFromConfig(context, { actors, ...config }) {
|
|
1829
|
+
async function locatorsFromConfig(context, { actors, ...config }, onInsecureGenesisConfirm) {
|
|
1830
|
+
const rootContext = {
|
|
1831
|
+
...context,
|
|
1832
|
+
config: {
|
|
1833
|
+
...config,
|
|
1834
|
+
name: "_root"
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
const rootLocator = await rootLocatorFromConfig(rootContext, false, onInsecureGenesisConfirm);
|
|
1768
1838
|
const result = {
|
|
1769
|
-
_root:
|
|
1770
|
-
...context,
|
|
1771
|
-
config: {
|
|
1772
|
-
...config,
|
|
1773
|
-
name: "_root"
|
|
1774
|
-
}
|
|
1775
|
-
})
|
|
1839
|
+
_root: rootLocator
|
|
1776
1840
|
};
|
|
1777
1841
|
for (const actorConfig of actors) {
|
|
1778
1842
|
switch (actorConfig.name) {
|
|
@@ -1797,10 +1861,10 @@ async function locatorsFromConfig(context, { actors, ...config }) {
|
|
|
1797
1861
|
}, result._root);
|
|
1798
1862
|
break;
|
|
1799
1863
|
}
|
|
1800
|
-
case "
|
|
1801
|
-
result[actorConfig.name] = await
|
|
1864
|
+
case "finalizer": {
|
|
1865
|
+
result[actorConfig.name] = await finalizerLocatorFromConfig({
|
|
1802
1866
|
...context,
|
|
1803
|
-
config:
|
|
1867
|
+
config: FinalizerConfigZod.parse(deepMerge2(config, actorConfig))
|
|
1804
1868
|
}, result._root);
|
|
1805
1869
|
break;
|
|
1806
1870
|
}
|
|
@@ -1830,6 +1894,21 @@ import { ConfigZod } from "@xyo-network/xl1-sdk";
|
|
|
1830
1894
|
import { cosmiconfig } from "cosmiconfig";
|
|
1831
1895
|
var configName = "xyo";
|
|
1832
1896
|
var configSection = "xl1";
|
|
1897
|
+
var ConfigFileNotFoundError = class extends Error {
|
|
1898
|
+
static {
|
|
1899
|
+
__name(this, "ConfigFileNotFoundError");
|
|
1900
|
+
}
|
|
1901
|
+
constructor(configPath) {
|
|
1902
|
+
super(`Config file not found: ${configPath}`);
|
|
1903
|
+
this.name = "ConfigFileNotFoundError";
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
var isMissingFileError = /* @__PURE__ */ __name((error) => {
|
|
1907
|
+
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
1908
|
+
}, "isMissingFileError");
|
|
1909
|
+
var isRecord = /* @__PURE__ */ __name((value) => {
|
|
1910
|
+
return typeof value === "object" && value !== null;
|
|
1911
|
+
}, "isRecord");
|
|
1833
1912
|
async function tryParseConfig(options) {
|
|
1834
1913
|
const { configPath, searchPlaces } = options ?? {};
|
|
1835
1914
|
const explorer = cosmiconfig(configName, {
|
|
@@ -1837,10 +1916,25 @@ async function tryParseConfig(options) {
|
|
|
1837
1916
|
// loaders: { '.ts': TypeScriptLoader() },
|
|
1838
1917
|
searchPlaces
|
|
1839
1918
|
});
|
|
1840
|
-
|
|
1841
|
-
if (isDefined4(
|
|
1919
|
+
let result;
|
|
1920
|
+
if (isDefined4(configPath)) {
|
|
1921
|
+
try {
|
|
1922
|
+
result = (await explorer.load(configPath))?.config;
|
|
1923
|
+
} catch (error) {
|
|
1924
|
+
if (isMissingFileError(error)) {
|
|
1925
|
+
throw new ConfigFileNotFoundError(configPath);
|
|
1926
|
+
}
|
|
1927
|
+
throw error;
|
|
1928
|
+
}
|
|
1929
|
+
if (!isDefined4(result) || isNull(result)) {
|
|
1930
|
+
throw new ConfigFileNotFoundError(configPath);
|
|
1931
|
+
}
|
|
1932
|
+
} else {
|
|
1933
|
+
result = (await explorer.search())?.config;
|
|
1934
|
+
}
|
|
1935
|
+
if (isRecord(result)) {
|
|
1842
1936
|
const section = result[configSection];
|
|
1843
|
-
if (
|
|
1937
|
+
if (isRecord(section)) {
|
|
1844
1938
|
const parsed = ConfigZod.loose().parse(section);
|
|
1845
1939
|
return typeof section.mnemonic === "string" ? {
|
|
1846
1940
|
...parsed,
|
|
@@ -1864,10 +1958,14 @@ export {
|
|
|
1864
1958
|
BridgeConfigContext,
|
|
1865
1959
|
BridgeConfigZod,
|
|
1866
1960
|
BridgeSettingsZod,
|
|
1961
|
+
ConfigFileNotFoundError,
|
|
1867
1962
|
DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL,
|
|
1868
1963
|
DEFAULT_MEMPOOL_BLOCK_PRUNE_INTERVAL,
|
|
1869
1964
|
DEFAULT_MEMPOOL_TRANSACTION_PRUNE_INTERVAL,
|
|
1870
1965
|
DefaultServiceProvider,
|
|
1966
|
+
FinalizerActor,
|
|
1967
|
+
FinalizerConfigContext,
|
|
1968
|
+
FinalizerConfigZod,
|
|
1871
1969
|
GENESIS_REWARD_AMOUNT,
|
|
1872
1970
|
GenericHost,
|
|
1873
1971
|
INSECURE_GENESIS_REWARD_MNEMONIC,
|
|
@@ -1880,31 +1978,32 @@ export {
|
|
|
1880
1978
|
ProducerConfigZod,
|
|
1881
1979
|
PublicChildManifests,
|
|
1882
1980
|
ROOT_WALLET_RUNTIME_ID,
|
|
1981
|
+
RejectedTransactionsArchivistProviderMoniker,
|
|
1883
1982
|
RewardRedemptionConfigContext,
|
|
1884
1983
|
RewardRedemptionConfigZod,
|
|
1885
1984
|
SHARED_ACCOUNT_REPORT_COUNT,
|
|
1886
1985
|
ServiceLifetime,
|
|
1887
|
-
|
|
1888
|
-
ValidatorConfigContext,
|
|
1889
|
-
ValidatorConfigZod,
|
|
1986
|
+
SimpleRejectedTransactionsArchivistProvider,
|
|
1890
1987
|
asApiConfig,
|
|
1891
1988
|
asApiConfigContext,
|
|
1892
1989
|
asBridgeConfig,
|
|
1893
1990
|
asBridgeConfigContext,
|
|
1991
|
+
asFinalizerConfig,
|
|
1992
|
+
asFinalizerConfigContext,
|
|
1894
1993
|
asMempoolConfig,
|
|
1895
1994
|
asMempoolConfigContext,
|
|
1896
1995
|
asProducerConfig,
|
|
1897
1996
|
asProducerConfigContext,
|
|
1898
1997
|
asRewardRedemptionConfig,
|
|
1899
1998
|
asRewardRedemptionConfigContext,
|
|
1900
|
-
asValidatorConfig,
|
|
1901
|
-
asValidatorConfigContext,
|
|
1902
1999
|
basicRemoteRunnerLocator,
|
|
1903
2000
|
basicRemoteViewerLocator,
|
|
2001
|
+
buildInsecureGenesisRewardAccounts,
|
|
1904
2002
|
buildTelemetryConfig,
|
|
1905
2003
|
clearResolvedWalletReport,
|
|
1906
2004
|
contextFromConfigWithoutLocator,
|
|
1907
2005
|
createProducerChainStakeIntentBlock,
|
|
2006
|
+
formatInsecureGenesisRewardWarning,
|
|
1908
2007
|
formatWalletReport,
|
|
1909
2008
|
getBuiltInDevMnemonic,
|
|
1910
2009
|
getInsecureGenesisRewardMnemonic,
|
|
@@ -1928,14 +2027,14 @@ export {
|
|
|
1928
2027
|
isApiConfigContext,
|
|
1929
2028
|
isBridgeConfig,
|
|
1930
2029
|
isBridgeConfigContext,
|
|
2030
|
+
isFinalizerConfig,
|
|
2031
|
+
isFinalizerConfigContext,
|
|
1931
2032
|
isMempoolConfig,
|
|
1932
2033
|
isMempoolConfigContext,
|
|
1933
2034
|
isProducerConfig,
|
|
1934
2035
|
isProducerConfigContext,
|
|
1935
2036
|
isRewardRedemptionConfig,
|
|
1936
2037
|
isRewardRedemptionConfigContext,
|
|
1937
|
-
isValidatorConfig,
|
|
1938
|
-
isValidatorConfigContext,
|
|
1939
2038
|
loadNode,
|
|
1940
2039
|
localLocatorFromConfig,
|
|
1941
2040
|
locatorsFromConfig,
|
|
@@ -1951,14 +2050,14 @@ export {
|
|
|
1951
2050
|
toApiConfigContext,
|
|
1952
2051
|
toBridgeConfig,
|
|
1953
2052
|
toBridgeConfigContext,
|
|
2053
|
+
toFinalizerConfig,
|
|
2054
|
+
toFinalizerConfigContext,
|
|
1954
2055
|
toMempoolConfig,
|
|
1955
2056
|
toMempoolConfigContext,
|
|
1956
2057
|
toProducerConfig,
|
|
1957
2058
|
toProducerConfigContext,
|
|
1958
2059
|
toRewardRedemptionConfig,
|
|
1959
2060
|
toRewardRedemptionConfigContext,
|
|
1960
|
-
toValidatorConfig,
|
|
1961
|
-
toValidatorConfigContext,
|
|
1962
2061
|
tryParseConfig
|
|
1963
2062
|
};
|
|
1964
2063
|
//# sourceMappingURL=index.mjs.map
|