Cater for key definitions rework (#1269)

* Keys structure update

* Bump metadata, pull new keys

* Update for latest

* Update tests for new values

* Polkador session keys override

* Cleanup tests (browserlist adjustments)

* Update metadata

* Bump deps
This commit is contained in:
Jaco Greeff
2019-08-07 21:21:45 +02:00
committed by GitHub
parent 11e9ccba21
commit b2102d9a2b
17 changed files with 300 additions and 136 deletions
@@ -379,16 +379,38 @@
" Next epoch randomness."
]
},
{
"name": "SegmentIndex",
"modifier": "Default",
"type": {
"PlainType": "u32"
},
"fallback": "0x00000000",
"documentation": [
" Randomness under construction.",
"",
" We make a tradeoff between storage accesses and list length.",
" We store the under-construction randomness in segments of up to",
" `UNDER_CONSTRUCTION_SEGMENT_LENGTH`.",
"",
" Once a segment reaches this length, we begin the next one.",
" We reset all segments and return to `0` at the beginning of every",
" epoch."
]
},
{
"name": "UnderConstruction",
"modifier": "Default",
"type": {
"PlainType": "[u8;32]"
"MapType": {
"hasher": "Blake2_256",
"key": "u32",
"value": "Vec<[u8;32]>",
"isLinked": false
}
},
"fallback": "0x0000000000000000000000000000000000000000000000000000000000000000",
"documentation": [
" Randomness under construction."
]
"fallback": "0x00",
"documentation": []
}
]
},
@@ -1911,35 +1933,6 @@
" # </weight>"
]
},
{
"name": "emergency_propose",
"args": [
{
"name": "proposal",
"type": "Proposal"
},
{
"name": "threshold",
"type": "VoteThreshold"
},
{
"name": "voting_period",
"type": "BlockNumber"
},
{
"name": "delay",
"type": "BlockNumber"
}
],
"documentation": [
" Schedule an emergency referendum.",
"",
" This will create a new referendum for the `proposal`, approved as long as counted votes",
" exceed `threshold` and, if approved, enacted after the given `delay`.",
"",
" It may be called from either the Root or the Emergency origin."
]
},
{
"name": "emergency_cancel",
"args": [
@@ -1976,11 +1969,30 @@
],
"documentation": [
" Schedule a majority-carries referendum to be tabled next once it is legal to schedule",
" an external referendum."
" an external referendum.",
"",
" Unlike `external_propose`, blacklisting has no effect on this and it may replace a",
" pre-scheduled `external_propose` call."
]
},
{
"name": "external_push",
"name": "external_propose_default",
"args": [
{
"name": "proposal",
"type": "Proposal"
}
],
"documentation": [
" Schedule a negative-turnout-bias referendum to be tabled next once it is legal to",
" schedule an external referendum.",
"",
" Unlike `external_propose`, blacklisting has no effect on this and it may replace a",
" pre-scheduled `external_propose` call."
]
},
{
"name": "fast_track",
"args": [
{
"name": "proposal_hash",
@@ -2258,7 +2270,7 @@
{
"name": "CooloffPeriod",
"type": "BlockNumber",
"value": "0x8097060000000000",
"value": "0x0027060000000000",
"documentation": [
" Period in blocks where an external proposal may not be re-submitted after being vetoed."
]
@@ -3277,6 +3289,128 @@
}
]
},
{
"name": "TechnicalMembership",
"storage": {
"prefix": "Instance1Membership",
"items": [
{
"name": "Members",
"modifier": "Default",
"type": {
"PlainType": "Vec<AccountId>"
},
"fallback": "0x00",
"documentation": [
" The current membership, stored as an ordered Vec."
]
}
]
},
"calls": [
{
"name": "add_member",
"args": [
{
"name": "who",
"type": "AccountId"
}
],
"documentation": [
" Add a member `who` to the set.",
"",
" May only be called from `AddOrigin` or root."
]
},
{
"name": "remove_member",
"args": [
{
"name": "who",
"type": "AccountId"
}
],
"documentation": [
" Remove a member `who` from the set.",
"",
" May only be called from `RemoveOrigin` or root."
]
},
{
"name": "swap_member",
"args": [
{
"name": "remove",
"type": "AccountId"
},
{
"name": "add",
"type": "AccountId"
}
],
"documentation": [
" Swap out one member `remove` for another `add`.",
"",
" May only be called from `SwapOrigin` or root."
]
},
{
"name": "reset_members",
"args": [
{
"name": "members",
"type": "Vec<AccountId>"
}
],
"documentation": [
" Change the membership to a new set, disregarding the existing membership. Be nice and",
" pass `members` pre-sorted.",
"",
" May only be called from `ResetOrigin` or root."
]
}
],
"events": [
{
"name": "MemberAdded",
"args": [],
"documentation": [
" The given member was added; see the transaction for who."
]
},
{
"name": "MemberRemoved",
"args": [],
"documentation": [
" The given member was removed; see the transaction for who."
]
},
{
"name": "MembersSwapped",
"args": [],
"documentation": [
" Two members were swapped; see the transaction for who."
]
},
{
"name": "MembersReset",
"args": [],
"documentation": [
" The membership was reset; see the transaction for who the new set is."
]
},
{
"name": "Dummy",
"args": [
"PhantomData"
],
"documentation": [
" Phantom member, never used."
]
}
],
"constants": []
},
{
"name": "FinalityTracker",
"storage": null,
@@ -3824,35 +3958,6 @@
" If contract is not evicted as a result of this call, no actions are taken and",
" the sender is not eligible for the reward."
]
},
{
"name": "restore_to",
"args": [
{
"name": "dest",
"type": "AccountId"
},
{
"name": "code_hash",
"type": "CodeHash"
},
{
"name": "rent_allowance",
"type": "BalanceOf"
},
{
"name": "delta",
"type": "Vec<ContractStorageKey>"
}
],
"documentation": [
" Allows a contract to restore a tombstone by giving its storage.",
"",
" The contract that wants to restore (i.e. origin of the call, or `msg.sender` in Solidity terms) will compute a",
" tombstone with its storage and the given code_hash. If the computed tombstone",
" match the destination one, the destination contract is restored with the rent_allowance` specified,",
" while the origin sends all its funds to the destination and is removed."
]
}
],
"events": [
@@ -4158,16 +4263,20 @@
"PlainType": "BlockNumber"
},
"fallback": "0x0000000000000000",
"documentation": []
"documentation": [
" The block number when we should gossip."
]
},
{
"name": "LastNewEraStart",
"modifier": "Optional",
"name": "Keys",
"modifier": "Default",
"type": {
"PlainType": "SessionIndex"
"PlainType": "Vec<AuthorityId>"
},
"fallback": "0x00",
"documentation": []
"documentation": [
" The current set of keys that may issue a heartbeat."
]
},
{
"name": "ReceivedHeartbeats",
@@ -4176,13 +4285,16 @@
"DoubleMapType": {
"hasher": "Blake2_256",
"key1": "SessionIndex",
"key2": "AuthorityId",
"key2": "AuthIndex",
"value": "Bytes",
"key2Hasher": "Blake2_256"
}
},
"fallback": "0x00",
"documentation": []
"documentation": [
" For each session index we keep a mapping of `AuthorityId`",
" to `offchain::OpaqueNetworkState`."
]
}
]
},
@@ -4196,7 +4308,7 @@
},
{
"name": "_signature",
"type": "Bytes"
"type": "AuthoritySignature"
}
],
"documentation": []
@@ -4206,24 +4318,14 @@
{
"name": "HeartbeatReceived",
"args": [
"BlockNumber",
"AuthorityId"
],
"documentation": [
" A new heartbeat was received at this `BlockNumber` from `AuthorityId`"
" A new heartbeat was received from `AuthorityId`"
]
}
],
"constants": [
{
"name": "SessionsPerEra",
"type": "SessionIndex",
"value": "0x06000000",
"documentation": [
" Number of sessions per era."
]
}
]
"constants": []
}
]
}
File diff suppressed because one or more lines are too long
@@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeRegistry } from './typeRegistry';
import Struct from '../codec/Struct';
import Text from '../primitive/Text';
import U32 from '../primitive/U32';
@@ -58,9 +59,9 @@ describe('TypeRegistry', (): void => {
bar: 'testing'
});
expect(SomeStruct.name).toBe('Struct');
expect(struct.get('foo').toNumber()).toEqual(42);
expect(struct.get('bar').toString()).toEqual('testing');
expect(struct instanceof Struct).toBe(true);
expect(struct.foo.toNumber()).toEqual(42);
expect(struct.bar.toString()).toEqual('testing');
});
});
});
+19 -3
View File
@@ -2,9 +2,9 @@
import { Compact, Option, Vec } from './codec';
import { Bytes, Data, Fixed64, H160, H256, H512, Null, StorageData, StorageHasher, StorageKey, Text, Type, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from './primitive';
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, Consensus, ConsensusEngineId, Digest, DigestItem, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, Hash, Header, ImmortalEra, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Moment, MortalEra, Origin, Perbill, Permill, Phantom, PreRuntime, Seal, SealV0, Signature, SignedBlock, Sr25519Signature, ValidatorId, Weight, WeightMultiplier } from './interfaces/runtime';
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, Consensus, ConsensusEngineId, Digest, DigestItem, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, Hash, Header, ImmortalEra, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Moment, MortalEra, Origin, Perbill, Permill, Phantom, PhantomData, PreRuntime, Seal, SealV0, Signature, SignedBlock, Sr25519Signature, ValidatorId, Weight, WeightMultiplier } from './interfaces/runtime';
import { AuthorityId } from './interfaces/consensus';
import { Keys, SessionIndex } from './interfaces/session';
import { Keys, SessionIndex, SessionKeysPolkadot, SessionKeysSubstrate } from './interfaces/session';
import { AuthorityWeight, NextAuthority, PendingPause, PendingResume, StoredPendingChange, StoredState } from './interfaces/grandpa';
import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from './interfaces/elections';
import { InclusionHeight, Uncle, UncleEntryItem } from './interfaces/authorship';
@@ -15,7 +15,7 @@ import { AliveContractInfo, CodeHash, ContractInfo, ContractStorageKey, Gas, Pre
import { Conviction, PropIndex, Proposal, ReferendumIndex, ReferendumInfo } from './interfaces/democracy';
import { AccountInfo, Amount, AssetOf, InherentOfflineReport, LockPeriods, NewAccountOutcome, OpaqueKey, SessionKey } from './interfaces/deprecated';
import { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from './interfaces/genericAsset';
import { Heartbeat, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from './interfaces/imOnline';
import { AuthIndex, AuthoritySignature, Heartbeat, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from './interfaces/imOnline';
import { EraIndex, EraRewards, Exposure, IndividualExposure, MomentOf, RewardDestination, StakingLedger, UnlockChunk, ValidatorPrefs } from './interfaces/staking';
import { DigestOf, Event, EventId, EventIndex, EventRecord, EventRecord0to76, Key, Phase } from './interfaces/system';
import { TreasuryProposal } from './interfaces/treasury';
@@ -166,6 +166,9 @@ export interface InterfaceRegistry {
Phantom: Phantom;
'Option<Phantom>': Option<Phantom>;
'Vec<Phantom>': Vec<Phantom>;
PhantomData: PhantomData;
'Option<PhantomData>': Option<PhantomData>;
'Vec<PhantomData>': Vec<PhantomData>;
ValidatorId: ValidatorId;
'Option<ValidatorId>': Option<ValidatorId>;
'Vec<ValidatorId>': Vec<ValidatorId>;
@@ -250,6 +253,12 @@ export interface InterfaceRegistry {
'Compact<SessionIndex>': Compact<SessionIndex>;
'Option<SessionIndex>': Option<SessionIndex>;
'Vec<SessionIndex>': Vec<SessionIndex>;
SessionKeysSubstrate: SessionKeysSubstrate;
'Option<SessionKeysSubstrate>': Option<SessionKeysSubstrate>;
'Vec<SessionKeysSubstrate>': Vec<SessionKeysSubstrate>;
SessionKeysPolkadot: SessionKeysPolkadot;
'Option<SessionKeysPolkadot>': Option<SessionKeysPolkadot>;
'Vec<SessionKeysPolkadot>': Vec<SessionKeysPolkadot>;
Keys: Keys;
'Option<Keys>': Option<Keys>;
'Vec<Keys>': Vec<Keys>;
@@ -424,6 +433,13 @@ export interface InterfaceRegistry {
AssetOptions: AssetOptions;
'Option<AssetOptions>': Option<AssetOptions>;
'Vec<AssetOptions>': Vec<AssetOptions>;
AuthIndex: AuthIndex;
'Compact<AuthIndex>': Compact<AuthIndex>;
'Option<AuthIndex>': Option<AuthIndex>;
'Vec<AuthIndex>': Vec<AuthIndex>;
AuthoritySignature: AuthoritySignature;
'Option<AuthoritySignature>': Option<AuthoritySignature>;
'Vec<AuthoritySignature>': Vec<AuthoritySignature>;
OpaqueMultiaddr: OpaqueMultiaddr;
'Option<OpaqueMultiaddr>': Option<OpaqueMultiaddr>;
'Vec<OpaqueMultiaddr>': Vec<OpaqueMultiaddr>;
@@ -4,6 +4,8 @@
export default {
types: {
AuthIndex: 'u32',
AuthoritySignature: 'Signature',
OpaqueMultiaddr: 'Bytes',
OpaquePeerId: 'Bytes',
OpaqueNetworkState: {
@@ -1,11 +1,17 @@
// Auto-generated via `yarn build:interfaces`, do not edit
import { Struct, Vec } from '../../codec';
import { Bytes } from '../../primitive';
import { BlockNumber } from '../runtime';
import { Bytes, u32 } from '../../primitive';
import { BlockNumber, Signature } from '../runtime';
import { AuthorityId } from '../consensus';
import { SessionIndex } from '../session';
/** u32 */
export type AuthIndex = u32;
/** Signature */
export type AuthoritySignature = Signature;
/** Struct */
export interface Heartbeat extends Struct {
/** BlockNumber */
@@ -20,6 +20,7 @@ export default {
Perbill: 'u32',
Permill: 'u32',
Phantom: 'Null',
PhantomData: 'Null',
ValidatorId: 'AccountId',
Weight: 'u32',
WeightMultiplier: 'Fixed64',
@@ -111,6 +111,9 @@ export type Permill = u32;
/** Null */
export type Phantom = Null;
/** Null */
export type PhantomData = Null;
/** [ConsensusEngineId, Bytes] & Codec */
export type PreRuntime = [ConsensusEngineId, Bytes] & Codec;
@@ -5,10 +5,21 @@
export default {
types: {
SessionIndex: 'u32',
// node/runtime/src/lib.rs, impl_opaque_keys
Keys: {
ed25519: 'AccountId', // Grandpa, aka GrandpaId
sr25519: 'AccountId' // Babe, aka BabeId
}
// The runtime definition of SessionKeys are passes as a Trait to session
// Defined in `node/runtime/src/lib.rs` as follow
// impl_opaque_keys! {
// pub struct SessionKeys {
SessionKeysSubstrate: {
grandpa: 'AccountId', // aka GrandpaId
babe: 'AccountId', // aka BabeId
imOnline: 'AccountId' // aka ImOnlineId
},
SessionKeysPolkadot: {
grandpa: 'AccountId', // aka GrandpaId
babe: 'AccountId', // aka BabeId
imOnline: 'AccountId' // aka ImOnlineId
},
Keys: 'SessionKeysSubstrate'
}
};
+22 -7
View File
@@ -4,13 +4,28 @@ import { Struct } from '../../codec';
import { u32 } from '../../primitive';
import { AccountId } from '../runtime';
/** Struct */
export interface Keys extends Struct {
/** AccountId */
readonly ed25519: AccountId;
/** AccountId */
readonly sr25519: AccountId;
}
/** SessionKeysSubstrate */
export type Keys = SessionKeysSubstrate;
/** u32 */
export type SessionIndex = u32;
/** Struct */
export interface SessionKeysPolkadot extends Struct {
/** AccountId */
readonly grandpa: AccountId;
/** AccountId */
readonly babe: AccountId;
/** AccountId */
readonly imOnline: AccountId;
}
/** Struct */
export interface SessionKeysSubstrate extends Struct {
/** AccountId */
readonly grandpa: AccountId;
/** AccountId */
readonly babe: AccountId;
/** AccountId */
readonly imOnline: AccountId;
}
+4 -2
View File
@@ -65,7 +65,7 @@ export default class Type extends Text {
Type._alias('Lookup::Target', 'AccountId'),
// alias for grandpa, as used in polkadot
Type._alias('grandpa::AuthorityId', 'AuthorityId'),
// specific for SessionIndex (cvould make this session::, but be conservative)
// specific for SessionIndex (could make this session::, but be conservative)
Type._alias('session::SessionIndex', 'SessionIndex'),
// HACK duplication between contracts & primitives, however contracts prefixed with exec
Type._alias('exec::StorageKey', 'ContractStorageKey'),
@@ -223,7 +223,9 @@ export default class Type extends Text {
// replace `<...>::Type`
.replace(/::Type/g, '')
// replace `wasm::*` eg. `wasm::PrefabWasmModule`
.replace(/wasm::/g, '');
.replace(/wasm::/g, '')
// `sr_std::marker::`
.replace(/sr_std::marker::/g, '');
};
}
@@ -18,13 +18,9 @@ export default class Unconstructable extends Null {
throw new Error('Unconstructable should not be constructed, it is only a placeholder for compatibility');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public static with (typeDef: any): Constructor {
return class extends Null {
public constructor () {
super();
throw new Error(`Unable to construct ${JSON.stringify(typeDef)}`);
}
return class extends Unconstructable {
};
}
}