@xyo-network/chain-orchestration 1.17.1 → 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/neutral/ChainInitializableParams.d.ts +11 -0
- package/dist/neutral/ChainInitializableParams.d.ts.map +1 -0
- package/dist/neutral/actor/Actor.d.ts.map +1 -1
- package/dist/neutral/actor/BalanceActor.d.ts +14 -0
- package/dist/neutral/actor/BalanceActor.d.ts.map +1 -0
- package/dist/neutral/actor/ValidatorActor.d.ts +23 -0
- package/dist/neutral/actor/ValidatorActor.d.ts.map +1 -0
- package/dist/neutral/actor/index.d.ts +2 -0
- package/dist/neutral/actor/index.d.ts.map +1 -1
- package/dist/neutral/archivists/ChainFinalized/archivist.d.ts +4 -0
- package/dist/neutral/archivists/ChainFinalized/archivist.d.ts.map +1 -0
- package/dist/neutral/archivists/ChainFinalized/index.d.ts +2 -0
- package/dist/neutral/archivists/ChainFinalized/index.d.ts.map +1 -0
- package/dist/neutral/archivists/ChainFinalized/local.d.ts +7 -0
- package/dist/neutral/archivists/ChainFinalized/local.d.ts.map +1 -0
- package/dist/neutral/archivists/PendingBlocks/archivist.d.ts +4 -0
- package/dist/neutral/archivists/PendingBlocks/archivist.d.ts.map +1 -0
- package/dist/neutral/archivists/PendingBlocks/index.d.ts +2 -0
- package/dist/neutral/archivists/PendingBlocks/index.d.ts.map +1 -0
- package/dist/neutral/archivists/PendingBlocks/local.d.ts +7 -0
- package/dist/neutral/archivists/PendingBlocks/local.d.ts.map +1 -0
- package/dist/neutral/archivists/PendingTransactions/archivist.d.ts +4 -0
- package/dist/neutral/archivists/PendingTransactions/archivist.d.ts.map +1 -0
- package/dist/neutral/archivists/PendingTransactions/index.d.ts +2 -0
- package/dist/neutral/archivists/PendingTransactions/index.d.ts.map +1 -0
- package/dist/neutral/archivists/PendingTransactions/local.d.ts +7 -0
- package/dist/neutral/archivists/PendingTransactions/local.d.ts.map +1 -0
- package/dist/neutral/archivists/RejectedTransactions/archivist.d.ts +4 -0
- package/dist/neutral/archivists/RejectedTransactions/archivist.d.ts.map +1 -0
- package/dist/neutral/archivists/RejectedTransactions/index.d.ts +2 -0
- package/dist/neutral/archivists/RejectedTransactions/index.d.ts.map +1 -0
- package/dist/neutral/archivists/RejectedTransactions/local.d.ts +4 -0
- package/dist/neutral/archivists/RejectedTransactions/local.d.ts.map +1 -0
- package/dist/neutral/archivists/StakeIntentState/archivist.d.ts +5 -0
- package/dist/neutral/archivists/StakeIntentState/archivist.d.ts.map +1 -0
- package/dist/neutral/archivists/StakeIntentState/index.d.ts +2 -0
- package/dist/neutral/archivists/StakeIntentState/index.d.ts.map +1 -0
- package/dist/neutral/archivists/StakeIntentState/local.d.ts +7 -0
- package/dist/neutral/archivists/StakeIntentState/local.d.ts.map +1 -0
- package/dist/neutral/archivists/index.d.ts +6 -0
- package/dist/neutral/archivists/index.d.ts.map +1 -0
- package/dist/neutral/archivists/lib/index.d.ts +2 -0
- package/dist/neutral/archivists/lib/index.d.ts.map +1 -0
- package/dist/neutral/archivists/lib/localPersistentArchivist.d.ts +21 -0
- package/dist/neutral/archivists/lib/localPersistentArchivist.d.ts.map +1 -0
- package/dist/neutral/buildTelemetryConfig.d.ts +13 -0
- package/dist/neutral/buildTelemetryConfig.d.ts.map +1 -0
- package/dist/neutral/health/index.d.ts +2 -0
- package/dist/neutral/health/index.d.ts.map +1 -0
- package/dist/neutral/health/initHealthEndpoints.d.ts +11 -0
- package/dist/neutral/health/initHealthEndpoints.d.ts.map +1 -0
- package/dist/neutral/host/implementation/DefaultHost.d.ts +12 -0
- package/dist/neutral/host/implementation/DefaultHost.d.ts.map +1 -0
- package/dist/neutral/host/implementation/DefaultServiceCollection.d.ts +24 -0
- package/dist/neutral/host/implementation/DefaultServiceCollection.d.ts.map +1 -0
- package/dist/neutral/host/implementation/DefaultServiceProvider.d.ts +7 -0
- package/dist/neutral/host/implementation/DefaultServiceProvider.d.ts.map +1 -0
- package/dist/neutral/host/implementation/index.d.ts +3 -0
- package/dist/neutral/host/implementation/index.d.ts.map +1 -0
- package/dist/neutral/host/index.d.ts +3 -0
- package/dist/neutral/host/index.d.ts.map +1 -0
- package/dist/neutral/host/model/Host.d.ts +19 -0
- package/dist/neutral/host/model/Host.d.ts.map +1 -0
- package/dist/neutral/host/model/ServiceCollection.d.ts +20 -0
- package/dist/neutral/host/model/ServiceCollection.d.ts.map +1 -0
- package/dist/neutral/host/model/ServiceProvider.d.ts +4 -0
- package/dist/neutral/host/model/ServiceProvider.d.ts.map +1 -0
- package/dist/neutral/host/model/index.d.ts +4 -0
- package/dist/neutral/host/model/index.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +7 -2
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +701 -626
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/init/index.d.ts +1 -2
- package/dist/neutral/init/index.d.ts.map +1 -1
- package/dist/neutral/init/initChainStakeViewer.d.ts +4 -1
- package/dist/neutral/init/initChainStakeViewer.d.ts.map +1 -1
- package/dist/neutral/init/initServerNode.d.ts +4 -2
- package/dist/neutral/init/initServerNode.d.ts.map +1 -1
- package/dist/neutral/init/initStatusReporter.d.ts +6 -0
- package/dist/neutral/init/initStatusReporter.d.ts.map +1 -0
- package/dist/neutral/manifest/getLocator.d.ts +1 -1
- package/dist/neutral/manifest/getLocator.d.ts.map +1 -1
- package/dist/neutral/manifest/loadNode.d.ts.map +1 -1
- package/dist/neutral/manifest/public/index.d.ts +5 -2
- package/dist/neutral/manifest/public/index.d.ts.map +1 -1
- package/dist/neutral/orchestrator/Orchestrator.d.ts +0 -2
- package/dist/neutral/orchestrator/Orchestrator.d.ts.map +1 -1
- package/dist/neutral/status/RuntimeStatusMonitor.d.ts +31 -0
- package/dist/neutral/status/RuntimeStatusMonitor.d.ts.map +1 -0
- package/dist/neutral/status/ServiceStatus.d.ts +8 -0
- package/dist/neutral/status/ServiceStatus.d.ts.map +1 -0
- package/dist/neutral/status/index.d.ts +3 -0
- package/dist/neutral/status/index.d.ts.map +1 -0
- package/package.json +34 -36
- package/src/ChainInitializableParams.ts +12 -0
- package/src/actor/Actor.ts +0 -1
- package/src/actor/BalanceActor.ts +36 -0
- package/src/actor/ValidatorActor.ts +126 -0
- package/src/actor/index.ts +2 -0
- package/src/archivists/ChainFinalized/archivist.ts +21 -0
- package/src/archivists/ChainFinalized/index.ts +1 -0
- package/src/archivists/ChainFinalized/local.ts +18 -0
- package/src/archivists/PendingBlocks/archivist.ts +21 -0
- package/src/archivists/PendingBlocks/index.ts +1 -0
- package/src/archivists/PendingBlocks/local.ts +18 -0
- package/src/archivists/PendingTransactions/archivist.ts +21 -0
- package/src/archivists/PendingTransactions/index.ts +1 -0
- package/src/archivists/PendingTransactions/local.ts +18 -0
- package/src/archivists/RejectedTransactions/archivist.ts +21 -0
- package/src/archivists/RejectedTransactions/index.ts +1 -0
- package/src/archivists/RejectedTransactions/local.ts +20 -0
- package/src/archivists/StakeIntentState/archivist.ts +24 -0
- package/src/archivists/StakeIntentState/index.ts +1 -0
- package/src/archivists/StakeIntentState/local.ts +19 -0
- package/src/archivists/index.ts +5 -0
- package/src/archivists/lib/index.ts +1 -0
- package/src/archivists/lib/localPersistentArchivist.ts +63 -0
- package/src/buildTelemetryConfig.ts +15 -0
- package/src/health/index.ts +1 -0
- package/src/health/initHealthEndpoints.ts +71 -0
- package/src/host/implementation/DefaultHost.ts +25 -0
- package/src/host/implementation/DefaultServiceCollection.ts +60 -0
- package/src/host/implementation/DefaultServiceProvider.ts +12 -0
- package/src/host/implementation/index.ts +2 -0
- package/src/host/index.ts +2 -0
- package/src/host/model/Host.ts +21 -0
- package/src/host/model/ServiceCollection.ts +22 -0
- package/src/host/model/ServiceProvider.ts +3 -0
- package/src/host/model/index.ts +3 -0
- package/src/index.ts +7 -2
- package/src/init/index.ts +1 -2
- package/src/init/initChainStakeViewer.ts +1 -1
- package/src/init/initServerNode.ts +26 -12
- package/src/init/initStatusReporter.ts +16 -0
- package/src/manifest/getLocator.ts +2 -33
- package/src/manifest/loadNode.ts +1 -3
- package/src/manifest/public/{WithoutMempool/Pending.json → Chain.json} +18 -18
- package/src/manifest/public/{WithMempool/Pending.json → Pending.json} +2 -2
- package/src/manifest/public/index.ts +20 -2
- package/src/orchestrator/Orchestrator.ts +0 -2
- package/src/status/RuntimeStatusMonitor.ts +117 -0
- package/src/status/ServiceStatus.ts +20 -0
- package/src/status/index.ts +2 -0
- package/dist/neutral/archivist/index.d.ts +0 -3
- package/dist/neutral/archivist/index.d.ts.map +0 -1
- package/dist/neutral/archivist/initArchivistSync.d.ts +0 -6
- package/dist/neutral/archivist/initArchivistSync.d.ts.map +0 -1
- package/dist/neutral/archivist/wrapWithReadCachingArchivist.d.ts +0 -5
- package/dist/neutral/archivist/wrapWithReadCachingArchivist.d.ts.map +0 -1
- package/dist/neutral/bridge.d.ts +0 -3
- package/dist/neutral/bridge.d.ts.map +0 -1
- package/dist/neutral/init/initPendingBlockArchivist.d.ts +0 -4
- package/dist/neutral/init/initPendingBlockArchivist.d.ts.map +0 -1
- package/dist/neutral/init/initPendingTransactionArchivist.d.ts +0 -4
- package/dist/neutral/init/initPendingTransactionArchivist.d.ts.map +0 -1
- package/dist/neutral/manifest/public/WithMempool/index.d.ts +0 -6
- package/dist/neutral/manifest/public/WithMempool/index.d.ts.map +0 -1
- package/dist/neutral/manifest/public/WithoutMempool/index.d.ts +0 -6
- package/dist/neutral/manifest/public/WithoutMempool/index.d.ts.map +0 -1
- package/src/archivist/index.ts +0 -2
- package/src/archivist/initArchivistSync.ts +0 -61
- package/src/archivist/wrapWithReadCachingArchivist.ts +0 -56
- package/src/bridge.ts +0 -25
- package/src/init/initPendingBlockArchivist.ts +0 -31
- package/src/init/initPendingTransactionArchivist.ts +0 -31
- package/src/manifest/public/WithMempool/Chain.json +0 -175
- package/src/manifest/public/WithMempool/index.ts +0 -20
- package/src/manifest/public/WithoutMempool/Chain.json +0 -97
- package/src/manifest/public/WithoutMempool/index.ts +0 -20
package/dist/neutral/index.mjs
CHANGED
|
@@ -123,126 +123,350 @@ Actor = _ts_decorate([
|
|
|
123
123
|
creatable()
|
|
124
124
|
], Actor);
|
|
125
125
|
|
|
126
|
-
// src/
|
|
127
|
-
import {
|
|
128
|
-
import {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
126
|
+
// src/actor/BalanceActor.ts
|
|
127
|
+
import { assertEx } from "@xylabs/sdk-js";
|
|
128
|
+
import { Mutex } from "async-mutex";
|
|
129
|
+
var BalanceActor = class extends Actor {
|
|
130
|
+
static {
|
|
131
|
+
__name(this, "BalanceActor");
|
|
132
|
+
}
|
|
133
|
+
_updateMutex = new Mutex();
|
|
134
|
+
get balanceService() {
|
|
135
|
+
return assertEx(this.params.balance, () => "balanceService not set");
|
|
136
|
+
}
|
|
137
|
+
get blockViewer() {
|
|
138
|
+
return assertEx(this.params.blockViewer, () => "blockViewer not set");
|
|
139
|
+
}
|
|
140
|
+
async startHandler() {
|
|
141
|
+
await super.startHandler();
|
|
142
|
+
this.registerTimer(
|
|
143
|
+
"BalanceTimer",
|
|
144
|
+
async () => {
|
|
145
|
+
await this.updateBalance();
|
|
146
|
+
},
|
|
147
|
+
1e3,
|
|
148
|
+
1e4
|
|
149
|
+
/* 1000 */
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
async updateBalance() {
|
|
153
|
+
if (this._updateMutex.isLocked()) return;
|
|
154
|
+
await this._updateMutex.runExclusive(async () => {
|
|
155
|
+
const head = await this.blockViewer.currentBlockHash();
|
|
156
|
+
await this.balanceService.accountBalances([], head);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// src/actor/ValidatorActor.ts
|
|
162
|
+
import { assertEx as assertEx2, creatable as creatable2 } from "@xylabs/sdk-js";
|
|
163
|
+
import { processPendingBlocks } from "@xyo-network/chain-sdk";
|
|
164
|
+
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
165
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
166
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
167
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
168
|
+
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;
|
|
169
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
170
|
+
}
|
|
171
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
172
|
+
var ValidatorActor = class extends Actor {
|
|
173
|
+
static {
|
|
174
|
+
__name(this, "ValidatorActor");
|
|
175
|
+
}
|
|
176
|
+
_lastValidatedBlock;
|
|
177
|
+
_lastValidatedBlockHash;
|
|
178
|
+
get account() {
|
|
179
|
+
return assertEx2(this.params.account, () => "account not set");
|
|
180
|
+
}
|
|
181
|
+
get balanceService() {
|
|
182
|
+
return assertEx2(this.params.balance, () => "balanceService not set");
|
|
183
|
+
}
|
|
184
|
+
get blockViewer() {
|
|
185
|
+
return assertEx2(this.params.blockViewer, () => "blockViewer not set");
|
|
186
|
+
}
|
|
187
|
+
get chainStakeViewer() {
|
|
188
|
+
return assertEx2(this.params.chainStakeViewer, () => "chainStakeViewer not set");
|
|
189
|
+
}
|
|
190
|
+
get mempoolViewer() {
|
|
191
|
+
return assertEx2(this.params.mempoolViewer, () => "mempoolViewer not set");
|
|
192
|
+
}
|
|
193
|
+
get pendingBlocksArchivist() {
|
|
194
|
+
return assertEx2(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist not set");
|
|
195
|
+
}
|
|
196
|
+
// protected get chainSubmissionsArchivistWrite() {
|
|
197
|
+
// return assertEx(this.params.chainSubmissionsArchivistWrite, () => 'chainSubmissionsArchivistWrite not set')
|
|
198
|
+
// }
|
|
199
|
+
// protected get pendingBundledTransactionsArchivistWrite() {
|
|
200
|
+
// return assertEx(this.params.pendingBundledTransactionsArchivistWrite, () => 'pendingBundledTransactionsArchivistWrite not set')
|
|
201
|
+
// }
|
|
202
|
+
// protected get stakeIntentService() {
|
|
203
|
+
// return assertEx(this.params.stakeIntent, () => 'stakeIntentService not set')
|
|
204
|
+
// }
|
|
205
|
+
// protected get validator() {
|
|
206
|
+
// return assertEx(this.params.validator, () => 'validator not set')
|
|
207
|
+
// }
|
|
208
|
+
async startHandler() {
|
|
209
|
+
await super.startHandler();
|
|
210
|
+
this.registerTimer(
|
|
211
|
+
"ValidatorActor",
|
|
212
|
+
async () => {
|
|
213
|
+
await this.spanAsync("processPendingBlocks", async () => {
|
|
214
|
+
console.log("ValidatorActor: Processing pending blocks...");
|
|
215
|
+
await processPendingBlocks({
|
|
216
|
+
logger: this.logger,
|
|
217
|
+
mempoolViewer: this.mempoolViewer,
|
|
218
|
+
blockViewer: this.blockViewer,
|
|
219
|
+
chainArchivist: this.pendingBlocksArchivist
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
2e3,
|
|
224
|
+
1500
|
|
225
|
+
/* 500 */
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
async slashInvalidBlock(_block) {
|
|
229
|
+
const slashed = await Promise.resolve(true);
|
|
230
|
+
return slashed;
|
|
231
|
+
}
|
|
232
|
+
async validateBlock(block) {
|
|
233
|
+
const valid = await Promise.resolve(true);
|
|
234
|
+
this._lastValidatedBlock = block;
|
|
235
|
+
this._lastValidatedBlockHash = await PayloadBuilder.hash(block);
|
|
236
|
+
return valid;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
ValidatorActor = _ts_decorate2([
|
|
240
|
+
creatable2()
|
|
241
|
+
], ValidatorActor);
|
|
242
|
+
|
|
243
|
+
// src/archivists/ChainFinalized/archivist.ts
|
|
244
|
+
import { startupSpanAsync } from "@xyo-network/chain-utils";
|
|
245
|
+
import { timeBudget } from "@xyo-network/xl1-protocol-sdk";
|
|
246
|
+
import { Mutex as Mutex3 } from "async-mutex";
|
|
247
|
+
|
|
248
|
+
// src/archivists/ChainFinalized/local.ts
|
|
249
|
+
import { Mutex as Mutex2 } from "async-mutex";
|
|
250
|
+
|
|
251
|
+
// src/archivists/lib/localPersistentArchivist.ts
|
|
252
|
+
import { rm } from "fs/promises";
|
|
253
|
+
import Path from "path";
|
|
254
|
+
import { LmdbArchivist, LmdbArchivistConfigSchema } from "@xyo-network/archivist-lmdb";
|
|
255
|
+
import { getStoreDirectory } from "@xyo-network/chain-protocol";
|
|
256
|
+
var DEFAULT_STORAGE_ROOT = Path.join(process.cwd(), ".store");
|
|
257
|
+
var getLocalPersistentArchivist = /* @__PURE__ */ __name((name, dbName, storeName, storageRoot, kind = "lmdb") => {
|
|
258
|
+
switch (kind) {
|
|
259
|
+
case "lmdb": {
|
|
260
|
+
const root = storageRoot ?? DEFAULT_STORAGE_ROOT;
|
|
261
|
+
return LmdbArchivist.create({
|
|
262
|
+
account: "random",
|
|
263
|
+
config: {
|
|
264
|
+
name,
|
|
265
|
+
clearStoreOnStart: false,
|
|
266
|
+
dbName,
|
|
267
|
+
location: getStoreDirectory(dbName, root, "lmdb"),
|
|
268
|
+
schema: LmdbArchivistConfigSchema,
|
|
269
|
+
storeName
|
|
169
270
|
}
|
|
170
|
-
|
|
271
|
+
});
|
|
171
272
|
}
|
|
273
|
+
}
|
|
274
|
+
}, "getLocalPersistentArchivist");
|
|
275
|
+
|
|
276
|
+
// src/archivists/ChainFinalized/local.ts
|
|
277
|
+
var mutex = new Mutex2();
|
|
278
|
+
var singleton;
|
|
279
|
+
var initLocalChainFinalizedArchivist = /* @__PURE__ */ __name(async ({ config }) => {
|
|
280
|
+
return await mutex.runExclusive(async () => {
|
|
281
|
+
if (singleton) return singleton;
|
|
282
|
+
const { root } = config.storage;
|
|
283
|
+
singleton = await getLocalPersistentArchivist("local-finalized-chain", "chain", "finalized", root);
|
|
284
|
+
return singleton;
|
|
172
285
|
});
|
|
173
|
-
|
|
174
|
-
await node.attach(sentinel.address);
|
|
175
|
-
return node;
|
|
176
|
-
}, "initArchivistSync");
|
|
286
|
+
}, "initLocalChainFinalizedArchivist");
|
|
177
287
|
|
|
178
|
-
// src/archivist
|
|
179
|
-
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}, "getDynamicDefaultReadCachingArchivistConfig");
|
|
193
|
-
var getDynamicReadCachingArchivistConfig = /* @__PURE__ */ __name((_archivist) => {
|
|
194
|
-
const dynamicConfig = {};
|
|
195
|
-
return dynamicConfig;
|
|
196
|
-
}, "getDynamicReadCachingArchivistConfig");
|
|
197
|
-
var wrapWithReadCachingArchivist = /* @__PURE__ */ __name(async (archivist, config = DefaultReadCachingArchivistConfig) => {
|
|
198
|
-
const dynamicDefaultReadCachingArchivistConfig = getDynamicDefaultReadCachingArchivistConfig(archivist);
|
|
199
|
-
const dynamicReadCachingArchivistConfig = getDynamicReadCachingArchivistConfig(archivist);
|
|
200
|
-
const materializedConfig = {
|
|
201
|
-
// Use the static defaults
|
|
202
|
-
...DefaultReadCachingArchivistConfig,
|
|
203
|
-
// Use the dynamic defaults
|
|
204
|
-
...dynamicDefaultReadCachingArchivistConfig,
|
|
205
|
-
// Use the supplied config
|
|
206
|
-
...config,
|
|
207
|
-
// Use they dynamic config
|
|
208
|
-
...dynamicReadCachingArchivistConfig
|
|
209
|
-
};
|
|
210
|
-
const cachingArchivist = await MemoryArchivist.create({
|
|
211
|
-
account: "random",
|
|
212
|
-
config: materializedConfig
|
|
288
|
+
// src/archivists/ChainFinalized/archivist.ts
|
|
289
|
+
var mutex2 = new Mutex3();
|
|
290
|
+
var singleton2;
|
|
291
|
+
async function initChainFinalizedArchivist({ config, logger }) {
|
|
292
|
+
return await mutex2.runExclusive(async () => {
|
|
293
|
+
if (singleton2) return singleton2;
|
|
294
|
+
return await timeBudget("initChainFinalizedArchivist", logger, async () => {
|
|
295
|
+
const local = await startupSpanAsync("ChainFinalizedArchivist:initLocal", () => initLocalChainFinalizedArchivist({
|
|
296
|
+
config,
|
|
297
|
+
logger
|
|
298
|
+
}));
|
|
299
|
+
singleton2 = local;
|
|
300
|
+
return singleton2;
|
|
301
|
+
}, 2e3, true);
|
|
213
302
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}, "wrapWithReadCachingArchivist");
|
|
303
|
+
}
|
|
304
|
+
__name(initChainFinalizedArchivist, "initChainFinalizedArchivist");
|
|
217
305
|
|
|
218
|
-
// src/
|
|
219
|
-
import {
|
|
220
|
-
import {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
306
|
+
// src/archivists/PendingBlocks/archivist.ts
|
|
307
|
+
import { startupSpanAsync as startupSpanAsync2 } from "@xyo-network/chain-utils";
|
|
308
|
+
import { timeBudget as timeBudget2 } from "@xyo-network/xl1-protocol-sdk";
|
|
309
|
+
import { Mutex as Mutex5 } from "async-mutex";
|
|
310
|
+
|
|
311
|
+
// src/archivists/PendingBlocks/local.ts
|
|
312
|
+
import { Mutex as Mutex4 } from "async-mutex";
|
|
313
|
+
var mutex3 = new Mutex4();
|
|
314
|
+
var singleton3;
|
|
315
|
+
var initLocalPendingBlocksArchivist = /* @__PURE__ */ __name(async ({ config }) => {
|
|
316
|
+
return await mutex3.runExclusive(async () => {
|
|
317
|
+
if (singleton3) return singleton3;
|
|
318
|
+
const { root } = config.storage;
|
|
319
|
+
singleton3 = await getLocalPersistentArchivist("local-pending-blocks", "chain", "pending_block_bundles", root);
|
|
320
|
+
return singleton3;
|
|
321
|
+
});
|
|
322
|
+
}, "initLocalPendingBlocksArchivist");
|
|
323
|
+
|
|
324
|
+
// src/archivists/PendingBlocks/archivist.ts
|
|
325
|
+
var mutex4 = new Mutex5();
|
|
326
|
+
var singleton4;
|
|
327
|
+
async function initPendingBlocksArchivist({ config, logger }) {
|
|
328
|
+
return await mutex4.runExclusive(async () => {
|
|
329
|
+
if (singleton4) return singleton4;
|
|
330
|
+
return await timeBudget2("initPendingBlocksArchivist", logger, async () => {
|
|
331
|
+
const local = await startupSpanAsync2("PendingBlocksArchivist:initLocal", () => initLocalPendingBlocksArchivist({
|
|
332
|
+
config,
|
|
333
|
+
logger
|
|
334
|
+
}));
|
|
335
|
+
singleton4 = local;
|
|
336
|
+
return singleton4;
|
|
337
|
+
}, 2e3, true);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
__name(initPendingBlocksArchivist, "initPendingBlocksArchivist");
|
|
341
|
+
|
|
342
|
+
// src/archivists/PendingTransactions/archivist.ts
|
|
343
|
+
import { startupSpanAsync as startupSpanAsync3 } from "@xyo-network/chain-utils";
|
|
344
|
+
import { timeBudget as timeBudget3 } from "@xyo-network/xl1-protocol-sdk";
|
|
345
|
+
import { Mutex as Mutex7 } from "async-mutex";
|
|
346
|
+
|
|
347
|
+
// src/archivists/PendingTransactions/local.ts
|
|
348
|
+
import { Mutex as Mutex6 } from "async-mutex";
|
|
349
|
+
var mutex5 = new Mutex6();
|
|
350
|
+
var singleton5;
|
|
351
|
+
var initLocalPendingTransactionsArchivist = /* @__PURE__ */ __name(async ({ config }) => {
|
|
352
|
+
return await mutex5.runExclusive(async () => {
|
|
353
|
+
if (singleton5) return singleton5;
|
|
354
|
+
const { root } = config.storage;
|
|
355
|
+
singleton5 = await getLocalPersistentArchivist("local-pending-transactions", "chain", "pending_transaction_bundles", root);
|
|
356
|
+
return singleton5;
|
|
357
|
+
});
|
|
358
|
+
}, "initLocalPendingTransactionsArchivist");
|
|
359
|
+
|
|
360
|
+
// src/archivists/PendingTransactions/archivist.ts
|
|
361
|
+
var mutex6 = new Mutex7();
|
|
362
|
+
var singleton6;
|
|
363
|
+
async function initPendingTransactionsArchivist({ config, logger }) {
|
|
364
|
+
return await mutex6.runExclusive(async () => {
|
|
365
|
+
if (singleton6) return singleton6;
|
|
366
|
+
return await timeBudget3("initPendingTransactionsArchivist", logger, async () => {
|
|
367
|
+
const local = await startupSpanAsync3("PendingTransactionsArchivist:initLocal", () => initLocalPendingTransactionsArchivist({
|
|
368
|
+
config,
|
|
369
|
+
logger
|
|
370
|
+
}));
|
|
371
|
+
singleton6 = local;
|
|
372
|
+
return singleton6;
|
|
373
|
+
}, 2e3, true);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
__name(initPendingTransactionsArchivist, "initPendingTransactionsArchivist");
|
|
377
|
+
|
|
378
|
+
// src/archivists/RejectedTransactions/archivist.ts
|
|
379
|
+
import { startupSpanAsync as startupSpanAsync4 } from "@xyo-network/chain-utils";
|
|
380
|
+
import { timeBudget as timeBudget4 } from "@xyo-network/xl1-protocol-sdk";
|
|
381
|
+
import { Mutex as Mutex9 } from "async-mutex";
|
|
382
|
+
|
|
383
|
+
// src/archivists/RejectedTransactions/local.ts
|
|
384
|
+
import { MemoryArchivist, MemoryArchivistConfigSchema } from "@xyo-network/archivist-memory";
|
|
385
|
+
import { Mutex as Mutex8 } from "async-mutex";
|
|
386
|
+
var mutex7 = new Mutex8();
|
|
387
|
+
var singleton7;
|
|
388
|
+
var initLocalRejectedTransactionsArchivist = /* @__PURE__ */ __name(async () => {
|
|
389
|
+
return await mutex7.runExclusive(async () => {
|
|
390
|
+
if (singleton7) return singleton7;
|
|
391
|
+
singleton7 = await MemoryArchivist.create({
|
|
228
392
|
account: "random",
|
|
229
393
|
config: {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
discoverRoots: "start"
|
|
234
|
-
},
|
|
235
|
-
schema: HttpBridgeConfigSchema,
|
|
236
|
-
security: {
|
|
237
|
-
allowAnonymous: true
|
|
238
|
-
}
|
|
394
|
+
schema: MemoryArchivistConfigSchema,
|
|
395
|
+
max: 1e3,
|
|
396
|
+
name: "localRejectedTransactions"
|
|
239
397
|
}
|
|
240
398
|
});
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
399
|
+
return singleton7;
|
|
400
|
+
});
|
|
401
|
+
}, "initLocalRejectedTransactionsArchivist");
|
|
402
|
+
|
|
403
|
+
// src/archivists/RejectedTransactions/archivist.ts
|
|
404
|
+
var mutex8 = new Mutex9();
|
|
405
|
+
var singleton8;
|
|
406
|
+
async function initRejectedTransactionsArchivist(params) {
|
|
407
|
+
return await mutex8.runExclusive(async () => {
|
|
408
|
+
if (singleton8) return singleton8;
|
|
409
|
+
return await timeBudget4("initRejectedTransactionsArchivist", params.logger, async () => {
|
|
410
|
+
const local = await startupSpanAsync4("RejectedTransactionsArchivist:initLocal", () => initLocalRejectedTransactionsArchivist(params));
|
|
411
|
+
singleton8 = local;
|
|
412
|
+
return singleton8;
|
|
413
|
+
}, 2e3, true);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
__name(initRejectedTransactionsArchivist, "initRejectedTransactionsArchivist");
|
|
417
|
+
|
|
418
|
+
// src/archivists/StakeIntentState/archivist.ts
|
|
419
|
+
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
420
|
+
import { startupSpanAsync as startupSpanAsync5 } from "@xyo-network/chain-utils";
|
|
421
|
+
import { timeBudget as timeBudget5 } from "@xyo-network/xl1-protocol-sdk";
|
|
422
|
+
import { Mutex as Mutex11 } from "async-mutex";
|
|
423
|
+
|
|
424
|
+
// src/archivists/StakeIntentState/local.ts
|
|
425
|
+
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
426
|
+
import { Mutex as Mutex10 } from "async-mutex";
|
|
427
|
+
var mutex9 = new Mutex10();
|
|
428
|
+
var singleton9;
|
|
429
|
+
var initLocalStakeIntentStateArchivist = /* @__PURE__ */ __name(async ({ config }) => {
|
|
430
|
+
return await mutex9.runExclusive(async () => {
|
|
431
|
+
if (singleton9) return singleton9;
|
|
432
|
+
const { root } = config.storage;
|
|
433
|
+
singleton9 = await getLocalPersistentArchivist("local-stake-intent-state", "stakeIntent", "state", root);
|
|
434
|
+
return assertEx3(singleton9, () => new Error("Failed to initialize stake intent state archivist"));
|
|
435
|
+
});
|
|
436
|
+
}, "initLocalStakeIntentStateArchivist");
|
|
437
|
+
|
|
438
|
+
// src/archivists/StakeIntentState/archivist.ts
|
|
439
|
+
var mutex10 = new Mutex11();
|
|
440
|
+
var singleton10;
|
|
441
|
+
var initStakeIntentStateArchivist = /* @__PURE__ */ __name(async (params) => {
|
|
442
|
+
return await mutex10.runExclusive(async () => {
|
|
443
|
+
if (singleton10) return singleton10;
|
|
444
|
+
return await timeBudget5("initStakeIntentStateArchivist", params.logger, async () => {
|
|
445
|
+
const local = await startupSpanAsync5("StakeIntentStateArchivist:initLocal", () => initLocalStakeIntentStateArchivist(params));
|
|
446
|
+
singleton10 = local;
|
|
447
|
+
return assertEx4(singleton10, () => "StakeIntentStateArchivist is undefined");
|
|
448
|
+
}, 2e3, true);
|
|
244
449
|
});
|
|
245
|
-
}, "
|
|
450
|
+
}, "initStakeIntentStateArchivist");
|
|
451
|
+
|
|
452
|
+
// src/buildTelemetryConfig.ts
|
|
453
|
+
function buildTelemetryConfig(config, serviceName, serviceVersion) {
|
|
454
|
+
const { otlpEndpoint } = config.telemetry?.otel ?? {};
|
|
455
|
+
const { path: endpoint = "/metrics", port = 9464 } = config.telemetry?.metrics?.scrape ?? {};
|
|
456
|
+
const telemetryConfig = {
|
|
457
|
+
attributes: {
|
|
458
|
+
serviceName,
|
|
459
|
+
serviceVersion
|
|
460
|
+
},
|
|
461
|
+
otlpEndpoint,
|
|
462
|
+
metricsConfig: {
|
|
463
|
+
endpoint,
|
|
464
|
+
port
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
return telemetryConfig;
|
|
468
|
+
}
|
|
469
|
+
__name(buildTelemetryConfig, "buildTelemetryConfig");
|
|
246
470
|
|
|
247
471
|
// src/createDeclarationIntentBlock.ts
|
|
248
472
|
import { buildNextBlock, createDeclarationIntent } from "@xyo-network/chain-sdk";
|
|
@@ -256,91 +480,20 @@ async function createProducerChainStakeIntentBlock(prevBlock, producerAccount, r
|
|
|
256
480
|
}
|
|
257
481
|
__name(createProducerChainStakeIntentBlock, "createProducerChainStakeIntentBlock");
|
|
258
482
|
|
|
259
|
-
// src/init/initBalanceSummaryMap.ts
|
|
260
|
-
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
261
|
-
import { assertEx } from "@xylabs/sdk-js";
|
|
262
|
-
import { MongoMap } from "@xyo-network/chain-protocol";
|
|
263
|
-
import { hasMongoConfig, MemoryMap } from "@xyo-network/xl1-protocol-sdk";
|
|
264
|
-
async function initBalanceSummaryMap({ config, logger }) {
|
|
265
|
-
const mongoConfig = config.storage?.mongo;
|
|
266
|
-
if (hasMongoConfig(mongoConfig)) {
|
|
267
|
-
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
268
|
-
const payloadSdkConfig = {
|
|
269
|
-
dbConnectionString,
|
|
270
|
-
dbDomain,
|
|
271
|
-
dbName,
|
|
272
|
-
dbPassword,
|
|
273
|
-
dbUserName
|
|
274
|
-
};
|
|
275
|
-
const sdkBalanceSummaryMap = new BaseMongoSdk({
|
|
276
|
-
...payloadSdkConfig,
|
|
277
|
-
collection: "balance_summary_map"
|
|
278
|
-
});
|
|
279
|
-
const result = await MongoMap.create({
|
|
280
|
-
sdk: sdkBalanceSummaryMap,
|
|
281
|
-
getCache: {
|
|
282
|
-
enabled: true,
|
|
283
|
-
maxEntries: 5e3
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
assertEx(await result.start(), () => "Failed to start transfer summary map");
|
|
287
|
-
return result;
|
|
288
|
-
} else {
|
|
289
|
-
logger?.warn("[API] Mongo configuration not found. Using MemoryMap for BalanceSummaryMap.");
|
|
290
|
-
return new MemoryMap();
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
__name(initBalanceSummaryMap, "initBalanceSummaryMap");
|
|
294
|
-
|
|
295
|
-
// src/init/initBridgedModule.ts
|
|
296
|
-
import { assertEx as assertEx2 } from "@xylabs/sdk-js";
|
|
297
|
-
import { asAttachableArchivistInstance } from "@xyo-network/archivist-model";
|
|
298
|
-
import { asAttachableModuleInstance } from "@xyo-network/module-model";
|
|
299
|
-
import { Mutex as Mutex2 } from "async-mutex";
|
|
300
|
-
var initMutex2 = new Mutex2();
|
|
301
|
-
var bridgedModuleDictionary = {};
|
|
302
|
-
var initBridgedModule = /* @__PURE__ */ __name(async ({ bridge, moduleName }) => {
|
|
303
|
-
return await initMutex2.runExclusive(async () => {
|
|
304
|
-
const existing = bridgedModuleDictionary?.[bridge.address]?.[moduleName];
|
|
305
|
-
if (existing) return existing;
|
|
306
|
-
const mod = assertEx2(await bridge.resolve(moduleName), () => `Could not resolve ${moduleName}`);
|
|
307
|
-
const moduleInstance = assertEx2(asAttachableModuleInstance(mod), () => `Could not convert ${moduleName} to attachable module instance`);
|
|
308
|
-
let moduleMap = bridgedModuleDictionary[bridge.address];
|
|
309
|
-
if (moduleMap === void 0) {
|
|
310
|
-
moduleMap = {};
|
|
311
|
-
bridgedModuleDictionary[bridge.address] = moduleMap;
|
|
312
|
-
}
|
|
313
|
-
moduleMap[moduleName] = moduleInstance;
|
|
314
|
-
return moduleInstance;
|
|
315
|
-
});
|
|
316
|
-
}, "initBridgedModule");
|
|
317
|
-
var initBridgedArchivistModule = /* @__PURE__ */ __name(async ({ bridge, moduleName }) => {
|
|
318
|
-
return assertEx2(asAttachableArchivistInstance(await initBridgedModule({
|
|
319
|
-
bridge,
|
|
320
|
-
moduleName
|
|
321
|
-
})), () => `Could not convert ${moduleName} to attachable archivist instance`);
|
|
322
|
-
}, "initBridgedArchivistModule");
|
|
323
|
-
|
|
324
|
-
// src/init/initChainStakeViewer.ts
|
|
325
|
-
import { asAddress, assertEx as assertEx7, toAddress, toEthAddress } from "@xylabs/sdk-js";
|
|
326
|
-
import { EthereumChainStakeEvents, EthereumChainStakeViewer } from "@xyo-network/chain-sdk";
|
|
327
|
-
import { StakedXyoChainV2__factory } from "@xyo-network/typechain";
|
|
328
|
-
import { SimpleChainStakeViewer } from "@xyo-network/xl1-protocol-sdk";
|
|
329
|
-
|
|
330
483
|
// src/evm/initEvmProvider.ts
|
|
331
|
-
import { assertEx as
|
|
484
|
+
import { assertEx as assertEx8 } from "@xylabs/sdk-js";
|
|
332
485
|
|
|
333
486
|
// src/evm/initInfuraProvider.ts
|
|
334
|
-
import { assertEx as
|
|
487
|
+
import { assertEx as assertEx6, isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
335
488
|
import { InfuraProvider } from "ethers/providers";
|
|
336
489
|
|
|
337
490
|
// src/evm/initChainId.ts
|
|
338
|
-
import { assertEx as
|
|
491
|
+
import { assertEx as assertEx5, hexFrom, isDefined, isHex } from "@xylabs/sdk-js";
|
|
339
492
|
var canUseChainId = /* @__PURE__ */ __name((config) => {
|
|
340
493
|
return isDefined(config.evm.chainId);
|
|
341
494
|
}, "canUseChainId");
|
|
342
495
|
var getChainId = /* @__PURE__ */ __name((config) => {
|
|
343
|
-
const chainId =
|
|
496
|
+
const chainId = assertEx5(config.evm.chainId, () => "Missing config.evm.chainId");
|
|
344
497
|
if (isHex(chainId, {
|
|
345
498
|
prefix: true
|
|
346
499
|
})) {
|
|
@@ -365,8 +518,8 @@ var canUseInfuraProvider = /* @__PURE__ */ __name((config) => {
|
|
|
365
518
|
return canUseChainId(config) && isDefined2(config.evm?.infura?.projectId) && isDefined2(config.evm?.infura?.projectSecret);
|
|
366
519
|
}, "canUseInfuraProvider");
|
|
367
520
|
var getInfuraProviderConfig = /* @__PURE__ */ __name((config) => {
|
|
368
|
-
const projectId =
|
|
369
|
-
const projectSecret =
|
|
521
|
+
const projectId = assertEx6(config.evm?.infura?.projectId, () => "Missing config.evm.infura.projectId");
|
|
522
|
+
const projectSecret = assertEx6(config.evm?.infura?.projectSecret, () => "Missing config.evm.infura.projectSecret");
|
|
370
523
|
return [
|
|
371
524
|
getChainId(config),
|
|
372
525
|
projectId,
|
|
@@ -375,7 +528,7 @@ var getInfuraProviderConfig = /* @__PURE__ */ __name((config) => {
|
|
|
375
528
|
}, "getInfuraProviderConfig");
|
|
376
529
|
|
|
377
530
|
// src/evm/initJsonRpcProvider.ts
|
|
378
|
-
import { assertEx as
|
|
531
|
+
import { assertEx as assertEx7, isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
379
532
|
import { JsonRpcProvider } from "ethers/providers";
|
|
380
533
|
var initJsonRpcProvider = /* @__PURE__ */ __name((config) => {
|
|
381
534
|
const providerConfig = getJsonRpcProviderConfig(config);
|
|
@@ -385,7 +538,7 @@ var canUseJsonRpcProvider = /* @__PURE__ */ __name((config) => {
|
|
|
385
538
|
return canUseChainId(config) && isDefined3(config.evm.jsonRpc?.url);
|
|
386
539
|
}, "canUseJsonRpcProvider");
|
|
387
540
|
var getJsonRpcProviderConfig = /* @__PURE__ */ __name((config) => {
|
|
388
|
-
const jsonRpcUrl =
|
|
541
|
+
const jsonRpcUrl = assertEx7(config.evm.jsonRpc?.url, () => "Missing config.evm.jsonRpc.url");
|
|
389
542
|
return [
|
|
390
543
|
jsonRpcUrl,
|
|
391
544
|
getChainId(config)
|
|
@@ -401,31 +554,195 @@ var initEvmProvider = /* @__PURE__ */ __name(async ({ config }) => {
|
|
|
401
554
|
} else if (canUseJsonRpcProvider(config)) {
|
|
402
555
|
provider = initJsonRpcProvider(config);
|
|
403
556
|
}
|
|
404
|
-
return
|
|
557
|
+
return assertEx8(await provider, () => "No provider available");
|
|
405
558
|
}, "initEvmProvider");
|
|
406
559
|
var canUseEvmProvider = /* @__PURE__ */ __name(({ config }) => {
|
|
407
560
|
return canUseInfuraProvider(config) || canUseJsonRpcProvider(config);
|
|
408
561
|
}, "canUseEvmProvider");
|
|
409
562
|
|
|
563
|
+
// src/health/initHealthEndpoints.ts
|
|
564
|
+
import http from "http";
|
|
565
|
+
import { isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
566
|
+
var sendStatus = /* @__PURE__ */ __name((res, status, errorCode) => {
|
|
567
|
+
const statusCode = status === "started" ? 200 : errorCode;
|
|
568
|
+
res.writeHead(statusCode, {
|
|
569
|
+
"Content-Type": "application/json"
|
|
570
|
+
});
|
|
571
|
+
res.end(JSON.stringify({
|
|
572
|
+
status
|
|
573
|
+
}));
|
|
574
|
+
}, "sendStatus");
|
|
575
|
+
var notFound = /* @__PURE__ */ __name((res) => {
|
|
576
|
+
res.writeHead(404, {
|
|
577
|
+
"Content-Type": "application/json"
|
|
578
|
+
});
|
|
579
|
+
res.end(JSON.stringify({
|
|
580
|
+
status: "not found"
|
|
581
|
+
}));
|
|
582
|
+
}, "notFound");
|
|
583
|
+
var createHealthServer = /* @__PURE__ */ __name((port, statusMonitor, logger) => {
|
|
584
|
+
const server = http.createServer((req, res) => {
|
|
585
|
+
const url = req.url ?? "";
|
|
586
|
+
const status = statusMonitor.getGlobalStatus();
|
|
587
|
+
switch (url) {
|
|
588
|
+
case "/healthz": {
|
|
589
|
+
sendStatus(res, status, 500);
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
case "/livez": {
|
|
593
|
+
sendStatus(res, status, 503);
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
case "/readyz": {
|
|
597
|
+
sendStatus(res, status, 503);
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
default: {
|
|
601
|
+
notFound(res);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
server.listen(port, () => {
|
|
606
|
+
logger.log(`Health server running on http://localhost:${port}`);
|
|
607
|
+
logger.log(" - /healthz");
|
|
608
|
+
logger.log(" - /livez");
|
|
609
|
+
logger.log(" - /readyz");
|
|
610
|
+
});
|
|
611
|
+
return server;
|
|
612
|
+
}, "createHealthServer");
|
|
613
|
+
var initHealthEndpoints = /* @__PURE__ */ __name((params) => {
|
|
614
|
+
const { config, logger, statusReporter } = params;
|
|
615
|
+
const { healthCheckPort } = config.producer;
|
|
616
|
+
return isDefined4(healthCheckPort) ? createHealthServer(healthCheckPort, statusReporter, logger) : void 0;
|
|
617
|
+
}, "initHealthEndpoints");
|
|
618
|
+
|
|
619
|
+
// src/host/implementation/DefaultHost.ts
|
|
620
|
+
var GenericHost = class {
|
|
621
|
+
static {
|
|
622
|
+
__name(this, "GenericHost");
|
|
623
|
+
}
|
|
624
|
+
services;
|
|
625
|
+
constructor(services) {
|
|
626
|
+
this.services = services;
|
|
627
|
+
}
|
|
628
|
+
async start() {
|
|
629
|
+
await Promise.resolve();
|
|
630
|
+
console.log("Host is starting...");
|
|
631
|
+
}
|
|
632
|
+
async stop() {
|
|
633
|
+
await Promise.resolve();
|
|
634
|
+
console.log("Host is stopping...");
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
// src/host/implementation/DefaultServiceProvider.ts
|
|
639
|
+
var DefaultServiceProvider = class {
|
|
640
|
+
static {
|
|
641
|
+
__name(this, "DefaultServiceProvider");
|
|
642
|
+
}
|
|
643
|
+
_services;
|
|
644
|
+
constructor(services) {
|
|
645
|
+
this._services = services;
|
|
646
|
+
}
|
|
647
|
+
getService(serviceIdentifier) {
|
|
648
|
+
return this._services[serviceIdentifier];
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
// src/host/model/ServiceCollection.ts
|
|
653
|
+
var ServiceLifetime = {
|
|
654
|
+
Singleton: "Singleton",
|
|
655
|
+
Transient: "Transient"
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// src/init/initBalanceSummaryMap.ts
|
|
659
|
+
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
660
|
+
import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
661
|
+
import { MongoMap } from "@xyo-network/chain-protocol";
|
|
662
|
+
import { hasMongoConfig, MemoryMap } from "@xyo-network/xl1-protocol-sdk";
|
|
663
|
+
async function initBalanceSummaryMap({ config, logger }) {
|
|
664
|
+
const mongoConfig = config.storage?.mongo;
|
|
665
|
+
if (hasMongoConfig(mongoConfig)) {
|
|
666
|
+
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
667
|
+
const payloadSdkConfig = {
|
|
668
|
+
dbConnectionString,
|
|
669
|
+
dbDomain,
|
|
670
|
+
dbName,
|
|
671
|
+
dbPassword,
|
|
672
|
+
dbUserName
|
|
673
|
+
};
|
|
674
|
+
const sdkBalanceSummaryMap = new BaseMongoSdk({
|
|
675
|
+
...payloadSdkConfig,
|
|
676
|
+
collection: "balance_summary_map"
|
|
677
|
+
});
|
|
678
|
+
const result = await MongoMap.create({
|
|
679
|
+
sdk: sdkBalanceSummaryMap,
|
|
680
|
+
getCache: {
|
|
681
|
+
enabled: true,
|
|
682
|
+
maxEntries: 5e3
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
assertEx9(await result.start(), () => "Failed to start transfer summary map");
|
|
686
|
+
return result;
|
|
687
|
+
} else {
|
|
688
|
+
logger?.warn("[API] Mongo configuration not found. Using MemoryMap for BalanceSummaryMap.");
|
|
689
|
+
return new MemoryMap();
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
__name(initBalanceSummaryMap, "initBalanceSummaryMap");
|
|
693
|
+
|
|
694
|
+
// src/init/initBridgedModule.ts
|
|
695
|
+
import { assertEx as assertEx10 } from "@xylabs/sdk-js";
|
|
696
|
+
import { asAttachableArchivistInstance } from "@xyo-network/archivist-model";
|
|
697
|
+
import { asAttachableModuleInstance } from "@xyo-network/module-model";
|
|
698
|
+
import { Mutex as Mutex12 } from "async-mutex";
|
|
699
|
+
var initMutex = new Mutex12();
|
|
700
|
+
var bridgedModuleDictionary = {};
|
|
701
|
+
var initBridgedModule = /* @__PURE__ */ __name(async ({ bridge, moduleName }) => {
|
|
702
|
+
return await initMutex.runExclusive(async () => {
|
|
703
|
+
const existing = bridgedModuleDictionary?.[bridge.address]?.[moduleName];
|
|
704
|
+
if (existing) return existing;
|
|
705
|
+
const mod = assertEx10(await bridge.resolve(moduleName), () => `Could not resolve ${moduleName}`);
|
|
706
|
+
const moduleInstance = assertEx10(asAttachableModuleInstance(mod), () => `Could not convert ${moduleName} to attachable module instance`);
|
|
707
|
+
let moduleMap = bridgedModuleDictionary[bridge.address];
|
|
708
|
+
if (moduleMap === void 0) {
|
|
709
|
+
moduleMap = {};
|
|
710
|
+
bridgedModuleDictionary[bridge.address] = moduleMap;
|
|
711
|
+
}
|
|
712
|
+
moduleMap[moduleName] = moduleInstance;
|
|
713
|
+
return moduleInstance;
|
|
714
|
+
});
|
|
715
|
+
}, "initBridgedModule");
|
|
716
|
+
var initBridgedArchivistModule = /* @__PURE__ */ __name(async ({ bridge, moduleName }) => {
|
|
717
|
+
return assertEx10(asAttachableArchivistInstance(await initBridgedModule({
|
|
718
|
+
bridge,
|
|
719
|
+
moduleName
|
|
720
|
+
})), () => `Could not convert ${moduleName} to attachable archivist instance`);
|
|
721
|
+
}, "initBridgedArchivistModule");
|
|
722
|
+
|
|
410
723
|
// src/init/initChainStakeViewer.ts
|
|
724
|
+
import { asAddress, assertEx as assertEx11, toAddress, toEthAddress } from "@xylabs/sdk-js";
|
|
725
|
+
import { EthereumChainStakeEvents, EthereumChainStakeViewer } from "@xyo-network/chain-sdk";
|
|
726
|
+
import { StakedXyoChainV2__factory } from "@xyo-network/typechain";
|
|
727
|
+
import { SimpleChainStakeViewer } from "@xyo-network/xl1-protocol-sdk";
|
|
411
728
|
async function initEvmChainStakeViewer(config, logger) {
|
|
412
729
|
const provider2 = await initEvmProvider({
|
|
413
730
|
config,
|
|
414
731
|
logger
|
|
415
732
|
});
|
|
416
|
-
const contractAddress =
|
|
733
|
+
const contractAddress = assertEx11(config.chain.id, () => "Missing config.evm.chainId");
|
|
417
734
|
const contract = StakedXyoChainV2__factory.connect(toEthAddress(contractAddress), provider2);
|
|
418
735
|
const stakeEventsViewer = await EthereumChainStakeEvents.create({
|
|
419
736
|
contract,
|
|
420
737
|
logger
|
|
421
738
|
});
|
|
422
|
-
|
|
739
|
+
assertEx11(await stakeEventsViewer.start(), () => "Failed to start EthereumChainStakeEvents reader");
|
|
423
740
|
const stakeChainViewer = await EthereumChainStakeViewer.create({
|
|
424
741
|
contract,
|
|
425
742
|
stakeEventsViewer,
|
|
426
743
|
logger
|
|
427
744
|
});
|
|
428
|
-
|
|
745
|
+
assertEx11(await stakeChainViewer.start(), () => "Failed to start EthereumChainStake viewer");
|
|
429
746
|
return stakeChainViewer;
|
|
430
747
|
}
|
|
431
748
|
__name(initEvmChainStakeViewer, "initEvmChainStakeViewer");
|
|
@@ -435,11 +752,11 @@ async function initSimpleStakeViewer(config, logger) {
|
|
|
435
752
|
logger,
|
|
436
753
|
positions: []
|
|
437
754
|
});
|
|
438
|
-
|
|
755
|
+
assertEx11(await stakeChainViewer.start(), () => "Failed to start SimpleChainStake viewer");
|
|
439
756
|
return stakeChainViewer;
|
|
440
757
|
}
|
|
441
758
|
__name(initSimpleStakeViewer, "initSimpleStakeViewer");
|
|
442
|
-
async function initStakeViewer(config, logger) {
|
|
759
|
+
async function initStakeViewer({ config, logger }) {
|
|
443
760
|
if (canUseEvmProvider({
|
|
444
761
|
config
|
|
445
762
|
})) {
|
|
@@ -451,64 +768,6 @@ async function initStakeViewer(config, logger) {
|
|
|
451
768
|
}
|
|
452
769
|
__name(initStakeViewer, "initStakeViewer");
|
|
453
770
|
|
|
454
|
-
// src/init/initPendingBlockArchivist.ts
|
|
455
|
-
import { MemoryArchivist as MemoryArchivist2 } from "@xyo-network/archivist-memory";
|
|
456
|
-
import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
|
|
457
|
-
import { hasMongoConfig as hasMongoConfig2 } from "@xyo-network/xl1-protocol-sdk";
|
|
458
|
-
async function initPendingBlockArchivist({ config, logger }) {
|
|
459
|
-
const mongoConfig = config.storage?.mongo;
|
|
460
|
-
if (hasMongoConfig2(mongoConfig)) {
|
|
461
|
-
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
462
|
-
const payloadSdkConfig = {
|
|
463
|
-
dbConnectionString,
|
|
464
|
-
dbDomain,
|
|
465
|
-
dbName,
|
|
466
|
-
dbPassword,
|
|
467
|
-
dbUserName
|
|
468
|
-
};
|
|
469
|
-
return await MongoDBArchivistV2.create({
|
|
470
|
-
payloadSdkConfig: {
|
|
471
|
-
...payloadSdkConfig,
|
|
472
|
-
collection: "pending_block_bundles"
|
|
473
|
-
},
|
|
474
|
-
logger
|
|
475
|
-
});
|
|
476
|
-
} else {
|
|
477
|
-
logger?.warn("[API] Mongo configuration not found. Using MemoryArchivist for TransferSummaryMap.");
|
|
478
|
-
return await MemoryArchivist2.create();
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
__name(initPendingBlockArchivist, "initPendingBlockArchivist");
|
|
482
|
-
|
|
483
|
-
// src/init/initPendingTransactionArchivist.ts
|
|
484
|
-
import { MemoryArchivist as MemoryArchivist3 } from "@xyo-network/archivist-memory";
|
|
485
|
-
import { MongoDBArchivistV2 as MongoDBArchivistV22 } from "@xyo-network/archivist-mongodb";
|
|
486
|
-
import { hasMongoConfig as hasMongoConfig3 } from "@xyo-network/xl1-protocol-sdk";
|
|
487
|
-
async function initPendingTransactionArchivist({ config, logger }) {
|
|
488
|
-
const mongoConfig = config.storage?.mongo;
|
|
489
|
-
if (hasMongoConfig3(mongoConfig)) {
|
|
490
|
-
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
491
|
-
const payloadSdkConfig = {
|
|
492
|
-
dbConnectionString,
|
|
493
|
-
dbDomain,
|
|
494
|
-
dbName,
|
|
495
|
-
dbPassword,
|
|
496
|
-
dbUserName
|
|
497
|
-
};
|
|
498
|
-
return await MongoDBArchivistV22.create({
|
|
499
|
-
payloadSdkConfig: {
|
|
500
|
-
...payloadSdkConfig,
|
|
501
|
-
collection: "pending_transaction_bundles"
|
|
502
|
-
},
|
|
503
|
-
logger
|
|
504
|
-
});
|
|
505
|
-
} else {
|
|
506
|
-
logger?.warn("[API] Mongo configuration not found. Using MemoryArchivist for TransferSummaryMap.");
|
|
507
|
-
return await MemoryArchivist3.create();
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
__name(initPendingTransactionArchivist, "initPendingTransactionArchivist");
|
|
511
|
-
|
|
512
771
|
// src/init/initProducerAccount.ts
|
|
513
772
|
import { isUndefined } from "@xylabs/sdk-js";
|
|
514
773
|
import { HDWallet } from "@xyo-network/wallet";
|
|
@@ -534,7 +793,7 @@ ${randomMnemonic}
|
|
|
534
793
|
}, "initProducerAccount");
|
|
535
794
|
|
|
536
795
|
// src/init/initSeedPhrase.ts
|
|
537
|
-
import { assertEx as
|
|
796
|
+
import { assertEx as assertEx12, isString } from "@xylabs/sdk-js";
|
|
538
797
|
import { HDWallet as HDWallet2 } from "@xyo-network/wallet";
|
|
539
798
|
async function initSeedPhrase({ config, logger, bios }) {
|
|
540
799
|
const storedSeedPhrase = await bios.seedPhraseStore.get("os");
|
|
@@ -554,28 +813,25 @@ async function initSeedPhrase({ config, logger, bios }) {
|
|
|
554
813
|
}
|
|
555
814
|
await bios.seedPhraseStore.set("os", seedPhrase);
|
|
556
815
|
}
|
|
557
|
-
return
|
|
816
|
+
return assertEx12(await bios.seedPhraseStore.get("os"), () => "Unable to acquire mnemonic from bios");
|
|
558
817
|
}
|
|
559
818
|
__name(initSeedPhrase, "initSeedPhrase");
|
|
560
819
|
|
|
561
820
|
// src/init/initServerNode.ts
|
|
562
|
-
import { assertEx as
|
|
821
|
+
import { assertEx as assertEx13 } from "@xylabs/sdk-js";
|
|
563
822
|
import { asArchivistInstance } from "@xyo-network/archivist-model";
|
|
564
823
|
|
|
565
824
|
// src/manifest/getLocator.ts
|
|
566
|
-
import {
|
|
567
|
-
import { MemoryArchivist as
|
|
568
|
-
import { MongoDBArchivistV2
|
|
825
|
+
import { isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
826
|
+
import { MemoryArchivist as MemoryArchivist2 } from "@xyo-network/archivist-memory";
|
|
827
|
+
import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
|
|
569
828
|
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
570
|
-
import { AddressBalanceDivinerV2, AddressTransferDiviner, ArchivistSyncDiviner as ArchivistSyncDiviner2, HeadValidationDiviner } from "@xyo-network/chain-modules";
|
|
571
829
|
import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
572
830
|
import { AbstractModule, LoggerModuleStatusReporter } from "@xyo-network/module-abstract";
|
|
573
831
|
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
574
|
-
import { MemorySentinel
|
|
575
|
-
import {
|
|
576
|
-
|
|
577
|
-
import { Semaphore as Semaphore2 } from "async-mutex";
|
|
578
|
-
var getLocator = /* @__PURE__ */ __name(async ({ config, logger, balancesSummaryMap, transfersSummaryMap }) => {
|
|
832
|
+
import { MemorySentinel } from "@xyo-network/sentinel-memory";
|
|
833
|
+
import { hasMongoConfig as hasMongoConfig2 } from "@xyo-network/xl1-protocol-sdk";
|
|
834
|
+
var getLocator = /* @__PURE__ */ __name(async ({ config, logger }) => {
|
|
579
835
|
const { otlpEndpoint } = config.telemetry?.otel ?? {};
|
|
580
836
|
const { path: endpoint = "/metrics", port = 9465 } = config.telemetry?.metrics?.scrape ?? {};
|
|
581
837
|
const { traceProvider, meterProvider } = await initTelemetry({
|
|
@@ -589,11 +845,11 @@ var getLocator = /* @__PURE__ */ __name(async ({ config, logger, balancesSummary
|
|
|
589
845
|
port
|
|
590
846
|
}
|
|
591
847
|
});
|
|
592
|
-
if (
|
|
848
|
+
if (isDefined5(logger)) AbstractModule.defaultLogger = logger;
|
|
593
849
|
const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : void 0;
|
|
594
850
|
const locator = new ModuleFactoryLocator();
|
|
595
851
|
const mongoConfig = config.storage?.mongo;
|
|
596
|
-
if (
|
|
852
|
+
if (hasMongoConfig2(mongoConfig)) {
|
|
597
853
|
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
598
854
|
const payloadSdkConfig = {
|
|
599
855
|
dbConnectionString,
|
|
@@ -608,36 +864,14 @@ var getLocator = /* @__PURE__ */ __name(async ({ config, logger, balancesSummary
|
|
|
608
864
|
statusReporter,
|
|
609
865
|
traceProvider
|
|
610
866
|
};
|
|
611
|
-
locator.register(
|
|
867
|
+
locator.register(MongoDBArchivistV2.factory(params), void 0, true);
|
|
612
868
|
}
|
|
613
|
-
locator.register(
|
|
614
|
-
traceProvider,
|
|
615
|
-
meterProvider,
|
|
616
|
-
statusReporter,
|
|
617
|
-
summaryMap: balancesSummaryMap,
|
|
618
|
-
stepSemaphores: StepSizes.map(() => new Semaphore2(20))
|
|
619
|
-
}));
|
|
620
|
-
locator.register(AddressTransferDiviner.factory({
|
|
621
|
-
traceProvider,
|
|
622
|
-
meterProvider,
|
|
623
|
-
statusReporter,
|
|
624
|
-
summaryMap: transfersSummaryMap,
|
|
625
|
-
stepSemaphores: StepSizes.map(() => new Semaphore2(20))
|
|
626
|
-
}));
|
|
627
|
-
const chainId = isDefined4(config.chain.id) ? assertEx9(asAddress2(config.chain.id), () => "chain.id must be an Address") : ZERO_ADDRESS;
|
|
628
|
-
locator.register(HeadValidationDiviner.factory({
|
|
629
|
-
traceProvider,
|
|
630
|
-
meterProvider,
|
|
631
|
-
statusReporter,
|
|
632
|
-
chainId,
|
|
633
|
-
allowedProducers: config.producer.allowlist
|
|
634
|
-
}));
|
|
635
|
-
locator.register(MemoryArchivist4.factory({
|
|
869
|
+
locator.register(MemoryArchivist2.factory({
|
|
636
870
|
traceProvider,
|
|
637
871
|
meterProvider,
|
|
638
872
|
statusReporter
|
|
639
873
|
}));
|
|
640
|
-
locator.register(
|
|
874
|
+
locator.register(MemorySentinel.factory({
|
|
641
875
|
traceProvider,
|
|
642
876
|
meterProvider,
|
|
643
877
|
statusReporter
|
|
@@ -647,11 +881,6 @@ var getLocator = /* @__PURE__ */ __name(async ({ config, logger, balancesSummary
|
|
|
647
881
|
meterProvider,
|
|
648
882
|
statusReporter
|
|
649
883
|
}));
|
|
650
|
-
locator.register(ArchivistSyncDiviner2.factory({
|
|
651
|
-
traceProvider,
|
|
652
|
-
meterProvider,
|
|
653
|
-
statusReporter
|
|
654
|
-
}));
|
|
655
884
|
return locator;
|
|
656
885
|
}, "getLocator");
|
|
657
886
|
|
|
@@ -683,7 +912,7 @@ var NodeManifest = node_default;
|
|
|
683
912
|
// src/manifest/private/index.ts
|
|
684
913
|
var PrivateChildManifests = [];
|
|
685
914
|
|
|
686
|
-
// src/manifest/public/
|
|
915
|
+
// src/manifest/public/Chain.json
|
|
687
916
|
var Chain_default = {
|
|
688
917
|
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
689
918
|
nodes: [
|
|
@@ -708,108 +937,12 @@ var Chain_default = {
|
|
|
708
937
|
},
|
|
709
938
|
schema: "network.xyo.archivist.config"
|
|
710
939
|
}
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
config: {
|
|
714
|
-
accountPath: "1/1'/2'",
|
|
715
|
-
schema: "network.xyo.diviner.chain.head.validation.config",
|
|
716
|
-
eventSubscriptions: [
|
|
717
|
-
{
|
|
718
|
-
sourceEvent: "inserted",
|
|
719
|
-
sourceModule: "Submissions",
|
|
720
|
-
targetModuleFunction: "divine"
|
|
721
|
-
}
|
|
722
|
-
],
|
|
723
|
-
inArchivist: "Submissions",
|
|
724
|
-
outArchivist: "Validated",
|
|
725
|
-
name: "HeadValidationDiviner"
|
|
726
|
-
}
|
|
727
|
-
},
|
|
728
|
-
{
|
|
729
|
-
config: {
|
|
730
|
-
accountPath: "1/1'/3'",
|
|
731
|
-
automations: [
|
|
732
|
-
{
|
|
733
|
-
frequency: 1e3,
|
|
734
|
-
frequencyUnits: "millis",
|
|
735
|
-
schema: "network.xyo.automation.interval",
|
|
736
|
-
type: "interval"
|
|
737
|
-
}
|
|
738
|
-
],
|
|
739
|
-
name: "ChainValidationSentinel",
|
|
740
|
-
schema: "network.xyo.sentinel.config",
|
|
741
|
-
synchronous: true,
|
|
742
|
-
tasks: [
|
|
743
|
-
{
|
|
744
|
-
mod: "HeadValidationDiviner",
|
|
745
|
-
endPoint: "divine"
|
|
746
|
-
}
|
|
747
|
-
]
|
|
748
|
-
}
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
config: {
|
|
752
|
-
accountPath: "1/1'/4'",
|
|
753
|
-
automations: [
|
|
754
|
-
{
|
|
755
|
-
frequency: 1e4,
|
|
756
|
-
frequencyUnits: "millis",
|
|
757
|
-
schema: "network.xyo.automation.interval",
|
|
758
|
-
type: "interval"
|
|
759
|
-
}
|
|
760
|
-
],
|
|
761
|
-
name: "AddressBalancePollingSentinel",
|
|
762
|
-
schema: "network.xyo.sentinel.config",
|
|
763
|
-
synchronous: true,
|
|
764
|
-
tasks: [
|
|
765
|
-
{
|
|
766
|
-
mod: "AddressBalanceDiviner",
|
|
767
|
-
endPoint: "divine"
|
|
768
|
-
}
|
|
769
|
-
]
|
|
770
|
-
}
|
|
771
|
-
},
|
|
772
|
-
{
|
|
773
|
-
config: {
|
|
774
|
-
accountPath: "1/1'/5'",
|
|
775
|
-
automations: [
|
|
776
|
-
{
|
|
777
|
-
frequency: 1e4,
|
|
778
|
-
frequencyUnits: "millis",
|
|
779
|
-
schema: "network.xyo.automation.interval",
|
|
780
|
-
type: "interval"
|
|
781
|
-
}
|
|
782
|
-
],
|
|
783
|
-
name: "AddressTransferPollingSentinel",
|
|
784
|
-
schema: "network.xyo.sentinel.config",
|
|
785
|
-
synchronous: true,
|
|
786
|
-
tasks: [
|
|
787
|
-
{
|
|
788
|
-
mod: "AddressTransferDiviner",
|
|
789
|
-
endPoint: "divine"
|
|
790
|
-
}
|
|
791
|
-
]
|
|
792
|
-
}
|
|
793
940
|
}
|
|
794
941
|
],
|
|
795
942
|
public: [
|
|
796
943
|
{
|
|
797
944
|
config: {
|
|
798
945
|
accountPath: "1/1/1",
|
|
799
|
-
name: "Submissions",
|
|
800
|
-
getCache: {
|
|
801
|
-
enabled: true,
|
|
802
|
-
maxEntries: 5e3
|
|
803
|
-
},
|
|
804
|
-
payloadSdkConfig: {
|
|
805
|
-
collection: "chain_submissions"
|
|
806
|
-
},
|
|
807
|
-
schema: "network.xyo.archivist.config"
|
|
808
|
-
}
|
|
809
|
-
},
|
|
810
|
-
{
|
|
811
|
-
config: {
|
|
812
|
-
accountPath: "1/1/2",
|
|
813
946
|
name: "Finalized",
|
|
814
947
|
allowedQueries: [
|
|
815
948
|
"network.xyo.query.archivist.get",
|
|
@@ -822,36 +955,6 @@ var Chain_default = {
|
|
|
822
955
|
originArchivist: "Validated",
|
|
823
956
|
schema: "network.xyo.archivist.view.config"
|
|
824
957
|
}
|
|
825
|
-
},
|
|
826
|
-
{
|
|
827
|
-
config: {
|
|
828
|
-
accountPath: "1/1/3'",
|
|
829
|
-
name: "AddressBalanceDiviner",
|
|
830
|
-
schema: "network.xyo.diviner.chain.address.balance.config",
|
|
831
|
-
map: {
|
|
832
|
-
lmdb: {
|
|
833
|
-
dbName: "summaries",
|
|
834
|
-
storeName: "address_balance",
|
|
835
|
-
location: ".store"
|
|
836
|
-
}
|
|
837
|
-
},
|
|
838
|
-
archivist: "Validated"
|
|
839
|
-
}
|
|
840
|
-
},
|
|
841
|
-
{
|
|
842
|
-
config: {
|
|
843
|
-
accountPath: "1/1/4'",
|
|
844
|
-
name: "AddressTransferDiviner",
|
|
845
|
-
schema: "network.xyo.diviner.chain.address.transfer.config",
|
|
846
|
-
map: {
|
|
847
|
-
lmdb: {
|
|
848
|
-
dbName: "summaries",
|
|
849
|
-
storeName: "address_transfer",
|
|
850
|
-
location: ".store"
|
|
851
|
-
}
|
|
852
|
-
},
|
|
853
|
-
archivist: "Validated"
|
|
854
|
-
}
|
|
855
958
|
}
|
|
856
959
|
]
|
|
857
960
|
}
|
|
@@ -860,7 +963,7 @@ var Chain_default = {
|
|
|
860
963
|
schema: "network.xyo.manifest"
|
|
861
964
|
};
|
|
862
965
|
|
|
863
|
-
// src/manifest/public/
|
|
966
|
+
// src/manifest/public/Pending.json
|
|
864
967
|
var Pending_default = {
|
|
865
968
|
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
866
969
|
nodes: [
|
|
@@ -876,7 +979,7 @@ var Pending_default = {
|
|
|
876
979
|
{
|
|
877
980
|
config: {
|
|
878
981
|
accountPath: "2/1/1",
|
|
879
|
-
name: "
|
|
982
|
+
name: "Transactions",
|
|
880
983
|
getCache: {
|
|
881
984
|
enabled: true,
|
|
882
985
|
maxEntries: 5e3
|
|
@@ -893,7 +996,7 @@ var Pending_default = {
|
|
|
893
996
|
{
|
|
894
997
|
config: {
|
|
895
998
|
accountPath: "2/1/2",
|
|
896
|
-
name: "
|
|
999
|
+
name: "Blocks",
|
|
897
1000
|
getCache: {
|
|
898
1001
|
enabled: true,
|
|
899
1002
|
maxEntries: 5e3
|
|
@@ -911,176 +1014,16 @@ var Pending_default = {
|
|
|
911
1014
|
schema: "network.xyo.manifest"
|
|
912
1015
|
};
|
|
913
1016
|
|
|
914
|
-
// src/manifest/public/
|
|
1017
|
+
// src/manifest/public/index.ts
|
|
915
1018
|
var ChainNodeManifest = Chain_default;
|
|
916
1019
|
var PendingNodeManifest = Pending_default;
|
|
917
|
-
var
|
|
1020
|
+
var PublicChildManifests = [
|
|
918
1021
|
...ChainNodeManifest.nodes,
|
|
919
1022
|
...PendingNodeManifest.nodes
|
|
920
1023
|
];
|
|
921
1024
|
|
|
922
|
-
// src/manifest/public/WithoutMempool/Chain.json
|
|
923
|
-
var Chain_default2 = {
|
|
924
|
-
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
925
|
-
nodes: [
|
|
926
|
-
{
|
|
927
|
-
config: {
|
|
928
|
-
accountPath: "1",
|
|
929
|
-
name: "Chain",
|
|
930
|
-
schema: "network.xyo.node.config"
|
|
931
|
-
},
|
|
932
|
-
modules: {
|
|
933
|
-
private: [
|
|
934
|
-
{
|
|
935
|
-
config: {
|
|
936
|
-
accountPath: "1/1'/1'",
|
|
937
|
-
name: "Validated",
|
|
938
|
-
allowedQueries: [
|
|
939
|
-
"network.xyo.query.archivist.get",
|
|
940
|
-
"network.xyo.query.archivist.next"
|
|
941
|
-
],
|
|
942
|
-
getCache: {
|
|
943
|
-
enabled: true,
|
|
944
|
-
maxEntries: 5e3
|
|
945
|
-
},
|
|
946
|
-
payloadSdkConfig: {
|
|
947
|
-
collection: "chain_validated"
|
|
948
|
-
},
|
|
949
|
-
schema: "network.xyo.archivist.config"
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
],
|
|
953
|
-
public: [
|
|
954
|
-
{
|
|
955
|
-
config: {
|
|
956
|
-
accountPath: "1/1/1",
|
|
957
|
-
name: "Submissions",
|
|
958
|
-
getCache: {
|
|
959
|
-
enabled: true,
|
|
960
|
-
maxEntries: 5e3
|
|
961
|
-
},
|
|
962
|
-
payloadSdkConfig: {
|
|
963
|
-
collection: "chain_submissions"
|
|
964
|
-
},
|
|
965
|
-
schema: "network.xyo.archivist.config"
|
|
966
|
-
}
|
|
967
|
-
},
|
|
968
|
-
{
|
|
969
|
-
config: {
|
|
970
|
-
accountPath: "1/1/2",
|
|
971
|
-
name: "Finalized",
|
|
972
|
-
allowedQueries: [
|
|
973
|
-
"network.xyo.query.archivist.get",
|
|
974
|
-
"network.xyo.query.archivist.next"
|
|
975
|
-
],
|
|
976
|
-
getCache: {
|
|
977
|
-
enabled: true,
|
|
978
|
-
maxEntries: 5e4
|
|
979
|
-
},
|
|
980
|
-
originArchivist: "Validated",
|
|
981
|
-
schema: "network.xyo.archivist.view.config"
|
|
982
|
-
}
|
|
983
|
-
},
|
|
984
|
-
{
|
|
985
|
-
config: {
|
|
986
|
-
accountPath: "1/1/3'",
|
|
987
|
-
name: "AddressBalanceDiviner",
|
|
988
|
-
schema: "network.xyo.diviner.chain.address.balance.config",
|
|
989
|
-
map: {
|
|
990
|
-
lmdb: {
|
|
991
|
-
dbName: "summaries",
|
|
992
|
-
storeName: "address_balance",
|
|
993
|
-
location: ".store"
|
|
994
|
-
}
|
|
995
|
-
},
|
|
996
|
-
archivist: "Validated"
|
|
997
|
-
}
|
|
998
|
-
},
|
|
999
|
-
{
|
|
1000
|
-
config: {
|
|
1001
|
-
accountPath: "1/1/4'",
|
|
1002
|
-
name: "AddressTransferDiviner",
|
|
1003
|
-
schema: "network.xyo.diviner.chain.address.transfer.config",
|
|
1004
|
-
map: {
|
|
1005
|
-
lmdb: {
|
|
1006
|
-
dbName: "summaries",
|
|
1007
|
-
storeName: "address_transfer",
|
|
1008
|
-
location: ".store"
|
|
1009
|
-
}
|
|
1010
|
-
},
|
|
1011
|
-
archivist: "Validated"
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
]
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
],
|
|
1018
|
-
schema: "network.xyo.manifest"
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
// src/manifest/public/WithoutMempool/Pending.json
|
|
1022
|
-
var Pending_default2 = {
|
|
1023
|
-
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
1024
|
-
nodes: [
|
|
1025
|
-
{
|
|
1026
|
-
config: {
|
|
1027
|
-
accountPath: "2",
|
|
1028
|
-
name: "Pending",
|
|
1029
|
-
schema: "network.xyo.node.config"
|
|
1030
|
-
},
|
|
1031
|
-
modules: {
|
|
1032
|
-
private: [],
|
|
1033
|
-
public: [
|
|
1034
|
-
{
|
|
1035
|
-
config: {
|
|
1036
|
-
accountPath: "2/1/1",
|
|
1037
|
-
name: "PendingTransactions",
|
|
1038
|
-
getCache: {
|
|
1039
|
-
enabled: true,
|
|
1040
|
-
maxEntries: 5e3
|
|
1041
|
-
},
|
|
1042
|
-
labels: {
|
|
1043
|
-
"network.xyo.storage.class": "mongodb"
|
|
1044
|
-
},
|
|
1045
|
-
payloadSdkConfig: {
|
|
1046
|
-
collection: "pending_transaction_bundles"
|
|
1047
|
-
},
|
|
1048
|
-
schema: "network.xyo.archivist.config"
|
|
1049
|
-
}
|
|
1050
|
-
},
|
|
1051
|
-
{
|
|
1052
|
-
config: {
|
|
1053
|
-
accountPath: "2/1/2",
|
|
1054
|
-
name: "PendingBlocks",
|
|
1055
|
-
getCache: {
|
|
1056
|
-
enabled: true,
|
|
1057
|
-
maxEntries: 5e3
|
|
1058
|
-
},
|
|
1059
|
-
payloadSdkConfig: {
|
|
1060
|
-
collection: "pending_block_bundles"
|
|
1061
|
-
},
|
|
1062
|
-
schema: "network.xyo.archivist.config"
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
]
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
],
|
|
1069
|
-
schema: "network.xyo.manifest"
|
|
1070
|
-
};
|
|
1071
|
-
|
|
1072
|
-
// src/manifest/public/WithoutMempool/index.ts
|
|
1073
|
-
var ChainNodeManifest2 = Chain_default2;
|
|
1074
|
-
var PendingNodeManifest2 = Pending_default2;
|
|
1075
|
-
var PublicChildManifestsWithoutMempool = [
|
|
1076
|
-
...ChainNodeManifest2.nodes,
|
|
1077
|
-
...PendingNodeManifest2.nodes
|
|
1078
|
-
];
|
|
1079
|
-
|
|
1080
1025
|
// src/manifest/loadNode.ts
|
|
1081
1026
|
var loadNode = /* @__PURE__ */ __name(async ({ wallet, config, balancesSummaryMap, transfersSummaryMap }) => {
|
|
1082
|
-
const { enabled: mempoolEnabled } = config.mempool;
|
|
1083
|
-
const PublicChildManifests = mempoolEnabled ? PublicChildManifestsWithoutMempool : PublicChildManifestsWithMempool;
|
|
1084
1027
|
const locator = await getLocator({
|
|
1085
1028
|
config,
|
|
1086
1029
|
balancesSummaryMap,
|
|
@@ -1096,20 +1039,30 @@ var loadNode = /* @__PURE__ */ __name(async ({ wallet, config, balancesSummaryMa
|
|
|
1096
1039
|
}, "loadNode");
|
|
1097
1040
|
|
|
1098
1041
|
// src/init/initServerNode.ts
|
|
1099
|
-
async function
|
|
1100
|
-
|
|
1042
|
+
async function writableChainArchivistFromNode(node) {
|
|
1043
|
+
return asArchivistInstance(await node.resolve("Chain:Validated"), {
|
|
1044
|
+
required: true
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
__name(writableChainArchivistFromNode, "writableChainArchivistFromNode");
|
|
1048
|
+
async function readonlyChainArchivistFromNode(node) {
|
|
1049
|
+
return assertEx13(asArchivistInstance(await node.resolve("Chain:Validated"), {
|
|
1050
|
+
required: true
|
|
1051
|
+
}));
|
|
1052
|
+
}
|
|
1053
|
+
__name(readonlyChainArchivistFromNode, "readonlyChainArchivistFromNode");
|
|
1054
|
+
async function pendingTransactionsArchivistFromNode(node) {
|
|
1055
|
+
return asArchivistInstance(await node.resolve("XYOChain:Pending:Transactions"), {
|
|
1101
1056
|
required: true
|
|
1102
|
-
})
|
|
1103
|
-
return chainArchivist;
|
|
1057
|
+
});
|
|
1104
1058
|
}
|
|
1105
|
-
__name(
|
|
1106
|
-
async function
|
|
1107
|
-
|
|
1059
|
+
__name(pendingTransactionsArchivistFromNode, "pendingTransactionsArchivistFromNode");
|
|
1060
|
+
async function pendingBlocksArchivistFromNode(node) {
|
|
1061
|
+
return asArchivistInstance(await node.resolve("XYOChain:Pending:Blocks"), {
|
|
1108
1062
|
required: true
|
|
1109
|
-
})
|
|
1110
|
-
return pendingArchivist;
|
|
1063
|
+
});
|
|
1111
1064
|
}
|
|
1112
|
-
__name(
|
|
1065
|
+
__name(pendingBlocksArchivistFromNode, "pendingBlocksArchivistFromNode");
|
|
1113
1066
|
async function initServerNode({ wallet, logger, config, node: providedNode, transfersSummaryMap, balancesSummaryMap }) {
|
|
1114
1067
|
const node = providedNode ?? await loadNode({
|
|
1115
1068
|
wallet,
|
|
@@ -1118,24 +1071,28 @@ async function initServerNode({ wallet, logger, config, node: providedNode, tran
|
|
|
1118
1071
|
transfersSummaryMap,
|
|
1119
1072
|
balancesSummaryMap
|
|
1120
1073
|
});
|
|
1121
|
-
const
|
|
1122
|
-
const
|
|
1074
|
+
const writableChainArchivist = await writableChainArchivistFromNode(node);
|
|
1075
|
+
const readonlyChainArchivist = await readonlyChainArchivistFromNode(node);
|
|
1076
|
+
const pendingTransactionsArchivist = await pendingTransactionsArchivistFromNode(node);
|
|
1077
|
+
const pendingBlocksArchivist = await pendingBlocksArchivistFromNode(node);
|
|
1123
1078
|
return {
|
|
1124
1079
|
node,
|
|
1125
|
-
|
|
1126
|
-
|
|
1080
|
+
writableChainArchivist,
|
|
1081
|
+
readonlyChainArchivist,
|
|
1082
|
+
pendingTransactionsArchivist,
|
|
1083
|
+
pendingBlocksArchivist
|
|
1127
1084
|
};
|
|
1128
1085
|
}
|
|
1129
1086
|
__name(initServerNode, "initServerNode");
|
|
1130
1087
|
|
|
1131
1088
|
// src/init/initServerWallet.ts
|
|
1132
|
-
import { isDefined as
|
|
1089
|
+
import { isDefined as isDefined6 } from "@xylabs/sdk-js";
|
|
1133
1090
|
import { boot } from "@xyo-network/bios";
|
|
1134
1091
|
import { HDWallet as HDWallet3 } from "@xyo-network/wallet";
|
|
1135
1092
|
async function initServerWallet({ config, logger }) {
|
|
1136
1093
|
const { mnemonic } = config.api;
|
|
1137
1094
|
const bios = await boot();
|
|
1138
|
-
const seedPhrase =
|
|
1095
|
+
const seedPhrase = isDefined6(mnemonic) ? mnemonic : await initSeedPhrase({
|
|
1139
1096
|
bios,
|
|
1140
1097
|
config,
|
|
1141
1098
|
logger
|
|
@@ -1144,14 +1101,122 @@ async function initServerWallet({ config, logger }) {
|
|
|
1144
1101
|
}
|
|
1145
1102
|
__name(initServerWallet, "initServerWallet");
|
|
1146
1103
|
|
|
1104
|
+
// src/status/ServiceStatus.ts
|
|
1105
|
+
var LoggerStatusReporter = class {
|
|
1106
|
+
static {
|
|
1107
|
+
__name(this, "LoggerStatusReporter");
|
|
1108
|
+
}
|
|
1109
|
+
logger;
|
|
1110
|
+
statusMap = {};
|
|
1111
|
+
constructor(logger) {
|
|
1112
|
+
this.logger = logger;
|
|
1113
|
+
}
|
|
1114
|
+
report(name, status, progress) {
|
|
1115
|
+
this.statusMap[name] = status;
|
|
1116
|
+
const starting = Object.entries(this.statusMap).map(([, value]) => value === "starting" ? 1 : 0).reduce((a, b) => a + b, 0);
|
|
1117
|
+
const started = Object.entries(this.statusMap).map(([, value]) => value === "started" ? 1 : 0).reduce((a, b) => a + b, 0);
|
|
1118
|
+
this.logger.info(`${started}/${starting + started} ${name} status: ${status}`, {
|
|
1119
|
+
progress
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// src/status/RuntimeStatusMonitor.ts
|
|
1125
|
+
var statusPriority = {
|
|
1126
|
+
error: 0,
|
|
1127
|
+
stopped: 1,
|
|
1128
|
+
stopping: 2,
|
|
1129
|
+
creating: 3,
|
|
1130
|
+
created: 4,
|
|
1131
|
+
starting: 5,
|
|
1132
|
+
started: 6
|
|
1133
|
+
};
|
|
1134
|
+
var SENTINEL_STATUS = "starting";
|
|
1135
|
+
var reduceToMinimumStatus = /* @__PURE__ */ __name((statuses) => {
|
|
1136
|
+
let minStatus = SENTINEL_STATUS;
|
|
1137
|
+
let minPriority = Infinity;
|
|
1138
|
+
for (const status of statuses) {
|
|
1139
|
+
const priority = statusPriority[status];
|
|
1140
|
+
if (priority < minPriority) {
|
|
1141
|
+
minPriority = priority;
|
|
1142
|
+
minStatus = status;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
return minStatus;
|
|
1146
|
+
}, "reduceToMinimumStatus");
|
|
1147
|
+
var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
1148
|
+
static {
|
|
1149
|
+
__name(this, "RuntimeStatusMonitor");
|
|
1150
|
+
}
|
|
1151
|
+
globalTransitions = [];
|
|
1152
|
+
transitions = [];
|
|
1153
|
+
getGlobalStatus() {
|
|
1154
|
+
if (Object.keys(this.statusMap).length === 0) return SENTINEL_STATUS;
|
|
1155
|
+
return reduceToMinimumStatus(Object.values(this.statusMap));
|
|
1156
|
+
}
|
|
1157
|
+
getStatus(name) {
|
|
1158
|
+
return this.statusMap[name];
|
|
1159
|
+
}
|
|
1160
|
+
onGlobalTransition(match, handler) {
|
|
1161
|
+
this.globalTransitions.push({
|
|
1162
|
+
...match,
|
|
1163
|
+
handler
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Register a callback to be called on a specific transition.
|
|
1168
|
+
*/
|
|
1169
|
+
onTransition(match, handler) {
|
|
1170
|
+
this.transitions.push({
|
|
1171
|
+
...match,
|
|
1172
|
+
handler
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
report(name, status, progress) {
|
|
1176
|
+
const previous = this.statusMap[name];
|
|
1177
|
+
const previousGlobal = this.getGlobalStatus();
|
|
1178
|
+
super.report(name, status, progress);
|
|
1179
|
+
if (previous === status) return;
|
|
1180
|
+
this.runTransitions(this.transitions, previous, status, name);
|
|
1181
|
+
const globalStatus = this.getGlobalStatus();
|
|
1182
|
+
if (previousGlobal === globalStatus) return;
|
|
1183
|
+
this.runTransitions(this.globalTransitions, previousGlobal, globalStatus);
|
|
1184
|
+
}
|
|
1185
|
+
runTransitions(transitions, prev, next, name) {
|
|
1186
|
+
for (const { from, to, name: matchName, handler } of transitions) {
|
|
1187
|
+
if ((matchName === void 0 || matchName === name) && (from === void 0 || from === prev) && (to === void 0 || to === next)) {
|
|
1188
|
+
handler(prev, next);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
// src/init/initStatusReporter.ts
|
|
1195
|
+
function initStatusReporter({ logger }) {
|
|
1196
|
+
const statusReporter = new RuntimeStatusMonitor(logger);
|
|
1197
|
+
statusReporter.onGlobalTransition({
|
|
1198
|
+
to: "started"
|
|
1199
|
+
}, () => {
|
|
1200
|
+
logger.log("All services started.");
|
|
1201
|
+
});
|
|
1202
|
+
statusReporter.onGlobalTransition({
|
|
1203
|
+
to: "error"
|
|
1204
|
+
}, () => {
|
|
1205
|
+
logger.error("Producer encountered an unhandled error!");
|
|
1206
|
+
process.exit(1);
|
|
1207
|
+
});
|
|
1208
|
+
return statusReporter;
|
|
1209
|
+
}
|
|
1210
|
+
__name(initStatusReporter, "initStatusReporter");
|
|
1211
|
+
|
|
1147
1212
|
// src/init/initTransferSummaryMap.ts
|
|
1148
1213
|
import { BaseMongoSdk as BaseMongoSdk2 } from "@xylabs/mongo";
|
|
1149
|
-
import { assertEx as
|
|
1214
|
+
import { assertEx as assertEx14 } from "@xylabs/sdk-js";
|
|
1150
1215
|
import { MongoMap as MongoMap2 } from "@xyo-network/chain-protocol";
|
|
1151
|
-
import { hasMongoConfig as
|
|
1216
|
+
import { hasMongoConfig as hasMongoConfig3, MemoryMap as MemoryMap2 } from "@xyo-network/xl1-protocol-sdk";
|
|
1152
1217
|
async function initTransferSummaryMap({ config, logger }) {
|
|
1153
1218
|
const mongoConfig = config.storage?.mongo;
|
|
1154
|
-
if (
|
|
1219
|
+
if (hasMongoConfig3(mongoConfig)) {
|
|
1155
1220
|
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
1156
1221
|
const payloadSdkConfig = {
|
|
1157
1222
|
dbConnectionString,
|
|
@@ -1171,7 +1236,7 @@ async function initTransferSummaryMap({ config, logger }) {
|
|
|
1171
1236
|
maxEntries: 5e3
|
|
1172
1237
|
}
|
|
1173
1238
|
});
|
|
1174
|
-
|
|
1239
|
+
assertEx14(await result.start(), () => "Failed to start transfer summary map");
|
|
1175
1240
|
return result;
|
|
1176
1241
|
} else {
|
|
1177
1242
|
logger?.warn("[API] Mongo configuration not found. Using MemoryMap for TransferSummaryMap.");
|
|
@@ -1182,41 +1247,41 @@ __name(initTransferSummaryMap, "initTransferSummaryMap");
|
|
|
1182
1247
|
|
|
1183
1248
|
// src/init/iterator.ts
|
|
1184
1249
|
import { BaseElectionService, ChainBlockNumberIterationService, XyoStakeIntentService } from "@xyo-network/chain-services";
|
|
1185
|
-
import { timeBudget } from "@xyo-network/xl1-protocol-sdk";
|
|
1250
|
+
import { timeBudget as timeBudget6 } from "@xyo-network/xl1-protocol-sdk";
|
|
1186
1251
|
var chainIteratorServiceSingleton;
|
|
1187
1252
|
var stakeIntentServiceSingleton;
|
|
1188
1253
|
var electionServiceSingleton;
|
|
1189
1254
|
var initChainIterator = /* @__PURE__ */ __name((params) => {
|
|
1190
1255
|
if (chainIteratorServiceSingleton) return chainIteratorServiceSingleton;
|
|
1191
|
-
return
|
|
1256
|
+
return timeBudget6("initChainIterator", params.logger, () => {
|
|
1192
1257
|
chainIteratorServiceSingleton = ChainBlockNumberIterationService.create(params);
|
|
1193
1258
|
return chainIteratorServiceSingleton;
|
|
1194
1259
|
}, 2e3, true);
|
|
1195
1260
|
}, "initChainIterator");
|
|
1196
1261
|
var initStakeIntentService = /* @__PURE__ */ __name((params) => {
|
|
1197
1262
|
if (stakeIntentServiceSingleton) return stakeIntentServiceSingleton;
|
|
1198
|
-
return
|
|
1263
|
+
return timeBudget6("initStakeIntentService", params.logger, () => {
|
|
1199
1264
|
stakeIntentServiceSingleton = XyoStakeIntentService.create(params);
|
|
1200
1265
|
return stakeIntentServiceSingleton;
|
|
1201
1266
|
}, 2e3, true);
|
|
1202
1267
|
}, "initStakeIntentService");
|
|
1203
1268
|
var initElectionService = /* @__PURE__ */ __name((params) => {
|
|
1204
1269
|
if (electionServiceSingleton) return electionServiceSingleton;
|
|
1205
|
-
return
|
|
1270
|
+
return timeBudget6("initElectionService", params.logger, () => {
|
|
1206
1271
|
electionServiceSingleton = BaseElectionService.create(params);
|
|
1207
1272
|
return electionServiceSingleton;
|
|
1208
1273
|
}, 2e3, true);
|
|
1209
1274
|
}, "initElectionService");
|
|
1210
1275
|
|
|
1211
1276
|
// src/orchestrator/Orchestrator.ts
|
|
1212
|
-
import { AbstractCreatable as AbstractCreatable2, creatable as
|
|
1213
|
-
function
|
|
1277
|
+
import { AbstractCreatable as AbstractCreatable2, creatable as creatable3 } from "@xylabs/sdk-js";
|
|
1278
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
1214
1279
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1215
1280
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1216
1281
|
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;
|
|
1217
1282
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1218
1283
|
}
|
|
1219
|
-
__name(
|
|
1284
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
1220
1285
|
var Orchestrator = class extends AbstractCreatable2 {
|
|
1221
1286
|
static {
|
|
1222
1287
|
__name(this, "Orchestrator");
|
|
@@ -1269,38 +1334,48 @@ var Orchestrator = class extends AbstractCreatable2 {
|
|
|
1269
1334
|
this.logger?.log("[Orchestrator] Stopped...");
|
|
1270
1335
|
}
|
|
1271
1336
|
};
|
|
1272
|
-
Orchestrator =
|
|
1273
|
-
|
|
1337
|
+
Orchestrator = _ts_decorate3([
|
|
1338
|
+
creatable3()
|
|
1274
1339
|
], Orchestrator);
|
|
1275
1340
|
export {
|
|
1276
1341
|
Actor,
|
|
1277
|
-
|
|
1342
|
+
BalanceActor,
|
|
1343
|
+
DefaultServiceProvider,
|
|
1344
|
+
GenericHost,
|
|
1345
|
+
LoggerStatusReporter,
|
|
1278
1346
|
NodeManifest,
|
|
1279
1347
|
Orchestrator,
|
|
1280
1348
|
PrivateChildManifests,
|
|
1281
|
-
|
|
1282
|
-
|
|
1349
|
+
PublicChildManifests,
|
|
1350
|
+
RuntimeStatusMonitor,
|
|
1351
|
+
ServiceLifetime,
|
|
1352
|
+
ValidatorActor,
|
|
1353
|
+
buildTelemetryConfig,
|
|
1354
|
+
canUseEvmProvider,
|
|
1283
1355
|
createProducerChainStakeIntentBlock,
|
|
1284
1356
|
getLocator,
|
|
1285
|
-
initArchivistSync,
|
|
1286
1357
|
initBalanceSummaryMap,
|
|
1287
|
-
initBridge,
|
|
1288
1358
|
initBridgedArchivistModule,
|
|
1289
1359
|
initBridgedModule,
|
|
1360
|
+
initChainFinalizedArchivist,
|
|
1290
1361
|
initChainIterator,
|
|
1291
1362
|
initElectionService,
|
|
1292
1363
|
initEvmChainStakeViewer,
|
|
1293
|
-
|
|
1294
|
-
|
|
1364
|
+
initEvmProvider,
|
|
1365
|
+
initHealthEndpoints,
|
|
1366
|
+
initPendingBlocksArchivist,
|
|
1367
|
+
initPendingTransactionsArchivist,
|
|
1295
1368
|
initProducerAccount,
|
|
1369
|
+
initRejectedTransactionsArchivist,
|
|
1296
1370
|
initSeedPhrase,
|
|
1297
1371
|
initServerNode,
|
|
1298
1372
|
initServerWallet,
|
|
1299
1373
|
initSimpleStakeViewer,
|
|
1300
1374
|
initStakeIntentService,
|
|
1375
|
+
initStakeIntentStateArchivist,
|
|
1301
1376
|
initStakeViewer,
|
|
1377
|
+
initStatusReporter,
|
|
1302
1378
|
initTransferSummaryMap,
|
|
1303
|
-
loadNode
|
|
1304
|
-
wrapWithReadCachingArchivist
|
|
1379
|
+
loadNode
|
|
1305
1380
|
};
|
|
1306
1381
|
//# sourceMappingURL=index.mjs.map
|