@xyo-network/xl1-cli-lib 1.14.3 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.mjs +146 -78
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/orchestration/initServices.d.ts.map +1 -1
- package/dist/node/orchestration/map/BalanceSummary/index.d.ts +1 -0
- package/dist/node/orchestration/map/BalanceSummary/index.d.ts.map +1 -1
- package/dist/node/orchestration/map/BalanceSummary/{local.d.ts → initLocalBalanceSummaryMap.d.ts} +1 -1
- package/dist/node/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.d.ts.map +1 -0
- package/dist/node/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.d.ts +7 -0
- package/dist/node/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.d.ts.map +1 -0
- package/dist/node/orchestration/map/BalanceSummary/initTransferSummaryMap.d.ts +7 -0
- package/dist/node/orchestration/map/BalanceSummary/initTransferSummaryMap.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/evm/initEvmProvider.d.ts +2 -2
- package/dist/node/orchestration/services/implementation/evm/initEvmProvider.d.ts.map +1 -1
- package/dist/node/orchestration/services/implementation/head/createBootstrapHead.d.ts +2 -2
- package/dist/node/orchestration/services/implementation/head/createBootstrapHead.d.ts.map +1 -1
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getFirstBlockForNewChain.d.ts.map +1 -1
- package/dist/node/orchestration/services/implementation/head/head.d.ts.map +1 -1
- package/dist/node/orchestration/services/implementation/index.d.ts +1 -0
- package/dist/node/orchestration/services/implementation/index.d.ts.map +1 -1
- package/dist/node/orchestration/services/implementation/time.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/time.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/transfer.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/transfer.d.ts.map +1 -0
- package/dist/node/runCLI.d.ts.map +1 -1
- package/dist/node/xl1.mjs +145 -78
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +8 -7
- package/src/optionsFromGlobalZodRegistry.ts +1 -1
- package/src/orchestration/initServices.ts +32 -16
- package/src/orchestration/map/BalanceSummary/index.ts +1 -0
- package/src/orchestration/map/BalanceSummary/initBalanceSummaryMap.ts +1 -1
- package/src/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.ts +21 -0
- package/src/orchestration/map/BalanceSummary/initTransferSummaryMap.ts +22 -0
- package/src/orchestration/services/implementation/evm/initEvmProvider.ts +2 -1
- package/src/orchestration/services/implementation/head/createBootstrapHead.ts +27 -5
- package/src/orchestration/services/implementation/head/createForkedHead/config/getBridgeDestinationDetails.ts +3 -3
- package/src/orchestration/services/implementation/head/createForkedHead/getFirstBlockForNewChain.ts +5 -6
- package/src/orchestration/services/implementation/head/head.ts +4 -3
- package/src/orchestration/services/implementation/index.ts +1 -0
- package/src/orchestration/services/implementation/time.ts +23 -0
- package/src/orchestration/services/implementation/transfer.ts +13 -0
- package/src/runCLI.ts +1 -0
- package/dist/node/orchestration/map/BalanceSummary/local.d.ts.map +0 -1
- /package/src/orchestration/map/BalanceSummary/{local.ts → initLocalBalanceSummaryMap.ts} +0 -0
package/dist/node/index.mjs
CHANGED
|
@@ -529,8 +529,8 @@ var initHealthEndpoints = /* @__PURE__ */ __name((params) => {
|
|
|
529
529
|
// src/orchestration/initServices.ts
|
|
530
530
|
import { assertEx as assertEx18 } from "@xylabs/assert";
|
|
531
531
|
import { asAddress as asAddress2 } from "@xylabs/hex";
|
|
532
|
-
import { isDefined as
|
|
533
|
-
import { balanceSummaryRepositoryFromMap,
|
|
532
|
+
import { isDefined as isDefined14 } from "@xylabs/typeof";
|
|
533
|
+
import { balanceSummaryRepositoryFromMap, initTelemetry, startupSpanAsync as startupSpanAsync8, validateHydratedBlockState } from "@xyo-network/chain-sdk";
|
|
534
534
|
|
|
535
535
|
// src/orchestration/archivists/ChainFinalized/archivist.ts
|
|
536
536
|
import { initArchivistSync, startupSpanAsync } from "@xyo-network/chain-sdk";
|
|
@@ -805,7 +805,7 @@ import { isDefined as isDefined5 } from "@xylabs/typeof";
|
|
|
805
805
|
import { startupSpanAsync as startupSpanAsync6 } from "@xyo-network/chain-sdk";
|
|
806
806
|
import { Mutex as Mutex15 } from "async-mutex";
|
|
807
807
|
|
|
808
|
-
// src/orchestration/map/BalanceSummary/
|
|
808
|
+
// src/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.ts
|
|
809
809
|
import { isDefined as isDefined4 } from "@xylabs/typeof";
|
|
810
810
|
import { Mutex as Mutex14 } from "async-mutex";
|
|
811
811
|
|
|
@@ -891,7 +891,7 @@ var getLocalPersistentMap = /* @__PURE__ */ __name(async (dbName, storeName, sto
|
|
|
891
891
|
}
|
|
892
892
|
}, "getLocalPersistentMap");
|
|
893
893
|
|
|
894
|
-
// src/orchestration/map/BalanceSummary/
|
|
894
|
+
// src/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.ts
|
|
895
895
|
var mutex13 = new Mutex14();
|
|
896
896
|
var singleton13;
|
|
897
897
|
var initLocalBalanceSummaryMap = /* @__PURE__ */ __name(async (params) => {
|
|
@@ -916,6 +916,38 @@ async function initBalanceSummaryMap(params) {
|
|
|
916
916
|
}
|
|
917
917
|
__name(initBalanceSummaryMap, "initBalanceSummaryMap");
|
|
918
918
|
|
|
919
|
+
// src/orchestration/map/BalanceSummary/initTransferSummaryMap.ts
|
|
920
|
+
import { isDefined as isDefined7 } from "@xylabs/typeof";
|
|
921
|
+
import { startupSpanAsync as startupSpanAsync7 } from "@xyo-network/chain-sdk";
|
|
922
|
+
import { Mutex as Mutex17 } from "async-mutex";
|
|
923
|
+
|
|
924
|
+
// src/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.ts
|
|
925
|
+
import { isDefined as isDefined6 } from "@xylabs/typeof";
|
|
926
|
+
import { Mutex as Mutex16 } from "async-mutex";
|
|
927
|
+
var mutex15 = new Mutex16();
|
|
928
|
+
var singleton15;
|
|
929
|
+
var initLocalTransferSummaryMap = /* @__PURE__ */ __name(async (params) => {
|
|
930
|
+
return await mutex15.runExclusive(async () => {
|
|
931
|
+
if (isDefined6(singleton15)) return singleton15;
|
|
932
|
+
const { root } = params.config.storage;
|
|
933
|
+
singleton15 = await getLocalPersistentMap("transfer", "summary", root);
|
|
934
|
+
return singleton15;
|
|
935
|
+
});
|
|
936
|
+
}, "initLocalTransferSummaryMap");
|
|
937
|
+
|
|
938
|
+
// src/orchestration/map/BalanceSummary/initTransferSummaryMap.ts
|
|
939
|
+
var mutex16 = new Mutex17();
|
|
940
|
+
var singleton16;
|
|
941
|
+
async function initTransferSummaryMap(params) {
|
|
942
|
+
return await mutex16.runExclusive(async () => {
|
|
943
|
+
if (isDefined7(singleton16)) return singleton16;
|
|
944
|
+
const local = await startupSpanAsync7("TransferSummaryMap:initLocal", () => initLocalTransferSummaryMap(params));
|
|
945
|
+
singleton16 = local;
|
|
946
|
+
return singleton16;
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
__name(initTransferSummaryMap, "initTransferSummaryMap");
|
|
950
|
+
|
|
919
951
|
// src/orchestration/services/implementation/account.ts
|
|
920
952
|
import { isUndefined as isUndefined3 } from "@xylabs/typeof";
|
|
921
953
|
import { HDWallet } from "@xyo-network/wallet";
|
|
@@ -955,7 +987,7 @@ import { MemoryChainService } from "@xyo-network/chain-sdk";
|
|
|
955
987
|
// src/orchestration/services/implementation/chain/evm.ts
|
|
956
988
|
import { assertEx as assertEx15 } from "@xylabs/assert";
|
|
957
989
|
import { asAddress, ZERO_ADDRESS } from "@xylabs/hex";
|
|
958
|
-
import { isDefined as
|
|
990
|
+
import { isDefined as isDefined11 } from "@xylabs/typeof";
|
|
959
991
|
import { EvmChainService } from "@xyo-network/chain-sdk";
|
|
960
992
|
import { Wallet } from "ethers/wallet";
|
|
961
993
|
|
|
@@ -964,15 +996,15 @@ import { assertEx as assertEx14 } from "@xylabs/assert";
|
|
|
964
996
|
|
|
965
997
|
// src/orchestration/services/implementation/evm/initInfuraProvider.ts
|
|
966
998
|
import { assertEx as assertEx12 } from "@xylabs/assert";
|
|
967
|
-
import { isDefined as
|
|
999
|
+
import { isDefined as isDefined9 } from "@xylabs/typeof";
|
|
968
1000
|
import { InfuraProvider } from "ethers/providers";
|
|
969
1001
|
|
|
970
1002
|
// src/orchestration/services/implementation/evm/initChainId.ts
|
|
971
1003
|
import { assertEx as assertEx11 } from "@xylabs/assert";
|
|
972
1004
|
import { hexFrom, isHex } from "@xylabs/hex";
|
|
973
|
-
import { isDefined as
|
|
1005
|
+
import { isDefined as isDefined8 } from "@xylabs/typeof";
|
|
974
1006
|
var canUseChainId = /* @__PURE__ */ __name((config3) => {
|
|
975
|
-
return
|
|
1007
|
+
return isDefined8(config3.evm.chainId);
|
|
976
1008
|
}, "canUseChainId");
|
|
977
1009
|
var getChainId = /* @__PURE__ */ __name((config3) => {
|
|
978
1010
|
const chainId = assertEx11(config3.evm.chainId, () => "Missing config.evm.chainId");
|
|
@@ -997,7 +1029,7 @@ var initInfuraProvider = /* @__PURE__ */ __name((config3) => {
|
|
|
997
1029
|
return instance;
|
|
998
1030
|
}, "initInfuraProvider");
|
|
999
1031
|
var canUseInfuraProvider = /* @__PURE__ */ __name((config3) => {
|
|
1000
|
-
return canUseChainId(config3) &&
|
|
1032
|
+
return canUseChainId(config3) && isDefined9(config3.evm?.infura?.projectId) && isDefined9(config3.evm?.infura?.projectSecret);
|
|
1001
1033
|
}, "canUseInfuraProvider");
|
|
1002
1034
|
var getInfuraProviderConfig = /* @__PURE__ */ __name((config3) => {
|
|
1003
1035
|
const projectId = assertEx12(config3.evm?.infura?.projectId, () => "Missing config.evm.infura.projectId");
|
|
@@ -1011,14 +1043,14 @@ var getInfuraProviderConfig = /* @__PURE__ */ __name((config3) => {
|
|
|
1011
1043
|
|
|
1012
1044
|
// src/orchestration/services/implementation/evm/initJsonRpcProvider.ts
|
|
1013
1045
|
import { assertEx as assertEx13 } from "@xylabs/assert";
|
|
1014
|
-
import { isDefined as
|
|
1046
|
+
import { isDefined as isDefined10 } from "@xylabs/typeof";
|
|
1015
1047
|
import { JsonRpcProvider } from "ethers/providers";
|
|
1016
1048
|
var initJsonRpcProvider = /* @__PURE__ */ __name((config3) => {
|
|
1017
1049
|
const providerConfig = getJsonRpcProviderConfig(config3);
|
|
1018
1050
|
return Promise.resolve(new JsonRpcProvider(...providerConfig));
|
|
1019
1051
|
}, "initJsonRpcProvider");
|
|
1020
1052
|
var canUseJsonRpcProvider = /* @__PURE__ */ __name((config3) => {
|
|
1021
|
-
return canUseChainId(config3) &&
|
|
1053
|
+
return canUseChainId(config3) && isDefined10(config3.evm.jsonRpc?.url);
|
|
1022
1054
|
}, "canUseJsonRpcProvider");
|
|
1023
1055
|
var getJsonRpcProviderConfig = /* @__PURE__ */ __name((config3) => {
|
|
1024
1056
|
const jsonRpcUrl = assertEx13(config3.evm.jsonRpc?.url, () => "Missing config.evm.jsonRpc.url");
|
|
@@ -1047,7 +1079,7 @@ var canUseEvmProvider = /* @__PURE__ */ __name(({ config: config3 }) => {
|
|
|
1047
1079
|
var chainStakeServiceSingleton;
|
|
1048
1080
|
var canUseEvmContractChainService = /* @__PURE__ */ __name((config3) => {
|
|
1049
1081
|
const { id } = config3.chain;
|
|
1050
|
-
return
|
|
1082
|
+
return isDefined11(id) && id !== ZERO_ADDRESS && canUseEvmProvider({
|
|
1051
1083
|
config: config3
|
|
1052
1084
|
});
|
|
1053
1085
|
}, "canUseEvmContractChainService");
|
|
@@ -1092,18 +1124,28 @@ var init = /* @__PURE__ */ __name((params) => {
|
|
|
1092
1124
|
|
|
1093
1125
|
// src/orchestration/services/implementation/head/head.ts
|
|
1094
1126
|
import { assertEx as assertEx16 } from "@xylabs/assert";
|
|
1095
|
-
import { isDefined as
|
|
1127
|
+
import { isDefined as isDefined13 } from "@xylabs/typeof";
|
|
1096
1128
|
import { findMostRecentBlock as findMostRecentBlock2 } from "@xyo-network/chain-sdk";
|
|
1097
1129
|
|
|
1098
1130
|
// src/orchestration/services/implementation/head/createBootstrapHead.ts
|
|
1099
|
-
import {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1131
|
+
import { buildNextBlock, createDeclarationIntent as createDeclarationIntent2, createGenesisBlock } from "@xyo-network/chain-sdk";
|
|
1132
|
+
var createBootstrapHead = /* @__PURE__ */ __name(async (account, chainService) => {
|
|
1133
|
+
const chainId = chainService.chainId;
|
|
1134
|
+
const chain = [];
|
|
1135
|
+
const genesisBlock = await createGenesisBlock(account, chainId, 10000000n, account.address);
|
|
1136
|
+
chain.push(genesisBlock);
|
|
1137
|
+
const producerDeclarationPayload = createDeclarationIntent2(account.address, "producer", genesisBlock[0].block, genesisBlock[0].block + 1e4);
|
|
1138
|
+
const producerDeclarationBlock = await buildNextBlock(genesisBlock[0], [], [
|
|
1139
|
+
producerDeclarationPayload
|
|
1140
|
+
], [
|
|
1141
|
+
account
|
|
1142
|
+
]);
|
|
1143
|
+
chain.push(producerDeclarationBlock);
|
|
1144
|
+
return chain;
|
|
1103
1145
|
}, "createBootstrapHead");
|
|
1104
1146
|
|
|
1105
1147
|
// src/orchestration/services/implementation/head/createForkedHead/getBridgeDestinationObservation.ts
|
|
1106
|
-
import { BridgeDestinationObservationSchema, buildNextBlock } from "@xyo-network/chain-sdk";
|
|
1148
|
+
import { BridgeDestinationObservationSchema, buildNextBlock as buildNextBlock2 } from "@xyo-network/chain-sdk";
|
|
1107
1149
|
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
1108
1150
|
|
|
1109
1151
|
// src/orchestration/services/implementation/head/createForkedHead/config/getBridgeDestinationDetails.ts
|
|
@@ -1121,9 +1163,9 @@ var getForkBlockRewardHex = /* @__PURE__ */ __name(() => {
|
|
|
1121
1163
|
|
|
1122
1164
|
// src/orchestration/services/implementation/head/createForkedHead/config/getBridgeDestinationDetails.ts
|
|
1123
1165
|
var ethChainId = toHex5("0x1");
|
|
1124
|
-
var bridgeableTokenContract = toHex5("
|
|
1125
|
-
var bridgeDestAddress = toHex5("
|
|
1126
|
-
var destConfirmation = toHex5("
|
|
1166
|
+
var bridgeableTokenContract = toHex5("0xf72aE3E0DA743033AbD7A407557D684c1aE66aed");
|
|
1167
|
+
var bridgeDestAddress = toHex5("0x0e65b65B10C791942665030402c35023d88B14dA");
|
|
1168
|
+
var destConfirmation = toHex5("0x950861b10523b52cdbb4a9ee52ed26601db555d2652bfec21c709e5e70d5b7d3");
|
|
1127
1169
|
var getBridgeDestChainId = /* @__PURE__ */ __name(() => ethChainId, "getBridgeDestChainId");
|
|
1128
1170
|
var getBridgeDestToken = /* @__PURE__ */ __name(() => bridgeableTokenContract, "getBridgeDestToken");
|
|
1129
1171
|
var getBridgeDestAddress = /* @__PURE__ */ __name(() => bridgeDestAddress, "getBridgeDestAddress");
|
|
@@ -1162,7 +1204,7 @@ var getBridgeDestinationObservation = /* @__PURE__ */ __name(async (previousBloc
|
|
|
1162
1204
|
const bridgeDestinationObservation = new PayloadBuilder4({
|
|
1163
1205
|
schema: BridgeDestinationObservationSchema
|
|
1164
1206
|
}).fields(bridgeDestinationObservationFields).build();
|
|
1165
|
-
return await
|
|
1207
|
+
return await buildNextBlock2(previousBlock[0], [], [
|
|
1166
1208
|
bridgeDestinationObservation
|
|
1167
1209
|
], [
|
|
1168
1210
|
account
|
|
@@ -1170,7 +1212,7 @@ var getBridgeDestinationObservation = /* @__PURE__ */ __name(async (previousBloc
|
|
|
1170
1212
|
}, "getBridgeDestinationObservation");
|
|
1171
1213
|
|
|
1172
1214
|
// src/orchestration/services/implementation/head/createForkedHead/getBridgeIntent.ts
|
|
1173
|
-
import { BridgeIntentSchema, buildNextBlock as
|
|
1215
|
+
import { BridgeIntentSchema, buildNextBlock as buildNextBlock3, createTransferPayload, XYO_BRIDGE_ADDRESS } from "@xyo-network/chain-sdk";
|
|
1174
1216
|
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
1175
1217
|
var getBridgeIntent = /* @__PURE__ */ __name(async (previousBlock, account, chainService) => {
|
|
1176
1218
|
const transferPayload = createTransferPayload(account.address, {
|
|
@@ -1185,7 +1227,7 @@ var getBridgeIntent = /* @__PURE__ */ __name(async (previousBlock, account, chai
|
|
|
1185
1227
|
const bridgeIntent = new PayloadBuilder5({
|
|
1186
1228
|
schema: BridgeIntentSchema
|
|
1187
1229
|
}).fields(bridgeIntentFields).build();
|
|
1188
|
-
return await
|
|
1230
|
+
return await buildNextBlock3(previousBlock[0], [], [
|
|
1189
1231
|
bridgeIntent,
|
|
1190
1232
|
transferPayload
|
|
1191
1233
|
], [
|
|
@@ -1194,7 +1236,7 @@ var getBridgeIntent = /* @__PURE__ */ __name(async (previousBlock, account, chai
|
|
|
1194
1236
|
}, "getBridgeIntent");
|
|
1195
1237
|
|
|
1196
1238
|
// src/orchestration/services/implementation/head/createForkedHead/getBridgeSourceObservation.ts
|
|
1197
|
-
import { BridgeSourceObservationSchema, buildNextBlock as
|
|
1239
|
+
import { BridgeSourceObservationSchema, buildNextBlock as buildNextBlock4 } from "@xyo-network/chain-sdk";
|
|
1198
1240
|
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
|
|
1199
1241
|
var getBridgeSourceObservation = /* @__PURE__ */ __name(async (previousBlock, account, chainService) => {
|
|
1200
1242
|
const srcTxHash = previousBlock[0]._hash;
|
|
@@ -1207,7 +1249,7 @@ var getBridgeSourceObservation = /* @__PURE__ */ __name(async (previousBlock, ac
|
|
|
1207
1249
|
const bridgeSourceObservation = new PayloadBuilder6({
|
|
1208
1250
|
schema: BridgeSourceObservationSchema
|
|
1209
1251
|
}).fields(bridgeSourceObservationFields).build();
|
|
1210
|
-
return await
|
|
1252
|
+
return await buildNextBlock4(previousBlock[0], [], [
|
|
1211
1253
|
bridgeSourceObservation
|
|
1212
1254
|
], [
|
|
1213
1255
|
account
|
|
@@ -1215,11 +1257,10 @@ var getBridgeSourceObservation = /* @__PURE__ */ __name(async (previousBlock, ac
|
|
|
1215
1257
|
}, "getBridgeSourceObservation");
|
|
1216
1258
|
|
|
1217
1259
|
// src/orchestration/services/implementation/head/createForkedHead/getFirstBlockForNewChain.ts
|
|
1218
|
-
import { buildBlock } from "@xyo-network/chain-sdk";
|
|
1260
|
+
import { AttoXL1, buildBlock, XYO_STEP_REWARD_ADDRESS } from "@xyo-network/chain-sdk";
|
|
1219
1261
|
var getFirstBlockForNewChain = /* @__PURE__ */ __name(async (forkBlock, account, chainService) => {
|
|
1220
1262
|
const { _hash: previousBlockHash, block: previousBlockNumber, step_hashes: previousStepHashes, protocol } = forkBlock;
|
|
1221
1263
|
const chainId = chainService.chainId;
|
|
1222
|
-
const forkBlockReward = getForkBlockReward();
|
|
1223
1264
|
const options = {
|
|
1224
1265
|
blockPayloads: [],
|
|
1225
1266
|
chainId,
|
|
@@ -1231,8 +1272,8 @@ var getFirstBlockForNewChain = /* @__PURE__ */ __name(async (forkBlock, account,
|
|
|
1231
1272
|
],
|
|
1232
1273
|
txs: [],
|
|
1233
1274
|
protocol,
|
|
1234
|
-
|
|
1235
|
-
|
|
1275
|
+
stepRewardAddress: XYO_STEP_REWARD_ADDRESS,
|
|
1276
|
+
stepRewardPoolBalance: AttoXL1(0n)
|
|
1236
1277
|
};
|
|
1237
1278
|
return await buildBlock(options);
|
|
1238
1279
|
}, "getFirstBlockForNewChain");
|
|
@@ -1253,14 +1294,14 @@ var createForkedHead = /* @__PURE__ */ __name(async (forkFromBlock, account, cha
|
|
|
1253
1294
|
|
|
1254
1295
|
// src/orchestration/services/implementation/head/getForkFromBlock.ts
|
|
1255
1296
|
import { asHash, hexFromBigInt } from "@xylabs/hex";
|
|
1256
|
-
import { isDefined as
|
|
1297
|
+
import { isDefined as isDefined12 } from "@xylabs/typeof";
|
|
1257
1298
|
import { isBlockBoundWitnessWithHashStorageMeta } from "@xyo-network/chain-sdk";
|
|
1258
1299
|
var getForkFromBlock = /* @__PURE__ */ __name(async (head, chainService, chainArchivist) => {
|
|
1259
1300
|
if (head.chain !== chainService.chainId) {
|
|
1260
1301
|
const forkedAtBigInt = await chainService.forkedAtHash();
|
|
1261
1302
|
const forkedAtHex = hexFromBigInt(forkedAtBigInt);
|
|
1262
1303
|
const forkedAtHash = asHash(forkedAtHex);
|
|
1263
|
-
if (
|
|
1304
|
+
if (isDefined12(forkedAtHash)) {
|
|
1264
1305
|
const [forkedAtBlock] = await chainArchivist.get([
|
|
1265
1306
|
forkedAtHash
|
|
1266
1307
|
]);
|
|
@@ -1298,18 +1339,17 @@ var initHead = /* @__PURE__ */ __name(async (params) => {
|
|
|
1298
1339
|
let head = await findMostRecentBlock2(chainArchivist);
|
|
1299
1340
|
if (head) {
|
|
1300
1341
|
const forkFromBlock = await getForkFromBlock(head, chainService, chainArchivist);
|
|
1301
|
-
if (
|
|
1342
|
+
if (isDefined13(forkFromBlock)) {
|
|
1302
1343
|
const chain = await createForkedHead(forkFromBlock, account, chainService);
|
|
1303
1344
|
await submitNewChain(chain, chainArchivist, chainSubmissionsArchivistWrite);
|
|
1304
1345
|
const newBlock = assertEx16(chain.at(-1), () => new Error("Failed to get new head after forking"));
|
|
1305
1346
|
head = newBlock[0];
|
|
1306
1347
|
}
|
|
1307
1348
|
} else {
|
|
1308
|
-
const
|
|
1309
|
-
await submitNewChain(
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
head = genesisBlock[0];
|
|
1349
|
+
const chain = await createBootstrapHead(account, chainService);
|
|
1350
|
+
await submitNewChain(chain, chainArchivist, chainSubmissionsArchivistWrite);
|
|
1351
|
+
const newBlock = assertEx16(chain.at(-1), () => new Error("Failed to get new head after genesis"));
|
|
1352
|
+
head = newBlock[0];
|
|
1313
1353
|
}
|
|
1314
1354
|
headSingleton = head;
|
|
1315
1355
|
return headSingleton;
|
|
@@ -1388,6 +1428,27 @@ var initEvmBlockRewardService = /* @__PURE__ */ __name(async (params) => {
|
|
|
1388
1428
|
return rewardServiceSingleton;
|
|
1389
1429
|
}, "initEvmBlockRewardService");
|
|
1390
1430
|
|
|
1431
|
+
// src/orchestration/services/implementation/time.ts
|
|
1432
|
+
import { BaseTimeSyncService } from "@xyo-network/chain-sdk";
|
|
1433
|
+
var timeSyncServiceSingleton;
|
|
1434
|
+
var initTimeService = /* @__PURE__ */ __name(async ({ chainArchivist, chainIterator, config: config3, logger, meterProvider, traceProvider }) => {
|
|
1435
|
+
if (timeSyncServiceSingleton) return timeSyncServiceSingleton;
|
|
1436
|
+
const ethProvider = canUseEvmProvider({
|
|
1437
|
+
config: config3
|
|
1438
|
+
}) ? await initEvmProvider({
|
|
1439
|
+
config: config3
|
|
1440
|
+
}) : void 0;
|
|
1441
|
+
timeSyncServiceSingleton = BaseTimeSyncService.create({
|
|
1442
|
+
chainArchivist,
|
|
1443
|
+
chainIterator,
|
|
1444
|
+
ethProvider,
|
|
1445
|
+
logger,
|
|
1446
|
+
meterProvider,
|
|
1447
|
+
traceProvider
|
|
1448
|
+
});
|
|
1449
|
+
return await timeSyncServiceSingleton;
|
|
1450
|
+
}, "initTimeService");
|
|
1451
|
+
|
|
1391
1452
|
// src/orchestration/services/implementation/validator.ts
|
|
1392
1453
|
var serviceSingleton3;
|
|
1393
1454
|
var initValidator = /* @__PURE__ */ __name((params) => {
|
|
@@ -1488,7 +1549,7 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
1488
1549
|
|
|
1489
1550
|
// src/orchestration/initServices.ts
|
|
1490
1551
|
var isStartable = /* @__PURE__ */ __name((value) => {
|
|
1491
|
-
return
|
|
1552
|
+
return isDefined14(value.start) && typeof value.start === "function";
|
|
1492
1553
|
}, "isStartable");
|
|
1493
1554
|
var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
1494
1555
|
const { config: config3, logger } = context;
|
|
@@ -1504,7 +1565,7 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
1504
1565
|
logger.error("Producer encountered an unhandled error!");
|
|
1505
1566
|
process.exit(1);
|
|
1506
1567
|
});
|
|
1507
|
-
await
|
|
1568
|
+
await startupSpanAsync8("initHealthEndpoints", () => initHealthEndpoints({
|
|
1508
1569
|
...context,
|
|
1509
1570
|
statusReporter
|
|
1510
1571
|
}));
|
|
@@ -1521,8 +1582,8 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
1521
1582
|
}
|
|
1522
1583
|
};
|
|
1523
1584
|
const [{ traceProvider, meterProvider }, account] = await Promise.all([
|
|
1524
|
-
|
|
1525
|
-
|
|
1585
|
+
startupSpanAsync8("initTelemetry", () => initTelemetry(telemetryConfig)),
|
|
1586
|
+
startupSpanAsync8("initAccount", () => initAccount(context))
|
|
1526
1587
|
]);
|
|
1527
1588
|
const initParams = {
|
|
1528
1589
|
config: config3,
|
|
@@ -1531,24 +1592,25 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
1531
1592
|
statusReporter,
|
|
1532
1593
|
traceProvider
|
|
1533
1594
|
};
|
|
1534
|
-
const [chainArchivist, [pendingBundledTransactionsArchivist, pendingBundledTransactionsArchivistWrite], rejectedTransactionsArchivist, chainSubmissionsArchivistWrite, stakeIntentStateArchivist, chainService, balanceSummaryMap] = await Promise.all([
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1595
|
+
const [chainArchivist, [pendingBundledTransactionsArchivist, pendingBundledTransactionsArchivistWrite], rejectedTransactionsArchivist, chainSubmissionsArchivistWrite, stakeIntentStateArchivist, chainService, balanceSummaryMap, transferSummaryMap] = await Promise.all([
|
|
1596
|
+
startupSpanAsync8("ChainFinalizedArchivist", () => initChainFinalizedArchivist(initParams)),
|
|
1597
|
+
startupSpanAsync8("PendingBundledTransactionsArchivist", () => initPendingBundledTransactionsArchivist(initParams)),
|
|
1598
|
+
startupSpanAsync8("RejectedTransactionsArchivist", () => initRejectedTransactionsArchivist(initParams)),
|
|
1599
|
+
startupSpanAsync8("ChainSubmissionsArchivist", () => initChainSubmissionsArchivist(initParams)),
|
|
1600
|
+
startupSpanAsync8("StakeIntentStateArchivist", () => initStakeIntentStateArchivist(initParams)),
|
|
1601
|
+
startupSpanAsync8("ChainService", () => initChainService({
|
|
1541
1602
|
...initParams,
|
|
1542
1603
|
account,
|
|
1543
1604
|
name: "ChainService"
|
|
1544
1605
|
})),
|
|
1545
|
-
|
|
1606
|
+
startupSpanAsync8("BalanceSummaryMap", () => initBalanceSummaryMap(initParams)),
|
|
1607
|
+
startupSpanAsync8("TransferSummaryMap", () => initTransferSummaryMap(initParams))
|
|
1546
1608
|
]);
|
|
1547
1609
|
const chainId = chainService.chainId;
|
|
1548
1610
|
const chainContractViewer = chainService;
|
|
1549
1611
|
const chainStakeViewer = chainService;
|
|
1550
1612
|
const chainStaker = chainService;
|
|
1551
|
-
const head = await
|
|
1613
|
+
const head = await startupSpanAsync8("initHead", () => initHead({
|
|
1552
1614
|
...initParams,
|
|
1553
1615
|
account,
|
|
1554
1616
|
chainArchivist,
|
|
@@ -1556,7 +1618,7 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
1556
1618
|
chainService
|
|
1557
1619
|
}));
|
|
1558
1620
|
const [pendingTransactionsService, rewardService, chainIterator, balanceService] = await Promise.all([
|
|
1559
|
-
|
|
1621
|
+
startupSpanAsync8("PendingTransactions", () => initPendingTransactions({
|
|
1560
1622
|
name: "PendingTransactionsService",
|
|
1561
1623
|
chainArchivist,
|
|
1562
1624
|
chainId,
|
|
@@ -1564,34 +1626,42 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
1564
1626
|
rejectedTransactionsArchivist,
|
|
1565
1627
|
...initParams
|
|
1566
1628
|
})),
|
|
1567
|
-
|
|
1629
|
+
startupSpanAsync8("RewardService", () => initBlockRewardService({
|
|
1568
1630
|
name: "RewardService",
|
|
1569
1631
|
account,
|
|
1570
1632
|
chainService,
|
|
1571
1633
|
...initParams
|
|
1572
1634
|
})),
|
|
1573
|
-
|
|
1635
|
+
startupSpanAsync8("ChainIterator", () => initChainIterator({
|
|
1574
1636
|
name: "ChainIterator",
|
|
1575
1637
|
chainArchivist,
|
|
1576
1638
|
head,
|
|
1577
1639
|
...initParams
|
|
1578
1640
|
})),
|
|
1579
|
-
|
|
1641
|
+
startupSpanAsync8("BalanceService", () => initBalanceService({
|
|
1580
1642
|
name: "BalanceService",
|
|
1581
1643
|
chainArchivist,
|
|
1582
1644
|
summaryRepository: balanceSummaryRepositoryFromMap(balanceSummaryMap),
|
|
1583
1645
|
...initParams
|
|
1584
1646
|
}))
|
|
1585
1647
|
]);
|
|
1586
|
-
const stakeIntentService = await
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1648
|
+
const [stakeIntentService, time] = await Promise.all([
|
|
1649
|
+
startupSpanAsync8("StakeIntentService", () => initStakeIntentService({
|
|
1650
|
+
name: "StakeIntentService",
|
|
1651
|
+
chainArchivist,
|
|
1652
|
+
chainIterator,
|
|
1653
|
+
chainStakeViewer,
|
|
1654
|
+
stakeIntentStateArchivist,
|
|
1655
|
+
...initParams
|
|
1656
|
+
})),
|
|
1657
|
+
startupSpanAsync8("TimeService", () => initTimeService({
|
|
1658
|
+
name: "TimeService",
|
|
1659
|
+
chainArchivist,
|
|
1660
|
+
chainIterator,
|
|
1661
|
+
...initParams
|
|
1662
|
+
}))
|
|
1663
|
+
]);
|
|
1664
|
+
const electionService = await startupSpanAsync8("ElectionService", () => initElectionService({
|
|
1595
1665
|
name: "ElectionService",
|
|
1596
1666
|
chainIterator,
|
|
1597
1667
|
chainStakeViewer,
|
|
@@ -1610,11 +1680,7 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
1610
1680
|
validateHydratedBlockState,
|
|
1611
1681
|
...initParams
|
|
1612
1682
|
};
|
|
1613
|
-
const
|
|
1614
|
-
chainArchivist,
|
|
1615
|
-
chainIterator
|
|
1616
|
-
});
|
|
1617
|
-
const rewardAddress = isDefined12(config3.producer.rewardAddress) ? assertEx18(asAddress2(config3.producer.rewardAddress), () => "Invalid block reward address provided") : account.address;
|
|
1683
|
+
const rewardAddress = isDefined14(config3.producer.rewardAddress) ? assertEx18(asAddress2(config3.producer.rewardAddress), () => "Invalid block reward address provided") : account.address;
|
|
1618
1684
|
const producerParams = {
|
|
1619
1685
|
...validatorParams,
|
|
1620
1686
|
name: "Producer",
|
|
@@ -1627,7 +1693,7 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
1627
1693
|
time,
|
|
1628
1694
|
...initParams
|
|
1629
1695
|
};
|
|
1630
|
-
const producer = await
|
|
1696
|
+
const producer = await startupSpanAsync8("Producer", () => initBlockProducer(producerParams));
|
|
1631
1697
|
const result = {
|
|
1632
1698
|
account,
|
|
1633
1699
|
balance: balanceService,
|
|
@@ -1655,7 +1721,7 @@ var initServices = /* @__PURE__ */ __name(async (context) => {
|
|
|
1655
1721
|
|
|
1656
1722
|
// src/runCLI.ts
|
|
1657
1723
|
import { deepMerge } from "@xylabs/object";
|
|
1658
|
-
import { isDefined as
|
|
1724
|
+
import { isDefined as isDefined17 } from "@xylabs/typeof";
|
|
1659
1725
|
import { ConfigZod } from "@xyo-network/xl1-protocol-sdk";
|
|
1660
1726
|
import yargs from "yargs";
|
|
1661
1727
|
import { hideBin } from "yargs/helpers";
|
|
@@ -1715,16 +1781,16 @@ var XL1LogoColorizedAscii = `\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\
|
|
|
1715
1781
|
// src/initLogger.ts
|
|
1716
1782
|
import { Base as Base2 } from "@xylabs/base";
|
|
1717
1783
|
import { ConsoleLogger, LogLevel, SilentLogger } from "@xylabs/logger";
|
|
1718
|
-
import { isDefined as
|
|
1784
|
+
import { isDefined as isDefined15 } from "@xylabs/typeof";
|
|
1719
1785
|
var initLogger = /* @__PURE__ */ __name((config3) => {
|
|
1720
1786
|
let logger;
|
|
1721
1787
|
if (config3.silent) {
|
|
1722
1788
|
logger = new SilentLogger();
|
|
1723
1789
|
} else {
|
|
1724
1790
|
let level;
|
|
1725
|
-
if (
|
|
1791
|
+
if (isDefined15(config3.logLevel)) {
|
|
1726
1792
|
const parsed = LogLevel[config3.logLevel.toLowerCase()];
|
|
1727
|
-
if (
|
|
1793
|
+
if (isDefined15(parsed)) level = parsed;
|
|
1728
1794
|
}
|
|
1729
1795
|
logger = new ConsoleLogger(level);
|
|
1730
1796
|
}
|
|
@@ -1740,7 +1806,7 @@ var usageMetaToOptions = /* @__PURE__ */ __name((meta) => {
|
|
|
1740
1806
|
}, "usageMetaToOptions");
|
|
1741
1807
|
var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
1742
1808
|
const opts = {};
|
|
1743
|
-
for (const schema of globalRegistry._map
|
|
1809
|
+
for (const schema of Object.values(globalRegistry._map)) {
|
|
1744
1810
|
if (isUsageMeta(schema)) {
|
|
1745
1811
|
if (schema.hidden) continue;
|
|
1746
1812
|
opts[schema.title] = usageMetaToOptions(schema);
|
|
@@ -1750,7 +1816,7 @@ var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
|
1750
1816
|
}, "optionsFromGlobalZodRegistry");
|
|
1751
1817
|
|
|
1752
1818
|
// src/tryParseConfig.ts
|
|
1753
|
-
import { isDefined as
|
|
1819
|
+
import { isDefined as isDefined16, isNull } from "@xylabs/typeof";
|
|
1754
1820
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
1755
1821
|
var configName = "xyo";
|
|
1756
1822
|
var configSection = "xl1";
|
|
@@ -1759,7 +1825,7 @@ var tryParseConfig = /* @__PURE__ */ __name(() => {
|
|
|
1759
1825
|
const result = explorer.search();
|
|
1760
1826
|
if (!isNull(result)) {
|
|
1761
1827
|
const section = result?.config?.[configSection];
|
|
1762
|
-
if (
|
|
1828
|
+
if (isDefined16(section) && typeof section === "object") {
|
|
1763
1829
|
return section;
|
|
1764
1830
|
}
|
|
1765
1831
|
}
|
|
@@ -1789,7 +1855,7 @@ var waitForHostPort = /* @__PURE__ */ __name((host, port) => {
|
|
|
1789
1855
|
|
|
1790
1856
|
// src/runCLI.ts
|
|
1791
1857
|
var config;
|
|
1792
|
-
var version =
|
|
1858
|
+
var version = isDefined17("1.14.4") ? "1.14.4" : "unknown";
|
|
1793
1859
|
var getContextFromConfig = /* @__PURE__ */ __name((config3) => {
|
|
1794
1860
|
const logger = initLogger(config3);
|
|
1795
1861
|
const orchestrator = new Orchestrator(logger);
|
|
@@ -1821,6 +1887,7 @@ Run various components of the XL1 ecosystem.
|
|
|
1821
1887
|
Usage:
|
|
1822
1888
|
$0 <command> [options]`).parserConfiguration({
|
|
1823
1889
|
"dot-notation": true,
|
|
1890
|
+
"parse-numbers": false,
|
|
1824
1891
|
"populate--": true
|
|
1825
1892
|
}).env("XL1").scriptName("xl1").middleware((argv2) => {
|
|
1826
1893
|
try {
|
|
@@ -1900,6 +1967,7 @@ export {
|
|
|
1900
1967
|
initPendingTransactions,
|
|
1901
1968
|
initServices,
|
|
1902
1969
|
initStakeIntentService,
|
|
1970
|
+
initTimeService,
|
|
1903
1971
|
initValidator,
|
|
1904
1972
|
runCLI,
|
|
1905
1973
|
start
|