@xyo-network/xl1-cli-lib 1.7.4
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/LICENSE +165 -0
- package/README.md +46 -0
- package/dist/node/commands/api/index.d.ts +2 -0
- package/dist/node/commands/api/index.d.ts.map +1 -0
- package/dist/node/commands/api/runApi.d.ts +9 -0
- package/dist/node/commands/api/runApi.d.ts.map +1 -0
- package/dist/node/commands/index.d.ts +4 -0
- package/dist/node/commands/index.d.ts.map +1 -0
- package/dist/node/commands/producer/index.d.ts +2 -0
- package/dist/node/commands/producer/index.d.ts.map +1 -0
- package/dist/node/commands/producer/runProducer.d.ts +11 -0
- package/dist/node/commands/producer/runProducer.d.ts.map +1 -0
- package/dist/node/commands/validator/index.d.ts +2 -0
- package/dist/node/commands/validator/index.d.ts.map +1 -0
- package/dist/node/commands/validator/runValidator.d.ts +11 -0
- package/dist/node/commands/validator/runValidator.d.ts.map +1 -0
- package/dist/node/images.d.ts +2 -0
- package/dist/node/images.d.ts.map +1 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +1712 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/initConfig.d.ts +3 -0
- package/dist/node/initConfig.d.ts.map +1 -0
- package/dist/node/initLogger.d.ts +4 -0
- package/dist/node/initLogger.d.ts.map +1 -0
- package/dist/node/optionsFromZodSchema.d.ts +4 -0
- package/dist/node/optionsFromZodSchema.d.ts.map +1 -0
- package/dist/node/orchestration/ChainInitializableParams.d.ts +11 -0
- package/dist/node/orchestration/ChainInitializableParams.d.ts.map +1 -0
- package/dist/node/orchestration/actor/implementation/BalanceActor.d.ts +18 -0
- package/dist/node/orchestration/actor/implementation/BalanceActor.d.ts.map +1 -0
- package/dist/node/orchestration/actor/implementation/ChainHeadUpdateActor.d.ts +19 -0
- package/dist/node/orchestration/actor/implementation/ChainHeadUpdateActor.d.ts.map +1 -0
- package/dist/node/orchestration/actor/implementation/ProducerActor.d.ts +28 -0
- package/dist/node/orchestration/actor/implementation/ProducerActor.d.ts.map +1 -0
- package/dist/node/orchestration/actor/implementation/ValidatorActor.d.ts +26 -0
- package/dist/node/orchestration/actor/implementation/ValidatorActor.d.ts.map +1 -0
- package/dist/node/orchestration/actor/implementation/index.d.ts +5 -0
- package/dist/node/orchestration/actor/implementation/index.d.ts.map +1 -0
- package/dist/node/orchestration/actor/index.d.ts +3 -0
- package/dist/node/orchestration/actor/index.d.ts.map +1 -0
- package/dist/node/orchestration/actor/model/Actor.d.ts +39 -0
- package/dist/node/orchestration/actor/model/Actor.d.ts.map +1 -0
- package/dist/node/orchestration/actor/model/Orchestrator.d.ts +27 -0
- package/dist/node/orchestration/actor/model/Orchestrator.d.ts.map +1 -0
- package/dist/node/orchestration/actor/model/index.d.ts +3 -0
- package/dist/node/orchestration/actor/model/index.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/ChainFinalized/archivist.d.ts +4 -0
- package/dist/node/orchestration/archivists/ChainFinalized/archivist.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/ChainFinalized/index.d.ts +2 -0
- package/dist/node/orchestration/archivists/ChainFinalized/index.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/ChainFinalized/local.d.ts +7 -0
- package/dist/node/orchestration/archivists/ChainFinalized/local.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/ChainFinalized/remote.d.ts +7 -0
- package/dist/node/orchestration/archivists/ChainFinalized/remote.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/ChainSubmissions/archivist.d.ts +7 -0
- package/dist/node/orchestration/archivists/ChainSubmissions/archivist.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/ChainSubmissions/index.d.ts +2 -0
- package/dist/node/orchestration/archivists/ChainSubmissions/index.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/ChainSubmissions/remote.d.ts +7 -0
- package/dist/node/orchestration/archivists/ChainSubmissions/remote.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/PendingTransactions/archivist.d.ts +6 -0
- package/dist/node/orchestration/archivists/PendingTransactions/archivist.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/PendingTransactions/index.d.ts +2 -0
- package/dist/node/orchestration/archivists/PendingTransactions/index.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/PendingTransactions/local.d.ts +7 -0
- package/dist/node/orchestration/archivists/PendingTransactions/local.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/PendingTransactions/remote.d.ts +7 -0
- package/dist/node/orchestration/archivists/PendingTransactions/remote.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/RejectedTransactions/archivist.d.ts +4 -0
- package/dist/node/orchestration/archivists/RejectedTransactions/archivist.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/RejectedTransactions/index.d.ts +2 -0
- package/dist/node/orchestration/archivists/RejectedTransactions/index.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/RejectedTransactions/local.d.ts +4 -0
- package/dist/node/orchestration/archivists/RejectedTransactions/local.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/StakeIntentState/archivist.d.ts +5 -0
- package/dist/node/orchestration/archivists/StakeIntentState/archivist.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/StakeIntentState/index.d.ts +2 -0
- package/dist/node/orchestration/archivists/StakeIntentState/index.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/StakeIntentState/local.d.ts +7 -0
- package/dist/node/orchestration/archivists/StakeIntentState/local.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/index.d.ts +6 -0
- package/dist/node/orchestration/archivists/index.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/lib/index.d.ts +2 -0
- package/dist/node/orchestration/archivists/lib/index.d.ts.map +1 -0
- package/dist/node/orchestration/archivists/lib/localPersistentArchivist.d.ts +20 -0
- package/dist/node/orchestration/archivists/lib/localPersistentArchivist.d.ts.map +1 -0
- package/dist/node/orchestration/health/index.d.ts +2 -0
- package/dist/node/orchestration/health/index.d.ts.map +1 -0
- package/dist/node/orchestration/health/initHealthEndpoints.d.ts +11 -0
- package/dist/node/orchestration/health/initHealthEndpoints.d.ts.map +1 -0
- package/dist/node/orchestration/host/implementation/DefaultHost.d.ts +12 -0
- package/dist/node/orchestration/host/implementation/DefaultHost.d.ts.map +1 -0
- package/dist/node/orchestration/host/implementation/DefaultServiceCollection.d.ts +24 -0
- package/dist/node/orchestration/host/implementation/DefaultServiceCollection.d.ts.map +1 -0
- package/dist/node/orchestration/host/implementation/DefaultServiceProvider.d.ts +7 -0
- package/dist/node/orchestration/host/implementation/DefaultServiceProvider.d.ts.map +1 -0
- package/dist/node/orchestration/host/implementation/index.d.ts +3 -0
- package/dist/node/orchestration/host/implementation/index.d.ts.map +1 -0
- package/dist/node/orchestration/host/index.d.ts +3 -0
- package/dist/node/orchestration/host/index.d.ts.map +1 -0
- package/dist/node/orchestration/host/model/Host.d.ts +19 -0
- package/dist/node/orchestration/host/model/Host.d.ts.map +1 -0
- package/dist/node/orchestration/host/model/ServiceCollection.d.ts +20 -0
- package/dist/node/orchestration/host/model/ServiceCollection.d.ts.map +1 -0
- package/dist/node/orchestration/host/model/ServiceProvider.d.ts +4 -0
- package/dist/node/orchestration/host/model/ServiceProvider.d.ts.map +1 -0
- package/dist/node/orchestration/host/model/index.d.ts +4 -0
- package/dist/node/orchestration/host/model/index.d.ts.map +1 -0
- package/dist/node/orchestration/index.d.ts +6 -0
- package/dist/node/orchestration/index.d.ts.map +1 -0
- package/dist/node/orchestration/initServices.d.ts +9 -0
- package/dist/node/orchestration/initServices.d.ts.map +1 -0
- package/dist/node/orchestration/map/BalanceSummary/index.d.ts +2 -0
- package/dist/node/orchestration/map/BalanceSummary/index.d.ts.map +1 -0
- package/dist/node/orchestration/map/BalanceSummary/initBalanceSummaryMap.d.ts +7 -0
- package/dist/node/orchestration/map/BalanceSummary/initBalanceSummaryMap.d.ts.map +1 -0
- package/dist/node/orchestration/map/BalanceSummary/local.d.ts +7 -0
- package/dist/node/orchestration/map/BalanceSummary/local.d.ts.map +1 -0
- package/dist/node/orchestration/map/driver/index.d.ts +2 -0
- package/dist/node/orchestration/map/driver/index.d.ts.map +1 -0
- package/dist/node/orchestration/map/driver/lmdb/Params.d.ts +7 -0
- package/dist/node/orchestration/map/driver/lmdb/Params.d.ts.map +1 -0
- package/dist/node/orchestration/map/driver/lmdb/SynchronousLmdbMap.d.ts +32 -0
- package/dist/node/orchestration/map/driver/lmdb/SynchronousLmdbMap.d.ts.map +1 -0
- package/dist/node/orchestration/map/driver/lmdb/index.d.ts +2 -0
- package/dist/node/orchestration/map/driver/lmdb/index.d.ts.map +1 -0
- package/dist/node/orchestration/map/driver/lmdb/spec/SynchronousLmdbMap.spec.d.ts +2 -0
- package/dist/node/orchestration/map/driver/lmdb/spec/SynchronousLmdbMap.spec.d.ts.map +1 -0
- package/dist/node/orchestration/map/index.d.ts +3 -0
- package/dist/node/orchestration/map/index.d.ts.map +1 -0
- package/dist/node/orchestration/map/localPersistentMap.d.ts +13 -0
- package/dist/node/orchestration/map/localPersistentMap.d.ts.map +1 -0
- package/dist/node/orchestration/repository/index.d.ts +2 -0
- package/dist/node/orchestration/repository/index.d.ts.map +1 -0
- package/dist/node/orchestration/repository/lib/index.d.ts +2 -0
- package/dist/node/orchestration/repository/lib/index.d.ts.map +1 -0
- package/dist/node/orchestration/repository/lib/repositoryFromArchivist.d.ts +6 -0
- package/dist/node/orchestration/repository/lib/repositoryFromArchivist.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/account.d.ts +7 -0
- package/dist/node/orchestration/services/implementation/account.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/balance.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/balance.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/chain/evm.d.ts +7 -0
- package/dist/node/orchestration/services/implementation/chain/evm.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/chain/index.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/chain/index.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/evm/index.d.ts +2 -0
- package/dist/node/orchestration/services/implementation/evm/index.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/evm/initChainId.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/evm/initChainId.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/evm/initEvmProvider.d.ts +11 -0
- package/dist/node/orchestration/services/implementation/evm/initEvmProvider.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/evm/initInfuraProvider.d.ts +6 -0
- package/dist/node/orchestration/services/implementation/evm/initInfuraProvider.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/evm/initJsonRpcProvider.d.ts +6 -0
- package/dist/node/orchestration/services/implementation/evm/initJsonRpcProvider.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head.d.ts +10 -0
- package/dist/node/orchestration/services/implementation/head.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/index.d.ts +11 -0
- package/dist/node/orchestration/services/implementation/index.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/iterator.d.ts +6 -0
- package/dist/node/orchestration/services/implementation/iterator.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/pendingTransactions.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/pendingTransactions.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/producer.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/producer.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/reward.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/reward.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/validator.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/validator.d.ts.map +1 -0
- package/dist/node/orchestration/services/index.d.ts +2 -0
- package/dist/node/orchestration/services/index.d.ts.map +1 -0
- package/dist/node/orchestration/status/RuntimeStatusMonitor.d.ts +31 -0
- package/dist/node/orchestration/status/RuntimeStatusMonitor.d.ts.map +1 -0
- package/dist/node/orchestration/status/ServiceStatus.d.ts +9 -0
- package/dist/node/orchestration/status/ServiceStatus.d.ts.map +1 -0
- package/dist/node/orchestration/status/index.d.ts +3 -0
- package/dist/node/orchestration/status/index.d.ts.map +1 -0
- package/dist/node/orchestration/store/StoreKind.d.ts +2 -0
- package/dist/node/orchestration/store/StoreKind.d.ts.map +1 -0
- package/dist/node/orchestration/store/getStoreDirectory.d.ts +10 -0
- package/dist/node/orchestration/store/getStoreDirectory.d.ts.map +1 -0
- package/dist/node/orchestration/store/index.d.ts +3 -0
- package/dist/node/orchestration/store/index.d.ts.map +1 -0
- package/dist/node/runCLI.d.ts +2 -0
- package/dist/node/runCLI.d.ts.map +1 -0
- package/dist/node/spec/BootstrapChain.spec.d.ts +2 -0
- package/dist/node/spec/BootstrapChain.spec.d.ts.map +1 -0
- package/dist/node/start.d.ts +2 -0
- package/dist/node/start.d.ts.map +1 -0
- package/dist/node/waitForHostPort.d.ts +2 -0
- package/dist/node/waitForHostPort.d.ts.map +1 -0
- package/dist/node/xl1.d.ts +2 -0
- package/dist/node/xl1.d.ts.map +1 -0
- package/dist/node/xl1.mjs +1610 -0
- package/dist/node/xl1.mjs.map +1 -0
- package/package.json +96 -0
- package/src/commands/api/index.ts +1 -0
- package/src/commands/api/runApi.ts +12 -0
- package/src/commands/index.ts +3 -0
- package/src/commands/producer/index.ts +1 -0
- package/src/commands/producer/runProducer.ts +38 -0
- package/src/commands/validator/index.ts +1 -0
- package/src/commands/validator/runValidator.ts +38 -0
- package/src/images.ts +19 -0
- package/src/index.ts +3 -0
- package/src/initConfig.ts +6 -0
- package/src/initLogger.ts +23 -0
- package/src/optionsFromZodSchema.ts +69 -0
- package/src/orchestration/ChainInitializableParams.ts +12 -0
- package/src/orchestration/actor/implementation/BalanceActor.ts +50 -0
- package/src/orchestration/actor/implementation/ChainHeadUpdateActor.ts +65 -0
- package/src/orchestration/actor/implementation/ProducerActor.ts +244 -0
- package/src/orchestration/actor/implementation/ValidatorActor.ts +113 -0
- package/src/orchestration/actor/implementation/index.ts +4 -0
- package/src/orchestration/actor/index.ts +2 -0
- package/src/orchestration/actor/model/Actor.ts +114 -0
- package/src/orchestration/actor/model/Orchestrator.ts +71 -0
- package/src/orchestration/actor/model/index.ts +2 -0
- package/src/orchestration/archivists/ChainFinalized/archivist.ts +29 -0
- package/src/orchestration/archivists/ChainFinalized/index.ts +1 -0
- package/src/orchestration/archivists/ChainFinalized/local.ts +18 -0
- package/src/orchestration/archivists/ChainFinalized/remote.ts +20 -0
- package/src/orchestration/archivists/ChainSubmissions/archivist.ts +20 -0
- package/src/orchestration/archivists/ChainSubmissions/index.ts +1 -0
- package/src/orchestration/archivists/ChainSubmissions/remote.ts +20 -0
- package/src/orchestration/archivists/PendingTransactions/archivist.ts +29 -0
- package/src/orchestration/archivists/PendingTransactions/index.ts +1 -0
- package/src/orchestration/archivists/PendingTransactions/local.ts +21 -0
- package/src/orchestration/archivists/PendingTransactions/remote.ts +20 -0
- package/src/orchestration/archivists/RejectedTransactions/archivist.ts +18 -0
- package/src/orchestration/archivists/RejectedTransactions/index.ts +1 -0
- package/src/orchestration/archivists/RejectedTransactions/local.ts +20 -0
- package/src/orchestration/archivists/StakeIntentState/archivist.ts +21 -0
- package/src/orchestration/archivists/StakeIntentState/index.ts +1 -0
- package/src/orchestration/archivists/StakeIntentState/local.ts +19 -0
- package/src/orchestration/archivists/index.ts +5 -0
- package/src/orchestration/archivists/lib/index.ts +1 -0
- package/src/orchestration/archivists/lib/localPersistentArchivist.ts +57 -0
- package/src/orchestration/health/index.ts +1 -0
- package/src/orchestration/health/initHealthEndpoints.ts +72 -0
- package/src/orchestration/host/implementation/DefaultHost.ts +25 -0
- package/src/orchestration/host/implementation/DefaultServiceCollection.ts +60 -0
- package/src/orchestration/host/implementation/DefaultServiceProvider.ts +12 -0
- package/src/orchestration/host/implementation/index.ts +2 -0
- package/src/orchestration/host/index.ts +2 -0
- package/src/orchestration/host/model/Host.ts +21 -0
- package/src/orchestration/host/model/ServiceCollection.ts +22 -0
- package/src/orchestration/host/model/ServiceProvider.ts +3 -0
- package/src/orchestration/host/model/index.ts +3 -0
- package/src/orchestration/index.ts +5 -0
- package/src/orchestration/initServices.ts +240 -0
- package/src/orchestration/map/BalanceSummary/index.ts +1 -0
- package/src/orchestration/map/BalanceSummary/initBalanceSummaryMap.ts +22 -0
- package/src/orchestration/map/BalanceSummary/local.ts +21 -0
- package/src/orchestration/map/driver/index.ts +1 -0
- package/src/orchestration/map/driver/lmdb/Params.ts +7 -0
- package/src/orchestration/map/driver/lmdb/SynchronousLmdbMap.ts +66 -0
- package/src/orchestration/map/driver/lmdb/index.ts +1 -0
- package/src/orchestration/map/driver/lmdb/spec/SynchronousLmdbMap.spec.ts +97 -0
- package/src/orchestration/map/index.ts +2 -0
- package/src/orchestration/map/localPersistentMap.ts +52 -0
- package/src/orchestration/repository/index.ts +1 -0
- package/src/orchestration/repository/lib/index.ts +1 -0
- package/src/orchestration/repository/lib/repositoryFromArchivist.ts +27 -0
- package/src/orchestration/services/implementation/account.ts +24 -0
- package/src/orchestration/services/implementation/balance.ts +13 -0
- package/src/orchestration/services/implementation/chain/evm.ts +38 -0
- package/src/orchestration/services/implementation/chain/index.ts +22 -0
- package/src/orchestration/services/implementation/evm/index.ts +1 -0
- package/src/orchestration/services/implementation/evm/initChainId.ts +20 -0
- package/src/orchestration/services/implementation/evm/initEvmProvider.ts +23 -0
- package/src/orchestration/services/implementation/evm/initInfuraProvider.ts +27 -0
- package/src/orchestration/services/implementation/evm/initJsonRpcProvider.ts +21 -0
- package/src/orchestration/services/implementation/head.ts +44 -0
- package/src/orchestration/services/implementation/index.ts +10 -0
- package/src/orchestration/services/implementation/iterator.ts +36 -0
- package/src/orchestration/services/implementation/pendingTransactions.ts +14 -0
- package/src/orchestration/services/implementation/producer.ts +13 -0
- package/src/orchestration/services/implementation/reward.ts +41 -0
- package/src/orchestration/services/implementation/validator.ts +14 -0
- package/src/orchestration/services/index.ts +1 -0
- package/src/orchestration/status/RuntimeStatusMonitor.ts +117 -0
- package/src/orchestration/status/ServiceStatus.ts +21 -0
- package/src/orchestration/status/index.ts +2 -0
- package/src/orchestration/store/StoreKind.ts +1 -0
- package/src/orchestration/store/getStoreDirectory.ts +14 -0
- package/src/orchestration/store/index.ts +2 -0
- package/src/runCLI.ts +111 -0
- package/src/spec/BootstrapChain.spec.ts +133 -0
- package/src/spec/MultiProducer.ChainOutput.json +864 -0
- package/src/start.ts +8 -0
- package/src/waitForHostPort.ts +26 -0
- package/src/xl1.ts +8 -0
package/src/runCLI.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Logger } from '@xylabs/logger'
|
|
2
|
+
import { isDefined } from '@xylabs/typeof'
|
|
3
|
+
import { type Config, ConfigSchema } from '@xyo-network/xl1-protocol-sdk'
|
|
4
|
+
import type { Argv } from 'yargs'
|
|
5
|
+
import yargs from 'yargs'
|
|
6
|
+
import { hideBin } from 'yargs/helpers'
|
|
7
|
+
import { ZodError } from 'zod'
|
|
8
|
+
|
|
9
|
+
import { runApi, runProducer } from './commands/index.ts'
|
|
10
|
+
import { XL1LogoColorizedAscii } from './images.ts'
|
|
11
|
+
import { initLogger } from './initLogger.ts'
|
|
12
|
+
import { optionsFromZodSchema } from './optionsFromZodSchema.ts'
|
|
13
|
+
import { Orchestrator } from './orchestration/index.ts'
|
|
14
|
+
import { waitForHostPort } from './waitForHostPort.ts'
|
|
15
|
+
|
|
16
|
+
/** Version string injected by Rollup at build time. */
|
|
17
|
+
declare const __VERSION__: string
|
|
18
|
+
|
|
19
|
+
interface RunCliContext {
|
|
20
|
+
logger: Logger
|
|
21
|
+
orchestrator: Orchestrator
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The configuration that will be used throughout the CLI.
|
|
26
|
+
* This is materialized after parsing the command-line arguments,
|
|
27
|
+
* environment variables, and defaults.
|
|
28
|
+
*/
|
|
29
|
+
let config: Config
|
|
30
|
+
|
|
31
|
+
const version = isDefined(__VERSION__) ? __VERSION__ : 'unknown'
|
|
32
|
+
|
|
33
|
+
const getContextFromConfig = (config: Config): RunCliContext => {
|
|
34
|
+
const logger = initLogger(config)
|
|
35
|
+
const orchestrator = new Orchestrator(logger)
|
|
36
|
+
// Handle cancellation (Ctrl+C)
|
|
37
|
+
process.on('SIGINT', () => {
|
|
38
|
+
void (async () => {
|
|
39
|
+
try {
|
|
40
|
+
logger.log('\nSIGINT received. Attempting graceful shutdown...')
|
|
41
|
+
await orchestrator?.stop()
|
|
42
|
+
logger.log('Orchestrator stopped, exiting now.')
|
|
43
|
+
process.exit(0)
|
|
44
|
+
} catch (err) {
|
|
45
|
+
logger.error('Error stopping orchestrator:', err)
|
|
46
|
+
process.exit(1)
|
|
47
|
+
}
|
|
48
|
+
})()
|
|
49
|
+
})
|
|
50
|
+
return { logger, orchestrator }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Main entry point
|
|
54
|
+
export async function runCLI() {
|
|
55
|
+
// Parse command-line arguments using Yargs
|
|
56
|
+
const y = yargs(hideBin(process.argv)) as Argv<Config>
|
|
57
|
+
const argv = y
|
|
58
|
+
.usage(`
|
|
59
|
+
🚀 XL1 Node CLI (${version})
|
|
60
|
+
${XL1LogoColorizedAscii}
|
|
61
|
+
Run various components of the XL1 ecosystem.
|
|
62
|
+
|
|
63
|
+
Usage:
|
|
64
|
+
$0 <command> [options]`)
|
|
65
|
+
.parserConfiguration({ 'dot-notation': true }) // foo.bar → { foo: { bar } }
|
|
66
|
+
.env('XL1')
|
|
67
|
+
.scriptName('xl1')
|
|
68
|
+
.config()
|
|
69
|
+
.version(version)
|
|
70
|
+
.middleware((argv) => {
|
|
71
|
+
try {
|
|
72
|
+
// Parse and validate the config
|
|
73
|
+
config = ConfigSchema.parse(argv)
|
|
74
|
+
} catch (err) {
|
|
75
|
+
if (err instanceof ZodError) {
|
|
76
|
+
for (const issue of err.errors) {
|
|
77
|
+
console.error(`${issue.path.join('.')} → ${issue.message}`)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
throw new Error('Invalid configuration')
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.options(optionsFromZodSchema(ConfigSchema.shape))
|
|
84
|
+
// .commandDir('./command/commands', opts) // Not yet supported for ESM
|
|
85
|
+
.wrap(y.terminalWidth())
|
|
86
|
+
.command('api', 'Run a XL1 API Node', (yargs) => {
|
|
87
|
+
return yargs
|
|
88
|
+
.command('$0', 'Run a XL1 API Node', () => {}, () => {
|
|
89
|
+
const context = getContextFromConfig(config)
|
|
90
|
+
runApi({ ...context, config })
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
.command('producer', 'Run a XL1 Producer Node', (yargs) => {
|
|
94
|
+
return yargs
|
|
95
|
+
.command('$0', 'Run a XL1 Producer Node', () => {}, async () => {
|
|
96
|
+
const context = getContextFromConfig(config)
|
|
97
|
+
await runProducer({ ...context, config })
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
.command('$0', 'Run a full XL1 Node', () => {}, async () => {
|
|
101
|
+
const context = getContextFromConfig(config)
|
|
102
|
+
runApi({ ...context, config })
|
|
103
|
+
await waitForHostPort('localhost', config.api.port)
|
|
104
|
+
await runProducer({ ...context, config })
|
|
105
|
+
})
|
|
106
|
+
.help()
|
|
107
|
+
.alias('help', 'h')
|
|
108
|
+
.argv
|
|
109
|
+
|
|
110
|
+
await argv
|
|
111
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import type { ChildProcess } from 'node:child_process'
|
|
4
|
+
|
|
5
|
+
import { assertEx } from '@xylabs/assert'
|
|
6
|
+
import { delay } from '@xylabs/delay'
|
|
7
|
+
import type { Address } from '@xylabs/hex'
|
|
8
|
+
import { asAddress, hexFromBigInt } from '@xylabs/hex'
|
|
9
|
+
import {
|
|
10
|
+
approveTestStakeChainAddress,
|
|
11
|
+
createTestChainContract, createTestErc20, createTestGenesisBlock,
|
|
12
|
+
startGanache, stopGanache, transferTestTokens,
|
|
13
|
+
} from '@xyo-network/chain-sdk'
|
|
14
|
+
import { EvmChainService } from '@xyo-network/chain-services'
|
|
15
|
+
import { HDWallet } from '@xyo-network/wallet'
|
|
16
|
+
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
17
|
+
import type { ChainServiceCollectionV2 } from '@xyo-network/xl1-protocol-sdk'
|
|
18
|
+
import { ConfigSchema, flattenHydratedBlock } from '@xyo-network/xl1-protocol-sdk'
|
|
19
|
+
import type { ContractRunner } from 'ethers'
|
|
20
|
+
import { getAddress } from 'ethers/address'
|
|
21
|
+
import { JsonRpcProvider } from 'ethers/providers'
|
|
22
|
+
import { parseUnits } from 'ethers/utils'
|
|
23
|
+
import { Wallet } from 'ethers/wallet'
|
|
24
|
+
import {
|
|
25
|
+
afterAll, beforeAll, describe, expect, it,
|
|
26
|
+
} from 'vitest'
|
|
27
|
+
|
|
28
|
+
import { initServices } from '../orchestration/index.ts'
|
|
29
|
+
|
|
30
|
+
const ganachePort = 8575
|
|
31
|
+
const testPhrase = 'daring scout quote quarter avoid umbrella spin unhappy buddy luxury cannon urge culture emotion soldier'
|
|
32
|
+
const sharedAccountPhrase = 'crane ribbon cook cousin tobacco vital moral protect merit knock veteran hint knee ocean nurse'
|
|
33
|
+
const useGanache = false
|
|
34
|
+
const bootstrapMultiProducer = false
|
|
35
|
+
const multiProducerSeedPhrases: string[] = []
|
|
36
|
+
|
|
37
|
+
describe.sequential.skip('MultiProducer Network', () => {
|
|
38
|
+
let ganacheProcess: ChildProcess
|
|
39
|
+
let blockProducerAccounts: WalletInstance[]
|
|
40
|
+
let erc20Address: Address
|
|
41
|
+
let xyoChainContractAddress: Address
|
|
42
|
+
// let chainArchivist: ArchivistInstance
|
|
43
|
+
// let head: BlockBoundWitness
|
|
44
|
+
// let chainIterator: ChainIterator
|
|
45
|
+
// let chainStakeService: EvmContractChainStake
|
|
46
|
+
// let stakeIntentService: StakeIntentService
|
|
47
|
+
let services: ChainServiceCollectionV2
|
|
48
|
+
|
|
49
|
+
const setupStakingContract = async () => {
|
|
50
|
+
const ganacheProcess = await startGanache(ganachePort, testPhrase)
|
|
51
|
+
const sharedAccount = await HDWallet.fromPhrase(sharedAccountPhrase, "m/44'/60'/0'/0")
|
|
52
|
+
const walletPerson = await HDWallet.fromPhrase(testPhrase, "m/44'/60'/0'/0")
|
|
53
|
+
const account0 = await walletPerson.derivePath("m/44'/60'/0'/0/0")
|
|
54
|
+
const account1 = await walletPerson.derivePath("m/44'/60'/0'/0/1")
|
|
55
|
+
const erc20Address = await createTestErc20(ganachePort, testPhrase, account0)
|
|
56
|
+
await transferTestTokens(ganachePort, erc20Address, account0, account1)
|
|
57
|
+
const xyoChainContractAddress = await createTestChainContract(ganachePort, erc20Address, account0, sharedAccount)
|
|
58
|
+
await approveTestStakeChainAddress(ganachePort, erc20Address, xyoChainContractAddress, account0)
|
|
59
|
+
return [ganacheProcess, erc20Address, xyoChainContractAddress] as const
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const fundAndStakeBlockProducerAccount = async (blockProducerAccount: WalletInstance) => {
|
|
63
|
+
const walletPerson = await HDWallet.fromPhrase(testPhrase, "m/44'/60'/0'/0")
|
|
64
|
+
const account0 = await walletPerson.derivePath("m/44'/60'/0'/0/0")
|
|
65
|
+
const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)
|
|
66
|
+
const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)
|
|
67
|
+
await ethWalletPerson0.sendTransaction({ to: getAddress(blockProducerAccount.address), value: parseUnits('1', 18) })
|
|
68
|
+
await transferTestTokens(ganachePort, erc20Address, account0, blockProducerAccount)
|
|
69
|
+
await approveTestStakeChainAddress(ganachePort, erc20Address, xyoChainContractAddress, blockProducerAccount)
|
|
70
|
+
const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)
|
|
71
|
+
const ethWalletPerson1 = new Wallet(blockProducerAccount.privateKey, provider1)
|
|
72
|
+
const xyoChainPerson1 = await EvmChainService.create({ id: xyoChainContractAddress, runner: ethWalletPerson1 as ContractRunner })
|
|
73
|
+
expect(await xyoChainPerson1.addStake(await ethWalletPerson1.getAddress(), parseUnits('50', 18))).toBeTrue()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
beforeAll(async () => {
|
|
77
|
+
if (useGanache) {
|
|
78
|
+
[ganacheProcess, erc20Address, xyoChainContractAddress] = await setupStakingContract()
|
|
79
|
+
assertEx(asAddress(xyoChainContractAddress), () => 'Invalid contract address')
|
|
80
|
+
for (const blockProducerAccount of blockProducerAccounts) {
|
|
81
|
+
await fundAndStakeBlockProducerAccount(blockProducerAccount)
|
|
82
|
+
}
|
|
83
|
+
} else if (bootstrapMultiProducer) {
|
|
84
|
+
services = await initServices({ config: ConfigSchema.parse({}), logger: console })
|
|
85
|
+
blockProducerAccounts = await Promise.all(multiProducerSeedPhrases.map(async (phrase) => {
|
|
86
|
+
return await HDWallet.fromPhrase(phrase, "m/44'/60'/0'/0")
|
|
87
|
+
}))
|
|
88
|
+
} else {
|
|
89
|
+
services = await initServices({ config: ConfigSchema.parse({}), logger: console })
|
|
90
|
+
const { account } = services
|
|
91
|
+
blockProducerAccounts = [account]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const {
|
|
95
|
+
chainArchivist, chainIterator, chainSubmissionsArchivistWrite,
|
|
96
|
+
} = services
|
|
97
|
+
if (chainIterator) {
|
|
98
|
+
const [
|
|
99
|
+
firstBlock,
|
|
100
|
+
signedPayloads,
|
|
101
|
+
] = await createTestGenesisBlock(blockProducerAccounts)
|
|
102
|
+
const head = firstBlock
|
|
103
|
+
const firstBlockPayloads = flattenHydratedBlock([firstBlock, signedPayloads])
|
|
104
|
+
expect(head).toBeDefined()
|
|
105
|
+
expect(head.block).toBe(hexFromBigInt(0n))
|
|
106
|
+
// Insert all payloads from first block into chain archivist
|
|
107
|
+
await chainArchivist.insert(firstBlockPayloads)
|
|
108
|
+
await chainSubmissionsArchivistWrite.insert(firstBlockPayloads)
|
|
109
|
+
await chainIterator.updateHead(head)
|
|
110
|
+
// const pendingTransactionsArchivist = await MemoryArchivist.create({ account: 'random' })
|
|
111
|
+
// await pendingTransactionsArchivist.insert([firstBlock, ...signedStakedBlockProducerIntentsBws, ...signedStakedBlockProducerIntentsPayloads])
|
|
112
|
+
}
|
|
113
|
+
}, 120_000)
|
|
114
|
+
|
|
115
|
+
afterAll(async () => {
|
|
116
|
+
await delay(1000)
|
|
117
|
+
stopGanache(ganacheProcess)
|
|
118
|
+
}, 20_000)
|
|
119
|
+
|
|
120
|
+
it('producers show up as staked', async () => {
|
|
121
|
+
const { stakeIntentService } = services
|
|
122
|
+
await delay(1000)
|
|
123
|
+
const validStakedProducers = await stakeIntentService.getDeclaredCandidatesForBlock(0, 'producer')
|
|
124
|
+
expect(validStakedProducers).toBeArrayOfSize(blockProducerAccounts.length)
|
|
125
|
+
expect(validStakedProducers).toIncludeAllMembers(blockProducerAccounts.map(account => account.address))
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
describe('Stub', () => {
|
|
130
|
+
it('Stub', () => {
|
|
131
|
+
expect(true).toBeTrue()
|
|
132
|
+
})
|
|
133
|
+
})
|