Skip to content
Snippets Groups Projects
Commit b196e93b authored by Squirrel's avatar Squirrel Committed by GitHub
Browse files

Add Statemint Genesis Values (#817) (#905)


* Add Statemint Genesis Values (#817)

* add some docs to genesis scripts

* move statemint test chainspec

* add initial (draft) version of statemint chain spec

* adjust genesis value script

* add Statemint genesis Aura keys

* add bootnodes to statemint-genesis spec

* Add checks, debug and doc (#790)

* Add checks, debug and doc

* Update scripts/generate_genesis_value.sh

Co-authored-by: default avatarAlexander Popiak <alexander.popiak@parity.io>

* Update scripts/generate_genesis_value.sh

Co-authored-by: default avatarAlexander Popiak <alexander.popiak@parity.io>

Co-authored-by: default avatarAlexander Popiak <alexander.popiak@parity.io>

* default to official shell rpc endpoint for genesis values

* remove statemint test chain spec

* add Statemint chain spec and genesis values

* sort statemint genesis values

* some script docs adjustments

Co-authored-by: default avatarChevdor <chevdor@users.noreply.github.com>

* cargo fmt

Co-authored-by: default avatarAlexander Popiak <alexander.popiak@parity.io>
Co-authored-by: default avatarChevdor <chevdor@users.noreply.github.com>
parent d03ef1d5
No related merge requests found
This diff is collapsed.
This diff is collapsed.
[["0x15464cac3378d46f113cd5b7a4d71c84476f594316a7dfe49c1f352d95abdaf1","0x00000000"],["0x15464cac3378d46f113cd5b7a4d71c844e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x15464cac3378d46f113cd5b7a4d71c845579297f4dfb9609e7e4c2ebab9ce40a","0x104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3"],["0x15464cac3378d46f113cd5b7a4d71c84579f5a43435b04a98d64da0cefe18505","0x00a0acb9030000000000000000000000"],["0x1809d78346727a0ef58c0fa03bafa3234e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x267ada16405529c2f7ef2727d71edbde4e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x3a63","0x"],["0x3c311d57d4daf52904616cf69648081e4e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x3c311d57d4daf52904616cf69648081e5e0621c4869aa60c02be9adcc98a0d1d","0x104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3"],["0x3f1467a096bcd71a5b6a0c8155e208104e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x57f8dc2f5ab09467896f47300f0424384e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x57f8dc2f5ab09467896f47300f0424385e0621c4869aa60c02be9adcc98a0d1d","0x104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3"],["0x5e8a19e3cd1b7c148b33880c479c02814e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x682a59d51ab9e48a8c8cc418ff9708d24e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x7474449cca95dc5d0c00e71735a6d17d4e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0x7b3237373ffdfeb1cab4222e3b520d6b4e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0xc2261276cc9d1f8598ea4b6a74b15c2f308ce9615de0775a82f8a94dc3d285a1","0x01"],["0xc2261276cc9d1f8598ea4b6a74b15c2f4e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0xc2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80","0x00000000000000000000000000000000"],["0xcd5c1f6df63bc97f4a8ce37f14a50ca74e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0xcec5070d609dd3497f72bde07fc96ba04c014e6bf8b8c2c011e7290b85696bb30b1aeeca675702f24c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421","0x4c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421"],["0xcec5070d609dd3497f72bde07fc96ba04c014e6bf8b8c2c011e7290b85696bb314f6a7e973c2c34dc5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b762","0xc5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b762"],["0xcec5070d609dd3497f72bde07fc96ba04c014e6bf8b8c2c011e7290b85696bb34cb6fa5260704ee40b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3","0x0b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3"],["0xcec5070d609dd3497f72bde07fc96ba04c014e6bf8b8c2c011e7290b85696bb35242002c980f9df1c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811","0xc7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811"],["0xcec5070d609dd3497f72bde07fc96ba04e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0xcec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa19502fe5f80e8854f64761757261804c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421","0x4c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421"],["0xcec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa1950a3f059d7e690a34f6175726180c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811","0xc7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811"],["0xcec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa1950c41649dd3c9d26696175726180c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b762","0xc5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b762"],["0xcec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa1950fa571e62466b970561757261800b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3","0x0b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3"],["0xcec5070d609dd3497f72bde07fc96ba088dcde934c658227ee1dfafcd6e16903","0x104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3"],["0xcec5070d609dd3497f72bde07fc96ba0e0cdd062e6eaf24295ad4ccfc41d4609","0x104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d54214c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b762c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b30b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3"],["0xd57bce545fb382c34570e5dfbf338f5e4e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0xd5e1a2fa16732ce6906189438c0a82c64e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0xe38f185207498abb5c213d0fb059b3d84e7b9012096b41c4eb3aaf947f6ea429","0x0000"],["0xe38f185207498abb5c213d0fb059b3d86323ae84c43568be0d1394d5d0d522c4","0x02000000"],["0xf0c365c3cf59d671eb72da0e7a4113c44e7b9012096b41c4eb3aaf947f6ea429","0x0000"]]
\ No newline at end of file
0x0006908015464cac3378d46f113cd5b7a4d71c84476f594316a7dfe49c1f352d95abdaf110000000008015464cac3378d46f113cd5b7a4d71c844e7b9012096b41c4eb3aaf947f6ea4290800008015464cac3378d46f113cd5b7a4d71c845579297f4dfb9609e7e4c2ebab9ce40a0502104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b38015464cac3378d46f113cd5b7a4d71c84579f5a43435b04a98d64da0cefe185054000a0acb9030000000000000000000000801809d78346727a0ef58c0fa03bafa3234e7b9012096b41c4eb3aaf947f6ea42908000080267ada16405529c2f7ef2727d71edbde4e7b9012096b41c4eb3aaf947f6ea429080000083a6300803c311d57d4daf52904616cf69648081e4e7b9012096b41c4eb3aaf947f6ea429080000803c311d57d4daf52904616cf69648081e5e0621c4869aa60c02be9adcc98a0d1d0502104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3803f1467a096bcd71a5b6a0c8155e208104e7b9012096b41c4eb3aaf947f6ea4290800008057f8dc2f5ab09467896f47300f0424384e7b9012096b41c4eb3aaf947f6ea4290800008057f8dc2f5ab09467896f47300f0424385e0621c4869aa60c02be9adcc98a0d1d0502104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3805e8a19e3cd1b7c148b33880c479c02814e7b9012096b41c4eb3aaf947f6ea42908000080682a59d51ab9e48a8c8cc418ff9708d24e7b9012096b41c4eb3aaf947f6ea429080000807474449cca95dc5d0c00e71735a6d17d4e7b9012096b41c4eb3aaf947f6ea429080000807b3237373ffdfeb1cab4222e3b520d6b4e7b9012096b41c4eb3aaf947f6ea42908000080c2261276cc9d1f8598ea4b6a74b15c2f308ce9615de0775a82f8a94dc3d285a1040180c2261276cc9d1f8598ea4b6a74b15c2f4e7b9012096b41c4eb3aaf947f6ea42908000080c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80400000000000000000000000000000000080cd5c1f6df63bc97f4a8ce37f14a50ca74e7b9012096b41c4eb3aaf947f6ea4290800002101cec5070d609dd3497f72bde07fc96ba04c014e6bf8b8c2c011e7290b85696bb30b1aeeca675702f24c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421804c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d54212101cec5070d609dd3497f72bde07fc96ba04c014e6bf8b8c2c011e7290b85696bb314f6a7e973c2c34dc5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b76280c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7622101cec5070d609dd3497f72bde07fc96ba04c014e6bf8b8c2c011e7290b85696bb34cb6fa5260704ee40b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3800b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b32101cec5070d609dd3497f72bde07fc96ba04c014e6bf8b8c2c011e7290b85696bb35242002c980f9df1c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d781180c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d781180cec5070d609dd3497f72bde07fc96ba04e7b9012096b41c4eb3aaf947f6ea4290800003501cec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa19502fe5f80e8854f64761757261804c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421804c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d54213501cec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa1950a3f059d7e690a34f6175726180c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d781180c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d78113501cec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa1950c41649dd3c9d26696175726180c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b76280c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7623501cec5070d609dd3497f72bde07fc96ba0726380404683fc89e8233450c8aa1950fa571e62466b970561757261800b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3800b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b380cec5070d609dd3497f72bde07fc96ba088dcde934c658227ee1dfafcd6e169030502104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b380cec5070d609dd3497f72bde07fc96ba0e0cdd062e6eaf24295ad4ccfc41d46090504104c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d54214c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b762c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b7620b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b30b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b380d57bce545fb382c34570e5dfbf338f5e4e7b9012096b41c4eb3aaf947f6ea42908000080d5e1a2fa16732ce6906189438c0a82c64e7b9012096b41c4eb3aaf947f6ea42908000080e38f185207498abb5c213d0fb059b3d84e7b9012096b41c4eb3aaf947f6ea42908000080e38f185207498abb5c213d0fb059b3d86323ae84c43568be0d1394d5d0d522c4100200000080f0c365c3cf59d671eb72da0e7a4113c44e7b9012096b41c4eb3aaf947f6ea429080000
\ No newline at end of file
......@@ -355,6 +355,65 @@ pub fn statemint_local_config() -> StatemintChainSpec {
)
}
// Not used for syncing, but just to determine the genesis values set for the upgrade from shell.
pub fn statemint_config() -> StatemintChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
StatemintChainSpec::from_genesis(
// Name
"Statemint",
// ID
"statemint",
ChainType::Live,
move || {
statemint_genesis(
// initial collators.
vec![
(
hex!("4c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421")
.into(),
hex!("4c3d674d2a01060f0ded218e5dcc6f90c1726f43df79885eb3e22d97a20d5421")
.unchecked_into(),
),
(
hex!("c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811")
.into(),
hex!("c7d7d38d16bc23c6321152c50306212dc22c0efc04a2e52b5cccfc31ab3d7811")
.unchecked_into(),
),
(
hex!("c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b762")
.into(),
hex!("c5c07ba203d7375675f5c1ebe70f0a5bb729ae57b48bcc877fcc2ab21309b762")
.unchecked_into(),
),
(
hex!("0b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3")
.into(),
hex!("0b2d0013fb974794bd7aa452465b567d48ef70373fe231a637c1fb7c547e85b3")
.unchecked_into(),
),
],
vec![],
1000u32.into(),
)
},
vec![
"/ip4/34.65.251.121/tcp/30334/p2p/12D3KooWG3GrM6XKMM4gp3cvemdwUvu96ziYoJmqmetLZBXE8bSa".parse().unwrap(),
"/ip4/34.65.35.228/tcp/30334/p2p/12D3KooWMRyTLrCEPcAQD6c4EnudL3vVzg9zji3whvsMYPUYevpq".parse().unwrap(),
"/ip4/34.83.247.146/tcp/30334/p2p/12D3KooWE4jFh5FpJDkWVZhnWtFnbSqRhdjvC7Dp9b8b3FTuubQC".parse().unwrap(),
"/ip4/104.199.117.230/tcp/30334/p2p/12D3KooWG9R8pVXKumVo2rdkeVD4j5PVhRTqmYgLHY3a4yPYgLqM".parse().unwrap(),
],
None,
None,
None,
Some(properties),
Extensions { relay_chain: "polkadot".into(), para_id: 1000 },
)
}
fn statemint_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
......
......@@ -97,9 +97,17 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
&include_bytes!("../res/track.json")[..],
)?),
"shell" => Box::new(chain_spec::get_shell_chain_spec()),
// -- Statemint
"seedling" => Box::new(chain_spec::get_seedling_chain_spec()),
"statemint-dev" => Box::new(chain_spec::statemint_development_config()),
"statemint-local" => Box::new(chain_spec::statemint_local_config()),
// the chain spec as used for generating the upgrade genesis values
"statemint-genesis" => Box::new(chain_spec::statemint_config()),
// the shell-based chain spec as used for syncing
"statemint" => Box::new(chain_spec::ChainSpec::from_json_bytes(
&include_bytes!("../res/statemint.json")[..],
)?),
// -- Statemine
"statemine-dev" => Box::new(chain_spec::statemine_development_config()),
"statemine-local" => Box::new(chain_spec::statemine_local_config()),
// the chain spec as used for generating the upgrade genesis values
......@@ -108,6 +116,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
"statemine" => Box::new(chain_spec::ChainSpec::from_json_bytes(
&include_bytes!("../res/statemine.json")[..],
)?),
// -- Westmint
"westmint-dev" => Box::new(chain_spec::westmint_development_config()),
"westmint-local" => Box::new(chain_spec::westmint_local_config()),
// the chain spec as used for generating the upgrade genesis values
......
#!/usr/bin/env bash
# Call from the root of the repo as:
# ./scripts/generate_genesis_value.sh <chain-id> [rpc endpoint]
usage() {
echo Usage:
echo "$0 <chain-id>"
echo "$0 <chain-id> [rpc endpoint]"
exit 1
}
chain_spec_summary() {
if [ -f $chain_spec ]; then
echo -e "ℹ️ Using chain specs from" $chain_spec
echo -e " - name :" $(jq -r .name $chain_spec)
echo -e " - id :" $(jq -r .id $chain_spec)
echo -e " - type :" $(jq -r .chainType $chain_spec)
echo -e " - decimals :" $(jq -r .properties.tokenDecimals $chain_spec)
echo -e " - symbol :" $(jq -r .properties.tokenSymbol $chain_spec)
echo -e " - relay_chain :" $(jq -r .relay_chain $chain_spec)
echo -e " - para_id :" $(jq -r .para_id $chain_spec)
echo -e " - bootNodes :" $(jq '.bootNodes | length' $chain_spec)
echo
else
echo "❌ Chain specs not found from" $chain_spec
exit 1
fi
}
check_collator() {
BIN=target/release/polkadot-collator
if [ -f $BIN ]; then
echo "✅ Collator binary found:"
$BIN --version
else
echo "❌ Collator binary not found, exiting"
exit 1
fi
}
set -e
chain_id=$1
rpc_endpoint=$2
work_dir="polkadot-parachains/res"
chain_spec=$work_dir/$chain_id.json
chain_values=$work_dir/${chain_id}_values.json
chain_values_scale=$work_dir/${chain_id}_values.scale
[ -z "$chain_id" ] && usage
chain_spec_summary
pushd generate_genesis_values
if [ "$rpc_endpoint" == "" ]; then
# default connecting to the official rpc
rpc_endpoint='wss://statemint-shell.polkadot.io'
fi
if [[ "$rpc_endpoint" =~ "localhost" ]]; then
check_collator
echo -e "Make sure you have a collator running with the correct version at $rpc_endpoint."
echo -e "If you don't, NOW is the time to start it with:"
echo -e "target/release/polkadot-collator --chain polkadot-parachains/res/shell-statemint.json --tmp\n"
read -p "You can abort with CTRL+C if this is not correct, otherwise press ENTER "
fi
echo "Generating genesis values..."
pushd scripts/generate_genesis_values
yarn
popd
node generate_genesis_values ../polkadot-parachains/res/$chain_id.json ../polkadot-parachains/res/${chain_id}_genesis_values.json
node scripts/generate_genesis_values $chain_spec $chain_values
pushd scale_encode_genesis
echo "Scale encoding..."
pushd scripts/scale_encode_genesis
yarn
popd
node scale_encode_genesis ../polkadot-parachains/res/${chain_id}_genesis_values.json ${chain_id}_genesis_values.txt
node scripts/scale_encode_genesis $chain_values $chain_values_scale $rpc_endpoint
ls -al polkadot-parachains/res/${chain_id}_value*.*
......@@ -2,6 +2,10 @@ const fs = require("fs");
const { exit } = require("process");
const { xxhashAsHex } = require("@polkadot/util-crypto");
// Utility script scraping a chain spec for the genesis keys and values and writing them out as a
// json array of pairs. Filters the keys for anything already present in a shell runtime and sorts
// the output for reproducibility.
if (!process.argv[2] || !process.argv[3]) {
console.log("usage: node generate_keys <input chainspec> <output json>");
exit();
......@@ -49,6 +53,7 @@ fs.readFile(input, "utf8", (err, data) => {
Object.entries(spec.genesis.raw.top).filter(
([key, value]) => !startsWith(key, filter_prefixes)
);
genesis.sort();
fs.writeFileSync(output, JSON.stringify(genesis));
});
const fs = require("fs");
const { exit } = require("process");
const {WsProvider, ApiPromise} = require("@polkadot/api");
const { WsProvider, ApiPromise } = require("@polkadot/api");
const util = require("@polkadot/util");
async function connect(port, types) {
const provider = new WsProvider("ws://127.0.0.1:" + port);
// Utility script constructing a SCALE-encoded setStorage call from a key-value json array of
// genesis values by connecting to a running instance of the chain. (It is not required to be
// functional or synced.)
// connect to a substrate chain and return the api object
async function connect(endpoint, types = {}) {
const provider = new WsProvider(endpoint);
const api = await ApiPromise.create({
provider,
types,
......@@ -14,28 +19,37 @@ async function connect(port, types) {
}
if (!process.argv[2] || !process.argv[3]) {
console.log("usage: node generate_keys <input json> <scale output file>");
exit();
console.log("usage: node generate_keys <input json> <scale output file> [rpc enpoint]");
exit();
}
const input = process.argv[2];
const output = process.argv[3];
// default to localhost and the default Substrate port
const rpcEnpoint = process.argv[4] || "ws://localhost:9944";
console.log("Processing", input, output);
fs.readFile(input, "utf8", (err, data) => {
if (err) {
console.log(`Error reading file from disk: ${err}`);
exit(1);
}
if (err) {
console.log(`Error reading file from disk: ${err}`);
exit(1);
}
const genesis = JSON.parse(data);
const genesis = JSON.parse(data);
connect(9944, {}).then(api => {
const setStorage = api.tx.system.setStorage(genesis);
const raw = setStorage.method.toU8a();
const hex = util.u8aToHex(raw);
fs.writeFileSync(output, hex);
exit(0)
}).catch(e => {
console.error(e);
exit(1)
});
console.log("loaded genesis, length = ", genesis.length);
console.log(`Connecting to RPC endpoint: ${rpcEnpoint}`);
connect(rpcEnpoint)
.then((api) => {
console.log('Connected');
const setStorage = api.tx.system.setStorage(genesis);
const raw = setStorage.method.toU8a();
const hex = util.u8aToHex(raw);
fs.writeFileSync(output, hex);
exit(0);
})
.catch((e) => {
console.error(e);
exit(1);
});
});
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment