mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-10-26 13:39:50 +00:00
cli: Command to fetch chainSpec and optimise its size (#1278)
* cli: Add chainSpec command Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli/chainSpec: Move to dedicated module Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Compute the state root hash Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Remove code substitutes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * artifacts: Update polkadot.json Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * scripts: Generate the chain spec Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Remove testing artifacts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Apply rustfmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Introduce feature flag for smoldot dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Rename chain-spec to chain-spec-pruning Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * scripts: Update chain-spec command Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
1 parent
7503977b6a
commit
06cfb211a9
8 files changed
+270
-46
No files matched your search
Generated
+2
@@ -4218,10 +4218,12 @@ dependencies = [
|
||||
"scale-value",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"smoldot",
|
||||
"subxt",
|
||||
"subxt-codegen",
|
||||
"subxt-metadata",
|
||||
"syn 2.0.37",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,47 +1,62 @@
|
||||
{
|
||||
"name": "Polkadot",
|
||||
"id": "polkadot",
|
||||
"chainType": "Live",
|
||||
"bootNodes": [
|
||||
"/dns/polkadot-connect-0.parity.io/tcp/443/wss/p2p/12D3KooWEPmjoRpDSUuiTjvyNDd8fejZ9eNWH5bE965nyBMDrB4o",
|
||||
"/dns/polkadot-connect-1.parity.io/tcp/443/wss/p2p/12D3KooWLvcA24g6sT9YTaQyinwowMbLF5z7iMLoxZpEiV9pSmNf",
|
||||
"/dns/polkadot-connect-2.parity.io/tcp/443/wss/p2p/12D3KooWDhp18HYzJuVX2jLhtjQgAhT1XWGqah42StoUJpkLvh2o",
|
||||
"/dns/polkadot-connect-3.parity.io/tcp/443/wss/p2p/12D3KooWEsPEadSjLAPyxckqVJkp54aVdPuX3DD6a1FTL2y5cB9x",
|
||||
"/dns/polkadot-connect-4.parity.io/tcp/443/wss/p2p/12D3KooWFfG1SQvcPoUK2N41cx7r52KYXKpRtZxfLZk8xtVzpp4d",
|
||||
"/dns/polkadot-connect-5.parity.io/tcp/443/wss/p2p/12D3KooWDmQPkBvQGg9wjBdFThtWj3QCDVQyHJ1apfWrHvjwbYS8",
|
||||
"/dns/polkadot-connect-6.parity.io/tcp/443/wss/p2p/12D3KooWBKtPpCnVTTzD7fPpCdFsrsYZ5K8fwmsLabb1JBuCycYs",
|
||||
"/dns/polkadot-connect-7.parity.io/tcp/443/wss/p2p/12D3KooWP3BsFY6UaiLjEJ3YbDp6q6SMQgAHB15qKj41DUZQLMqD",
|
||||
"/dns/p2p.0.polkadot.network/tcp/30333/p2p/12D3KooWHsvEicXjWWraktbZ4MQBizuyADQtuEGr3NbDvtm5rFA5",
|
||||
"/dns/p2p.1.polkadot.network/tcp/30333/p2p/12D3KooWQz2q2UWVCiy9cFX1hHYEmhSKQB2hjEZCccScHLGUPjcc",
|
||||
"/dns/p2p.2.polkadot.network/tcp/30333/p2p/12D3KooWNHxjYbDLLbDNZ2tq1kXgif5MSiLTUWJKcDdedKu4KaG8",
|
||||
"/dns/p2p.3.polkadot.network/tcp/30333/p2p/12D3KooWGJQysxrQcSvUWWNw88RkqYvJhH3ZcDpWJ8zrXKhLP5Vr",
|
||||
"/dns/p2p.4.polkadot.network/tcp/30333/p2p/12D3KooWKer8bYqpYjwurVABu13mkELpX2X7mSpEicpjShLeg7D6",
|
||||
"/dns/p2p.5.polkadot.network/tcp/30333/p2p/12D3KooWSRjL9LcEQd5u2fQTbyLxTEHq1tUFgQ6amXSp8Eu7TfKP",
|
||||
"/dns/cc1-0.parity.tech/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU",
|
||||
"/dns/cc1-1.parity.tech/tcp/30333/p2p/12D3KooWFN2mhgpkJsDBuNuE5427AcDrsib8EoqGMZmkxWwx3Md4"
|
||||
],
|
||||
"telemetryEndpoints": [
|
||||
[
|
||||
"wss://telemetry.polkadot.io/submit/",
|
||||
0
|
||||
]
|
||||
],
|
||||
"properties": {
|
||||
"ss58Format": 0,
|
||||
"tokenDecimals": 10,
|
||||
"tokenSymbol": "DOT"
|
||||
},
|
||||
"forkBlocks": null,
|
||||
"badBlocks": null,
|
||||
"consensusEngine": null,
|
||||
"genesis": {
|
||||
"stateRootHash": "0x29d0d972cd27cbc511e9589fcb7a4506d5eb6a9e8df205f00472e5ab354a4e17"
|
||||
},
|
||||
"lightSyncState": {
|
||||
"babeEpochChanges": "0x048edc0df46d8dd7b4d2976d124920bf94ab2bdd9058f837f3a502586a70d22ddbd24ddc0001733eaa1000000000d347aa1000000000049a41a36f474af1af3046324e211e0edba2f8cc50390dff82976981bbd67245db2957dc0001d347aa10000000003351aa10000000000486ce7842747897a71c3dd8462432fe113713580f11146d55ee881318f910e3797f60dc00013351aa1000000000935aaa100000000000000c86ce7842747897a71c3dd8462432fe113713580f11146d55ee881318f910e3797f60dc00019f170000000000003351aa10000000006009000000000000a50466f60202b962c40e58fcf3481f5773dc178b9fe096f81511eaa4c7bad20e612001000000000000009c40155989f6072e82caba245d7db7e40a60f866b403257976b89aba6be2b55b0100000000000000ee3b07c54f0d93945caa98d8deea125865e36dee14644453fb07176d4605bb2c010000000000000072ab87b654d80294c876cbefb534b3344c2f64159b015b89221331ec2145417501000000000000008e43fb54c6d8074ba65ddc6c1b9c54a9c9f0508ec939d5b1746ad2bc42069c600100000000000000e2782e5b1d9962dcb6c006b797af79017be14346a6c2086ff132776ee7e74f53010000000000000020352ba0565811731625a8001d26f5d899e5856dedd0f9c6bc3bec2995704e5b01000000000000004c9886e2e62ee92a6778d6a7928052732044b64fa61969cd8e37f3f7e3406f72010000000000000012f7e35aedc710f8335cc813db106f2a569c6224505416e33c241e625993a86a0100000000000000dceaa05fb95e70e99b9fcfa547a67d067b1ec24b1e795bcd739ff3fdf1c2c9160100000000000000002e496e564f088a075525d2f9155aadd1a7eb017fa36f9e16096e9db7e1693301000000000000006a49a129620f4318c4a99b69c28cbe5f94c7578bbce50bf2627c61590f68df750100000000000000f6dddaaaa53b57763610037753656b591d90fa81efbadcabbeddf7378c23602701000000000000009601c5f103f77e1cb78d4e03f2585320142cbb4fd6c5c37f21edbbb2d343eb560100000000000000466c0e97d043a4b0f4c3ac4849e11f901e9b31b28f8b3e40b7cdb0ba7f77480801000000000000002049288b4dbfb741109778c602f9308daf2e31b3b66e9aa550065e73c6787d7c0100000000000000e67c524e443cda4cd27dfcce70488a5d23a93c8c46a5e83ef5a69eff3a02fa5a0100000000000000ca4fb6a27ee4ba734e8e8caac9ed440170a99efe98af430a14a3eaa4b0d03d600100000000000000400c83c89f541c02338cf113c5a841d810bf3bf17c5c6e78efbd637059005f7001000000000000002e85d3d2c07aaf1c0a5f63f544c34b87cfa90a98c4f6167e86cee0b74a20cb1201000000000000007c5f58a83f8101943c089dba3ab906c07811e853444aa58dbcc986c4095fbe7c01000000000000005494142902284943201b7cf610306e8665eeeec87c014d607175c3f50f76103b01000000000000001822493200c35242a149070784dca5e7012a8a52b61cd218ec7d65e469e8cc560100000000000000dcf6d4dda860d902eb4acb8adff1116c637c12eb9d0633caa8fd0b65a30c8105010000000000000042e377034ce6b2a582bfd66c465252ab10ce790e4f0d3bbe99a42ff86b29965c010000000000000052e281ebf2cb6e1751a844d92574869e5a06e596bc41404de1fe55e99980dc6901000000000000004e2753547f6ec0a896bcbc55b9eeab875e8019acdeb10b979210af63f24c4b740100000000000000822467882ab8bd2cd75152843a948b3e56ae1da6aac9b66ac4cba1448217d8410100000000000000f63e0c859002c868d1e8bf7b36558b7b3f4a033f13850862ad643bc99628f335010000000000000090fd0815e122cc480aaa256b319405ab08f867d414dd59736bc81b7f054c59700100000000000000046c86bcf2260b9e862c5867def0e1a528c32e64ce0cb20d41bba00f30013a690100000000000000d416213c0b30df8f5aadf00642a4777dcea76b12836c51a98abcd133c78899470100000000000000ae831c0a4d22eeff12f679540c229029e321499477451768b8999b1191d6164801000000000000006ec27dfa7ac9d35eb002c55d3e4d56b4df928dd5c44323ac228305741c9e09360100000000000000b89cbc83a386d6f5d4fed93289ee50fdf69d77369ca0c9a8b962554e3fc0d37e0100000000000000e61da4eefdd14434952c58dd1943f7f63185d03321ccc8835e4216badd16fc19010000000000000078f66da37371586d480a8c4dcb2fc772c7c3c185961b5757169cb3b72c12436b0100000000000000a20797f3a8669a909adb22a3aee2844dba82d231cc33f5d9be0e2c533cb82a670100000000000000e297620b731b4958e3c6aa06611c6aa5a45f7e116362d64954a0a330d2a98f33010000000000000088c2166cef8e248c6dc7f801967f6c936b21ecff6f061035d9f95cbaabbcbb0f01000000000000005a7a6d3951924738f27fec8c0baa71a0f518a2d56d8289a1887d3d6805088c220100000000000000049e89e200ca2e92ee67afb644b216f3e99c8b4eaf26c1f0e42038850d0c617901000000000000004077191c8d78ed00c81b74788215db40d498f37252f9966f57e96c9d3f6af31701000000000000000ef6f09a9e310abb5c57dd7050a94d56d766772b80789b997cbb40f3b40f625d0100000000000000b25892ec76bcc88536409e440cb14f9de9589c4efe2b69608fff594885a2fe6501000000000000007cc03ffbfb187c1ea32cf4d25893238aae9073b2016084052a6defac64a7e36c01000000000000003af71b42b712323aa28fd7a2099c4f8b8071e3ed27c8a52ff2cdff5d1a5eb66b0100000000000000a88864a0dc9e292aa7cc8eddaa8dd8b6be2a4bc7e8f290023c6604e5c4ad1a7a0100000000000000dc68569b46a09aebabe8fc4452e293fac635e4a2889739809b32e4e2303e3f71010000000000000034ffee048e511f4187a6f40339650ec60a3d99ac5a1158ae162c5729b59d51740100000000000000be7c58318c49ff328d53a6d67830a8a046a41f5124824d3ce2e72cc9965ef57e0100000000000000a693f218033b3eb885bd2c7793227834d1ff3350c296e49aef3d8d801d5719750100000000000000b06e3ee1ea6420fb73ebd502988420f51b977a83074e1aa5daf0121f4a8b6b1e01000000000000003843abe933fa3ce63f3a5e422e13ec05dc9c0e8f150b93a0fa97f1b193cfba2d01000000000000009cdd57a06bd22d104d539527a19033620becff73dd267f0c2f9f13bc37b0d32c0100000000000000e020b5e946e4c6b0603ceac71b44c330fa7d9cb3e79791ebe1e16bedbb9c71000100000000000000a86c7bdf11794e554439b09f9f294c8e0aLine truncated
|
||||
"babeFinalizedBlockWeight": 3605523,
|
||||
"finalizedBlockHeader": "0x78835356007a3483eb5f099af463786e062e8513d025f5e8b326f2f05e8d040ed685710377e7b4ebd68adb7bbe2d509bf61eafb18fce581eb6a0411d161ceba9cc5d4c621806d6ca96d5ccabe0ec3cd1f047ee61015eb765fbc4ed735aaac976f243fa76080642414245b5010311000000cc48aa10000000004a79e7001b31b145320daed393d6e6f9a619bab04c27742be4477952fb46fc4c1b17fe2fa71fec279dcfbb9f234bfea251d8f715f76db1a0562bbbec80d43006ada682bb30d431003e91fba8dfb656396159aa4251a779b3f72c22c18bd4f501054241424501013cce6589582512ce47682b3b5365d7474caf6a6d75bfeb0dd96fe9d0b44aea308b1d8ffd8ce1ddc2f08a974382a154dea572ca87d333c99c5703c2ef1c7bcd8a",
|
||||
"grandpaAuthoritySet": "0xa5043866d53e02db8ff21ae934a03e06375ba5f3588bd444902794dde526fac2cae00100000000000000fff437ff18629bf1490e5c9b3ec6f1515d46bb9b2aeaa6e39e36611f2479b50d01000000000000006719dee0d6e25f2aabec94019e598524b205b514c1582e72fb9f1be3555300a5010000000000000047f940bc985355be7187c709ded2b689b66d69e61e293a507f1d4f90bdbeceee0100000000000000525c0460e98f5cda7d20e67ea1e27b3ca471760559baa73dcf77b2e163b957180100000000000000f98b21ab797ac19b101f8e446865564901dff29b4e0bbc5badcae7ac88dab7d80100000000000000b61e9b13e849779be8f5378a670d61991875d8e091f359384d7be73d02d50693010000000000000070ba6e5985990ba1b1392713236f1b50df750f10f744cc6eb95fa7c5cfbc687601000000000000005081c119ae99cfaacd677ac4eed05ce7d0d3f9af9e1caa58194564bedff73a480100000000000000b54a0bdc05bf5634a385ad79469726bd507dce50ff5e2e5f6132868fe9ced6af010000000000000057ae0c85ebaf333a6ec3251f577cab910cce072f238d1e50046322b83bbc0dd50100000000000000bdae4bc60b03f8fbc14299f0449301ef7f423a4cd15c6f6a35ea6a44fc5bcb0f01000000000000000139b946b46bee4c61be50c986f2a9ef2e76917644e2ecd842c59d61a94ee612010000000000000076aa25ab781816fdfabc9051149c3db958bc09d2e8f0e10a4d91e0df8c79ec9b010000000000000053352e16d2a27fb3525d5d8750d6ad7f46b303a45e434a409ac727d5cb80432b01000000000000008c54298c6f8704498112ecb24f64f7a28ed2289ec573620b0d1e5a9a44f5fa78010000000000000041ef4a31eb7dc1e01f4630604e1908e644d7cdee3f66a60f98d6d59605326f8b0100000000000000c4ab2451500e321f187140d3aeed09d5cdf67f09d9997b966c86dd74714233db010000000000000021acf715d75065242920f902a3490f2f9f3dbf5bae57a4a6fbc8ed3f805eb8620100000000000000049cb09a86d544249f9e11cf6c348bc0561600343ebee89d1c90bbef3d13e5170100000000000000d04d64a07f144638f20f081de122b88fed0cc8bda57e4810e7afb38036dd8bbf0100000000000000f26945a8a64032a1defa76e720a99649125b55751b6088205e7acab901de670b0100000000000000684768723f0efc2001562c3b2156b987601ae9431f8aaa6f4199649cba487aea01000000000000005ee4dbc4f6c4f07171eda6db4f331180ad4434b34f809071e958910df3252c8c01000000000000009b94bc45bf79bb33f70430c82880456cd7bd5fb3ea131c1b26d493d01c5fe7100100000000000000d7e8ce7ff46c836473acb0c3016feab586b5c4a6b529f7cedef01c6727dbbcf601000000000000006f4855725ebb9eced957bae43ffa7d30657ce7d06b251ce20e2218bcf929e4050100000000000000f2f0f84855c6bce35c42d537fb4022662272203cc4985767ad4ef8ef1bbb716501000000000000008376e5e1a7b6eac21e3e9f9e133f89ed0053b5559376a97e58896653725c502d0100000000000000ff0bf39c82ed573d48585448b0fc19ba3f6203806cb6b4a230848892c097a26f01000000000000009c27510363c46fb84c22765901302fa26af266da5a22099368fce05562ce97eb01000000000000003478e6a5b64e3aaaa6795e6536a12728a20af7a8d44c75f5e981c6d2aee4517701000000000000003b252801bf8a2f4797699a0d95e8fad8c8fb42cf6f6a33f4555bde1c7fefd4490100000000000000c1c1ff5f66fefb5c0849e3b2333411d1f7e9dd4888600e334e7a33623f15fa360100000000000000fe240e80ff8a48a77947b394979cf361017cd906ddaab637d72cf72e729d79bf010000000000000006854c73f5703242d31d2576ac2297c93f0b5dc16ade0097c59d5dc0faa43c5501000000000000004e8f0524e30ac39910b99d0c465e945580c48070ea75214f7c01a920b1a66e4901000000000000008aabd4f6d7ecec7a749c83fc7be33f3b4818cca6f93a4927b4964900df9454e50100000000000000b9186b95c90d2d00a31e7c68066bd37d73408271762604e3608e2f2c983f83090100000000000000f5260c9ada18534d79be08836484429e686985c8241e113307792aa1255b1cb10100000000000000e730007e26ea493e96a65b30d278e92ef85444e61fee3606729a5e699b74f1100100000000000000d4d8cfaa23b3a1a89a7f6a90cdbfdea15c87ad2ca4ae77deb3389406ad3feffe01000000000000002db20e745d850245733e6f6aa93ea9a176044e904160e59995846aac21f1ff610100000000000000dc1427d14e83926d22f6be25d1bd39cbc82a194f5e9373ecae644f156ae9c62e01000000000000005cc3bf681735b048c6d32066de94abae0515d8f401583bf9bb103b4e07ec6e700100000000000000beab86851a829fb4f25d1c1a5d92b4cd97718fd0f2f9ef345b0d3cab98a304aa01000000000000000339088379600f5bd507277eb894aba34d2a8f27ce1964f41e60ef2a4142dc6e010000000000000003d105a30087d96b5f0684f6ded76f826b01dab61e4136e1d851a24f0088b5ed010000000000000020d4e595c50bb9558dad9be6a8784492bbbfc754b9c5fae17edf4f8a84e8b47101000000000000006ba031ff146af5199eeb335a4a9c2fd487685a489e1a154ba1d012e965fdd5ba0100000000000000608f61824d3ae16d443cd0fec15c18590c890d4105e9402cad8743fb423e52b40100000000000000fe95aa161a01b3473ed9dc7f4e2219528d8be86530bcfa7095086ed61e3d7a0301000000000000000ccee96768f9b1d29d5bd9e63afd2be78a90cc89d19653ff1910cb36000b48530100000000000000818a546c630b881c2161588866965649678cda0f4110cccc3533d0f20e5e41200100000000000000088f8736e1cf2ea3d102f0a96ccf51222b8aa1f93d8e42947892f4395cb5477c0100000000000000c3ff25a1743a9df92af4ccd9a7aed5cbc90f64fd538c3df0a9539128f596526701000000000000004e3fb8c16ad624c1852777456805e5352d0221269de66949c95da4076206b35a01000000000000007ad55381f9de00220678c95a19489640fc61331e2a40d927e3d833555575c6fc0100000000000000cb92ffeace78dbafe6fbf275741b4b38657fb81590712aa0bca7877931f6ad39010000000000000074a8906dd2888c9e7edea13ba3c42ad4d833f4a5de43d5ce0d9b12c654ab2e8701000000000000005cd0c7b21d4834c5a41a80f7d421c7d0297e42eb409a524d33aa7557df13adaa01000000000000007ac1f611f90df5fb222924b2c6683062db933d6083922c4a17ce29f21298a7680100000000000000077Line truncated
|
||||
}
|
||||
}
|
||||
|
||||
"badBlocks": null,
|
||||
"bootNodes": [
|
||||
"/dns/polkadot-bootnode-0.polkadot.io/tcp/30333/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU",
|
||||
"/dns/polkadot-bootnode-0.polkadot.io/tcp/30334/ws/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU",
|
||||
"/dns/polkadot-bootnode-0.polkadot.io/tcp/443/wss/p2p/12D3KooWSz8r2WyCdsfWHgPyvD8GKQdJ1UAiRmrcrs8sQB3fe2KU",
|
||||
"/dns/polkadot-bootnode-1.polkadot.io/tcp/30333/p2p/12D3KooWFN2mhgpkJsDBuNuE5427AcDrsib8EoqGMZmkxWwx3Md4",
|
||||
"/dns/polkadot-bootnode-1.polkadot.io/tcp/30334/ws/p2p/12D3KooWFN2mhgpkJsDBuNuE5427AcDrsib8EoqGMZmkxWwx3Md4",
|
||||
"/dns/polkadot-bootnode-1.polkadot.io/tcp/443/wss/p2p/12D3KooWFN2mhgpkJsDBuNuE5427AcDrsib8EoqGMZmkxWwx3Md4",
|
||||
"/dns/polkadot-boot.dwellir.com/tcp/30334/ws/p2p/12D3KooWKvdDyRKqUfSAaUCbYiLwKY8uK3wDWpCuy2FiDLbkPTDJ",
|
||||
"/dns/polkadot-boot.dwellir.com/tcp/443/wss/p2p/12D3KooWKvdDyRKqUfSAaUCbYiLwKY8uK3wDWpCuy2FiDLbkPTDJ",
|
||||
"/dns/boot.stake.plus/tcp/30333/p2p/12D3KooWKT4ZHNxXH4icMjdrv7EwWBkfbz5duxE5sdJKKeWFYi5n",
|
||||
"/dns/boot.stake.plus/tcp/30334/wss/p2p/12D3KooWKT4ZHNxXH4icMjdrv7EwWBkfbz5duxE5sdJKKeWFYi5n",
|
||||
"/dns/boot-node.helikon.io/tcp/7070/p2p/12D3KooWS9ZcvRxyzrSf6p63QfTCWs12nLoNKhGux865crgxVA4H",
|
||||
"/dns/boot-node.helikon.io/tcp/7072/wss/p2p/12D3KooWS9ZcvRxyzrSf6p63QfTCWs12nLoNKhGux865crgxVA4H",
|
||||
"/dns/polkadot.bootnode.amforc.com/tcp/30333/p2p/12D3KooWAsuCEVCzUVUrtib8W82Yne3jgVGhQZN3hizko5FTnDg3",
|
||||
"/dns/polkadot.bootnode.amforc.com/tcp/30334/wss/p2p/12D3KooWAsuCEVCzUVUrtib8W82Yne3jgVGhQZN3hizko5FTnDg3",
|
||||
"/dns/polkadot-bootnode.polkadotters.com/tcp/30333/p2p/12D3KooWPAVUgBaBk6n8SztLrMk8ESByncbAfRKUdxY1nygb9zG3",
|
||||
"/dns/polkadot-bootnode.polkadotters.com/tcp/30334/wss/p2p/12D3KooWPAVUgBaBk6n8SztLrMk8ESByncbAfRKUdxY1nygb9zG3",
|
||||
"/dns/boot-cr.gatotech.network/tcp/33100/p2p/12D3KooWK4E16jKk9nRhvC4RfrDVgcZzExg8Q3Q2G7ABUUitks1w",
|
||||
"/dns/boot-cr.gatotech.network/tcp/35100/wss/p2p/12D3KooWK4E16jKk9nRhvC4RfrDVgcZzExg8Q3Q2G7ABUUitks1w",
|
||||
"/dns/boot-polkadot.metaspan.io/tcp/13012/p2p/12D3KooWRjHFApinuqSBjoaDjQHvxwubQSpEVy5hrgC9Smvh92WF",
|
||||
"/dns/boot-polkadot.metaspan.io/tcp/13015/ws/p2p/12D3KooWRjHFApinuqSBjoaDjQHvxwubQSpEVy5hrgC9Smvh92WF",
|
||||
"/dns/boot-polkadot.metaspan.io/tcp/13016/wss/p2p/12D3KooWRjHFApinuqSBjoaDjQHvxwubQSpEVy5hrgC9Smvh92WF",
|
||||
"/dns/polkadot-bootnode.turboflakes.io/tcp/30300/p2p/12D3KooWHJBMZgt7ymAdTRtadPcGXpJw79vBGe8z53r9JMkZW7Ha",
|
||||
"/dns/polkadot-bootnode.turboflakes.io/tcp/30400/wss/p2p/12D3KooWHJBMZgt7ymAdTRtadPcGXpJw79vBGe8z53r9JMkZW7Ha",
|
||||
"/dns/polkadot-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWFFqjBKoSdQniRpw1Y8W6kkV7takWv1DU2ZMkaA81PYVq",
|
||||
"/dns/polkadot-boot-ng.dwellir.com/tcp/30336/p2p/12D3KooWFFqjBKoSdQniRpw1Y8W6kkV7takWv1DU2ZMkaA81PYVq",
|
||||
"/dns/polkadot-bootnode.radiumblock.com/tcp/30335/wss/p2p/12D3KooWNwWNRrPrTk4qMah1YszudMjxNw2qag7Kunhw3Ghs9ea5",
|
||||
"/dns/polkadot-bootnode.radiumblock.com/tcp/30333/p2p/12D3KooWNwWNRrPrTk4qMah1YszudMjxNw2qag7Kunhw3Ghs9ea5",
|
||||
"/dns/dot-bootnode.stakeworld.io/tcp/30310/p2p/12D3KooWAb5MyC1UJiEQJk4Hg4B2Vi3AJdqSUhTGYUqSnEqCFMFg",
|
||||
"/dns/dot-bootnode.stakeworld.io/tcp/30311/ws/p2p/12D3KooWAb5MyC1UJiEQJk4Hg4B2Vi3AJdqSUhTGYUqSnEqCFMFg",
|
||||
"/dns/dot-bootnode.stakeworld.io/tcp/30312/wss/p2p/12D3KooWAb5MyC1UJiEQJk4Hg4B2Vi3AJdqSUhTGYUqSnEqCFMFg",
|
||||
"/dns/dot14.rotko.net/tcp/35214/wss/p2p/12D3KooWPyEvPEXghnMC67Gff6PuZiSvfx3fmziKiPZcGStZ5xff",
|
||||
"/dns/dot14.rotko.net/tcp/33214/p2p/12D3KooWPyEvPEXghnMC67Gff6PuZiSvfx3fmziKiPZcGStZ5xff"
|
||||
],
|
||||
"chainType": "Live",
|
||||
"forkBlocks": null,
|
||||
"genesis": {
|
||||
"stateRootHash": "0x29d0d972cd27cbc511e9589fcb7a4506d5eb6a9e8df205f00472e5ab354a4e17"
|
||||
},
|
||||
"id": "polkadot",
|
||||
"lightSyncState": {
|
||||
"babeEpochChanges": "0x044736295f5ace57cb8f84fd667e8ed439db12f470d45736d046f67f54bccaada2b69c16010153bae41000000000b3c3e41000000000046646627e2646c3b728990fc968ec647c2170e66b55fbe48365e54557ae43756916a6160101b3c3e4100000000013cde41000000000086441c5d73eef491062ed18d31770e3f8a95eba0a9e78b407d28c706c6f06332775af16010113cde4100000000073d6e41000000000007494065a1f61226b66736add1b00a214e14611c3f78e1ab4d3e0d9c69ae732f875af16010113cde4100000000073d6e410000000000000104736295f5ace57cb8f84fd667e8ed439db12f470d45736d046f67f54bccaada2b69c160101da1d00000000000053bae410000000006009000000000000a50474a0fc84f72a4a9b8493379b7dfc59ca58a261a2e94997600d14b6b444c1475901000000000000009c40155989f6072e82caba245d7db7e40a60f866b403257976b89aba6be2b55b010000000000000014b0a3a620f70ada506d6ef1b7ab099219f2f05689523af7eebc81f9ba258e6001000000000000007067d4c5b492b11e2052a2bb0b4f729a52b3667afbca7dfefa863011254b5272010000000000000072ab87b654d80294c876cbefb534b3344c2f64159b015b89221331ec2145417501000000000000008008c1b7061a2402634fc15d3849e2913863beb9f55024bc8cc7fa7d6e397817010000000000000024a51a9bdb67213626d1b52bd8dbc0e9b94ea88ea417aa17b56212d1cea3e1780100000000000000488d520146f681678e9d229f5e29354edf65e521246b28a4175c0502e060b92001000000000000003ae9dfa8b24faaf16407328ff38a89b25fc7c673c44f9de3de0c011233d4226d01000000000000009e47382505cd1a803bdbe7803d36a61413e58697bd9396ce1607c89a48d1e051010000000000000020352ba0565811731625a8001d26f5d899e5856dedd0f9c6bc3bec2995704e5b01000000000000009cb389c209afbebda2b12113e0266b3d30f46e2a91aaf4451c193d640288357101000000000000004c9886e2e62ee92a6778d6a7928052732044b64fa61969cd8e37f3f7e3406f7201000000000000000c78c9dfc0033ff87657c56b7ab8cec4d1249be2de18729f743f385343af0f160100000000000000002e496e564f088a075525d2f9155aadd1a7eb017fa36f9e16096e9db7e169330100000000000000ae40860237c8f606dfb6974046eaa6b6b96f8d0aef56fbe3ce4865f66646bd260100000000000000f6dddaaaa53b57763610037753656b591d90fa81efbadcabbeddf7378c23602701000000000000003e69835397599a4bf081775f9f42f0f4ee686d67c9af8eacc4a733fdcdb0290b0100000000000000c48c594bb4e173544a0379055b65d995af53256f653d04f2cf4fdf8f3548943901000000000000003a80d898638dccd4aaa472e7948e7394969cc443335c494159948915c097c036010000000000000000b84e6e296de1009aeca95ee09bc5173aec6e91b1145b247d69e477588789720100000000000000466c0e97d043a4b0f4c3ac4849e11f901e9b31b28f8b3e40b7cdb0ba7f77480801000000000000002049288b4dbfb741109778c602f9308daf2e31b3b66e9aa550065e73c6787d7c0100000000000000e67c524e443cda4cd27dfcce70488a5d23a93c8c46a5e83ef5a69eff3a02fa5a010000000000000024a57db63b380456d56d561d8a9da6db13d298045c9672bc4086a2e0a567d55c01000000000000006c50859d9dde209012eb3868c1a3a6e80ae8fa528ace9df68e92dbbae6036820010000000000000078c88041bbca9b2bebd62fde7c46f4dc5e55d8877a113d063a6b525dfd6f7f2a01000000000000002e85d3d2c07aaf1c0a5f63f544c34b87cfa90a98c4f6167e86cee0b74a20cb120100000000000000723f3865d97a772459da8942cbb4757164f1fe7485cbcefb4b206e157ee5ed0201000000000000007c5f58a83f8101943c089dba3ab906c07811e853444aa58dbcc986c4095fbe7c01000000000000005494142902284943201b7cf610306e8665eeeec87c014d607175c3f50f76103b01000000000000001822493200c35242a149070784dca5e7012a8a52b61cd218ec7d65e469e8cc56010000000000000072ed7192625403acef94aa9189f9f179deb89e60478816ca96c79b742f757e750100000000000000d8f30bc2ee88e69f60d0278998414c80f4a130b8e1738e873bcd14ef31e58d36010000000000000042e377034ce6b2a582bfd66c465252ab10ce790e4f0d3bbe99a42ff86b29965c01000000000000000e164f314984e9a172a3a1526d853ff70bd11f3c596f17accbbebe2f7820833c01000000000000007e91ca522b14cbb71b45348c699b7d65c3198516ee771079b672ee3d7cfc577501000000000000004e2753547f6ec0a896bcbc55b9eeab875e8019acdeb10b979210af63f24c4b74010000000000000098faca5e78664fd082bf47f0079de33a5021415c8f5f912941e651a0b7071d1f0100000000000000ca6e63cec4c0801ecd740073da08be68b9cf4c7ff76b740fb6a522a63e838b5a010000000000000042e7851b82d8b7722b9eeb5eead57b21bf533fd25acb10542a52889376fc3920010000000000000028ce9c093ac772f56acb8dfe8b33a3966d4b8699bd41814117352d397195bd5f010000000000000042ad4ba7e8a60af1abcee04fdd82ad02b24f1e2535bdb1abcdde886efbf0fc4301000000000000006ec27dfa7ac9d35eb002c55d3e4d56b4df928dd5c44323ac228305741c9e09360100000000000000b89cbc83a386d6f5d4fed93289ee50fdf69d77369ca0c9a8b962554e3fc0d37e0100000000000000e61da4eefdd14434952c58dd1943f7f63185d03321ccc8835e4216badd16fc19010000000000000012a64d79e44f1adb33c85c4f2bdfcd8d8b38a34d984604f39289c9a7624a442d0100000000000000a20797f3a8669a909adb22a3aee2844dba82d231cc33f5d9be0e2c533cb82a670100000000000000e297620b731b4958e3c6aa06611c6aa5a45f7e116362d64954a0a330d2a98f330100000000000000dc1274e0689c7a3eac31b41ce352719529e65c01f26999f74ce17c9905fce87401000000000000000e5e5f8e89cd8d58ef83abddd3d1c2079691dec4f6965af70436e84411c31f3901000000000000007c21799f6143fa837a8c18bebe3368d60f4e009b114f61490b54e6344034040d0100000000000000e2f4efaa91da8465ac7d109cd80be5c02b9ba7a0603ff372cd77824de17f6c4201000000000000000ef6f09a9e310abb5c57dd7050a94d56d766772b80789b997cbb40f3b40f625d0100000000000000a88864a0dc9e292aa7cc8eddaa8dd8b6be2a4bc7e8f290023c6604e5c4ad1a7a0100000000000000dc68569bLine truncated
|
||||
"babeFinalizedBlockWeight": 4559738,
|
||||
"finalizedBlockHeader": "0xd77079fcf54a7a83fb2b75b24bc4c7b8a776c50c5a6ca04fcf5eba857e2a7f5052c05a04443844f2007aff2b5c8afe4731e735126f337ad52776ffd32f586da47451186fd49b29a11d724d4a7e0eba71b2c74ce1f9fe5958264219cf8ec4160346bc6b12080642414245b501036200000052c4e410000000009a76cf5448916664e377946b2cdf61f1afdc50feae99314db4a62b2ecd5fb24c501e3f442fc8eb763a2fe20657380d5e43c7b8223b90137aeafca12dfe65cd01a3c5a3977a9f1d929cd0855d15aa6f8a5d304ad7f1745bcc857e6e69d0a0e9020542414245010186408d036b3647c440fec22006c5386f1eef56c4fb9314e8bcea8bd26c681f04f8910b1bb3332e0bd2ce3b2cb16a3a9cbf53cb7b1c1152b0693ac90b268eca89",
|
||||
"grandpaAuthoritySet": "0xa5042f8da08bb2421ef844015c3b2ea23464fc66a9dcb4a2215fe0241f892d19afc50100000000000000fff437ff18629bf1490e5c9b3ec6f1515d46bb9b2aeaa6e39e36611f2479b50d01000000000000000334021ff54e46fb7da4bd257cf113519a0c7ee4a2251b66fe48466fed5853520100000000000000d95f04dc8ea4ac05deea7077457f0406fdd152bd03a7480e7d0de0983b959d3c010000000000000047f940bc985355be7187c709ded2b689b66d69e61e293a507f1d4f90bdbeceee01000000000000004a3fc0fe1020c7f460c7bd23d0b657c03368552b2f0a12d80a1c406fd066e0db01000000000000009b992b5e9b99eb2cd3b2b648d6db81ed722a2feb4938d998b58dcb5d159fadfa0100000000000000aee9de3938173700b3e3f4fbf2b200ae296173a0854157f40de2598dd4cad8f10100000000000000e0b1aae640bfbed119730710c584be65ef59abb3e9ee5dc8a754751e1ba163960100000000000000495a0370e02aadf1beff005feceb521a1d9bb0d85e7fe58658b97ec988fb996c0100000000000000b61e9b13e849779be8f5378a670d61991875d8e091f359384d7be73d02d506930100000000000000426b2be4596a759a15028d84e08c5c56440e6cede68d088f47c671cc3387c3e6010000000000000070ba6e5985990ba1b1392713236f1b50df750f10f744cc6eb95fa7c5cfbc687601000000000000005b27660cd4c375f2654c6d923b29fd8abbab7e96ee040c79598be14f832f56ca010000000000000057ae0c85ebaf333a6ec3251f577cab910cce072f238d1e50046322b83bbc0dd5010000000000000072c09c9e2dc9ab20a65cf70e951352f554442514ba2ac7063966ea7bbe3e6cf001000000000000000139b946b46bee4c61be50c986f2a9ef2e76917644e2ecd842c59d61a94ee612010000000000000019a9d56ea35496122fc44fcb5c29d27fbb43520556d6f8d97753767aaa0f228e01000000000000007cd50f6921fade39653f847bddd48360668004225081a6a3ad7997f78debd34c010000000000000053a51c848834661c92e74b3c2492b8de2591f914ab75345d70e61c79be9699d70100000000000000a5b094ae7c156592baa68ce18dab6368d5b665e9a0f07dfc5f54f58309e086c1010000000000000053352e16d2a27fb3525d5d8750d6ad7f46b303a45e434a409ac727d5cb80432b01000000000000008c54298c6f8704498112ecb24f64f7a28ed2289ec573620b0d1e5a9a44f5fa78010000000000000041ef4a31eb7dc1e01f4630604e1908e644d7cdee3f66a60f98d6d59605326f8b010000000000000097743d6364cdb6c4790cd37c4c2ab5fbc6c65e8bb606625e70a6ee04ed1650d9010000000000000008cc1d6c743da905511a39a6f0a68809a6bc32f8ac25e53bb2d6aca4f493fc9b0100000000000000c9dc00c6a757495c50092362d5c70d2a971ae1da4eb67c9da9f4367c9d408c1d0100000000000000049cb09a86d544249f9e11cf6c348bc0561600343ebee89d1c90bbef3d13e517010000000000000086c42c0f6b8f7c06f9ce823eeecf7cf0371bb5b97f3c7af63872f8bbfb353abd0100000000000000d04d64a07f144638f20f081de122b88fed0cc8bda57e4810e7afb38036dd8bbf0100000000000000f26945a8a64032a1defa76e720a99649125b55751b6088205e7acab901de670b0100000000000000684768723f0efc2001562c3b2156b987601ae9431f8aaa6f4199649cba487aea01000000000000005cba2c6f569da1edc3778308da406f266aa53140381dbb3f14f22909ba6e30040100000000000000c9a741ab82126c4d4eaa6a758cfc1209bbd7b29330e89ccd97fb62ae567c8d4301000000000000009b94bc45bf79bb33f70430c82880456cd7bd5fb3ea131c1b26d493d01c5fe7100100000000000000ce8d085d4b0a9502a680280ecc162bd33533a5ebada62f3be19427542189cb5a0100000000000000a1a9debad5e4afb076cf293c2c797f0b5901ffdb8bd01611235e762411a0db3901000000000000006f4855725ebb9eced957bae43ffa7d30657ce7d06b251ce20e2218bcf929e40501000000000000007c10f10bd6eb9c1201b52c6025545fcbc310432781bbe02629b5cc9e5fdd229a0100000000000000b046cf7d24d49b720b28dd2476b36c157262208fb065c077b1b94db1e9ffa6050100000000000000749556da4a259bc1f0b8ea8e3726c2251656b92205c30b635ec9f42038f8defb01000000000000000ce4d93e25fa5302f4b059456f680047f87be428ae88579e0b862502b5ceed600100000000000000c1758f7cbffeb844419bc494a9dc65fb394259f01e9bf23789a75acc29d7d9620100000000000000c1c1ff5f66fefb5c0849e3b2333411d1f7e9dd4888600e334e7a33623f15fa360100000000000000fe240e80ff8a48a77947b394979cf361017cd906ddaab637d72cf72e729d79bf010000000000000006854c73f5703242d31d2576ac2297c93f0b5dc16ade0097c59d5dc0faa43c550100000000000000c650b1a6b34347bd80ed06b48aa4ae1a33adaa507e8ac23bf6c6b94223b63b9d01000000000000008aabd4f6d7ecec7a749c83fc7be33f3b4818cca6f93a4927b4964900df9454e50100000000000000b9186b95c90d2d00a31e7c68066bd37d73408271762604e3608e2f2c983f830901000000000000003948bfd09bbbc2fe6ac5dfe53146e32df50828eecf7b2b18cdcff8dc385cbd7501000000000000001ba602a293ccdb7a77042fb486c6e010d48b13dff2bef0a26c53637312aac7f70100000000000000ba8180cbc0dceb098ee6b22fe89978bf92ebf196a280470b1501bc2138ec02c70100000000000000f6373ec61f3d99dfcd0bcc6a2b5ddb7e9c8a7d8e5777aa58bc2ac949315dee250100000000000000dc1427d14e83926d22f6be25d1bd39cbc82a194f5e9373ecae644f156ae9c62e010000000000000003d105a30087d96b5f0684f6ded76f826b01dab61e4136e1d851a24f0088b5ed010000000000000020d4e595c50bb9558dad9be6a8784492bbbfc754b9c5fae17edf4f8a84e8b47101000000000000006ba031ff146af5199eeb335a4a9c2fd487685a489e1a154ba1d012e965fdd5ba0100000000000000608f61824d3ae16d443cd0fec15c18590c890d4105e9402cad8743fb423e52b401000000000000000ccee96768f9b1d29d5bd9e63afd2be78a90cc89d19653ff1910cb36000b48530100000000000000818a546c630b881c2161588866965649678cda0f4110cccc3533d0f20e5e41200100000000000000088f8736e1cf2ea3d102f0a96ccf51222b8aa1f93d8e42947892f4395cb5477c0100000000000000c3ff25a1743a9df92af4ccd9a7aed5cbc90f64fd538c3df0a9539128f596526701000000000000004e3fbLine truncated
|
||||
},
|
||||
"name": "Polkadot",
|
||||
"properties": {
|
||||
"ss58Format": 0,
|
||||
"tokenDecimals": 10,
|
||||
"tokenSymbol": "DOT"
|
||||
},
|
||||
"protocolId": "dot",
|
||||
"telemetryEndpoints": [
|
||||
[
|
||||
"/dns/telemetry.polkadot.io/tcp/443/x-parity-wss/%2Fsubmit%2F",
|
||||
0
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -16,6 +16,11 @@ description = "Command line utilities for working with subxt codegen"
|
||||
name = "subxt"
|
||||
path = "src/main.rs"
|
||||
|
||||
[features]
|
||||
# Compute the state root hash from the genesis entry.
|
||||
# Enable this to create a smaller chain spec file.
|
||||
chain-spec-pruning = ["smoldot"]
|
||||
|
||||
[dependencies]
|
||||
subxt-codegen = { workspace = true, features = ["fetch-metadata"] }
|
||||
subxt-metadata = { workspace = true }
|
||||
@@ -32,3 +37,5 @@ scale-value = { workspace = true }
|
||||
syn = { workspace = true }
|
||||
jsonrpsee = { workspace = true, features = ["async-client", "client-ws-transport-native-tls", "http-client"] }
|
||||
tokio = { workspace = true, features = ["rt-multi-thread"] }
|
||||
thiserror = { workspace = true }
|
||||
smoldot = { workspace = true, optional = true}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use jsonrpsee::{
|
||||
async_client::ClientBuilder,
|
||||
client_transport::ws::WsTransportClientBuilder,
|
||||
core::{client::ClientT, Error},
|
||||
http_client::HttpClientBuilder,
|
||||
};
|
||||
use std::time::Duration;
|
||||
use subxt_codegen::fetch_metadata::Url;
|
||||
|
||||
/// Returns the node's chainSpec from the provided URL.
|
||||
pub async fn fetch_chain_spec(url: Url) -> Result<serde_json::Value, FetchSpecError> {
|
||||
async fn fetch_ws(url: Url) -> Result<serde_json::Value, Error> {
|
||||
let (sender, receiver) = WsTransportClientBuilder::default()
|
||||
.build(url)
|
||||
.await
|
||||
.map_err(|e| Error::Transport(e.into()))?;
|
||||
|
||||
let client = ClientBuilder::default()
|
||||
.request_timeout(Duration::from_secs(180))
|
||||
.max_buffer_capacity_per_subscription(4096)
|
||||
.build_with_tokio(sender, receiver);
|
||||
|
||||
inner_fetch(client).await
|
||||
}
|
||||
|
||||
async fn fetch_http(url: Url) -> Result<serde_json::Value, Error> {
|
||||
let client = HttpClientBuilder::default()
|
||||
.request_timeout(Duration::from_secs(180))
|
||||
.build(url)?;
|
||||
|
||||
inner_fetch(client).await
|
||||
}
|
||||
|
||||
async fn inner_fetch(client: impl ClientT) -> Result<serde_json::Value, Error> {
|
||||
client
|
||||
.request("sync_state_genSyncSpec", jsonrpsee::rpc_params![true])
|
||||
.await
|
||||
}
|
||||
|
||||
let spec = match url.scheme() {
|
||||
"http" | "https" => fetch_http(url).await.map_err(FetchSpecError::RequestError),
|
||||
"ws" | "wss" => fetch_ws(url).await.map_err(FetchSpecError::RequestError),
|
||||
invalid_scheme => Err(FetchSpecError::InvalidScheme(invalid_scheme.to_owned())),
|
||||
}?;
|
||||
|
||||
Ok(spec)
|
||||
}
|
||||
|
||||
/// Error attempting to fetch chainSpec.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[non_exhaustive]
|
||||
pub enum FetchSpecError {
|
||||
/// JSON-RPC error fetching metadata.
|
||||
#[error("Request error: {0}")]
|
||||
RequestError(#[from] jsonrpsee::core::Error),
|
||||
/// URL scheme is not http, https, ws or wss.
|
||||
#[error("'{0}' not supported, supported URI schemes are http, https, ws or wss.")]
|
||||
InvalidScheme(String),
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use clap::Parser as ClapParser;
|
||||
#[cfg(feature = "chain-spec-pruning")]
|
||||
use serde_json::Value;
|
||||
use std::{io::Write, path::PathBuf};
|
||||
use subxt_codegen::fetch_metadata::Url;
|
||||
|
||||
mod fetch;
|
||||
|
||||
/// Download chainSpec from a substrate node.
|
||||
#[derive(Debug, ClapParser)]
|
||||
pub struct Opts {
|
||||
/// The url of the substrate node to query for metadata for codegen.
|
||||
#[clap(long)]
|
||||
url: Url,
|
||||
/// Write the output of the command to the provided file path.
|
||||
#[clap(long, short, value_parser)]
|
||||
output_file: Option<PathBuf>,
|
||||
/// Replaced the genesis raw entry with a stateRootHash to optimize
|
||||
/// the spec size and avoid the need to calculate the genesis storage.
|
||||
///
|
||||
/// This option is enabled with the `chain-spec-pruning` feature.
|
||||
///
|
||||
/// Defaults to `false`.
|
||||
#[cfg(feature = "chain-spec-pruning")]
|
||||
#[clap(long)]
|
||||
state_root_hash: bool,
|
||||
/// Remove the `codeSubstitutes` entry from the chain spec.
|
||||
/// This is useful when wanting to store a smaller chain spec.
|
||||
/// At this moment, the light client does not utilize this object.
|
||||
///
|
||||
/// Defaults to `false`.
|
||||
#[clap(long)]
|
||||
remove_substitutes: bool,
|
||||
}
|
||||
|
||||
/// Error attempting to fetch chainSpec.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[non_exhaustive]
|
||||
pub enum ChainSpecError {
|
||||
/// Failed to fetch the chain spec.
|
||||
#[error("Failed to fetch the chain spec: {0}")]
|
||||
FetchError(#[from] fetch::FetchSpecError),
|
||||
|
||||
#[cfg(feature = "chain-spec-pruning")]
|
||||
/// The provided chain spec is invalid.
|
||||
#[error("Error while parsing the chain spec: {0})")]
|
||||
ParseError(String),
|
||||
|
||||
#[cfg(feature = "chain-spec-pruning")]
|
||||
/// Cannot compute the state root hash.
|
||||
#[error("Error computing state root hash: {0})")]
|
||||
ComputeError(String),
|
||||
|
||||
/// Other error.
|
||||
#[error("Other: {0})")]
|
||||
Other(String),
|
||||
}
|
||||
|
||||
#[cfg(feature = "chain-spec-pruning")]
|
||||
fn compute_state_root_hash(spec: &Value) -> Result<[u8; 32], ChainSpecError> {
|
||||
let chain_spec = smoldot::chain_spec::ChainSpec::from_json_bytes(spec.to_string().as_bytes())
|
||||
.map_err(|err| ChainSpecError::ParseError(err.to_string()))?;
|
||||
|
||||
let genesis_chain_information = chain_spec.to_chain_information().map(|(ci, _)| ci);
|
||||
|
||||
let state_root = match genesis_chain_information {
|
||||
Ok(genesis_chain_information) => {
|
||||
let header = genesis_chain_information.as_ref().finalized_block_header;
|
||||
*header.state_root
|
||||
}
|
||||
// From the smoldot code this error is encountered when the genesis already contains the
|
||||
// state root hash entry instead of the raw entry.
|
||||
Err(smoldot::chain_spec::FromGenesisStorageError::UnknownStorageItems) => *chain_spec
|
||||
.genesis_storage()
|
||||
.into_trie_root_hash()
|
||||
.ok_or_else(|| {
|
||||
ChainSpecError::ParseError(
|
||||
"The chain spec does not contain the proper shape for the genesis.raw entry"
|
||||
.to_string(),
|
||||
)
|
||||
})?,
|
||||
Err(err) => return Err(ChainSpecError::ComputeError(err.to_string())),
|
||||
};
|
||||
|
||||
Ok(state_root)
|
||||
}
|
||||
|
||||
pub async fn run(opts: Opts, output: &mut impl Write) -> color_eyre::Result<()> {
|
||||
let url = opts.url;
|
||||
|
||||
let mut spec = fetch::fetch_chain_spec(url).await?;
|
||||
|
||||
let mut output: Box<dyn Write> = match opts.output_file {
|
||||
Some(path) => Box::new(std::fs::File::create(path)?),
|
||||
None => Box::new(output),
|
||||
};
|
||||
|
||||
#[cfg(feature = "chain-spec-pruning")]
|
||||
if opts.state_root_hash {
|
||||
let state_root_hash = compute_state_root_hash(&spec)?;
|
||||
let state_root_hash = format!("0x{}", hex::encode(state_root_hash));
|
||||
|
||||
if let Some(genesis) = spec.get_mut("genesis") {
|
||||
let object = genesis.as_object_mut().ok_or_else(|| {
|
||||
ChainSpecError::Other("The genesis entry must be an object".to_string())
|
||||
})?;
|
||||
|
||||
object.remove("raw").ok_or_else(|| {
|
||||
ChainSpecError::Other("The genesis entry must contain a raw entry".to_string())
|
||||
})?;
|
||||
|
||||
object.insert("stateRootHash".to_string(), Value::String(state_root_hash));
|
||||
}
|
||||
}
|
||||
|
||||
if opts.remove_substitutes {
|
||||
let object = spec
|
||||
.as_object_mut()
|
||||
.ok_or_else(|| ChainSpecError::Other("The chain spec must be an object".to_string()))?;
|
||||
|
||||
object.remove("codeSubstitutes");
|
||||
}
|
||||
|
||||
let json = serde_json::to_string_pretty(&spec)?;
|
||||
write!(output, "{json}")?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
pub mod chain_spec;
|
||||
pub mod codegen;
|
||||
pub mod compatibility;
|
||||
pub mod diff;
|
||||
|
||||
@@ -18,6 +18,7 @@ enum Command {
|
||||
Diff(commands::diff::Opts),
|
||||
Version(commands::version::Opts),
|
||||
Explore(commands::explore::Opts),
|
||||
ChainSpec(commands::chain_spec::Opts),
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -32,5 +33,6 @@ async fn main() -> color_eyre::Result<()> {
|
||||
Command::Diff(opts) => commands::diff::run(opts, &mut output).await,
|
||||
Command::Version(opts) => commands::version::run(opts, &mut output),
|
||||
Command::Explore(opts) => commands::explore::run(opts, &mut output).await,
|
||||
Command::ChainSpec(opts) => commands::chain_spec::run(opts, &mut output).await,
|
||||
}
|
||||
}
|
||||
@@ -21,3 +21,6 @@ cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --p
|
||||
cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets "" > artifacts/polkadot_metadata_tiny.scale
|
||||
# generate a metadata file that only contains some custom metadata
|
||||
cargo run --bin generate-custom-metadata > artifacts/metadata_with_custom_values.scale
|
||||
|
||||
# Generate the polkadot chain spec.
|
||||
cargo run --features chain-spec-pruning --bin subxt chain-spec --url wss://rpc.polkadot.io:443 --output-file artifacts/demo_chain_specs/polkadot.json --state-root-hash --remove-substitutes
|
||||
Reference in new issue
Block a user