From a24af20c760d8577511b7fac131fe21d40669f88 Mon Sep 17 00:00:00 2001 From: tarikgul Date: Mon, 5 Aug 2024 12:45:51 -0400 Subject: [PATCH] Support for BeefyApi v4 --- packages/api-augment/src/substrate/runtime.ts | 26 ++++++++++++- .../types/src/interfaces/beefy/runtime.ts | 38 ++++++++++++++++--- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/packages/api-augment/src/substrate/runtime.ts b/packages/api-augment/src/substrate/runtime.ts index 66e3821f58c2..c37db184603e 100644 --- a/packages/api-augment/src/substrate/runtime.ts +++ b/packages/api-augment/src/substrate/runtime.ts @@ -10,6 +10,7 @@ import type { Bytes, Null, Option, Result, U64, Vec, bool, u128, u32 } from '@po import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types'; import type { TAssetBalance } from '@polkadot/types/interfaces/assets'; import type { BabeEquivocationProof, BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe'; +import type { ValidatorSet, ValidatorSetId } from '@polkadot/types/interfaces/beefy'; import type { CheckInherentsResult, InherentData } from '@polkadot/types/interfaces/blockbuilder'; import type { BlockHash } from '@polkadot/types/interfaces/chain'; import type { AuthorityId } from '@polkadot/types/interfaces/consensus'; @@ -28,7 +29,7 @@ import type { RuntimeVersion } from '@polkadot/types/interfaces/state'; import type { StatementStoreInvalidStatement, StatementStoreStatementSource, StatementStoreValidStatement } from '@polkadot/types/interfaces/statement'; import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces/system'; import type { TransactionSource, TransactionValidity } from '@polkadot/types/interfaces/txqueue'; -import type { SpStatementStoreStatement, StagingXcmV3MultiLocation } from '@polkadot/types/lookup'; +import type { SpConsensusBeefyDoubleVotingProof, SpStatementStoreStatement, StagingXcmV3MultiLocation } from '@polkadot/types/lookup'; import type { IExtrinsic, Observable } from '@polkadot/types/types'; export type __AugmentedCall = AugmentedCall; @@ -119,6 +120,29 @@ declare module '@polkadot/api-base/types/calls' { **/ [key: string]: DecoratedCallBase; }; + /** 0x49eaaf1b548a0cb0/4 */ + beefyApi: { + /** + * Return the block number where BEEFY consensus is enabled/started + **/ + beefyGenesis: AugmentedCall Observable>>; + /** + * Generates a proof of key ownership for the given authority in the given set. + **/ + generateKeyOwnershipProof: AugmentedCall Observable>>; + /** + * Submits an unsigned extrinsic to report a double voting equivocation. + **/ + submitReportDoubleVotingUnsignedExtrinsic: AugmentedCall Observable>>; + /** + * Return the current active BEEFY validator set + **/ + validatorSet: AugmentedCall Observable>>; + /** + * Generic call + **/ + [key: string]: DecoratedCallBase; + }; /** 0x40fe3ad401f8959a/6 */ blockBuilder: { /** diff --git a/packages/types/src/interfaces/beefy/runtime.ts b/packages/types/src/interfaces/beefy/runtime.ts index 207c5f92f53f..73c9fd61e277 100644 --- a/packages/types/src/interfaces/beefy/runtime.ts +++ b/packages/types/src/interfaces/beefy/runtime.ts @@ -3,7 +3,7 @@ import type { DefinitionCall, DefinitionsCall } from '../../types/index.js'; -const BEEFY_V1_V3: Record = { +const BEEFY_V3: Record = { beefy_genesis: { description: 'Return the block number where BEEFY consensus is enabled/started', params: [], @@ -23,6 +23,15 @@ const BEEFY_V1_V3: Record = { ], type: 'Option' }, + validator_set: { + description: 'Return the current active BEEFY validator set', + params: [], + type: 'Option' + } +}; + +const BEEFY_V1_V3: Record = { + ...BEEFY_V3, submit_report_equivocation_unsigned_extrinsic: { description: 'Submits an unsigned extrinsic to report an equivocation.', params: [ @@ -36,11 +45,24 @@ const BEEFY_V1_V3: Record = { } ], type: 'Option' - }, - validator_set: { - description: 'Return the current active BEEFY validator set', - params: [], - type: 'Option' + } +}; + +const BEEFY_V4: Record = { + ...BEEFY_V3, + submit_report_double_voting_unsigned_extrinsic: { + description: 'Submits an unsigned extrinsic to report a double voting equivocation.', + params: [ + { + name: 'equivocationProof', + type: 'SpConsensusBeefyDoubleVotingProof' + }, + { + name: 'keyOwnerProof', + type: 'OpaqueKeyOwnershipProof' + } + ], + type: 'Option' } }; @@ -59,6 +81,10 @@ const BEEFY_MMR_V1: Record = { export const runtime: DefinitionsCall = { BeefyApi: [ + { + methods: BEEFY_V4, + version: 4 + }, { methods: BEEFY_V1_V3, version: 3