From f29fa91b09cd83bf8a5c135d3bfcb987013597f5 Mon Sep 17 00:00:00 2001 From: girazoki Date: Thu, 1 Feb 2024 12:17:01 +0100 Subject: [PATCH] Support for tanssi orchestrator and async backing pallets (#665) * support for tanssi orchestrator, and distinguish between container and orchestrator in configs * modify config files * add test for orchestrator * fix imports * pr reviews --- configs/{tanssi.yml => tanssi-container.yml} | 0 configs/tanssi-orchestrator.yml | 18 ++++++++++ .../parachain/nimbus-author-inherent.ts | 33 ++++++++++++++++--- packages/core/src/utils/index.ts | 1 + packages/e2e/src/author-inherent-mock.test.ts | 11 ++++++- 5 files changed, 58 insertions(+), 5 deletions(-) rename configs/{tanssi.yml => tanssi-container.yml} (100%) create mode 100644 configs/tanssi-orchestrator.yml 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 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..3b58f12c 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,9 @@ -import { GenericExtrinsic } from '@polkadot/types' -import { HexString } from '@polkadot/util/types' - 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' - // Support for Nimbus Author Inherent export class SetNimbusAuthorInherent implements InherentProvider { async createInherents(newBlock: Block, _params: BuildBlockParams): Promise { @@ -44,7 +42,34 @@ export class SetNimbusAuthorInherent implements InherentProvider { meta.registry.createType(`Vec<${accountType}>`, [alice]).toHex(), ) } + if (meta.query.authorityAssignment && meta.query.session) { + 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(), + ) + } 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 ] 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',