Skip to content

Commit 4b55f1b

Browse files
authored
Babe Equivocation (#2374)
* Babe Equivocation * metadata field rename to GrandpaEquivocationProof
1 parent f2a6776 commit 4b55f1b

File tree

8 files changed

+57
-33
lines changed

8 files changed

+57
-33
lines changed

packages/api/src/augment/tx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts';
99
import { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
1010
import { DefunctVoter, Renouncing } from '@polkadot/types/interfaces/elections';
1111
import { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
12-
import { EquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa';
12+
import { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa';
1313
import { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
1414
import { Heartbeat } from '@polkadot/types/interfaces/imOnline';
1515
import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, Perbill, Percent, ProxyType, Weight } from '@polkadot/types/interfaces/runtime';
@@ -878,7 +878,7 @@ declare module '@polkadot/api/types/submittable' {
878878
* submission of invalid equivocation reports, a mandatory pre-validation of
879879
* the extrinsic is implemented in a `SignedExtension`.
880880
**/
881-
reportEquivocation: AugmentedSubmittable<(equivocationProof: EquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
881+
reportEquivocation: AugmentedSubmittable<(equivocationProof: GrandpaEquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
882882
};
883883
identity: {
884884
[index: string]: SubmittableExtrinsicFunction<ApiType>;

packages/metadata/src/Metadata/v11/static-substrate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6391,7 +6391,7 @@
63916391
"args": [
63926392
{
63936393
"name": "equivocation_proof",
6394-
"type": "EquivocationProof"
6394+
"type": "GrandpaEquivocationProof"
63956395
},
63966396
{
63976397
"name": "key_owner_proof",

packages/types-known/src/modules.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { OverrideModuleType } from '@polkadot/types/types';
66

77
// type overrides for modules (where duplication between modules exist)
88
const typesModules: Record<string, OverrideModuleType> = {
9+
babe: {
10+
EquivocationProof: 'BabeEquivocationProof'
11+
},
912
balances: {
1013
Releases: 'ReleasesBalances',
1114
Status: 'BalanceStatus'
@@ -20,6 +23,10 @@ const typesModules: Record<string, OverrideModuleType> = {
2023
democracy: {
2124
Releases: 'ReleasesDemocracy'
2225
},
26+
grandpa: {
27+
Equivocation: 'GrandpaEquivocation',
28+
EquivocationProof: 'GrandpaEquivocationProof'
29+
},
2330
identity: {
2431
Judgement: 'IdentityJudgement'
2532
},

packages/types/src/augment/registry.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/t
77
import { RawAuraPreDigest } from '@polkadot/types/interfaces/aura';
88
import { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
99
import { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
10-
import { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
10+
import { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEquivocationProof, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
1111
import { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReleasesBalances, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
1212
import { BlockHash } from '@polkadot/types/interfaces/chain';
1313
import { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
@@ -21,7 +21,7 @@ import { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
2121
import { Account, Log, Vicinity } from '@polkadot/types/interfaces/evm';
2222
import { EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV1, ExtrinsicPayloadV2, ExtrinsicPayloadV3, ExtrinsicPayloadV4, ExtrinsicSignatureV1, ExtrinsicSignatureV2, ExtrinsicSignatureV3, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
2323
import { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
24-
import { AuthorityIndex, AuthorityList, AuthorityWeight, Equivocation, EquivocationProof, GrandpaEquivocation, GrandpaPrevote, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
24+
import { AuthorityIndex, AuthorityList, AuthorityWeight, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaPrevote, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
2525
import { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
2626
import { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
2727
import { CallMetadataV0, DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, DoubleMapTypeV8, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV8, ErrorMetadataV9, EventMetadataLatest, EventMetadataV0, EventMetadataV1, EventMetadataV10, EventMetadataV11, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, EventMetadataV8, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionArgumentMetadataV8, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, FunctionMetadataV8, FunctionMetadataV9, MapTypeLatest, MapTypeV0, MapTypeV10, MapTypeV11, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MapTypeV8, MapTypeV9, MetadataAll, MetadataLatest, MetadataV0, MetadataV1, MetadataV10, MetadataV11, MetadataV2, MetadataV3, MetadataV4, MetadataV5, MetadataV6, MetadataV7, MetadataV8, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleConstantMetadataV8, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV0, ModuleMetadataV1, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV2, ModuleMetadataV3, ModuleMetadataV4, ModuleMetadataV5, ModuleMetadataV6, ModuleMetadataV7, ModuleMetadataV8, ModuleMetadataV9, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeLatest, PlainTypeV0, PlainTypeV10, PlainTypeV11, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, PlainTypeV8, PlainTypeV9, RuntimeModuleMetadataV0, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV6, StorageEntryMetadataV7, StorageEntryMetadataV8, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV6, StorageEntryModifierV7, StorageEntryModifierV8, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV6, StorageEntryTypeV7, StorageEntryTypeV8, StorageEntryTypeV9, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionMetadataV2, StorageFunctionMetadataV3, StorageFunctionMetadataV4, StorageFunctionMetadataV5, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageFunctionTypeV2, StorageFunctionTypeV3, StorageFunctionTypeV4, StorageFunctionTypeV5, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV4, StorageHasherV5, StorageHasherV6, StorageHasherV7, StorageHasherV8, StorageHasherV9, StorageMetadataLatest, StorageMetadataV0, StorageMetadataV10, StorageMetadataV11, StorageMetadataV7, StorageMetadataV8, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
@@ -304,16 +304,19 @@ declare module '@polkadot/types/types/registry' {
304304
'Compact<BabeBlockWeight>': Compact<BabeBlockWeight>;
305305
'Option<BabeBlockWeight>': Option<BabeBlockWeight>;
306306
'Vec<BabeBlockWeight>': Vec<BabeBlockWeight>;
307+
BabeEquivocationProof: BabeEquivocationProof;
308+
'Option<BabeEquivocationProof>': Option<BabeEquivocationProof>;
309+
'Vec<BabeEquivocationProof>': Vec<BabeEquivocationProof>;
310+
BabeWeight: BabeWeight;
311+
'Compact<BabeWeight>': Compact<BabeWeight>;
312+
'Option<BabeWeight>': Option<BabeWeight>;
313+
'Vec<BabeWeight>': Vec<BabeWeight>;
307314
MaybeRandomness: MaybeRandomness;
308315
'Option<MaybeRandomness>': Option<MaybeRandomness>;
309316
'Vec<MaybeRandomness>': Vec<MaybeRandomness>;
310317
MaybeVrf: MaybeVrf;
311318
'Option<MaybeVrf>': Option<MaybeVrf>;
312319
'Vec<MaybeVrf>': Vec<MaybeVrf>;
313-
BabeWeight: BabeWeight;
314-
'Compact<BabeWeight>': Compact<BabeWeight>;
315-
'Option<BabeWeight>': Option<BabeWeight>;
316-
'Vec<BabeWeight>': Vec<BabeWeight>;
317320
EpochAuthorship: EpochAuthorship;
318321
'Option<EpochAuthorship>': Option<EpochAuthorship>;
319322
'Vec<EpochAuthorship>': Vec<EpochAuthorship>;
@@ -664,15 +667,15 @@ declare module '@polkadot/types/types/registry' {
664667
'Compact<AuthorityWeight>': Compact<AuthorityWeight>;
665668
'Option<AuthorityWeight>': Option<AuthorityWeight>;
666669
'Vec<AuthorityWeight>': Vec<AuthorityWeight>;
667-
Equivocation: Equivocation;
668-
'Option<Equivocation>': Option<Equivocation>;
669-
'Vec<Equivocation>': Vec<Equivocation>;
670-
EquivocationProof: EquivocationProof;
671-
'Option<EquivocationProof>': Option<EquivocationProof>;
672-
'Vec<EquivocationProof>': Vec<EquivocationProof>;
673670
GrandpaEquivocation: GrandpaEquivocation;
674671
'Option<GrandpaEquivocation>': Option<GrandpaEquivocation>;
675672
'Vec<GrandpaEquivocation>': Vec<GrandpaEquivocation>;
673+
GrandpaEquivocationProof: GrandpaEquivocationProof;
674+
'Option<GrandpaEquivocationProof>': Option<GrandpaEquivocationProof>;
675+
'Vec<GrandpaEquivocationProof>': Vec<GrandpaEquivocationProof>;
676+
GrandpaEquivocationValue: GrandpaEquivocationValue;
677+
'Option<GrandpaEquivocationValue>': Option<GrandpaEquivocationValue>;
678+
'Vec<GrandpaEquivocationValue>': Vec<GrandpaEquivocationValue>;
676679
GrandpaPrevote: GrandpaPrevote;
677680
'Option<GrandpaPrevote>': Option<GrandpaPrevote>;
678681
'Vec<GrandpaPrevote>': Vec<GrandpaPrevote>;

packages/types/src/interfaces/babe/definitions.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ export default {
2121
},
2222
BabeAuthorityWeight: 'u64',
2323
BabeBlockWeight: 'u32',
24+
BabeEquivocationProof: {
25+
offender: 'AuthorityId',
26+
slotNumber: 'SlotNumber',
27+
firstHeader: 'Header',
28+
secondHeader: 'Header'
29+
},
30+
BabeWeight: 'u64',
2431
MaybeRandomness: 'Option<Randomness>',
2532
MaybeVrf: 'Option<VrfData>',
26-
// TODO Remove as soon as merged and metadata static updated
27-
BabeWeight: 'u64',
2833
EpochAuthorship: {
2934
primary: 'Vec<u64>',
3035
secondary: 'Vec<u64>'

packages/types/src/interfaces/babe/types.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import { ITuple } from '@polkadot/types/types';
55
import { Enum, Option, Struct, U8aFixed, Vec } from '@polkadot/types/codec';
66
import { u32, u64 } from '@polkadot/types/primitive';
7-
import { Hash } from '@polkadot/types/interfaces/runtime';
7+
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
8+
import { Hash, Header } from '@polkadot/types/interfaces/runtime';
89

910
/** @name AllowedSlots */
1011
export interface AllowedSlots extends Enum {
@@ -19,6 +20,14 @@ export interface BabeAuthorityWeight extends u64 {}
1920
/** @name BabeBlockWeight */
2021
export interface BabeBlockWeight extends u32 {}
2122

23+
/** @name BabeEquivocationProof */
24+
export interface BabeEquivocationProof extends Struct {
25+
readonly offender: AuthorityId;
26+
readonly slotNumber: SlotNumber;
27+
readonly firstHeader: Header;
28+
readonly secondHeader: Header;
29+
}
30+
2231
/** @name BabeWeight */
2332
export interface BabeWeight extends u64 {}
2433

packages/types/src/interfaces/grandpa/definitions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ export default {
1919
AuthorityIndex: 'u64',
2020
AuthorityList: 'Vec<NextAuthority>',
2121
AuthorityWeight: 'u64',
22-
Equivocation: {
22+
GrandpaEquivocation: {
2323
_enum: {
24-
Prevote: 'GrandpaEquivocation',
25-
Precommit: 'GrandpaEquivocation'
24+
Prevote: 'GrandpaEquivocationValue',
25+
Precommit: 'GrandpaEquivocationValue'
2626
}
2727
},
28-
EquivocationProof: {
28+
GrandpaEquivocationProof: {
2929
setId: 'SetId',
30-
equivocation: 'Equivocation'
30+
equivocation: 'GrandpaEquivocation'
3131
},
32-
GrandpaEquivocation: {
32+
GrandpaEquivocationValue: {
3333
roundNumber: 'u64',
3434
identity: 'AuthorityId',
3535
first: '(GrandpaPrevote, AuthoritySignature)',

packages/types/src/interfaces/grandpa/types.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ export interface AuthorityList extends Vec<NextAuthority> {}
1818
/** @name AuthorityWeight */
1919
export interface AuthorityWeight extends u64 {}
2020

21-
/** @name Equivocation */
22-
export interface Equivocation extends Enum {
21+
/** @name GrandpaEquivocation */
22+
export interface GrandpaEquivocation extends Enum {
2323
readonly isPrevote: boolean;
24-
readonly asPrevote: GrandpaEquivocation;
24+
readonly asPrevote: GrandpaEquivocationValue;
2525
readonly isPrecommit: boolean;
26-
readonly asPrecommit: GrandpaEquivocation;
26+
readonly asPrecommit: GrandpaEquivocationValue;
2727
}
2828

29-
/** @name EquivocationProof */
30-
export interface EquivocationProof extends Struct {
29+
/** @name GrandpaEquivocationProof */
30+
export interface GrandpaEquivocationProof extends Struct {
3131
readonly setId: SetId;
32-
readonly equivocation: Equivocation;
32+
readonly equivocation: GrandpaEquivocation;
3333
}
3434

35-
/** @name GrandpaEquivocation */
36-
export interface GrandpaEquivocation extends Struct {
35+
/** @name GrandpaEquivocationValue */
36+
export interface GrandpaEquivocationValue extends Struct {
3737
readonly roundNumber: u64;
3838
readonly identity: AuthorityId;
3939
readonly first: ITuple<[GrandpaPrevote, AuthoritySignature]>;

0 commit comments

Comments
 (0)