Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate People chain specs with Identity off-chain migration #2931

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
407d4d9
script done
NachoPal Sep 23, 2023
442976a
clean up + README
NachoPal Sep 25, 2023
5485501
get IdentityOf info
NachoPal Oct 9, 2023
7b65fd5
added identity migration file
NachoPal Oct 24, 2023
83479b8
discord migration done
NachoPal Oct 24, 2023
86ff8cd
ready
NachoPal Oct 25, 2023
5120076
ready
NachoPal Oct 25, 2023
7dc2f91
update README
NachoPal Oct 25, 2023
7835e5e
Merge branch 'master' into nacho/script-migrate-data-to-genesis
NachoPal Oct 25, 2023
e2db65b
rename riot to matrix
NachoPal Oct 25, 2023
664bd5c
Merge branch 'nacho/script-migrate-data-to-genesis' of github.com:par…
NachoPal Oct 25, 2023
cb442cf
Apply suggestions from code review
joepetrowski Nov 28, 2023
001400c
comments nits
NachoPal Dec 19, 2023
0dc630e
fix
NachoPal Dec 20, 2023
077510e
undo
NachoPal Dec 20, 2023
a3a8104
Merge branch 'master' into nacho/script-migrate-data-to-genesis
NachoPal Dec 20, 2023
69ebd35
set SubsOf deposit to 0
NachoPal Dec 20, 2023
cfb1322
Merge branch 'nacho/script-migrate-data-to-genesis' of github.com:par…
NachoPal Dec 20, 2023
ab1fcef
add Username
NachoPal Jan 5, 2024
a6b3a83
Bump workspace unified version
EgorPopelyaev Jan 10, 2024
3865fd8
Bump node version to 1.6.0 in polkadot-cli
EgorPopelyaev Jan 10, 2024
950a366
Bump crate versions in: cumulus/polkadot-parachain/Cargo.toml
EgorPopelyaev Jan 10, 2024
2e7cc70
Bump spec_version
EgorPopelyaev Jan 10, 2024
680adc7
Bump people spec_version
EgorPopelyaev Jan 11, 2024
fd14874
move prdoc files to the release folder
EgorPopelyaev Jan 12, 2024
7e86691
regenerate people-rococo base chain_spec
NachoPal Jan 15, 2024
a3e30c6
Merge branch 'nacho/script-migrate-data-to-genesis' into nacho/people…
NachoPal Jan 15, 2024
9091da1
recover lost chain_spec json
NachoPal Jan 15, 2024
1240928
Merge branch 'master' into nacho/people-chain-spec-with-migation
NachoPal Jan 15, 2024
feb7818
chain spec with off-chain migration done
NachoPal Jan 15, 2024
d2203c4
merge master
joepetrowski Jan 17, 2024
e078264
Merge branch 'master' into nacho/people-chain-spec-with-migation
NachoPal Jan 22, 2024
fca5044
people-westend chain_spec regenerated
NachoPal Jan 22, 2024
70606b1
Update cumulus/scripts/migrate_storage_to_genesis/index.js
NachoPal Jan 24, 2024
3e83c3d
Update cumulus/scripts/migrate_storage_to_genesis/README.md
NachoPal Jan 24, 2024
e115230
fix comments
NachoPal Jan 24, 2024
b0b45a7
Merge branch 'master' into nacho/people-chain-spec-with-migation
NachoPal Jan 24, 2024
dd57153
more fix comments
NachoPal Jan 24, 2024
956df13
merge marster
NachoPal Apr 5, 2024
2365851
Merge branch 'master' into nacho/people-chain-spec-with-migation
joepetrowski Apr 10, 2024
62d38aa
Merge branch 'master' into nacho/people-chain-spec-with-migation
NachoPal Apr 17, 2024
0887f9a
edit genesis people kusama
NachoPal Apr 18, 2024
0a47dc2
fix conflict
NachoPal Apr 29, 2024
d9c8753
People Chain migration: filter `FeePaid ` judgements (#4909)
muharem Jun 28, 2024
12f690e
Add scripts to generate people chain base chainspecs (#4910)
seadanda Jul 3, 2024
f4bfc3d
Add people-polkadot genesis chainspec
seadanda Jul 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 41 additions & 22 deletions cumulus/parachains/chain-specs/people-rococo.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 1_005_001,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 14,
Expand All @@ -124,7 +124,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 1_005_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 14,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("westmint"),
impl_name: create_runtime_str!("westmint"),
authoring_version: 1,
spec_version: 1_005_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 14,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bridge-hub-rococo"),
impl_name: create_runtime_str!("bridge-hub-rococo"),
authoring_version: 1,
spec_version: 1_005_002,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bridge-hub-westend"),
impl_name: create_runtime_str!("bridge-hub-westend"),
authoring_version: 1,
spec_version: 1_005_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("collectives-westend"),
impl_name: create_runtime_str!("collectives-westend"),
authoring_version: 1,
spec_version: 1_005_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("contracts-rococo"),
impl_name: create_runtime_str!("contracts-rococo"),
authoring_version: 1,
spec_version: 1_005_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("coretime-rococo"),
impl_name: create_runtime_str!("coretime-rococo"),
authoring_version: 1,
spec_version: 1_005_004,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("coretime-westend"),
impl_name: create_runtime_str!("coretime-westend"),
authoring_version: 1,
spec_version: 1_005_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("glutton-westend"),
impl_name: create_runtime_str!("glutton-westend"),
authoring_version: 1,
spec_version: 1_005_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("people-rococo"),
impl_name: create_runtime_str!("people-rococo"),
authoring_version: 1,
spec_version: 1_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("people-westend"),
impl_name: create_runtime_str!("people-westend"),
authoring_version: 1,
spec_version: 1_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("test-parachain"),
impl_name: create_runtime_str!("test-parachain"),
authoring_version: 1,
spec_version: 1_005_000,
spec_version: 1_006_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 6,
Expand Down
2 changes: 1 addition & 1 deletion cumulus/polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-parachain-bin"
version = "1.5.0"
version = "1.6.0"
authors.workspace = true
build = "build.rs"
edition.workspace = true
Expand Down
30 changes: 5 additions & 25 deletions cumulus/scripts/create_people_rococo_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,18 @@ cat chain-spec-plain.json | jq --rawfile code rt-hex.txt '.genesis.runtimeGenesi
| jq '.id = "people-rococo"' \
| jq '.chainType = "Live"' \
| jq '.bootNodes = [
"/dns/rococo-people-collator-node-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWDZg5jMYhKXTu6RU491V5sxsFnP4oaEmZJEUfcRkYzps5",
"/dns/rococo-people-collator-node-0.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWDZg5jMYhKXTu6RU491V5sxsFnP4oaEmZJEUfcRkYzps5",
"/dns/rococo-people-collator-node-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWGGR5i6qQqfo7iDNp7vjDRKPWuDk53idGV6nFLwS12X5H",
"/dns/rococo-people-collator-node-1.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWGGR5i6qQqfo7iDNp7vjDRKPWuDk53idGV6nFLwS12X5H",
"/dns/rococo-people-collator-node-2.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWBvA9BmBfrsVMcAcqVXGYFCpMTvkSk2igNXpmoareYbeT",
"/dns/rococo-people-collator-node-2.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWBvA9BmBfrsVMcAcqVXGYFCpMTvkSk2igNXpmoareYbeT",
"/dns/rococo-people-collator-node-3.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWQ7Q9jLcJTPXy7KEp5hSZ8YMY9pHx9CnQVz3T8TKQ81UG",
"/dns/rococo-people-collator-node-3.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWQ7Q9jLcJTPXy7KEp5hSZ8YMY9pHx9CnQVz3T8TKQ81UG"
"/dns/rococo-people-collator-node-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWDZg5jMYhKXTu6RU491V5sxsFnP4oaEmZJEUfcRkYzps5",
"/dns/rococo-people-collator-node-0.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWDZg5jMYhKXTu6RU491V5sxsFnP4oaEmZJEUfcRkYzps5",
"/dns/rococo-people-collator-node-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWGGR5i6qQqfo7iDNp7vjDRKPWuDk53idGV6nFLwS12X5H",
"/dns/rococo-people-collator-node-1.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWGGR5i6qQqfo7iDNp7vjDRKPWuDk53idGV6nFLwS12X5H"
]' \
| jq '.relay_chain = "rococo"' \
| jq --argjson para_id $para_id '.para_id = $para_id' \
| jq --argjson para_id $para_id '.genesis.runtimeGenesis.patch.parachainInfo.parachainId = $para_id' \
| jq '.genesis.runtimeGenesis.patch.balances.balances = []' \
| jq '.genesis.runtimeGenesis.patch.collatorSelection.invulnerables = [
"5Gnjmw1iuF2kV4PecFgetJed7B8quBKfLiRM99ELcXvFH9Vn",
"5FLZRxyeRPhG69zo4ZPqCJSYboSKaRBUjBvQc1nkuWoBpZ5P",
"5DNnmPH2MT6SXpfqbJZbTz4eERmuZegssfxc4ysL8PWrHaNN",
"5DkKcSP5MboNMpXScW1CyRqaktKMXH8QLP4Mn49TwS5vhL6k"
"5FLZRxyeRPhG69zo4ZPqCJSYboSKaRBUjBvQc1nkuWoBpZ5P"
]' \
| jq '.genesis.runtimeGenesis.patch.session.keys = [
[
Expand All @@ -74,20 +68,6 @@ cat chain-spec-plain.json | jq --rawfile code rt-hex.txt '.genesis.runtimeGenesi
{
"aura": "5FLZRxyeRPhG69zo4ZPqCJSYboSKaRBUjBvQc1nkuWoBpZ5P"
}
],
[
"5DNnmPH2MT6SXpfqbJZbTz4eERmuZegssfxc4ysL8PWrHaNN",
"5DNnmPH2MT6SXpfqbJZbTz4eERmuZegssfxc4ysL8PWrHaNN",
{
"aura": "5DNnmPH2MT6SXpfqbJZbTz4eERmuZegssfxc4ysL8PWrHaNN"
}
],
[
"5DkKcSP5MboNMpXScW1CyRqaktKMXH8QLP4Mn49TwS5vhL6k",
"5DkKcSP5MboNMpXScW1CyRqaktKMXH8QLP4Mn49TwS5vhL6k",
{
"aura": "5DkKcSP5MboNMpXScW1CyRqaktKMXH8QLP4Mn49TwS5vhL6k"
}
]
]' \
> edited-chain-spec-plain.json
Expand Down
13 changes: 13 additions & 0 deletions cumulus/scripts/migrate_storage_to_genesis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Migrate storage to genesis state
Script to query storage under a particular key and add it to a raw chain_spec json file as genesis state.

# How to use
The storage to be quired can be selected by either providing a pallet name or a key in hex format.
```
yarn migrate -c <wss_chain_enpoint> -f <chain_spec_raw_to_edit.json> -p <pallet_name> -k <storage_key> -m <js_migration_function_file>
```

Example for migrating `Identity` pallet from Polkadot:
```
yarn migrate -c wss://rpc.polkadot.io -f new_genesis_raw.json -p Identity -m ./identityMigration.js
```
108 changes: 108 additions & 0 deletions cumulus/scripts/migrate_storage_to_genesis/identityMigration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const { u8aToHex, hexToString } = require('@polkadot/util');
const { xxhashAsHex } = require('@polkadot/util-crypto');

const migrateIdentity = async (key, data, api) => {
// Register the new `Registration` format type
api.registry.register({
IdentityInfoNew: {
_fallback: 'IdentityInfoTo198',
display: 'Data',
legal: 'Data',
web: 'Data',
matrix: 'Data',
email: 'Data',
pgpFingerprint: 'Option<H160>',
image: 'Data',
twitter: 'Data',
github: 'Data',
discord: 'Data',
},
RegistrationNew: {
_fallback: 'RegistrationTo198',
judgements: 'Vec<RegistrationJudgement>',
deposit: 'Balance',
info: 'IdentityInfoNew'
},
Username: 'Vec<u8>',
});

// We want to migrate `IdentityOf` storage item
let IdentityOfkeyToMigrate = "IdentityOf";
let IdentityOfHexkeyToMigrate = xxhashAsHex(IdentityOfkeyToMigrate, 128);

// We want to migrate `SubsOf` storage item
let SubsOfkeyToMigrate = "SubsOf";
let SubsOfHexkeyToMigrate = xxhashAsHex(SubsOfkeyToMigrate, 128);

// We take the second half of the key, which is the storage item identifier
let storageItem = u8aToHex(key.toU8a().slice(18, 34));

// Migrate `IdentityOf` data to its new format
if (IdentityOfHexkeyToMigrate === storageItem) {
let decoded = api.createType('(Registration, Option<Username>)', data.toU8a(true));

// Default value for `discord` and `github` fields.
let discord = { none: null };
let github = { none: null };

// Get the `Registration` part from the `IdentityInfo` tuple
let decodedJson = decoded.toJSON()[0];

// Look for `Discord` and `Github` keys in `additional` field
decodedJson.info.additional.forEach(([key, data]) => {
let keyString = hexToString(key.raw)

if (keyString.toLowerCase() === "discord") {
discord = { raw: data.raw };
} else if (keyString.toLowerCase() === "github") {
github = { raw: data.raw };
}
});

// Migrate `IdentityInfo` data to the new format:
// - remove `additional` field
// - add `discord` field
// - add `github` field
// - set `deposit` to 0
let decodedNew = api.createType(
'(RegistrationNew, Option<Username>)',
[
{
judgements: decodedJson.judgements,
deposit: 0,
info: {
display: decodedJson.info.display,
legal: decodedJson.info.legal,
web: decodedJson.info.web,
matrix: decodedJson.info.riot,
email: decodedJson.info.email,
pgpFingerprint: decodedJson.info.pgpFingerprint,
image: decodedJson.info.image,
twitter: decodedJson.info.twitter,
github: github,
discord: discord,
}
},
null
]
);

data = decodedNew.toHex();

} else if (SubsOfHexkeyToMigrate === storageItem) {
let decoded = api.createType('(Balance, BoundedVec<AccountId, MaxApprovals>)', data.toU8a(true));

// Migrate `SubsOf` data:
// - set Deposit to 0
let decodedNew = api.createType(
'(Balance, BoundedVec<AccountId, MaxApprovals>)',
[0, decoded.toJSON()[1]]
);

data = decodedNew.toHex();
}

return data;
};

module.exports = migrateIdentity;
Loading
Loading