Merkle Mountain Range & BEEFY integration (#2101)

* Switch branch.

* Implement basic MMR leaf.

* Revert "Switch branch."

This reverts commit 7f4d41c67f27ca560c53fc63fd3bd06ac182403c.

* Bump substrate.

* Integrate BEEFY.

Bump all.

Fix missing imports.

* Use beefy pallet to get authorities.

* Bump BEEFY repo.

* Use next authority set instead of the current one.

* Start BEEFY service.

* Fix BEEFY start up.

* Cache BEEFY authority set.

* Add BEEFY ValidatorSetId to MMR

* Fix code.

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Review grumbles.

* Update beefy repo.

* Work-around missing protocol.

* Revert "Work-around missing protocol."

This reverts commit 0a6257a8bccc1c67e966898cdedc408c6469ffd6.

* Add beefy peers set config.

* Expose storage of BEEFY.

* Uncompress BEEFY keys for merkle tree.

* Update ordering.

* Switch to branch.

* Bump deps.

* Switch to custom beefy.

* Add MMR RuntimeApi and custom rpc.

* Add set length details.

* Fix compilation.

* Expose MmrLeaf storage.

* Expose MmrLeaf storage.

* Don't use session handler, and rather compute & cache beefy details on call.

* Don't use session handler, and rather compute & cache beefy details on call.

* Fixes.

* Update Cargo.lock.

* Switch back to master.

* Update lockfile.

* Fix xcm print issue.

* Cargo.lock.

* Use master branch.

* Remove extra dep.

* Fix tests.

* Update Cargo.lock

* Add BEEFY & MMR to westend.

* Implement session keys migration.

* Update testnet script.

* start BEEFY for all node types

* Update Cargo.lock

* fix Cargo.toml

* resolve another merge conflict

* add Westend BEEFY keys

* Apply suggestions from code review

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update BEEFY.

* Add Rococo BEEFY keys

* resolve merge issue

* fix pallet indices

* fix Westend OldSessionKey

* remove unused imports in Westend runtime

* Fix compilation for Westend.

* address review

* start BEEFY gadget conditionally

* address review again

* fix typo

* remove duplicate

* remove another duplicate

* well

* add missing stuff

* cleanup Cargo.toml files

- revert unnecessary changes
- add missing /std dependencies
- remove unused dependencies

* runtime: remove unused structs from rococo runtime

* node: cleanup service

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: adoerr <0xad@gmx.net>
Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Tomasz Drwięga
2021-04-01 12:50:04 +02:00
committed by GitHub
parent ccfabaa0c6
commit 5b77a89874
22 changed files with 1282 additions and 417 deletions
+313 -151
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -8,6 +8,8 @@ edition = "2018"
# Substrate Client # Substrate Client
sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" } babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master" }
beefy-gadget = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master" }
grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" } grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -48,6 +50,7 @@ pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "maste
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Substrate Other # Substrate Other
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
+115 -74
View File
@@ -18,6 +18,7 @@
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use babe_primitives::AuthorityId as BabeId; use babe_primitives::AuthorityId as BabeId;
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
use grandpa::AuthorityId as GrandpaId; use grandpa::AuthorityId as GrandpaId;
use hex_literal::hex; use hex_literal::hex;
use kusama::constants::currency::DOTS as KSM; use kusama::constants::currency::DOTS as KSM;
@@ -153,6 +154,7 @@ fn westend_session_keys(
para_validator: ValidatorId, para_validator: ValidatorId,
para_assignment: AssignmentId, para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId, authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> westend::SessionKeys { ) -> westend::SessionKeys {
westend::SessionKeys { westend::SessionKeys {
babe, babe,
@@ -161,6 +163,7 @@ fn westend_session_keys(
para_validator, para_validator,
para_assignment, para_assignment,
authority_discovery, authority_discovery,
beefy,
} }
} }
@@ -170,7 +173,8 @@ fn rococo_session_keys(
im_online: ImOnlineId, im_online: ImOnlineId,
para_validator: ValidatorId, para_validator: ValidatorId,
para_assignment: AssignmentId, para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> rococo_runtime::SessionKeys { ) -> rococo_runtime::SessionKeys {
rococo_runtime::SessionKeys { rococo_runtime::SessionKeys {
babe, babe,
@@ -179,6 +183,7 @@ fn rococo_session_keys(
para_validator, para_validator,
para_assignment, para_assignment,
authority_discovery, authority_discovery,
beefy,
} }
} }
@@ -290,6 +295,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
// for i in 1 2 3 4; do for j in grandpa; do subkey --ed25519 inspect "$SECRET//$i//$j"; done; done // for i in 1 2 3 4; do for j in grandpa; do subkey --ed25519 inspect "$SECRET//$i//$j"; done; done
// for i in 1 2 3 4; do for j in im_online; do subkey --sr25519 inspect "$SECRET//$i//$j"; done; done // for i in 1 2 3 4; do for j in im_online; do subkey --sr25519 inspect "$SECRET//$i//$j"; done; done
// for i in 1 2 3 4; do for j in para_validator para_assignment; do subkey --sr25519 inspect "$SECRET//$i//$j"; done; done // for i in 1 2 3 4; do for j in para_validator para_assignment; do subkey --sr25519 inspect "$SECRET//$i//$j"; done; done
// for i in 1 2 3 4; do for j in beefy; do subkey --ecdsa inspect "$SECRET//$i//$j"; done; done
let initial_authorities: Vec<( let initial_authorities: Vec<(
AccountId, AccountId,
AccountId, AccountId,
@@ -299,6 +305,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
ValidatorId, ValidatorId,
AssignmentId, AssignmentId,
AuthorityDiscoveryId, AuthorityDiscoveryId,
BeefyId,
)> = vec![ )> = vec![
( (
//5FZoQhgUCmqBxnkHX7jCqThScS2xQWiwiF61msg63CFL3Y8f //5FZoQhgUCmqBxnkHX7jCqThScS2xQWiwiF61msg63CFL3Y8f
@@ -306,23 +313,19 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
//5ExdKyXFhtrjiFhexnyQPDyGSP8xU9qHc4KDwVrtWxaP2RP6 //5ExdKyXFhtrjiFhexnyQPDyGSP8xU9qHc4KDwVrtWxaP2RP6
hex!["8011fb3641f0641f5570ba8787a64a0ff7d9c9999481f333d7207c4abd7e981c"].into(), hex!["8011fb3641f0641f5570ba8787a64a0ff7d9c9999481f333d7207c4abd7e981c"].into(),
//5Ef8qY8LRV6RFd4bThrwxBhhWfLjzqmd4rK8nX3Xs7zJqqp7 //5Ef8qY8LRV6RFd4bThrwxBhhWfLjzqmd4rK8nX3Xs7zJqqp7
hex!["72bae70a1398c0ba52f815cc5dfbc9ec5c013771e541ae28e05d1129243e3001"] hex!["72bae70a1398c0ba52f815cc5dfbc9ec5c013771e541ae28e05d1129243e3001"].unchecked_into(),
.unchecked_into(),
//5FSscBiPfaPaEhFbAt2qRhcYjryKBKf714X76F5nFfwtdXLa //5FSscBiPfaPaEhFbAt2qRhcYjryKBKf714X76F5nFfwtdXLa
hex!["959cebf18fecb305b96fd998c95f850145f52cbbb64b3ef937c0575cc7ebd652"] hex!["959cebf18fecb305b96fd998c95f850145f52cbbb64b3ef937c0575cc7ebd652"].unchecked_into(),
.unchecked_into(), //5CMC5eE4XvPLVTv8e4miXTvfMDEj1gGofT9ymAybwTZWU4Uu
// 5Ef8qY8LRV6RFd4bThrwxBhhWfLjzqmd4rK8nX3Xs7zJqqp7 hex!["0c92ef9543bd3d8ce7e31356ec19d1f539beb3bed293b056bfbe77c2627c1944"].unchecked_into(),
hex!["72bae70a1398c0ba52f815cc5dfbc9ec5c013771e541ae28e05d1129243e3001"] //5FRidgyc13cnzVZrav9gCamgdwoiy34er9ea6Hhk8wSzGnLQ
.unchecked_into(), hex!["94bb7784e5d7f4e03f474d76bd00563b05968ba1c8a842f3f45c531cfe389329"].unchecked_into(),
// 5Ef8qY8LRV6RFd4bThrwxBhhWfLjzqmd4rK8nX3Xs7zJqqp7 //5CFHEhVjscbquPvaPmrH4yUxGfxC9xq2bDYJAK6ccQzMVZQb
hex!["72bae70a1398c0ba52f815cc5dfbc9ec5c013771e541ae28e05d1129243e3001"] hex!["0810d2113438bb14856b06383a4f0da4e5cc2f92a3fc18ef03a54b34c6007662"].unchecked_into(),
.unchecked_into(), //5CkAdj1MpkMtQikrGXuzgzrRLvUnfLQH2JsnZa16u4cK2Xhf
// 5Ef8qY8LRV6RFd4bThrwxBhhWfLjzqmd4rK8nX3Xs7zJqqp7 hex!["1e18b5a9f872727189934a6988ff2a6732c87b9e31e2d694dd011aff9dfb2332"].unchecked_into(),
hex!["72bae70a1398c0ba52f815cc5dfbc9ec5c013771e541ae28e05d1129243e3001"] //5E6ogZEZyc5YZ3ijWUPB9M6Xtx6E9FabhmP9J4rwcEH6pLGv
.unchecked_into(), hex!["0293be7cdb81f25039dfd01aac905da8a5e50113366bc4b5dc5eb888cf5552b8a9"].unchecked_into(),
// 5Ef8qY8LRV6RFd4bThrwxBhhWfLjzqmd4rK8nX3Xs7zJqqp7
hex!["72bae70a1398c0ba52f815cc5dfbc9ec5c013771e541ae28e05d1129243e3001"]
.unchecked_into(),
), ),
( (
//5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ //5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ
@@ -330,23 +333,19 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
//5GeoZ1Mzix6Xnj32X8Xpj7q89X1SQHU5XTK1cnUVNXKTvXdK //5GeoZ1Mzix6Xnj32X8Xpj7q89X1SQHU5XTK1cnUVNXKTvXdK
hex!["caf27345aebc2fefeca85c9a67f4859eab3178d28ef92244714402290f3f415a"].into(), hex!["caf27345aebc2fefeca85c9a67f4859eab3178d28ef92244714402290f3f415a"].into(),
//5Et8y49AyE7ncVKiSRgzN6zbqbYtMK6y7kKuUaS8YqvfLBD9 //5Et8y49AyE7ncVKiSRgzN6zbqbYtMK6y7kKuUaS8YqvfLBD9
hex!["7ca58770eb41c1a68ef77e92255e4635fc11f665cb89aee469e920511c48343a"] hex!["7ca58770eb41c1a68ef77e92255e4635fc11f665cb89aee469e920511c48343a"].unchecked_into(),
.unchecked_into(),
//5Hpn3HVViECsuxMDFtinWjRj2dNfpRp1kB24nZHvQCJsSUek //5Hpn3HVViECsuxMDFtinWjRj2dNfpRp1kB24nZHvQCJsSUek
hex!["feca0be2c87141f6074b221c919c0161a1c468d9173c5c1be59b68fab9a0ff93"] hex!["feca0be2c87141f6074b221c919c0161a1c468d9173c5c1be59b68fab9a0ff93"].unchecked_into(),
.unchecked_into(), //5HHHSvewgWiwEBX5BWeeeYBXTn5qNDZSsbk1WvWGum1ohp3t
// 5Et8y49AyE7ncVKiSRgzN6zbqbYtMK6y7kKuUaS8YqvfLBD9 hex!["e6c53033eabfad2f519eecfcb01e89cf86b014d0b9c2fad93d84fb59d759115f"].unchecked_into(),
hex!["7ca58770eb41c1a68ef77e92255e4635fc11f665cb89aee469e920511c48343a"] //5GjwEr3FMP9hWd3WSrLccfCna7xEKnQhShp15F4UGGyB7X2j
.unchecked_into(), hex!["cedc8dbcba3c51aab26a043306366c28791533df33b6d92b822b626939cf2217"].unchecked_into(),
// 5Et8y49AyE7ncVKiSRgzN6zbqbYtMK6y7kKuUaS8YqvfLBD9 //5Gv7xHsEeAivjxH4tniXQ3MonKBRWs88xEgHAWym2XzZxb5n
hex!["7ca58770eb41c1a68ef77e92255e4635fc11f665cb89aee469e920511c48343a"] hex!["d6a113804a98728bb2af4f3721ab31a3644731292bffe0268995d8f8fb073b57"].unchecked_into(),
.unchecked_into(), //5DUrcztb1pRz6DfA8Vo8JSUSpoQVr27Yo6gjPmnumhhubLeN
// 5Et8y49AyE7ncVKiSRgzN6zbqbYtMK6y7kKuUaS8YqvfLBD9 hex!["3ea7a06009d1b9b1d4233dea3e6bb6494b9aeda91edc443629a28afa9fab8c62"].unchecked_into(),
hex!["7ca58770eb41c1a68ef77e92255e4635fc11f665cb89aee469e920511c48343a"] //5HUYyVYXjm5mdEpDiykmhxZGzQjY4LLxyTPD7hfMjfLUy3VT
.unchecked_into(), hex!["020e0ba5e112f0d3356ff8c78a37e2d7f76f90ab8dc9ed2eac98c87c5ffb2b0ebe"].unchecked_into(),
// 5Et8y49AyE7ncVKiSRgzN6zbqbYtMK6y7kKuUaS8YqvfLBD9
hex!["7ca58770eb41c1a68ef77e92255e4635fc11f665cb89aee469e920511c48343a"]
.unchecked_into(),
), ),
( (
//5HYYWyhyUQ7Ae11f8fCid58bhJ7ikLHM9bU8A6Ynwoc3dStR //5HYYWyhyUQ7Ae11f8fCid58bhJ7ikLHM9bU8A6Ynwoc3dStR
@@ -354,23 +353,19 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
//5DnUXT3xiQn6ZRttFT6eSCJbT9P2tiLdexr5WsvnbLG8igqW //5DnUXT3xiQn6ZRttFT6eSCJbT9P2tiLdexr5WsvnbLG8igqW
hex!["4c17a9bfdd19411f452fa32420fa7acab622e87e57351f4ba3248ae40ce75123"].into(), hex!["4c17a9bfdd19411f452fa32420fa7acab622e87e57351f4ba3248ae40ce75123"].into(),
//5EhnN1SumSv5KxwLAdwE8ugJaw1S8xARZb8V2BMYCKaD7ure //5EhnN1SumSv5KxwLAdwE8ugJaw1S8xARZb8V2BMYCKaD7ure
hex!["74bfb70627416e6e6c4785e928ced384c6c06e5c8dd173a094bc3118da7b673e"] hex!["74bfb70627416e6e6c4785e928ced384c6c06e5c8dd173a094bc3118da7b673e"].unchecked_into(),
.unchecked_into(),
//5Hmvd2qjb1zatrJTkPwgFicxPfZuwaTwa2L7adSRmz6mVxfb //5Hmvd2qjb1zatrJTkPwgFicxPfZuwaTwa2L7adSRmz6mVxfb
hex!["fc9d33059580a69454179ffa41cbae6de2bc8d2bd2c3f1d018fe5484a5a91956"] hex!["fc9d33059580a69454179ffa41cbae6de2bc8d2bd2c3f1d018fe5484a5a91956"].unchecked_into(),
.unchecked_into(), //5G1YwfKpir3fW3C4pHk1c8MX2XYpo1mQaTDxkpxyu8cQthEg
// 5EhnN1SumSv5KxwLAdwE8ugJaw1S8xARZb8V2BMYCKaD7ure hex!["ae8930d06f23b0f0e1f31717f12b9f31e7150ceb735b22e35ad86fd94e10125f"].unchecked_into(),
hex!["74bfb70627416e6e6c4785e928ced384c6c06e5c8dd173a094bc3118da7b673e"] //5GF6xvz37CmPyRsNgpQMFjBDv3crmh2rVRtxkASR8YWNJSKy
.unchecked_into(), hex!["b8df2d1ea3d352cb818868c71e21c06e7929b3c7fda62bb93f2cff9152efc844"].unchecked_into(),
// 5EhnN1SumSv5KxwLAdwE8ugJaw1S8xARZb8V2BMYCKaD7ure //5CPYVGRq4Gbntijd9FyoGX9QYVKXdeen4K9sFb8v3SuYoRWx
hex!["74bfb70627416e6e6c4785e928ced384c6c06e5c8dd173a094bc3118da7b673e"] hex!["0e5e1fb2c0fa7db11cd83fef3493900292badf02f35812ba738efeab9978a46c"].unchecked_into(),
.unchecked_into(), //5GvKehGrFVea8rywSeJhTopmpBDNHSFBoZp32g3CecppYa3V
// 5EhnN1SumSv5KxwLAdwE8ugJaw1S8xARZb8V2BMYCKaD7ure hex!["d6c8735316211321cd85ccd7c583222ab024393b8c86c7c8d1192a1d4f35bb2e"].unchecked_into(),
hex!["74bfb70627416e6e6c4785e928ced384c6c06e5c8dd173a094bc3118da7b673e"] //5FpX3V5qCGehdTBRxkpHzGjwK9nvihLYj6gwR4NWn8DjbAoL
.unchecked_into(), hex!["020b4bc2972761bd1abf20d5f83f79ff546ef63094e193d21758566c58dea9642f"].unchecked_into(),
// 5EhnN1SumSv5KxwLAdwE8ugJaw1S8xARZb8V2BMYCKaD7ure
hex!["74bfb70627416e6e6c4785e928ced384c6c06e5c8dd173a094bc3118da7b673e"]
.unchecked_into(),
), ),
( (
//5CFPcUJgYgWryPaV1aYjSbTpbTLu42V32Ytw1L9rfoMAsfGh //5CFPcUJgYgWryPaV1aYjSbTpbTLu42V32Ytw1L9rfoMAsfGh
@@ -378,24 +373,21 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
//5F6z64cYZFRAmyMUhp7rnge6jaZmbY6o7XfA9czJyuAUiaFD //5F6z64cYZFRAmyMUhp7rnge6jaZmbY6o7XfA9czJyuAUiaFD
hex!["8671d451c3d4f6de8c16ea0bc61cf714914d6b2ffa2899872620525419327478"].into(), hex!["8671d451c3d4f6de8c16ea0bc61cf714914d6b2ffa2899872620525419327478"].into(),
//5Ft7o2uqDq5pXCK4g5wR94BctmtLEzCBy5MvPqRa8753ZemD //5Ft7o2uqDq5pXCK4g5wR94BctmtLEzCBy5MvPqRa8753ZemD
hex!["a8ddd0891e14725841cd1b5581d23806a97f41c28a25436db6473c86e15dcd4f"] hex!["a8ddd0891e14725841cd1b5581d23806a97f41c28a25436db6473c86e15dcd4f"].unchecked_into(),
.unchecked_into(),
//5FgBijJLL6p7nDZgQed56L3BM7ovgwc4t4FYsv9apYtRGAGv //5FgBijJLL6p7nDZgQed56L3BM7ovgwc4t4FYsv9apYtRGAGv
hex!["9fc415cce1d0b2eed702c9e05f476217d23b46a8723fd56f08cddad650be7c2d"] hex!["9fc415cce1d0b2eed702c9e05f476217d23b46a8723fd56f08cddad650be7c2d"].unchecked_into(),
.unchecked_into(), //5DwPxYdY9FcNjMPptwrcGeeu1jbpWYwCdGc8cvjQNkY7nE8m
// 5Ft7o2uqDq5pXCK4g5wR94BctmtLEzCBy5MvPqRa8753ZemD hex!["52e57f2e1451ced7431c810cb4c3ad532ac4a37aeb9303f9a4a34d77a05aa269"].unchecked_into(),
hex!["a8ddd0891e14725841cd1b5581d23806a97f41c28a25436db6473c86e15dcd4f"] //5Ew1qAPRe3oGVynud5eDg2aXdJUtV3Wy16MWfjzbqv9cnLbe
.unchecked_into(), hex!["7ed73e3c97c7cf6a24d074e49d4ad750ecb2ed28886398a1b2916142c2bf5f62"].unchecked_into(),
// 5Ft7o2uqDq5pXCK4g5wR94BctmtLEzCBy5MvPqRa8753ZemD //5GVzBxaAf7au8VKnsKFNvFvzamdqbnuzXUxDfp5xkFivfqKv
hex!["a8ddd0891e14725841cd1b5581d23806a97f41c28a25436db6473c86e15dcd4f"] hex!["c4390ca0274f0262a4ef7cd4d3aa6cab0875a6efdd40d38c21be4f770b6c4b1a"].unchecked_into(),
.unchecked_into(), //5CZd519gfE3gALMtFWa283VHikXwoGFmT92B3Nu3iN7YGcaR
// 5Ft7o2uqDq5pXCK4g5wR94BctmtLEzCBy5MvPqRa8753ZemD hex!["160e0049b62d368c59d286275697e8d5e68d34ee8663ac4c3da646b0abb4a86f"].unchecked_into(),
hex!["a8ddd0891e14725841cd1b5581d23806a97f41c28a25436db6473c86e15dcd4f"] //5Fnu4YYBx9V71ihCBkJyFGsKw9Q2jjNzRQL9kRNpKTPNSAhc
.unchecked_into(), hex!["03e9393ee30ae95fc2b7864230f53e45409a807949390140ce2bc77756cdb4bb83"].unchecked_into(),
// 5Ft7o2uqDq5pXCK4g5wR94BctmtLEzCBy5MvPqRa8753ZemD
hex!["a8ddd0891e14725841cd1b5581d23806a97f41c28a25436db6473c86e15dcd4f"]
.unchecked_into(),
), ),
]; ];
const ENDOWMENT: u128 = 1_000_000 * WND; const ENDOWMENT: u128 = 1_000_000 * WND;
@@ -413,6 +405,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(), .collect(),
}, },
pallet_beefy: Default::default(),
pallet_indices: westend::IndicesConfig { indices: vec![] }, pallet_indices: westend::IndicesConfig { indices: vec![] },
pallet_session: westend::SessionConfig { pallet_session: westend::SessionConfig {
keys: initial_authorities keys: initial_authorities
@@ -428,6 +421,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
x.5.clone(), x.5.clone(),
x.6.clone(), x.6.clone(),
x.7.clone(), x.7.clone(),
x.8.clone(),
), ),
) )
}) })
@@ -683,8 +677,10 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
ImOnlineId, ImOnlineId,
ValidatorId, ValidatorId,
AssignmentId, AssignmentId,
AuthorityDiscoveryId AuthorityDiscoveryId,
)> = vec![( BeefyId,
)> = vec![
(
//5EHZkbp22djdbuMFH9qt1DVzSCvqi3zWpj6DAYfANa828oei //5EHZkbp22djdbuMFH9qt1DVzSCvqi3zWpj6DAYfANa828oei
hex!["62475fe5406a7cb6a64c51d0af9d3ab5c2151bcae982fb812f7a76b706914d6a"].into(), hex!["62475fe5406a7cb6a64c51d0af9d3ab5c2151bcae982fb812f7a76b706914d6a"].into(),
//5FeSEpi9UYYaWwXXb3tV88qtZkmSdB3mvgj3pXkxKyYLGhcd //5FeSEpi9UYYaWwXXb3tV88qtZkmSdB3mvgj3pXkxKyYLGhcd
@@ -701,6 +697,8 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!["ec60e71fe4a567ef9fef99d4bbf37ffae70564b41aa6f94ef0317c13e0a5477b"].unchecked_into(), hex!["ec60e71fe4a567ef9fef99d4bbf37ffae70564b41aa6f94ef0317c13e0a5477b"].unchecked_into(),
//5HbSgM72xVuscsopsdeG3sCSCYdAeM1Tay9p79N6ky6vwDGq //5HbSgM72xVuscsopsdeG3sCSCYdAeM1Tay9p79N6ky6vwDGq
hex!["f49eae66a0ac9f610316906ec8f1a0928e20d7059d76a5ca53cbcb5a9b50dd3c"].unchecked_into(), hex!["f49eae66a0ac9f610316906ec8f1a0928e20d7059d76a5ca53cbcb5a9b50dd3c"].unchecked_into(),
//5DPSWdgw38Spu315r6LSvYCggeeieBAJtP5A1qzuzKhqmjVu
hex!["034f68c5661a41930c82f26a662276bf89f33467e1c850f2fb8ef687fe43d62276"].unchecked_into(),
), ),
( (
//5DvH8oEjQPYhzCoQVo7WDU91qmQfLZvxe9wJcrojmJKebCmG //5DvH8oEjQPYhzCoQVo7WDU91qmQfLZvxe9wJcrojmJKebCmG
@@ -719,6 +717,8 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!["68bf52c482630a8d1511f2edd14f34127a7d7082219cccf7fd4c6ecdb535f80d"].unchecked_into(), hex!["68bf52c482630a8d1511f2edd14f34127a7d7082219cccf7fd4c6ecdb535f80d"].unchecked_into(),
//5HeXbwb5PxtcRoopPZTp5CQun38atn2UudQ8p2AxR5BzoaXw //5HeXbwb5PxtcRoopPZTp5CQun38atn2UudQ8p2AxR5BzoaXw
hex!["f6f8fe475130d21165446a02fb1dbce3a7bf36412e5d98f4f0473aed9252f349"].unchecked_into(), hex!["f6f8fe475130d21165446a02fb1dbce3a7bf36412e5d98f4f0473aed9252f349"].unchecked_into(),
//5F7nTtN8MyJV4UsXpjg7tHSnfANXZ5KRPJmkASc1ZSH2Xoa5
hex!["03a90c2bb6d3b7000020f6152fe2e5002fa970fd1f42aafb6c8edda8dacc2ea77e"].unchecked_into(),
), ),
( (
//5FPMzsezo1PRxYbVpJMWK7HNbR2kUxidsAAxH4BosHa4wd6S //5FPMzsezo1PRxYbVpJMWK7HNbR2kUxidsAAxH4BosHa4wd6S
@@ -737,6 +737,8 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!["244f3421b310c68646e99cdbf4963e02067601f57756b072a4b19431448c186e"].unchecked_into(), hex!["244f3421b310c68646e99cdbf4963e02067601f57756b072a4b19431448c186e"].unchecked_into(),
//5D4r6YaB6F7A7nvMRHNFNF6zrR9g39bqDJFenrcaFmTCRwfa //5D4r6YaB6F7A7nvMRHNFNF6zrR9g39bqDJFenrcaFmTCRwfa
hex!["2c57f81fd311c1ab53813c6817fe67f8947f8d39258252663b3384ab4195494d"].unchecked_into(), hex!["2c57f81fd311c1ab53813c6817fe67f8947f8d39258252663b3384ab4195494d"].unchecked_into(),
//5EPoHj8uV4fFKQHYThc6Z9fDkU7B6ih2ncVzQuDdNFb8UyhF
hex!["039d065fe4f9234f0a4f13cc3ae585f2691e9c25afa469618abb6645111f607a53"].unchecked_into(),
), ),
( (
//5DMNx7RoX6d7JQ38NEM7DWRcW2THu92LBYZEWvBRhJeqcWgR //5DMNx7RoX6d7JQ38NEM7DWRcW2THu92LBYZEWvBRhJeqcWgR
@@ -755,6 +757,8 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!["821271c99c958b9220f1771d9f5e29af969edfa865631dba31e1ab7bc0582b75"].unchecked_into(), hex!["821271c99c958b9220f1771d9f5e29af969edfa865631dba31e1ab7bc0582b75"].unchecked_into(),
//5CtgRR74VypK4h154s369abs78hDUxZSJqcbWsfXvsjcHJNA //5CtgRR74VypK4h154s369abs78hDUxZSJqcbWsfXvsjcHJNA
hex!["2496f28d887d84705c6dae98aee8bf90fc5ad10bb5545eca1de6b68425b70f7c"].unchecked_into(), hex!["2496f28d887d84705c6dae98aee8bf90fc5ad10bb5545eca1de6b68425b70f7c"].unchecked_into(),
//5CPx6dsr11SCJHKFkcAQ9jpparS7FwXQBrrMznRo4Hqv1PXz
hex!["0307d29bbf6a5c4061c2157b44fda33b7bb4ec52a5a0305668c74688cedf288d58"].unchecked_into(),
), ),
( (
//5C8AL1Zb4bVazgT3EgDxFgcow1L4SJjVu44XcLC9CrYqFN4N //5C8AL1Zb4bVazgT3EgDxFgcow1L4SJjVu44XcLC9CrYqFN4N
@@ -773,6 +777,8 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!["16c69ea8d595e80b6736f44be1eaeeef2ac9c04a803cc4fd944364cb0d617a33"].unchecked_into(), hex!["16c69ea8d595e80b6736f44be1eaeeef2ac9c04a803cc4fd944364cb0d617a33"].unchecked_into(),
//5DABsdQCDUGuhzVGWe5xXzYQ9rtrVxRygW7RXf9Tsjsw1aGJ //5DABsdQCDUGuhzVGWe5xXzYQ9rtrVxRygW7RXf9Tsjsw1aGJ
hex!["306ac5c772fe858942f92b6e28bd82fb7dd8cdd25f9a4626c1b0eee075fcb531"].unchecked_into(), hex!["306ac5c772fe858942f92b6e28bd82fb7dd8cdd25f9a4626c1b0eee075fcb531"].unchecked_into(),
//5H91T5mHhoCw9JJG4NjghDdQyhC6L7XcSuBWKD3q3TAhEVvQ
hex!["02fb0330356e63a35dd930bc74525edf28b3bf5eb44aab9e9e4962c8309aaba6a6"].unchecked_into(),
), ),
( (
//5C8XbDXdMNKJrZSrQURwVCxdNdk8AzG6xgLggbzuA399bBBF //5C8XbDXdMNKJrZSrQURwVCxdNdk8AzG6xgLggbzuA399bBBF
@@ -791,6 +797,8 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!["4c64d3f06d28adeb36a892fdaccecace150bec891f04694448a60b74fa469c22"].unchecked_into(), hex!["4c64d3f06d28adeb36a892fdaccecace150bec891f04694448a60b74fa469c22"].unchecked_into(),
//5CZdFnyzZvKetZTeUwj5APAYskVJe4QFiTezo5dQNsrnehGd //5CZdFnyzZvKetZTeUwj5APAYskVJe4QFiTezo5dQNsrnehGd
hex!["160ea09c5717270e958a3da42673fa011613a9539b2e4ebcad8626bc117ca04a"].unchecked_into(), hex!["160ea09c5717270e958a3da42673fa011613a9539b2e4ebcad8626bc117ca04a"].unchecked_into(),
//5HgoR9JJkdBusxKrrs3zgd3ToppgNoGj1rDyAJp4e7eZiYyT
hex!["020019a8bb188f8145d02fa855e9c36e9914457d37c500e03634b5223aa5702474"].unchecked_into(),
), ),
( (
//5HinEonzr8MywkqedcpsmwpxKje2jqr9miEwuzyFXEBCvVXM //5HinEonzr8MywkqedcpsmwpxKje2jqr9miEwuzyFXEBCvVXM
@@ -809,6 +817,8 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!["fab485e87ed1537d089df521edf983a777c57065a702d7ed2b6a2926f31da74f"].unchecked_into(), hex!["fab485e87ed1537d089df521edf983a777c57065a702d7ed2b6a2926f31da74f"].unchecked_into(),
//5ELv74v7QcsS6FdzvG4vL2NnYDGWmRnJUSMKYwdyJD7Xcdi7 //5ELv74v7QcsS6FdzvG4vL2NnYDGWmRnJUSMKYwdyJD7Xcdi7
hex!["64d59feddb3d00316a55906953fb3db8985797472bd2e6c7ea1ab730cc339d7f"].unchecked_into(), hex!["64d59feddb3d00316a55906953fb3db8985797472bd2e6c7ea1ab730cc339d7f"].unchecked_into(),
//5FaUcPt4fPz93vBhcrCJqmDkjYZ7jCbzAF56QJoCmvPaKrmx
hex!["033f1a6d47fe86f88934e4b83b9fae903b92b5dcf4fec97d5e3e8bf4f39df03685"].unchecked_into(),
), ),
( (
//5Ey3NQ3dfabaDc16NUv7wRLsFCMDFJSqZFzKVycAsWuUC6Di //5Ey3NQ3dfabaDc16NUv7wRLsFCMDFJSqZFzKVycAsWuUC6Di
@@ -827,7 +837,10 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!["481538f8c2c011a76d7d57db11c2789a5e83b0f9680dc6d26211d2f9c021ae4c"].unchecked_into(), hex!["481538f8c2c011a76d7d57db11c2789a5e83b0f9680dc6d26211d2f9c021ae4c"].unchecked_into(),
//5DqAvikdpfRdk5rR35ZobZhqaC5bJXZcEuvzGtexAZP1hU3T //5DqAvikdpfRdk5rR35ZobZhqaC5bJXZcEuvzGtexAZP1hU3T
hex!["4e262811acdfe94528bfc3c65036080426a0e1301b9ada8d687a70ffcae99c26"].unchecked_into(), hex!["4e262811acdfe94528bfc3c65036080426a0e1301b9ada8d687a70ffcae99c26"].unchecked_into(),
)]; //5E41Znrr2YtZu8bZp3nvRuLVHg3jFksfQ3tXuviLku4wsao7
hex!["025e84e95ed043e387ddb8668176b42f8e2773ddd84f7f58a6d9bf436a4b527986"].unchecked_into(),
),
];
const ENDOWMENT: u128 = 1_000_000 * ROC; const ENDOWMENT: u128 = 1_000_000 * ROC;
const STASH: u128 = 100 * ROC; const STASH: u128 = 100 * ROC;
@@ -843,6 +856,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(), .collect(),
}, },
pallet_beefy: Default::default(),
pallet_indices: rococo_runtime::IndicesConfig { pallet_indices: rococo_runtime::IndicesConfig {
indices: vec![], indices: vec![],
}, },
@@ -857,6 +871,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
x.5.clone(), x.5.clone(),
x.6.clone(), x.6.clone(),
x.7.clone(), x.7.clone(),
x.8.clone(),
), ),
)).collect::<Vec<_>>(), )).collect::<Vec<_>>(),
}, },
@@ -1022,6 +1037,26 @@ where
/// Helper function to generate stash, controller and session key from seed /// Helper function to generate stash, controller and session key from seed
pub fn get_authority_keys_from_seed( pub fn get_authority_keys_from_seed(
seed: &str, seed: &str,
) -> (
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
) {
let keys = get_authority_keys_from_seed_no_beefy(seed);
(
keys.0, keys.1, keys.2, keys.3, keys.4, keys.5, keys.6, keys.7, get_from_seed::<BeefyId>(seed)
)
}
/// Helper function to generate stash, controller and session key from seed
pub fn get_authority_keys_from_seed_no_beefy(
seed: &str,
) -> ( ) -> (
AccountId, AccountId,
AccountId, AccountId,
@@ -1269,6 +1304,7 @@ pub fn westend_testnet_genesis(
ValidatorId, ValidatorId,
AssignmentId, AssignmentId,
AuthorityDiscoveryId, AuthorityDiscoveryId,
BeefyId,
)>, )>,
root_key: AccountId, root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>, endowed_accounts: Option<Vec<AccountId>>,
@@ -1290,6 +1326,7 @@ pub fn westend_testnet_genesis(
.map(|k| (k.clone(), ENDOWMENT)) .map(|k| (k.clone(), ENDOWMENT))
.collect(), .collect(),
}, },
pallet_beefy: Default::default(),
pallet_session: westend::SessionConfig { pallet_session: westend::SessionConfig {
keys: initial_authorities keys: initial_authorities
.iter() .iter()
@@ -1304,6 +1341,7 @@ pub fn westend_testnet_genesis(
x.5.clone(), x.5.clone(),
x.6.clone(), x.6.clone(),
x.7.clone(), x.7.clone(),
x.8.clone(),
), ),
) )
}) })
@@ -1352,6 +1390,7 @@ pub fn rococo_testnet_genesis(
ValidatorId, ValidatorId,
AssignmentId, AssignmentId,
AuthorityDiscoveryId, AuthorityDiscoveryId,
BeefyId,
)>, )>,
root_key: AccountId, root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>, endowed_accounts: Option<Vec<AccountId>>,
@@ -1365,6 +1404,7 @@ pub fn rococo_testnet_genesis(
code: wasm_binary.to_vec(), code: wasm_binary.to_vec(),
changes_trie_config: Default::default(), changes_trie_config: Default::default(),
}, },
pallet_beefy: Default::default(),
pallet_indices: rococo_runtime::IndicesConfig { pallet_indices: rococo_runtime::IndicesConfig {
indices: vec![], indices: vec![],
}, },
@@ -1382,6 +1422,7 @@ pub fn rococo_testnet_genesis(
x.5.clone(), x.5.clone(),
x.6.clone(), x.6.clone(),
x.7.clone(), x.7.clone(),
x.8.clone(),
), ),
)).collect::<Vec<_>>(), )).collect::<Vec<_>>(),
}, },
@@ -1443,7 +1484,7 @@ pub fn rococo_testnet_genesis(
fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig { fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
polkadot_testnet_genesis( polkadot_testnet_genesis(
wasm_binary, wasm_binary,
vec![get_authority_keys_from_seed("Alice")], vec![get_authority_keys_from_seed_no_beefy("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
None, None,
) )
@@ -1452,7 +1493,7 @@ fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisC
fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig { fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
kusama_testnet_genesis( kusama_testnet_genesis(
wasm_binary, wasm_binary,
vec![get_authority_keys_from_seed("Alice")], vec![get_authority_keys_from_seed_no_beefy("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
None, None,
) )
@@ -1522,8 +1563,8 @@ fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig
polkadot_testnet_genesis( polkadot_testnet_genesis(
wasm_binary, wasm_binary,
vec![ vec![
get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed_no_beefy("Alice"),
get_authority_keys_from_seed("Bob"), get_authority_keys_from_seed_no_beefy("Bob"),
], ],
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
None, None,
@@ -1551,8 +1592,8 @@ fn kusama_local_testnet_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
kusama_testnet_genesis( kusama_testnet_genesis(
wasm_binary, wasm_binary,
vec![ vec![
get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed_no_beefy("Alice"),
get_authority_keys_from_seed("Bob"), get_authority_keys_from_seed_no_beefy("Bob"),
], ],
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
None, None,
+6 -1
View File
@@ -17,6 +17,7 @@
//! Polkadot Client meta trait //! Polkadot Client meta trait
use std::sync::Arc; use std::sync::Arc;
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
use sp_api::{ProvideRuntimeApi, CallApiAt, NumberFor}; use sp_api::{ProvideRuntimeApi, CallApiAt, NumberFor};
use sp_blockchain::HeaderBackend; use sp_blockchain::HeaderBackend;
use sp_runtime::{ use sp_runtime::{
@@ -36,11 +37,13 @@ pub trait RuntimeApiCollection:
+ ParachainHost<Block> + ParachainHost<Block>
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> + frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_mmr_primitives::MmrApi<Block, <Block as BlockT>::Hash>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block> + sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_authority_discovery::AuthorityDiscoveryApi<Block> + sp_authority_discovery::AuthorityDiscoveryApi<Block>
+ beefy_primitives::BeefyApi<Block, BeefyId>
where where
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>, <Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{} {}
@@ -54,11 +57,13 @@ where
+ ParachainHost<Block> + ParachainHost<Block>
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> + frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_mmr_primitives::MmrApi<Block, <Block as BlockT>::Hash>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block> + sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>, + sp_authority_discovery::AuthorityDiscoveryApi<Block>
+ beefy_primitives::BeefyApi<Block, BeefyId>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>, <Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{} {}
+45 -5
View File
@@ -40,6 +40,7 @@ use {
sc_keystore::LocalKeystore, sc_keystore::LocalKeystore,
babe_primitives::BabeApi, babe_primitives::BabeApi,
grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}, grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider},
beefy_primitives::ecdsa::AuthoritySignature as BeefySignature,
sp_runtime::traits::Header as HeaderT, sp_runtime::traits::Header as HeaderT,
}; };
#[cfg(feature = "real-overseer")] #[cfg(feature = "real-overseer")]
@@ -243,7 +244,8 @@ fn new_partial<RuntimeApi, Executor>(
Block, FullClient<RuntimeApi, Executor>, FullGrandpaBlockImport<RuntimeApi, Executor> Block, FullClient<RuntimeApi, Executor>, FullGrandpaBlockImport<RuntimeApi, Executor>
>, >,
grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>, grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
babe::BabeLink<Block> babe::BabeLink<Block>,
beefy_gadget::notification::BeefySignedCommitmentSender<Block, BeefySignature>,
), ),
grandpa::SharedVoterState, grandpa::SharedVoterState,
std::time::Duration, // slot-duration std::time::Duration, // slot-duration
@@ -342,6 +344,9 @@ fn new_partial<RuntimeApi, Executor>(
telemetry.as_ref().map(|x| x.handle()), telemetry.as_ref().map(|x| x.handle()),
)?; )?;
let (beefy_link, beefy_commitment_stream) =
beefy_gadget::notification::BeefySignedCommitmentStream::channel();
let justification_stream = grandpa_link.justification_stream(); let justification_stream = grandpa_link.justification_stream();
let shared_authority_set = grandpa_link.shared_authority_set().clone(); let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty(); let shared_voter_state = grandpa::SharedVoterState::empty();
@@ -350,7 +355,7 @@ fn new_partial<RuntimeApi, Executor>(
Some(shared_authority_set.clone()), Some(shared_authority_set.clone()),
); );
let import_setup = (block_import.clone(), grandpa_link, babe_link.clone()); let import_setup = (block_import.clone(), grandpa_link, babe_link.clone(), beefy_link);
let rpc_setup = shared_voter_state.clone(); let rpc_setup = shared_voter_state.clone();
let shared_epoch_changes = babe_link.epoch_changes().clone(); let shared_epoch_changes = babe_link.epoch_changes().clone();
@@ -363,7 +368,9 @@ fn new_partial<RuntimeApi, Executor>(
let select_chain = select_chain.clone(); let select_chain = select_chain.clone();
let chain_spec = config.chain_spec.cloned_box(); let chain_spec = config.chain_spec.cloned_box();
move |deny_unsafe, subscription_executor| -> polkadot_rpc::RpcExtension { move |deny_unsafe, subscription_executor: polkadot_rpc::SubscriptionTaskExecutor|
-> polkadot_rpc::RpcExtension
{
let deps = polkadot_rpc::FullDeps { let deps = polkadot_rpc::FullDeps {
client: client.clone(), client: client.clone(),
pool: transaction_pool.clone(), pool: transaction_pool.clone(),
@@ -379,9 +386,13 @@ fn new_partial<RuntimeApi, Executor>(
shared_voter_state: shared_voter_state.clone(), shared_voter_state: shared_voter_state.clone(),
shared_authority_set: shared_authority_set.clone(), shared_authority_set: shared_authority_set.clone(),
justification_stream: justification_stream.clone(), justification_stream: justification_stream.clone(),
subscription_executor, subscription_executor: subscription_executor.clone(),
finality_provider: finality_proof_provider.clone(), finality_provider: finality_proof_provider.clone(),
}, },
beefy: polkadot_rpc::BeefyDeps {
beefy_commitment_stream: beefy_commitment_stream.clone(),
subscription_executor,
},
}; };
polkadot_rpc::create_full(deps) polkadot_rpc::create_full(deps)
@@ -731,6 +742,11 @@ pub fn new_full<RuntimeApi, Executor>(
// anything in terms of behaviour, but makes the logs more consistent with the other // anything in terms of behaviour, but makes the logs more consistent with the other
// Substrate nodes. // Substrate nodes.
config.network.extra_sets.push(grandpa::grandpa_peers_set_config()); config.network.extra_sets.push(grandpa::grandpa_peers_set_config());
if config.chain_spec.is_westend() || config.chain_spec.is_rococo() {
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
}
#[cfg(feature = "real-overseer")] #[cfg(feature = "real-overseer")]
{ {
use polkadot_network_bridge::{peer_sets_info, IsAuthority}; use polkadot_network_bridge::{peer_sets_info, IsAuthority};
@@ -824,6 +840,7 @@ pub fn new_full<RuntimeApi, Executor>(
} }
let availability_config = config.database.clone().try_into().map_err(Error::Availability)?; let availability_config = config.database.clone().try_into().map_err(Error::Availability)?;
let chain_spec = config.chain_spec.cloned_box();
let approval_voting_config = ApprovalVotingConfig { let approval_voting_config = ApprovalVotingConfig {
path: config.database.path() path: config.database.path()
@@ -849,7 +866,7 @@ pub fn new_full<RuntimeApi, Executor>(
telemetry: telemetry.as_mut(), telemetry: telemetry.as_mut(),
})?; })?;
let (block_import, link_half, babe_link) = import_setup; let (block_import, link_half, babe_link, beefy_link) = import_setup;
let overseer_client = client.clone(); let overseer_client = client.clone();
let spawner = task_manager.spawn_handle(); let spawner = task_manager.spawn_handle();
@@ -967,6 +984,29 @@ pub fn new_full<RuntimeApi, Executor>(
task_manager.spawn_essential_handle().spawn_blocking("babe", babe); task_manager.spawn_essential_handle().spawn_blocking("babe", babe);
} }
// We currently only run the BEEFY gadget on Rococo and Westend test
// networks. On Rococo we start the BEEFY gadget as a normal (non-essential)
// task for now, since BEEFY is still experimental and we don't want a
// failure to bring down the whole node. Westend test network is less used
// than Rococo and therefore a failure there will be less problematic, this
// will be the main testing target for BEEFY for now.
if chain_spec.is_westend() || chain_spec.is_rococo() {
let gadget = beefy_gadget::start_beefy_gadget::<_, beefy_primitives::ecdsa::AuthorityPair, _, _, _, _>(
client.clone(),
keystore_container.sync_keystore(),
network.clone(),
beefy_link,
network.clone(),
prometheus_registry.clone()
);
if chain_spec.is_westend() {
task_manager.spawn_essential_handle().spawn_blocking("beefy-gadget", gadget);
} else {
task_manager.spawn_handle().spawn_blocking("beefy-gadget", gadget);
}
}
// if the node isn't actively participating in consensus then it doesn't // if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below. // need a keystore, regardless of which protocol we use below.
let keystore_opt = if role.is_authority() { let keystore_opt = if role.is_authority() {
+3
View File
@@ -25,6 +25,9 @@ sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "maste
sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
txpool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master" } txpool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master" }
frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" } frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
parity-scale-codec = { version = "2.0.0", default-features = false } parity-scale-codec = { version = "2.0.0", default-features = false }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
beefy-gadget = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master" }
beefy-gadget-rpc = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master" }
+28 -3
View File
@@ -74,8 +74,16 @@ pub struct GrandpaDeps<B> {
pub finality_provider: Arc<FinalityProofProvider<B, Block>>, pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
} }
/// Dependencies for BEEFY
pub struct BeefyDeps<BeefySignature> {
/// Receives notifications about signed commitment events from BEEFY.
pub beefy_commitment_stream: beefy_gadget::notification::BeefySignedCommitmentStream<Block, BeefySignature>,
/// Executor to drive the subscription manager in the BEEFY RPC handler.
pub subscription_executor: sc_rpc::SubscriptionTaskExecutor,
}
/// Full client dependencies /// Full client dependencies
pub struct FullDeps<C, P, SC, B> { pub struct FullDeps<C, P, SC, B, BS> {
/// The client instance to use. /// The client instance to use.
pub client: Arc<C>, pub client: Arc<C>,
/// Transaction pool instance. /// Transaction pool instance.
@@ -90,13 +98,16 @@ pub struct FullDeps<C, P, SC, B> {
pub babe: BabeDeps, pub babe: BabeDeps,
/// GRANDPA specific dependencies. /// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps<B>, pub grandpa: GrandpaDeps<B>,
/// BEEFY specific dependencies.
pub beefy: BeefyDeps<BS>,
} }
/// Instantiate all RPC extensions. /// Instantiate all RPC extensions.
pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension where pub fn create_full<C, P, SC, B, BS>(deps: FullDeps<C, P, SC, B, BS>) -> RpcExtension where
C: ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore + C: ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore +
HeaderMetadata<Block, Error=BlockChainError> + Send + Sync + 'static, HeaderMetadata<Block, Error=BlockChainError> + Send + Sync + 'static,
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>, C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_mmr_rpc::MmrRuntimeApi<Block, <Block as sp_runtime::traits::Block>::Hash>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BabeApi<Block>, C::Api: BabeApi<Block>,
C::Api: BlockBuilder<Block>, C::Api: BlockBuilder<Block>,
@@ -104,11 +115,13 @@ pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension whe
SC: SelectChain<Block> + 'static, SC: SelectChain<Block> + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static, B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::StateBackend<sp_runtime::traits::HashFor<Block>>, B::State: sc_client_api::StateBackend<sp_runtime::traits::HashFor<Block>>,
BS: Clone + Send + parity_scale_codec::Encode + 'static,
{ {
use frame_rpc_system::{FullSystem, SystemApi}; use frame_rpc_system::{FullSystem, SystemApi};
use pallet_mmr_rpc::{MmrApi, Mmr};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler};
use sc_consensus_babe_rpc::BabeRpcHandler; use sc_consensus_babe_rpc::BabeRpcHandler;
use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler};
let mut io = jsonrpc_core::IoHandler::default(); let mut io = jsonrpc_core::IoHandler::default();
let FullDeps { let FullDeps {
@@ -119,6 +132,7 @@ pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension whe
deny_unsafe, deny_unsafe,
babe, babe,
grandpa, grandpa,
beefy,
} = deps; } = deps;
let BabeDeps { let BabeDeps {
keystore, keystore,
@@ -139,6 +153,9 @@ pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension whe
io.extend_with( io.extend_with(
TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone())) TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone()))
); );
io.extend_with(
MmrApi::to_delegate(Mmr::new(client.clone()))
);
io.extend_with( io.extend_with(
sc_consensus_babe_rpc::BabeApi::to_delegate( sc_consensus_babe_rpc::BabeApi::to_delegate(
BabeRpcHandler::new( BabeRpcHandler::new(
@@ -169,6 +186,14 @@ pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension whe
deny_unsafe, deny_unsafe,
)) ))
); );
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(
beefy_gadget_rpc::BeefyRpcHandler::new(
beefy.beefy_commitment_stream,
beefy.subscription_executor,
),
));
io io
} }
+11 -3
View File
@@ -8,12 +8,13 @@ edition = "2018"
impl-trait-for-tuples = "0.2.0" impl-trait-for-tuples = "0.2.0"
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] } bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] } parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.13", optional = true } log = { version = "0.4.13", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false } rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.123", default-features = false } serde = { version = "1.0.123", default-features = false }
serde_derive = { version = "1.0.117", optional = true } serde_derive = { version = "1.0.117", optional = true }
static_assertions = "1.1.0" static_assertions = "1.1.0"
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -35,11 +36,14 @@ pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "m
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features=false, optional = true } pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features=false, optional = true }
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
libsecp256k1 = { version = "0.3.5", default-features = false, optional = true } libsecp256k1 = { version = "0.3.5", default-features = false }
runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false }
xcm = { path = "../../xcm", default-features = false } xcm = { path = "../../xcm", default-features = false }
@@ -63,9 +67,10 @@ libsecp256k1 = "0.3.5"
default = ["std"] default = ["std"]
no_std = [] no_std = []
std = [ std = [
"beefy-primitives/std",
"bitvec/std", "bitvec/std",
"parity-scale-codec/std", "parity-scale-codec/std",
"log", "log/std",
"rustc-hex/std", "rustc-hex/std",
"serde_derive", "serde_derive",
"serde/std", "serde/std",
@@ -78,6 +83,8 @@ std = [
"frame-support/std", "frame-support/std",
"pallet-authorship/std", "pallet-authorship/std",
"pallet-balances/std", "pallet-balances/std",
"pallet-beefy/std",
"pallet-mmr/std",
"pallet-session/std", "pallet-session/std",
"pallet-staking/std", "pallet-staking/std",
"pallet-timestamp/std", "pallet-timestamp/std",
@@ -88,6 +95,7 @@ std = [
"sp-session/std", "sp-session/std",
"sp-staking/std", "sp-staking/std",
"frame-system/std", "frame-system/std",
"libsecp256k1/std",
"runtime-parachains/std", "runtime-parachains/std",
"xcm/std", "xcm/std",
] ]
+3 -1
View File
@@ -25,14 +25,16 @@ pub mod auctions;
pub mod crowdloan; pub mod crowdloan;
pub mod purchase; pub mod purchase;
pub mod impls; pub mod impls;
pub mod mmr;
pub mod paras_sudo_wrapper; pub mod paras_sudo_wrapper;
pub mod paras_registrar; pub mod paras_registrar;
pub mod traits; pub mod traits;
pub mod xcm_sender;
#[cfg(test)] #[cfg(test)]
mod mock; mod mock;
#[cfg(test)] #[cfg(test)]
mod integration_tests; mod integration_tests;
pub mod xcm_sender;
use primitives::v1::{BlockNumber, ValidatorId, AssignmentId}; use primitives::v1::{BlockNumber, ValidatorId, AssignmentId};
use sp_runtime::{Perquintill, Perbill, FixedPointNumber}; use sp_runtime::{Perquintill, Perbill, FixedPointNumber};
+216
View File
@@ -0,0 +1,216 @@
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! A pallet responsible for creating Merkle Mountain Range (MMR) leaf for current block.
use beefy_primitives::ValidatorSetId;
use sp_core::H256;
use sp_runtime::traits::Convert;
use sp_std::prelude::*;
use frame_support::{decl_module, decl_storage, RuntimeDebug};
use pallet_mmr::primitives::LeafDataProvider;
use parity_scale_codec::{Encode, Decode};
use runtime_parachains::paras;
/// A BEEFY consensus digest item with MMR root hash.
pub struct DepositBeefyDigest<T>(sp_std::marker::PhantomData<T>);
impl<T> pallet_mmr::primitives::OnNewRoot<beefy_primitives::MmrRootHash> for DepositBeefyDigest<T> where
T: pallet_mmr::Config<Hash = beefy_primitives::MmrRootHash>,
T: pallet_beefy::Config,
{
fn on_new_root(root: &<T as pallet_mmr::Config>::Hash) {
let digest = sp_runtime::generic::DigestItem::Consensus(
beefy_primitives::BEEFY_ENGINE_ID,
parity_scale_codec::Encode::encode(
&beefy_primitives::ConsensusLog::<<T as pallet_beefy::Config>::AuthorityId>::MmrRoot(*root)
),
);
<frame_system::Pallet<T>>::deposit_log(digest);
}
}
/// Convert BEEFY secp256k1 public keys into uncompressed form
pub struct UncompressBeefyEcdsaKeys;
impl Convert<beefy_primitives::ecdsa::AuthorityId, Vec<u8>> for UncompressBeefyEcdsaKeys {
fn convert(a: beefy_primitives::ecdsa::AuthorityId) -> Vec<u8> {
use sp_core::crypto::Public;
let compressed_key = a.as_slice();
// TODO [ToDr] Temporary workaround until we have a better way to get uncompressed keys.
secp256k1::PublicKey::parse_slice(compressed_key, Some(secp256k1::PublicKeyFormat::Compressed))
.map(|pub_key| pub_key.serialize().to_vec())
.map_err(|_| {
log::error!(target: "runtime::beefy", "Invalid BEEFY PublicKey format!");
})
.unwrap_or_default()
}
}
/// A leaf that gets added every block to the MMR constructed by [pallet_mmr].
#[derive(RuntimeDebug, PartialEq, Eq, Clone, Encode, Decode)]
pub struct MmrLeaf<BlockNumber, Hash, MerkleRoot> {
/// Current block parent number and hash.
pub parent_number_and_hash: (BlockNumber, Hash),
/// A merkle root of all registered parachain heads.
pub parachain_heads: MerkleRoot,
/// A merkle root of the next BEEFY authority set.
pub beefy_next_authority_set: BeefyNextAuthoritySet<MerkleRoot>,
}
/// Details of the next BEEFY authority set.
#[derive(RuntimeDebug, Default, PartialEq, Eq, Clone, Encode, Decode)]
pub struct BeefyNextAuthoritySet<MerkleRoot> {
/// Id of the next set.
///
/// Id is required to correlate BEEFY signed commitments with the validator set.
/// Light Client can easily verify that the commitment witness it is getting is
/// produced by the latest validator set.
pub id: ValidatorSetId,
/// Number of validators in the set.
///
/// Some BEEFY Light Clients may use an interactive protocol to verify only subset
/// of signatures. We put set length here, so that these clients can verify the minimal
/// number of required signatures.
pub len: u32,
/// Merkle Root Hash build from BEEFY AuthorityIds.
///
/// This is used by Light Clients to confirm that the commitments are signed by the correct
/// validator set. Light Clients using interactive protocol, might verify only subset of
/// signatures, hence don't require the full list here (will receive inclusion proofs).
pub root: MerkleRoot,
}
type MerkleRootOf<T> = <T as pallet_mmr::Config>::Hash;
/// The module's configuration trait.
pub trait Config: pallet_mmr::Config + pallet_beefy::Config {
/// Convert BEEFY AuthorityId to a form that would end up in the Merkle Tree.
///
/// For instance for ECDSA (secp256k1) we want to store uncompressed public keys (65 bytes)
/// to simplify using them on Ethereum chain, but the rest of the Substrate codebase
/// is storing them compressed (33 bytes) for efficiency reasons.
type BeefyAuthorityToMerkleLeaf: Convert<<Self as pallet_beefy::Config>::AuthorityId, Vec<u8>>;
/// Retrieve a list of current parachain heads.
///
/// The trait is implemented for `paras` module, but since not all chains might have parachains,
/// and we want to keep the MMR leaf structure uniform, it's possible to use `()` as well to
/// simply put dummy data to the leaf.
type ParachainHeads: ParachainHeadsProvider;
}
/// A type that is able to return current list of parachain heads that end up in the MMR leaf.
pub trait ParachainHeadsProvider {
/// Return a list of encoded parachain heads.
fn encoded_heads() -> Vec<Vec<u8>>;
}
/// A default implementation for runtimes without parachains.
impl ParachainHeadsProvider for () {
fn encoded_heads() -> Vec<Vec<u8>> {
Default::default()
}
}
impl<T: Config + paras::Config> ParachainHeadsProvider for paras::Pallet<T> {
fn encoded_heads() -> Vec<Vec<u8>> {
paras::Pallet::<T>::parachains()
.into_iter()
.map(paras::Pallet::<T>::para_head)
.map(|maybe_para_head| maybe_para_head.encode())
.collect()
}
}
decl_storage! {
trait Store for Pallet<T: Config> as Beefy {
/// Details of next BEEFY authority set.
///
/// This storage entry is used as cache for calls to [`update_beefy_next_authority_set`].
pub BeefyNextAuthorities get(fn beefy_next_authorities): BeefyNextAuthoritySet<MerkleRootOf<T>>;
}
}
decl_module! {
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
}
}
impl<T: Config> LeafDataProvider for Pallet<T> where
MerkleRootOf<T>: From<H256>,
{
type LeafData = MmrLeaf<
<T as frame_system::Config>::BlockNumber,
<T as frame_system::Config>::Hash,
MerkleRootOf<T>,
>;
fn leaf_data() -> Self::LeafData {
MmrLeaf {
parent_number_and_hash: frame_system::Pallet::<T>::leaf_data(),
parachain_heads: Pallet::<T>::parachain_heads_merkle_root(),
beefy_next_authority_set: Pallet::<T>::update_beefy_next_authority_set(),
}
}
}
impl<T: Config> Pallet<T> where
MerkleRootOf<T>: From<H256>,
<T as pallet_beefy::Config>::AuthorityId:
{
/// Returns latest root hash of a merkle tree constructed from all registered parachain headers.
///
/// NOTE this does not include parathreads - only parachains are part of the merkle tree.
///
/// NOTE This is an initial and inefficient implementation, which re-constructs
/// the merkle tree every block. Instead we should update the merkle root in [Self::on_initialize]
/// call of this pallet and update the merkle tree efficiently (use on-chain storage to persist inner nodes).
fn parachain_heads_merkle_root() -> MerkleRootOf<T> {
let para_heads = T::ParachainHeads::encoded_heads();
sp_io::trie::keccak_256_ordered_root(para_heads).into()
}
/// Returns details of the next BEEFY authority set.
///
/// Details contain authority set id, authority set length and a merkle root,
/// constructed from uncompressed secp256k1 public keys of the next BEEFY authority set.
///
/// This function will use a storage-cached entry in case the set didn't change, or compute and cache
/// new one in case it did.
fn update_beefy_next_authority_set() -> BeefyNextAuthoritySet<MerkleRootOf<T>> {
let id = pallet_beefy::Pallet::<T>::validator_set_id() + 1;
let current_next = Self::beefy_next_authorities();
// avoid computing the merkle tree if validator set id didn't change.
if id == current_next.id {
return current_next;
}
let beefy_public_keys = pallet_beefy::Pallet::<T>::next_authorities()
.into_iter()
.map(T::BeefyAuthorityToMerkleLeaf::convert)
.collect::<Vec<_>>();
let len = beefy_public_keys.len() as u32;
let root: MerkleRootOf<T> = sp_io::trie::keccak_256_ordered_root(beefy_public_keys).into();
let next_set = BeefyNextAuthoritySet {
id,
len,
root,
};
// cache the result
BeefyNextAuthorities::<T>::put(&next_set);
next_set
}
}
+4
View File
@@ -17,6 +17,7 @@ smallvec = "1.6.1"
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -48,6 +49,7 @@ pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "m
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -154,6 +156,8 @@ std = [
"runtime-common/std", "runtime-common/std",
"frame-try-runtime/std", "frame-try-runtime/std",
"sp-npos-elections/std", "sp-npos-elections/std",
"beefy-primitives/std",
"pallet-mmr-primitives/std",
] ]
runtime-benchmarks = [ runtime-benchmarks = [
"runtime-common/runtime-benchmarks", "runtime-common/runtime-benchmarks",
+34
View File
@@ -66,6 +66,8 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pallet_session::historical as session_historical; use pallet_session::historical as session_historical;
use static_assertions::const_assert; use static_assertions::const_assert;
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
use pallet_mmr_primitives as mmr;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use pallet_staking::StakerStatus; pub use pallet_staking::StakerStatus;
@@ -1217,6 +1219,38 @@ sp_api::impl_runtime_apis! {
} }
} }
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> {
// dummy implementation due to lack of BEEFY pallet.
beefy_primitives::ValidatorSet { validators: Vec::new(), id: 0 }
}
}
impl mmr::MmrApi<Block, Hash> for Runtime {
fn generate_proof(_leaf_index: u64)
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
{
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::GenerateProof)
}
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::Verify)
}
fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
_proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> {
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::Verify)
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime { impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> Vec<(GrandpaId, u64)> { fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
Grandpa::grandpa_authorities() Grandpa::grandpa_authorities()
+4
View File
@@ -17,6 +17,7 @@ smallvec = "1.6.1"
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -48,6 +49,7 @@ pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "m
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -150,6 +152,8 @@ std = [
"runtime-common/std", "runtime-common/std",
"frame-try-runtime/std", "frame-try-runtime/std",
"sp-npos-elections/std", "sp-npos-elections/std",
"beefy-primitives/std",
"pallet-mmr-primitives/std",
] ]
runtime-benchmarks = [ runtime-benchmarks = [
"runtime-common/runtime-benchmarks", "runtime-common/runtime-benchmarks",
+34
View File
@@ -66,6 +66,8 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pallet_session::historical as session_historical; use pallet_session::historical as session_historical;
use static_assertions::const_assert; use static_assertions::const_assert;
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
use pallet_mmr_primitives as mmr;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use pallet_staking::StakerStatus; pub use pallet_staking::StakerStatus;
@@ -1243,6 +1245,38 @@ sp_api::impl_runtime_apis! {
} }
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> {
// dummy implementation due to lack of BEEFY pallet.
beefy_primitives::ValidatorSet { validators: Vec::new(), id: 0 }
}
}
impl mmr::MmrApi<Block, Hash> for Runtime {
fn generate_proof(_leaf_index: u64)
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
{
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::GenerateProof)
}
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::Verify)
}
fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
_proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> {
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::Verify)
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime { impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> Vec<(GrandpaId, u64)> { fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
Grandpa::grandpa_authorities() Grandpa::grandpa_authorities()
+13 -5
View File
@@ -28,21 +28,25 @@ block-builder-api = { package = "sp-block-builder", git = "https://github.com/pa
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", git = "https://github.com/paritytech/substrate", branch = "master" } pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", git = "https://github.com/paritytech/substrate", branch = "master" }
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -75,9 +79,13 @@ std = [
"pallet-authority-discovery/std", "pallet-authority-discovery/std",
"pallet-authorship/std", "pallet-authorship/std",
"pallet-babe/std", "pallet-babe/std",
"beefy-primitives/std",
"pallet-balances/std", "pallet-balances/std",
"pallet-beefy/std",
"pallet-grandpa/std", "pallet-grandpa/std",
"pallet-sudo/std", "pallet-sudo/std",
"pallet-mmr/std",
"pallet-mmr-primitives/std",
"pallet-indices/std", "pallet-indices/std",
"pallet-im-online/std", "pallet-im-online/std",
"pallet-session/std", "pallet-session/std",
+115 -2
View File
@@ -32,6 +32,7 @@ use primitives::v1::{
SessionInfo as SessionInfoData, SessionInfo as SessionInfoData,
}; };
use runtime_common::{ use runtime_common::{
mmr as mmr_common,
SlowAdjustingFeeUpdate, impls::ToAuthor, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, SlowAdjustingFeeUpdate, impls::ToAuthor, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
}; };
use runtime_parachains::{ use runtime_parachains::{
@@ -44,7 +45,7 @@ use sp_runtime::{
ApplyExtrinsicResult, KeyTypeId, Perbill, ModuleId, ApplyExtrinsicResult, KeyTypeId, Perbill, ModuleId,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}, transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{ traits::{
BlakeTwo256, Block as BlockT, OpaqueKeys, AccountIdLookup, self, Keccak256, BlakeTwo256, Block as BlockT, OpaqueKeys, AccountIdLookup,
Extrinsic as ExtrinsicT, SaturatedConversion, Verify, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
}, },
}; };
@@ -58,6 +59,8 @@ use pallet_grandpa::{AuthorityId as GrandpaId, fg_primitives};
use sp_core::{OpaqueMetadata, RuntimeDebug}; use sp_core::{OpaqueMetadata, RuntimeDebug};
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use pallet_session::historical as session_historical; use pallet_session::historical as session_historical;
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
use pallet_mmr_primitives as mmr;
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use runtime_common::{paras_sudo_wrapper, paras_registrar, xcm_sender, auctions, crowdloan, slots}; use runtime_common::{paras_sudo_wrapper, paras_registrar, xcm_sender, auctions, crowdloan, slots};
@@ -151,10 +154,29 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signatu
/// Extrinsic type that has already been checked. /// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Nonce, Call>; pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Nonce, Call>;
/// Executive: handles dispatch to the various modules. /// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllPallets>; pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
UpgradeSessionKeys,
>;
/// The payload being signed in transactions. /// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
// TODO [ToDr] Remove while BEEFY runtime upgrade is done.
impl_opaque_keys! {
pub struct OldSessionKeys {
pub grandpa: Grandpa,
pub babe: Babe,
pub im_online: ImOnline,
pub para_validator: Initializer,
pub para_assignment: SessionInfo,
pub authority_discovery: AuthorityDiscovery,
}
}
impl_opaque_keys! { impl_opaque_keys! {
pub struct SessionKeys { pub struct SessionKeys {
pub grandpa: Grandpa, pub grandpa: Grandpa,
@@ -163,6 +185,35 @@ impl_opaque_keys! {
pub para_validator: Initializer, pub para_validator: Initializer,
pub para_assignment: SessionInfo, pub para_assignment: SessionInfo,
pub authority_discovery: AuthorityDiscovery, pub authority_discovery: AuthorityDiscovery,
pub beefy: Beefy,
}
}
fn transform_session_keys(v: AccountId, old: OldSessionKeys) -> SessionKeys {
SessionKeys {
grandpa: old.grandpa,
babe: old.babe,
im_online: old.im_online,
para_validator: old.para_validator,
para_assignment: old.para_assignment,
authority_discovery: old.authority_discovery,
beefy: {
// We need to produce a dummy value that's unique for the validator.
let mut id = BeefyId::default();
let id_raw: &mut [u8] = id.as_mut();
id_raw.copy_from_slice(v.as_ref());
id_raw[0..4].copy_from_slice(b"beef");
id
},
}
}
// When this is removed, should also remove `OldSessionKeys`.
pub struct UpgradeSessionKeys;
impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
Session::upgrade_keys::<OldSessionKeys, _>(transform_session_keys);
Perbill::from_percent(50) * BlockWeights::get().max_block
} }
} }
@@ -215,6 +266,11 @@ construct_runtime! {
// Sudo // Sudo
Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>}, Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>},
// Bridges support.
Mmr: pallet_mmr::{Pallet, Call, Storage},
Beefy: pallet_beefy::{Pallet, Config<T>, Storage},
MmrLeaf: mmr_common::{Pallet, Storage},
// Validator Manager pallet. // Validator Manager pallet.
ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>}, ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>},
@@ -619,6 +675,24 @@ impl paras_registrar::Config for Runtime {
/// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES. /// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES.
pub struct ParentHashRandomness; pub struct ParentHashRandomness;
impl pallet_beefy::Config for Runtime {
type AuthorityId = BeefyId;
}
impl pallet_mmr::Config for Runtime {
const INDEXING_PREFIX: &'static [u8] = b"mmr";
type Hashing = Keccak256;
type Hash = <Keccak256 as traits::Hash>::Output;
type OnNewRoot = mmr_common::DepositBeefyDigest<Runtime>;
type WeightInfo = ();
type LeafData = mmr_common::Pallet<Runtime>;
}
impl mmr_common::Config for Runtime {
type BeefyAuthorityToMerkleLeaf = mmr_common::UncompressBeefyEcdsaKeys;
type ParachainHeads = Paras;
}
impl Randomness<Hash, BlockNumber> for ParentHashRandomness { impl Randomness<Hash, BlockNumber> for ParentHashRandomness {
fn random(subject: &[u8]) -> (Hash, BlockNumber) { fn random(subject: &[u8]) -> (Hash, BlockNumber) {
( (
@@ -981,6 +1055,45 @@ sp_api::impl_runtime_apis! {
} }
} }
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> {
Beefy::validator_set()
}
}
impl pallet_mmr_primitives::MmrApi<Block, Hash> for Runtime {
fn generate_proof(leaf_index: u64)
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
{
Mmr::generate_proof(leaf_index)
.map(|(leaf, proof)| (mmr::EncodableOpaqueLeaf::from_leaf(&leaf), proof))
}
fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
pub type Leaf = <
<Runtime as pallet_mmr::Config>::LeafData as mmr::LeafDataProvider
>::LeafData;
let leaf: Leaf = leaf
.into_opaque_leaf()
.try_decode()
.ok_or(mmr::Error::Verify)?;
Mmr::verify_leaf(leaf, proof)
}
fn verify_proof_stateless(
root: Hash,
leaf: mmr::EncodableOpaqueLeaf,
proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> {
type MmrHashing = <Runtime as pallet_mmr::Config>::Hashing;
let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf());
pallet_mmr::verify_leaf_proof::<MmrHashing, _>(root, node, proof)
}
}
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime { impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
fn account_nonce(account: AccountId) -> Nonce { fn account_nonce(account: AccountId) -> Nonce {
System::account_nonce(account) System::account_nonce(account)
+2
View File
@@ -16,6 +16,7 @@ smallvec = "1.6.1"
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -39,6 +40,7 @@ pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/parityt
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
+34
View File
@@ -69,6 +69,8 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pallet_session::historical as session_historical; use pallet_session::historical as session_historical;
use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints; use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints;
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
use pallet_mmr_primitives as mmr;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use pallet_staking::StakerStatus; pub use pallet_staking::StakerStatus;
@@ -701,6 +703,38 @@ sp_api::impl_runtime_apis! {
} }
} }
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> {
// dummy implementation due to lack of BEEFY pallet.
beefy_primitives::ValidatorSet { validators: Vec::new(), id: 0 }
}
}
impl mmr::MmrApi<Block, Hash> for Runtime {
fn generate_proof(_leaf_index: u64)
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
{
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::GenerateProof)
}
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::Verify)
}
fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
_proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> {
// dummy implementation due to lack of MMR pallet.
Err(mmr::Error::Verify)
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime { impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> Vec<(GrandpaId, u64)> { fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
Grandpa::grandpa_authorities() Grandpa::grandpa_authorities()
+9
View File
@@ -17,6 +17,7 @@ static_assertions = "1.1.0"
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -34,6 +35,7 @@ sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch =
pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -47,6 +49,8 @@ pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "m
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -124,6 +128,10 @@ std = [
"pallet-im-online/std", "pallet-im-online/std",
"pallet-indices/std", "pallet-indices/std",
"pallet-membership/std", "pallet-membership/std",
"pallet-beefy/std",
"pallet-mmr/std",
"pallet-mmr-primitives/std",
"beefy-primitives/std",
"pallet-multisig/std", "pallet-multisig/std",
"pallet-nicks/std", "pallet-nicks/std",
"pallet-offences/std", "pallet-offences/std",
@@ -171,6 +179,7 @@ runtime-benchmarks = [
"pallet-identity/runtime-benchmarks", "pallet-identity/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks", "pallet-im-online/runtime-benchmarks",
"pallet-indices/runtime-benchmarks", "pallet-indices/runtime-benchmarks",
"pallet-mmr/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks", "pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks", "pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks",
+108 -2
View File
@@ -31,6 +31,7 @@ use primitives::v1::{
InboundDownwardMessage, InboundHrmpMessage, SessionInfo, InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
}; };
use runtime_common::{ use runtime_common::{
mmr as mmr_common,
SlowAdjustingFeeUpdate, CurrencyToVote, SlowAdjustingFeeUpdate, CurrencyToVote,
impls::ToAuthor, impls::ToAuthor,
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, OffchainSolutionWeightLimit, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, OffchainSolutionWeightLimit,
@@ -41,7 +42,7 @@ use sp_runtime::{
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear, ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}, transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{ traits::{
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup, Keccak256, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
Extrinsic as ExtrinsicT, SaturatedConversion, Verify, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
}, },
}; };
@@ -63,6 +64,8 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pallet_session::historical as session_historical; use pallet_session::historical as session_historical;
use frame_system::{EnsureRoot}; use frame_system::{EnsureRoot};
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
use pallet_mmr_primitives as mmr;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use pallet_staking::StakerStatus; pub use pallet_staking::StakerStatus;
@@ -263,6 +266,18 @@ parameter_types! {
pub const Offset: BlockNumber = 0; pub const Offset: BlockNumber = 0;
} }
// TODO [ToDr] Remove while BEEFY runtime upgrade is done.
impl_opaque_keys! {
pub struct OldSessionKeys {
pub grandpa: Grandpa,
pub babe: Babe,
pub im_online: ImOnline,
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
pub authority_discovery: AuthorityDiscovery,
}
}
impl_opaque_keys! { impl_opaque_keys! {
pub struct SessionKeys { pub struct SessionKeys {
pub grandpa: Grandpa, pub grandpa: Grandpa,
@@ -271,6 +286,35 @@ impl_opaque_keys! {
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>, pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>, pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
pub authority_discovery: AuthorityDiscovery, pub authority_discovery: AuthorityDiscovery,
pub beefy: Beefy,
}
}
fn transform_session_keys(v: AccountId, old: OldSessionKeys) -> SessionKeys {
SessionKeys {
grandpa: old.grandpa,
babe: old.babe,
im_online: old.im_online,
para_validator: old.para_validator,
para_assignment: old.para_assignment,
authority_discovery: old.authority_discovery,
beefy: {
// We need to produce a dummy value that's unique for the validator.
let mut id = BeefyId::default();
let id_raw: &mut [u8] = id.as_mut();
id_raw.copy_from_slice(v.as_ref());
id_raw[0..4].copy_from_slice(b"beef");
id
},
}
}
// When this is removed, should also remove `OldSessionKeys`.
pub struct UpgradeSessionKeys;
impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
Session::upgrade_keys::<OldSessionKeys, _>(transform_session_keys);
Perbill::from_percent(50) * BlockWeights::get().max_block
} }
} }
@@ -581,6 +625,24 @@ impl pallet_sudo::Config for Runtime {
type Call = Call; type Call = Call;
} }
impl pallet_beefy::Config for Runtime {
type AuthorityId = BeefyId;
}
impl pallet_mmr::Config for Runtime {
const INDEXING_PREFIX: &'static [u8] = b"mmr";
type Hashing = Keccak256;
type Hash = <Keccak256 as sp_runtime::traits::Hash>::Output;
type OnNewRoot = mmr_common::DepositBeefyDigest<Runtime>;
type WeightInfo = ();
type LeafData = mmr_common::Pallet<Runtime>;
}
impl mmr_common::Config for Runtime {
type BeefyAuthorityToMerkleLeaf = mmr_common::UncompressBeefyEcdsaKeys;
type ParachainHeads = ();
}
parameter_types! { parameter_types! {
// One storage item; key size 32, value size 8; . // One storage item; key size 32, value size 8; .
pub const ProxyDepositBase: Balance = deposit(1, 8); pub const ProxyDepositBase: Balance = deposit(1, 8);
@@ -739,6 +801,11 @@ construct_runtime! {
// Election pallet. Only works with staking, but placed here to maintain indices. // Election pallet. Only works with staking, but placed here to maintain indices.
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 24, ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 24,
// Bridges support.
Mmr: pallet_mmr::{Pallet, Call, Storage} = 28,
Beefy: pallet_beefy::{Pallet, Config<T>, Storage} = 29,
MmrLeaf: mmr_common::{Pallet, Storage} = 30,
} }
} }
@@ -788,7 +855,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>, frame_system::ChainContext<Runtime>,
Runtime, Runtime,
AllPallets, AllPallets,
BabeEpochConfigMigrations (BabeEpochConfigMigrations, UpgradeSessionKeys),
>; >;
/// The payload being signed in transactions. /// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
@@ -917,6 +984,45 @@ sp_api::impl_runtime_apis! {
} }
} }
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> {
Beefy::validator_set()
}
}
impl pallet_mmr_primitives::MmrApi<Block, Hash> for Runtime {
fn generate_proof(leaf_index: u64)
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
{
Mmr::generate_proof(leaf_index)
.map(|(leaf, proof)| (mmr::EncodableOpaqueLeaf::from_leaf(&leaf), proof))
}
fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
pub type Leaf = <
<Runtime as pallet_mmr::Config>::LeafData as mmr::LeafDataProvider
>::LeafData;
let leaf: Leaf = leaf
.into_opaque_leaf()
.try_decode()
.ok_or(mmr::Error::Verify)?;
Mmr::verify_leaf(leaf, proof)
}
fn verify_proof_stateless(
root: Hash,
leaf: mmr::EncodableOpaqueLeaf,
proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> {
type MmrHashing = <Runtime as pallet_mmr::Config>::Hashing;
let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf());
pallet_mmr::verify_leaf_proof::<MmrHashing, _>(root, node, proof)
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime { impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> Vec<(GrandpaId, u64)> { fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
Grandpa::grandpa_authorities() Grandpa::grandpa_authorities()
+12
View File
@@ -14,6 +14,17 @@ generate_address() {
subkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "SS58 Address" | awk '{ print $3 }' subkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "SS58 Address" | awk '{ print $3 }'
} }
generate_public_key() {
subkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "Public" | awk '{ print $4 }'
}
generate_address_and_public_key() {
ADDRESS=$(generate_address $1 $2 $3)
PUBLIC_KEY=$(generate_public_key $1 $2 $3)
printf "//$ADDRESS\nhex![\"${PUBLIC_KEY#'0x'}\"].unchecked_into(),"
}
generate_address_and_account_id() { generate_address_and_account_id() {
ACCOUNT=$(generate_account_id $1 $2 $3) ACCOUNT=$(generate_account_id $1 $2 $3)
ADDRESS=$(generate_address $1 $2 $3) ADDRESS=$(generate_address $1 $2 $3)
@@ -40,6 +51,7 @@ for i in $(seq 1 $V_NUM); do
AUTHORITIES+="$(generate_address_and_account_id $i para_validator '--scheme sr25519' true)\n" AUTHORITIES+="$(generate_address_and_account_id $i para_validator '--scheme sr25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i para_assignment '--scheme sr25519' true)\n" AUTHORITIES+="$(generate_address_and_account_id $i para_assignment '--scheme sr25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i authority_discovery '--scheme sr25519' true)\n" AUTHORITIES+="$(generate_address_and_account_id $i authority_discovery '--scheme sr25519' true)\n"
AUTHORITIES+="$(generate_address_and_public_key $i beefy '--scheme ecdsa' true)\n"
AUTHORITIES+="),\n" AUTHORITIES+="),\n"
done done