Skip to content

Commit 5a7811c

Browse files
authored
Bump metadata (#2058)
* Bump metadata * Add missing @types/jest * Update tests for new metadata * CHANGELOG for linked map removals * expand re-added check
1 parent 1c529bd commit 5a7811c

File tree

15 files changed

+314
-287
lines changed

15 files changed

+314
-287
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# 1.7.0-beta.x
22

3+
- **Important** Current versions of Polkadot/Substrate has dropped linked maps, if you are using these, e.g. `staking.{nominators,validators}()` to retrieve all entries, and using an upgraded chain, you need to swap to retrieving values via `.entries()`
4+
- Support latest Substrate types & metadata
35
- Add support for new Substrate `state_getKeysPaged` RPC
4-
- Re-add fixed (with tests) checks for query args
6+
- Re-add fixed (with tests) checks for query args, previously disabled in 1.6.2
57
- Move `derive.staking.controllers` to `derive.staking.stashes`, reflecting actual content
68
- Cater for adjusted storage (non-linked maps) for `derive.staking.stashes` (with old-compat)
79
- Expanded `derive.staking.*` derives, including addition of `derive.staking.own*`

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
"@babel/core": "^7.8.7",
2828
"@babel/register": "^7.8.6",
2929
"@babel/runtime": "^7.8.7",
30-
"@polkadot/dev": "^0.51.1",
31-
"@polkadot/ts": "^0.3.11",
30+
"@polkadot/dev": "^0.51.5",
31+
"@polkadot/ts": "^0.3.13",
3232
"@polkadot/typegen": "workspace:packages/typegen",
33+
"@types/jest": "^25.1.4",
3334
"copyfiles": "^2.2.0"
3435
}
3536
}

packages/api/src/augment/consts.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable @typescript-eslint/no-empty-interface */
33

