Introduce compact version of CompactAssignments (#2483)

* Introduce compact version of CompactAssignments

* Rebuild interfaces, update tests
This commit is contained in:
Jaco Greeff
2020-08-11 13:43:24 +02:00
committed by GitHub
parent cb3816df78
commit 3c8cd499c4
11 changed files with 102 additions and 18 deletions
+1
View File
@@ -2,6 +2,7 @@
## 1.29.0-beta.x
- **Important** The Substrate `CompactAssignments` type has changed for better space utilization. On older chains, supply `CompactAssignments: 'CompactAssignmentsTo257'`
- Add additional `Fixed{I,U}{64,128}` and `{I,U}32F32` types
## 1.28.1 Aug 10, 2020
+9 -1
View File
@@ -20,6 +20,7 @@ const versioned: OverrideVersionedType[] = [
types: {
Address: 'GenericAddress',
BalanceLock: 'BalanceLockTo212',
CompactAssignments: 'CompactAssignmentsTo257',
DispatchError: 'DispatchErrorTo198',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
@@ -38,6 +39,7 @@ const versioned: OverrideVersionedType[] = [
types: {
Address: 'GenericAddress',
BalanceLock: 'BalanceLockTo212',
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
LookupSource: 'Address',
@@ -56,6 +58,7 @@ const versioned: OverrideVersionedType[] = [
types: {
Address: 'GenericAddress',
BalanceLock: 'BalanceLockTo212',
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Keys: 'SessionKeys5',
LookupSource: 'Address',
@@ -72,6 +75,7 @@ const versioned: OverrideVersionedType[] = [
types: {
// Indices optional, not in transaction
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
@@ -84,6 +88,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [1055, 1056],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
@@ -95,6 +100,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [1057, 1061],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
OpenTip: 'OpenTipTo225'
}
@@ -103,13 +109,15 @@ const versioned: OverrideVersionedType[] = [
minmax: [1062, 2012],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225'
}
},
{
minmax: [2013, undefined],
types: {
...sharedTypes
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257'
}
}
];
+3 -1
View File
@@ -19,13 +19,15 @@ const versioned: OverrideVersionedType[] = [
minmax: [0, 12],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225'
}
},
{
minmax: [13, undefined],
types: {
...sharedTypes
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257'
}
}
];
+2 -1
View File
@@ -14,7 +14,8 @@ const versioned: OverrideVersionedType[] = [
{
minmax: [0, undefined],
types: {
...sharedTypes
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257'
}
}
];
+4 -1
View File
@@ -18,6 +18,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [1, 2],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257',
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
Weight: 'u32'
@@ -27,13 +28,15 @@ const versioned: OverrideVersionedType[] = [
minmax: [3, 22],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225'
}
},
{
minmax: [23, undefined],
types: {
...sharedTypes
...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257'
}
}
];
+21 -6
View File
@@ -34,11 +34,11 @@ import { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/i
import { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import { RpcMethods } from '@polkadot/types/interfaces/rpc';
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H160, H256, H512, Hash, Header, I32F32, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H160, H256, H512, Hash, Header, I32F32, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, ValidatorCount } from '@polkadot/types/interfaces/session';
import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, OffchainAccuracy, PerU16, PhragmenScore, Points, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
import { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
import { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import { AccountInfo, ApplyExtrinsicResult, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount, TransactionValidityError, UnknownTransaction } from '@polkadot/types/interfaces/system';
@@ -153,6 +153,10 @@ declare module '@polkadot/types/types/registry' {
U32F32: U32F32;
'Option<U32F32>': Option<U32F32>;
'Vec<U32F32>': Vec<U32F32>;
PerU16: PerU16;
'Compact<PerU16>': Compact<PerU16>;
'Option<PerU16>': Option<PerU16>;
'Vec<PerU16>': Vec<PerU16>;
Perbill: Perbill;
'Compact<Perbill>': Compact<Perbill>;
'Option<Perbill>': Option<Perbill>;
@@ -915,9 +919,15 @@ declare module '@polkadot/types/types/registry' {
CompactAssignments: CompactAssignments;
'Option<CompactAssignments>': Option<CompactAssignments>;
'Vec<CompactAssignments>': Vec<CompactAssignments>;
CompactAssignmentsTo257: CompactAssignmentsTo257;
'Option<CompactAssignmentsTo257>': Option<CompactAssignmentsTo257>;
'Vec<CompactAssignmentsTo257>': Vec<CompactAssignmentsTo257>;
CompactScore: CompactScore;
'Option<CompactScore>': Option<CompactScore>;
'Vec<CompactScore>': Vec<CompactScore>;
CompactScoreCompact: CompactScoreCompact;
'Option<CompactScoreCompact>': Option<CompactScoreCompact>;
'Vec<CompactScoreCompact>': Vec<CompactScoreCompact>;
ElectionCompute: ElectionCompute;
'Option<ElectionCompute>': Option<ElectionCompute>;
'Vec<ElectionCompute>': Vec<ElectionCompute>;
@@ -965,13 +975,15 @@ declare module '@polkadot/types/types/registry' {
'Compact<NominatorIndex>': Compact<NominatorIndex>;
'Option<NominatorIndex>': Option<NominatorIndex>;
'Vec<NominatorIndex>': Vec<NominatorIndex>;
NominatorIndexCompact: NominatorIndexCompact;
'Option<NominatorIndexCompact>': Option<NominatorIndexCompact>;
'Vec<NominatorIndexCompact>': Vec<NominatorIndexCompact>;
OffchainAccuracy: OffchainAccuracy;
'Option<OffchainAccuracy>': Option<OffchainAccuracy>;
'Vec<OffchainAccuracy>': Vec<OffchainAccuracy>;
PerU16: PerU16;
'Compact<PerU16>': Compact<PerU16>;
'Option<PerU16>': Option<PerU16>;
'Vec<PerU16>': Vec<PerU16>;
OffchainAccuracyCompact: OffchainAccuracyCompact;
'Option<OffchainAccuracyCompact>': Option<OffchainAccuracyCompact>;
'Vec<OffchainAccuracyCompact>': Vec<OffchainAccuracyCompact>;
PhragmenScore: PhragmenScore;
'Option<PhragmenScore>': Option<PhragmenScore>;
'Vec<PhragmenScore>': Vec<PhragmenScore>;
@@ -1020,6 +1032,9 @@ declare module '@polkadot/types/types/registry' {
'Compact<ValidatorIndex>': Compact<ValidatorIndex>;
'Option<ValidatorIndex>': Option<ValidatorIndex>;
'Vec<ValidatorIndex>': Vec<ValidatorIndex>;
ValidatorIndexCompact: ValidatorIndexCompact;
'Option<ValidatorIndexCompact>': Option<ValidatorIndexCompact>;
'Vec<ValidatorIndexCompact>': Vec<ValidatorIndexCompact>;
ValidatorPrefs: ValidatorPrefs;
'Option<ValidatorPrefs>': Option<ValidatorPrefs>;
'Vec<ValidatorPrefs>': Vec<ValidatorPrefs>;
@@ -16,6 +16,7 @@ const numberTypes = {
FixedU128: 'UInt<128, FixedU128>',
I32F32: 'Int<64, I32F32>',
U32F32: 'UInt<64, U32F32>',
PerU16: 'u16',
Perbill: 'u32',
Percent: 'u8',
Permill: 'u32',
@@ -4,7 +4,7 @@
import { ITuple } from '@polkadot/types/types';
import { Compact, Enum, Int, Struct, U8aFixed, UInt, Vec } from '@polkadot/types/codec';
import { GenericAccountId, GenericAccountIndex, GenericAddress, GenericBlock, GenericCall, GenericConsensusEngineId } from '@polkadot/types/generic';
import { Bytes, DoNotConstruct, Null, StorageKey, u128, u32, u64, u8 } from '@polkadot/types/primitive';
import { Bytes, DoNotConstruct, Null, StorageKey, u128, u16, u32, u64, u8 } from '@polkadot/types/primitive';
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
import { Signature } from '@polkadot/types/interfaces/extrinsics';
@@ -178,6 +178,9 @@ export interface Permill extends u32 {}
/** @name Perquintill */
export interface Perquintill extends u64 {}
/** @name PerU16 */
export interface PerU16 extends u16 {}
/** @name Phantom */
export interface Phantom extends Null {}
File diff suppressed because one or more lines are too long
@@ -24,6 +24,24 @@ export default {
start: 'Option<Moment>'
},
CompactAssignments: {
votes1: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 0], ValidatorIndexCompact)>',
votes2: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 1], ValidatorIndexCompact)>',
votes3: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 2], ValidatorIndexCompact)>',
votes4: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 3], ValidatorIndexCompact)>',
votes5: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 4], ValidatorIndexCompact)>',
votes6: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 5], ValidatorIndexCompact)>',
votes7: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 6], ValidatorIndexCompact)>',
votes8: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 7], ValidatorIndexCompact)>',
votes9: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 8], ValidatorIndexCompact)>',
votes10: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 9], ValidatorIndexCompact)>',
votes11: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 10], ValidatorIndexCompact)>',
votes12: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 11], ValidatorIndexCompact)>',
votes13: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 12], ValidatorIndexCompact)>',
votes14: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 13], ValidatorIndexCompact)>',
votes15: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 14], ValidatorIndexCompact)>',
votes16: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 15], ValidatorIndexCompact)>'
},
CompactAssignmentsTo257: {
votes1: 'Vec<(NominatorIndex, [CompactScore; 0], ValidatorIndex)>',
votes2: 'Vec<(NominatorIndex, [CompactScore; 1], ValidatorIndex)>',
votes3: 'Vec<(NominatorIndex, [CompactScore; 2], ValidatorIndex)>',
@@ -42,6 +60,7 @@ export default {
votes16: 'Vec<(NominatorIndex, [CompactScore; 15], ValidatorIndex)>'
},
CompactScore: '(ValidatorIndex, OffchainAccuracy)',
CompactScoreCompact: '(ValidatorIndexCompact, OffchainAccuracyCompact)',
ElectionCompute: {
_enum: ['OnChain', 'Signed', 'Authority']
},
@@ -96,8 +115,9 @@ export default {
suppressed: 'bool'
},
NominatorIndex: 'u32',
NominatorIndexCompact: 'Compact<NominatorIndex>',
OffchainAccuracy: 'PerU16',
PerU16: 'u16',
OffchainAccuracyCompact: 'Compact<OffchainAccuracy>',
PhragmenScore: '[u128; 3]',
Points: 'u32',
RewardDestination: {
@@ -162,6 +182,7 @@ export default {
era: 'Compact<BlockNumber>'
},
ValidatorIndex: 'u16',
ValidatorIndexCompact: 'Compact<ValidatorIndex>',
ValidatorPrefs: {
commission: 'Compact<Perbill>'
},
+32 -3
View File
@@ -4,7 +4,7 @@
import { ITuple } from '@polkadot/types/types';
import { BTreeMap, Compact, Enum, Option, Struct, Vec } from '@polkadot/types/codec';
import { bool, u128, u16, u32 } from '@polkadot/types/primitive';
import { AccountId, Balance, BlockNumber, Moment, Perbill } from '@polkadot/types/interfaces/runtime';
import { AccountId, Balance, BlockNumber, Moment, PerU16, Perbill } from '@polkadot/types/interfaces/runtime';
/** @name ActiveEraInfo */
export interface ActiveEraInfo extends Struct {
@@ -14,6 +14,26 @@ export interface ActiveEraInfo extends Struct {
/** @name CompactAssignments */
export interface CompactAssignments extends Struct {
readonly votes1: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes2: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes3: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes4: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes5: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes6: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes7: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes8: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes9: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes10: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes11: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes12: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes13: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes14: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes15: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
readonly votes16: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
}
/** @name CompactAssignmentsTo257 */
export interface CompactAssignmentsTo257 extends Struct {
readonly votes1: Vec<ITuple<[NominatorIndex, Vec<CompactScore>, ValidatorIndex]>>;
readonly votes2: Vec<ITuple<[NominatorIndex, Vec<CompactScore>, ValidatorIndex]>>;
readonly votes3: Vec<ITuple<[NominatorIndex, Vec<CompactScore>, ValidatorIndex]>>;
@@ -35,6 +55,9 @@ export interface CompactAssignments extends Struct {
/** @name CompactScore */
export interface CompactScore extends ITuple<[ValidatorIndex, OffchainAccuracy]> {}
/** @name CompactScoreCompact */
export interface CompactScoreCompact extends ITuple<[ValidatorIndexCompact, OffchainAccuracyCompact]> {}
/** @name ElectionCompute */
export interface ElectionCompute extends Enum {
readonly isOnChain: boolean;
@@ -124,11 +147,14 @@ export interface Nominations extends Struct {
/** @name NominatorIndex */
export interface NominatorIndex extends u32 {}
/** @name NominatorIndexCompact */
export interface NominatorIndexCompact extends Compact<NominatorIndex> {}
/** @name OffchainAccuracy */
export interface OffchainAccuracy extends PerU16 {}
/** @name PerU16 */
export interface PerU16 extends u16 {}
/** @name OffchainAccuracyCompact */
export interface OffchainAccuracyCompact extends Compact<OffchainAccuracy> {}
/** @name PhragmenScore */
export interface PhragmenScore extends Vec<u128> {}
@@ -224,6 +250,9 @@ export interface UnlockChunk extends Struct {
/** @name ValidatorIndex */
export interface ValidatorIndex extends u16 {}
/** @name ValidatorIndexCompact */
export interface ValidatorIndexCompact extends Compact<ValidatorIndex> {}
/** @name ValidatorPrefs */
export interface ValidatorPrefs extends Struct {
readonly commission: Compact<Perbill>;