From 3bf4e905e94c5db33f2b9a542bdcc59041330bff Mon Sep 17 00:00:00 2001 From: Jaco Date: Thu, 14 Jul 2022 13:03:15 +0200 Subject: [PATCH] BlockBuilder 2/3/4 & GrandpaApi 2 runtime interface definitions (#5067) --- CHANGELOG.md | 1 + .../src/interfaces/blockbuilder/runtime.ts | 75 ++++++++++++----- .../types/src/interfaces/grandpa/runtime.ts | 81 ++++++++++--------- 3 files changed, 103 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83ca60031c..ad6ae31507 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changes: - Add `derive.chain.subscribeFinalized{Heads, Blocks}` which returns all finalized, no skips - Support Moonbeam author extraction on `derive.chain.*` (w/ shared logic extraction) +- Ctarer for `BlockBuilder 2/3/4` & `GrandpaApi 2` runtime interface definitions ## 8.12.2 Jul 10, 2022 diff --git a/packages/types/src/interfaces/blockbuilder/runtime.ts b/packages/types/src/interfaces/blockbuilder/runtime.ts index 72341c6e11..9ca8d6ca1a 100644 --- a/packages/types/src/interfaces/blockbuilder/runtime.ts +++ b/packages/types/src/interfaces/blockbuilder/runtime.ts @@ -5,7 +5,29 @@ import type { DefinitionsCall, DefinitionsCallEntry } from '../../types'; import { objectSpread } from '@polkadot/util'; -const BB_V5_TO_V6: DefinitionsCallEntry['methods'] = { +const BB_V2_TO_V4: DefinitionsCallEntry['methods'] = { + // this was removed after V4 + random_seed: { + description: 'Generate a random seed.', + params: [], + type: 'Hash' + } +}; + +const BB_V2_TO_V5: DefinitionsCallEntry['methods'] = { + apply_extrinsic: { + description: 'Apply the given extrinsic.', + params: [ + { + name: 'extrinsic', + type: 'Extrinsic' + } + ], + type: 'ApplyExtrinsicResultPre6' + } +}; + +const BB_V2_TO_V6: DefinitionsCallEntry['methods'] = { check_inherents: { description: 'Check that the inherents are valid.', params: [ @@ -20,11 +42,6 @@ const BB_V5_TO_V6: DefinitionsCallEntry['methods'] = { ], type: 'CheckInherentsResult' }, - finalize_block: { - description: 'Finish the current block.', - params: [], - type: 'Header' - }, inherent_extrinsics: { description: 'Generate inherent extrinsics.', params: [ @@ -37,6 +54,15 @@ const BB_V5_TO_V6: DefinitionsCallEntry['methods'] = { } }; +const BB_V3_TO_V6: DefinitionsCallEntry['methods'] = { + // renamed in v3 from finalize_block + finalize_block: { + description: 'Finish the current block.', + params: [], + type: 'Header' + } +}; + export const runtime: DefinitionsCall = { BlockBuilder: [ { @@ -51,23 +77,36 @@ export const runtime: DefinitionsCall = { ], type: 'ApplyExtrinsicResult' } - }, BB_V5_TO_V6), + }, BB_V2_TO_V6, BB_V3_TO_V6), version: 6 }, { methods: objectSpread({ - apply_extrinsic: { - description: 'Apply the given extrinsic.', - params: [ - { - name: 'extrinsic', - type: 'Extrinsic' - } - ], - type: 'ApplyExtrinsicResultPre6' - } - }, BB_V5_TO_V6), + // apply_extrinsic result changed in 6 + }, BB_V2_TO_V5, BB_V2_TO_V6, BB_V3_TO_V6), version: 5 + }, + { + methods: objectSpread({ + // random_seed removed + }, BB_V2_TO_V4, BB_V2_TO_V5, BB_V2_TO_V6, BB_V3_TO_V6), + version: 4 + }, + { + methods: objectSpread({ + // finalize_block renamed + }, BB_V2_TO_V4, BB_V2_TO_V6, BB_V3_TO_V6), + version: 3 + }, + { + methods: objectSpread({ + finalise_block: { + description: 'Finish the current block.', + params: [], + type: 'Header' + } + }, BB_V2_TO_V4, BB_V2_TO_V6), + version: 2 } ] }; diff --git a/packages/types/src/interfaces/grandpa/runtime.ts b/packages/types/src/interfaces/grandpa/runtime.ts index ec400ebe21..615bb95f23 100644 --- a/packages/types/src/interfaces/grandpa/runtime.ts +++ b/packages/types/src/interfaces/grandpa/runtime.ts @@ -1,52 +1,61 @@ // Copyright 2017-2022 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { DefinitionsCall } from '../../types'; +import type { DefinitionsCall, DefinitionsCallEntry } from '../../types'; + +import { objectSpread } from '@polkadot/util'; + +const GRANDPA_V2_V3: DefinitionsCallEntry['methods'] = { + generate_key_ownership_proof: { + description: 'Generates a proof of key ownership for the given authority in the given set.', + params: [ + { + name: 'setId', + type: 'SetId' + }, + { + name: 'authorityId', + type: 'AuthorityId' + } + ], + type: 'Option' + }, + grandpa_authorities: { + description: 'Get the current GRANDPA authorities and weights. This should not change except for when changes are scheduled and the corresponding delay has passed.', + params: [], + type: 'AuthorityList' + }, + submit_report_equivocation_unsigned_extrinsic: { + description: 'Submits an unsigned extrinsic to report an equivocation.', + params: [ + { + name: 'equivocationProof', + type: 'GrandpaEquivocationProof' + }, + { + name: 'keyOwnerProof', + type: 'OpaqueKeyOwnershipProof' + } + ], + type: 'Option' + } +}; export const runtime: DefinitionsCall = { GrandpaApi: [ { - methods: { + methods: objectSpread({ current_set_id: { description: 'Get current GRANDPA authority set id.', params: [], type: 'SetId' - }, - generate_key_ownership_proof: { - description: 'Generates a proof of key ownership for the given authority in the given set.', - params: [ - { - name: 'setId', - type: 'SetId' - }, - { - name: 'authorityId', - type: 'AuthorityId' - } - ], - type: 'Option' - }, - grandpa_authorities: { - description: 'Get the current GRANDPA authorities and weights. This should not change except for when changes are scheduled and the corresponding delay has passed.', - params: [], - type: 'AuthorityList' - }, - submit_report_equivocation_unsigned_extrinsic: { - description: 'Submits an unsigned extrinsic to report an equivocation.', - params: [ - { - name: 'equivocationProof', - type: 'GrandpaEquivocationProof' - }, - { - name: 'keyOwnerProof', - type: 'OpaqueKeyOwnershipProof' - } - ], - type: 'Option' } - }, + }, GRANDPA_V2_V3), version: 3 + }, + { + methods: GRANDPA_V2_V3, + version: 2 } ] };