From b24a0bfc874d3368fb8cdbfeb43f14bd40c2002d Mon Sep 17 00:00:00 2001 From: girazoki Date: Thu, 1 Feb 2024 10:14:20 +0100 Subject: [PATCH 1/5] support for tanssi orchestrator, and distinguish between container and orchestrator in configs --- configs/tanssi_orchestrator.yml | 18 +++++++++++++ .../parachain/nimbus-author-inherent.ts | 26 ++++++++++++++++--- packages/core/src/utils/index.ts | 1 + 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 configs/tanssi_orchestrator.yml diff --git a/configs/tanssi_orchestrator.yml b/configs/tanssi_orchestrator.yml new file mode 100644 index 00000000..fe898619 --- /dev/null +++ b/configs/tanssi_orchestrator.yml @@ -0,0 +1,18 @@ +endpoint: wss://dancebox.tanssi-api.network +mock-signature-host: true +block: ${env.TANSSI_BLOCK_NUMBER} +db: ./tmp/db_mba.sqlite + +import-storage: + System: + Account: + - - - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + - providers: 1 + data: + free: "100000000000000000000000" + Sudo: + Key: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" + + Registrar: + registeredParaIds: [] + pendingParaIds: [] \ No newline at end of file diff --git a/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts b/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts index c8a4519c..5844c429 100644 --- a/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts +++ b/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts @@ -1,11 +1,12 @@ import { GenericExtrinsic } from '@polkadot/types' -import { HexString } from '@polkadot/util/types' +import { HexString, } from '@polkadot/util/types' +//import { u8aToHex } from '@polkadot/util' import { Block } from '../../block.js' import { BuildBlockParams } from '../../txpool.js' import { InherentProvider } from '../index.js' import { compactHex } from '../../../utils/index.js' - +import { hexToBigInt } from '@polkadot/util' // Support for Nimbus Author Inherent export class SetNimbusAuthorInherent implements InherentProvider { async createInherents(newBlock: Block, _params: BuildBlockParams): Promise { @@ -44,7 +45,26 @@ export class SetNimbusAuthorInherent implements InherentProvider { meta.registry.createType(`Vec<${accountType}>`, [alice]).toHex(), ) } - + if (meta.query.authorityAssignment && meta.query.session) { + const session = hexToBigInt(await newBlock.chain.head.get(compactHex(meta.query.session.currentIndex())), { isLe: true}); + // We need to set both the assignemnt for current and next sessions + layer.set( + compactHex(meta.query.authorityAssignment.collatorContainerChain(session)), + meta.registry.createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { + "orchestratorChain" : [alice], + }).toHex(), + ) + layer.set( + compactHex(meta.query.authorityAssignment.collatorContainerChain(session +1n)), + meta.registry.createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { + "orchestratorChain" : [alice], + }).toHex(), + ) + layer.set( + compactHex(meta.query.authorNoting.didSetContainerAuthorData()), + meta.registry.createType('bool', true).toHex(), + ) + } return [new GenericExtrinsic(meta.registry, meta.tx.authorInherent.kickOffAuthorshipValidation()).toHex()] } } diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts index 853b9635..9a4daf87 100644 --- a/packages/core/src/utils/index.ts +++ b/packages/core/src/utils/index.ts @@ -117,6 +117,7 @@ export const stripChildPrefix = (key: HexString) => { const POTENTIAL_SLOT_KEYS = [ '0x1cb6f36e027abb2091cfb5110ab5087f06155b3cd9a8c9e5e9a23fd5dc13a5ed', // babe.currentSlot '0x57f8dc2f5ab09467896f47300f04243806155b3cd9a8c9e5e9a23fd5dc13a5ed', // aura.currentSlot + '0x8985dff79e6002d0deba9ddac46f32a5a70806914c906d747e668a21f9021729', // asynchronousBacking.slotInfo '0xab2a8d5eca218f218c6fda6b1d22bb926bc171ab77f6a731a6e80c34ee1eda19', // authorInherent.highestSlotSeen ] From 0e563f3cb62d7b70d5be0672423d68e78cd9f902 Mon Sep 17 00:00:00 2001 From: girazoki Date: Thu, 1 Feb 2024 10:15:02 +0100 Subject: [PATCH 2/5] modify config files --- configs/{tanssi.yml => tanssi-container-yml} | 0 configs/{tanssi_orchestrator.yml => tanssi-orchestrator.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename configs/{tanssi.yml => tanssi-container-yml} (100%) rename configs/{tanssi_orchestrator.yml => tanssi-orchestrator.yml} (100%) diff --git a/configs/tanssi.yml b/configs/tanssi-container-yml similarity index 100% rename from configs/tanssi.yml rename to configs/tanssi-container-yml diff --git a/configs/tanssi_orchestrator.yml b/configs/tanssi-orchestrator.yml similarity index 100% rename from configs/tanssi_orchestrator.yml rename to configs/tanssi-orchestrator.yml From ca7bfe8838cba92fbe5f9c4cf4db780e9c1a2a29 Mon Sep 17 00:00:00 2001 From: girazoki Date: Thu, 1 Feb 2024 10:24:54 +0100 Subject: [PATCH 3/5] add test for orchestrator --- .../{tanssi-container-yml => tanssi-container.yml} | 0 packages/e2e/src/author-inherent-mock.test.ts | 11 ++++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) rename configs/{tanssi-container-yml => tanssi-container.yml} (100%) diff --git a/configs/tanssi-container-yml b/configs/tanssi-container.yml similarity index 100% rename from configs/tanssi-container-yml rename to configs/tanssi-container.yml diff --git a/packages/e2e/src/author-inherent-mock.test.ts b/packages/e2e/src/author-inherent-mock.test.ts index 17a204ef..9a03901f 100644 --- a/packages/e2e/src/author-inherent-mock.test.ts +++ b/packages/e2e/src/author-inherent-mock.test.ts @@ -11,7 +11,7 @@ describe.runIf(process.env.CI || process.env.RUN_ALL)('Nimbus author inherent mo await teardown() }) - it('Tanssi build blocks', async () => { + it('Tanssi container build blocks', async () => { const { dev, teardown } = await setupContext({ endpoint: 'wss://fraa-dancebox-3001-rpc.a.dancebox.tanssi.network', db: !process.env.RUN_TESTS_WITHOUT_DB ? 'e2e-tests-db.sqlite' : undefined, @@ -20,6 +20,15 @@ describe.runIf(process.env.CI || process.env.RUN_ALL)('Nimbus author inherent mo await teardown() }) + it('Tanssi orchestrator build blocks', async () => { + const { dev, teardown } = await setupContext({ + endpoint: 'wss://dancebox.tanssi-api.network', + db: !process.env.RUN_TESTS_WITHOUT_DB ? 'e2e-tests-db.sqlite' : undefined, + }) + await dev.newBlock({ count: 2 }) + await teardown() + }) + it('Moonbeam build blocks', async () => { const { dev, teardown } = await setupContext({ endpoint: 'wss://wss.api.moonbeam.network', From c47dc2eb2e5c8699b5d7118f9c19f6715b668774 Mon Sep 17 00:00:00 2001 From: girazoki Date: Thu, 1 Feb 2024 11:08:27 +0100 Subject: [PATCH 4/5] fix imports --- .../parachain/nimbus-author-inherent.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts b/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts index 5844c429..4029c45c 100644 --- a/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts +++ b/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts @@ -1,9 +1,7 @@ -import { GenericExtrinsic } from '@polkadot/types' -import { HexString, } from '@polkadot/util/types' -//import { u8aToHex } from '@polkadot/util' - import { Block } from '../../block.js' import { BuildBlockParams } from '../../txpool.js' +import { GenericExtrinsic } from '@polkadot/types' +import { HexString } from '@polkadot/util/types' import { InherentProvider } from '../index.js' import { compactHex } from '../../../utils/index.js' import { hexToBigInt } from '@polkadot/util' @@ -46,19 +44,25 @@ export class SetNimbusAuthorInherent implements InherentProvider { ) } if (meta.query.authorityAssignment && meta.query.session) { - const session = hexToBigInt(await newBlock.chain.head.get(compactHex(meta.query.session.currentIndex())), { isLe: true}); + const session = hexToBigInt(await newBlock.chain.head.get(compactHex(meta.query.session.currentIndex())), { + isLe: true, + }) // We need to set both the assignemnt for current and next sessions layer.set( compactHex(meta.query.authorityAssignment.collatorContainerChain(session)), - meta.registry.createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { - "orchestratorChain" : [alice], - }).toHex(), + meta.registry + .createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { + orchestratorChain: [alice], + }) + .toHex(), ) layer.set( - compactHex(meta.query.authorityAssignment.collatorContainerChain(session +1n)), - meta.registry.createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { - "orchestratorChain" : [alice], - }).toHex(), + compactHex(meta.query.authorityAssignment.collatorContainerChain(session + 1n)), + meta.registry + .createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { + orchestratorChain: [alice], + }) + .toHex(), ) layer.set( compactHex(meta.query.authorNoting.didSetContainerAuthorData()), From df3d78bbef533cffd2cfdc6460ae931d57e28bc7 Mon Sep 17 00:00:00 2001 From: girazoki Date: Thu, 1 Feb 2024 11:22:17 +0100 Subject: [PATCH 5/5] pr reviews --- .../parachain/nimbus-author-inherent.ts | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts b/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts index 4029c45c..3b58f12c 100644 --- a/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts +++ b/packages/core/src/blockchain/inherent/parachain/nimbus-author-inherent.ts @@ -4,7 +4,6 @@ import { GenericExtrinsic } from '@polkadot/types' import { HexString } from '@polkadot/util/types' import { InherentProvider } from '../index.js' import { compactHex } from '../../../utils/index.js' -import { hexToBigInt } from '@polkadot/util' // Support for Nimbus Author Inherent export class SetNimbusAuthorInherent implements InherentProvider { async createInherents(newBlock: Block, _params: BuildBlockParams): Promise { @@ -44,26 +43,28 @@ export class SetNimbusAuthorInherent implements InherentProvider { ) } if (meta.query.authorityAssignment && meta.query.session) { - const session = hexToBigInt(await newBlock.chain.head.get(compactHex(meta.query.session.currentIndex())), { - isLe: true, - }) - // We need to set both the assignemnt for current and next sessions - layer.set( - compactHex(meta.query.authorityAssignment.collatorContainerChain(session)), - meta.registry - .createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { - orchestratorChain: [alice], - }) - .toHex(), - ) - layer.set( - compactHex(meta.query.authorityAssignment.collatorContainerChain(session + 1n)), - meta.registry - .createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { - orchestratorChain: [alice], - }) - .toHex(), - ) + const session = await newBlock.chain.head.read('u32', meta.query.session.currentIndex) + + if (session) { + // We need to set both the assignemnt for current and next sessions + layer.set( + compactHex(meta.query.authorityAssignment.collatorContainerChain(session)), + meta.registry + .createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { + orchestratorChain: [alice], + }) + .toHex(), + ) + layer.set( + compactHex(meta.query.authorityAssignment.collatorContainerChain(session.toBigInt() + 1n)), + meta.registry + .createType(`DpCollatorAssignmentAssignedCollatorsPublic`, { + orchestratorChain: [alice], + }) + .toHex(), + ) + } + layer.set( compactHex(meta.query.authorNoting.didSetContainerAuthorData()), meta.registry.createType('bool', true).toHex(),