@xyo-network/xl1-cli-lib 1.14.1 → 1.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.mjs +255 -51
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/orchestration/actor/implementation/BalanceActor.d.ts +1 -1
- package/dist/node/orchestration/actor/implementation/BalanceActor.d.ts.map +1 -1
- package/dist/node/orchestration/actor/implementation/ProducerActor.d.ts +1 -1
- package/dist/node/orchestration/actor/implementation/ProducerActor.d.ts.map +1 -1
- package/dist/node/orchestration/actor/implementation/ValidatorActor.d.ts +1 -1
- package/dist/node/orchestration/actor/implementation/ValidatorActor.d.ts.map +1 -1
- package/dist/node/orchestration/archivists/lib/localPersistentArchivist.d.ts +1 -1
- package/dist/node/orchestration/archivists/lib/localPersistentArchivist.d.ts.map +1 -1
- package/dist/node/orchestration/initServices.d.ts.map +1 -1
- package/dist/node/orchestration/services/implementation/head/createBootstrapHead.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/head/createBootstrapHead.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/config/getBridgeDestinationDetails.d.ts +18 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/config/getBridgeDestinationDetails.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/config/getBridgeSourceDetails.d.ts +14 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/config/getBridgeSourceDetails.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/config/getForkDetails.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/config/getForkDetails.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/config/index.d.ts +4 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/config/index.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/createForkedHead.d.ts +5 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/createForkedHead.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getBridgeDestinationObservation.d.ts +10 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getBridgeDestinationObservation.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getBridgeIntent.d.ts +10 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getBridgeIntent.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getBridgeSourceObservation.d.ts +10 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getBridgeSourceObservation.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getFirstBlockForNewChain.d.ts +12 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/getFirstBlockForNewChain.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/index.d.ts +2 -0
- package/dist/node/orchestration/services/implementation/head/createForkedHead/index.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/getForkFromBlock.d.ts +12 -0
- package/dist/node/orchestration/services/implementation/head/getForkFromBlock.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/{head.d.ts → head/head.d.ts} +2 -1
- package/dist/node/orchestration/services/implementation/head/head.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/index.d.ts +2 -0
- package/dist/node/orchestration/services/implementation/head/index.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/head/submitNewChain.d.ts +10 -0
- package/dist/node/orchestration/services/implementation/head/submitNewChain.d.ts.map +1 -0
- package/dist/node/orchestration/services/implementation/index.d.ts +1 -1
- package/dist/node/orchestration/services/implementation/index.d.ts.map +1 -1
- package/dist/node/xl1.mjs +253 -49
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +13 -13
- package/src/orchestration/actor/implementation/BalanceActor.ts +2 -2
- package/src/orchestration/actor/implementation/ChainHeadUpdateActor.ts +2 -2
- package/src/orchestration/actor/implementation/ProducerActor.ts +4 -4
- package/src/orchestration/actor/implementation/ValidatorActor.ts +4 -4
- package/src/orchestration/actor/model/Actor.ts +2 -2
- package/src/orchestration/archivists/ChainFinalized/local.ts +1 -1
- package/src/orchestration/archivists/StakeIntentState/local.ts +1 -1
- package/src/orchestration/archivists/lib/localPersistentArchivist.ts +8 -1
- package/src/orchestration/initServices.ts +11 -7
- package/src/orchestration/services/implementation/head/createBootstrapHead.ts +8 -0
- package/src/orchestration/services/implementation/head/createForkedHead/config/getBridgeDestinationDetails.ts +27 -0
- package/src/orchestration/services/implementation/head/createForkedHead/config/getBridgeSourceDetails.ts +18 -0
- package/src/orchestration/services/implementation/head/createForkedHead/config/getForkDetails.ts +10 -0
- package/src/orchestration/services/implementation/head/createForkedHead/config/index.ts +3 -0
- package/src/orchestration/services/implementation/head/createForkedHead/createForkedHead.ts +31 -0
- package/src/orchestration/services/implementation/head/createForkedHead/getBridgeDestinationObservation.ts +38 -0
- package/src/orchestration/services/implementation/head/createForkedHead/getBridgeIntent.ts +50 -0
- package/src/orchestration/services/implementation/head/createForkedHead/getBridgeSourceObservation.ts +43 -0
- package/src/orchestration/services/implementation/head/createForkedHead/getFirstBlockForNewChain.ts +42 -0
- package/src/orchestration/services/implementation/head/createForkedHead/index.ts +1 -0
- package/src/orchestration/services/implementation/head/getForkFromBlock.ts +42 -0
- package/src/orchestration/services/implementation/head/head.ts +52 -0
- package/src/orchestration/services/implementation/head/index.ts +1 -0
- package/src/orchestration/services/implementation/head/submitNewChain.ts +27 -0
- package/src/orchestration/services/implementation/index.ts +1 -1
- package/src/spec/BootstrapChain.spec.ts +2 -2
- package/dist/node/orchestration/services/implementation/head.d.ts.map +0 -1
- package/src/orchestration/services/implementation/head.ts +0 -44
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { delay } from '@xylabs/delay'
|
|
2
|
+
import type { ArchivistInstance, WriteArchivist } from '@xyo-network/archivist-model'
|
|
3
|
+
import type { HydratedBlock } from '@xyo-network/xl1-protocol'
|
|
4
|
+
import { flattenHydratedBlock } from '@xyo-network/xl1-protocol-sdk'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Submit a new chain to the archivist.
|
|
8
|
+
* @param chain The new chain to submit
|
|
9
|
+
* @param chainArchivist The chain archivist instance
|
|
10
|
+
* @param chainSubmissionsArchivistWrite The chain submissions archivist instance
|
|
11
|
+
*/
|
|
12
|
+
export const submitNewChain = async (
|
|
13
|
+
chain: HydratedBlock[],
|
|
14
|
+
chainArchivist: ArchivistInstance,
|
|
15
|
+
chainSubmissionsArchivistWrite: WriteArchivist,
|
|
16
|
+
): Promise<void> => {
|
|
17
|
+
for (const block of chain) {
|
|
18
|
+
const [bw] = block
|
|
19
|
+
await chainSubmissionsArchivistWrite.insert(flattenHydratedBlock(block))
|
|
20
|
+
// Wait for block to show up in finalized archivist
|
|
21
|
+
while (true) {
|
|
22
|
+
const result = await chainArchivist.get([bw._hash])
|
|
23
|
+
if (result.length > 0) break
|
|
24
|
+
await delay(1000) // Wait 1 second before retrying
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -2,7 +2,7 @@ export * from './account.ts'
|
|
|
2
2
|
export * from './balance.ts'
|
|
3
3
|
export * from './chain/index.ts'
|
|
4
4
|
export * from './evm/index.ts'
|
|
5
|
-
export * from './head.ts'
|
|
5
|
+
export * from './head/index.ts'
|
|
6
6
|
export * from './iterator.ts'
|
|
7
7
|
export * from './pendingTransactions.ts'
|
|
8
8
|
export * from './producer.ts'
|
|
@@ -118,9 +118,9 @@ describe.sequential.skip('MultiProducer Network', () => {
|
|
|
118
118
|
}, 20_000)
|
|
119
119
|
|
|
120
120
|
it('producers show up as staked', async () => {
|
|
121
|
-
const {
|
|
121
|
+
const { stakeIntent } = services
|
|
122
122
|
await delay(1000)
|
|
123
|
-
const validStakedProducers = await
|
|
123
|
+
const validStakedProducers = await stakeIntent.getDeclaredCandidatesForBlock(0, 'producer')
|
|
124
124
|
expect(validStakedProducers).toBeArrayOfSize(blockProducerAccounts.length)
|
|
125
125
|
expect(validStakedProducers).toIncludeAllMembers(blockProducerAccounts.map(account => account.address))
|
|
126
126
|
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../../../../src/orchestration/services/implementation/head.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAErE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAsBjF,eAAO,MAAM,QAAQ,EAAE,aAAa,CAAC;IACnC,OAAO,EAAE,cAAc,CAAA;IACvB,cAAc,EAAE,iBAAiB,CAAA;IACjC,8BAA8B,EAAE,iBAAiB,CAAA;CAClD,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAUnC,CAAA"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { delay } from '@xylabs/delay'
|
|
2
|
-
import { ZERO_ADDRESS } from '@xylabs/hex'
|
|
3
|
-
import type { Promisable } from '@xylabs/promise'
|
|
4
|
-
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
5
|
-
import { createGenesisBlock, findMostRecentBlock } from '@xyo-network/chain-sdk'
|
|
6
|
-
import type { WithStorageMeta } from '@xyo-network/payload-model'
|
|
7
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
8
|
-
import type { BlockBoundWitness, Initializable } from '@xyo-network/xl1-protocol'
|
|
9
|
-
import { flattenHydratedBlock } from '@xyo-network/xl1-protocol-sdk'
|
|
10
|
-
|
|
11
|
-
let headSingleton: Promisable<WithStorageMeta<BlockBoundWitness>> | undefined
|
|
12
|
-
|
|
13
|
-
const createBootstrapHead = async (
|
|
14
|
-
chainSubmissionsArchivistWrite: ArchivistInstance,
|
|
15
|
-
chainArchivist: ArchivistInstance,
|
|
16
|
-
account: WalletInstance,
|
|
17
|
-
): Promise<WithStorageMeta<BlockBoundWitness>> => {
|
|
18
|
-
const block = await createGenesisBlock(account, ZERO_ADDRESS, 10_000_000n, account.address)
|
|
19
|
-
const [bw] = block
|
|
20
|
-
await chainSubmissionsArchivistWrite.insert(flattenHydratedBlock(block))
|
|
21
|
-
// Wait for block to show up in finalized archivist
|
|
22
|
-
while (true) {
|
|
23
|
-
const result = await chainArchivist.get([bw._hash])
|
|
24
|
-
if (result.length > 0) break
|
|
25
|
-
await delay(1000) // Wait 1 second before retrying
|
|
26
|
-
}
|
|
27
|
-
return bw
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const initHead: Initializable<{
|
|
31
|
-
account: WalletInstance
|
|
32
|
-
chainArchivist: ArchivistInstance
|
|
33
|
-
chainSubmissionsArchivistWrite: ArchivistInstance
|
|
34
|
-
}, WithStorageMeta<BlockBoundWitness>>
|
|
35
|
-
= async (params): Promise<WithStorageMeta<BlockBoundWitness>> => {
|
|
36
|
-
const {
|
|
37
|
-
account, chainArchivist, chainSubmissionsArchivistWrite,
|
|
38
|
-
} = params
|
|
39
|
-
if (headSingleton) return headSingleton
|
|
40
|
-
let head = await findMostRecentBlock(chainArchivist)
|
|
41
|
-
if (!head) head = await createBootstrapHead(chainSubmissionsArchivistWrite, chainArchivist, account)
|
|
42
|
-
headSingleton = head
|
|
43
|
-
return headSingleton
|
|
44
|
-
}
|