44
import { Codec } from '@polkadot/types/types';
5-
import { Bytes, u32, u64 } from '@polkadot/types/primitive';
5+
import { u32, u64 } from '@polkadot/types/primitive';
66
import { Gas } from '@polkadot/types/interfaces/contracts';
77
import { Balance, BalanceOf, BlockNumber, Moment, Percent, Permill } from '@polkadot/types/interfaces/runtime';
88
import { SessionIndex } from '@polkadot/types/interfaces/session';
@@ -160,14 +160,6 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
160160
**/
161161
windowSize: AugmentedConst<BlockNumber>;
162162
};
163-
session: {
164-
[index: string]: AugmentedConst<object & Codec>;
165-
/**
166-
* Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch
167-
* of the trie.
168-
**/
169-
dedupKeyPrefix: AugmentedConst<Bytes>;
170-
};
171163
society: {
172164
[index: string]: AugmentedConst<object & Codec>;
173165
/**

packages/api/src/augment/query.ts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable @typescript-eslint/no-empty-interface */
33

44
import { AnyNumber, ITuple } from '@polkadot/types/types';
5-
import { Linkage, Option, U8aFixed, Vec } from '@polkadot/types/codec';
5+
import { Option, U8aFixed, Vec } from '@polkadot/types/codec';
66
import { Bytes, Data, bool, u32, u64 } from '@polkadot/types/primitive';
77
import { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
88
import { BabeAuthorityWeight, MaybeVrf } from '@polkadot/types/interfaces/babe';
@@ -21,7 +21,7 @@ import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, Hash, KeyType
2121
import { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
2222
import { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
2323
import { ActiveEraInfo, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReleasesStaking, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
24-
import { AccountInfo, DigestOf, EventIndex, EventRecord } from '@polkadot/types/interfaces/system';
24+
import { AccountInfo, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo } from '@polkadot/types/interfaces/system';
2525
import { OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
2626
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
2727
import { Multisig } from '@polkadot/types/interfaces/utility';
@@ -194,7 +194,7 @@ declare module '@polkadot/api/types/storage' {
194194
/**
195195
* Get the account (and lock periods) to which another account is delegating vote.
196196
**/
197-
delegations: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[ITuple<[AccountId, Conviction]>, Linkage<AccountId>]>>> & QueryableStorageEntry<ApiType>;
197+
delegations: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[AccountId, Conviction]>>> & QueryableStorageEntry<ApiType>;
198198
/**
199199
* Those who have locked a deposit.
200200
**/
@@ -289,7 +289,7 @@ declare module '@polkadot/api/types/storage' {
289289
/**
290290
* Votes of a particular voter, with the round index of the votes.
291291
**/
292-
votesOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[Vec<AccountId>, Linkage<AccountId>]>>> & QueryableStorageEntry<ApiType>;
292+
votesOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
293293
};
294294
grandpa: {
295295
[index: string]: QueryableStorageEntry<ApiType>;
@@ -313,7 +313,8 @@ declare module '@polkadot/api/types/storage' {
313313
**/
314314
pendingChange: AugmentedQuery<ApiType, () => Observable<Option<StoredPendingChange>>> & QueryableStorageEntry<ApiType>;
315315
/**
316-
* A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible.
316+
* A mapping from grandpa set ID to the index of the *most recent* session for which its
317+
* members were responsible.
317318
**/
318319
setIdSession: AugmentedQuery<ApiType, (arg: SetId | AnyNumber | Uint8Array) => Observable<Option<SessionIndex>>> & QueryableStorageEntry<ApiType>;
319320
/**
@@ -368,8 +369,8 @@ declare module '@polkadot/api/types/storage' {
368369
**/
369370
keys: AugmentedQuery<ApiType, () => Observable<Vec<AuthorityId>>> & QueryableStorageEntry<ApiType>;
370371
/**
371-
* For each session index, we keep a mapping of `AuthIndex`
372-
* to `offchain::OpaqueNetworkState`.
372+
* For each session index, we keep a mapping of `AuthIndex` to
373+
* `offchain::OpaqueNetworkState`.
373374
**/
374375
receivedHeartbeats: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: AuthIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>> & QueryableStorageEntry<ApiType>;
375376
};
@@ -437,17 +438,13 @@ declare module '@polkadot/api/types/storage' {
437438
**/
438439
disabledValidators: AugmentedQuery<ApiType, () => Observable<Vec<u32>>> & QueryableStorageEntry<ApiType>;
439440
/**
440-
* The owner of a key. The second key is the `KeyTypeId` + the encoded key.
441-
* The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of
442-
* the trie. Having all data in the same branch should prevent slowing down other queries.
441+
* The owner of a key. The key is the `KeyTypeId` + the encoded key.
443442
**/
444-
keyOwner: AugmentedQueryDoubleMap<ApiType, (key1: Bytes | string | Uint8Array, key2: ITuple<[KeyTypeId, Bytes]> | [KeyTypeId | AnyNumber | Uint8Array, Bytes | string | Uint8Array]) => Observable<Option<ValidatorId>>> & QueryableStorageEntry<ApiType>;
443+
keyOwner: AugmentedQuery<ApiType, (arg: ITuple<[KeyTypeId, Bytes]> | [KeyTypeId | AnyNumber | Uint8Array, Bytes | string | Uint8Array]) => Observable<Option<ValidatorId>>> & QueryableStorageEntry<ApiType>;
445444
/**
446445
* The next session keys for a validator.
447-
* The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of
448-
* the trie. Having all data in the same branch should prevent slowing down other queries.
449446
**/
450-
nextKeys: AugmentedQueryDoubleMap<ApiType, (key1: Bytes | string | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<Option<Keys>>> & QueryableStorageEntry<ApiType>;
447+
nextKeys: AugmentedQuery<ApiType, (arg: ValidatorId | string | Uint8Array) => Observable<Option<Keys>>> & QueryableStorageEntry<ApiType>;
451448
/**
452449
* True if the underlying economic identities or weighting behind the validators
453450
* has changed in the queued validator set.
@@ -580,6 +577,7 @@ declare module '@polkadot/api/types/storage' {
580577
* Clipped Exposure of validator at era.
581578
* This is similar to [`ErasStakers`] but number of nominators exposed is reduce to the
582579
* `T::MaxNominatorRewardedPerValidator` biggest stakers.
580+
* (Note: the field `total` and `own` of the exposure remains unchanged).
583581
* This is used to limit the i/o cost for the nominator payout.
584582
* This is keyed fist by the era index to allow bulk deletion and then the stash account.
585583
* Is it removed after `HISTORY_DEPTH` eras.
@@ -597,7 +595,7 @@ declare module '@polkadot/api/types/storage' {
597595
erasTotalStake: AugmentedQuery<ApiType, (arg: EraIndex | AnyNumber | Uint8Array) => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
598596
/**
599597
* Similarly to `ErasStakers` this holds the preferences of validators.
600-
* This is keyed fist by the era index to allow bulk deletion and then the stash account.
598+
* This is keyed first by the era index to allow bulk deletion and then the stash account.
601599
* Is it removed after `HISTORY_DEPTH` eras.
602600
**/
603601
erasValidatorPrefs: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>> & QueryableStorageEntry<ApiType>;
@@ -635,7 +633,7 @@ declare module '@polkadot/api/types/storage' {
635633
/**
636634
* The map from nominator stash key to the set of stash keys of all validators to nominate.
637635
**/
638-
nominators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[Option<Nominations>, Linkage<AccountId>]>>> & QueryableStorageEntry<ApiType>;
636+
nominators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Nominations>>> & QueryableStorageEntry<ApiType>;
639637
/**
640638
* All slashing events on nominators, mapped by era to the highest slash value of the era.
641639
**/
@@ -674,7 +672,7 @@ declare module '@polkadot/api/types/storage' {
674672
/**
675673
* The map from (wannabe) validator stash key to the preferences of that validator.
676674
**/
677-
validators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[ValidatorPrefs, Linkage<AccountId>]>>> & QueryableStorageEntry<ApiType>;
675+
validators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>> & QueryableStorageEntry<ApiType>;
678676
/**
679677
* All slashing events on validators, mapped by era to the highest slash proportion
680678
* and slash value of the era.
@@ -741,6 +739,10 @@ declare module '@polkadot/api/types/storage' {
741739
* Extrinsics root of the current block, also part of the block header.
742740
**/
743741
extrinsicsRoot: AugmentedQuery<ApiType, () => Observable<Hash>> & QueryableStorageEntry<ApiType>;
742+
/**
743+
* Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened.
744+
**/
745+
lastRuntimeUpgrade: AugmentedQuery<ApiType, () => Observable<Option<LastRuntimeUpgradeInfo>>> & QueryableStorageEntry<ApiType>;
744746
/**
745747
* The current block number being processed. Set by `execute_block`.
746748
**/
@@ -749,10 +751,6 @@ declare module '@polkadot/api/types/storage' {
749751
* Hash of the previous block.
750752
**/
751753
parentHash: AugmentedQuery<ApiType, () => Observable<Hash>> & QueryableStorageEntry<ApiType>;
752-
/**
753-
* A bool to track if the runtime was upgraded last block.
754-
**/
755-
runtimeUpgraded: AugmentedQuery<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
756754
};
757755
technicalCommittee: {
758756
[index: string]: QueryableStorageEntry<ApiType>;

packages/api/src/augment/tx.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@ declare module '@polkadot/api/types/submittable' {
12151215
* be the account that controls it.
12161216
* `value` must be more than the `minimum_balance` specified by `T::Currency`.
12171217
* The dispatch origin for this call must be _Signed_ by the stash account.
1218+
* Emits `Bonded`.
12181219
* # <weight>
12191220
* - Independent of the arguments. Moderate complexity.
12201221
* - O(1).
@@ -1231,6 +1232,7 @@ declare module '@polkadot/api/types/submittable' {
12311232
* Unlike [`bond`] or [`unbond`] this function does not impose any limitation on the amount
12321233
* that can be added.
12331234
* The dispatch origin for this call must be _Signed_ by the stash, not the controller.
1235+
* Emits `Bonded`.
12341236
* # <weight>
12351237
* - Independent of the arguments. Insignificant complexity.
12361238
* - O(1).
@@ -1300,7 +1302,10 @@ declare module '@polkadot/api/types/submittable' {
13001302
* - `who` is the controller account of the nominator to pay out.
13011303
* - `era` may not be lower than one following the most recently paid era. If it is higher,
13021304
* then it indicates an instruction to skip the payout of all previous eras.
1303-
* - `validators` is the list of all validators that `who` had exposure to during `era`.
1305+
* - `validators` is the list of all validators that `who` had exposure to during `era`,
1306+
* alongside the index of `who` in the clipped exposure of the validator.
1307+
* I.e. each element is a tuple of
1308+
* `(validator, index of `who` in clipped exposure of validator)`.
13041309
* If it is incomplete, then less than the full reward will be paid out.
13051310
* It must not exceed `MAX_NOMINATIONS`.
13061311
* WARNING: once an era is payed for a validator such validator can't claim the payout of
@@ -1392,6 +1397,7 @@ declare module '@polkadot/api/types/submittable' {
13921397
* can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need
13931398
* to be called first to remove some of the chunks (if possible).
13941399
* The dispatch origin for this call must be _Signed_ by the controller, not the stash.
1400+
* Emits `Unbonded`.
13951401
* See also [`Call::withdraw_unbonded`].
13961402
* # <weight>
13971403
* - Independent of the arguments. Limited but potentially exploitable complexity.
@@ -1420,6 +1426,7 @@ declare module '@polkadot/api/types/submittable' {
14201426
* This essentially frees up that balance to be used by the stash account to do
14211427
* whatever it wants.
14221428
* The dispatch origin for this call must be _Signed_ by the controller, not the stash.
1429+
* Emits `Withdrawn`.
14231430
* See also [`Call::unbond`].
14241431
* # <weight>
14251432
* - Could be dependent on the `origin` argument and how much `unlocking` chunks exist.
@@ -1481,6 +1488,7 @@ declare module '@polkadot/api/types/submittable' {
14811488
* Kill some items from storage.
14821489
**/
14831490
killStorage: AugmentedSubmittable<(keys: Vec<Key> | (Key | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
1491+
migrateAccounts: AugmentedSubmittable<(accounts: Vec<AccountId> | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
14841492
/**
14851493
* Make some on-chain remark.
14861494
**/

packages/api/src/util/validate.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,20 @@ describe('extractStorageArgs', (): void => {
8080
).toThrow('staking.erasStakers(EraIndex, AccountId) is a doublemap, requiring 2 arguments, 1 found');
8181
});
8282

83-
it('validates linked map, no args', (): void => {
83+
// Linked maps have been removed
84+
it.skip('validates linked map, no args', (): void => {
8485
expect(
8586
extractStorageArgs(storage.staking.validators, [])
8687
).toEqual([storage.staking.validators]);
8788
});
8889

89-
it('validates linked map, single arg', (): void => {
90+
it.skip('validates linked map, single arg', (): void => {
9091
expect(
9192
extractStorageArgs(storage.staking.validators, [123])
9293
).toEqual([storage.staking.validators, 123]);
9394
});
9495

95-
it('validates linked map (failing with extra args)', (): void => {
96+
it.skip('validates linked map (failing with extra args)', (): void => {
9697
expect(
9798
(): any[] =>
9899
extractStorageArgs(storage.staking.validators, [123, 456])

packages/metadata/src/Decorated/Decorated.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Decorated', () => {
1818
decorated.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
1919
)
2020
).toEqual(
21-
'0x010126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da92e3fb4c297a84c5cebc0e78257d213d0927ccc7596044c6ba013dd05522aacba'
21+
'0x410126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
2222
);
2323
});
2424

packages/metadata/src/Decorated/consts/fromMetadata/fromMetadata.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ describe('fromMetadata', (): void => {
1919
expect(consts.democracy.cooloffPeriod.toNumber()).toEqual(28 * 24 * 60 * (60 / 3));
2020
});
2121

22-
it('correctly handles bytes', (): void => {
22+
// removed from session
23+
it.skip('correctly handles bytes', (): void => {
2324
// 0x34 removes as the length prefix removed
2425
expect(consts.session.dedupKeyPrefix.toHex()).toEqual('0x3a73657373696f6e3a6b657973');
2526
});

packages/metadata/src/Decorated/storage/fromMetadata/fromMetadata.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ describe('fromMetadata', (): void => {
3131
decorated.query.system.account(keyring.alice.address)
3232
)
3333
).toEqual(
34-
// new storage key format
35-
'0x010126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da92e3fb4c297a84c5cebc0e78257d213d0927ccc7596044c6ba013dd05522aacba'
34+
'0x410126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
3635
);
3736
});
3837
});

0 commit comments

Comments
 (0)