@xyo-network/xl1-cli-lib 1.17.2 → 1.17.3
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/node/commands/mempool/runMempool.d.ts +1 -1
- package/dist/node/commands/mempool/runMempool.d.ts.map +1 -1
- package/dist/node/commands/validator/runValidator.d.ts +1 -1
- package/dist/node/commands/validator/runValidator.d.ts.map +1 -1
- package/dist/node/index.mjs +78 -460
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/orchestration/index.d.ts +0 -3
- package/dist/node/orchestration/index.d.ts.map +1 -1
- package/dist/node/orchestration/initServices.d.ts +1 -1
- package/dist/node/orchestration/initServices.d.ts.map +1 -1
- package/dist/node/xl1.mjs +1 -1
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +18 -25
- package/src/commands/mempool/runMempool.ts +1 -1
- package/src/commands/validator/runValidator.ts +2 -2
- package/src/orchestration/index.ts +0 -3
- package/src/orchestration/initServices.ts +66 -73
- package/dist/node/orchestration/ChainInitializableParams.d.ts +0 -11
- package/dist/node/orchestration/ChainInitializableParams.d.ts.map +0 -1
- package/dist/node/orchestration/actor/implementation/BalanceActor.d.ts +0 -14
- package/dist/node/orchestration/actor/implementation/BalanceActor.d.ts.map +0 -1
- package/dist/node/orchestration/actor/implementation/ValidatorActor.d.ts +0 -20
- package/dist/node/orchestration/actor/implementation/ValidatorActor.d.ts.map +0 -1
- package/dist/node/orchestration/actor/implementation/index.d.ts +0 -3
- package/dist/node/orchestration/actor/implementation/index.d.ts.map +0 -1
- package/dist/node/orchestration/actor/index.d.ts +0 -2
- package/dist/node/orchestration/actor/index.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/ChainFinalized/archivist.d.ts +0 -4
- package/dist/node/orchestration/archivists/ChainFinalized/archivist.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/ChainFinalized/index.d.ts +0 -2
- package/dist/node/orchestration/archivists/ChainFinalized/index.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/ChainFinalized/local.d.ts +0 -7
- package/dist/node/orchestration/archivists/ChainFinalized/local.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/ChainFinalized/remote.d.ts +0 -7
- package/dist/node/orchestration/archivists/ChainFinalized/remote.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/ChainSubmissions/archivist.d.ts +0 -7
- package/dist/node/orchestration/archivists/ChainSubmissions/archivist.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/ChainSubmissions/index.d.ts +0 -2
- package/dist/node/orchestration/archivists/ChainSubmissions/index.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/ChainSubmissions/remote.d.ts +0 -7
- package/dist/node/orchestration/archivists/ChainSubmissions/remote.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/PendingTransactions/archivist.d.ts +0 -8
- package/dist/node/orchestration/archivists/PendingTransactions/archivist.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/PendingTransactions/index.d.ts +0 -2
- package/dist/node/orchestration/archivists/PendingTransactions/index.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/PendingTransactions/local.d.ts +0 -7
- package/dist/node/orchestration/archivists/PendingTransactions/local.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/PendingTransactions/remote.d.ts +0 -7
- package/dist/node/orchestration/archivists/PendingTransactions/remote.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/RejectedTransactions/archivist.d.ts +0 -4
- package/dist/node/orchestration/archivists/RejectedTransactions/archivist.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/RejectedTransactions/index.d.ts +0 -2
- package/dist/node/orchestration/archivists/RejectedTransactions/index.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/RejectedTransactions/local.d.ts +0 -4
- package/dist/node/orchestration/archivists/RejectedTransactions/local.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/StakeIntentState/archivist.d.ts +0 -5
- package/dist/node/orchestration/archivists/StakeIntentState/archivist.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/StakeIntentState/index.d.ts +0 -2
- package/dist/node/orchestration/archivists/StakeIntentState/index.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/StakeIntentState/local.d.ts +0 -7
- package/dist/node/orchestration/archivists/StakeIntentState/local.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/index.d.ts +0 -6
- package/dist/node/orchestration/archivists/index.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/lib/index.d.ts +0 -2
- package/dist/node/orchestration/archivists/lib/index.d.ts.map +0 -1
- package/dist/node/orchestration/archivists/lib/localPersistentArchivist.d.ts +0 -21
- package/dist/node/orchestration/archivists/lib/localPersistentArchivist.d.ts.map +0 -1
- package/dist/node/orchestration/health/index.d.ts +0 -2
- package/dist/node/orchestration/health/index.d.ts.map +0 -1
- package/dist/node/orchestration/health/initHealthEndpoints.d.ts +0 -11
- package/dist/node/orchestration/health/initHealthEndpoints.d.ts.map +0 -1
- package/dist/node/orchestration/host/implementation/DefaultHost.d.ts +0 -12
- package/dist/node/orchestration/host/implementation/DefaultHost.d.ts.map +0 -1
- package/dist/node/orchestration/host/implementation/DefaultServiceCollection.d.ts +0 -24
- package/dist/node/orchestration/host/implementation/DefaultServiceCollection.d.ts.map +0 -1
- package/dist/node/orchestration/host/implementation/DefaultServiceProvider.d.ts +0 -7
- package/dist/node/orchestration/host/implementation/DefaultServiceProvider.d.ts.map +0 -1
- package/dist/node/orchestration/host/implementation/index.d.ts +0 -3
- package/dist/node/orchestration/host/implementation/index.d.ts.map +0 -1
- package/dist/node/orchestration/host/index.d.ts +0 -3
- package/dist/node/orchestration/host/index.d.ts.map +0 -1
- package/dist/node/orchestration/host/model/Host.d.ts +0 -19
- package/dist/node/orchestration/host/model/Host.d.ts.map +0 -1
- package/dist/node/orchestration/host/model/ServiceCollection.d.ts +0 -20
- package/dist/node/orchestration/host/model/ServiceCollection.d.ts.map +0 -1
- package/dist/node/orchestration/host/model/ServiceProvider.d.ts +0 -4
- package/dist/node/orchestration/host/model/ServiceProvider.d.ts.map +0 -1
- package/dist/node/orchestration/host/model/index.d.ts +0 -4
- package/dist/node/orchestration/host/model/index.d.ts.map +0 -1
- package/dist/node/orchestration/map/BalanceSummary/index.d.ts +0 -3
- package/dist/node/orchestration/map/BalanceSummary/index.d.ts.map +0 -1
- package/dist/node/orchestration/map/BalanceSummary/initBalanceSummaryMap.d.ts +0 -5
- package/dist/node/orchestration/map/BalanceSummary/initBalanceSummaryMap.d.ts.map +0 -1
- package/dist/node/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.d.ts +0 -5
- package/dist/node/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.d.ts.map +0 -1
- package/dist/node/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.d.ts +0 -5
- package/dist/node/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.d.ts.map +0 -1
- package/dist/node/orchestration/map/BalanceSummary/initTransferSummaryMap.d.ts +0 -5
- package/dist/node/orchestration/map/BalanceSummary/initTransferSummaryMap.d.ts.map +0 -1
- package/dist/node/orchestration/map/index.d.ts +0 -2
- package/dist/node/orchestration/map/index.d.ts.map +0 -1
- package/dist/node/orchestration/repository/index.d.ts +0 -2
- package/dist/node/orchestration/repository/index.d.ts.map +0 -1
- package/dist/node/orchestration/repository/lib/index.d.ts +0 -2
- package/dist/node/orchestration/repository/lib/index.d.ts.map +0 -1
- package/dist/node/orchestration/repository/lib/repositoryFromArchivist.d.ts +0 -6
- package/dist/node/orchestration/repository/lib/repositoryFromArchivist.d.ts.map +0 -1
- package/dist/node/orchestration/status/RuntimeStatusMonitor.d.ts +0 -31
- package/dist/node/orchestration/status/RuntimeStatusMonitor.d.ts.map +0 -1
- package/dist/node/orchestration/status/ServiceStatus.d.ts +0 -8
- package/dist/node/orchestration/status/ServiceStatus.d.ts.map +0 -1
- package/dist/node/orchestration/status/index.d.ts +0 -3
- package/dist/node/orchestration/status/index.d.ts.map +0 -1
- package/src/orchestration/ChainInitializableParams.ts +0 -12
- package/src/orchestration/actor/implementation/BalanceActor.ts +0 -35
- package/src/orchestration/actor/implementation/ValidatorActor.ts +0 -104
- package/src/orchestration/actor/implementation/index.ts +0 -2
- package/src/orchestration/actor/index.ts +0 -1
- package/src/orchestration/archivists/ChainFinalized/archivist.ts +0 -32
- package/src/orchestration/archivists/ChainFinalized/index.ts +0 -1
- package/src/orchestration/archivists/ChainFinalized/local.ts +0 -18
- package/src/orchestration/archivists/ChainFinalized/remote.ts +0 -20
- package/src/orchestration/archivists/ChainSubmissions/archivist.ts +0 -22
- package/src/orchestration/archivists/ChainSubmissions/index.ts +0 -1
- package/src/orchestration/archivists/ChainSubmissions/remote.ts +0 -20
- package/src/orchestration/archivists/PendingTransactions/archivist.ts +0 -35
- package/src/orchestration/archivists/PendingTransactions/index.ts +0 -1
- package/src/orchestration/archivists/PendingTransactions/local.ts +0 -21
- package/src/orchestration/archivists/PendingTransactions/remote.ts +0 -20
- package/src/orchestration/archivists/RejectedTransactions/archivist.ts +0 -21
- package/src/orchestration/archivists/RejectedTransactions/index.ts +0 -1
- package/src/orchestration/archivists/RejectedTransactions/local.ts +0 -20
- package/src/orchestration/archivists/StakeIntentState/archivist.ts +0 -24
- package/src/orchestration/archivists/StakeIntentState/index.ts +0 -1
- package/src/orchestration/archivists/StakeIntentState/local.ts +0 -19
- package/src/orchestration/archivists/index.ts +0 -5
- package/src/orchestration/archivists/lib/index.ts +0 -1
- package/src/orchestration/archivists/lib/localPersistentArchivist.ts +0 -63
- package/src/orchestration/health/index.ts +0 -1
- package/src/orchestration/health/initHealthEndpoints.ts +0 -71
- package/src/orchestration/host/implementation/DefaultHost.ts +0 -25
- package/src/orchestration/host/implementation/DefaultServiceCollection.ts +0 -60
- package/src/orchestration/host/implementation/DefaultServiceProvider.ts +0 -12
- package/src/orchestration/host/implementation/index.ts +0 -2
- package/src/orchestration/host/index.ts +0 -2
- package/src/orchestration/host/model/Host.ts +0 -21
- package/src/orchestration/host/model/ServiceCollection.ts +0 -22
- package/src/orchestration/host/model/ServiceProvider.ts +0 -3
- package/src/orchestration/host/model/index.ts +0 -3
- package/src/orchestration/map/BalanceSummary/index.ts +0 -2
- package/src/orchestration/map/BalanceSummary/initBalanceSummaryMap.ts +0 -24
- package/src/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.ts +0 -19
- package/src/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.ts +0 -20
- package/src/orchestration/map/BalanceSummary/initTransferSummaryMap.ts +0 -25
- package/src/orchestration/map/index.ts +0 -1
- package/src/orchestration/repository/index.ts +0 -1
- package/src/orchestration/repository/lib/index.ts +0 -1
- package/src/orchestration/repository/lib/repositoryFromArchivist.ts +0 -26
- package/src/orchestration/status/RuntimeStatusMonitor.ts +0 -117
- package/src/orchestration/status/ServiceStatus.ts +0 -20
- package/src/orchestration/status/index.ts +0 -2
|
@@ -2,7 +2,7 @@ import type { Logger } from '@xylabs/sdk-js';
|
|
|
2
2
|
import type { Config } from '@xyo-network/xl1-protocol-sdk';
|
|
3
3
|
interface RunMempoolContext {
|
|
4
4
|
config: Config;
|
|
5
|
-
logger
|
|
5
|
+
logger: Logger;
|
|
6
6
|
}
|
|
7
7
|
export declare function runMempool(context: RunMempoolContext): void;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runMempool.d.ts","sourceRoot":"","sources":["../../../../src/commands/mempool/runMempool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAE3D,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,
|
|
1
|
+
{"version":3,"file":"runMempool.d.ts","sourceRoot":"","sources":["../../../../src/commands/mempool/runMempool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAE3D,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,QAEpD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@xylabs/sdk-js';
|
|
2
|
-
import type
|
|
2
|
+
import { type OrchestratorInstance } from '@xyo-network/chain-orchestration';
|
|
3
3
|
import type { Config } from '@xyo-network/xl1-protocol-sdk';
|
|
4
4
|
interface RunValidatorContext {
|
|
5
5
|
config: Config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runValidator.d.ts","sourceRoot":"","sources":["../../../../src/commands/validator/runValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"runValidator.d.ts","sourceRoot":"","sources":["../../../../src/commands/validator/runValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,KAAK,oBAAoB,EAAkB,MAAM,kCAAkC,CAAA;AAC5F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAI3D,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,oBAAoB,CAAA;CACnC;AAED,eAAO,MAAM,YAAY,GAAU,SAAS,mBAAmB,kBAsB9D,CAAA"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,431 +1,31 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
-
// src/orchestration/actor/implementation/BalanceActor.ts
|
|
5
|
-
import { assertEx } from "@xylabs/sdk-js";
|
|
6
|
-
import { Actor } from "@xyo-network/chain-orchestration";
|
|
7
|
-
import { Mutex } from "async-mutex";
|
|
8
|
-
var BalanceActor = class extends Actor {
|
|
9
|
-
static {
|
|
10
|
-
__name(this, "BalanceActor");
|
|
11
|
-
}
|
|
12
|
-
_updateMutex = new Mutex();
|
|
13
|
-
get balanceService() {
|
|
14
|
-
return assertEx(this.params.balance, () => "balanceService not set");
|
|
15
|
-
}
|
|
16
|
-
get blockViewer() {
|
|
17
|
-
return assertEx(this.params.blockViewer, () => "blockViewer not set");
|
|
18
|
-
}
|
|
19
|
-
async startHandler() {
|
|
20
|
-
await super.startHandler();
|
|
21
|
-
this.registerTimer(
|
|
22
|
-
"BalanceTimer",
|
|
23
|
-
async () => {
|
|
24
|
-
await this.updateBalance();
|
|
25
|
-
},
|
|
26
|
-
1e3,
|
|
27
|
-
1e4
|
|
28
|
-
/* 1000 */
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
async updateBalance() {
|
|
32
|
-
if (this._updateMutex.isLocked()) return;
|
|
33
|
-
await this._updateMutex.runExclusive(async () => {
|
|
34
|
-
const head = await this.blockViewer.currentBlockHash();
|
|
35
|
-
await this.balanceService.accountBalances([], head);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// src/orchestration/actor/implementation/ValidatorActor.ts
|
|
41
|
-
import { assertEx as assertEx2, creatable, isDefined, isUndefined, toHex } from "@xylabs/sdk-js";
|
|
42
|
-
import { Actor as Actor2 } from "@xyo-network/chain-orchestration";
|
|
43
|
-
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
44
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
45
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
46
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
47
|
-
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;
|
|
48
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
49
|
-
}
|
|
50
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
51
|
-
var ValidatorActor = class extends Actor2 {
|
|
52
|
-
static {
|
|
53
|
-
__name(this, "ValidatorActor");
|
|
54
|
-
}
|
|
55
|
-
_lastValidatedBlock;
|
|
56
|
-
_lastValidatedBlockHash;
|
|
57
|
-
get account() {
|
|
58
|
-
return assertEx2(this.params.account, () => "account not set");
|
|
59
|
-
}
|
|
60
|
-
get balanceService() {
|
|
61
|
-
return assertEx2(this.params.balance, () => "balanceService not set");
|
|
62
|
-
}
|
|
63
|
-
get blockViewer() {
|
|
64
|
-
return assertEx2(this.params.blockViewer, () => "blockViewer not set");
|
|
65
|
-
}
|
|
66
|
-
get chainStakeViewer() {
|
|
67
|
-
return assertEx2(this.params.chainStakeViewer, () => "chainStakeViewer not set");
|
|
68
|
-
}
|
|
69
|
-
// protected get chainSubmissionsArchivistWrite() {
|
|
70
|
-
// return assertEx(this.params.chainSubmissionsArchivistWrite, () => 'chainSubmissionsArchivistWrite not set')
|
|
71
|
-
// }
|
|
72
|
-
// protected get pendingBundledTransactionsArchivistWrite() {
|
|
73
|
-
// return assertEx(this.params.pendingBundledTransactionsArchivistWrite, () => 'pendingBundledTransactionsArchivistWrite not set')
|
|
74
|
-
// }
|
|
75
|
-
// protected get stakeIntentService() {
|
|
76
|
-
// return assertEx(this.params.stakeIntent, () => 'stakeIntentService not set')
|
|
77
|
-
// }
|
|
78
|
-
// protected get validator() {
|
|
79
|
-
// return assertEx(this.params.validator, () => 'validator not set')
|
|
80
|
-
// }
|
|
81
|
-
async startHandler() {
|
|
82
|
-
await super.startHandler();
|
|
83
|
-
this.registerTimer(
|
|
84
|
-
"BlockProductionTimer",
|
|
85
|
-
async () => {
|
|
86
|
-
await this.spanAsync("produceBlock", async () => {
|
|
87
|
-
const block = (await this.blockViewer.currentBlock())[0];
|
|
88
|
-
if (isUndefined(block)) return;
|
|
89
|
-
const hash = await PayloadBuilder.hash(block);
|
|
90
|
-
if (isDefined(this._lastValidatedBlock) && this._lastValidatedBlockHash === hash) {
|
|
91
|
-
this.logger?.log("Block already validated:", `0x${toHex(block.block)}`);
|
|
92
|
-
} else {
|
|
93
|
-
this.logger?.log("Validating block:", `0x${toHex(block.block)}`);
|
|
94
|
-
const valid = await this.validateBlock(block);
|
|
95
|
-
if (valid) {
|
|
96
|
-
this.logger?.log("Validated block:", `0x${toHex(block.block)}`);
|
|
97
|
-
} else {
|
|
98
|
-
this.logger?.log("Invalid block:", `0x${toHex(block.block)}`);
|
|
99
|
-
await this.slashInvalidBlock(block);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
2e3,
|
|
105
|
-
1500
|
|
106
|
-
/* 500 */
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
async slashInvalidBlock(_block) {
|
|
110
|
-
const slashed = await Promise.resolve(true);
|
|
111
|
-
return slashed;
|
|
112
|
-
}
|
|
113
|
-
async validateBlock(block) {
|
|
114
|
-
const valid = await Promise.resolve(true);
|
|
115
|
-
this._lastValidatedBlock = block;
|
|
116
|
-
this._lastValidatedBlockHash = await PayloadBuilder.hash(block);
|
|
117
|
-
return valid;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
ValidatorActor = _ts_decorate([
|
|
121
|
-
creatable()
|
|
122
|
-
], ValidatorActor);
|
|
123
|
-
|
|
124
|
-
// src/orchestration/health/initHealthEndpoints.ts
|
|
125
|
-
import http from "http";
|
|
126
|
-
import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
127
|
-
var sendStatus = /* @__PURE__ */ __name((res, status, errorCode) => {
|
|
128
|
-
const statusCode = status === "started" ? 200 : errorCode;
|
|
129
|
-
res.writeHead(statusCode, {
|
|
130
|
-
"Content-Type": "application/json"
|
|
131
|
-
});
|
|
132
|
-
res.end(JSON.stringify({
|
|
133
|
-
status
|
|
134
|
-
}));
|
|
135
|
-
}, "sendStatus");
|
|
136
|
-
var notFound = /* @__PURE__ */ __name((res) => {
|
|
137
|
-
res.writeHead(404, {
|
|
138
|
-
"Content-Type": "application/json"
|
|
139
|
-
});
|
|
140
|
-
res.end(JSON.stringify({
|
|
141
|
-
status: "not found"
|
|
142
|
-
}));
|
|
143
|
-
}, "notFound");
|
|
144
|
-
var createHealthServer = /* @__PURE__ */ __name((port, statusMonitor, logger) => {
|
|
145
|
-
const server = http.createServer((req, res) => {
|
|
146
|
-
const url = req.url ?? "";
|
|
147
|
-
const status = statusMonitor.getGlobalStatus();
|
|
148
|
-
switch (url) {
|
|
149
|
-
case "/healthz": {
|
|
150
|
-
sendStatus(res, status, 500);
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
case "/livez": {
|
|
154
|
-
sendStatus(res, status, 503);
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
case "/readyz": {
|
|
158
|
-
sendStatus(res, status, 503);
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
default: {
|
|
162
|
-
notFound(res);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
server.listen(port, () => {
|
|
167
|
-
logger.log(`Health server running on http://localhost:${port}`);
|
|
168
|
-
logger.log(" - /healthz");
|
|
169
|
-
logger.log(" - /livez");
|
|
170
|
-
logger.log(" - /readyz");
|
|
171
|
-
});
|
|
172
|
-
return server;
|
|
173
|
-
}, "createHealthServer");
|
|
174
|
-
var initHealthEndpoints = /* @__PURE__ */ __name((params) => {
|
|
175
|
-
const { config: config2, logger, statusReporter } = params;
|
|
176
|
-
const { healthCheckPort } = config2.producer;
|
|
177
|
-
return isDefined2(healthCheckPort) ? createHealthServer(healthCheckPort, statusReporter, logger) : void 0;
|
|
178
|
-
}, "initHealthEndpoints");
|
|
179
|
-
|
|
180
4
|
// src/orchestration/initServices.ts
|
|
181
|
-
import { asAddress, assertEx
|
|
182
|
-
import { initProducerAccount } from "@xyo-network/chain-orchestration";
|
|
5
|
+
import { asAddress, assertEx, isDefined } from "@xylabs/sdk-js";
|
|
6
|
+
import { buildTelemetryConfig, initBalanceSummaryMap, initHealthEndpoints, initProducerAccount, initRejectedTransactionsArchivist, initStatusReporter, initTransferSummaryMap } from "@xyo-network/chain-orchestration";
|
|
183
7
|
import { initAccountBalanceService, initBlockProducer, initBlockRewardViewer, initBlockViewer, initChainService, initMempoolRunner, initMempoolViewer, initTimeService } from "@xyo-network/chain-services";
|
|
184
8
|
import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
185
|
-
import { startupSpanAsync as startupSpanAsync4 } from "@xyo-network/chain-utils";
|
|
186
|
-
import { validateHydratedBlockState } from "@xyo-network/chain-validation";
|
|
187
|
-
|
|
188
|
-
// src/orchestration/archivists/RejectedTransactions/archivist.ts
|
|
189
9
|
import { startupSpanAsync } from "@xyo-network/chain-utils";
|
|
190
|
-
import {
|
|
191
|
-
import {
|
|
192
|
-
|
|
193
|
-
// src/orchestration/archivists/RejectedTransactions/local.ts
|
|
194
|
-
import { MemoryArchivist, MemoryArchivistConfigSchema } from "@xyo-network/archivist-memory";
|
|
195
|
-
import { Mutex as Mutex2 } from "async-mutex";
|
|
196
|
-
var mutex = new Mutex2();
|
|
197
|
-
var singleton;
|
|
198
|
-
var initLocalRejectedTransactionsArchivist = /* @__PURE__ */ __name(async () => {
|
|
199
|
-
return await mutex.runExclusive(async () => {
|
|
200
|
-
if (singleton) return singleton;
|
|
201
|
-
singleton = await MemoryArchivist.create({
|
|
202
|
-
account: "random",
|
|
203
|
-
config: {
|
|
204
|
-
schema: MemoryArchivistConfigSchema,
|
|
205
|
-
max: 1e3,
|
|
206
|
-
name: "localRejectedTransactions"
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
return singleton;
|
|
210
|
-
});
|
|
211
|
-
}, "initLocalRejectedTransactionsArchivist");
|
|
212
|
-
|
|
213
|
-
// src/orchestration/archivists/RejectedTransactions/archivist.ts
|
|
214
|
-
var mutex2 = new Mutex3();
|
|
215
|
-
var singleton2;
|
|
216
|
-
async function initRejectedTransactionsArchivist(params) {
|
|
217
|
-
return await mutex2.runExclusive(async () => {
|
|
218
|
-
if (singleton2) return singleton2;
|
|
219
|
-
return await timeBudget("initRejectedTransactionsArchivist", params.logger, async () => {
|
|
220
|
-
const local = await startupSpanAsync("RejectedTransactionsArchivist:initLocal", () => initLocalRejectedTransactionsArchivist(params));
|
|
221
|
-
singleton2 = local;
|
|
222
|
-
return singleton2;
|
|
223
|
-
}, 2e3, true);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
__name(initRejectedTransactionsArchivist, "initRejectedTransactionsArchivist");
|
|
227
|
-
|
|
228
|
-
// src/orchestration/map/BalanceSummary/initBalanceSummaryMap.ts
|
|
229
|
-
import { isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
230
|
-
import { startupSpanAsync as startupSpanAsync2 } from "@xyo-network/chain-utils";
|
|
231
|
-
import { timeBudget as timeBudget2 } from "@xyo-network/xl1-protocol-sdk";
|
|
232
|
-
import { Mutex as Mutex5 } from "async-mutex";
|
|
233
|
-
|
|
234
|
-
// src/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.ts
|
|
235
|
-
import { isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
236
|
-
import { getLocalPersistentMap } from "@xyo-network/chain-protocol";
|
|
237
|
-
import { Mutex as Mutex4 } from "async-mutex";
|
|
238
|
-
var mutex3 = new Mutex4();
|
|
239
|
-
var singleton3;
|
|
240
|
-
var initLocalBalanceSummaryMap = /* @__PURE__ */ __name(async (params) => {
|
|
241
|
-
return await mutex3.runExclusive(async () => {
|
|
242
|
-
if (isDefined3(singleton3)) return singleton3;
|
|
243
|
-
const { root } = params.config.storage;
|
|
244
|
-
singleton3 = await getLocalPersistentMap("balance", "summary", root);
|
|
245
|
-
return singleton3;
|
|
246
|
-
});
|
|
247
|
-
}, "initLocalBalanceSummaryMap");
|
|
248
|
-
|
|
249
|
-
// src/orchestration/map/BalanceSummary/initBalanceSummaryMap.ts
|
|
250
|
-
var mutex4 = new Mutex5();
|
|
251
|
-
var singleton4;
|
|
252
|
-
async function initBalanceSummaryMap(params) {
|
|
253
|
-
return await mutex4.runExclusive(async () => {
|
|
254
|
-
if (isDefined4(singleton4)) return singleton4;
|
|
255
|
-
return await timeBudget2("initBalanceSummaryMap", params.logger, async () => {
|
|
256
|
-
const local = await startupSpanAsync2("BalanceSummaryMap:initLocal", () => initLocalBalanceSummaryMap(params));
|
|
257
|
-
singleton4 = local;
|
|
258
|
-
return singleton4;
|
|
259
|
-
}, 2e3, true);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
__name(initBalanceSummaryMap, "initBalanceSummaryMap");
|
|
263
|
-
|
|
264
|
-
// src/orchestration/map/BalanceSummary/initTransferSummaryMap.ts
|
|
265
|
-
import { isDefined as isDefined6 } from "@xylabs/sdk-js";
|
|
266
|
-
import { startupSpanAsync as startupSpanAsync3 } from "@xyo-network/chain-utils";
|
|
267
|
-
import { timeBudget as timeBudget3 } from "@xyo-network/xl1-protocol-sdk";
|
|
268
|
-
import { Mutex as Mutex7 } from "async-mutex";
|
|
269
|
-
|
|
270
|
-
// src/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.ts
|
|
271
|
-
import { isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
272
|
-
import { getLocalPersistentMap as getLocalPersistentMap2 } from "@xyo-network/chain-protocol";
|
|
273
|
-
import { Mutex as Mutex6 } from "async-mutex";
|
|
274
|
-
var mutex5 = new Mutex6();
|
|
275
|
-
var singleton5;
|
|
276
|
-
var initLocalTransferSummaryMap = /* @__PURE__ */ __name(async (params) => {
|
|
277
|
-
return await mutex5.runExclusive(async () => {
|
|
278
|
-
if (isDefined5(singleton5)) return singleton5;
|
|
279
|
-
const { root } = params.config.storage;
|
|
280
|
-
singleton5 = await getLocalPersistentMap2("transfer", "summary", root);
|
|
281
|
-
return singleton5;
|
|
282
|
-
});
|
|
283
|
-
}, "initLocalTransferSummaryMap");
|
|
284
|
-
|
|
285
|
-
// src/orchestration/map/BalanceSummary/initTransferSummaryMap.ts
|
|
286
|
-
var mutex6 = new Mutex7();
|
|
287
|
-
var singleton6;
|
|
288
|
-
async function initTransferSummaryMap(params) {
|
|
289
|
-
return await mutex6.runExclusive(async () => {
|
|
290
|
-
if (isDefined6(singleton6)) return singleton6;
|
|
291
|
-
return await timeBudget3("initTransferSummaryMap:Init", params.logger, async () => {
|
|
292
|
-
const local = await startupSpanAsync3("TransferSummaryMap:initLocal", () => initLocalTransferSummaryMap(params));
|
|
293
|
-
singleton6 = local;
|
|
294
|
-
return singleton6;
|
|
295
|
-
}, 2e3, true);
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
__name(initTransferSummaryMap, "initTransferSummaryMap");
|
|
299
|
-
|
|
300
|
-
// src/orchestration/status/ServiceStatus.ts
|
|
301
|
-
var LoggerStatusReporter = class {
|
|
302
|
-
static {
|
|
303
|
-
__name(this, "LoggerStatusReporter");
|
|
304
|
-
}
|
|
305
|
-
logger;
|
|
306
|
-
statusMap = {};
|
|
307
|
-
constructor(logger) {
|
|
308
|
-
this.logger = logger;
|
|
309
|
-
}
|
|
310
|
-
report(name, status, progress) {
|
|
311
|
-
this.statusMap[name] = status;
|
|
312
|
-
const starting = Object.entries(this.statusMap).map(([, value]) => value === "starting" ? 1 : 0).reduce((a, b) => a + b, 0);
|
|
313
|
-
const started = Object.entries(this.statusMap).map(([, value]) => value === "started" ? 1 : 0).reduce((a, b) => a + b, 0);
|
|
314
|
-
this.logger.info(`${started}/${starting + started} ${name} status: ${status}`, {
|
|
315
|
-
progress
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
// src/orchestration/status/RuntimeStatusMonitor.ts
|
|
321
|
-
var statusPriority = {
|
|
322
|
-
error: 0,
|
|
323
|
-
stopped: 1,
|
|
324
|
-
stopping: 2,
|
|
325
|
-
creating: 3,
|
|
326
|
-
created: 4,
|
|
327
|
-
starting: 5,
|
|
328
|
-
started: 6
|
|
329
|
-
};
|
|
330
|
-
var SENTINEL_STATUS = "starting";
|
|
331
|
-
var reduceToMinimumStatus = /* @__PURE__ */ __name((statuses) => {
|
|
332
|
-
let minStatus = SENTINEL_STATUS;
|
|
333
|
-
let minPriority = Infinity;
|
|
334
|
-
for (const status of statuses) {
|
|
335
|
-
const priority = statusPriority[status];
|
|
336
|
-
if (priority < minPriority) {
|
|
337
|
-
minPriority = priority;
|
|
338
|
-
minStatus = status;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return minStatus;
|
|
342
|
-
}, "reduceToMinimumStatus");
|
|
343
|
-
var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
344
|
-
static {
|
|
345
|
-
__name(this, "RuntimeStatusMonitor");
|
|
346
|
-
}
|
|
347
|
-
globalTransitions = [];
|
|
348
|
-
transitions = [];
|
|
349
|
-
getGlobalStatus() {
|
|
350
|
-
if (Object.keys(this.statusMap).length === 0) return SENTINEL_STATUS;
|
|
351
|
-
return reduceToMinimumStatus(Object.values(this.statusMap));
|
|
352
|
-
}
|
|
353
|
-
getStatus(name) {
|
|
354
|
-
return this.statusMap[name];
|
|
355
|
-
}
|
|
356
|
-
onGlobalTransition(match, handler) {
|
|
357
|
-
this.globalTransitions.push({
|
|
358
|
-
...match,
|
|
359
|
-
handler
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Register a callback to be called on a specific transition.
|
|
364
|
-
*/
|
|
365
|
-
onTransition(match, handler) {
|
|
366
|
-
this.transitions.push({
|
|
367
|
-
...match,
|
|
368
|
-
handler
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
report(name, status, progress) {
|
|
372
|
-
const previous = this.statusMap[name];
|
|
373
|
-
const previousGlobal = this.getGlobalStatus();
|
|
374
|
-
super.report(name, status, progress);
|
|
375
|
-
if (previous === status) return;
|
|
376
|
-
this.runTransitions(this.transitions, previous, status, name);
|
|
377
|
-
const globalStatus = this.getGlobalStatus();
|
|
378
|
-
if (previousGlobal === globalStatus) return;
|
|
379
|
-
this.runTransitions(this.globalTransitions, previousGlobal, globalStatus);
|
|
380
|
-
}
|
|
381
|
-
runTransitions(transitions, prev, next, name) {
|
|
382
|
-
for (const { from, to, name: matchName, handler } of transitions) {
|
|
383
|
-
if ((matchName === void 0 || matchName === name) && (from === void 0 || from === prev) && (to === void 0 || to === next)) {
|
|
384
|
-
handler(prev, next);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
// src/orchestration/initServices.ts
|
|
10
|
+
import { validateHydratedBlockState } from "@xyo-network/chain-validation";
|
|
11
|
+
import { ChainContractViewerMoniker, ChainStakeViewerMoniker } from "@xyo-network/xl1-protocol-sdk";
|
|
391
12
|
var isStartable = /* @__PURE__ */ __name((value) => {
|
|
392
13
|
const possibleStartable = value;
|
|
393
|
-
return
|
|
14
|
+
return isDefined(possibleStartable.start) && typeof possibleStartable.start === "function" && possibleStartable.status === "created";
|
|
394
15
|
}, "isStartable");
|
|
395
16
|
var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
396
17
|
const { config: config2, logger } = context;
|
|
397
|
-
const statusReporter =
|
|
398
|
-
|
|
399
|
-
to: "started"
|
|
400
|
-
}, () => {
|
|
401
|
-
logger.log("All services started.");
|
|
402
|
-
});
|
|
403
|
-
statusReporter.onGlobalTransition({
|
|
404
|
-
to: "error"
|
|
405
|
-
}, () => {
|
|
406
|
-
logger.error("Producer encountered an unhandled error!");
|
|
407
|
-
process.exit(1);
|
|
18
|
+
const statusReporter = initStatusReporter({
|
|
19
|
+
logger
|
|
408
20
|
});
|
|
409
|
-
await
|
|
21
|
+
await startupSpanAsync("initHealthEndpoints", () => initHealthEndpoints({
|
|
410
22
|
...context,
|
|
411
23
|
statusReporter
|
|
412
24
|
}));
|
|
413
|
-
const
|
|
414
|
-
const { path: endpoint = "/metrics", port = 9464 } = config2.telemetry?.metrics?.scrape ?? {};
|
|
415
|
-
const telemetryConfig = {
|
|
416
|
-
attributes: {
|
|
417
|
-
serviceName: "xl1-producer",
|
|
418
|
-
serviceVersion: "1.0.0"
|
|
419
|
-
},
|
|
420
|
-
otlpEndpoint,
|
|
421
|
-
metricsConfig: {
|
|
422
|
-
endpoint,
|
|
423
|
-
port
|
|
424
|
-
}
|
|
425
|
-
};
|
|
25
|
+
const telemetryConfig = buildTelemetryConfig(config2, "xl1-server", "1.0.0");
|
|
426
26
|
const [{ traceProvider, meterProvider }, account] = await Promise.all([
|
|
427
|
-
|
|
428
|
-
|
|
27
|
+
startupSpanAsync("initTelemetry", () => initTelemetry(telemetryConfig)),
|
|
28
|
+
startupSpanAsync("initProducerAccount", () => initProducerAccount(context))
|
|
429
29
|
]);
|
|
430
30
|
const baseParamsFields = {
|
|
431
31
|
logger,
|
|
@@ -447,49 +47,77 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
447
47
|
config: config2,
|
|
448
48
|
logger
|
|
449
49
|
});
|
|
450
|
-
const [
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
// chainSubmissionsArchivistWrite,
|
|
454
|
-
// stakeIntentStateArchivist,
|
|
455
|
-
chainService,
|
|
456
|
-
balanceSummaryMap
|
|
457
|
-
] = await Promise.all([
|
|
458
|
-
// startupSpanAsync(
|
|
459
|
-
// 'PendingBundledTransactionsArchivist',
|
|
460
|
-
// () => initPendingBundledTransactionsArchivist(initParams),
|
|
461
|
-
// ),
|
|
462
|
-
startupSpanAsync4("RejectedTransactionsArchivist", () => initRejectedTransactionsArchivist(initParams)),
|
|
463
|
-
// startupSpanAsync(
|
|
464
|
-
// 'ChainSubmissionsArchivist',
|
|
465
|
-
// () => initChainSubmissionsArchivist(initParams),
|
|
466
|
-
// ),
|
|
467
|
-
// startupSpanAsync(
|
|
468
|
-
// 'StakeIntentStateArchivist',
|
|
469
|
-
// () => initStakeIntentStateArchivist(initParams),
|
|
470
|
-
// ),
|
|
471
|
-
startupSpanAsync4("ChainService", () => initChainService({
|
|
50
|
+
const [rejectedTransactionsArchivist, chainService, balanceSummaryMap] = await Promise.all([
|
|
51
|
+
startupSpanAsync("RejectedTransactionsArchivist", () => initRejectedTransactionsArchivist(initParams)),
|
|
52
|
+
startupSpanAsync("ChainService", () => initChainService({
|
|
472
53
|
...initParams,
|
|
473
54
|
account,
|
|
474
55
|
name: "ChainService"
|
|
475
56
|
})),
|
|
476
|
-
|
|
477
|
-
|
|
57
|
+
startupSpanAsync("BalanceSummaryMap", () => initBalanceSummaryMap(initParams)),
|
|
58
|
+
startupSpanAsync("TransferSummaryMap", () => initTransferSummaryMap(initParams))
|
|
478
59
|
]);
|
|
479
|
-
const chainContractViewer =
|
|
480
|
-
|
|
60
|
+
const chainContractViewer = {
|
|
61
|
+
forkedAtBlockNumber: /* @__PURE__ */ __name(function() {
|
|
62
|
+
return chainService.forkedAtBlockNumber();
|
|
63
|
+
}, "forkedAtBlockNumber"),
|
|
64
|
+
forkedAtHash: /* @__PURE__ */ __name(function() {
|
|
65
|
+
return chainService.forkedAtHash();
|
|
66
|
+
}, "forkedAtHash"),
|
|
67
|
+
forkedChainId: /* @__PURE__ */ __name(function() {
|
|
68
|
+
return chainService.forkedChainId();
|
|
69
|
+
}, "forkedChainId"),
|
|
70
|
+
minWithdrawalBlocks: /* @__PURE__ */ __name(function() {
|
|
71
|
+
return chainService.minWithdrawalBlocks();
|
|
72
|
+
}, "minWithdrawalBlocks"),
|
|
73
|
+
rewardsContract: /* @__PURE__ */ __name(function() {
|
|
74
|
+
return chainService.rewardsContract();
|
|
75
|
+
}, "rewardsContract"),
|
|
76
|
+
stakingTokenAddress: /* @__PURE__ */ __name(function() {
|
|
77
|
+
return chainService.stakingTokenAddress();
|
|
78
|
+
}, "stakingTokenAddress"),
|
|
79
|
+
moniker: ChainContractViewerMoniker
|
|
80
|
+
};
|
|
81
|
+
const chainStakeViewer = {
|
|
82
|
+
...chainContractViewer,
|
|
83
|
+
active: /* @__PURE__ */ __name(function() {
|
|
84
|
+
return chainService.active();
|
|
85
|
+
}, "active"),
|
|
86
|
+
activeByStaked: /* @__PURE__ */ __name(function(staked) {
|
|
87
|
+
return chainService.activeByStaked(staked);
|
|
88
|
+
}, "activeByStaked"),
|
|
89
|
+
activeByStaker: /* @__PURE__ */ __name(function(address) {
|
|
90
|
+
return chainService.activeByStaker(address);
|
|
91
|
+
}, "activeByStaker"),
|
|
92
|
+
pending: /* @__PURE__ */ __name(function() {
|
|
93
|
+
return chainService.pending();
|
|
94
|
+
}, "pending"),
|
|
95
|
+
pendingByStaker: /* @__PURE__ */ __name(function(staker) {
|
|
96
|
+
return chainService.pendingByStaker(staker);
|
|
97
|
+
}, "pendingByStaker"),
|
|
98
|
+
withdrawn: /* @__PURE__ */ __name(function() {
|
|
99
|
+
return chainService.withdrawn();
|
|
100
|
+
}, "withdrawn"),
|
|
101
|
+
withdrawnByStaker: /* @__PURE__ */ __name(function(staker) {
|
|
102
|
+
return chainService.withdrawnByStaker(staker);
|
|
103
|
+
}, "withdrawnByStaker"),
|
|
104
|
+
chainId: /* @__PURE__ */ __name(function() {
|
|
105
|
+
return chainService.chainId();
|
|
106
|
+
}, "chainId"),
|
|
107
|
+
moniker: ChainStakeViewerMoniker
|
|
108
|
+
};
|
|
481
109
|
const blockRewardViewer = await initBlockRewardViewer({
|
|
482
110
|
config: config2,
|
|
483
111
|
chainContractViewer
|
|
484
112
|
});
|
|
485
113
|
const chainId = await chainService.chainId();
|
|
486
|
-
const blockViewer = await
|
|
114
|
+
const blockViewer = await startupSpanAsync("BlockViewer", () => initBlockViewer({
|
|
487
115
|
...initParams
|
|
488
116
|
}));
|
|
489
|
-
const balanceService = await
|
|
117
|
+
const balanceService = await startupSpanAsync("BalanceService", () => initAccountBalanceService({
|
|
490
118
|
...initParams
|
|
491
119
|
}));
|
|
492
|
-
const time = await
|
|
120
|
+
const time = await startupSpanAsync("TimeService", () => initTimeService({
|
|
493
121
|
name: "TimeService",
|
|
494
122
|
blockViewer,
|
|
495
123
|
...initParams
|
|
@@ -500,7 +128,7 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
500
128
|
validateHydratedBlockState,
|
|
501
129
|
...initParams
|
|
502
130
|
};
|
|
503
|
-
const rewardAddress =
|
|
131
|
+
const rewardAddress = isDefined(config2.producer.rewardAddress) ? assertEx(asAddress(config2.producer.rewardAddress), () => "Invalid block reward address provided") : account.address;
|
|
504
132
|
const producerParams = {
|
|
505
133
|
...validatorParams,
|
|
506
134
|
account,
|
|
@@ -510,23 +138,18 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
510
138
|
blockRewardViewer,
|
|
511
139
|
mempoolRunner,
|
|
512
140
|
mempoolViewer,
|
|
513
|
-
// pendingBundledTransactionsArchivist,
|
|
514
|
-
// pendingTransactionsService,
|
|
515
141
|
rejectedTransactionsArchivist,
|
|
516
142
|
rewardAddress,
|
|
517
143
|
time,
|
|
518
144
|
...initParams
|
|
519
145
|
};
|
|
520
|
-
const producer = await
|
|
146
|
+
const producer = await startupSpanAsync("Producer", () => initBlockProducer(producerParams));
|
|
521
147
|
const services = {
|
|
522
148
|
account,
|
|
523
149
|
balance: balanceService,
|
|
524
150
|
chainContractViewer,
|
|
525
151
|
blockViewer,
|
|
526
152
|
chainStakeViewer,
|
|
527
|
-
// chainSubmissionsArchivistWrite,
|
|
528
|
-
// election: electionService,
|
|
529
|
-
// pendingBundledTransactionsArchivistWrite,
|
|
530
153
|
mempoolRunner,
|
|
531
154
|
mempoolViewer,
|
|
532
155
|
producer,
|
|
@@ -537,7 +160,7 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
537
160
|
balanceSummaryMap,
|
|
538
161
|
...Object.values(services)
|
|
539
162
|
].filter(isStartable);
|
|
540
|
-
|
|
163
|
+
assertEx((await Promise.all(startableServices.map((service) => service.start()))).every(Boolean), () => "One or more services failed to start");
|
|
541
164
|
logger?.log("All services started successfully.");
|
|
542
165
|
return {
|
|
543
166
|
...services,
|
|
@@ -546,7 +169,7 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
546
169
|
}, "initServices");
|
|
547
170
|
|
|
548
171
|
// src/runCLI.ts
|
|
549
|
-
import { deepMerge, isDefined as
|
|
172
|
+
import { deepMerge, isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
550
173
|
import { Orchestrator } from "@xyo-network/chain-orchestration";
|
|
551
174
|
import { runProducer } from "@xyo-network/chain-producer";
|
|
552
175
|
import { ConfigZod } from "@xyo-network/xl1-protocol-sdk";
|
|
@@ -603,16 +226,16 @@ var XL1LogoColorizedAscii = `\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\
|
|
|
603
226
|
\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\x1B[0m\x1B[38;2;108;93;162m\xB2\x1B[0m\x1B[38;2;99;79;176m^\x1B[0m`;
|
|
604
227
|
|
|
605
228
|
// src/initLogger.ts
|
|
606
|
-
import { Base, ConsoleLogger, isDefined as
|
|
229
|
+
import { Base, ConsoleLogger, isDefined as isDefined2, LogLevel, SilentLogger } from "@xylabs/sdk-js";
|
|
607
230
|
var initLogger = /* @__PURE__ */ __name((config2) => {
|
|
608
231
|
let logger;
|
|
609
232
|
if (config2.silent) {
|
|
610
233
|
logger = new SilentLogger();
|
|
611
234
|
} else {
|
|
612
235
|
let level;
|
|
613
|
-
if (
|
|
236
|
+
if (isDefined2(config2.logLevel)) {
|
|
614
237
|
const parsed = LogLevel[config2.logLevel.toLowerCase()];
|
|
615
|
-
if (
|
|
238
|
+
if (isDefined2(parsed)) level = parsed;
|
|
616
239
|
}
|
|
617
240
|
logger = new ConsoleLogger(level);
|
|
618
241
|
}
|
|
@@ -638,7 +261,7 @@ var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
|
638
261
|
}, "optionsFromGlobalZodRegistry");
|
|
639
262
|
|
|
640
263
|
// src/tryParseConfig.ts
|
|
641
|
-
import { isDefined as
|
|
264
|
+
import { isDefined as isDefined3, isNull } from "@xylabs/sdk-js";
|
|
642
265
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
643
266
|
var configName = "xyo";
|
|
644
267
|
var configSection = "xl1";
|
|
@@ -647,7 +270,7 @@ var tryParseConfig = /* @__PURE__ */ __name(() => {
|
|
|
647
270
|
const result = explorer.search();
|
|
648
271
|
if (!isNull(result)) {
|
|
649
272
|
const section = result?.config?.[configSection];
|
|
650
|
-
if (
|
|
273
|
+
if (isDefined3(section) && typeof section === "object") {
|
|
651
274
|
return section;
|
|
652
275
|
}
|
|
653
276
|
}
|
|
@@ -677,7 +300,7 @@ var waitForHostPort = /* @__PURE__ */ __name((host, port) => {
|
|
|
677
300
|
|
|
678
301
|
// src/runCLI.ts
|
|
679
302
|
var configuration;
|
|
680
|
-
var version =
|
|
303
|
+
var version = isDefined4("1.17.2") ? "1.17.2" : "unknown";
|
|
681
304
|
var getContextFromConfig = /* @__PURE__ */ __name(async (configuration2) => {
|
|
682
305
|
const logger = initLogger(configuration2);
|
|
683
306
|
const orchestrator = await Orchestrator.create({
|
|
@@ -803,11 +426,6 @@ var start = /* @__PURE__ */ __name(async () => {
|
|
|
803
426
|
await runCLI();
|
|
804
427
|
}, "start");
|
|
805
428
|
export {
|
|
806
|
-
BalanceActor,
|
|
807
|
-
LoggerStatusReporter,
|
|
808
|
-
RuntimeStatusMonitor,
|
|
809
|
-
ValidatorActor,
|
|
810
|
-
initHealthEndpoints,
|
|
811
429
|
initServices,
|
|
812
430
|
runCLI,
|
|
813
431
|
start
|