mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
Update bridges subtree (#5165)
* Squashed 'bridges/' changes from 1602249f0a..f220d2fcca f220d2fcca Polkadot staging update (#1356) 02fd3d497c fix parse_transaction on Rialto+Millau (#1360) bc191fd9a2 update parity-scale-codec to 3.1.2 (#1359) a37226e79c update chain versions (#1358) ff5d539fcb Update Substrate/Polkadot/Cumulus references (#1353) 1581f60cd5 Support dedicated lanes for pallets (#962) 0a7ccf5c57 ignore more "increase" alerts that are sometimes signalling NoData at startup (#1351) 31165127cc added no_stack_overflow_when_decoding_nested_call_during_dispatch test (#1349) 7000619eb8 replace From<>InboundLaneApi with direct storage reads (#1348) 515df10ccc added alerts for relay balances (#1347) b56f6a87de Mortal conversion rate updater transactions (#1257) 20f2f331ec edition = "2021" (#1346) 99147d4f75 update regex to 1.5.5 (#1345) 686191f379 use DecodeLimit when decoding incoming calls (#1344) a70c276006 get rid of '[No Data] Messages from Millau to Rialto are not being delivered' warnings (#1342) 01f29b8ac1 fix conversion rate metric in dashboards (#1341) 51c3bf351f Increase rate from metric when estimating fee (#1340) 3bb9c4f68f fix generator scripts to be consistent with updatedrelay output (#1339) 0475a1667b fixed mess with conversion rates (#1338) d8fdd7d716 synchronize relay cli changes and token swap generator script (#1337) 6e928137a5 fix conversion rate override in token swap (#1336) 62d4a4811d override conversion rate in tokens swap generator (#1335) ed9e1c839c fi typo in generator script (#1334) 3254b5af7a Override conversion rate when computing message fee (#1261) 66df68b5b8 Revert "Revert "override conversion rate in estimate-message-fee RPC (#1189)" (#1275)" (#1333) 0ca6fc6ef8 fix clippy issues (#1332) 5414b2fffb Reinitialize bridge relay subcommand (#1331) a63d95ba7d removed extra *_RUNTIME_VERSION consts from relay code (#1330) 59fb18a310 fix typo in alert expression (#1329) a6267a47ee Using-same-fork metric for finality and complex relay (#1327) 88d684d37e use mortal transactions in transaction resubmitter (#1326) 8ff88b6844 impl Decode for SignedExtensions (otherwise transaction resubmitter panicks) (#1325) 1ed09854f0 Encode and estimate Rococo/Wococo/Kusama/Polkadot messages (#1322) ddb4517e13 Add some tests to check integrity of chain constants + bridge configuration (#1316) bdeedb7ab9 Fix issues from cargo deny (#1311) d3d79d01e0 expose fee multiplier metrics in messages relay (#1312) c8b3f0ea16 Endow relayer account at target chain in message benchmarks (#1310) f51ecd92b6 fix benchmarks before using it in Polkadot/Kusama/Rococo runtimes (#1309) 6935c619ad increase relay balance guard limits for Polkadot<>Kusama bridge (#1308) 7e31834c66 Fix mandatory headers scanning in on-demand relay (#1306) 92ddc3ea7a Polkadot-staging update (#1305) 3787193a31 fix session length of Rococo and Wococo (#1304) eb468d29c0 Revert nightly docker pin (#1301) e2d4c073e1 Use raw balance value if tokenDecimals property is missing (#1299) 108f4b29d1 Fix ss58 prefixes of Polkadot, Kusama and Westend used by relay (#1298) 64fbd2705e bump chain spec versions (#1297) 5707777b86 Bump Substrate/Polkadot/Cumulus refs (#1295) 29eecdf1fa Merge pull request #1294 from paritytech/polkadot-staging-update 1f0c05368e Relay balance metrics (#1291) 6356bb90b3 when messages pallet is halted, relay shall not submit messages delivery/confirmation transactions (#1289) 800dc2df8d when GRANDPA pallet is halted, relay shall not submit finality transactions (#1288) 3dd8e4f936 disable BEEFY allerts for Rialto (#1285) f58fed7380 support version mode cli options in send-message subcommand (#1284) 3aac448da3 reuse polkadot-service code (#1273) 2bdbb651e1 replace latest_confirmed_nonce runtime APIs with direct storage reads (#1282) 5f9c6d241f move "common" code of messages pallet benchmarks helpers to the common library (#1281) 173d2d8229 Merge pull request #1280 from paritytech/polkadot-staging-update 8b9c4ec16d do not start spec_version guard when version mode is set to auto (#1278) e98d682de2 removed extra messages benchmarks (#1279) c730e25b61 Move benchmarks from Rialto to Millau (#1277) 54146416e7 Merge pull request #1276 from paritytech/polkadot-staging-update df70118174 Merge branch 'master' into polkadot-staging-update ed7def64c4 Revert "override conversion rate in estimate-message-fee RPC (#1189)" (#1275) 38c6c3a49f Use "production" floating tag when uilding docker image from version git tags (#1272) ded9ff6dbb Replace InboundLaneApi::latest_received_nonce with direct storage read (#1269) f704a741ee Polkadot staging update (#1270) 8c65f0d7ab verify that GRANDPA pallet is not initialized before submitting initialization transaction (#1267) e7e83d8944 remove OutboundLaneApi::latest_received_nonce (#1262) 9f4b34acf1 bump rococo version (#1263) 82c08c5a87 read latest_generated_nonce directly from storage (#1260) 50ffb5dd08 override conversion rate in estimate-message-fee RPC (#1189) 467ca5ef59 move storage keys computation to primitivs (#1254) 4f9884066b remporary use pinned bridges-ci image in Dockerfile (#1258) edfcb74e00 Change submit transaction spec_version and transaction_version query from chain (#1248) 4009d970d0 pin bridges-ci image (#1256) 65e51b5e1c decrease startup sleep to 5s for relays and to 120s for generators + remove curl (#1251) 3bc74355d9 Add missing RPC APIs to rialto parachain node (#1250) 80c9429284 Bump relay version to 1.0.0 (#1249) 9ead06af2a runtimes: fix call_size() test (#1245) 4fc8a29357 Use same endowed accounts set on dev/local chains (#1244) fed54371c2 Refactor message relay helpers (#1234) a15b4faae7 post-merge build fix (#1243) 52232d8d54 Fix transactions mortality (#1196) c07bba931f Expose prometheus BEEFY metrics and add them to grafana dashboard (#1242) f927775bd5 Refactor finality relay helpers (#1220) 7bf76f14a8 Update Rococo/Wococo version + prepare relay for Rococo<>Wococo bridge (#1241) e860fecd04 Enable offchain indexing for Rialto/Millau nodes (#1239) 04d4d1c6b4 Enable Beefy debug logs in test deployment (#1237) cd771f1089 Fix storage parameter name computation (#1238) 816ddd2dd2 Integrate BEEFY with Rialto & Millau runtimes (#1227) d94b62b1ac update dependencies (#1229) 98eb9ee13d Add mut support (#1232) ffef6f89f9 fixed set_operational in GRANDPA pallet (#1226) bd2f8bfbd7 Add CODEOWNERS file (#1219) 6b5cf2b591 Unify metric names (#1209) d1541e797e remove abandoned exchange relay (#1217) 39140d0b34 Remove unused `relays/headers` (#1216) 9bc071d42b Remove unused PoA<>Substrate bridge (#1210) 877e8d01e3 Fix UI deployment. (#1211) 6cd5775ebe Add `AtLeast32BitUnsigned` for MessageLance::SourceChainBalance (#1207) git-subtree-dir: bridges git-subtree-split: f220d2fccabbf141101d19456ecb4e3576a1d797 * fix compilation warnings
This commit is contained in:
committed by
GitHub
parent
20da356434
commit
8e01ba9c03
Generated
+11
-2
@@ -726,9 +726,12 @@ name = "bp-header-chain"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assert_matches",
|
"assert_matches",
|
||||||
|
"bp-runtime",
|
||||||
"bp-test-utils",
|
"bp-test-utils",
|
||||||
"finality-grandpa",
|
"finality-grandpa",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
|
"hex",
|
||||||
|
"hex-literal",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -757,10 +760,13 @@ dependencies = [
|
|||||||
"bp-runtime",
|
"bp-runtime",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
"frame-system",
|
"frame-system",
|
||||||
|
"hex",
|
||||||
|
"hex-literal",
|
||||||
"impl-trait-for-tuples",
|
"impl-trait-for-tuples",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
"serde",
|
"serde",
|
||||||
|
"sp-core",
|
||||||
"sp-std",
|
"sp-std",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -853,18 +859,23 @@ dependencies = [
|
|||||||
"bp-runtime",
|
"bp-runtime",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
|
"frame-system",
|
||||||
"hash-db",
|
"hash-db",
|
||||||
|
"pallet-balances",
|
||||||
"pallet-bridge-dispatch",
|
"pallet-bridge-dispatch",
|
||||||
"pallet-bridge-grandpa",
|
"pallet-bridge-grandpa",
|
||||||
"pallet-bridge-messages",
|
"pallet-bridge-messages",
|
||||||
"pallet-transaction-payment",
|
"pallet-transaction-payment",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
|
"sp-api",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
"sp-state-machine",
|
"sp-state-machine",
|
||||||
"sp-std",
|
"sp-std",
|
||||||
"sp-trie",
|
"sp-trie",
|
||||||
|
"sp-version",
|
||||||
|
"static_assertions",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5256,8 +5267,6 @@ dependencies = [
|
|||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
"frame-system",
|
"frame-system",
|
||||||
"hex",
|
|
||||||
"hex-literal",
|
|
||||||
"log",
|
"log",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"pallet-balances",
|
"pallet-balances",
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ default:
|
|||||||
when:
|
when:
|
||||||
- runner_system_failure
|
- runner_system_failure
|
||||||
- unknown_failure
|
- unknown_failure
|
||||||
- api_failure
|
- api_failure
|
||||||
interruptible: true
|
interruptible: true
|
||||||
tags:
|
tags:
|
||||||
- linux-docker
|
- linux-docker
|
||||||
@@ -240,7 +240,14 @@ build-nightly:
|
|||||||
elif [[ "${CI_COMMIT_REF_NAME}" ]]; then
|
elif [[ "${CI_COMMIT_REF_NAME}" ]]; then
|
||||||
VERSION=$(echo ${CI_COMMIT_REF_NAME} | sed -r 's#/+#-#g');
|
VERSION=$(echo ${CI_COMMIT_REF_NAME} | sed -r 's#/+#-#g');
|
||||||
fi
|
fi
|
||||||
- echo "Effective tags = ${VERSION} sha-${CI_COMMIT_SHORT_SHA} latest"
|
# When building from version tags (v1.0, v2.1rc1, ...) we'll use "production" to tag
|
||||||
|
# docker image. In all other cases, it'll be "latest".
|
||||||
|
- if [[ $CI_COMMIT_REF_NAME =~ ^v[0-9]+\.[0-9]+.*$ ]]; then
|
||||||
|
FLOATING_TAG="production";
|
||||||
|
else
|
||||||
|
FLOATING_TAG="latest";
|
||||||
|
fi
|
||||||
|
- echo "Effective tags = ${VERSION} sha-${CI_COMMIT_SHORT_SHA} ${FLOATING_TAG}"
|
||||||
secrets:
|
secrets:
|
||||||
DOCKER_HUB_USER:
|
DOCKER_HUB_USER:
|
||||||
vault: cicd/gitlab/parity/DOCKER_HUB_USER@kv
|
vault: cicd/gitlab/parity/DOCKER_HUB_USER@kv
|
||||||
@@ -260,7 +267,7 @@ build-nightly:
|
|||||||
--build-arg VERSION="${VERSION}"
|
--build-arg VERSION="${VERSION}"
|
||||||
--tag "${IMAGE_NAME}:${VERSION}"
|
--tag "${IMAGE_NAME}:${VERSION}"
|
||||||
--tag "${IMAGE_NAME}:sha-${CI_COMMIT_SHORT_SHA}"
|
--tag "${IMAGE_NAME}:sha-${CI_COMMIT_SHORT_SHA}"
|
||||||
--tag "${IMAGE_NAME}:latest"
|
--tag "${IMAGE_NAME}:${FLOATING_TAG}"
|
||||||
--file "${DOCKERFILE}" .
|
--file "${DOCKERFILE}" .
|
||||||
# The job will success only on the protected branch
|
# The job will success only on the protected branch
|
||||||
- echo "${DOCKER_HUB_PASS}" |
|
- echo "${DOCKER_HUB_PASS}" |
|
||||||
@@ -268,7 +275,7 @@ build-nightly:
|
|||||||
- buildah info
|
- buildah info
|
||||||
- buildah push --format=v2s2 "${IMAGE_NAME}:${VERSION}"
|
- buildah push --format=v2s2 "${IMAGE_NAME}:${VERSION}"
|
||||||
- buildah push --format=v2s2 "${IMAGE_NAME}:sha-${CI_COMMIT_SHORT_SHA}"
|
- buildah push --format=v2s2 "${IMAGE_NAME}:sha-${CI_COMMIT_SHORT_SHA}"
|
||||||
- buildah push --format=v2s2 "${IMAGE_NAME}:latest"
|
- buildah push --format=v2s2 "${IMAGE_NAME}:${FLOATING_TAG}"
|
||||||
after_script:
|
after_script:
|
||||||
- env REGISTRY_AUTH_FILE= buildah logout --all
|
- env REGISTRY_AUTH_FILE= buildah logout --all
|
||||||
|
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
|
||||||
// This file is part of Parity Bridges Common.
|
|
||||||
|
|
||||||
// Parity Bridges Common 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.
|
|
||||||
|
|
||||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see
|
|
||||||
<http: //www.gnu.org/licenses />.
|
|
||||||
|
|
||||||
//! Autogenerated weights for `{{pallet}}`
|
|
||||||
//!
|
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}}
|
|
||||||
//! DATE: {{date}}, STEPS: {{cmd.steps}}, REPEAT: {{cmd.repeat}}
|
|
||||||
//! LOW RANGE: {{cmd.lowest_range_values}}, HIGH RANGE: {{cmd.highest_range_values}}
|
|
||||||
//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}
|
|
||||||
//! CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}}
|
|
||||||
|
|
||||||
// Executed Command:
|
|
||||||
{{#each args as |arg|~}}
|
|
||||||
// {{arg}}
|
|
||||||
{{/each}}
|
|
||||||
|
|
||||||
#![allow(clippy::all)]
|
|
||||||
#![allow(unused_parens)]
|
|
||||||
#![allow(unused_imports)]
|
|
||||||
|
|
||||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
|
||||||
use sp_std::marker::PhantomData;
|
|
||||||
|
|
||||||
/// Weight functions needed for `{{pallet}}`.
|
|
||||||
pub trait WeightInfo {
|
|
||||||
{{~#each benchmarks as |benchmark|}}
|
|
||||||
fn {{benchmark.name~}}
|
|
||||||
(
|
|
||||||
{{~#each benchmark.components as |c| ~}}
|
|
||||||
{{c.name}}: u32, {{/each~}}
|
|
||||||
) -> Weight;
|
|
||||||
{{~/each}}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Weights for `{{pallet}}` using the Rialto node and recommended hardware.
|
|
||||||
pub struct RialtoWeight<T>(PhantomData<T>);
|
|
||||||
impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
|
||||||
{{~#each benchmarks as |benchmark|}}
|
|
||||||
fn {{benchmark.name~}}
|
|
||||||
(
|
|
||||||
{{~#each benchmark.components as |c| ~}}
|
|
||||||
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
|
|
||||||
) -> Weight {
|
|
||||||
({{underscore benchmark.base_weight}} as Weight)
|
|
||||||
{{~#each benchmark.component_weight as |cw|}}
|
|
||||||
.saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))
|
|
||||||
{{~/each}}
|
|
||||||
{{~#if (ne benchmark.base_reads "0")}}
|
|
||||||
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight))
|
|
||||||
{{~/if}}
|
|
||||||
{{~#each benchmark.component_reads as |cr|}}
|
|
||||||
.saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as
|
|
||||||
Weight)))
|
|
||||||
{{~/each}}
|
|
||||||
{{~#if (ne benchmark.base_writes "0")}}
|
|
||||||
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight))
|
|
||||||
{{~/if}}
|
|
||||||
{{~#each benchmark.component_writes as |cw|}}
|
|
||||||
.saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as
|
|
||||||
Weight)))
|
|
||||||
{{~/each}}
|
|
||||||
}
|
|
||||||
{{~/each}}
|
|
||||||
}
|
|
||||||
|
|
||||||
// For backwards compatibility and tests
|
|
||||||
impl WeightInfo for () {
|
|
||||||
{{~#each benchmarks as |benchmark|}}
|
|
||||||
fn {{benchmark.name~}}
|
|
||||||
(
|
|
||||||
{{~#each benchmark.components as |c| ~}}
|
|
||||||
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
|
|
||||||
) -> Weight {
|
|
||||||
({{underscore benchmark.base_weight}} as Weight)
|
|
||||||
{{~#each benchmark.component_weight as |cw|}}
|
|
||||||
.saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))
|
|
||||||
{{~/each}}
|
|
||||||
{{~#if (ne benchmark.base_reads "0")}}
|
|
||||||
.saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as Weight))
|
|
||||||
{{~/if}}
|
|
||||||
{{~#each benchmark.component_reads as |cr|}}
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as
|
|
||||||
Weight)))
|
|
||||||
{{~/each}}
|
|
||||||
{{~#if (ne benchmark.base_writes "0")}}
|
|
||||||
.saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as Weight))
|
|
||||||
{{~/if}}
|
|
||||||
{{~#each benchmark.component_writes as |cw|}}
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as
|
|
||||||
Weight)))
|
|
||||||
{{~/each}}
|
|
||||||
}
|
|
||||||
{{~/each}}
|
|
||||||
}
|
|
||||||
@@ -3,15 +3,15 @@ name = "millau-bridge-node"
|
|||||||
description = "Substrate node compatible with Millau runtime"
|
description = "Substrate node compatible with Millau runtime"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
homepage = "https://substrate.dev"
|
homepage = "https://substrate.dev"
|
||||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = { version = "3.1", features = ["derive"] }
|
||||||
jsonrpc-core = "18.0"
|
jsonrpc-core = "18.0"
|
||||||
structopt = "0.3.21"
|
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
|
|
||||||
# Bridge dependencies
|
# Bridge dependencies
|
||||||
|
|||||||
@@ -88,21 +88,14 @@ impl Alternative {
|
|||||||
testnet_genesis(
|
testnet_genesis(
|
||||||
vec![get_authority_keys_from_seed("Alice")],
|
vec![get_authority_keys_from_seed("Alice")],
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
vec![
|
endowed_accounts(),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
|
||||||
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
properties,
|
properties,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
@@ -120,54 +113,14 @@ impl Alternative {
|
|||||||
get_authority_keys_from_seed("Eve"),
|
get_authority_keys_from_seed("Eve"),
|
||||||
],
|
],
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
vec![
|
endowed_accounts(),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("George"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Harry"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("George//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Harry//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("RialtoMessagesOwner"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("WithRialtoTokenSwap"),
|
|
||||||
pallet_bridge_messages::relayer_fund_account_id::<
|
|
||||||
bp_millau::AccountId,
|
|
||||||
bp_millau::AccountIdConverter,
|
|
||||||
>(),
|
|
||||||
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
)),
|
|
||||||
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
)),
|
|
||||||
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
|
||||||
)),
|
|
||||||
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
|
||||||
)),
|
|
||||||
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
|
||||||
)),
|
|
||||||
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
properties,
|
properties,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
@@ -175,6 +128,55 @@ impl Alternative {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// We're using the same set of endowed accounts on all Millau chains (dev/local) to make
|
||||||
|
/// sure that all accounts, required for bridge to be functional (e.g. relayers fund account,
|
||||||
|
/// accounts used by relayers in our test deployments, accounts used for demonstration
|
||||||
|
/// purposes), are all available on these chains.
|
||||||
|
fn endowed_accounts() -> Vec<AccountId> {
|
||||||
|
vec![
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("George"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Harry"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("George//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Harry//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("RialtoMessagesOwner"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("WithRialtoTokenSwap"),
|
||||||
|
pallet_bridge_messages::relayer_fund_account_id::<
|
||||||
|
bp_millau::AccountId,
|
||||||
|
bp_millau::AccountIdConverter,
|
||||||
|
>(),
|
||||||
|
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
)),
|
||||||
|
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
|
)),
|
||||||
|
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||||
|
)),
|
||||||
|
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||||
|
)),
|
||||||
|
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||||
|
)),
|
||||||
|
derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||||
|
)),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
fn session_keys(aura: AuraId, beefy: BeefyId, grandpa: GrandpaId) -> SessionKeys {
|
fn session_keys(aura: AuraId, beefy: BeefyId, grandpa: GrandpaId) -> SessionKeys {
|
||||||
SessionKeys { aura, beefy, grandpa }
|
SessionKeys { aura, beefy, grandpa }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
use sc_cli::RunCmd;
|
use sc_cli::RunCmd;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[structopt(subcommand)]
|
#[structopt(subcommand)]
|
||||||
pub subcommand: Option<Subcommand>,
|
pub subcommand: Option<Subcommand>,
|
||||||
@@ -27,9 +27,10 @@ pub struct Cli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Possible subcommands of the main binary.
|
/// Possible subcommands of the main binary.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub enum Subcommand {
|
pub enum Subcommand {
|
||||||
/// Key management CLI utilities
|
/// Key management CLI utilities
|
||||||
|
#[clap(subcommand)]
|
||||||
Key(sc_cli::KeySubcommand),
|
Key(sc_cli::KeySubcommand),
|
||||||
|
|
||||||
/// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key.
|
/// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key.
|
||||||
|
|||||||
@@ -30,14 +30,13 @@
|
|||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
|
|
||||||
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
||||||
use sc_client_api::ExecutorProvider;
|
use sc_client_api::{BlockBackend, ExecutorProvider};
|
||||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||||
pub use sc_executor::NativeElseWasmExecutor;
|
pub use sc_executor::NativeElseWasmExecutor;
|
||||||
use sc_finality_grandpa::SharedVoterState;
|
use sc_finality_grandpa::SharedVoterState;
|
||||||
use sc_keystore::LocalKeystore;
|
use sc_keystore::LocalKeystore;
|
||||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
||||||
use sc_telemetry::{Telemetry, TelemetryWorker};
|
use sc_telemetry::{Telemetry, TelemetryWorker};
|
||||||
use sp_consensus::SlotData;
|
|
||||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
@@ -66,6 +65,7 @@ type FullClient =
|
|||||||
type FullBackend = sc_service::TFullBackend<Block>;
|
type FullBackend = sc_service::TFullBackend<Block>;
|
||||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||||
|
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn new_partial(
|
pub fn new_partial(
|
||||||
config: &Configuration,
|
config: &Configuration,
|
||||||
) -> Result<
|
) -> Result<
|
||||||
@@ -89,7 +89,7 @@ pub fn new_partial(
|
|||||||
ServiceError,
|
ServiceError,
|
||||||
> {
|
> {
|
||||||
if config.keystore_remote.is_some() {
|
if config.keystore_remote.is_some() {
|
||||||
return Err(ServiceError::Other(format!("Remote Keystores are not supported.")))
|
return Err(ServiceError::Other("Remote Keystores are not supported.".into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
let telemetry = config
|
let telemetry = config
|
||||||
@@ -112,7 +112,7 @@ pub fn new_partial(
|
|||||||
|
|
||||||
let (client, backend, keystore_container, task_manager) =
|
let (client, backend, keystore_container, task_manager) =
|
||||||
sc_service::new_full_parts::<Block, RuntimeApi, _>(
|
sc_service::new_full_parts::<Block, RuntimeApi, _>(
|
||||||
&config,
|
config,
|
||||||
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
||||||
executor,
|
executor,
|
||||||
)?;
|
)?;
|
||||||
@@ -140,7 +140,7 @@ pub fn new_partial(
|
|||||||
telemetry.as_ref().map(|x| x.handle()),
|
telemetry.as_ref().map(|x| x.handle()),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
|
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
|
||||||
|
|
||||||
let import_queue =
|
let import_queue =
|
||||||
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(ImportQueueParams {
|
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(ImportQueueParams {
|
||||||
@@ -151,7 +151,7 @@ pub fn new_partial(
|
|||||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
||||||
|
|
||||||
let slot =
|
let slot =
|
||||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||||
*timestamp,
|
*timestamp,
|
||||||
slot_duration,
|
slot_duration,
|
||||||
);
|
);
|
||||||
@@ -179,7 +179,7 @@ pub fn new_partial(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remote_keystore(_url: &String) -> Result<Arc<LocalKeystore>, &'static str> {
|
fn remote_keystore(_url: &str) -> Result<Arc<LocalKeystore>, &'static str> {
|
||||||
// FIXME: here would the concrete keystore be built,
|
// FIXME: here would the concrete keystore be built,
|
||||||
// must return a concrete type (NOT `LocalKeystore`) that
|
// must return a concrete type (NOT `LocalKeystore`) that
|
||||||
// implements `CryptoStore` and `SyncCryptoStore`
|
// implements `CryptoStore` and `SyncCryptoStore`
|
||||||
@@ -210,8 +210,27 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
|
// Note: GrandPa is pushed before the Polkadot-specific protocols. This doesn't change
|
||||||
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
|
// anything in terms of behaviour, but makes the logs more consistent with the other
|
||||||
|
// Substrate nodes.
|
||||||
|
let grandpa_protocol_name = sc_finality_grandpa::protocol_standard_name(
|
||||||
|
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
||||||
|
&config.chain_spec,
|
||||||
|
);
|
||||||
|
config
|
||||||
|
.network
|
||||||
|
.extra_sets
|
||||||
|
.push(sc_finality_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
|
||||||
|
|
||||||
|
let beefy_protocol_name = beefy_gadget::protocol_standard_name(
|
||||||
|
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
||||||
|
&config.chain_spec,
|
||||||
|
);
|
||||||
|
config
|
||||||
|
.network
|
||||||
|
.extra_sets
|
||||||
|
.push(beefy_gadget::beefy_peers_set_config(beefy_protocol_name.clone()));
|
||||||
|
|
||||||
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
|
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
|
||||||
backend.clone(),
|
backend.clone(),
|
||||||
grandpa_link.shared_authority_set().clone(),
|
grandpa_link.shared_authority_set().clone(),
|
||||||
@@ -245,8 +264,10 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
let enable_grandpa = !config.disable_grandpa;
|
let enable_grandpa = !config.disable_grandpa;
|
||||||
let prometheus_registry = config.prometheus_registry().cloned();
|
let prometheus_registry = config.prometheus_registry().cloned();
|
||||||
let shared_voter_state = SharedVoterState::empty();
|
let shared_voter_state = SharedVoterState::empty();
|
||||||
let (signed_commitment_sender, signed_commitment_stream) =
|
let (beefy_commitment_link, beefy_commitment_stream) =
|
||||||
beefy_gadget::notification::BeefySignedCommitmentStream::channel();
|
beefy_gadget::notification::BeefySignedCommitmentStream::<Block>::channel();
|
||||||
|
let (beefy_best_block_link, beefy_best_block_stream) =
|
||||||
|
beefy_gadget::notification::BeefyBestBlockStream::<Block>::channel();
|
||||||
|
|
||||||
let rpc_extensions_builder = {
|
let rpc_extensions_builder = {
|
||||||
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
|
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
|
||||||
@@ -287,10 +308,12 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
finality_proof_provider.clone(),
|
finality_proof_provider.clone(),
|
||||||
)));
|
)));
|
||||||
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(
|
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(
|
||||||
beefy_gadget_rpc::BeefyRpcHandler::new(
|
beefy_gadget_rpc::BeefyRpcHandler::<Block>::new(
|
||||||
signed_commitment_stream.clone(),
|
beefy_commitment_stream.clone(),
|
||||||
|
beefy_best_block_stream.clone(),
|
||||||
subscription_executor,
|
subscription_executor,
|
||||||
),
|
)
|
||||||
|
.map_err(|e| sc_service::Error::Other(format!("{}", e)))?,
|
||||||
));
|
));
|
||||||
io.extend_with(pallet_mmr_rpc::MmrApi::to_delegate(pallet_mmr_rpc::Mmr::new(
|
io.extend_with(pallet_mmr_rpc::MmrApi::to_delegate(pallet_mmr_rpc::Mmr::new(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
@@ -325,7 +348,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||||
|
|
||||||
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
|
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
|
||||||
let raw_slot_duration = slot_duration.slot_duration();
|
|
||||||
|
|
||||||
let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _, _>(
|
let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _, _>(
|
||||||
StartAuraParams {
|
StartAuraParams {
|
||||||
@@ -338,9 +360,9 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
||||||
|
|
||||||
let slot =
|
let slot =
|
||||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||||
*timestamp,
|
*timestamp,
|
||||||
raw_slot_duration,
|
slot_duration,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok((timestamp, slot))
|
Ok((timestamp, slot))
|
||||||
@@ -374,9 +396,11 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
backend,
|
backend,
|
||||||
key_store: keystore.clone(),
|
key_store: keystore.clone(),
|
||||||
network: network.clone(),
|
network: network.clone(),
|
||||||
signed_commitment_sender,
|
signed_commitment_sender: beefy_commitment_link,
|
||||||
|
beefy_best_block_sender: beefy_best_block_link,
|
||||||
min_block_delta: 4,
|
min_block_delta: 4,
|
||||||
prometheus_registry: prometheus_registry.clone(),
|
prometheus_registry: prometheus_registry.clone(),
|
||||||
|
protocol_name: beefy_protocol_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start the BEEFY bridge gadget.
|
// Start the BEEFY bridge gadget.
|
||||||
@@ -395,6 +419,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
keystore,
|
keystore,
|
||||||
local_role: role,
|
local_role: role,
|
||||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||||
|
protocol_name: grandpa_protocol_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
if enable_grandpa {
|
if enable_grandpa {
|
||||||
|
|||||||
@@ -2,20 +2,22 @@
|
|||||||
name = "millau-runtime"
|
name = "millau-runtime"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
homepage = "https://substrate.dev"
|
homepage = "https://substrate.dev"
|
||||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hex-literal = "0.3"
|
hex-literal = "0.3"
|
||||||
codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] }
|
||||||
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||||
|
|
||||||
# Bridge dependencies
|
# Bridge dependencies
|
||||||
|
|
||||||
bp-header-chain = { path = "../../../primitives/header-chain", default-features = false }
|
bp-header-chain = { path = "../../../primitives/header-chain", default-features = false }
|
||||||
|
bp-message-dispatch = { path = "../../../primitives/message-dispatch", default-features = false }
|
||||||
bp-messages = { path = "../../../primitives/messages", default-features = false }
|
bp-messages = { path = "../../../primitives/messages", default-features = false }
|
||||||
bp-millau = { path = "../../../primitives/chain-millau", default-features = false }
|
bp-millau = { path = "../../../primitives/chain-millau", default-features = false }
|
||||||
bp-rialto = { path = "../../../primitives/chain-rialto", default-features = false }
|
bp-rialto = { path = "../../../primitives/chain-rialto", default-features = false }
|
||||||
@@ -63,6 +65,10 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch
|
|||||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] }
|
||||||
|
static_assertions = "1.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|
||||||
@@ -71,6 +77,7 @@ default = ["std"]
|
|||||||
std = [
|
std = [
|
||||||
"beefy-primitives/std",
|
"beefy-primitives/std",
|
||||||
"bp-header-chain/std",
|
"bp-header-chain/std",
|
||||||
|
"bp-message-dispatch/std",
|
||||||
"bp-messages/std",
|
"bp-messages/std",
|
||||||
"bp-millau/std",
|
"bp-millau/std",
|
||||||
"bp-rialto/std",
|
"bp-rialto/std",
|
||||||
@@ -116,8 +123,12 @@ std = [
|
|||||||
"sp-version/std",
|
"sp-version/std",
|
||||||
]
|
]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking",
|
"bridge-runtime-common/runtime-benchmarks",
|
||||||
|
"frame-benchmarking/runtime-benchmarks",
|
||||||
"frame-support/runtime-benchmarks",
|
"frame-support/runtime-benchmarks",
|
||||||
"frame-system/runtime-benchmarks",
|
"frame-system/runtime-benchmarks",
|
||||||
|
"libsecp256k1",
|
||||||
|
"pallet-bridge-messages/runtime-benchmarks",
|
||||||
"pallet-bridge-token-swap/runtime-benchmarks",
|
"pallet-bridge-token-swap/runtime-benchmarks",
|
||||||
|
"sp-runtime/runtime-benchmarks",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ use sp_runtime::{
|
|||||||
create_runtime_str, generic, impl_opaque_keys,
|
create_runtime_str, generic, impl_opaque_keys,
|
||||||
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
|
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
|
||||||
transaction_validity::{TransactionSource, TransactionValidity},
|
transaction_validity::{TransactionSource, TransactionValidity},
|
||||||
ApplyExtrinsicResult, FixedPointNumber, MultiSignature, MultiSigner, Perquintill,
|
ApplyExtrinsicResult, FixedPointNumber, FixedU128, MultiSignature, MultiSigner, Perquintill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
@@ -136,6 +136,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 1,
|
impl_version: 1,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The version information used to identify this runtime when compiled natively.
|
/// The version information used to identify this runtime when compiled natively.
|
||||||
@@ -373,12 +374,26 @@ parameter_types! {
|
|||||||
// Note that once this is hit the pallet will essentially throttle incoming requests down to one
|
// Note that once this is hit the pallet will essentially throttle incoming requests down to one
|
||||||
// call per block.
|
// call per block.
|
||||||
pub const MaxRequests: u32 = 50;
|
pub const MaxRequests: u32 = 50;
|
||||||
|
}
|
||||||
|
|
||||||
// Number of headers to keep.
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
//
|
parameter_types! {
|
||||||
// Assuming the worst case of every header being finalized, we will keep headers for at least a
|
/// Number of headers to keep in benchmarks.
|
||||||
// week.
|
///
|
||||||
pub const HeadersToKeep: u32 = 7 * bp_millau::DAYS as u32;
|
/// In benchmarks we always populate with full number of `HeadersToKeep` to make sure that
|
||||||
|
/// pruning is taken into account.
|
||||||
|
///
|
||||||
|
/// Note: This is lower than regular value, to speed up benchmarking setup.
|
||||||
|
pub const HeadersToKeep: u32 = 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||||
|
parameter_types! {
|
||||||
|
/// Number of headers to keep.
|
||||||
|
///
|
||||||
|
/// Assuming the worst case of every header being finalized, we will keep headers at least for a
|
||||||
|
/// week.
|
||||||
|
pub const HeadersToKeep: u32 = 7 * bp_rialto::DAYS as u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type RialtoGrandpaInstance = ();
|
pub type RialtoGrandpaInstance = ();
|
||||||
@@ -387,8 +402,7 @@ impl pallet_bridge_grandpa::Config for Runtime {
|
|||||||
type MaxRequests = MaxRequests;
|
type MaxRequests = MaxRequests;
|
||||||
type HeadersToKeep = HeadersToKeep;
|
type HeadersToKeep = HeadersToKeep;
|
||||||
|
|
||||||
// TODO [#391]: Use weights generated for the Millau runtime instead of Rialto ones.
|
type WeightInfo = pallet_bridge_grandpa::weights::MillauWeight<Runtime>;
|
||||||
type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type WestendGrandpaInstance = pallet_bridge_grandpa::Instance1;
|
pub type WestendGrandpaInstance = pallet_bridge_grandpa::Instance1;
|
||||||
@@ -397,8 +411,7 @@ impl pallet_bridge_grandpa::Config<WestendGrandpaInstance> for Runtime {
|
|||||||
type MaxRequests = MaxRequests;
|
type MaxRequests = MaxRequests;
|
||||||
type HeadersToKeep = HeadersToKeep;
|
type HeadersToKeep = HeadersToKeep;
|
||||||
|
|
||||||
// TODO [#391]: Use weights generated for the Millau runtime instead of Rialto ones.
|
type WeightInfo = pallet_bridge_grandpa::weights::MillauWeight<Runtime>;
|
||||||
type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_shift_session_manager::Config for Runtime {}
|
impl pallet_shift_session_manager::Config for Runtime {}
|
||||||
@@ -406,9 +419,9 @@ impl pallet_shift_session_manager::Config for Runtime {}
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
|
pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
|
||||||
pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce =
|
pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce =
|
||||||
bp_millau::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE;
|
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
|
||||||
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
||||||
bp_millau::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE;
|
bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
||||||
// `IdentityFee` is used by Millau => we may use weight directly
|
// `IdentityFee` is used by Millau => we may use weight directly
|
||||||
pub const GetDeliveryConfirmationTransactionFee: Balance =
|
pub const GetDeliveryConfirmationTransactionFee: Balance =
|
||||||
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _;
|
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _;
|
||||||
@@ -421,8 +434,7 @@ pub type WithRialtoMessagesInstance = ();
|
|||||||
|
|
||||||
impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
|
impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/390
|
type WeightInfo = pallet_bridge_messages::weights::MillauWeight<Runtime>;
|
||||||
type WeightInfo = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
|
||||||
type Parameter = rialto_messages::MillauToRialtoMessagesParameter;
|
type Parameter = rialto_messages::MillauToRialtoMessagesParameter;
|
||||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||||
@@ -442,10 +454,9 @@ impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
|
|||||||
type MessageDeliveryAndDispatchPayment =
|
type MessageDeliveryAndDispatchPayment =
|
||||||
pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
|
pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
|
||||||
Runtime,
|
Runtime,
|
||||||
(),
|
WithRialtoMessagesInstance,
|
||||||
pallet_balances::Pallet<Runtime>,
|
pallet_balances::Pallet<Runtime>,
|
||||||
GetDeliveryConfirmationTransactionFee,
|
GetDeliveryConfirmationTransactionFee,
|
||||||
RootAccountForPayments,
|
|
||||||
>;
|
>;
|
||||||
type OnMessageAccepted = ();
|
type OnMessageAccepted = ();
|
||||||
type OnDeliveryConfirmed =
|
type OnDeliveryConfirmed =
|
||||||
@@ -511,7 +522,7 @@ construct_runtime!(
|
|||||||
BridgeRialtoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage},
|
BridgeRialtoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage},
|
||||||
BridgeDispatch: pallet_bridge_dispatch::{Pallet, Event<T>},
|
BridgeDispatch: pallet_bridge_dispatch::{Pallet, Event<T>},
|
||||||
BridgeRialtoMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event<T>, Config<T>},
|
BridgeRialtoMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event<T>, Config<T>},
|
||||||
BridgeRialtoTokenSwap: pallet_bridge_token_swap::{Pallet, Call, Storage, Event<T>},
|
BridgeRialtoTokenSwap: pallet_bridge_token_swap::{Pallet, Call, Storage, Event<T>, Origin<T>},
|
||||||
|
|
||||||
// Westend bridge modules.
|
// Westend bridge modules.
|
||||||
BridgeWestendGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Config<T>, Storage},
|
BridgeWestendGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Config<T>, Storage},
|
||||||
@@ -551,7 +562,7 @@ pub type Executive = frame_executive::Executive<
|
|||||||
Block,
|
Block,
|
||||||
frame_system::ChainContext<Runtime>,
|
frame_system::ChainContext<Runtime>,
|
||||||
Runtime,
|
Runtime,
|
||||||
AllPallets,
|
AllPalletsWithSystem,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
@@ -664,7 +675,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||||
fn validator_set() -> ValidatorSet<BeefyId> {
|
fn validator_set() -> Option<ValidatorSet<BeefyId>> {
|
||||||
Beefy::validator_set()
|
Beefy::validator_set()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -742,10 +753,6 @@ impl_runtime_apis! {
|
|||||||
let header = BridgeRialtoGrandpa::best_finalized();
|
let header = BridgeRialtoGrandpa::best_finalized();
|
||||||
(header.number, header.hash())
|
(header.number, header.hash())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_known_header(hash: bp_rialto::Hash) -> bool {
|
|
||||||
BridgeRialtoGrandpa::is_known_header(hash)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl bp_westend::WestendFinalityApi<Block> for Runtime {
|
impl bp_westend::WestendFinalityApi<Block> for Runtime {
|
||||||
@@ -753,20 +760,18 @@ impl_runtime_apis! {
|
|||||||
let header = BridgeWestendGrandpa::best_finalized();
|
let header = BridgeWestendGrandpa::best_finalized();
|
||||||
(header.number, header.hash())
|
(header.number, header.hash())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_known_header(hash: bp_westend::Hash) -> bool {
|
|
||||||
BridgeWestendGrandpa::is_known_header(hash)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl bp_rialto::ToRialtoOutboundLaneApi<Block, Balance, ToRialtoMessagePayload> for Runtime {
|
impl bp_rialto::ToRialtoOutboundLaneApi<Block, Balance, ToRialtoMessagePayload> for Runtime {
|
||||||
fn estimate_message_delivery_and_dispatch_fee(
|
fn estimate_message_delivery_and_dispatch_fee(
|
||||||
_lane_id: bp_messages::LaneId,
|
_lane_id: bp_messages::LaneId,
|
||||||
payload: ToRialtoMessagePayload,
|
payload: ToRialtoMessagePayload,
|
||||||
|
rialto_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Option<Balance> {
|
) -> Option<Balance> {
|
||||||
estimate_message_dispatch_and_delivery_fee::<WithRialtoMessageBridge>(
|
estimate_message_dispatch_and_delivery_fee::<WithRialtoMessageBridge>(
|
||||||
&payload,
|
&payload,
|
||||||
WithRialtoMessageBridge::RELAYER_FEE_PERCENT,
|
WithRialtoMessageBridge::RELAYER_FEE_PERCENT,
|
||||||
|
rialto_to_this_conversion_rate,
|
||||||
).ok()
|
).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -781,28 +786,6 @@ impl_runtime_apis! {
|
|||||||
WithRialtoMessageBridge,
|
WithRialtoMessageBridge,
|
||||||
>(lane, begin, end)
|
>(lane, begin, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
|
|
||||||
BridgeRialtoMessages::outbound_latest_received_nonce(lane)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn latest_generated_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
|
|
||||||
BridgeRialtoMessages::outbound_latest_generated_nonce(lane)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl bp_rialto::FromRialtoInboundLaneApi<Block> for Runtime {
|
|
||||||
fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
|
|
||||||
BridgeRialtoMessages::inbound_latest_received_nonce(lane)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
|
|
||||||
BridgeRialtoMessages::inbound_latest_confirmed_nonce(lane)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState {
|
|
||||||
BridgeRialtoMessages::inbound_unrewarded_relayers_state(lane)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
@@ -814,8 +797,13 @@ impl_runtime_apis! {
|
|||||||
use frame_benchmarking::{Benchmarking, BenchmarkList};
|
use frame_benchmarking::{Benchmarking, BenchmarkList};
|
||||||
use frame_support::traits::StorageInfoTrait;
|
use frame_support::traits::StorageInfoTrait;
|
||||||
|
|
||||||
|
use pallet_bridge_messages::benchmarking::Pallet as MessagesBench;
|
||||||
|
|
||||||
let mut list = Vec::<BenchmarkList>::new();
|
let mut list = Vec::<BenchmarkList>::new();
|
||||||
list_benchmarks!(list, extra);
|
|
||||||
|
list_benchmark!(list, extra, pallet_bridge_token_swap, BridgeRialtoTokenSwap);
|
||||||
|
list_benchmark!(list, extra, pallet_bridge_messages, MessagesBench::<Runtime, WithRialtoMessagesInstance>);
|
||||||
|
list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeRialtoGrandpa);
|
||||||
|
|
||||||
let storage_info = AllPalletsWithSystem::storage_info();
|
let storage_info = AllPalletsWithSystem::storage_info();
|
||||||
return (list, storage_info)
|
return (list, storage_info)
|
||||||
@@ -842,6 +830,74 @@ impl_runtime_apis! {
|
|||||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
let mut batches = Vec::<BenchmarkBatch>::new();
|
||||||
let params = (&config, &whitelist);
|
let params = (&config, &whitelist);
|
||||||
|
|
||||||
|
use bridge_runtime_common::messages_benchmarking::{prepare_message_delivery_proof, prepare_message_proof, prepare_outbound_message};
|
||||||
|
use bridge_runtime_common::messages;
|
||||||
|
use pallet_bridge_messages::benchmarking::{
|
||||||
|
Pallet as MessagesBench,
|
||||||
|
Config as MessagesConfig,
|
||||||
|
MessageDeliveryProofParams,
|
||||||
|
MessageParams,
|
||||||
|
MessageProofParams,
|
||||||
|
};
|
||||||
|
use rialto_messages::WithRialtoMessageBridge;
|
||||||
|
|
||||||
|
impl MessagesConfig<WithRialtoMessagesInstance> for Runtime {
|
||||||
|
fn maximal_message_size() -> u32 {
|
||||||
|
messages::source::maximal_message_size::<WithRialtoMessageBridge>()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bridged_relayer_id() -> Self::InboundRelayer {
|
||||||
|
[0u8; 32].into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee {
|
||||||
|
pallet_balances::Pallet::<Runtime>::free_balance(account)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn endow_account(account: &Self::AccountId) {
|
||||||
|
pallet_balances::Pallet::<Runtime>::make_free_balance_be(
|
||||||
|
account,
|
||||||
|
Balance::MAX / 100,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prepare_outbound_message(
|
||||||
|
params: MessageParams<Self::AccountId>,
|
||||||
|
) -> (rialto_messages::ToRialtoMessagePayload, Balance) {
|
||||||
|
(prepare_outbound_message::<WithRialtoMessageBridge>(params), Self::message_fee())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prepare_message_proof(
|
||||||
|
params: MessageProofParams,
|
||||||
|
) -> (rialto_messages::FromRialtoMessagesProof, Weight) {
|
||||||
|
prepare_message_proof::<Runtime, (), (), WithRialtoMessageBridge, bp_rialto::Header, bp_rialto::Hasher>(
|
||||||
|
params,
|
||||||
|
&VERSION,
|
||||||
|
Balance::MAX / 100,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prepare_message_delivery_proof(
|
||||||
|
params: MessageDeliveryProofParams<Self::AccountId>,
|
||||||
|
) -> rialto_messages::ToRialtoMessagesDeliveryProof {
|
||||||
|
prepare_message_delivery_proof::<Runtime, (), WithRialtoMessageBridge, bp_rialto::Header, bp_rialto::Hasher>(
|
||||||
|
params,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_message_dispatched(nonce: bp_messages::MessageNonce) -> bool {
|
||||||
|
frame_system::Pallet::<Runtime>::events()
|
||||||
|
.into_iter()
|
||||||
|
.map(|event_record| event_record.event)
|
||||||
|
.any(|event| matches!(
|
||||||
|
event,
|
||||||
|
Event::BridgeDispatch(pallet_bridge_dispatch::Event::<Runtime, _>::MessageDispatched(
|
||||||
|
_, ([0, 0, 0, 0], nonce_from_event), _,
|
||||||
|
)) if nonce_from_event == nonce
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
use pallet_bridge_token_swap::benchmarking::Config as TokenSwapConfig;
|
use pallet_bridge_token_swap::benchmarking::Config as TokenSwapConfig;
|
||||||
|
|
||||||
impl TokenSwapConfig<WithRialtoTokenSwapInstance> for Runtime {
|
impl TokenSwapConfig<WithRialtoTokenSwapInstance> for Runtime {
|
||||||
@@ -857,9 +913,15 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_benchmarks!(params, batches);
|
add_benchmark!(
|
||||||
|
params,
|
||||||
|
batches,
|
||||||
|
pallet_bridge_messages,
|
||||||
|
MessagesBench::<Runtime, WithRialtoMessagesInstance>
|
||||||
|
);
|
||||||
|
add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeRialtoGrandpa);
|
||||||
|
add_benchmark!(params, batches, pallet_bridge_token_swap, BridgeRialtoTokenSwap);
|
||||||
|
|
||||||
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
|
|
||||||
Ok(batches)
|
Ok(batches)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -892,52 +954,18 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bridge_runtime_common::messages;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn ensure_millau_message_lane_weights_are_correct() {
|
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/390
|
|
||||||
type Weights = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
|
||||||
|
|
||||||
pallet_bridge_messages::ensure_weights_are_correct::<Weights>(
|
|
||||||
bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT,
|
|
||||||
bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT,
|
|
||||||
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT,
|
|
||||||
bp_millau::PAY_INBOUND_DISPATCH_FEE_WEIGHT,
|
|
||||||
DbWeight::get(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let max_incoming_message_proof_size = bp_rialto::EXTRA_STORAGE_PROOF_SIZE.saturating_add(
|
|
||||||
messages::target::maximal_incoming_message_size(bp_millau::max_extrinsic_size()),
|
|
||||||
);
|
|
||||||
pallet_bridge_messages::ensure_able_to_receive_message::<Weights>(
|
|
||||||
bp_millau::max_extrinsic_size(),
|
|
||||||
bp_millau::max_extrinsic_weight(),
|
|
||||||
max_incoming_message_proof_size,
|
|
||||||
messages::target::maximal_incoming_message_dispatch_weight(
|
|
||||||
bp_millau::max_extrinsic_weight(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let max_incoming_inbound_lane_data_proof_size =
|
|
||||||
bp_messages::InboundLaneData::<()>::encoded_size_hint(
|
|
||||||
bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
|
||||||
bp_rialto::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE as _,
|
|
||||||
bp_rialto::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE as _,
|
|
||||||
)
|
|
||||||
.unwrap_or(u32::MAX);
|
|
||||||
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights>(
|
|
||||||
bp_millau::max_extrinsic_size(),
|
|
||||||
bp_millau::max_extrinsic_weight(),
|
|
||||||
max_incoming_inbound_lane_data_proof_size,
|
|
||||||
bp_rialto::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE,
|
|
||||||
bp_rialto::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE,
|
|
||||||
DbWeight::get(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn call_size() {
|
fn call_size() {
|
||||||
|
const BRIDGES_PALLETS_MAX_CALL_SIZE: usize = 200;
|
||||||
|
assert!(
|
||||||
|
core::mem::size_of::<pallet_bridge_grandpa::Call<Runtime>>() <=
|
||||||
|
BRIDGES_PALLETS_MAX_CALL_SIZE
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
core::mem::size_of::<pallet_bridge_messages::Call<Runtime>>() <=
|
||||||
|
BRIDGES_PALLETS_MAX_CALL_SIZE
|
||||||
|
);
|
||||||
const MAX_CALL_SIZE: usize = 230; // value from polkadot-runtime tests
|
const MAX_CALL_SIZE: usize = 230; // value from polkadot-runtime tests
|
||||||
assert!(core::mem::size_of::<Call>() <= MAX_CALL_SIZE);
|
assert!(core::mem::size_of::<Call>() <= MAX_CALL_SIZE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
use crate::Runtime;
|
use crate::Runtime;
|
||||||
|
|
||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
source_chain::TargetHeaderChain,
|
source_chain::{SenderOrigin, TargetHeaderChain},
|
||||||
target_chain::{ProvedMessages, SourceHeaderChain},
|
target_chain::{ProvedMessages, SourceHeaderChain},
|
||||||
InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessagesParameter,
|
InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessagesParameter,
|
||||||
};
|
};
|
||||||
use bp_runtime::{ChainId, MILLAU_CHAIN_ID, RIALTO_CHAIN_ID};
|
use bp_runtime::{Chain, ChainId, MILLAU_CHAIN_ID, RIALTO_CHAIN_ID};
|
||||||
use bridge_runtime_common::messages::{self, MessageBridge, MessageTransaction};
|
use bridge_runtime_common::messages::{self, MessageBridge, MessageTransaction};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
@@ -64,10 +64,10 @@ pub type FromRialtoMessagePayload =
|
|||||||
pub type FromRialtoEncodedCall = messages::target::FromBridgedChainEncodedMessageCall<crate::Call>;
|
pub type FromRialtoEncodedCall = messages::target::FromBridgedChainEncodedMessageCall<crate::Call>;
|
||||||
|
|
||||||
/// Messages proof for Rialto -> Millau messages.
|
/// Messages proof for Rialto -> Millau messages.
|
||||||
type FromRialtoMessagesProof = messages::target::FromBridgedChainMessagesProof<bp_rialto::Hash>;
|
pub type FromRialtoMessagesProof = messages::target::FromBridgedChainMessagesProof<bp_rialto::Hash>;
|
||||||
|
|
||||||
/// Messages delivery proof for Millau -> Rialto messages.
|
/// Messages delivery proof for Millau -> Rialto messages.
|
||||||
type ToRialtoMessagesDeliveryProof =
|
pub type ToRialtoMessagesDeliveryProof =
|
||||||
messages::source::FromBridgedChainMessagesDeliveryProof<bp_rialto::Hash>;
|
messages::source::FromBridgedChainMessagesDeliveryProof<bp_rialto::Hash>;
|
||||||
|
|
||||||
/// Call-dispatch based message dispatch for Rialto -> Millau messages.
|
/// Call-dispatch based message dispatch for Rialto -> Millau messages.
|
||||||
@@ -86,16 +86,19 @@ impl MessageBridge for WithRialtoMessageBridge {
|
|||||||
const RELAYER_FEE_PERCENT: u32 = 10;
|
const RELAYER_FEE_PERCENT: u32 = 10;
|
||||||
const THIS_CHAIN_ID: ChainId = MILLAU_CHAIN_ID;
|
const THIS_CHAIN_ID: ChainId = MILLAU_CHAIN_ID;
|
||||||
const BRIDGED_CHAIN_ID: ChainId = RIALTO_CHAIN_ID;
|
const BRIDGED_CHAIN_ID: ChainId = RIALTO_CHAIN_ID;
|
||||||
const BRIDGED_MESSAGES_PALLET_NAME: &'static str = bp_rialto::WITH_MILLAU_MESSAGES_PALLET_NAME;
|
const BRIDGED_MESSAGES_PALLET_NAME: &'static str = bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME;
|
||||||
|
|
||||||
type ThisChain = Millau;
|
type ThisChain = Millau;
|
||||||
type BridgedChain = Rialto;
|
type BridgedChain = Rialto;
|
||||||
|
|
||||||
fn bridged_balance_to_this_balance(bridged_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
fn bridged_balance_to_this_balance(
|
||||||
bp_millau::Balance::try_from(
|
bridged_balance: bp_rialto::Balance,
|
||||||
RialtoToMillauConversionRate::get().saturating_mul_int(bridged_balance),
|
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||||
)
|
) -> bp_millau::Balance {
|
||||||
.unwrap_or(bp_millau::Balance::MAX)
|
let conversion_rate = bridged_to_this_conversion_rate_override
|
||||||
|
.unwrap_or_else(|| RialtoToMillauConversionRate::get());
|
||||||
|
bp_millau::Balance::try_from(conversion_rate.saturating_mul_int(bridged_balance))
|
||||||
|
.unwrap_or(bp_millau::Balance::MAX)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,12 +116,23 @@ impl messages::ChainWithMessages for Millau {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl messages::ThisChainWithMessages for Millau {
|
impl messages::ThisChainWithMessages for Millau {
|
||||||
|
type Origin = crate::Origin;
|
||||||
type Call = crate::Call;
|
type Call = crate::Call;
|
||||||
|
|
||||||
fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
|
fn is_message_accepted(send_origin: &Self::Origin, lane: &LaneId) -> bool {
|
||||||
*lane == [0, 0, 0, 0] ||
|
// lanes 0x00000000 && 0x00000001 are accepting any paid messages, while
|
||||||
*lane == [0, 0, 0, 1] ||
|
// `TokenSwapMessageLane` only accepts messages from token swap pallet
|
||||||
*lane == crate::TokenSwapMessagesLane::get()
|
let token_swap_dedicated_lane = crate::TokenSwapMessagesLane::get();
|
||||||
|
match *lane {
|
||||||
|
[0, 0, 0, 0] | [0, 0, 0, 1] => send_origin.linked_account().is_some(),
|
||||||
|
_ if *lane == token_swap_dedicated_lane => matches!(
|
||||||
|
send_origin.caller,
|
||||||
|
crate::OriginCaller::BridgeRialtoTokenSwap(
|
||||||
|
pallet_bridge_token_swap::RawOrigin::TokenSwap { .. }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
||||||
@@ -172,13 +186,13 @@ impl messages::ChainWithMessages for Rialto {
|
|||||||
|
|
||||||
impl messages::BridgedChainWithMessages for Rialto {
|
impl messages::BridgedChainWithMessages for Rialto {
|
||||||
fn maximal_extrinsic_size() -> u32 {
|
fn maximal_extrinsic_size() -> u32 {
|
||||||
bp_rialto::max_extrinsic_size()
|
bp_rialto::Rialto::max_extrinsic_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn message_weight_limits(_message_payload: &[u8]) -> RangeInclusive<Weight> {
|
fn message_weight_limits(_message_payload: &[u8]) -> RangeInclusive<Weight> {
|
||||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||||
let upper_limit = messages::target::maximal_incoming_message_dispatch_weight(
|
let upper_limit = messages::target::maximal_incoming_message_dispatch_weight(
|
||||||
bp_rialto::max_extrinsic_weight(),
|
bp_rialto::Rialto::max_extrinsic_weight(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// we're charging for payload bytes in `WithRialtoMessageBridge::transaction_payment`
|
// we're charging for payload bytes in `WithRialtoMessageBridge::transaction_payment`
|
||||||
@@ -274,6 +288,25 @@ impl SourceHeaderChain<bp_rialto::Balance> for Rialto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SenderOrigin<crate::AccountId> for crate::Origin {
|
||||||
|
fn linked_account(&self) -> Option<crate::AccountId> {
|
||||||
|
match self.caller {
|
||||||
|
crate::OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) =>
|
||||||
|
Some(submitter.clone()),
|
||||||
|
crate::OriginCaller::system(frame_system::RawOrigin::Root) |
|
||||||
|
crate::OriginCaller::system(frame_system::RawOrigin::None) =>
|
||||||
|
crate::RootAccountForPayments::get(),
|
||||||
|
crate::OriginCaller::BridgeRialtoTokenSwap(
|
||||||
|
pallet_bridge_token_swap::RawOrigin::TokenSwap {
|
||||||
|
ref swap_account_at_this_chain,
|
||||||
|
..
|
||||||
|
},
|
||||||
|
) => Some(swap_account_at_this_chain.clone()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Millau -> Rialto message lane pallet parameters.
|
/// Millau -> Rialto message lane pallet parameters.
|
||||||
#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)]
|
#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)]
|
||||||
pub enum MillauToRialtoMessagesParameter {
|
pub enum MillauToRialtoMessagesParameter {
|
||||||
@@ -289,3 +322,107 @@ impl MessagesParameter for MillauToRialtoMessagesParameter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::{DbWeight, RialtoGrandpaInstance, Runtime, WithRialtoMessagesInstance};
|
||||||
|
|
||||||
|
use bp_runtime::Chain;
|
||||||
|
use bridge_runtime_common::{
|
||||||
|
assert_complete_bridge_types,
|
||||||
|
integrity::{
|
||||||
|
assert_complete_bridge_constants, AssertBridgeMessagesPalletConstants,
|
||||||
|
AssertBridgePalletNames, AssertChainConstants, AssertCompleteBridgeConstants,
|
||||||
|
},
|
||||||
|
messages,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ensure_millau_message_lane_weights_are_correct() {
|
||||||
|
type Weights = pallet_bridge_messages::weights::MillauWeight<Runtime>;
|
||||||
|
|
||||||
|
pallet_bridge_messages::ensure_weights_are_correct::<Weights>(
|
||||||
|
bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT,
|
||||||
|
bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT,
|
||||||
|
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT,
|
||||||
|
bp_millau::PAY_INBOUND_DISPATCH_FEE_WEIGHT,
|
||||||
|
DbWeight::get(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let max_incoming_message_proof_size = bp_rialto::EXTRA_STORAGE_PROOF_SIZE.saturating_add(
|
||||||
|
messages::target::maximal_incoming_message_size(bp_millau::Millau::max_extrinsic_size()),
|
||||||
|
);
|
||||||
|
pallet_bridge_messages::ensure_able_to_receive_message::<Weights>(
|
||||||
|
bp_millau::Millau::max_extrinsic_size(),
|
||||||
|
bp_millau::Millau::max_extrinsic_weight(),
|
||||||
|
max_incoming_message_proof_size,
|
||||||
|
messages::target::maximal_incoming_message_dispatch_weight(
|
||||||
|
bp_millau::Millau::max_extrinsic_weight(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
let max_incoming_inbound_lane_data_proof_size =
|
||||||
|
bp_messages::InboundLaneData::<()>::encoded_size_hint(
|
||||||
|
bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
||||||
|
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _,
|
||||||
|
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as _,
|
||||||
|
)
|
||||||
|
.unwrap_or(u32::MAX);
|
||||||
|
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights>(
|
||||||
|
bp_millau::Millau::max_extrinsic_size(),
|
||||||
|
bp_millau::Millau::max_extrinsic_weight(),
|
||||||
|
max_incoming_inbound_lane_data_proof_size,
|
||||||
|
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
|
||||||
|
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
|
||||||
|
DbWeight::get(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ensure_bridge_integrity() {
|
||||||
|
assert_complete_bridge_types!(
|
||||||
|
runtime: Runtime,
|
||||||
|
with_bridged_chain_grandpa_instance: RialtoGrandpaInstance,
|
||||||
|
with_bridged_chain_messages_instance: WithRialtoMessagesInstance,
|
||||||
|
bridge: WithRialtoMessageBridge,
|
||||||
|
this_chain: bp_millau::Millau,
|
||||||
|
bridged_chain: bp_rialto::Rialto,
|
||||||
|
this_chain_account_id_converter: bp_millau::AccountIdConverter
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_complete_bridge_constants::<
|
||||||
|
Runtime,
|
||||||
|
RialtoGrandpaInstance,
|
||||||
|
WithRialtoMessagesInstance,
|
||||||
|
WithRialtoMessageBridge,
|
||||||
|
bp_millau::Millau,
|
||||||
|
>(AssertCompleteBridgeConstants {
|
||||||
|
this_chain_constants: AssertChainConstants {
|
||||||
|
block_length: bp_millau::BlockLength::get(),
|
||||||
|
block_weights: bp_millau::BlockWeights::get(),
|
||||||
|
},
|
||||||
|
messages_pallet_constants: AssertBridgeMessagesPalletConstants {
|
||||||
|
max_unrewarded_relayers_in_bridged_confirmation_tx:
|
||||||
|
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
|
||||||
|
max_unconfirmed_messages_in_bridged_confirmation_tx:
|
||||||
|
bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
|
||||||
|
bridged_chain_id: bp_runtime::RIALTO_CHAIN_ID,
|
||||||
|
},
|
||||||
|
pallet_names: AssertBridgePalletNames {
|
||||||
|
with_this_chain_messages_pallet_name: bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME,
|
||||||
|
with_bridged_chain_grandpa_pallet_name: bp_rialto::WITH_RIALTO_GRANDPA_PALLET_NAME,
|
||||||
|
with_bridged_chain_messages_pallet_name:
|
||||||
|
bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
RialtoToMillauConversionRate::key().to_vec(),
|
||||||
|
bp_runtime::storage_parameter_key(
|
||||||
|
bp_millau::RIALTO_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME
|
||||||
|
)
|
||||||
|
.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name = "rialto-parachain-collator"
|
name = "rialto-parachain-collator"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
homepage = "https://substrate.dev"
|
homepage = "https://substrate.dev"
|
||||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
@@ -18,10 +18,10 @@ default = []
|
|||||||
runtime-benchmarks = ['rialto-parachain-runtime/runtime-benchmarks']
|
runtime-benchmarks = ['rialto-parachain-runtime/runtime-benchmarks']
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = { version = "3.1", features = ["derive"] }
|
||||||
derive_more = '0.99.2'
|
derive_more = '0.99.2'
|
||||||
log = '0.4.14'
|
log = '0.4.14'
|
||||||
codec = { package = 'parity-scale-codec', version = '2.0.0' }
|
codec = { package = 'parity-scale-codec', version = '3.0.0' }
|
||||||
structopt = '0.3.8'
|
|
||||||
serde = { version = '1.0', features = ['derive'] }
|
serde = { version = '1.0', features = ['derive'] }
|
||||||
hex-literal = '0.3.1'
|
hex-literal = '0.3.1'
|
||||||
|
|
||||||
@@ -80,6 +80,8 @@ cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch
|
|||||||
cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
|
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
|
cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
|
|
||||||
# Polkadot dependencies
|
# Polkadot dependencies
|
||||||
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ pub fn development_config(id: ParaId) -> ChainSpec {
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
Extensions {
|
Extensions {
|
||||||
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
||||||
para_id: id.into(),
|
para_id: id.into(),
|
||||||
@@ -133,6 +134,7 @@ pub fn local_testnet_config(id: ParaId) -> ChainSpec {
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
Extensions {
|
Extensions {
|
||||||
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
||||||
para_id: id.into(),
|
para_id: id.into(),
|
||||||
|
|||||||
@@ -15,18 +15,18 @@
|
|||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::chain_spec;
|
use crate::chain_spec;
|
||||||
|
use clap::Parser;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
/// Sub-commands supported by the collator.
|
/// Sub-commands supported by the collator.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub enum Subcommand {
|
pub enum Subcommand {
|
||||||
/// Export the genesis state of the parachain.
|
/// Export the genesis state of the parachain.
|
||||||
#[structopt(name = "export-genesis-state")]
|
#[clap(name = "export-genesis-state")]
|
||||||
ExportGenesisState(ExportGenesisStateCommand),
|
ExportGenesisState(ExportGenesisStateCommand),
|
||||||
|
|
||||||
/// Export the genesis wasm of the parachain.
|
/// Export the genesis wasm of the parachain.
|
||||||
#[structopt(name = "export-genesis-wasm")]
|
#[clap(name = "export-genesis-wasm")]
|
||||||
ExportGenesisWasm(ExportGenesisWasmCommand),
|
ExportGenesisWasm(ExportGenesisWasmCommand),
|
||||||
|
|
||||||
/// Build a chain specification.
|
/// Build a chain specification.
|
||||||
@@ -51,66 +51,66 @@ pub enum Subcommand {
|
|||||||
Revert(sc_cli::RevertCmd),
|
Revert(sc_cli::RevertCmd),
|
||||||
|
|
||||||
/// The custom benchmark subcommmand benchmarking runtime pallets.
|
/// The custom benchmark subcommmand benchmarking runtime pallets.
|
||||||
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
|
#[clap(name = "benchmark", about = "Benchmark runtime pallets.")]
|
||||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Command for exporting the genesis state of the parachain
|
/// Command for exporting the genesis state of the parachain
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct ExportGenesisStateCommand {
|
pub struct ExportGenesisStateCommand {
|
||||||
/// Output file name or stdout if unspecified.
|
/// Output file name or stdout if unspecified.
|
||||||
#[structopt(parse(from_os_str))]
|
#[clap(parse(from_os_str))]
|
||||||
pub output: Option<PathBuf>,
|
pub output: Option<PathBuf>,
|
||||||
|
|
||||||
/// Id of the parachain this state is for.
|
/// Id of the parachain this state is for.
|
||||||
///
|
///
|
||||||
/// Default: 100
|
/// Default: 100
|
||||||
#[structopt(long, conflicts_with = "chain")]
|
#[clap(long, conflicts_with = "chain")]
|
||||||
pub parachain_id: Option<u32>,
|
pub parachain_id: Option<u32>,
|
||||||
|
|
||||||
/// Write output in binary. Default is to write in hex.
|
/// Write output in binary. Default is to write in hex.
|
||||||
#[structopt(short, long)]
|
#[clap(short, long)]
|
||||||
pub raw: bool,
|
pub raw: bool,
|
||||||
|
|
||||||
/// The name of the chain for that the genesis state should be exported.
|
/// The name of the chain for that the genesis state should be exported.
|
||||||
#[structopt(long, conflicts_with = "parachain-id")]
|
#[clap(long, conflicts_with = "parachain-id")]
|
||||||
pub chain: Option<String>,
|
pub chain: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Command for exporting the genesis wasm file.
|
/// Command for exporting the genesis wasm file.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct ExportGenesisWasmCommand {
|
pub struct ExportGenesisWasmCommand {
|
||||||
/// Output file name or stdout if unspecified.
|
/// Output file name or stdout if unspecified.
|
||||||
#[structopt(parse(from_os_str))]
|
#[clap(parse(from_os_str))]
|
||||||
pub output: Option<PathBuf>,
|
pub output: Option<PathBuf>,
|
||||||
|
|
||||||
/// Write output in binary. Default is to write in hex.
|
/// Write output in binary. Default is to write in hex.
|
||||||
#[structopt(short, long)]
|
#[clap(short, long)]
|
||||||
pub raw: bool,
|
pub raw: bool,
|
||||||
|
|
||||||
/// The name of the chain for that the genesis wasm file should be exported.
|
/// The name of the chain for that the genesis wasm file should be exported.
|
||||||
#[structopt(long)]
|
#[clap(long)]
|
||||||
pub chain: Option<String>,
|
pub chain: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
#[structopt(settings = &[
|
#[clap(
|
||||||
structopt::clap::AppSettings::GlobalVersion,
|
propagate_version = true,
|
||||||
structopt::clap::AppSettings::ArgsNegateSubcommands,
|
args_conflicts_with_subcommands = true,
|
||||||
structopt::clap::AppSettings::SubcommandsNegateReqs,
|
subcommand_negates_reqs = true
|
||||||
])]
|
)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[structopt(subcommand)]
|
#[clap(subcommand)]
|
||||||
pub subcommand: Option<Subcommand>,
|
pub subcommand: Option<Subcommand>,
|
||||||
|
|
||||||
#[structopt(long)]
|
#[clap(long)]
|
||||||
pub parachain_id: Option<u32>,
|
pub parachain_id: Option<u32>,
|
||||||
|
|
||||||
#[structopt(flatten)]
|
#[clap(flatten)]
|
||||||
pub run: cumulus_client_cli::RunCmd,
|
pub run: cumulus_client_cli::RunCmd,
|
||||||
|
|
||||||
/// Relaychain arguments
|
/// Relaychain arguments
|
||||||
#[structopt(raw = true)]
|
#[clap(raw = true)]
|
||||||
pub relaychain_args: Vec<String>,
|
pub relaychain_args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +135,6 @@ impl RelayChainCli {
|
|||||||
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
|
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
|
||||||
let chain_id = extension.map(|e| e.relay_chain.clone());
|
let chain_id = extension.map(|e| e.relay_chain.clone());
|
||||||
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("rialto-bridge-node"));
|
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("rialto-bridge-node"));
|
||||||
Self { base_path, chain_id, base: polkadot_cli::RunCmd::from_iter(relay_chain_args) }
|
Self { base_path, chain_id, base: polkadot_cli::RunCmd::parse_from(relay_chain_args) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,10 +211,12 @@ pub fn run() -> Result<()> {
|
|||||||
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
|
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
|
||||||
let _ = builder.init();
|
let _ = builder.init();
|
||||||
|
|
||||||
let block: Block = generate_genesis_block(&load_spec(
|
let spec = load_spec(
|
||||||
¶ms.chain.clone().unwrap_or_default(),
|
¶ms.chain.clone().unwrap_or_default(),
|
||||||
params.parachain_id.expect("Missing ParaId").into(),
|
params.parachain_id.expect("Missing ParaId").into(),
|
||||||
)?)?;
|
)?;
|
||||||
|
let state_version = Cli::native_runtime_version(&spec).state_version();
|
||||||
|
let block: Block = generate_genesis_block(&spec, state_version)?;
|
||||||
let raw_header = block.header().encode();
|
let raw_header = block.header().encode();
|
||||||
let output_buf = if params.raw {
|
let output_buf = if params.raw {
|
||||||
raw_header
|
raw_header
|
||||||
@@ -263,6 +265,7 @@ pub fn run() -> Result<()> {
|
|||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
let runner = cli.create_runner(&cli.run.normalize())?;
|
let runner = cli.create_runner(&cli.run.normalize())?;
|
||||||
|
let collator_options = cli.run.collator_options();
|
||||||
|
|
||||||
runner.run_node_until_exit(|config| async move {
|
runner.run_node_until_exit(|config| async move {
|
||||||
let para_id =
|
let para_id =
|
||||||
@@ -276,10 +279,12 @@ pub fn run() -> Result<()> {
|
|||||||
let id = ParaId::from(cli.parachain_id.or(para_id).expect("Missing ParaId"));
|
let id = ParaId::from(cli.parachain_id.or(para_id).expect("Missing ParaId"));
|
||||||
|
|
||||||
let parachain_account =
|
let parachain_account =
|
||||||
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
|
AccountIdConversion::<polkadot_primitives::v2::AccountId>::into_account(&id);
|
||||||
|
|
||||||
let block: Block =
|
let state_version =
|
||||||
generate_genesis_block(&config.chain_spec).map_err(|e| format!("{:?}", e))?;
|
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
|
||||||
|
let block: Block = generate_genesis_block(&config.chain_spec, state_version)
|
||||||
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
||||||
|
|
||||||
let polkadot_config = SubstrateCli::create_configuration(
|
let polkadot_config = SubstrateCli::create_configuration(
|
||||||
@@ -294,7 +299,7 @@ pub fn run() -> Result<()> {
|
|||||||
info!("Parachain genesis state: {}", genesis_state);
|
info!("Parachain genesis state: {}", genesis_state);
|
||||||
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
|
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
|
||||||
|
|
||||||
crate::service::start_node(config, polkadot_config, id)
|
crate::service::start_node(config, polkadot_config, collator_options, id)
|
||||||
.await
|
.await
|
||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
@@ -357,11 +362,24 @@ impl CliConfiguration<Self> for RelayChainCli {
|
|||||||
self.base.base.rpc_ws(default_listen_port)
|
self.base.base.rpc_ws(default_listen_port)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prometheus_config(&self, default_listen_port: u16) -> Result<Option<PrometheusConfig>> {
|
fn prometheus_config(
|
||||||
self.base.base.prometheus_config(default_listen_port)
|
&self,
|
||||||
|
default_listen_port: u16,
|
||||||
|
chain_spec: &Box<dyn ChainSpec>,
|
||||||
|
) -> Result<Option<PrometheusConfig>> {
|
||||||
|
self.base.base.prometheus_config(default_listen_port, chain_spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init<C: SubstrateCli>(&self) -> Result<()> {
|
fn init<F>(
|
||||||
|
&self,
|
||||||
|
_support_url: &String,
|
||||||
|
_impl_version: &String,
|
||||||
|
_logger_hook: F,
|
||||||
|
_config: &sc_service::Configuration,
|
||||||
|
) -> Result<()>
|
||||||
|
where
|
||||||
|
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
|
||||||
|
{
|
||||||
unreachable!("PolkadotCli is never initialized; qed");
|
unreachable!("PolkadotCli is never initialized; qed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,22 +14,30 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Rialto parachain node service.
|
||||||
|
//!
|
||||||
|
//! The code is mostly copy of `polkadot-parachains/src/service.rs` file from Cumulus
|
||||||
|
//! repository with some parts removed. We have added two RPC extensions to the original
|
||||||
|
//! service: `pallet_transaction_payment_rpc::TransactionPaymentApi` and
|
||||||
|
//! `substrate_frame_rpc_system::SystemApi`.
|
||||||
|
|
||||||
// std
|
// std
|
||||||
use std::sync::Arc;
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
// Local Runtime Types
|
// Local Runtime Types
|
||||||
use rialto_parachain_runtime::RuntimeApi;
|
use rialto_parachain_runtime::RuntimeApi;
|
||||||
|
|
||||||
// Cumulus Imports
|
// Cumulus Imports
|
||||||
use cumulus_client_consensus_aura::{
|
use cumulus_client_cli::CollatorOptions;
|
||||||
build_aura_consensus, BuildAuraConsensusParams, SlotProportion,
|
use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
|
||||||
};
|
|
||||||
use cumulus_client_consensus_common::ParachainConsensus;
|
use cumulus_client_consensus_common::ParachainConsensus;
|
||||||
use cumulus_client_network::build_block_announce_validator;
|
use cumulus_client_network::BlockAnnounceValidator;
|
||||||
use cumulus_client_service::{
|
use cumulus_client_service::{
|
||||||
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
|
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
|
||||||
};
|
};
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
|
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
|
||||||
|
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};
|
||||||
|
|
||||||
// Substrate Imports
|
// Substrate Imports
|
||||||
use sc_client_api::ExecutorProvider;
|
use sc_client_api::ExecutorProvider;
|
||||||
@@ -38,7 +46,6 @@ use sc_network::NetworkService;
|
|||||||
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
|
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
|
||||||
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
|
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
|
||||||
use sp_api::ConstructRuntimeApi;
|
use sp_api::ConstructRuntimeApi;
|
||||||
use sp_consensus::SlotData;
|
|
||||||
use sp_keystore::SyncCryptoStorePtr;
|
use sp_keystore::SyncCryptoStorePtr;
|
||||||
use sp_runtime::traits::BlakeTwo256;
|
use sp_runtime::traits::BlakeTwo256;
|
||||||
use substrate_prometheus_endpoint::Registry;
|
use substrate_prometheus_endpoint::Registry;
|
||||||
@@ -188,6 +195,7 @@ where
|
|||||||
async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
|
async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
|
||||||
parachain_config: Configuration,
|
parachain_config: Configuration,
|
||||||
polkadot_config: Configuration,
|
polkadot_config: Configuration,
|
||||||
|
collator_options: CollatorOptions,
|
||||||
id: ParaId,
|
id: ParaId,
|
||||||
rpc_ext_builder: RB,
|
rpc_ext_builder: RB,
|
||||||
build_import_queue: BIQ,
|
build_import_queue: BIQ,
|
||||||
@@ -213,7 +221,14 @@ where
|
|||||||
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
|
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
|
||||||
Executor: NativeExecutionDispatch + 'static,
|
Executor: NativeExecutionDispatch + 'static,
|
||||||
RB: Fn(
|
RB: Fn(
|
||||||
|
sc_rpc_api::DenyUnsafe,
|
||||||
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
|
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
|
||||||
|
Arc<
|
||||||
|
sc_transaction_pool::FullPool<
|
||||||
|
Block,
|
||||||
|
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
) -> jsonrpc_core::IoHandler<sc_rpc::Metadata>
|
) -> jsonrpc_core::IoHandler<sc_rpc::Metadata>
|
||||||
+ Send
|
+ Send
|
||||||
+ 'static,
|
+ 'static,
|
||||||
@@ -234,7 +249,7 @@ where
|
|||||||
Option<&Registry>,
|
Option<&Registry>,
|
||||||
Option<TelemetryHandle>,
|
Option<TelemetryHandle>,
|
||||||
&TaskManager,
|
&TaskManager,
|
||||||
&polkadot_service::NewFull<polkadot_service::Client>,
|
Arc<dyn RelayChainInterface>,
|
||||||
Arc<
|
Arc<
|
||||||
sc_transaction_pool::FullPool<
|
sc_transaction_pool::FullPool<
|
||||||
Block,
|
Block,
|
||||||
@@ -255,27 +270,26 @@ where
|
|||||||
let params = new_partial::<RuntimeApi, Executor, BIQ>(¶chain_config, build_import_queue)?;
|
let params = new_partial::<RuntimeApi, Executor, BIQ>(¶chain_config, build_import_queue)?;
|
||||||
let (mut telemetry, telemetry_worker_handle) = params.other;
|
let (mut telemetry, telemetry_worker_handle) = params.other;
|
||||||
|
|
||||||
let relay_chain_full_node =
|
let mut task_manager = params.task_manager;
|
||||||
cumulus_client_service::build_polkadot_full_node(polkadot_config, telemetry_worker_handle)
|
let (relay_chain_interface, collator_key) = build_inprocess_relay_chain(
|
||||||
.map_err(|e| match e {
|
polkadot_config,
|
||||||
polkadot_service::Error::Sub(x) => x,
|
¶chain_config,
|
||||||
s => format!("{}", s).into(),
|
telemetry_worker_handle,
|
||||||
})?;
|
&mut task_manager,
|
||||||
|
)
|
||||||
|
.map_err(|e| match e {
|
||||||
|
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
|
||||||
|
s => s.to_string().into(),
|
||||||
|
})?;
|
||||||
|
|
||||||
let client = params.client.clone();
|
let client = params.client.clone();
|
||||||
let backend = params.backend.clone();
|
let backend = params.backend.clone();
|
||||||
let block_announce_validator = build_block_announce_validator(
|
let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);
|
||||||
relay_chain_full_node.client.clone(),
|
|
||||||
id,
|
|
||||||
Box::new(relay_chain_full_node.network.clone()),
|
|
||||||
relay_chain_full_node.backend.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let force_authoring = parachain_config.force_authoring;
|
let force_authoring = parachain_config.force_authoring;
|
||||||
let validator = parachain_config.role.is_authority();
|
let validator = parachain_config.role.is_authority();
|
||||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||||
let transaction_pool = params.transaction_pool.clone();
|
let transaction_pool = params.transaction_pool.clone();
|
||||||
let mut task_manager = params.task_manager;
|
|
||||||
let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);
|
let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);
|
||||||
let (network, system_rpc_tx, start_network) =
|
let (network, system_rpc_tx, start_network) =
|
||||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||||
@@ -284,12 +298,17 @@ where
|
|||||||
transaction_pool: transaction_pool.clone(),
|
transaction_pool: transaction_pool.clone(),
|
||||||
spawn_handle: task_manager.spawn_handle(),
|
spawn_handle: task_manager.spawn_handle(),
|
||||||
import_queue: import_queue.clone(),
|
import_queue: import_queue.clone(),
|
||||||
block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),
|
block_announce_validator_builder: Some(Box::new(|_| {
|
||||||
|
Box::new(block_announce_validator)
|
||||||
|
})),
|
||||||
warp_sync: None,
|
warp_sync: None,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let rpc_client = client.clone();
|
let rpc_client = client.clone();
|
||||||
let rpc_extensions_builder = Box::new(move |_, _| Ok(rpc_ext_builder(rpc_client.clone())));
|
let rpc_transaction_pool = transaction_pool.clone();
|
||||||
|
let rpc_extensions_builder = Box::new(move |deny_unsafe, _| {
|
||||||
|
Ok(rpc_ext_builder(deny_unsafe, rpc_client.clone(), rpc_transaction_pool.clone()))
|
||||||
|
});
|
||||||
|
|
||||||
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||||
rpc_extensions_builder,
|
rpc_extensions_builder,
|
||||||
@@ -309,13 +328,15 @@ where
|
|||||||
Arc::new(move |hash, data| network.announce_block(hash, data))
|
Arc::new(move |hash, data| network.announce_block(hash, data))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let relay_chain_slot_duration = Duration::from_secs(6);
|
||||||
|
|
||||||
if validator {
|
if validator {
|
||||||
let parachain_consensus = build_consensus(
|
let parachain_consensus = build_consensus(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
prometheus_registry.as_ref(),
|
prometheus_registry.as_ref(),
|
||||||
telemetry.as_ref().map(|t| t.handle()),
|
telemetry.as_ref().map(|t| t.handle()),
|
||||||
&task_manager,
|
&task_manager,
|
||||||
&relay_chain_full_node,
|
relay_chain_interface.clone(),
|
||||||
transaction_pool,
|
transaction_pool,
|
||||||
network,
|
network,
|
||||||
params.keystore_container.sync_keystore(),
|
params.keystore_container.sync_keystore(),
|
||||||
@@ -330,10 +351,12 @@ where
|
|||||||
announce_block,
|
announce_block,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
task_manager: &mut task_manager,
|
task_manager: &mut task_manager,
|
||||||
relay_chain_full_node,
|
relay_chain_interface,
|
||||||
spawner,
|
spawner,
|
||||||
parachain_consensus,
|
parachain_consensus,
|
||||||
import_queue,
|
import_queue,
|
||||||
|
collator_key: collator_key.expect("Command line arguments do not allow this. qed"),
|
||||||
|
relay_chain_slot_duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
start_collator(params).await?;
|
start_collator(params).await?;
|
||||||
@@ -343,7 +366,10 @@ where
|
|||||||
announce_block,
|
announce_block,
|
||||||
task_manager: &mut task_manager,
|
task_manager: &mut task_manager,
|
||||||
para_id: id,
|
para_id: id,
|
||||||
relay_chain_full_node,
|
relay_chain_interface,
|
||||||
|
relay_chain_slot_duration,
|
||||||
|
import_queue,
|
||||||
|
collator_options,
|
||||||
};
|
};
|
||||||
|
|
||||||
start_full_node(params)?;
|
start_full_node(params)?;
|
||||||
@@ -385,9 +411,9 @@ pub fn parachain_build_import_queue(
|
|||||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||||
|
|
||||||
let slot =
|
let slot =
|
||||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||||
*time,
|
*time,
|
||||||
slot_duration.slot_duration(),
|
slot_duration,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok((time, slot))
|
Ok((time, slot))
|
||||||
@@ -404,6 +430,7 @@ pub fn parachain_build_import_queue(
|
|||||||
pub async fn start_node(
|
pub async fn start_node(
|
||||||
parachain_config: Configuration,
|
parachain_config: Configuration,
|
||||||
polkadot_config: Configuration,
|
polkadot_config: Configuration,
|
||||||
|
collator_options: CollatorOptions,
|
||||||
id: ParaId,
|
id: ParaId,
|
||||||
) -> sc_service::error::Result<(
|
) -> sc_service::error::Result<(
|
||||||
TaskManager,
|
TaskManager,
|
||||||
@@ -412,14 +439,27 @@ pub async fn start_node(
|
|||||||
start_node_impl::<RuntimeApi, ParachainRuntimeExecutor, _, _, _>(
|
start_node_impl::<RuntimeApi, ParachainRuntimeExecutor, _, _, _>(
|
||||||
parachain_config,
|
parachain_config,
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
|
collator_options,
|
||||||
id,
|
id,
|
||||||
|_| Default::default(),
|
|deny_unsafe, client, pool| {
|
||||||
|
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
|
||||||
|
use substrate_frame_rpc_system::{FullSystem, SystemApi};
|
||||||
|
|
||||||
|
let mut io = jsonrpc_core::IoHandler::default();
|
||||||
|
io.extend_with(SystemApi::to_delegate(FullSystem::new(
|
||||||
|
client.clone(),
|
||||||
|
pool,
|
||||||
|
deny_unsafe,
|
||||||
|
)));
|
||||||
|
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client)));
|
||||||
|
io
|
||||||
|
},
|
||||||
parachain_build_import_queue,
|
parachain_build_import_queue,
|
||||||
|client,
|
|client,
|
||||||
prometheus_registry,
|
prometheus_registry,
|
||||||
telemetry,
|
telemetry,
|
||||||
task_manager,
|
task_manager,
|
||||||
relay_chain_node,
|
relay_chain_interface,
|
||||||
transaction_pool,
|
transaction_pool,
|
||||||
sync_oracle,
|
sync_oracle,
|
||||||
keystore,
|
keystore,
|
||||||
@@ -434,60 +474,47 @@ pub async fn start_node(
|
|||||||
telemetry.clone(),
|
telemetry.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let relay_chain_backend = relay_chain_node.backend.clone();
|
Ok(AuraConsensus::build::<sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _>(
|
||||||
let relay_chain_client = relay_chain_node.client.clone();
|
BuildAuraConsensusParams {
|
||||||
Ok(build_aura_consensus::<
|
proposer_factory,
|
||||||
sp_consensus_aura::sr25519::AuthorityPair,
|
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
|
||||||
_,
|
let relay_chain_interface = relay_chain_interface.clone();
|
||||||
_,
|
async move {
|
||||||
_,
|
let parachain_inherent =
|
||||||
_,
|
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
|
||||||
_,
|
|
||||||
_,
|
|
||||||
_,
|
|
||||||
_,
|
|
||||||
_,
|
|
||||||
>(BuildAuraConsensusParams {
|
|
||||||
proposer_factory,
|
|
||||||
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
|
|
||||||
let parachain_inherent =
|
|
||||||
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client(
|
|
||||||
relay_parent,
|
relay_parent,
|
||||||
&relay_chain_client,
|
&relay_chain_interface,
|
||||||
&*relay_chain_backend,
|
|
||||||
&validation_data,
|
&validation_data,
|
||||||
id,
|
id,
|
||||||
);
|
).await;
|
||||||
async move {
|
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
|
||||||
|
|
||||||
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||||
*time,
|
*time,
|
||||||
slot_duration.slot_duration(),
|
slot_duration,
|
||||||
);
|
);
|
||||||
|
|
||||||
let parachain_inherent = parachain_inherent.ok_or_else(|| {
|
let parachain_inherent = parachain_inherent.ok_or_else(|| {
|
||||||
Box::<dyn std::error::Error + Send + Sync>::from(
|
Box::<dyn std::error::Error + Send + Sync>::from(
|
||||||
"Failed to create parachain inherent",
|
"Failed to create parachain inherent",
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
Ok((time, slot, parachain_inherent))
|
Ok((time, slot, parachain_inherent))
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
block_import: client.clone(),
|
||||||
|
para_client: client,
|
||||||
|
backoff_authoring_blocks: Option::<()>::None,
|
||||||
|
sync_oracle,
|
||||||
|
keystore,
|
||||||
|
force_authoring,
|
||||||
|
slot_duration,
|
||||||
|
// We got around 500ms for proposing
|
||||||
|
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
|
||||||
|
telemetry,
|
||||||
|
max_block_proposal_slot_portion: None,
|
||||||
},
|
},
|
||||||
block_import: client.clone(),
|
))
|
||||||
relay_chain_client: relay_chain_node.client.clone(),
|
|
||||||
relay_chain_backend: relay_chain_node.backend.clone(),
|
|
||||||
para_client: client,
|
|
||||||
backoff_authoring_blocks: Option::<()>::None,
|
|
||||||
sync_oracle,
|
|
||||||
keystore,
|
|
||||||
force_authoring,
|
|
||||||
slot_duration,
|
|
||||||
// We got around 500ms for proposing
|
|
||||||
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
|
|
||||||
telemetry,
|
|
||||||
max_block_proposal_slot_portion: None,
|
|
||||||
}))
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name = "rialto-parachain-runtime"
|
name = "rialto-parachain-runtime"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
homepage = "https://substrate.dev"
|
homepage = "https://substrate.dev"
|
||||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
@@ -11,9 +11,9 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|||||||
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = 'parity-scale-codec', version = '2.0.0', default-features = false, features = ['derive']}
|
codec = { package = 'parity-scale-codec', version = '3.0.0', default-features = false, features = ['derive']}
|
||||||
log = { version = "0.4.14", default-features = false }
|
log = { version = "0.4.14", default-features = false }
|
||||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
serde = { version = '1.0', optional = true, features = ['derive'] }
|
serde = { version = '1.0', optional = true, features = ['derive'] }
|
||||||
|
|
||||||
# Bridge depedencies
|
# Bridge depedencies
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ pub use frame_support::{
|
|||||||
},
|
},
|
||||||
StorageValue,
|
StorageValue,
|
||||||
};
|
};
|
||||||
pub use frame_system::Call as SystemCall;
|
pub use frame_system::{Call as SystemCall, EnsureRoot};
|
||||||
pub use pallet_balances::Call as BalancesCall;
|
pub use pallet_balances::Call as BalancesCall;
|
||||||
pub use pallet_timestamp::Call as TimestampCall;
|
pub use pallet_timestamp::Call as TimestampCall;
|
||||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
@@ -104,7 +104,7 @@ pub type Executive = frame_executive::Executive<
|
|||||||
Block,
|
Block,
|
||||||
frame_system::ChainContext<Runtime>,
|
frame_system::ChainContext<Runtime>,
|
||||||
Runtime,
|
Runtime,
|
||||||
AllPallets,
|
AllPalletsWithSystem,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
impl_opaque_keys! {
|
impl_opaque_keys! {
|
||||||
@@ -123,6 +123,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This determines the average expected block time that we are targeting.
|
/// This determines the average expected block time that we are targeting.
|
||||||
@@ -210,6 +211,7 @@ impl frame_system::Config for Runtime {
|
|||||||
type SS58Prefix = SS58Prefix;
|
type SS58Prefix = SS58Prefix;
|
||||||
/// The action to take on a Runtime Upgrade
|
/// The action to take on a Runtime Upgrade
|
||||||
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
|
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -268,7 +270,7 @@ parameter_types! {
|
|||||||
|
|
||||||
impl cumulus_pallet_parachain_system::Config for Runtime {
|
impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type OnValidationData = ();
|
type OnSystemEvent = ();
|
||||||
type SelfParaId = parachain_info::Pallet<Runtime>;
|
type SelfParaId = parachain_info::Pallet<Runtime>;
|
||||||
type OutboundXcmpMessageSource = XcmpQueue;
|
type OutboundXcmpMessageSource = XcmpQueue;
|
||||||
type DmpMessageHandler = DmpQueue;
|
type DmpMessageHandler = DmpQueue;
|
||||||
@@ -294,7 +296,7 @@ parameter_types! {
|
|||||||
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
||||||
/// `Transact` in order to determine the dispatch Origin.
|
/// `Transact` in order to determine the dispatch Origin.
|
||||||
pub type LocationToAccountId = (
|
pub type LocationToAccountId = (
|
||||||
// The parent (Relay-chain) origin converts to the parent `AccountId`.
|
// The parent (Relay-chain) origin converts to the default `AccountId`.
|
||||||
ParentIsPreset<AccountId>,
|
ParentIsPreset<AccountId>,
|
||||||
// Sibling parachain origins convert to AccountId via the `ParaId::into`.
|
// Sibling parachain origins convert to AccountId via the `ParaId::into`.
|
||||||
SiblingParachainConvertsVia<Sibling, AccountId>,
|
SiblingParachainConvertsVia<Sibling, AccountId>,
|
||||||
@@ -421,6 +423,10 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
|||||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||||
type ChannelInfo = ParachainSystem;
|
type ChannelInfo = ParachainSystem;
|
||||||
type VersionWrapper = ();
|
type VersionWrapper = ();
|
||||||
|
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
|
||||||
|
type ControllerOrigin = EnsureRoot<AccountId>;
|
||||||
|
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||||
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||||
@@ -568,8 +574,8 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
|
impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
|
||||||
fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {
|
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
|
||||||
ParachainSystem::collect_collation_info()
|
ParachainSystem::collect_collation_info(header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,7 +627,6 @@ impl_runtime_apis! {
|
|||||||
let params = (&config, &whitelist);
|
let params = (&config, &whitelist);
|
||||||
add_benchmarks!(params, batches);
|
add_benchmarks!(params, batches);
|
||||||
|
|
||||||
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
|
|
||||||
Ok(batches)
|
Ok(batches)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ name = "rialto-bridge-node"
|
|||||||
description = "Substrate node compatible with Rialto runtime"
|
description = "Substrate node compatible with Rialto runtime"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
homepage = "https://substrate.dev"
|
homepage = "https://substrate.dev"
|
||||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = { version = "3.1", features = ["derive"] }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
jsonrpc-core = "18.0"
|
jsonrpc-core = "18.0"
|
||||||
kvdb = "0.10"
|
kvdb = "0.11"
|
||||||
kvdb-rocksdb = "0.12"
|
kvdb-rocksdb = "0.15"
|
||||||
lru = "0.7"
|
lru = "0.7"
|
||||||
structopt = "0.3.21"
|
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
|
||||||
@@ -50,7 +50,6 @@ sc-consensus-uncles = { git = "https://github.com/paritytech/substrate", branch
|
|||||||
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
#sc-finality-grandpa-warp-sync = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
|
||||||
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
@@ -77,37 +76,10 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate
|
|||||||
|
|
||||||
# Polkadot Dependencies
|
# Polkadot Dependencies
|
||||||
|
|
||||||
polkadot-client = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
|
|
||||||
# Polkadot (parachain) Dependencies
|
|
||||||
|
|
||||||
polkadot-approval-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-availability-bitfield-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-availability-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-availability-recovery = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-collator-protocol = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-dispute-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-gossip-support = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-network-bridge = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-collation-generation = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-approval-voting = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-av-store = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-backing = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-bitfield-signing = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-candidate-validation = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-chain-api = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-chain-selection = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-parachains-inherent = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-provisioner = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-pvf = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
polkadot-node-core-pvf = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||||
polkadot-node-core-runtime-api = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-core-dispute-coordinator = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-network-protocol = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-node-subsystem-util = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
|
||||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||||
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||||
polkadot-statement-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false, features = [ "full-node", "polkadot-native" ] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ use sp_finality_grandpa::AuthorityId as GrandpaId;
|
|||||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||||
|
|
||||||
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
||||||
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
|
pub type ChainSpec =
|
||||||
|
sc_service::GenericChainSpec<GenesisConfig, polkadot_service::chain_spec::Extensions>;
|
||||||
|
|
||||||
/// The chain specification option. This is expected to come in from the CLI and
|
/// The chain specification option. This is expected to come in from the CLI and
|
||||||
/// is little more than one of a number of alternatives which can easily be converted
|
/// is little more than one of a number of alternatives which can easily be converted
|
||||||
@@ -96,23 +97,16 @@ impl Alternative {
|
|||||||
testnet_genesis(
|
testnet_genesis(
|
||||||
vec![get_authority_keys_from_seed("Alice")],
|
vec![get_authority_keys_from_seed("Alice")],
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
vec![
|
endowed_accounts(),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
|
||||||
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
properties,
|
|
||||||
None,
|
None,
|
||||||
|
properties,
|
||||||
|
Default::default(),
|
||||||
),
|
),
|
||||||
Alternative::LocalTestnet => ChainSpec::from_genesis(
|
Alternative::LocalTestnet => ChainSpec::from_genesis(
|
||||||
"Rialto Local",
|
"Rialto Local",
|
||||||
@@ -128,61 +122,70 @@ impl Alternative {
|
|||||||
get_authority_keys_from_seed("Eve"),
|
get_authority_keys_from_seed("Eve"),
|
||||||
],
|
],
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
vec![
|
endowed_accounts(),
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("George"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Harry"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("George//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Harry//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("MillauMessagesOwner"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("WithMillauTokenSwap"),
|
|
||||||
pallet_bridge_messages::relayer_fund_account_id::<
|
|
||||||
bp_rialto::AccountId,
|
|
||||||
bp_rialto::AccountIdConverter,
|
|
||||||
>(),
|
|
||||||
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
)),
|
|
||||||
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
)),
|
|
||||||
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
|
||||||
)),
|
|
||||||
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
|
||||||
)),
|
|
||||||
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
|
||||||
)),
|
|
||||||
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
properties,
|
|
||||||
None,
|
None,
|
||||||
|
properties,
|
||||||
|
Default::default(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// We're using the same set of endowed accounts on all Millau chains (dev/local) to make
|
||||||
|
/// sure that all accounts, required for bridge to be functional (e.g. relayers fund account,
|
||||||
|
/// accounts used by relayers in our test deployments, accounts used for demonstration
|
||||||
|
/// purposes), are all available on these chains.
|
||||||
|
fn endowed_accounts() -> Vec<AccountId> {
|
||||||
|
vec![
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("George"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Harry"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("George//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Harry//stash"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("MillauMessagesOwner"),
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("WithMillauTokenSwap"),
|
||||||
|
pallet_bridge_messages::relayer_fund_account_id::<
|
||||||
|
bp_rialto::AccountId,
|
||||||
|
bp_rialto::AccountIdConverter,
|
||||||
|
>(),
|
||||||
|
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
)),
|
||||||
|
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||||
|
)),
|
||||||
|
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||||
|
)),
|
||||||
|
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||||
|
)),
|
||||||
|
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||||
|
)),
|
||||||
|
derive_account_from_millau_id(bp_runtime::SourceAccount::Account(
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||||
|
)),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
fn session_keys(
|
fn session_keys(
|
||||||
babe: BabeId,
|
babe: BabeId,
|
||||||
beefy: BeefyId,
|
beefy: BeefyId,
|
||||||
@@ -247,8 +250,8 @@ fn testnet_genesis(
|
|||||||
// (see /node/service/src/chain_spec.rs:default_parachains_host_configuration)
|
// (see /node/service/src/chain_spec.rs:default_parachains_host_configuration)
|
||||||
configuration: ConfigurationConfig {
|
configuration: ConfigurationConfig {
|
||||||
config: polkadot_runtime_parachains::configuration::HostConfiguration {
|
config: polkadot_runtime_parachains::configuration::HostConfiguration {
|
||||||
validation_upgrade_frequency: 1u32,
|
validation_upgrade_cooldown: 2u32,
|
||||||
validation_upgrade_delay: 1,
|
validation_upgrade_delay: 2,
|
||||||
code_retention_period: 1200,
|
code_retention_period: 1200,
|
||||||
max_code_size: polkadot_primitives::v2::MAX_CODE_SIZE,
|
max_code_size: polkadot_primitives::v2::MAX_CODE_SIZE,
|
||||||
max_pov_size: polkadot_primitives::v2::MAX_POV_SIZE,
|
max_pov_size: polkadot_primitives::v2::MAX_POV_SIZE,
|
||||||
@@ -258,13 +261,8 @@ fn testnet_genesis(
|
|||||||
thread_availability_period: 4,
|
thread_availability_period: 4,
|
||||||
max_upward_queue_count: 8,
|
max_upward_queue_count: 8,
|
||||||
max_upward_queue_size: 1024 * 1024,
|
max_upward_queue_size: 1024 * 1024,
|
||||||
max_downward_message_size: 1024,
|
max_downward_message_size: 1024 * 1024,
|
||||||
// this is approximatelly 4ms.
|
ump_service_total_weight: 100_000_000_000,
|
||||||
//
|
|
||||||
// Same as `4 * frame_support::weights::WEIGHT_PER_MILLIS`. We don't bother with
|
|
||||||
// an import since that's a made up number and should be replaced with a constant
|
|
||||||
// obtained by benchmarking anyway.
|
|
||||||
ump_service_total_weight: 4 * 1_000_000_000,
|
|
||||||
max_upward_message_size: 50 * 1024,
|
max_upward_message_size: 50 * 1024,
|
||||||
max_upward_message_num_per_candidate: 5,
|
max_upward_message_num_per_candidate: 5,
|
||||||
hrmp_sender_deposit: 0,
|
hrmp_sender_deposit: 0,
|
||||||
@@ -283,6 +281,7 @@ fn testnet_genesis(
|
|||||||
needed_approvals: 2,
|
needed_approvals: 2,
|
||||||
relay_vrf_modulo_samples: 2,
|
relay_vrf_modulo_samples: 2,
|
||||||
zeroth_delay_tranche_width: 0,
|
zeroth_delay_tranche_width: 0,
|
||||||
|
minimum_validation_upgrade_delay: 5,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
use sc_cli::RunCmd;
|
use sc_cli::RunCmd;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[structopt(subcommand)]
|
#[structopt(subcommand)]
|
||||||
pub subcommand: Option<Subcommand>,
|
pub subcommand: Option<Subcommand>,
|
||||||
@@ -27,9 +27,10 @@ pub struct Cli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Possible subcommands of the main binary.
|
/// Possible subcommands of the main binary.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub enum Subcommand {
|
pub enum Subcommand {
|
||||||
/// Key management CLI utilities
|
/// Key management CLI utilities
|
||||||
|
#[clap(subcommand)]
|
||||||
Key(sc_cli::KeySubcommand),
|
Key(sc_cli::KeySubcommand),
|
||||||
|
|
||||||
/// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key.
|
/// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key.
|
||||||
@@ -69,16 +70,16 @@ pub enum Subcommand {
|
|||||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||||
|
|
||||||
/// FOR INTERNAL USE: analog of the "prepare-worker" command of the polkadot binary.
|
/// FOR INTERNAL USE: analog of the "prepare-worker" command of the polkadot binary.
|
||||||
#[structopt(name = "prepare-worker", setting = structopt::clap::AppSettings::Hidden)]
|
#[clap(name = "prepare-worker", hide = true)]
|
||||||
PvfPrepareWorker(ValidationWorkerCommand),
|
PvfPrepareWorker(ValidationWorkerCommand),
|
||||||
|
|
||||||
/// FOR INTERNAL USE: analog of the "execute-worker" command of the polkadot binary.
|
/// FOR INTERNAL USE: analog of the "execute-worker" command of the polkadot binary.
|
||||||
#[structopt(name = "execute-worker", setting = structopt::clap::AppSettings::Hidden)]
|
#[clap(name = "execute-worker", hide = true)]
|
||||||
PvfExecuteWorker(ValidationWorkerCommand),
|
PvfExecuteWorker(ValidationWorkerCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validation worker command.
|
/// Validation worker command.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct ValidationWorkerCommand {
|
pub struct ValidationWorkerCommand {
|
||||||
/// The path to the validation host's socket.
|
/// The path to the validation host's socket.
|
||||||
pub socket_path: String,
|
pub socket_path: String,
|
||||||
|
|||||||
@@ -14,13 +14,9 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::{
|
use crate::cli::{Cli, Subcommand};
|
||||||
cli::{Cli, Subcommand},
|
|
||||||
service::new_partial,
|
|
||||||
};
|
|
||||||
use rialto_runtime::{Block, RuntimeApi};
|
use rialto_runtime::{Block, RuntimeApi};
|
||||||
use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli};
|
use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli};
|
||||||
use sc_service::PartialComponents;
|
|
||||||
|
|
||||||
impl SubstrateCli for Cli {
|
impl SubstrateCli for Cli {
|
||||||
fn impl_name() -> String {
|
fn impl_name() -> String {
|
||||||
@@ -67,6 +63,21 @@ impl SubstrateCli for Cli {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rialto native executor instance.
|
||||||
|
pub struct ExecutorDispatch;
|
||||||
|
|
||||||
|
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
|
||||||
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
|
|
||||||
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
rialto_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
rialto_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Parse and run command line arguments
|
/// Parse and run command line arguments
|
||||||
pub fn run() -> sc_cli::Result<()> {
|
pub fn run() -> sc_cli::Result<()> {
|
||||||
let cli = Cli::from_args();
|
let cli = Cli::from_args();
|
||||||
@@ -79,7 +90,7 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
if cfg!(feature = "runtime-benchmarks") {
|
if cfg!(feature = "runtime-benchmarks") {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
|
|
||||||
runner.sync_run(|config| cmd.run::<Block, crate::service::ExecutorDispatch>(config))
|
runner.sync_run(|config| cmd.run::<Block, ExecutorDispatch>(config))
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"Benchmarking wasn't enabled when building the node. \
|
"Benchmarking wasn't enabled when building the node. \
|
||||||
@@ -98,32 +109,32 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
Some(Subcommand::CheckBlock(cmd)) => {
|
Some(Subcommand::CheckBlock(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.async_run(|mut config| {
|
runner.async_run(|mut config| {
|
||||||
let PartialComponents { client, task_manager, import_queue, .. } =
|
let (client, _, import_queue, task_manager) =
|
||||||
new_partial(&mut config).map_err(service_error)?;
|
polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?;
|
||||||
Ok((cmd.run(client, import_queue), task_manager))
|
Ok((cmd.run(client, import_queue), task_manager))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Some(Subcommand::ExportBlocks(cmd)) => {
|
Some(Subcommand::ExportBlocks(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.async_run(|mut config| {
|
runner.async_run(|mut config| {
|
||||||
let PartialComponents { client, task_manager, .. } =
|
let (client, _, _, task_manager) =
|
||||||
new_partial(&mut config).map_err(service_error)?;
|
polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?;
|
||||||
Ok((cmd.run(client, config.database), task_manager))
|
Ok((cmd.run(client, config.database), task_manager))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Some(Subcommand::ExportState(cmd)) => {
|
Some(Subcommand::ExportState(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.async_run(|mut config| {
|
runner.async_run(|mut config| {
|
||||||
let PartialComponents { client, task_manager, .. } =
|
let (client, _, _, task_manager) =
|
||||||
new_partial(&mut config).map_err(service_error)?;
|
polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?;
|
||||||
Ok((cmd.run(client, config.chain_spec), task_manager))
|
Ok((cmd.run(client, config.chain_spec), task_manager))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Some(Subcommand::ImportBlocks(cmd)) => {
|
Some(Subcommand::ImportBlocks(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.async_run(|mut config| {
|
runner.async_run(|mut config| {
|
||||||
let PartialComponents { client, task_manager, import_queue, .. } =
|
let (client, _, import_queue, task_manager) =
|
||||||
new_partial(&mut config).map_err(service_error)?;
|
polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?;
|
||||||
Ok((cmd.run(client, import_queue), task_manager))
|
Ok((cmd.run(client, import_queue), task_manager))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -134,16 +145,14 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
Some(Subcommand::Revert(cmd)) => {
|
Some(Subcommand::Revert(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.async_run(|mut config| {
|
runner.async_run(|mut config| {
|
||||||
let PartialComponents { client, task_manager, backend, .. } =
|
let (client, backend, _, task_manager) =
|
||||||
new_partial(&mut config).map_err(service_error)?;
|
polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?;
|
||||||
Ok((cmd.run(client, backend), task_manager))
|
Ok((cmd.run(client, backend), task_manager))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Some(Subcommand::Inspect(cmd)) => {
|
Some(Subcommand::Inspect(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.sync_run(|config| {
|
runner.sync_run(|config| cmd.run::<Block, RuntimeApi, ExecutorDispatch>(config))
|
||||||
cmd.run::<Block, RuntimeApi, crate::service::ExecutorDispatch>(config)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
Some(Subcommand::PvfPrepareWorker(cmd)) => {
|
Some(Subcommand::PvfPrepareWorker(cmd)) => {
|
||||||
let mut builder = sc_cli::LoggerBuilder::new("");
|
let mut builder = sc_cli::LoggerBuilder::new("");
|
||||||
@@ -170,15 +179,35 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
// let no_beefy = true;
|
// let no_beefy = true;
|
||||||
// let telemetry_worker_handler = None;
|
// let telemetry_worker_handler = None;
|
||||||
// let is_collator = crate::service::IsCollator::No;
|
// let is_collator = crate::service::IsCollator::No;
|
||||||
let overseer_gen = crate::overseer::RealOverseerGen;
|
let overseer_gen = polkadot_service::overseer::RealOverseerGen;
|
||||||
runner.run_node_until_exit(|config| async move {
|
runner.run_node_until_exit(|config| async move {
|
||||||
match config.role {
|
match config.role {
|
||||||
Role::Light => Err(sc_cli::Error::Service(sc_service::Error::Other(
|
Role::Light => Err(sc_cli::Error::Service(sc_service::Error::Other(
|
||||||
"Light client is not supported by this node".into(),
|
"Light client is not supported by this node".into(),
|
||||||
))),
|
))),
|
||||||
_ => crate::service::build_full(config, overseer_gen)
|
_ => {
|
||||||
.map(|full| full.task_manager)
|
let is_collator = polkadot_service::IsCollator::No;
|
||||||
.map_err(service_error),
|
let grandpa_pause = None;
|
||||||
|
let enable_beefy = true;
|
||||||
|
let jaeger_agent = None;
|
||||||
|
let telemetry_worker_handle = None;
|
||||||
|
let program_path = None;
|
||||||
|
let overseer_enable_anyways = false;
|
||||||
|
|
||||||
|
polkadot_service::new_full::<rialto_runtime::RuntimeApi, ExecutorDispatch, _>(
|
||||||
|
config,
|
||||||
|
is_collator,
|
||||||
|
grandpa_pause,
|
||||||
|
enable_beefy,
|
||||||
|
jaeger_agent,
|
||||||
|
telemetry_worker_handle,
|
||||||
|
program_path,
|
||||||
|
overseer_enable_anyways,
|
||||||
|
overseer_gen,
|
||||||
|
)
|
||||||
|
.map(|full| full.task_manager)
|
||||||
|
.map_err(service_error)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -187,6 +216,6 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
|
|
||||||
// We don't want to change 'service.rs' too much to ease future updates => it'll keep using
|
// We don't want to change 'service.rs' too much to ease future updates => it'll keep using
|
||||||
// its own error enum like original polkadot service does.
|
// its own error enum like original polkadot service does.
|
||||||
fn service_error(err: crate::service::Error) -> sc_cli::Error {
|
fn service_error(err: polkadot_service::Error) -> sc_cli::Error {
|
||||||
sc_cli::Error::Application(Box::new(err))
|
sc_cli::Error::Application(Box::new(err))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,8 @@
|
|||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
mod chain_spec;
|
mod chain_spec;
|
||||||
#[macro_use]
|
|
||||||
mod service;
|
|
||||||
mod cli;
|
mod cli;
|
||||||
mod command;
|
mod command;
|
||||||
mod overseer;
|
|
||||||
mod parachains_db;
|
|
||||||
|
|
||||||
/// Run the Rialto Node
|
/// Run the Rialto Node
|
||||||
fn main() -> sc_cli::Result<()> {
|
fn main() -> sc_cli::Result<()> {
|
||||||
|
|||||||
@@ -1,320 +0,0 @@
|
|||||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
|
||||||
// This file is part of Parity Bridges Common.
|
|
||||||
|
|
||||||
// Parity Bridges Common 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.
|
|
||||||
|
|
||||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
//! This is almost 1:1 copy of `node/service/src/overseer.rs` file from Polkadot repository.
|
|
||||||
//! The only exception is that we don't support db upgrades => no `upgrade.rs` module.
|
|
||||||
|
|
||||||
// this warning comes from `polkadot_overseer::AllSubsystems` type
|
|
||||||
#![allow(clippy::type_complexity)]
|
|
||||||
|
|
||||||
use crate::service::{AuthorityDiscoveryApi, Error};
|
|
||||||
use rialto_runtime::{opaque::Block, Hash};
|
|
||||||
|
|
||||||
use lru::LruCache;
|
|
||||||
use polkadot_availability_distribution::IncomingRequestReceivers;
|
|
||||||
use polkadot_node_core_approval_voting::Config as ApprovalVotingConfig;
|
|
||||||
use polkadot_node_core_av_store::Config as AvailabilityConfig;
|
|
||||||
use polkadot_node_core_candidate_validation::Config as CandidateValidationConfig;
|
|
||||||
use polkadot_node_core_chain_selection::Config as ChainSelectionConfig;
|
|
||||||
use polkadot_node_core_dispute_coordinator::Config as DisputeCoordinatorConfig;
|
|
||||||
use polkadot_node_core_provisioner::ProvisionerConfig;
|
|
||||||
use polkadot_node_network_protocol::request_response::{v1 as request_v1, IncomingRequestReceiver};
|
|
||||||
use polkadot_overseer::{
|
|
||||||
metrics::Metrics as OverseerMetrics, BlockInfo, MetricsTrait, Overseer, InitializedOverseerBuilder,
|
|
||||||
OverseerConnector, OverseerHandle,
|
|
||||||
};
|
|
||||||
use polkadot_primitives::v2::ParachainHost;
|
|
||||||
use sc_authority_discovery::Service as AuthorityDiscoveryService;
|
|
||||||
use sc_client_api::AuxStore;
|
|
||||||
use sc_keystore::LocalKeystore;
|
|
||||||
use sp_api::ProvideRuntimeApi;
|
|
||||||
use sp_blockchain::HeaderBackend;
|
|
||||||
use sp_consensus_babe::BabeApi;
|
|
||||||
use sp_core::traits::SpawnNamed;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use substrate_prometheus_endpoint::Registry;
|
|
||||||
|
|
||||||
pub use polkadot_approval_distribution::ApprovalDistribution as ApprovalDistributionSubsystem;
|
|
||||||
pub use polkadot_availability_bitfield_distribution::BitfieldDistribution as BitfieldDistributionSubsystem;
|
|
||||||
pub use polkadot_availability_distribution::AvailabilityDistributionSubsystem;
|
|
||||||
pub use polkadot_availability_recovery::AvailabilityRecoverySubsystem;
|
|
||||||
pub use polkadot_collator_protocol::{CollatorProtocolSubsystem, ProtocolSide};
|
|
||||||
pub use polkadot_dispute_distribution::DisputeDistributionSubsystem;
|
|
||||||
pub use polkadot_gossip_support::GossipSupport as GossipSupportSubsystem;
|
|
||||||
pub use polkadot_network_bridge::NetworkBridge as NetworkBridgeSubsystem;
|
|
||||||
pub use polkadot_node_collation_generation::CollationGenerationSubsystem;
|
|
||||||
pub use polkadot_node_core_approval_voting::ApprovalVotingSubsystem;
|
|
||||||
pub use polkadot_node_core_av_store::AvailabilityStoreSubsystem;
|
|
||||||
pub use polkadot_node_core_backing::CandidateBackingSubsystem;
|
|
||||||
pub use polkadot_node_core_bitfield_signing::BitfieldSigningSubsystem;
|
|
||||||
pub use polkadot_node_core_candidate_validation::CandidateValidationSubsystem;
|
|
||||||
pub use polkadot_node_core_chain_api::ChainApiSubsystem;
|
|
||||||
pub use polkadot_node_core_chain_selection::ChainSelectionSubsystem;
|
|
||||||
pub use polkadot_node_core_dispute_coordinator::DisputeCoordinatorSubsystem;
|
|
||||||
pub use polkadot_node_core_provisioner::ProvisionerSubsystem;
|
|
||||||
pub use polkadot_node_core_runtime_api::RuntimeApiSubsystem;
|
|
||||||
pub use polkadot_statement_distribution::StatementDistributionSubsystem;
|
|
||||||
|
|
||||||
/// Arguments passed for overseer construction.
|
|
||||||
pub struct OverseerGenArgs<'a, Spawner, RuntimeClient>
|
|
||||||
where
|
|
||||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
|
||||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
|
||||||
Spawner: 'static + SpawnNamed + Clone + Unpin,
|
|
||||||
{
|
|
||||||
/// Set of initial relay chain leaves to track.
|
|
||||||
pub leaves: Vec<BlockInfo>,
|
|
||||||
/// The keystore to use for i.e. validator keys.
|
|
||||||
pub keystore: Arc<LocalKeystore>,
|
|
||||||
/// Runtime client generic, providing the `ProvieRuntimeApi` trait besides others.
|
|
||||||
pub runtime_client: Arc<RuntimeClient>,
|
|
||||||
/// The underlying key value store for the parachains.
|
|
||||||
pub parachains_db: Arc<dyn kvdb::KeyValueDB>,
|
|
||||||
/// Underlying network service implementation.
|
|
||||||
pub network_service: Arc<sc_network::NetworkService<Block, Hash>>,
|
|
||||||
/// Underlying authority discovery service.
|
|
||||||
pub authority_discovery_service: AuthorityDiscoveryService,
|
|
||||||
/// POV request receiver
|
|
||||||
pub pov_req_receiver: IncomingRequestReceiver<request_v1::PoVFetchingRequest>,
|
|
||||||
pub chunk_req_receiver: IncomingRequestReceiver<request_v1::ChunkFetchingRequest>,
|
|
||||||
pub collation_req_receiver: IncomingRequestReceiver<request_v1::CollationFetchingRequest>,
|
|
||||||
pub available_data_req_receiver:
|
|
||||||
IncomingRequestReceiver<request_v1::AvailableDataFetchingRequest>,
|
|
||||||
pub statement_req_receiver: IncomingRequestReceiver<request_v1::StatementFetchingRequest>,
|
|
||||||
pub dispute_req_receiver: IncomingRequestReceiver<request_v1::DisputeRequest>,
|
|
||||||
/// Prometheus registry, commonly used for production systems, less so for test.
|
|
||||||
pub registry: Option<&'a Registry>,
|
|
||||||
/// Task spawner to be used throughout the overseer and the APIs it provides.
|
|
||||||
pub spawner: Spawner,
|
|
||||||
/// Configuration for the approval voting subsystem.
|
|
||||||
pub approval_voting_config: ApprovalVotingConfig,
|
|
||||||
/// Configuration for the availability store subsystem.
|
|
||||||
pub availability_config: AvailabilityConfig,
|
|
||||||
/// Configuration for the candidate validation subsystem.
|
|
||||||
pub candidate_validation_config: CandidateValidationConfig,
|
|
||||||
/// Configuration for the chain selection subsystem.
|
|
||||||
pub chain_selection_config: ChainSelectionConfig,
|
|
||||||
/// Configuration for the dispute coordinator subsystem.
|
|
||||||
pub dispute_coordinator_config: DisputeCoordinatorConfig,
|
|
||||||
/// Configuration for the provisioner subsystem.
|
|
||||||
pub disputes_enabled: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Obtain a prepared `OverseerBuilder`, that is initialized
|
|
||||||
/// with all default values.
|
|
||||||
pub fn prepared_overseer_builder<Spawner, RuntimeClient>(
|
|
||||||
OverseerGenArgs {
|
|
||||||
leaves,
|
|
||||||
keystore,
|
|
||||||
runtime_client,
|
|
||||||
parachains_db,
|
|
||||||
network_service,
|
|
||||||
authority_discovery_service,
|
|
||||||
pov_req_receiver,
|
|
||||||
chunk_req_receiver,
|
|
||||||
collation_req_receiver: _,
|
|
||||||
available_data_req_receiver,
|
|
||||||
statement_req_receiver,
|
|
||||||
dispute_req_receiver,
|
|
||||||
registry,
|
|
||||||
spawner,
|
|
||||||
approval_voting_config,
|
|
||||||
availability_config,
|
|
||||||
candidate_validation_config,
|
|
||||||
chain_selection_config,
|
|
||||||
dispute_coordinator_config,
|
|
||||||
disputes_enabled,
|
|
||||||
}: OverseerGenArgs<'_, Spawner, RuntimeClient>,
|
|
||||||
) -> Result<
|
|
||||||
InitializedOverseerBuilder<
|
|
||||||
Spawner,
|
|
||||||
Arc<RuntimeClient>,
|
|
||||||
CandidateValidationSubsystem,
|
|
||||||
CandidateBackingSubsystem<Spawner>,
|
|
||||||
StatementDistributionSubsystem,
|
|
||||||
AvailabilityDistributionSubsystem,
|
|
||||||
AvailabilityRecoverySubsystem,
|
|
||||||
BitfieldSigningSubsystem<Spawner>,
|
|
||||||
BitfieldDistributionSubsystem,
|
|
||||||
ProvisionerSubsystem<Spawner>,
|
|
||||||
RuntimeApiSubsystem<RuntimeClient>,
|
|
||||||
AvailabilityStoreSubsystem,
|
|
||||||
NetworkBridgeSubsystem<
|
|
||||||
Arc<sc_network::NetworkService<Block, Hash>>,
|
|
||||||
AuthorityDiscoveryService,
|
|
||||||
>,
|
|
||||||
ChainApiSubsystem<RuntimeClient>,
|
|
||||||
CollationGenerationSubsystem,
|
|
||||||
CollatorProtocolSubsystem,
|
|
||||||
ApprovalDistributionSubsystem,
|
|
||||||
ApprovalVotingSubsystem,
|
|
||||||
GossipSupportSubsystem<AuthorityDiscoveryService>,
|
|
||||||
DisputeCoordinatorSubsystem,
|
|
||||||
DisputeDistributionSubsystem<AuthorityDiscoveryService>,
|
|
||||||
ChainSelectionSubsystem,
|
|
||||||
>,
|
|
||||||
Error,
|
|
||||||
>
|
|
||||||
where
|
|
||||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
|
||||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
|
||||||
Spawner: 'static + SpawnNamed + Clone + Unpin,
|
|
||||||
{
|
|
||||||
use polkadot_node_subsystem_util::metrics::Metrics;
|
|
||||||
use std::iter::FromIterator;
|
|
||||||
|
|
||||||
let metrics = <OverseerMetrics as MetricsTrait>::register(registry)?;
|
|
||||||
|
|
||||||
let builder = Overseer::builder()
|
|
||||||
.availability_distribution(AvailabilityDistributionSubsystem::new(
|
|
||||||
keystore.clone(),
|
|
||||||
IncomingRequestReceivers { pov_req_receiver, chunk_req_receiver },
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.availability_recovery(AvailabilityRecoverySubsystem::with_chunks_only(
|
|
||||||
available_data_req_receiver,
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.availability_store(AvailabilityStoreSubsystem::new(
|
|
||||||
parachains_db.clone(),
|
|
||||||
availability_config,
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.bitfield_distribution(BitfieldDistributionSubsystem::new(Metrics::register(registry)?))
|
|
||||||
.bitfield_signing(BitfieldSigningSubsystem::new(
|
|
||||||
spawner.clone(),
|
|
||||||
keystore.clone(),
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.candidate_backing(CandidateBackingSubsystem::new(
|
|
||||||
spawner.clone(),
|
|
||||||
keystore.clone(),
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.candidate_validation(CandidateValidationSubsystem::with_config(
|
|
||||||
candidate_validation_config,
|
|
||||||
Metrics::register(registry)?, // candidate-validation metrics
|
|
||||||
Metrics::register(registry)?, // validation host metrics
|
|
||||||
))
|
|
||||||
.chain_api(ChainApiSubsystem::new(runtime_client.clone(), Metrics::register(registry)?))
|
|
||||||
.collation_generation(CollationGenerationSubsystem::new(Metrics::register(registry)?))
|
|
||||||
.collator_protocol(CollatorProtocolSubsystem::new(ProtocolSide::Validator {
|
|
||||||
keystore: keystore.clone(),
|
|
||||||
eviction_policy: Default::default(),
|
|
||||||
metrics: Metrics::register(registry)?,
|
|
||||||
}))
|
|
||||||
.network_bridge(NetworkBridgeSubsystem::new(
|
|
||||||
network_service.clone(),
|
|
||||||
authority_discovery_service.clone(),
|
|
||||||
Box::new(network_service.clone()),
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.provisioner(ProvisionerSubsystem::new(spawner.clone(), ProvisionerConfig { disputes_enabled }, Metrics::register(registry)?))
|
|
||||||
.runtime_api(RuntimeApiSubsystem::new(
|
|
||||||
runtime_client.clone(),
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
spawner.clone(),
|
|
||||||
))
|
|
||||||
.statement_distribution(StatementDistributionSubsystem::new(
|
|
||||||
keystore.clone(),
|
|
||||||
statement_req_receiver,
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.approval_distribution(ApprovalDistributionSubsystem::new(Metrics::register(registry)?))
|
|
||||||
.approval_voting(ApprovalVotingSubsystem::with_config(
|
|
||||||
approval_voting_config,
|
|
||||||
parachains_db.clone(),
|
|
||||||
keystore.clone(),
|
|
||||||
Box::new(network_service),
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.gossip_support(GossipSupportSubsystem::new(
|
|
||||||
keystore.clone(),
|
|
||||||
authority_discovery_service.clone(),
|
|
||||||
))
|
|
||||||
.dispute_coordinator(DisputeCoordinatorSubsystem::new(
|
|
||||||
parachains_db.clone(),
|
|
||||||
dispute_coordinator_config,
|
|
||||||
keystore.clone(),
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.dispute_distribution(DisputeDistributionSubsystem::new(
|
|
||||||
keystore,
|
|
||||||
dispute_req_receiver,
|
|
||||||
authority_discovery_service,
|
|
||||||
Metrics::register(registry)?,
|
|
||||||
))
|
|
||||||
.chain_selection(ChainSelectionSubsystem::new(chain_selection_config, parachains_db))
|
|
||||||
.leaves(Vec::from_iter(
|
|
||||||
leaves
|
|
||||||
.into_iter()
|
|
||||||
.map(|BlockInfo { hash, parent_hash: _, number }| (hash, number)),
|
|
||||||
))
|
|
||||||
.activation_external_listeners(Default::default())
|
|
||||||
.span_per_active_leaf(Default::default())
|
|
||||||
.active_leaves(Default::default())
|
|
||||||
.supports_parachains(runtime_client)
|
|
||||||
.known_leaves(LruCache::new(KNOWN_LEAVES_CACHE_SIZE))
|
|
||||||
.metrics(metrics)
|
|
||||||
.spawner(spawner);
|
|
||||||
Ok(builder)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Trait for the `fn` generating the overseer.
|
|
||||||
///
|
|
||||||
/// Default behavior is to create an unmodified overseer, as `RealOverseerGen`
|
|
||||||
/// would do.
|
|
||||||
pub trait OverseerGen {
|
|
||||||
/// Overwrite the full generation of the overseer, including the subsystems.
|
|
||||||
fn generate<Spawner, RuntimeClient>(
|
|
||||||
&self,
|
|
||||||
connector: OverseerConnector,
|
|
||||||
args: OverseerGenArgs<'_, Spawner, RuntimeClient>,
|
|
||||||
) -> Result<(Overseer<Spawner, Arc<RuntimeClient>>, OverseerHandle), Error>
|
|
||||||
where
|
|
||||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
|
||||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
|
||||||
Spawner: 'static + SpawnNamed + Clone + Unpin,
|
|
||||||
{
|
|
||||||
let gen = RealOverseerGen;
|
|
||||||
RealOverseerGen::generate::<Spawner, RuntimeClient>(&gen, connector, args)
|
|
||||||
}
|
|
||||||
// It would be nice to make `create_subsystems` part of this trait,
|
|
||||||
// but the amount of generic arguments that would be required as
|
|
||||||
// as consequence make this rather annoying to implement and use.
|
|
||||||
}
|
|
||||||
|
|
||||||
use polkadot_overseer::KNOWN_LEAVES_CACHE_SIZE;
|
|
||||||
|
|
||||||
/// The regular set of subsystems.
|
|
||||||
pub struct RealOverseerGen;
|
|
||||||
|
|
||||||
impl OverseerGen for RealOverseerGen {
|
|
||||||
fn generate<Spawner, RuntimeClient>(
|
|
||||||
&self,
|
|
||||||
connector: OverseerConnector,
|
|
||||||
args: OverseerGenArgs<'_, Spawner, RuntimeClient>,
|
|
||||||
) -> Result<(Overseer<Spawner, Arc<RuntimeClient>>, OverseerHandle), Error>
|
|
||||||
where
|
|
||||||
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
|
|
||||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
|
||||||
Spawner: 'static + SpawnNamed + Clone + Unpin,
|
|
||||||
{
|
|
||||||
prepared_overseer_builder(args)?
|
|
||||||
.build_with_connector(connector)
|
|
||||||
.map_err(|e| e.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
|
||||||
// This file is part of Parity Bridges Common.
|
|
||||||
|
|
||||||
// Parity Bridges Common 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.
|
|
||||||
|
|
||||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
//! This is almost 1:1 copy of `node/service/parachains_db/mod.rs` file from Polkadot repository.
|
|
||||||
//! The only exception is that we don't support db upgrades => no `upgrade.rs` module.
|
|
||||||
|
|
||||||
use kvdb::KeyValueDB;
|
|
||||||
use std::{io, path::PathBuf, sync::Arc};
|
|
||||||
|
|
||||||
mod columns {
|
|
||||||
pub const NUM_COLUMNS: u32 = 5;
|
|
||||||
|
|
||||||
pub const COL_AVAILABILITY_DATA: u32 = 0;
|
|
||||||
pub const COL_AVAILABILITY_META: u32 = 1;
|
|
||||||
pub const COL_APPROVAL_DATA: u32 = 2;
|
|
||||||
pub const COL_CHAIN_SELECTION_DATA: u32 = 3;
|
|
||||||
pub const COL_DISPUTE_COORDINATOR_DATA: u32 = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Columns used by different subsystems.
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct ColumnsConfig {
|
|
||||||
/// The column used by the av-store for data.
|
|
||||||
pub col_availability_data: u32,
|
|
||||||
/// The column used by the av-store for meta information.
|
|
||||||
pub col_availability_meta: u32,
|
|
||||||
/// The column used by approval voting for data.
|
|
||||||
pub col_approval_data: u32,
|
|
||||||
/// The column used by chain selection for data.
|
|
||||||
pub col_chain_selection_data: u32,
|
|
||||||
/// The column used by dispute coordinator for data.
|
|
||||||
pub col_dispute_coordinator_data: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The real columns used by the parachains DB.
|
|
||||||
pub const REAL_COLUMNS: ColumnsConfig = ColumnsConfig {
|
|
||||||
col_availability_data: columns::COL_AVAILABILITY_DATA,
|
|
||||||
col_availability_meta: columns::COL_AVAILABILITY_META,
|
|
||||||
col_approval_data: columns::COL_APPROVAL_DATA,
|
|
||||||
col_chain_selection_data: columns::COL_CHAIN_SELECTION_DATA,
|
|
||||||
col_dispute_coordinator_data: columns::COL_DISPUTE_COORDINATOR_DATA,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// The cache size for each column, in megabytes.
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct CacheSizes {
|
|
||||||
/// Cache used by availability data.
|
|
||||||
pub availability_data: usize,
|
|
||||||
/// Cache used by availability meta.
|
|
||||||
pub availability_meta: usize,
|
|
||||||
/// Cache used by approval data.
|
|
||||||
pub approval_data: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for CacheSizes {
|
|
||||||
fn default() -> Self {
|
|
||||||
CacheSizes { availability_data: 25, availability_meta: 1, approval_data: 5 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn other_io_error(err: String) -> io::Error {
|
|
||||||
io::Error::new(io::ErrorKind::Other, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Open the database on disk, creating it if it doesn't exist.
|
|
||||||
pub fn open_creating(root: PathBuf, cache_sizes: CacheSizes) -> io::Result<Arc<dyn KeyValueDB>> {
|
|
||||||
use kvdb_rocksdb::{Database, DatabaseConfig};
|
|
||||||
|
|
||||||
let path = root.join("parachains").join("db");
|
|
||||||
|
|
||||||
let mut db_config = DatabaseConfig::with_columns(columns::NUM_COLUMNS);
|
|
||||||
|
|
||||||
let _ = db_config
|
|
||||||
.memory_budget
|
|
||||||
.insert(columns::COL_AVAILABILITY_DATA, cache_sizes.availability_data);
|
|
||||||
let _ = db_config
|
|
||||||
.memory_budget
|
|
||||||
.insert(columns::COL_AVAILABILITY_META, cache_sizes.availability_meta);
|
|
||||||
let _ = db_config
|
|
||||||
.memory_budget
|
|
||||||
.insert(columns::COL_APPROVAL_DATA, cache_sizes.approval_data);
|
|
||||||
|
|
||||||
let path_str = path
|
|
||||||
.to_str()
|
|
||||||
.ok_or_else(|| other_io_error(format!("Bad database path: {:?}", path)))?;
|
|
||||||
|
|
||||||
std::fs::create_dir_all(&path_str)?;
|
|
||||||
let db = Database::open(&db_config, path_str)?;
|
|
||||||
|
|
||||||
Ok(Arc::new(db))
|
|
||||||
}
|
|
||||||
@@ -1,759 +0,0 @@
|
|||||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
|
||||||
// This file is part of Parity Bridges Common.
|
|
||||||
|
|
||||||
// Parity Bridges Common 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.
|
|
||||||
|
|
||||||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
//! Rialto chain node service.
|
|
||||||
//!
|
|
||||||
//! The code is mostly copy of `service/src/lib.rs` file from Polkadot repository
|
|
||||||
//! without optional functions, and with BEEFY added on top.
|
|
||||||
|
|
||||||
use crate::overseer::{OverseerGen, OverseerGenArgs};
|
|
||||||
|
|
||||||
use polkadot_client::RuntimeApiCollection;
|
|
||||||
use polkadot_node_core_approval_voting::Config as ApprovalVotingConfig;
|
|
||||||
use polkadot_node_core_av_store::Config as AvailabilityConfig;
|
|
||||||
use polkadot_node_core_candidate_validation::Config as CandidateValidationConfig;
|
|
||||||
use polkadot_node_core_chain_selection::Config as ChainSelectionConfig;
|
|
||||||
use polkadot_node_core_dispute_coordinator::Config as DisputeCoordinatorConfig;
|
|
||||||
use polkadot_node_network_protocol::request_response::IncomingRequest;
|
|
||||||
use polkadot_overseer::{BlockInfo, OverseerConnector};
|
|
||||||
use polkadot_primitives::v2::BlockId;
|
|
||||||
use rialto_runtime::{self, opaque::Block, RuntimeApi};
|
|
||||||
use sc_client_api::ExecutorProvider;
|
|
||||||
use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch};
|
|
||||||
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
|
|
||||||
use sc_service::{config::PrometheusConfig, Configuration, TaskManager};
|
|
||||||
use sc_telemetry::{Telemetry, TelemetryWorker};
|
|
||||||
use sp_api::{ConstructRuntimeApi, HeaderT};
|
|
||||||
use sp_consensus::SelectChain;
|
|
||||||
use sp_runtime::traits::Block as BlockT;
|
|
||||||
use std::{sync::Arc, time::Duration};
|
|
||||||
use substrate_prometheus_endpoint::Registry;
|
|
||||||
|
|
||||||
pub use polkadot_overseer::Handle;
|
|
||||||
pub use polkadot_primitives::v2::ParachainHost;
|
|
||||||
pub use sc_client_api::AuxStore;
|
|
||||||
pub use sp_authority_discovery::AuthorityDiscoveryApi;
|
|
||||||
pub use sp_blockchain::HeaderBackend;
|
|
||||||
pub use sp_consensus_babe::BabeApi;
|
|
||||||
|
|
||||||
pub type Executor = NativeElseWasmExecutor<ExecutorDispatch>;
|
|
||||||
|
|
||||||
// Our native executor instance.
|
|
||||||
pub struct ExecutorDispatch;
|
|
||||||
|
|
||||||
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
|
|
||||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
|
||||||
|
|
||||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
|
||||||
rialto_runtime::api::dispatch(method, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn native_version() -> sc_executor::NativeVersion {
|
|
||||||
rialto_runtime::native_version()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
|
||||||
pub enum Error {
|
|
||||||
#[error(transparent)]
|
|
||||||
Io(#[from] std::io::Error),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
Cli(#[from] sc_cli::Error),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
Blockchain(#[from] sp_blockchain::Error),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
Consensus(#[from] sp_consensus::Error),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
Service(#[from] sc_service::Error),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
Telemetry(#[from] sc_telemetry::Error),
|
|
||||||
|
|
||||||
#[error("Failed to create an overseer")]
|
|
||||||
Overseer(#[from] polkadot_overseer::SubsystemError),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
Prometheus(#[from] substrate_prometheus_endpoint::PrometheusError),
|
|
||||||
|
|
||||||
#[error("Authorities require the real overseer implementation")]
|
|
||||||
AuthoritiesRequireRealOverseer,
|
|
||||||
|
|
||||||
#[error("Creating a custom database is required for validators")]
|
|
||||||
DatabasePathRequired,
|
|
||||||
}
|
|
||||||
|
|
||||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
|
||||||
type FullBackend = sc_service::TFullBackend<Block>;
|
|
||||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
|
||||||
type FullGrandpaBlockImport =
|
|
||||||
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>;
|
|
||||||
type FullTransactionPool = sc_transaction_pool::FullPool<Block, FullClient>;
|
|
||||||
type FullBabeBlockImport =
|
|
||||||
sc_consensus_babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport>;
|
|
||||||
type FullBabeLink = sc_consensus_babe::BabeLink<Block>;
|
|
||||||
type FullGrandpaLink = sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>;
|
|
||||||
|
|
||||||
// If we're using prometheus, use a registry with a prefix of `polkadot`.
|
|
||||||
fn set_prometheus_registry(config: &mut Configuration) -> Result<(), Error> {
|
|
||||||
if let Some(PrometheusConfig { registry, .. }) = config.prometheus_config.as_mut() {
|
|
||||||
*registry = Registry::new_custom(Some("polkadot".into()), None)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Needed here for complex return type while `impl Trait` in type aliases is unstable.
|
|
||||||
#[allow(clippy::type_complexity)]
|
|
||||||
pub fn new_partial(
|
|
||||||
config: &mut Configuration,
|
|
||||||
) -> Result<
|
|
||||||
sc_service::PartialComponents<
|
|
||||||
FullClient,
|
|
||||||
FullBackend,
|
|
||||||
FullSelectChain,
|
|
||||||
sc_consensus::DefaultImportQueue<Block, FullClient>,
|
|
||||||
FullTransactionPool,
|
|
||||||
(
|
|
||||||
impl Fn(
|
|
||||||
sc_rpc::DenyUnsafe,
|
|
||||||
sc_rpc::SubscriptionTaskExecutor,
|
|
||||||
) -> Result<jsonrpc_core::IoHandler<sc_service::RpcMetadata>, sc_service::Error>,
|
|
||||||
(
|
|
||||||
FullBabeBlockImport,
|
|
||||||
FullGrandpaLink,
|
|
||||||
FullBabeLink,
|
|
||||||
beefy_gadget::notification::BeefySignedCommitmentSender<Block>,
|
|
||||||
),
|
|
||||||
sc_finality_grandpa::SharedVoterState,
|
|
||||||
std::time::Duration,
|
|
||||||
Option<Telemetry>,
|
|
||||||
),
|
|
||||||
>,
|
|
||||||
Error,
|
|
||||||
>
|
|
||||||
where
|
|
||||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient> + Send + Sync + 'static,
|
|
||||||
<RuntimeApi as ConstructRuntimeApi<Block, FullClient>>::RuntimeApi:
|
|
||||||
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
|
|
||||||
ExecutorDispatch: NativeExecutionDispatch + 'static,
|
|
||||||
{
|
|
||||||
set_prometheus_registry(config)?;
|
|
||||||
|
|
||||||
let telemetry = config
|
|
||||||
.telemetry_endpoints
|
|
||||||
.clone()
|
|
||||||
.filter(|x| !x.is_empty())
|
|
||||||
.map(|endpoints| -> Result<_, sc_telemetry::Error> {
|
|
||||||
let worker = TelemetryWorker::new(16)?;
|
|
||||||
let telemetry = worker.handle().new_telemetry(endpoints);
|
|
||||||
Ok((worker, telemetry))
|
|
||||||
})
|
|
||||||
.transpose()?;
|
|
||||||
|
|
||||||
let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(
|
|
||||||
config.wasm_method,
|
|
||||||
config.default_heap_pages,
|
|
||||||
config.max_runtime_instances,
|
|
||||||
config.runtime_cache_size,
|
|
||||||
);
|
|
||||||
|
|
||||||
let (client, backend, keystore_container, task_manager) =
|
|
||||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(
|
|
||||||
config,
|
|
||||||
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
|
||||||
executor,
|
|
||||||
)?;
|
|
||||||
let client = Arc::new(client);
|
|
||||||
|
|
||||||
let telemetry = telemetry.map(|(worker, telemetry)| {
|
|
||||||
task_manager.spawn_handle().spawn("telemetry", None, worker.run());
|
|
||||||
telemetry
|
|
||||||
});
|
|
||||||
|
|
||||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
|
||||||
|
|
||||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
|
||||||
config.transaction_pool.clone(),
|
|
||||||
config.role.is_authority().into(),
|
|
||||||
config.prometheus_registry(),
|
|
||||||
task_manager.spawn_essential_handle(),
|
|
||||||
client.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let (grandpa_block_import, grandpa_link) =
|
|
||||||
sc_finality_grandpa::block_import_with_authority_set_hard_forks(
|
|
||||||
client.clone(),
|
|
||||||
&(client.clone() as Arc<_>),
|
|
||||||
select_chain.clone(),
|
|
||||||
Vec::new(),
|
|
||||||
telemetry.as_ref().map(|x| x.handle()),
|
|
||||||
)?;
|
|
||||||
let justification_import = grandpa_block_import.clone();
|
|
||||||
|
|
||||||
let babe_config = sc_consensus_babe::Config::get(&*client)?;
|
|
||||||
let (block_import, babe_link) =
|
|
||||||
sc_consensus_babe::block_import(babe_config.clone(), grandpa_block_import, client.clone())?;
|
|
||||||
|
|
||||||
let slot_duration = babe_link.config().slot_duration();
|
|
||||||
let import_queue = sc_consensus_babe::import_queue(
|
|
||||||
babe_link.clone(),
|
|
||||||
block_import.clone(),
|
|
||||||
Some(Box::new(justification_import)),
|
|
||||||
client.clone(),
|
|
||||||
select_chain.clone(),
|
|
||||||
move |_, ()| async move {
|
|
||||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
|
||||||
|
|
||||||
let slot =
|
|
||||||
sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_duration(
|
|
||||||
*timestamp,
|
|
||||||
slot_duration,
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok((timestamp, slot))
|
|
||||||
},
|
|
||||||
&task_manager.spawn_essential_handle(),
|
|
||||||
config.prometheus_registry(),
|
|
||||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
|
|
||||||
telemetry.as_ref().map(|x| x.handle()),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let justification_stream = grandpa_link.justification_stream();
|
|
||||||
let shared_authority_set = grandpa_link.shared_authority_set().clone();
|
|
||||||
let shared_voter_state = sc_finality_grandpa::SharedVoterState::empty();
|
|
||||||
|
|
||||||
let (signed_commitment_sender, signed_commitment_stream) =
|
|
||||||
beefy_gadget::notification::BeefySignedCommitmentStream::channel();
|
|
||||||
|
|
||||||
let import_setup = (block_import, grandpa_link, babe_link, signed_commitment_sender);
|
|
||||||
let rpc_setup = shared_voter_state.clone();
|
|
||||||
|
|
||||||
let slot_duration = babe_config.slot_duration();
|
|
||||||
|
|
||||||
let rpc_extensions_builder = {
|
|
||||||
let client = client.clone();
|
|
||||||
let transaction_pool = transaction_pool.clone();
|
|
||||||
let backend = backend.clone();
|
|
||||||
|
|
||||||
move |deny_unsafe,
|
|
||||||
subscription_executor: sc_rpc::SubscriptionTaskExecutor|
|
|
||||||
-> Result<jsonrpc_core::IoHandler<sc_service::RpcMetadata>, sc_service::Error> {
|
|
||||||
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
|
|
||||||
use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler};
|
|
||||||
use substrate_frame_rpc_system::{FullSystem, SystemApi};
|
|
||||||
|
|
||||||
let backend = backend.clone();
|
|
||||||
let client = client.clone();
|
|
||||||
let pool = transaction_pool.clone();
|
|
||||||
|
|
||||||
let shared_voter_state = shared_voter_state.clone();
|
|
||||||
|
|
||||||
let finality_proof_provider = GrandpaFinalityProofProvider::new_for_service(
|
|
||||||
backend,
|
|
||||||
Some(shared_authority_set.clone()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut io = jsonrpc_core::IoHandler::default();
|
|
||||||
io.extend_with(SystemApi::to_delegate(FullSystem::new(
|
|
||||||
client.clone(),
|
|
||||||
pool,
|
|
||||||
deny_unsafe,
|
|
||||||
)));
|
|
||||||
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
|
|
||||||
client.clone(),
|
|
||||||
)));
|
|
||||||
io.extend_with(GrandpaApi::to_delegate(GrandpaRpcHandler::new(
|
|
||||||
shared_authority_set.clone(),
|
|
||||||
shared_voter_state,
|
|
||||||
justification_stream.clone(),
|
|
||||||
subscription_executor.clone(),
|
|
||||||
finality_proof_provider,
|
|
||||||
)));
|
|
||||||
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(
|
|
||||||
beefy_gadget_rpc::BeefyRpcHandler::new(
|
|
||||||
signed_commitment_stream.clone(),
|
|
||||||
subscription_executor,
|
|
||||||
),
|
|
||||||
));
|
|
||||||
io.extend_with(pallet_mmr_rpc::MmrApi::to_delegate(pallet_mmr_rpc::Mmr::new(client)));
|
|
||||||
|
|
||||||
Ok(io)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(sc_service::PartialComponents {
|
|
||||||
client,
|
|
||||||
backend,
|
|
||||||
task_manager,
|
|
||||||
keystore_container,
|
|
||||||
select_chain,
|
|
||||||
import_queue,
|
|
||||||
transaction_pool,
|
|
||||||
other: (rpc_extensions_builder, import_setup, rpc_setup, slot_duration, telemetry),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct NewFull<C> {
|
|
||||||
pub task_manager: TaskManager,
|
|
||||||
pub client: C,
|
|
||||||
pub overseer_handle: Option<Handle>,
|
|
||||||
pub network: Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
|
|
||||||
pub rpc_handlers: sc_service::RpcHandlers,
|
|
||||||
pub backend: Arc<FullBackend>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The maximum number of active leaves we forward to the [`Overseer`] on start up.
|
|
||||||
const MAX_ACTIVE_LEAVES: usize = 4;
|
|
||||||
|
|
||||||
/// Returns the active leaves the overseer should start with.
|
|
||||||
async fn active_leaves(
|
|
||||||
select_chain: &sc_consensus::LongestChain<FullBackend, Block>,
|
|
||||||
client: &FullClient,
|
|
||||||
) -> Result<Vec<BlockInfo>, Error>
|
|
||||||
where
|
|
||||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient> + Send + Sync + 'static,
|
|
||||||
<RuntimeApi as ConstructRuntimeApi<Block, FullClient>>::RuntimeApi:
|
|
||||||
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
|
|
||||||
ExecutorDispatch: NativeExecutionDispatch + 'static,
|
|
||||||
{
|
|
||||||
let best_block = select_chain.best_chain().await?;
|
|
||||||
|
|
||||||
let mut leaves = select_chain
|
|
||||||
.leaves()
|
|
||||||
.await
|
|
||||||
.unwrap_or_default()
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|hash| {
|
|
||||||
let number = client.number(hash).ok()??;
|
|
||||||
|
|
||||||
// Only consider leaves that are in maximum an uncle of the best block.
|
|
||||||
if number < best_block.number().saturating_sub(1) || hash == best_block.hash() {
|
|
||||||
return None
|
|
||||||
}
|
|
||||||
|
|
||||||
let parent_hash = client.header(&BlockId::Hash(hash)).ok()??.parent_hash;
|
|
||||||
|
|
||||||
Some(BlockInfo { hash, parent_hash, number })
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
// Sort by block number and get the maximum number of leaves
|
|
||||||
leaves.sort_by_key(|b| b.number);
|
|
||||||
|
|
||||||
leaves.push(BlockInfo {
|
|
||||||
hash: best_block.hash(),
|
|
||||||
parent_hash: *best_block.parent_hash(),
|
|
||||||
number: *best_block.number(),
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(leaves.into_iter().rev().take(MAX_ACTIVE_LEAVES).collect())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new full node.
|
|
||||||
pub fn new_full(
|
|
||||||
mut config: Configuration,
|
|
||||||
program_path: Option<std::path::PathBuf>,
|
|
||||||
overseer_gen: impl OverseerGen,
|
|
||||||
) -> Result<NewFull<Arc<FullClient>>, Error>
|
|
||||||
where
|
|
||||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient> + Send + Sync + 'static,
|
|
||||||
<RuntimeApi as ConstructRuntimeApi<Block, FullClient>>::RuntimeApi:
|
|
||||||
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
|
|
||||||
ExecutorDispatch: NativeExecutionDispatch + 'static,
|
|
||||||
{
|
|
||||||
let is_collator = false;
|
|
||||||
|
|
||||||
let role = config.role.clone();
|
|
||||||
let force_authoring = config.force_authoring;
|
|
||||||
let backoff_authoring_blocks =
|
|
||||||
Some(sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging::default());
|
|
||||||
|
|
||||||
let disable_grandpa = config.disable_grandpa;
|
|
||||||
let name = config.network.node_name.clone();
|
|
||||||
|
|
||||||
let sc_service::PartialComponents {
|
|
||||||
client,
|
|
||||||
backend,
|
|
||||||
mut task_manager,
|
|
||||||
keystore_container,
|
|
||||||
select_chain,
|
|
||||||
import_queue,
|
|
||||||
transaction_pool,
|
|
||||||
other: (rpc_extensions_builder, import_setup, rpc_setup, slot_duration, mut telemetry),
|
|
||||||
} = new_partial(&mut config)?;
|
|
||||||
|
|
||||||
let prometheus_registry = config.prometheus_registry().cloned();
|
|
||||||
|
|
||||||
let overseer_connector = OverseerConnector::default();
|
|
||||||
|
|
||||||
let shared_voter_state = rpc_setup;
|
|
||||||
let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht;
|
|
||||||
|
|
||||||
// Note: GrandPa is pushed before the Polkadot-specific protocols. This doesn't change
|
|
||||||
// anything in terms of behaviour, but makes the logs more consistent with the other
|
|
||||||
// Substrate nodes.
|
|
||||||
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
|
|
||||||
|
|
||||||
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
|
|
||||||
|
|
||||||
{
|
|
||||||
use polkadot_network_bridge::{peer_sets_info, IsAuthority};
|
|
||||||
let is_authority = if role.is_authority() { IsAuthority::Yes } else { IsAuthority::No };
|
|
||||||
config.network.extra_sets.extend(peer_sets_info(is_authority));
|
|
||||||
}
|
|
||||||
|
|
||||||
let (pov_req_receiver, cfg) = IncomingRequest::get_config_receiver();
|
|
||||||
config.network.request_response_protocols.push(cfg);
|
|
||||||
let (chunk_req_receiver, cfg) = IncomingRequest::get_config_receiver();
|
|
||||||
config.network.request_response_protocols.push(cfg);
|
|
||||||
let (collation_req_receiver, cfg) = IncomingRequest::get_config_receiver();
|
|
||||||
config.network.request_response_protocols.push(cfg);
|
|
||||||
let (available_data_req_receiver, cfg) = IncomingRequest::get_config_receiver();
|
|
||||||
config.network.request_response_protocols.push(cfg);
|
|
||||||
let (statement_req_receiver, cfg) = IncomingRequest::get_config_receiver();
|
|
||||||
config.network.request_response_protocols.push(cfg);
|
|
||||||
let (dispute_req_receiver, cfg) = IncomingRequest::get_config_receiver();
|
|
||||||
config.network.request_response_protocols.push(cfg);
|
|
||||||
|
|
||||||
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
|
|
||||||
backend.clone(),
|
|
||||||
import_setup.1.shared_authority_set().clone(),
|
|
||||||
vec![],
|
|
||||||
));
|
|
||||||
|
|
||||||
let (network, system_rpc_tx, network_starter) =
|
|
||||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
|
||||||
config: &config,
|
|
||||||
client: client.clone(),
|
|
||||||
transaction_pool: transaction_pool.clone(),
|
|
||||||
spawn_handle: task_manager.spawn_handle(),
|
|
||||||
import_queue,
|
|
||||||
block_announce_validator_builder: None,
|
|
||||||
warp_sync: Some(warp_sync),
|
|
||||||
})?;
|
|
||||||
|
|
||||||
if config.offchain_worker.enabled {
|
|
||||||
let _ = sc_service::build_offchain_workers(
|
|
||||||
&config,
|
|
||||||
task_manager.spawn_handle(),
|
|
||||||
client.clone(),
|
|
||||||
network.clone(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let parachains_db = crate::parachains_db::open_creating(
|
|
||||||
config.database.path().ok_or(Error::DatabasePathRequired)?.into(),
|
|
||||||
crate::parachains_db::CacheSizes::default(),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let availability_config = AvailabilityConfig {
|
|
||||||
col_data: crate::parachains_db::REAL_COLUMNS.col_availability_data,
|
|
||||||
col_meta: crate::parachains_db::REAL_COLUMNS.col_availability_meta,
|
|
||||||
};
|
|
||||||
|
|
||||||
let approval_voting_config = ApprovalVotingConfig {
|
|
||||||
col_data: crate::parachains_db::REAL_COLUMNS.col_approval_data,
|
|
||||||
slot_duration_millis: slot_duration.as_millis() as u64,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
let candidate_validation_config = CandidateValidationConfig {
|
|
||||||
artifacts_cache_path: config
|
|
||||||
.database
|
|
||||||
.path()
|
|
||||||
.ok_or(Error::DatabasePathRequired)?
|
|
||||||
.join("pvf-artifacts"),
|
|
||||||
program_path: match program_path {
|
|
||||||
None => std::env::current_exe()?,
|
|
||||||
Some(p) => p,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
let chain_selection_config = ChainSelectionConfig {
|
|
||||||
col_data: crate::parachains_db::REAL_COLUMNS.col_chain_selection_data,
|
|
||||||
stagnant_check_interval: polkadot_node_core_chain_selection::StagnantCheckInterval::never(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let dispute_coordinator_config = DisputeCoordinatorConfig {
|
|
||||||
col_data: crate::parachains_db::REAL_COLUMNS.col_dispute_coordinator_data,
|
|
||||||
};
|
|
||||||
|
|
||||||
let rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
|
||||||
config,
|
|
||||||
backend: backend.clone(),
|
|
||||||
client: client.clone(),
|
|
||||||
keystore: keystore_container.sync_keystore(),
|
|
||||||
network: network.clone(),
|
|
||||||
rpc_extensions_builder: Box::new(rpc_extensions_builder),
|
|
||||||
transaction_pool: transaction_pool.clone(),
|
|
||||||
task_manager: &mut task_manager,
|
|
||||||
system_rpc_tx,
|
|
||||||
telemetry: telemetry.as_mut(),
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let (block_import, link_half, babe_link, signed_commitment_sender) = import_setup;
|
|
||||||
|
|
||||||
let overseer_client = client.clone();
|
|
||||||
let spawner = task_manager.spawn_handle();
|
|
||||||
let active_leaves = futures::executor::block_on(active_leaves(&select_chain, &*client))?;
|
|
||||||
|
|
||||||
let authority_discovery_service = if role.is_authority() || is_collator {
|
|
||||||
use futures::StreamExt;
|
|
||||||
use sc_network::Event;
|
|
||||||
|
|
||||||
let authority_discovery_role = if role.is_authority() {
|
|
||||||
sc_authority_discovery::Role::PublishAndDiscover(keystore_container.keystore())
|
|
||||||
} else {
|
|
||||||
// don't publish our addresses when we're only a collator
|
|
||||||
sc_authority_discovery::Role::Discover
|
|
||||||
};
|
|
||||||
let dht_event_stream =
|
|
||||||
network.event_stream("authority-discovery").filter_map(|e| async move {
|
|
||||||
match e {
|
|
||||||
Event::Dht(e) => Some(e),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let (worker, service) = sc_authority_discovery::new_worker_and_service_with_config(
|
|
||||||
sc_authority_discovery::WorkerConfig {
|
|
||||||
publish_non_global_ips: auth_disc_publish_non_global_ips,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
client.clone(),
|
|
||||||
network.clone(),
|
|
||||||
Box::pin(dht_event_stream),
|
|
||||||
authority_discovery_role,
|
|
||||||
prometheus_registry.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
task_manager
|
|
||||||
.spawn_handle()
|
|
||||||
.spawn("authority-discovery-worker", None, worker.run());
|
|
||||||
Some(service)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
// we'd say let overseer_handler =
|
|
||||||
// authority_discovery_service.map(|authority_discovery_service|, ...), but in that case we
|
|
||||||
// couldn't use ? to propagate errors
|
|
||||||
let local_keystore = keystore_container.local_keystore();
|
|
||||||
let maybe_params =
|
|
||||||
local_keystore.and_then(move |k| authority_discovery_service.map(|a| (a, k)));
|
|
||||||
|
|
||||||
let overseer_handle = if let Some((authority_discovery_service, keystore)) = maybe_params {
|
|
||||||
let (overseer, overseer_handle) = overseer_gen
|
|
||||||
.generate::<sc_service::SpawnTaskHandle, FullClient>(
|
|
||||||
overseer_connector,
|
|
||||||
OverseerGenArgs {
|
|
||||||
leaves: active_leaves,
|
|
||||||
keystore,
|
|
||||||
runtime_client: overseer_client.clone(),
|
|
||||||
parachains_db,
|
|
||||||
availability_config,
|
|
||||||
approval_voting_config,
|
|
||||||
network_service: network.clone(),
|
|
||||||
authority_discovery_service,
|
|
||||||
registry: prometheus_registry.as_ref(),
|
|
||||||
spawner,
|
|
||||||
candidate_validation_config,
|
|
||||||
available_data_req_receiver,
|
|
||||||
chain_selection_config,
|
|
||||||
chunk_req_receiver,
|
|
||||||
collation_req_receiver,
|
|
||||||
dispute_coordinator_config,
|
|
||||||
dispute_req_receiver,
|
|
||||||
pov_req_receiver,
|
|
||||||
statement_req_receiver,
|
|
||||||
disputes_enabled: false,
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
let handle = Handle::new(overseer_handle);
|
|
||||||
|
|
||||||
{
|
|
||||||
let handle = handle.clone();
|
|
||||||
task_manager.spawn_essential_handle().spawn_blocking(
|
|
||||||
"overseer",
|
|
||||||
None,
|
|
||||||
Box::pin(async move {
|
|
||||||
use futures::{pin_mut, select, FutureExt};
|
|
||||||
|
|
||||||
let forward = polkadot_overseer::forward_events(overseer_client, handle);
|
|
||||||
|
|
||||||
let forward = forward.fuse();
|
|
||||||
let overseer_fut = overseer.run().fuse();
|
|
||||||
|
|
||||||
pin_mut!(overseer_fut);
|
|
||||||
pin_mut!(forward);
|
|
||||||
|
|
||||||
select! {
|
|
||||||
_ = forward => (),
|
|
||||||
_ = overseer_fut => (),
|
|
||||||
complete => (),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(handle)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
if role.is_authority() {
|
|
||||||
let can_author_with =
|
|
||||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
|
||||||
|
|
||||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
|
||||||
task_manager.spawn_handle(),
|
|
||||||
client.clone(),
|
|
||||||
transaction_pool,
|
|
||||||
prometheus_registry.as_ref(),
|
|
||||||
telemetry.as_ref().map(|x| x.handle()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let client_clone = client.clone();
|
|
||||||
let overseer_handle =
|
|
||||||
overseer_handle.as_ref().ok_or(Error::AuthoritiesRequireRealOverseer)?.clone();
|
|
||||||
let slot_duration = babe_link.config().slot_duration();
|
|
||||||
let babe_config = sc_consensus_babe::BabeParams {
|
|
||||||
keystore: keystore_container.sync_keystore(),
|
|
||||||
client: client.clone(),
|
|
||||||
select_chain,
|
|
||||||
block_import,
|
|
||||||
env: proposer,
|
|
||||||
sync_oracle: network.clone(),
|
|
||||||
justification_sync_link: network.clone(),
|
|
||||||
create_inherent_data_providers: move |parent, ()| {
|
|
||||||
let client_clone = client_clone.clone();
|
|
||||||
let overseer_handle = overseer_handle.clone();
|
|
||||||
async move {
|
|
||||||
let parachain = polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::create(
|
|
||||||
&*client_clone,
|
|
||||||
overseer_handle,
|
|
||||||
parent,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(Box::new)?;
|
|
||||||
|
|
||||||
let uncles = sc_consensus_uncles::create_uncles_inherent_data_provider(
|
|
||||||
&*client_clone,
|
|
||||||
parent,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
|
||||||
|
|
||||||
let slot = sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_duration(
|
|
||||||
*timestamp,
|
|
||||||
slot_duration,
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok((timestamp, slot, uncles, parachain))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
force_authoring,
|
|
||||||
backoff_authoring_blocks,
|
|
||||||
babe_link,
|
|
||||||
can_author_with,
|
|
||||||
block_proposal_slot_portion: sc_consensus_babe::SlotProportion::new(2f32 / 3f32),
|
|
||||||
max_block_proposal_slot_portion: None,
|
|
||||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
|
||||||
};
|
|
||||||
|
|
||||||
let babe = sc_consensus_babe::start_babe(babe_config)?;
|
|
||||||
task_manager.spawn_essential_handle().spawn_blocking("babe", None, babe);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the node isn't actively participating in consensus then it doesn't
|
|
||||||
// need a keystore, regardless of which protocol we use below.
|
|
||||||
let keystore_opt =
|
|
||||||
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
|
|
||||||
|
|
||||||
let beefy_params = beefy_gadget::BeefyParams {
|
|
||||||
client: client.clone(),
|
|
||||||
backend: backend.clone(),
|
|
||||||
key_store: keystore_opt.clone(),
|
|
||||||
network: network.clone(),
|
|
||||||
signed_commitment_sender,
|
|
||||||
min_block_delta: 2,
|
|
||||||
prometheus_registry: prometheus_registry.clone(),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Start the BEEFY bridge gadget.
|
|
||||||
task_manager.spawn_essential_handle().spawn_blocking(
|
|
||||||
"beefy-gadget",
|
|
||||||
None,
|
|
||||||
beefy_gadget::start_beefy_gadget::<_, _, _, _>(beefy_params),
|
|
||||||
);
|
|
||||||
|
|
||||||
let config = sc_finality_grandpa::Config {
|
|
||||||
// FIXME substrate#1578 make this available through chainspec
|
|
||||||
gossip_duration: Duration::from_millis(1000),
|
|
||||||
justification_period: 512,
|
|
||||||
name: Some(name),
|
|
||||||
observer_enabled: false,
|
|
||||||
keystore: keystore_opt,
|
|
||||||
local_role: role,
|
|
||||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
|
||||||
};
|
|
||||||
|
|
||||||
let enable_grandpa = !disable_grandpa;
|
|
||||||
if enable_grandpa {
|
|
||||||
// start the full GRANDPA voter
|
|
||||||
// NOTE: unlike in substrate we are currently running the full
|
|
||||||
// GRANDPA voter protocol for all full nodes (regardless of whether
|
|
||||||
// they're validators or not). at this point the full voter should
|
|
||||||
// provide better guarantees of block and vote data availability than
|
|
||||||
// the observer.
|
|
||||||
|
|
||||||
// add a custom voting rule to temporarily stop voting for new blocks
|
|
||||||
// after the given pause block is finalized and restarting after the
|
|
||||||
// given delay.
|
|
||||||
let builder = sc_finality_grandpa::VotingRulesBuilder::default();
|
|
||||||
|
|
||||||
let voting_rule = builder.build();
|
|
||||||
let grandpa_config = sc_finality_grandpa::GrandpaParams {
|
|
||||||
config,
|
|
||||||
link: link_half,
|
|
||||||
network: network.clone(),
|
|
||||||
voting_rule,
|
|
||||||
prometheus_registry,
|
|
||||||
shared_voter_state,
|
|
||||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
|
||||||
};
|
|
||||||
|
|
||||||
task_manager.spawn_essential_handle().spawn_blocking(
|
|
||||||
"grandpa-voter",
|
|
||||||
None,
|
|
||||||
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
network_starter.start_network();
|
|
||||||
|
|
||||||
Ok(NewFull { task_manager, client, overseer_handle, network, rpc_handlers, backend })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn build_full(
|
|
||||||
config: Configuration,
|
|
||||||
overseer_gen: impl OverseerGen,
|
|
||||||
) -> Result<NewFull<Arc<FullClient>>, Error> {
|
|
||||||
new_full(config, None, overseer_gen)
|
|
||||||
}
|
|
||||||
@@ -2,17 +2,17 @@
|
|||||||
name = "rialto-runtime"
|
name = "rialto-runtime"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
homepage = "https://substrate.dev"
|
homepage = "https://substrate.dev"
|
||||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||||
hex-literal = "0.3"
|
hex-literal = "0.3"
|
||||||
libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] }
|
libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] }
|
||||||
log = { version = "0.4.14", default-features = false }
|
log = { version = "0.4.14", default-features = false }
|
||||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||||
|
|
||||||
# Bridge dependencies
|
# Bridge dependencies
|
||||||
@@ -73,7 +73,9 @@ polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", bran
|
|||||||
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
|
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] }
|
||||||
libsecp256k1 = { version = "0.7", features = ["hmac"] }
|
libsecp256k1 = { version = "0.7", features = ["hmac"] }
|
||||||
|
static_assertions = "1.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ use sp_runtime::{
|
|||||||
create_runtime_str, generic, impl_opaque_keys,
|
create_runtime_str, generic, impl_opaque_keys,
|
||||||
traits::{AccountIdLookup, Block as BlockT, Keccak256, NumberFor, OpaqueKeys},
|
traits::{AccountIdLookup, Block as BlockT, Keccak256, NumberFor, OpaqueKeys},
|
||||||
transaction_validity::{TransactionSource, TransactionValidity},
|
transaction_validity::{TransactionSource, TransactionValidity},
|
||||||
ApplyExtrinsicResult, FixedPointNumber, MultiSignature, MultiSigner, Perquintill,
|
ApplyExtrinsicResult, FixedPointNumber, FixedU128, MultiSignature, MultiSigner, Perquintill,
|
||||||
};
|
};
|
||||||
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
@@ -140,6 +140,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 1,
|
impl_version: 1,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
|
state_version: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The version information used to identify this runtime when compiled natively.
|
/// The version information used to identify this runtime when compiled natively.
|
||||||
@@ -399,21 +400,7 @@ parameter_types! {
|
|||||||
/// Note that once this is hit the pallet will essentially throttle incoming requests down to one
|
/// Note that once this is hit the pallet will essentially throttle incoming requests down to one
|
||||||
/// call per block.
|
/// call per block.
|
||||||
pub const MaxRequests: u32 = 50;
|
pub const MaxRequests: u32 = 50;
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
|
||||||
parameter_types! {
|
|
||||||
/// Number of headers to keep in benchmarks.
|
|
||||||
///
|
|
||||||
/// In benchmarks we always populate with full number of `HeadersToKeep` to make sure that
|
|
||||||
/// pruning is taken into account.
|
|
||||||
///
|
|
||||||
/// Note: This is lower than regular value, to speed up benchmarking setup.
|
|
||||||
pub const HeadersToKeep: u32 = 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
|
||||||
parameter_types! {
|
|
||||||
/// Number of headers to keep.
|
/// Number of headers to keep.
|
||||||
///
|
///
|
||||||
/// Assuming the worst case of every header being finalized, we will keep headers at least for a
|
/// Assuming the worst case of every header being finalized, we will keep headers at least for a
|
||||||
@@ -426,7 +413,7 @@ impl pallet_bridge_grandpa::Config for Runtime {
|
|||||||
type BridgedChain = bp_millau::Millau;
|
type BridgedChain = bp_millau::Millau;
|
||||||
type MaxRequests = MaxRequests;
|
type MaxRequests = MaxRequests;
|
||||||
type HeadersToKeep = HeadersToKeep;
|
type HeadersToKeep = HeadersToKeep;
|
||||||
type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
|
type WeightInfo = pallet_bridge_grandpa::weights::MillauWeight<Runtime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_shift_session_manager::Config for Runtime {}
|
impl pallet_shift_session_manager::Config for Runtime {}
|
||||||
@@ -434,9 +421,9 @@ impl pallet_shift_session_manager::Config for Runtime {}
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
|
pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
|
||||||
pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce =
|
pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce =
|
||||||
bp_rialto::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE;
|
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
|
||||||
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
||||||
bp_rialto::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE;
|
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
||||||
// `IdentityFee` is used by Rialto => we may use weight directly
|
// `IdentityFee` is used by Rialto => we may use weight directly
|
||||||
pub const GetDeliveryConfirmationTransactionFee: Balance =
|
pub const GetDeliveryConfirmationTransactionFee: Balance =
|
||||||
bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _;
|
bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _;
|
||||||
@@ -449,7 +436,7 @@ pub type WithMillauMessagesInstance = ();
|
|||||||
|
|
||||||
impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
|
impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type WeightInfo = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
type WeightInfo = pallet_bridge_messages::weights::MillauWeight<Runtime>;
|
||||||
type Parameter = millau_messages::RialtoToMillauMessagesParameter;
|
type Parameter = millau_messages::RialtoToMillauMessagesParameter;
|
||||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||||
@@ -469,10 +456,9 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
|
|||||||
type MessageDeliveryAndDispatchPayment =
|
type MessageDeliveryAndDispatchPayment =
|
||||||
pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
|
pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
|
||||||
Runtime,
|
Runtime,
|
||||||
(),
|
WithMillauMessagesInstance,
|
||||||
pallet_balances::Pallet<Runtime>,
|
pallet_balances::Pallet<Runtime>,
|
||||||
GetDeliveryConfirmationTransactionFee,
|
GetDeliveryConfirmationTransactionFee,
|
||||||
RootAccountForPayments,
|
|
||||||
>;
|
>;
|
||||||
type OnMessageAccepted = ();
|
type OnMessageAccepted = ();
|
||||||
type OnDeliveryConfirmed = ();
|
type OnDeliveryConfirmed = ();
|
||||||
@@ -568,7 +554,7 @@ pub type Executive = frame_executive::Executive<
|
|||||||
Block,
|
Block,
|
||||||
frame_system::ChainContext<Runtime>,
|
frame_system::ChainContext<Runtime>,
|
||||||
Runtime,
|
Runtime,
|
||||||
AllPallets,
|
AllPalletsWithSystem,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
@@ -633,7 +619,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||||
fn validator_set() -> ValidatorSet<BeefyId> {
|
fn validator_set() -> Option<ValidatorSet<BeefyId>> {
|
||||||
Beefy::validator_set()
|
Beefy::validator_set()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -676,10 +662,6 @@ impl_runtime_apis! {
|
|||||||
let header = BridgeMillauGrandpa::best_finalized();
|
let header = BridgeMillauGrandpa::best_finalized();
|
||||||
(header.number, header.hash())
|
(header.number, header.hash())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_known_header(hash: bp_millau::Hash) -> bool {
|
|
||||||
BridgeMillauGrandpa::is_known_header(hash)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||||
@@ -752,10 +734,7 @@ impl_runtime_apis! {
|
|||||||
polkadot_runtime_parachains::runtime_api_impl::v2::validators::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v2::validators::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validator_groups() -> (
|
fn validator_groups() -> (Vec<Vec<polkadot_primitives::v2::ValidatorIndex>>, polkadot_primitives::v2::GroupRotationInfo<BlockNumber>) {
|
||||||
Vec<Vec<polkadot_primitives::v2::ValidatorIndex>>,
|
|
||||||
polkadot_primitives::v2::GroupRotationInfo<BlockNumber>,
|
|
||||||
) {
|
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v2::validator_groups::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v2::validator_groups::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,10 +742,7 @@ impl_runtime_apis! {
|
|||||||
polkadot_runtime_parachains::runtime_api_impl::v2::availability_cores::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v2::availability_cores::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn persisted_validation_data(
|
fn persisted_validation_data(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption)
|
||||||
para_id: polkadot_primitives::v2::Id,
|
|
||||||
assumption: polkadot_primitives::v2::OccupiedCoreAssumption,
|
|
||||||
)
|
|
||||||
-> Option<polkadot_primitives::v2::PersistedValidationData<Hash, BlockNumber>> {
|
-> Option<polkadot_primitives::v2::PersistedValidationData<Hash, BlockNumber>> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v2::persisted_validation_data::<Runtime>(para_id, assumption)
|
polkadot_runtime_parachains::runtime_api_impl::v2::persisted_validation_data::<Runtime>(para_id, assumption)
|
||||||
}
|
}
|
||||||
@@ -775,7 +751,10 @@ impl_runtime_apis! {
|
|||||||
para_id: polkadot_primitives::v2::Id,
|
para_id: polkadot_primitives::v2::Id,
|
||||||
expected_persisted_validation_data_hash: Hash,
|
expected_persisted_validation_data_hash: Hash,
|
||||||
) -> Option<(polkadot_primitives::v2::PersistedValidationData<Hash, BlockNumber>, polkadot_primitives::v2::ValidationCodeHash)> {
|
) -> Option<(polkadot_primitives::v2::PersistedValidationData<Hash, BlockNumber>, polkadot_primitives::v2::ValidationCodeHash)> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v2::assumed_validation_data::<Runtime>(para_id, expected_persisted_validation_data_hash)
|
polkadot_runtime_parachains::runtime_api_impl::v2::assumed_validation_data::<Runtime>(
|
||||||
|
para_id,
|
||||||
|
expected_persisted_validation_data_hash,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_validation_outputs(
|
fn check_validation_outputs(
|
||||||
@@ -789,17 +768,12 @@ impl_runtime_apis! {
|
|||||||
polkadot_runtime_parachains::runtime_api_impl::v2::session_index_for_child::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v2::session_index_for_child::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validation_code(
|
fn validation_code(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption)
|
||||||
para_id: polkadot_primitives::v2::Id,
|
|
||||||
assumption: polkadot_primitives::v2::OccupiedCoreAssumption,
|
|
||||||
)
|
|
||||||
-> Option<polkadot_primitives::v2::ValidationCode> {
|
-> Option<polkadot_primitives::v2::ValidationCode> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code::<Runtime>(para_id, assumption)
|
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code::<Runtime>(para_id, assumption)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn candidate_pending_availability(
|
fn candidate_pending_availability(para_id: polkadot_primitives::v2::Id) -> Option<polkadot_primitives::v2::CommittedCandidateReceipt<Hash>> {
|
||||||
para_id: polkadot_primitives::v2::Id,
|
|
||||||
) -> Option<polkadot_primitives::v2::CommittedCandidateReceipt<Hash>> {
|
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v2::candidate_pending_availability::<Runtime>(para_id)
|
polkadot_runtime_parachains::runtime_api_impl::v2::candidate_pending_availability::<Runtime>(para_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,9 +792,7 @@ impl_runtime_apis! {
|
|||||||
polkadot_runtime_parachains::runtime_api_impl::v2::session_info::<Runtime>(index)
|
polkadot_runtime_parachains::runtime_api_impl::v2::session_info::<Runtime>(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dmq_contents(
|
fn dmq_contents(recipient: polkadot_primitives::v2::Id) -> Vec<polkadot_primitives::v2::InboundDownwardMessage<BlockNumber>> {
|
||||||
recipient: polkadot_primitives::v2::Id,
|
|
||||||
) -> Vec<polkadot_primitives::v2::InboundDownwardMessage<BlockNumber>> {
|
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v2::dmq_contents::<Runtime>(recipient)
|
polkadot_runtime_parachains::runtime_api_impl::v2::dmq_contents::<Runtime>(recipient)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,15 +802,27 @@ impl_runtime_apis! {
|
|||||||
polkadot_runtime_parachains::runtime_api_impl::v2::inbound_hrmp_channels_contents::<Runtime>(recipient)
|
polkadot_runtime_parachains::runtime_api_impl::v2::inbound_hrmp_channels_contents::<Runtime>(recipient)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validation_code_by_hash(
|
fn validation_code_by_hash(hash: polkadot_primitives::v2::ValidationCodeHash) -> Option<polkadot_primitives::v2::ValidationCode> {
|
||||||
hash: polkadot_primitives::v2::ValidationCodeHash,
|
|
||||||
) -> Option<polkadot_primitives::v2::ValidationCode> {
|
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_by_hash::<Runtime>(hash)
|
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_by_hash::<Runtime>(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_chain_votes() -> Option<polkadot_primitives::v2::ScrapedOnChainVotes<Hash>> {
|
fn on_chain_votes() -> Option<polkadot_primitives::v2::ScrapedOnChainVotes<Hash>> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v2::on_chain_votes::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v2::on_chain_votes::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn submit_pvf_check_statement(stmt: polkadot_primitives::v2::PvfCheckStatement, signature: polkadot_primitives::v2::ValidatorSignature) {
|
||||||
|
polkadot_runtime_parachains::runtime_api_impl::v2::submit_pvf_check_statement::<Runtime>(stmt, signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pvfs_require_precheck() -> Vec<polkadot_primitives::v2::ValidationCodeHash> {
|
||||||
|
polkadot_runtime_parachains::runtime_api_impl::v2::pvfs_require_precheck::<Runtime>()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn validation_code_hash(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption)
|
||||||
|
-> Option<polkadot_primitives::v2::ValidationCodeHash>
|
||||||
|
{
|
||||||
|
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_hash::<Runtime>(para_id, assumption)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
|
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
|
||||||
@@ -910,10 +894,12 @@ impl_runtime_apis! {
|
|||||||
fn estimate_message_delivery_and_dispatch_fee(
|
fn estimate_message_delivery_and_dispatch_fee(
|
||||||
_lane_id: bp_messages::LaneId,
|
_lane_id: bp_messages::LaneId,
|
||||||
payload: ToMillauMessagePayload,
|
payload: ToMillauMessagePayload,
|
||||||
|
millau_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Option<Balance> {
|
) -> Option<Balance> {
|
||||||
estimate_message_dispatch_and_delivery_fee::<WithMillauMessageBridge>(
|
estimate_message_dispatch_and_delivery_fee::<WithMillauMessageBridge>(
|
||||||
&payload,
|
&payload,
|
||||||
WithMillauMessageBridge::RELAYER_FEE_PERCENT,
|
WithMillauMessageBridge::RELAYER_FEE_PERCENT,
|
||||||
|
millau_to_this_conversion_rate,
|
||||||
).ok()
|
).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -928,243 +914,6 @@ impl_runtime_apis! {
|
|||||||
WithMillauMessageBridge,
|
WithMillauMessageBridge,
|
||||||
>(lane, begin, end)
|
>(lane, begin, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
|
|
||||||
BridgeMillauMessages::outbound_latest_received_nonce(lane)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn latest_generated_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
|
|
||||||
BridgeMillauMessages::outbound_latest_generated_nonce(lane)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl bp_millau::FromMillauInboundLaneApi<Block> for Runtime {
|
|
||||||
fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
|
|
||||||
BridgeMillauMessages::inbound_latest_received_nonce(lane)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
|
|
||||||
BridgeMillauMessages::inbound_latest_confirmed_nonce(lane)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState {
|
|
||||||
BridgeMillauMessages::inbound_unrewarded_relayers_state(lane)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
|
||||||
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
|
||||||
fn benchmark_metadata(extra: bool) -> (
|
|
||||||
Vec<frame_benchmarking::BenchmarkList>,
|
|
||||||
Vec<frame_support::traits::StorageInfo>,
|
|
||||||
) {
|
|
||||||
use frame_benchmarking::{Benchmarking, BenchmarkList};
|
|
||||||
use frame_support::traits::StorageInfoTrait;
|
|
||||||
|
|
||||||
use pallet_bridge_messages::benchmarking::Pallet as MessagesBench;
|
|
||||||
|
|
||||||
let mut list = Vec::<BenchmarkList>::new();
|
|
||||||
list_benchmarks!(list, extra);
|
|
||||||
|
|
||||||
let storage_info = AllPalletsWithSystem::storage_info();
|
|
||||||
return (list, storage_info)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn dispatch_benchmark(
|
|
||||||
config: frame_benchmarking::BenchmarkConfig,
|
|
||||||
) -> Result<
|
|
||||||
Vec<frame_benchmarking::BenchmarkBatch>,
|
|
||||||
sp_runtime::RuntimeString,
|
|
||||||
> {
|
|
||||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
|
|
||||||
use frame_support::traits::StorageInfoTrait;
|
|
||||||
|
|
||||||
let whitelist: Vec<TrackedStorageKey> = vec![
|
|
||||||
// Block Number
|
|
||||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
|
|
||||||
// Execution Phase
|
|
||||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
|
|
||||||
// Event Count
|
|
||||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
|
|
||||||
// System Events
|
|
||||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
|
|
||||||
// Caller 0 Account
|
|
||||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da946c154ffd9992e395af90b5b13cc6f295c77033fce8a9045824a6690bbf99c6db269502f0a8d1d2a008542d5690a0749").to_vec().into(),
|
|
||||||
];
|
|
||||||
|
|
||||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
|
||||||
let params = (&config, &whitelist);
|
|
||||||
|
|
||||||
use crate::millau_messages::{ToMillauMessagePayload, WithMillauMessageBridge};
|
|
||||||
use bp_runtime::messages::DispatchFeePayment;
|
|
||||||
use bridge_runtime_common::messages;
|
|
||||||
use pallet_bridge_messages::benchmarking::{
|
|
||||||
Pallet as MessagesBench,
|
|
||||||
Config as MessagesConfig,
|
|
||||||
MessageDeliveryProofParams,
|
|
||||||
MessageParams,
|
|
||||||
MessageProofParams,
|
|
||||||
ProofSize as MessagesProofSize,
|
|
||||||
};
|
|
||||||
|
|
||||||
impl MessagesConfig<WithMillauMessagesInstance> for Runtime {
|
|
||||||
fn maximal_message_size() -> u32 {
|
|
||||||
messages::source::maximal_message_size::<WithMillauMessageBridge>()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bridged_relayer_id() -> Self::InboundRelayer {
|
|
||||||
Default::default()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee {
|
|
||||||
pallet_balances::Pallet::<Runtime>::free_balance(account)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn endow_account(account: &Self::AccountId) {
|
|
||||||
pallet_balances::Pallet::<Runtime>::make_free_balance_be(
|
|
||||||
account,
|
|
||||||
Balance::MAX / 100,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_outbound_message(
|
|
||||||
params: MessageParams<Self::AccountId>,
|
|
||||||
) -> (millau_messages::ToMillauMessagePayload, Balance) {
|
|
||||||
let message_payload = vec![0; params.size as usize];
|
|
||||||
let dispatch_origin = bp_message_dispatch::CallOrigin::SourceAccount(
|
|
||||||
params.sender_account,
|
|
||||||
);
|
|
||||||
|
|
||||||
let message = ToMillauMessagePayload {
|
|
||||||
spec_version: 0,
|
|
||||||
weight: params.size as _,
|
|
||||||
origin: dispatch_origin,
|
|
||||||
call: message_payload,
|
|
||||||
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
|
|
||||||
};
|
|
||||||
(message, pallet_bridge_messages::benchmarking::MESSAGE_FEE.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_message_proof(
|
|
||||||
params: MessageProofParams,
|
|
||||||
) -> (millau_messages::FromMillauMessagesProof, Weight) {
|
|
||||||
use crate::millau_messages::WithMillauMessageBridge;
|
|
||||||
use bp_messages::MessageKey;
|
|
||||||
use bridge_runtime_common::{
|
|
||||||
messages::MessageBridge,
|
|
||||||
messages_benchmarking::{ed25519_sign, prepare_message_proof},
|
|
||||||
};
|
|
||||||
use codec::Encode;
|
|
||||||
use frame_support::weights::GetDispatchInfo;
|
|
||||||
use pallet_bridge_messages::storage_keys;
|
|
||||||
use sp_runtime::traits::{Header, IdentifyAccount};
|
|
||||||
|
|
||||||
let remark = match params.size {
|
|
||||||
MessagesProofSize::Minimal(ref size) => vec![0u8; *size as _],
|
|
||||||
_ => vec![],
|
|
||||||
};
|
|
||||||
let call = Call::System(SystemCall::remark { remark });
|
|
||||||
let call_weight = call.get_dispatch_info().weight;
|
|
||||||
|
|
||||||
let millau_account_id: bp_millau::AccountId = Default::default();
|
|
||||||
let (rialto_raw_public, rialto_raw_signature) = ed25519_sign(
|
|
||||||
&call,
|
|
||||||
&millau_account_id,
|
|
||||||
VERSION.spec_version,
|
|
||||||
bp_runtime::MILLAU_CHAIN_ID,
|
|
||||||
bp_runtime::RIALTO_CHAIN_ID,
|
|
||||||
);
|
|
||||||
let rialto_public = MultiSigner::Ed25519(sp_core::ed25519::Public::from_raw(rialto_raw_public));
|
|
||||||
let rialto_signature = MultiSignature::Ed25519(sp_core::ed25519::Signature::from_raw(
|
|
||||||
rialto_raw_signature,
|
|
||||||
));
|
|
||||||
|
|
||||||
if params.dispatch_fee_payment == DispatchFeePayment::AtTargetChain {
|
|
||||||
Self::endow_account(&rialto_public.clone().into_account());
|
|
||||||
}
|
|
||||||
|
|
||||||
let make_millau_message_key = |message_key: MessageKey| storage_keys::message_key(
|
|
||||||
<WithMillauMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
|
||||||
&message_key.lane_id, message_key.nonce,
|
|
||||||
).0;
|
|
||||||
let make_millau_outbound_lane_data_key = |lane_id| storage_keys::outbound_lane_data_key(
|
|
||||||
<WithMillauMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
|
||||||
&lane_id,
|
|
||||||
).0;
|
|
||||||
|
|
||||||
let make_millau_header = |state_root| bp_millau::Header::new(
|
|
||||||
0,
|
|
||||||
Default::default(),
|
|
||||||
state_root,
|
|
||||||
Default::default(),
|
|
||||||
Default::default(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let dispatch_fee_payment = params.dispatch_fee_payment.clone();
|
|
||||||
prepare_message_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, (), _, _, _>(
|
|
||||||
params,
|
|
||||||
make_millau_message_key,
|
|
||||||
make_millau_outbound_lane_data_key,
|
|
||||||
make_millau_header,
|
|
||||||
call_weight,
|
|
||||||
bp_message_dispatch::MessagePayload {
|
|
||||||
spec_version: VERSION.spec_version,
|
|
||||||
weight: call_weight,
|
|
||||||
origin: bp_message_dispatch::CallOrigin::<
|
|
||||||
bp_millau::AccountId,
|
|
||||||
MultiSigner,
|
|
||||||
Signature,
|
|
||||||
>::TargetAccount(
|
|
||||||
millau_account_id,
|
|
||||||
rialto_public,
|
|
||||||
rialto_signature,
|
|
||||||
),
|
|
||||||
dispatch_fee_payment,
|
|
||||||
call: call.encode(),
|
|
||||||
}.encode(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_message_delivery_proof(
|
|
||||||
params: MessageDeliveryProofParams<Self::AccountId>,
|
|
||||||
) -> millau_messages::ToMillauMessagesDeliveryProof {
|
|
||||||
use crate::millau_messages::WithMillauMessageBridge;
|
|
||||||
use bridge_runtime_common::{messages_benchmarking::prepare_message_delivery_proof};
|
|
||||||
use sp_runtime::traits::Header;
|
|
||||||
|
|
||||||
prepare_message_delivery_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, (), _, _>(
|
|
||||||
params,
|
|
||||||
|lane_id| pallet_bridge_messages::storage_keys::inbound_lane_data_key(
|
|
||||||
<WithMillauMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
|
||||||
&lane_id,
|
|
||||||
).0,
|
|
||||||
|state_root| bp_millau::Header::new(
|
|
||||||
0,
|
|
||||||
Default::default(),
|
|
||||||
state_root,
|
|
||||||
Default::default(),
|
|
||||||
Default::default(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_message_dispatched(nonce: bp_messages::MessageNonce) -> bool {
|
|
||||||
frame_system::Pallet::<Runtime>::events()
|
|
||||||
.into_iter()
|
|
||||||
.map(|event_record| event_record.event)
|
|
||||||
.any(|event| matches!(
|
|
||||||
event,
|
|
||||||
Event::BridgeDispatch(pallet_bridge_dispatch::Event::<Runtime, _>::MessageDispatched(
|
|
||||||
_, ([0, 0, 0, 0], nonce_from_event), _,
|
|
||||||
)) if nonce_from_event == nonce
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_benchmarks!(params, batches);
|
|
||||||
|
|
||||||
Ok(batches)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1195,55 +944,22 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bridge_runtime_common::messages;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn ensure_rialto_message_lane_weights_are_correct() {
|
|
||||||
type Weights = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
|
||||||
|
|
||||||
pallet_bridge_messages::ensure_weights_are_correct::<Weights>(
|
|
||||||
bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT,
|
|
||||||
bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT,
|
|
||||||
bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT,
|
|
||||||
bp_rialto::PAY_INBOUND_DISPATCH_FEE_WEIGHT,
|
|
||||||
DbWeight::get(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let max_incoming_message_proof_size = bp_millau::EXTRA_STORAGE_PROOF_SIZE.saturating_add(
|
|
||||||
messages::target::maximal_incoming_message_size(bp_rialto::max_extrinsic_size()),
|
|
||||||
);
|
|
||||||
pallet_bridge_messages::ensure_able_to_receive_message::<Weights>(
|
|
||||||
bp_rialto::max_extrinsic_size(),
|
|
||||||
bp_rialto::max_extrinsic_weight(),
|
|
||||||
max_incoming_message_proof_size,
|
|
||||||
messages::target::maximal_incoming_message_dispatch_weight(
|
|
||||||
bp_rialto::max_extrinsic_weight(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let max_incoming_inbound_lane_data_proof_size =
|
|
||||||
bp_messages::InboundLaneData::<()>::encoded_size_hint(
|
|
||||||
bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
|
||||||
bp_millau::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE as _,
|
|
||||||
bp_millau::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE as _,
|
|
||||||
)
|
|
||||||
.unwrap_or(u32::MAX);
|
|
||||||
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights>(
|
|
||||||
bp_rialto::max_extrinsic_size(),
|
|
||||||
bp_rialto::max_extrinsic_weight(),
|
|
||||||
max_incoming_inbound_lane_data_proof_size,
|
|
||||||
bp_millau::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE,
|
|
||||||
bp_millau::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE,
|
|
||||||
DbWeight::get(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn call_size() {
|
fn call_size() {
|
||||||
const DOT_MAX_CALL_SZ: usize = 230;
|
const BRIDGES_PALLETS_MAX_CALL_SIZE: usize = 200;
|
||||||
assert!(core::mem::size_of::<pallet_bridge_grandpa::Call<Runtime>>() <= DOT_MAX_CALL_SZ);
|
assert!(
|
||||||
// FIXME: get this down to 230. https://github.com/paritytech/grandpa-bridge-gadget/issues/359
|
core::mem::size_of::<pallet_bridge_grandpa::Call<Runtime>>() <=
|
||||||
const BEEFY_MAX_CALL_SZ: usize = 232;
|
BRIDGES_PALLETS_MAX_CALL_SIZE
|
||||||
assert!(core::mem::size_of::<pallet_bridge_messages::Call<Runtime>>() <= BEEFY_MAX_CALL_SZ);
|
);
|
||||||
|
assert!(
|
||||||
|
core::mem::size_of::<pallet_bridge_messages::Call<Runtime>>() <=
|
||||||
|
BRIDGES_PALLETS_MAX_CALL_SIZE
|
||||||
|
);
|
||||||
|
// Largest inner Call is `pallet_session::Call` with a size of 224 bytes. This size is a
|
||||||
|
// result of large `SessionKeys` struct.
|
||||||
|
// Total size of Rialto runtime Call is 232.
|
||||||
|
const MAX_CALL_SIZE: usize = 232;
|
||||||
|
assert!(core::mem::size_of::<Call>() <= MAX_CALL_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
use crate::Runtime;
|
use crate::Runtime;
|
||||||
|
|
||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
source_chain::TargetHeaderChain,
|
source_chain::{SenderOrigin, TargetHeaderChain},
|
||||||
target_chain::{ProvedMessages, SourceHeaderChain},
|
target_chain::{ProvedMessages, SourceHeaderChain},
|
||||||
InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessagesParameter,
|
InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessagesParameter,
|
||||||
};
|
};
|
||||||
use bp_runtime::{ChainId, MILLAU_CHAIN_ID, RIALTO_CHAIN_ID};
|
use bp_runtime::{Chain, ChainId, MILLAU_CHAIN_ID, RIALTO_CHAIN_ID};
|
||||||
use bridge_runtime_common::messages::{self, MessageBridge, MessageTransaction};
|
use bridge_runtime_common::messages::{self, MessageBridge, MessageTransaction};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
@@ -86,16 +86,19 @@ impl MessageBridge for WithMillauMessageBridge {
|
|||||||
const RELAYER_FEE_PERCENT: u32 = 10;
|
const RELAYER_FEE_PERCENT: u32 = 10;
|
||||||
const THIS_CHAIN_ID: ChainId = RIALTO_CHAIN_ID;
|
const THIS_CHAIN_ID: ChainId = RIALTO_CHAIN_ID;
|
||||||
const BRIDGED_CHAIN_ID: ChainId = MILLAU_CHAIN_ID;
|
const BRIDGED_CHAIN_ID: ChainId = MILLAU_CHAIN_ID;
|
||||||
const BRIDGED_MESSAGES_PALLET_NAME: &'static str = bp_millau::WITH_RIALTO_MESSAGES_PALLET_NAME;
|
const BRIDGED_MESSAGES_PALLET_NAME: &'static str = bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME;
|
||||||
|
|
||||||
type ThisChain = Rialto;
|
type ThisChain = Rialto;
|
||||||
type BridgedChain = Millau;
|
type BridgedChain = Millau;
|
||||||
|
|
||||||
fn bridged_balance_to_this_balance(bridged_balance: bp_millau::Balance) -> bp_rialto::Balance {
|
fn bridged_balance_to_this_balance(
|
||||||
bp_rialto::Balance::try_from(
|
bridged_balance: bp_millau::Balance,
|
||||||
MillauToRialtoConversionRate::get().saturating_mul_int(bridged_balance),
|
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||||
)
|
) -> bp_rialto::Balance {
|
||||||
.unwrap_or(bp_rialto::Balance::MAX)
|
let conversion_rate = bridged_to_this_conversion_rate_override
|
||||||
|
.unwrap_or_else(|| MillauToRialtoConversionRate::get());
|
||||||
|
bp_rialto::Balance::try_from(conversion_rate.saturating_mul_int(bridged_balance))
|
||||||
|
.unwrap_or(bp_rialto::Balance::MAX)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,10 +116,11 @@ impl messages::ChainWithMessages for Rialto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl messages::ThisChainWithMessages for Rialto {
|
impl messages::ThisChainWithMessages for Rialto {
|
||||||
|
type Origin = crate::Origin;
|
||||||
type Call = crate::Call;
|
type Call = crate::Call;
|
||||||
|
|
||||||
fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
|
fn is_message_accepted(send_origin: &Self::Origin, lane: &LaneId) -> bool {
|
||||||
*lane == [0, 0, 0, 0] || *lane == [0, 0, 0, 1]
|
send_origin.linked_account().is_some() && (*lane == [0, 0, 0, 0] || *lane == [0, 0, 0, 1])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
||||||
@@ -170,13 +174,13 @@ impl messages::ChainWithMessages for Millau {
|
|||||||
|
|
||||||
impl messages::BridgedChainWithMessages for Millau {
|
impl messages::BridgedChainWithMessages for Millau {
|
||||||
fn maximal_extrinsic_size() -> u32 {
|
fn maximal_extrinsic_size() -> u32 {
|
||||||
bp_millau::max_extrinsic_size()
|
bp_millau::Millau::max_extrinsic_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn message_weight_limits(_message_payload: &[u8]) -> RangeInclusive<Weight> {
|
fn message_weight_limits(_message_payload: &[u8]) -> RangeInclusive<Weight> {
|
||||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||||
let upper_limit = messages::target::maximal_incoming_message_dispatch_weight(
|
let upper_limit = messages::target::maximal_incoming_message_dispatch_weight(
|
||||||
bp_millau::max_extrinsic_weight(),
|
bp_millau::Millau::max_extrinsic_weight(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// we're charging for payload bytes in `WithMillauMessageBridge::transaction_payment`
|
// we're charging for payload bytes in `WithMillauMessageBridge::transaction_payment`
|
||||||
@@ -272,6 +276,19 @@ impl SourceHeaderChain<bp_millau::Balance> for Millau {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SenderOrigin<crate::AccountId> for crate::Origin {
|
||||||
|
fn linked_account(&self) -> Option<crate::AccountId> {
|
||||||
|
match self.caller {
|
||||||
|
crate::OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) =>
|
||||||
|
Some(submitter.clone()),
|
||||||
|
crate::OriginCaller::system(frame_system::RawOrigin::Root) |
|
||||||
|
crate::OriginCaller::system(frame_system::RawOrigin::None) =>
|
||||||
|
crate::RootAccountForPayments::get(),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Rialto -> Millau message lane pallet parameters.
|
/// Rialto -> Millau message lane pallet parameters.
|
||||||
#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)]
|
#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)]
|
||||||
pub enum RialtoToMillauMessagesParameter {
|
pub enum RialtoToMillauMessagesParameter {
|
||||||
@@ -291,15 +308,23 @@ impl MessagesParameter for RialtoToMillauMessagesParameter {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{AccountId, Call, ExistentialDeposit, Runtime, SystemCall, SystemConfig, VERSION};
|
use crate::{
|
||||||
|
AccountId, Call, DbWeight, ExistentialDeposit, MillauGrandpaInstance, Runtime, SystemCall,
|
||||||
|
SystemConfig, WithMillauMessagesInstance, VERSION,
|
||||||
|
};
|
||||||
use bp_message_dispatch::CallOrigin;
|
use bp_message_dispatch::CallOrigin;
|
||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
|
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
|
||||||
MessageKey,
|
MessageKey,
|
||||||
};
|
};
|
||||||
use bp_runtime::{derive_account_id, messages::DispatchFeePayment, SourceAccount};
|
use bp_runtime::{derive_account_id, messages::DispatchFeePayment, Chain, SourceAccount};
|
||||||
use bridge_runtime_common::messages::target::{
|
use bridge_runtime_common::{
|
||||||
FromBridgedChainEncodedMessageCall, FromBridgedChainMessagePayload,
|
assert_complete_bridge_types,
|
||||||
|
integrity::{
|
||||||
|
assert_complete_bridge_constants, AssertBridgeMessagesPalletConstants,
|
||||||
|
AssertBridgePalletNames, AssertChainConstants, AssertCompleteBridgeConstants,
|
||||||
|
},
|
||||||
|
messages::target::{FromBridgedChainEncodedMessageCall, FromBridgedChainMessagePayload},
|
||||||
};
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
traits::Currency,
|
traits::Currency,
|
||||||
@@ -316,7 +341,7 @@ mod tests {
|
|||||||
SystemConfig::default().build_storage::<Runtime>().unwrap().into();
|
SystemConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||||
ext.execute_with(|| {
|
ext.execute_with(|| {
|
||||||
let bridge = MILLAU_CHAIN_ID;
|
let bridge = MILLAU_CHAIN_ID;
|
||||||
let call: Call = SystemCall::remark { remark: vec![] }.into();
|
let call: Call = SystemCall::set_heap_pages { pages: 64 }.into();
|
||||||
let dispatch_weight = call.get_dispatch_info().weight;
|
let dispatch_weight = call.get_dispatch_info().weight;
|
||||||
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
|
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
|
||||||
&dispatch_weight,
|
&dispatch_weight,
|
||||||
@@ -377,4 +402,157 @@ mod tests {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ensure_rialto_message_lane_weights_are_correct() {
|
||||||
|
type Weights = pallet_bridge_messages::weights::MillauWeight<Runtime>;
|
||||||
|
|
||||||
|
pallet_bridge_messages::ensure_weights_are_correct::<Weights>(
|
||||||
|
bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT,
|
||||||
|
bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT,
|
||||||
|
bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT,
|
||||||
|
bp_rialto::PAY_INBOUND_DISPATCH_FEE_WEIGHT,
|
||||||
|
DbWeight::get(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let max_incoming_message_proof_size = bp_millau::EXTRA_STORAGE_PROOF_SIZE.saturating_add(
|
||||||
|
messages::target::maximal_incoming_message_size(bp_rialto::Rialto::max_extrinsic_size()),
|
||||||
|
);
|
||||||
|
pallet_bridge_messages::ensure_able_to_receive_message::<Weights>(
|
||||||
|
bp_rialto::Rialto::max_extrinsic_size(),
|
||||||
|
bp_rialto::Rialto::max_extrinsic_weight(),
|
||||||
|
max_incoming_message_proof_size,
|
||||||
|
messages::target::maximal_incoming_message_dispatch_weight(
|
||||||
|
bp_rialto::Rialto::max_extrinsic_weight(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
let max_incoming_inbound_lane_data_proof_size =
|
||||||
|
bp_messages::InboundLaneData::<()>::encoded_size_hint(
|
||||||
|
bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
||||||
|
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _,
|
||||||
|
bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as _,
|
||||||
|
)
|
||||||
|
.unwrap_or(u32::MAX);
|
||||||
|
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights>(
|
||||||
|
bp_rialto::Rialto::max_extrinsic_size(),
|
||||||
|
bp_rialto::Rialto::max_extrinsic_weight(),
|
||||||
|
max_incoming_inbound_lane_data_proof_size,
|
||||||
|
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
|
||||||
|
bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
|
||||||
|
DbWeight::get(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ensure_bridge_integrity() {
|
||||||
|
assert_complete_bridge_types!(
|
||||||
|
runtime: Runtime,
|
||||||
|
with_bridged_chain_grandpa_instance: MillauGrandpaInstance,
|
||||||
|
with_bridged_chain_messages_instance: WithMillauMessagesInstance,
|
||||||
|
bridge: WithMillauMessageBridge,
|
||||||
|
this_chain: bp_rialto::Rialto,
|
||||||
|
bridged_chain: bp_millau::Millau,
|
||||||
|
this_chain_account_id_converter: bp_rialto::AccountIdConverter
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_complete_bridge_constants::<
|
||||||
|
Runtime,
|
||||||
|
MillauGrandpaInstance,
|
||||||
|
WithMillauMessagesInstance,
|
||||||
|
WithMillauMessageBridge,
|
||||||
|
bp_rialto::Rialto,
|
||||||
|
>(AssertCompleteBridgeConstants {
|
||||||
|
this_chain_constants: AssertChainConstants {
|
||||||
|
block_length: bp_rialto::BlockLength::get(),
|
||||||
|
block_weights: bp_rialto::BlockWeights::get(),
|
||||||
|
},
|
||||||
|
messages_pallet_constants: AssertBridgeMessagesPalletConstants {
|
||||||
|
max_unrewarded_relayers_in_bridged_confirmation_tx:
|
||||||
|
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
|
||||||
|
max_unconfirmed_messages_in_bridged_confirmation_tx:
|
||||||
|
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
|
||||||
|
bridged_chain_id: bp_runtime::MILLAU_CHAIN_ID,
|
||||||
|
},
|
||||||
|
pallet_names: AssertBridgePalletNames {
|
||||||
|
with_this_chain_messages_pallet_name: bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME,
|
||||||
|
with_bridged_chain_grandpa_pallet_name: bp_millau::WITH_MILLAU_GRANDPA_PALLET_NAME,
|
||||||
|
with_bridged_chain_messages_pallet_name:
|
||||||
|
bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
MillauToRialtoConversionRate::key().to_vec(),
|
||||||
|
bp_runtime::storage_parameter_key(
|
||||||
|
bp_rialto::MILLAU_TO_RIALTO_CONVERSION_RATE_PARAMETER_NAME
|
||||||
|
)
|
||||||
|
.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore]
|
||||||
|
fn no_stack_overflow_when_decoding_nested_call_during_dispatch() {
|
||||||
|
// this test is normally ignored, because it only makes sense to run it in release mode
|
||||||
|
|
||||||
|
let mut ext: sp_io::TestExternalities =
|
||||||
|
SystemConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||||
|
ext.execute_with(|| {
|
||||||
|
let bridge = MILLAU_CHAIN_ID;
|
||||||
|
|
||||||
|
let mut call: Call = SystemCall::set_heap_pages { pages: 64 }.into();
|
||||||
|
|
||||||
|
for _i in 0..3000 {
|
||||||
|
call = Call::Sudo(pallet_sudo::Call::sudo { call: Box::new(call) });
|
||||||
|
}
|
||||||
|
|
||||||
|
let dispatch_weight = 500;
|
||||||
|
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
|
||||||
|
&dispatch_weight,
|
||||||
|
);
|
||||||
|
assert!(dispatch_fee > 0);
|
||||||
|
|
||||||
|
// create relayer account with minimal balance
|
||||||
|
let relayer_account: AccountId = [1u8; 32].into();
|
||||||
|
let initial_amount = ExistentialDeposit::get();
|
||||||
|
let _ = <pallet_balances::Pallet<Runtime> as Currency<AccountId>>::deposit_creating(
|
||||||
|
&relayer_account,
|
||||||
|
initial_amount,
|
||||||
|
);
|
||||||
|
|
||||||
|
// create dispatch account with minimal balance + dispatch fee
|
||||||
|
let dispatch_account = derive_account_id::<
|
||||||
|
<Runtime as pallet_bridge_dispatch::Config>::SourceChainAccountId,
|
||||||
|
>(bridge, SourceAccount::Root);
|
||||||
|
let dispatch_account =
|
||||||
|
<Runtime as pallet_bridge_dispatch::Config>::AccountIdConverter::convert(
|
||||||
|
dispatch_account,
|
||||||
|
);
|
||||||
|
let _ = <pallet_balances::Pallet<Runtime> as Currency<AccountId>>::deposit_creating(
|
||||||
|
&dispatch_account,
|
||||||
|
initial_amount + dispatch_fee,
|
||||||
|
);
|
||||||
|
|
||||||
|
// dispatch message with intention to pay dispatch fee at the target chain
|
||||||
|
//
|
||||||
|
// this is where the stack overflow has happened before the fix has been applied
|
||||||
|
FromMillauMessageDispatch::dispatch(
|
||||||
|
&relayer_account,
|
||||||
|
DispatchMessage {
|
||||||
|
key: MessageKey { lane_id: Default::default(), nonce: 0 },
|
||||||
|
data: DispatchMessageData {
|
||||||
|
payload: Ok(FromBridgedChainMessagePayload::<WithMillauMessageBridge> {
|
||||||
|
spec_version: VERSION.spec_version,
|
||||||
|
weight: dispatch_weight,
|
||||||
|
origin: CallOrigin::SourceRoot,
|
||||||
|
dispatch_fee_payment: DispatchFeePayment::AtTargetChain,
|
||||||
|
call: FromBridgedChainEncodedMessageCall::new(call.encode()),
|
||||||
|
}),
|
||||||
|
fee: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
//! Parachains support in Rialto runtime.
|
//! Parachains support in Rialto runtime.
|
||||||
|
|
||||||
use crate::{AccountId, Balance, Balances, BlockNumber, Event, Origin, Registrar, Runtime, Slots};
|
use crate::{
|
||||||
|
AccountId, Babe, Balance, Balances, BlockNumber, Call, Event, Origin, Registrar, Runtime,
|
||||||
|
Slots, UncheckedExtrinsic,
|
||||||
|
};
|
||||||
|
|
||||||
use frame_support::{parameter_types, weights::Weight};
|
use frame_support::{parameter_types, weights::Weight};
|
||||||
use frame_system::EnsureRoot;
|
use frame_system::EnsureRoot;
|
||||||
@@ -29,6 +32,15 @@ use polkadot_runtime_parachains::{
|
|||||||
paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
|
paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
|
||||||
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
|
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::transaction_validity::TransactionPriority;
|
||||||
|
|
||||||
|
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
|
||||||
|
where
|
||||||
|
Call: From<C>,
|
||||||
|
{
|
||||||
|
type Extrinsic = UncheckedExtrinsic;
|
||||||
|
type OverarchingCall = Call;
|
||||||
|
}
|
||||||
|
|
||||||
/// Special `RewardValidators` that does nothing ;)
|
/// Special `RewardValidators` that does nothing ;)
|
||||||
pub struct RewardValidators;
|
pub struct RewardValidators;
|
||||||
@@ -49,6 +61,7 @@ impl parachains_hrmp::Config for Runtime {
|
|||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
|
type WeightInfo = parachains_hrmp::TestWeightInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl parachains_inclusion::Config for Runtime {
|
impl parachains_inclusion::Config for Runtime {
|
||||||
@@ -65,10 +78,15 @@ impl parachains_initializer::Config for Runtime {
|
|||||||
|
|
||||||
impl parachains_origin::Config for Runtime {}
|
impl parachains_origin::Config for Runtime {}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
|
||||||
|
}
|
||||||
|
|
||||||
impl parachains_paras::Config for Runtime {
|
impl parachains_paras::Config for Runtime {
|
||||||
type Origin = Origin;
|
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type WeightInfo = parachains_paras::TestWeightInfo;
|
type WeightInfo = parachains_paras::TestWeightInfo;
|
||||||
|
type UnsignedPriority = ParasUnsignedPriority;
|
||||||
|
type NextSessionRotation = Babe;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl parachains_paras_inherent::Config for Runtime {
|
impl parachains_paras_inherent::Config for Runtime {
|
||||||
@@ -90,6 +108,7 @@ impl parachains_ump::Config for Runtime {
|
|||||||
type UmpSink = ();
|
type UmpSink = ();
|
||||||
type FirstMessageFactorPercent = FirstMessageFactorPercent;
|
type FirstMessageFactorPercent = FirstMessageFactorPercent;
|
||||||
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
|
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
|
||||||
|
type WeightInfo = parachains_ump::TestWeightInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// required onboarding pallets. We're not going to use auctions or crowdloans, so they're missing
|
// required onboarding pallets. We're not going to use auctions or crowdloans, so they're missing
|
||||||
@@ -120,6 +139,7 @@ impl slots::Config for Runtime {
|
|||||||
type LeasePeriod = LeasePeriod;
|
type LeasePeriod = LeasePeriod;
|
||||||
type WeightInfo = slots::TestWeightInfo;
|
type WeightInfo = slots::TestWeightInfo;
|
||||||
type LeaseOffset = ();
|
type LeaseOffset = ();
|
||||||
|
type ForceOrigin = EnsureRoot<AccountId>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl paras_sudo_wrapper::Config for Runtime {}
|
impl paras_sudo_wrapper::Config for Runtime {}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name = "bridge-runtime-common"
|
name = "bridge-runtime-common"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
homepage = "https://substrate.dev"
|
homepage = "https://substrate.dev"
|
||||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
@@ -11,7 +11,8 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|||||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||||
ed25519-dalek = { version = "1.0", default-features = false, optional = true }
|
ed25519-dalek = { version = "1.0", default-features = false, optional = true }
|
||||||
hash-db = { version = "0.15.2", default-features = false }
|
hash-db = { version = "0.15.2", default-features = false }
|
||||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
|
static_assertions = { version = "1.1", optional = true }
|
||||||
|
|
||||||
# Bridge dependencies
|
# Bridge dependencies
|
||||||
|
|
||||||
@@ -25,12 +26,16 @@ pallet-bridge-messages = { path = "../../modules/messages", default-features = f
|
|||||||
# Substrate dependencies
|
# Substrate dependencies
|
||||||
|
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
|
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
|
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||||
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 }
|
||||||
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
|
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
@@ -40,6 +45,7 @@ std = [
|
|||||||
"bp-runtime/std",
|
"bp-runtime/std",
|
||||||
"codec/std",
|
"codec/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
|
"frame-system/std",
|
||||||
"hash-db/std",
|
"hash-db/std",
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
"pallet-bridge-dispatch/std",
|
"pallet-bridge-dispatch/std",
|
||||||
@@ -47,6 +53,7 @@ std = [
|
|||||||
"pallet-bridge-messages/std",
|
"pallet-bridge-messages/std",
|
||||||
"pallet-transaction-payment/std",
|
"pallet-transaction-payment/std",
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
|
"sp-api/std",
|
||||||
"sp-core/std",
|
"sp-core/std",
|
||||||
"sp-runtime/std",
|
"sp-runtime/std",
|
||||||
"sp-state-machine/std",
|
"sp-state-machine/std",
|
||||||
@@ -55,7 +62,12 @@ std = [
|
|||||||
]
|
]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"ed25519-dalek/u64_backend",
|
"ed25519-dalek/u64_backend",
|
||||||
|
"pallet-balances",
|
||||||
"pallet-bridge-grandpa/runtime-benchmarks",
|
"pallet-bridge-grandpa/runtime-benchmarks",
|
||||||
"pallet-bridge-messages/runtime-benchmarks",
|
"pallet-bridge-messages/runtime-benchmarks",
|
||||||
"sp-state-machine",
|
"sp-state-machine",
|
||||||
|
"sp-version",
|
||||||
|
]
|
||||||
|
integrity-test = [
|
||||||
|
"static_assertions",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -62,8 +62,11 @@ corresponding chain. There is single exception, though (it may be changed in the
|
|||||||
|
|
||||||
This trait represents this chain from bridge point of view. Let's review every method of this trait:
|
This trait represents this chain from bridge point of view. Let's review every method of this trait:
|
||||||
|
|
||||||
- `ThisChainWithMessages::is_outbound_lane_enabled`: is used to check whether given lane accepts
|
- `ThisChainWithMessages::is_message_accepted`: is used to check whether given lane accepts
|
||||||
outbound messages.
|
messages. The send-message origin is passed to the function, so you may e.g. verify that only
|
||||||
|
given pallet is able to send messages over selected lane. **IMPORTANT**: if you assume that the
|
||||||
|
message must be paid by the sender, you must ensure that the sender origin has linked the account
|
||||||
|
for paying message delivery and dispatch fee.
|
||||||
|
|
||||||
- `ThisChainWithMessages::maximal_pending_messages_at_outbound_lane`: you should return maximal
|
- `ThisChainWithMessages::maximal_pending_messages_at_outbound_lane`: you should return maximal
|
||||||
number of pending (undelivered) messages from this function. Returning small values would require
|
number of pending (undelivered) messages from this function. Returning small values would require
|
||||||
|
|||||||
@@ -0,0 +1,331 @@
|
|||||||
|
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Parity Bridges Common.
|
||||||
|
|
||||||
|
// Parity Bridges Common 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.
|
||||||
|
|
||||||
|
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Integrity tests for chain constants and pallets configuration.
|
||||||
|
//!
|
||||||
|
//! Most of the tests in this module assume that the bridge is using standard (see `crate::messages`
|
||||||
|
//! module for details) configuration.
|
||||||
|
|
||||||
|
use crate::messages::MessageBridge;
|
||||||
|
|
||||||
|
use bp_messages::MessageNonce;
|
||||||
|
use bp_runtime::{Chain, ChainId};
|
||||||
|
use codec::Encode;
|
||||||
|
use frame_support::{storage::generator::StorageValue, traits::Get};
|
||||||
|
use frame_system::limits;
|
||||||
|
|
||||||
|
/// Macro that ensures that the runtime configuration and chain primitives crate are sharing
|
||||||
|
/// the same types (index, block number, hash, hasher, account id and header).
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_chain_types(
|
||||||
|
( runtime: $r:path, this_chain: $this:path ) => {
|
||||||
|
{
|
||||||
|
// if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard
|
||||||
|
// configuration is used), or something has broke existing configuration (meaning that all bridged chains
|
||||||
|
// and relays will stop functioning)
|
||||||
|
use frame_system::Config as SystemConfig;
|
||||||
|
use static_assertions::assert_type_eq_all;
|
||||||
|
|
||||||
|
assert_type_eq_all!(<$r as SystemConfig>::Index, bp_runtime::IndexOf<$this>);
|
||||||
|
assert_type_eq_all!(<$r as SystemConfig>::BlockNumber, bp_runtime::BlockNumberOf<$this>);
|
||||||
|
assert_type_eq_all!(<$r as SystemConfig>::Hash, bp_runtime::HashOf<$this>);
|
||||||
|
assert_type_eq_all!(<$r as SystemConfig>::Hashing, bp_runtime::HasherOf<$this>);
|
||||||
|
assert_type_eq_all!(<$r as SystemConfig>::AccountId, bp_runtime::AccountIdOf<$this>);
|
||||||
|
assert_type_eq_all!(<$r as SystemConfig>::Header, bp_runtime::HeaderOf<$this>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Macro that ensures that the bridge configuration and chain primitives crates are sharing
|
||||||
|
/// the same types (hash, account id, ...).
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_bridge_types(
|
||||||
|
( bridge: $bridge:path, this_chain: $this:path, bridged_chain: $bridged:path ) => {
|
||||||
|
{
|
||||||
|
// if one of this asserts fail, then all chains, bridged with this chain and bridge relays are now broken
|
||||||
|
//
|
||||||
|
// `frame_support::weights::Weight` is used here directly, because all chains we know are using this
|
||||||
|
// primitive (may be changed in the future)
|
||||||
|
use $crate::messages::{
|
||||||
|
AccountIdOf, BalanceOf, BridgedChain, HashOf, SignatureOf, SignerOf, ThisChain, WeightOf,
|
||||||
|
};
|
||||||
|
use static_assertions::assert_type_eq_all;
|
||||||
|
|
||||||
|
assert_type_eq_all!(HashOf<ThisChain<$bridge>>, bp_runtime::HashOf<$this>);
|
||||||
|
assert_type_eq_all!(AccountIdOf<ThisChain<$bridge>>, bp_runtime::AccountIdOf<$this>);
|
||||||
|
assert_type_eq_all!(SignerOf<ThisChain<$bridge>>, bp_runtime::AccountPublicOf<$this>);
|
||||||
|
assert_type_eq_all!(SignatureOf<ThisChain<$bridge>>, bp_runtime::SignatureOf<$this>);
|
||||||
|
assert_type_eq_all!(WeightOf<ThisChain<$bridge>>, frame_support::weights::Weight);
|
||||||
|
assert_type_eq_all!(BalanceOf<ThisChain<$bridge>>, bp_runtime::BalanceOf<$this>);
|
||||||
|
|
||||||
|
assert_type_eq_all!(HashOf<BridgedChain<$bridge>>, bp_runtime::HashOf<$bridged>);
|
||||||
|
assert_type_eq_all!(AccountIdOf<BridgedChain<$bridge>>, bp_runtime::AccountIdOf<$bridged>);
|
||||||
|
assert_type_eq_all!(SignerOf<BridgedChain<$bridge>>, bp_runtime::AccountPublicOf<$bridged>);
|
||||||
|
assert_type_eq_all!(SignatureOf<BridgedChain<$bridge>>, bp_runtime::SignatureOf<$bridged>);
|
||||||
|
assert_type_eq_all!(WeightOf<BridgedChain<$bridge>>, frame_support::weights::Weight);
|
||||||
|
assert_type_eq_all!(BalanceOf<BridgedChain<$bridge>>, bp_runtime::BalanceOf<$bridged>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Macro that ensures that the bridge GRANDPA pallet is configured properly to bridge with given
|
||||||
|
/// chain.
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_bridge_grandpa_pallet_types(
|
||||||
|
( runtime: $r:path, with_bridged_chain_grandpa_instance: $i:path, bridged_chain: $bridged:path ) => {
|
||||||
|
{
|
||||||
|
// if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard
|
||||||
|
// configuration is used), or something has broke existing configuration (meaning that all bridged chains
|
||||||
|
// and relays will stop functioning)
|
||||||
|
use pallet_bridge_grandpa::Config as GrandpaConfig;
|
||||||
|
use static_assertions::assert_type_eq_all;
|
||||||
|
|
||||||
|
assert_type_eq_all!(<$r as GrandpaConfig<$i>>::BridgedChain, $bridged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Macro that ensures that the bridge messages pallet is configured properly to bridge using given
|
||||||
|
/// configuration.
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_bridge_messages_pallet_types(
|
||||||
|
(
|
||||||
|
runtime: $r:path,
|
||||||
|
with_bridged_chain_messages_instance: $i:path,
|
||||||
|
bridge: $bridge:path,
|
||||||
|
this_chain_account_id_converter: $this_converter:path
|
||||||
|
) => {
|
||||||
|
{
|
||||||
|
// if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard
|
||||||
|
// configuration is used), or something has broke existing configuration (meaning that all bridged chains
|
||||||
|
// and relays will stop functioning)
|
||||||
|
use $crate::messages::{
|
||||||
|
source::FromThisChainMessagePayload,
|
||||||
|
target::FromBridgedChainMessagePayload,
|
||||||
|
AccountIdOf, BalanceOf, BridgedChain, ThisChain, WeightOf,
|
||||||
|
};
|
||||||
|
use pallet_bridge_messages::Config as MessagesConfig;
|
||||||
|
use static_assertions::assert_type_eq_all;
|
||||||
|
|
||||||
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::OutboundPayload, FromThisChainMessagePayload<$bridge>);
|
||||||
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::OutboundMessageFee, BalanceOf<ThisChain<$bridge>>);
|
||||||
|
|
||||||
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundPayload, FromBridgedChainMessagePayload<$bridge>);
|
||||||
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundMessageFee, BalanceOf<BridgedChain<$bridge>>);
|
||||||
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundRelayer, AccountIdOf<BridgedChain<$bridge>>);
|
||||||
|
|
||||||
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::AccountIdConverter, $this_converter);
|
||||||
|
|
||||||
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::TargetHeaderChain, BridgedChain<$bridge>);
|
||||||
|
assert_type_eq_all!(<$r as MessagesConfig<$i>>::SourceHeaderChain, BridgedChain<$bridge>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Macro that combines four other macro calls - `assert_chain_types`, `assert_bridge_types`,
|
||||||
|
/// `assert_bridge_grandpa_pallet_types` and `assert_bridge_messages_pallet_types`. It may be used
|
||||||
|
/// at the chain that is implemeting complete standard messages bridge (i.e. with bridge GRANDPA and
|
||||||
|
/// messages pallets deployed).
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_complete_bridge_types(
|
||||||
|
(
|
||||||
|
runtime: $r:path,
|
||||||
|
with_bridged_chain_grandpa_instance: $gi:path,
|
||||||
|
with_bridged_chain_messages_instance: $mi:path,
|
||||||
|
bridge: $bridge:path,
|
||||||
|
this_chain: $this:path,
|
||||||
|
bridged_chain: $bridged:path,
|
||||||
|
this_chain_account_id_converter: $this_converter:path
|
||||||
|
) => {
|
||||||
|
$crate::assert_chain_types!(runtime: $r, this_chain: $this);
|
||||||
|
$crate::assert_bridge_types!(bridge: $bridge, this_chain: $this, bridged_chain: $bridged);
|
||||||
|
$crate::assert_bridge_grandpa_pallet_types!(
|
||||||
|
runtime: $r,
|
||||||
|
with_bridged_chain_grandpa_instance: $gi,
|
||||||
|
bridged_chain: $bridged
|
||||||
|
);
|
||||||
|
$crate::assert_bridge_messages_pallet_types!(
|
||||||
|
runtime: $r,
|
||||||
|
with_bridged_chain_messages_instance: $mi,
|
||||||
|
bridge: $bridge,
|
||||||
|
this_chain_account_id_converter: $this_converter
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Parameters for asserting chain-related constants.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct AssertChainConstants {
|
||||||
|
/// Block length limits of the chain.
|
||||||
|
pub block_length: limits::BlockLength,
|
||||||
|
/// Block weight limits of the chain.
|
||||||
|
pub block_weights: limits::BlockWeights,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test that our hardcoded, chain-related constants, are matching chain runtime configuration.
|
||||||
|
///
|
||||||
|
/// In particular, this test ensures that:
|
||||||
|
///
|
||||||
|
/// 1) block weight limits are matching;
|
||||||
|
/// 2) block size limits are matching.
|
||||||
|
pub fn assert_chain_constants<R, C>(params: AssertChainConstants)
|
||||||
|
where
|
||||||
|
R: frame_system::Config,
|
||||||
|
C: Chain,
|
||||||
|
{
|
||||||
|
// we don't check runtime version here, because in our case we'll be building relay from one
|
||||||
|
// repo and runtime will live in another repo, along with outdated relay version. To avoid
|
||||||
|
// unneeded commits, let's not raise an error in case of version mismatch.
|
||||||
|
|
||||||
|
// if one of following assert fails, it means that we may need to upgrade bridged chain and
|
||||||
|
// relay to use updated constants. If constants are now smaller than before, it may lead to
|
||||||
|
// undeliverable messages.
|
||||||
|
|
||||||
|
// `BlockLength` struct is not implementing `PartialEq`, so we compare encoded values here.
|
||||||
|
assert_eq!(
|
||||||
|
R::BlockLength::get().encode(),
|
||||||
|
params.block_length.encode(),
|
||||||
|
"BlockLength from runtime ({:?}) differ from hardcoded: {:?}",
|
||||||
|
R::BlockLength::get(),
|
||||||
|
params.block_length,
|
||||||
|
);
|
||||||
|
// `BlockWeights` struct is not implementing `PartialEq`, so we compare encoded values here
|
||||||
|
assert_eq!(
|
||||||
|
R::BlockWeights::get().encode(),
|
||||||
|
params.block_weights.encode(),
|
||||||
|
"BlockWeights from runtime ({:?}) differ from hardcoded: {:?}",
|
||||||
|
R::BlockWeights::get(),
|
||||||
|
params.block_weights,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test that the constants, used in GRANDPA pallet configuration are valid.
|
||||||
|
pub fn assert_bridge_grandpa_pallet_constants<R, GI>()
|
||||||
|
where
|
||||||
|
R: pallet_bridge_grandpa::Config<GI>,
|
||||||
|
GI: 'static,
|
||||||
|
{
|
||||||
|
assert!(
|
||||||
|
R::MaxRequests::get() > 0,
|
||||||
|
"MaxRequests ({}) must be larger than zero",
|
||||||
|
R::MaxRequests::get(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parameters for asserting messages pallet constants.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct AssertBridgeMessagesPalletConstants {
|
||||||
|
/// Maximal number of unrewarded relayer entries in a confirmation transaction at the bridged
|
||||||
|
/// chain.
|
||||||
|
pub max_unrewarded_relayers_in_bridged_confirmation_tx: MessageNonce,
|
||||||
|
/// Maximal number of unconfirmed messages in a confirmation transaction at the bridged chain.
|
||||||
|
pub max_unconfirmed_messages_in_bridged_confirmation_tx: MessageNonce,
|
||||||
|
/// Identifier of the bridged chain.
|
||||||
|
pub bridged_chain_id: ChainId,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test that the constants, used in messages pallet configuration are valid.
|
||||||
|
pub fn assert_bridge_messages_pallet_constants<R, MI>(params: AssertBridgeMessagesPalletConstants)
|
||||||
|
where
|
||||||
|
R: pallet_bridge_messages::Config<MI>,
|
||||||
|
MI: 'static,
|
||||||
|
{
|
||||||
|
assert!(
|
||||||
|
R::MaxMessagesToPruneAtOnce::get() > 0,
|
||||||
|
"MaxMessagesToPruneAtOnce ({}) must be larger than zero",
|
||||||
|
R::MaxMessagesToPruneAtOnce::get(),
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
R::MaxUnrewardedRelayerEntriesAtInboundLane::get() <= params.max_unrewarded_relayers_in_bridged_confirmation_tx,
|
||||||
|
"MaxUnrewardedRelayerEntriesAtInboundLane ({}) must be <= than the hardcoded value for bridged chain: {}",
|
||||||
|
R::MaxUnrewardedRelayerEntriesAtInboundLane::get(),
|
||||||
|
params.max_unrewarded_relayers_in_bridged_confirmation_tx,
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
R::MaxUnconfirmedMessagesAtInboundLane::get() <= params.max_unconfirmed_messages_in_bridged_confirmation_tx,
|
||||||
|
"MaxUnrewardedRelayerEntriesAtInboundLane ({}) must be <= than the hardcoded value for bridged chain: {}",
|
||||||
|
R::MaxUnconfirmedMessagesAtInboundLane::get(),
|
||||||
|
params.max_unconfirmed_messages_in_bridged_confirmation_tx,
|
||||||
|
);
|
||||||
|
assert_eq!(R::BridgedChainId::get(), params.bridged_chain_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parameters for asserting bridge pallet names.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct AssertBridgePalletNames<'a> {
|
||||||
|
/// Name of the messages pallet, deployed at the bridged chain and used to bridge with this
|
||||||
|
/// chain.
|
||||||
|
pub with_this_chain_messages_pallet_name: &'a str,
|
||||||
|
/// Name of the GRANDPA pallet, deployed at this chain and used to bridge with the bridged
|
||||||
|
/// chain.
|
||||||
|
pub with_bridged_chain_grandpa_pallet_name: &'a str,
|
||||||
|
/// Name of the messages pallet, deployed at this chain and used to bridge with the bridged
|
||||||
|
/// chain.
|
||||||
|
pub with_bridged_chain_messages_pallet_name: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tests that bridge pallet names used in `construct_runtime!()` macro call are matching constants
|
||||||
|
/// from chain primitives crates.
|
||||||
|
pub fn assert_bridge_pallet_names<B, R, GI, MI>(params: AssertBridgePalletNames)
|
||||||
|
where
|
||||||
|
B: MessageBridge,
|
||||||
|
R: pallet_bridge_grandpa::Config<GI> + pallet_bridge_messages::Config<MI>,
|
||||||
|
GI: 'static,
|
||||||
|
MI: 'static,
|
||||||
|
{
|
||||||
|
assert_eq!(B::BRIDGED_MESSAGES_PALLET_NAME, params.with_this_chain_messages_pallet_name);
|
||||||
|
assert_eq!(
|
||||||
|
pallet_bridge_grandpa::PalletOwner::<R, GI>::storage_value_final_key().to_vec(),
|
||||||
|
bp_runtime::storage_value_key(params.with_bridged_chain_grandpa_pallet_name, "PalletOwner",).0,
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
pallet_bridge_messages::PalletOwner::<R, MI>::storage_value_final_key().to_vec(),
|
||||||
|
bp_runtime::storage_value_key(
|
||||||
|
params.with_bridged_chain_messages_pallet_name,
|
||||||
|
"PalletOwner",
|
||||||
|
)
|
||||||
|
.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parameters for asserting complete standard messages bridge.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct AssertCompleteBridgeConstants<'a> {
|
||||||
|
/// Parameters to assert this chain constants.
|
||||||
|
pub this_chain_constants: AssertChainConstants,
|
||||||
|
/// Parameters to assert messages pallet constants.
|
||||||
|
pub messages_pallet_constants: AssertBridgeMessagesPalletConstants,
|
||||||
|
/// Parameters to assert pallet names constants.
|
||||||
|
pub pallet_names: AssertBridgePalletNames<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// All bridge-related constants tests for the complete standard messages bridge (i.e. with bridge
|
||||||
|
/// GRANDPA and messages pallets deployed).
|
||||||
|
pub fn assert_complete_bridge_constants<R, GI, MI, B, This>(params: AssertCompleteBridgeConstants)
|
||||||
|
where
|
||||||
|
R: frame_system::Config
|
||||||
|
+ pallet_bridge_grandpa::Config<GI>
|
||||||
|
+ pallet_bridge_messages::Config<MI>,
|
||||||
|
GI: 'static,
|
||||||
|
MI: 'static,
|
||||||
|
B: MessageBridge,
|
||||||
|
This: Chain,
|
||||||
|
{
|
||||||
|
assert_chain_constants::<R, This>(params.this_chain_constants);
|
||||||
|
assert_bridge_grandpa_pallet_constants::<R, GI>();
|
||||||
|
assert_bridge_messages_pallet_constants::<R, MI>(params.messages_pallet_constants);
|
||||||
|
assert_bridge_pallet_names::<B, R, GI, MI>(params.pallet_names);
|
||||||
|
}
|
||||||
@@ -21,3 +21,6 @@
|
|||||||
pub mod messages;
|
pub mod messages;
|
||||||
pub mod messages_api;
|
pub mod messages_api;
|
||||||
pub mod messages_benchmarking;
|
pub mod messages_benchmarking;
|
||||||
|
|
||||||
|
#[cfg(feature = "integrity-test")]
|
||||||
|
pub mod integrity;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
use bp_message_dispatch::MessageDispatch as _;
|
use bp_message_dispatch::MessageDispatch as _;
|
||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
source_chain::{LaneMessageVerifier, Sender},
|
source_chain::LaneMessageVerifier,
|
||||||
target_chain::{DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages},
|
target_chain::{DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages},
|
||||||
InboundLaneData, LaneId, Message, MessageData, MessageKey, MessageNonce, OutboundLaneData,
|
InboundLaneData, LaneId, Message, MessageData, MessageKey, MessageNonce, OutboundLaneData,
|
||||||
};
|
};
|
||||||
@@ -30,7 +30,7 @@ use bp_runtime::{
|
|||||||
messages::{DispatchFeePayment, MessageDispatchResult},
|
messages::{DispatchFeePayment, MessageDispatchResult},
|
||||||
ChainId, Size, StorageProofChecker,
|
ChainId, Size, StorageProofChecker,
|
||||||
};
|
};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, DecodeLimit, Encode};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
traits::{Currency, ExistenceRequirement},
|
traits::{Currency, ExistenceRequirement},
|
||||||
weights::{Weight, WeightToFeePolynomial},
|
weights::{Weight, WeightToFeePolynomial},
|
||||||
@@ -70,6 +70,7 @@ pub trait MessageBridge {
|
|||||||
/// Convert Bridged chain balance into This chain balance.
|
/// Convert Bridged chain balance into This chain balance.
|
||||||
fn bridged_balance_to_this_balance(
|
fn bridged_balance_to_this_balance(
|
||||||
bridged_balance: BalanceOf<BridgedChain<Self>>,
|
bridged_balance: BalanceOf<BridgedChain<Self>>,
|
||||||
|
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||||
) -> BalanceOf<ThisChain<Self>>;
|
) -> BalanceOf<ThisChain<Self>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +111,13 @@ pub struct MessageTransaction<Weight> {
|
|||||||
|
|
||||||
/// This chain that has `pallet-bridge-messages` and `dispatch` modules.
|
/// This chain that has `pallet-bridge-messages` and `dispatch` modules.
|
||||||
pub trait ThisChainWithMessages: ChainWithMessages {
|
pub trait ThisChainWithMessages: ChainWithMessages {
|
||||||
|
/// Call origin on the chain.
|
||||||
|
type Origin;
|
||||||
/// Call type on the chain.
|
/// Call type on the chain.
|
||||||
type Call: Encode + Decode;
|
type Call: Encode + Decode;
|
||||||
|
|
||||||
/// Are we accepting any messages to the given lane?
|
/// Do we accept message sent by given origin to given lane?
|
||||||
fn is_outbound_lane_enabled(lane: &LaneId) -> bool;
|
fn is_message_accepted(origin: &Self::Origin, lane: &LaneId) -> bool;
|
||||||
|
|
||||||
/// Maximal number of pending (not yet delivered) messages at This chain.
|
/// Maximal number of pending (not yet delivered) messages at This chain.
|
||||||
///
|
///
|
||||||
@@ -172,11 +175,13 @@ pub type SignatureOf<C> = <C as ChainWithMessages>::Signature;
|
|||||||
pub type WeightOf<C> = <C as ChainWithMessages>::Weight;
|
pub type WeightOf<C> = <C as ChainWithMessages>::Weight;
|
||||||
/// Type of balances that is used on the chain.
|
/// Type of balances that is used on the chain.
|
||||||
pub type BalanceOf<C> = <C as ChainWithMessages>::Balance;
|
pub type BalanceOf<C> = <C as ChainWithMessages>::Balance;
|
||||||
|
/// Type of origin that is used on the chain.
|
||||||
|
pub type OriginOf<C> = <C as ThisChainWithMessages>::Origin;
|
||||||
/// Type of call that is used on this chain.
|
/// Type of call that is used on this chain.
|
||||||
pub type CallOf<C> = <C as ThisChainWithMessages>::Call;
|
pub type CallOf<C> = <C as ThisChainWithMessages>::Call;
|
||||||
|
|
||||||
/// Raw storage proof type (just raw trie nodes).
|
/// Raw storage proof type (just raw trie nodes).
|
||||||
type RawStorageProof = Vec<Vec<u8>>;
|
pub type RawStorageProof = Vec<Vec<u8>>;
|
||||||
|
|
||||||
/// Compute fee of transaction at runtime where regular transaction payment pallet is being used.
|
/// Compute fee of transaction at runtime where regular transaction payment pallet is being used.
|
||||||
///
|
///
|
||||||
@@ -269,7 +274,8 @@ pub mod source {
|
|||||||
pub struct FromThisChainMessageVerifier<B>(PhantomData<B>);
|
pub struct FromThisChainMessageVerifier<B>(PhantomData<B>);
|
||||||
|
|
||||||
/// The error message returned from LaneMessageVerifier when outbound lane is disabled.
|
/// The error message returned from LaneMessageVerifier when outbound lane is disabled.
|
||||||
pub const OUTBOUND_LANE_DISABLED: &str = "The outbound message lane is disabled.";
|
pub const MESSAGE_REJECTED_BY_OUTBOUND_LANE: &str =
|
||||||
|
"The outbound message lane has rejected the message.";
|
||||||
/// The error message returned from LaneMessageVerifier when too many pending messages at the
|
/// The error message returned from LaneMessageVerifier when too many pending messages at the
|
||||||
/// lane.
|
/// lane.
|
||||||
pub const TOO_MANY_PENDING_MESSAGES: &str = "Too many pending messages at the lane.";
|
pub const TOO_MANY_PENDING_MESSAGES: &str = "Too many pending messages at the lane.";
|
||||||
@@ -280,26 +286,30 @@ pub mod source {
|
|||||||
|
|
||||||
impl<B>
|
impl<B>
|
||||||
LaneMessageVerifier<
|
LaneMessageVerifier<
|
||||||
|
OriginOf<ThisChain<B>>,
|
||||||
AccountIdOf<ThisChain<B>>,
|
AccountIdOf<ThisChain<B>>,
|
||||||
FromThisChainMessagePayload<B>,
|
FromThisChainMessagePayload<B>,
|
||||||
BalanceOf<ThisChain<B>>,
|
BalanceOf<ThisChain<B>>,
|
||||||
> for FromThisChainMessageVerifier<B>
|
> for FromThisChainMessageVerifier<B>
|
||||||
where
|
where
|
||||||
B: MessageBridge,
|
B: MessageBridge,
|
||||||
|
// matches requirements from the `frame_system::Config::Origin`
|
||||||
|
OriginOf<ThisChain<B>>: Clone
|
||||||
|
+ Into<Result<frame_system::RawOrigin<AccountIdOf<ThisChain<B>>>, OriginOf<ThisChain<B>>>>,
|
||||||
AccountIdOf<ThisChain<B>>: PartialEq + Clone,
|
AccountIdOf<ThisChain<B>>: PartialEq + Clone,
|
||||||
{
|
{
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
|
|
||||||
fn verify_message(
|
fn verify_message(
|
||||||
submitter: &Sender<AccountIdOf<ThisChain<B>>>,
|
submitter: &OriginOf<ThisChain<B>>,
|
||||||
delivery_and_dispatch_fee: &BalanceOf<ThisChain<B>>,
|
delivery_and_dispatch_fee: &BalanceOf<ThisChain<B>>,
|
||||||
lane: &LaneId,
|
lane: &LaneId,
|
||||||
lane_outbound_data: &OutboundLaneData,
|
lane_outbound_data: &OutboundLaneData,
|
||||||
payload: &FromThisChainMessagePayload<B>,
|
payload: &FromThisChainMessagePayload<B>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
// reject message if lane is blocked
|
// reject message if lane is blocked
|
||||||
if !ThisChain::<B>::is_outbound_lane_enabled(lane) {
|
if !ThisChain::<B>::is_message_accepted(submitter, lane) {
|
||||||
return Err(OUTBOUND_LANE_DISABLED)
|
return Err(MESSAGE_REJECTED_BY_OUTBOUND_LANE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// reject message if there are too many pending messages at this lane
|
// reject message if there are too many pending messages at this lane
|
||||||
@@ -313,11 +323,29 @@ pub mod source {
|
|||||||
|
|
||||||
// Do the dispatch-specific check. We assume that the target chain uses
|
// Do the dispatch-specific check. We assume that the target chain uses
|
||||||
// `Dispatch`, so we verify the message accordingly.
|
// `Dispatch`, so we verify the message accordingly.
|
||||||
pallet_bridge_dispatch::verify_message_origin(submitter, payload)
|
let raw_origin_or_err: Result<
|
||||||
.map_err(|_| BAD_ORIGIN)?;
|
frame_system::RawOrigin<AccountIdOf<ThisChain<B>>>,
|
||||||
|
OriginOf<ThisChain<B>>,
|
||||||
|
> = submitter.clone().into();
|
||||||
|
match raw_origin_or_err {
|
||||||
|
Ok(raw_origin) =>
|
||||||
|
pallet_bridge_dispatch::verify_message_origin(&raw_origin, payload)
|
||||||
|
.map(drop)
|
||||||
|
.map_err(|_| BAD_ORIGIN)?,
|
||||||
|
Err(_) => {
|
||||||
|
// so what it means that we've failed to convert origin to the
|
||||||
|
// `frame_system::RawOrigin`? now it means that the custom pallet origin has
|
||||||
|
// been used to send the message. Do we need to verify it? The answer is no,
|
||||||
|
// because pallet may craft any origin (e.g. root) && we can't verify whether it
|
||||||
|
// is valid, or not.
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
let minimal_fee_in_this_tokens =
|
let minimal_fee_in_this_tokens = estimate_message_dispatch_and_delivery_fee::<B>(
|
||||||
estimate_message_dispatch_and_delivery_fee::<B>(payload, B::RELAYER_FEE_PERCENT)?;
|
payload,
|
||||||
|
B::RELAYER_FEE_PERCENT,
|
||||||
|
None,
|
||||||
|
)?;
|
||||||
|
|
||||||
// compare with actual fee paid
|
// compare with actual fee paid
|
||||||
if *delivery_and_dispatch_fee < minimal_fee_in_this_tokens {
|
if *delivery_and_dispatch_fee < minimal_fee_in_this_tokens {
|
||||||
@@ -371,6 +399,7 @@ pub mod source {
|
|||||||
pub fn estimate_message_dispatch_and_delivery_fee<B: MessageBridge>(
|
pub fn estimate_message_dispatch_and_delivery_fee<B: MessageBridge>(
|
||||||
payload: &FromThisChainMessagePayload<B>,
|
payload: &FromThisChainMessagePayload<B>,
|
||||||
relayer_fee_percent: u32,
|
relayer_fee_percent: u32,
|
||||||
|
bridged_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Result<BalanceOf<ThisChain<B>>, &'static str> {
|
) -> Result<BalanceOf<ThisChain<B>>, &'static str> {
|
||||||
// the fee (in Bridged tokens) of all transactions that are made on the Bridged chain
|
// the fee (in Bridged tokens) of all transactions that are made on the Bridged chain
|
||||||
//
|
//
|
||||||
@@ -391,8 +420,11 @@ pub mod source {
|
|||||||
ThisChain::<B>::transaction_payment(confirmation_transaction);
|
ThisChain::<B>::transaction_payment(confirmation_transaction);
|
||||||
|
|
||||||
// minimal fee (in This tokens) is a sum of all required fees
|
// minimal fee (in This tokens) is a sum of all required fees
|
||||||
let minimal_fee = B::bridged_balance_to_this_balance(delivery_transaction_fee)
|
let minimal_fee = B::bridged_balance_to_this_balance(
|
||||||
.checked_add(&confirmation_transaction_fee);
|
delivery_transaction_fee,
|
||||||
|
bridged_to_this_conversion_rate,
|
||||||
|
)
|
||||||
|
.checked_add(&confirmation_transaction_fee);
|
||||||
|
|
||||||
// before returning, add extra fee that is paid to the relayer (relayer interest)
|
// before returning, add extra fee that is paid to the relayer (relayer interest)
|
||||||
minimal_fee
|
minimal_fee
|
||||||
@@ -428,7 +460,7 @@ pub mod source {
|
|||||||
// Messages delivery proof is just proof of single storage key read => any error
|
// Messages delivery proof is just proof of single storage key read => any error
|
||||||
// is fatal.
|
// is fatal.
|
||||||
let storage_inbound_lane_data_key =
|
let storage_inbound_lane_data_key =
|
||||||
pallet_bridge_messages::storage_keys::inbound_lane_data_key(B::BRIDGED_MESSAGES_PALLET_NAME, &lane);
|
bp_messages::storage_keys::inbound_lane_data_key(B::BRIDGED_MESSAGES_PALLET_NAME, &lane);
|
||||||
let raw_inbound_lane_data = storage
|
let raw_inbound_lane_data = storage
|
||||||
.read_value(storage_inbound_lane_data_key.0.as_ref())
|
.read_value(storage_inbound_lane_data_key.0.as_ref())
|
||||||
.map_err(|_| "Failed to read inbound lane state from storage proof")?
|
.map_err(|_| "Failed to read inbound lane state from storage proof")?
|
||||||
@@ -513,7 +545,11 @@ pub mod target {
|
|||||||
for Result<DecodedCall, ()>
|
for Result<DecodedCall, ()>
|
||||||
{
|
{
|
||||||
fn from(encoded_call: FromBridgedChainEncodedMessageCall<DecodedCall>) -> Self {
|
fn from(encoded_call: FromBridgedChainEncodedMessageCall<DecodedCall>) -> Self {
|
||||||
DecodedCall::decode(&mut &encoded_call.encoded_call[..]).map_err(drop)
|
DecodedCall::decode_with_depth_limit(
|
||||||
|
sp_api::MAX_EXTRINSIC_DEPTH,
|
||||||
|
&mut &encoded_call.encoded_call[..],
|
||||||
|
)
|
||||||
|
.map_err(drop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,16 +710,15 @@ pub mod target {
|
|||||||
B: MessageBridge,
|
B: MessageBridge,
|
||||||
{
|
{
|
||||||
fn read_raw_outbound_lane_data(&self, lane_id: &LaneId) -> Option<Vec<u8>> {
|
fn read_raw_outbound_lane_data(&self, lane_id: &LaneId) -> Option<Vec<u8>> {
|
||||||
let storage_outbound_lane_data_key =
|
let storage_outbound_lane_data_key = bp_messages::storage_keys::outbound_lane_data_key(
|
||||||
pallet_bridge_messages::storage_keys::outbound_lane_data_key(
|
B::BRIDGED_MESSAGES_PALLET_NAME,
|
||||||
B::BRIDGED_MESSAGES_PALLET_NAME,
|
lane_id,
|
||||||
lane_id,
|
);
|
||||||
);
|
|
||||||
self.storage.read_value(storage_outbound_lane_data_key.0.as_ref()).ok()?
|
self.storage.read_value(storage_outbound_lane_data_key.0.as_ref()).ok()?
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_raw_message(&self, message_key: &MessageKey) -> Option<Vec<u8>> {
|
fn read_raw_message(&self, message_key: &MessageKey) -> Option<Vec<u8>> {
|
||||||
let storage_message_key = pallet_bridge_messages::storage_keys::message_key(
|
let storage_message_key = bp_messages::storage_keys::message_key(
|
||||||
B::BRIDGED_MESSAGES_PALLET_NAME,
|
B::BRIDGED_MESSAGES_PALLET_NAME,
|
||||||
&message_key.lane_id,
|
&message_key.lane_id,
|
||||||
message_key.nonce,
|
message_key.nonce,
|
||||||
@@ -799,8 +834,12 @@ mod tests {
|
|||||||
|
|
||||||
fn bridged_balance_to_this_balance(
|
fn bridged_balance_to_this_balance(
|
||||||
bridged_balance: BridgedChainBalance,
|
bridged_balance: BridgedChainBalance,
|
||||||
|
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||||
) -> ThisChainBalance {
|
) -> ThisChainBalance {
|
||||||
ThisChainBalance(bridged_balance.0 * BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE as u32)
|
let conversion_rate = bridged_to_this_conversion_rate_override
|
||||||
|
.map(|r| r.to_float() as u32)
|
||||||
|
.unwrap_or(BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE);
|
||||||
|
ThisChainBalance(bridged_balance.0 * conversion_rate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,7 +857,10 @@ mod tests {
|
|||||||
type ThisChain = BridgedChain;
|
type ThisChain = BridgedChain;
|
||||||
type BridgedChain = ThisChain;
|
type BridgedChain = ThisChain;
|
||||||
|
|
||||||
fn bridged_balance_to_this_balance(_this_balance: ThisChainBalance) -> BridgedChainBalance {
|
fn bridged_balance_to_this_balance(
|
||||||
|
_this_balance: ThisChainBalance,
|
||||||
|
_bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||||
|
) -> BridgedChainBalance {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -836,6 +878,18 @@ mod tests {
|
|||||||
#[codec(index = 84)]
|
#[codec(index = 84)]
|
||||||
Mint,
|
Mint,
|
||||||
}
|
}
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
struct ThisChainOrigin(Result<frame_system::RawOrigin<ThisChainAccountId>, ()>);
|
||||||
|
|
||||||
|
impl From<ThisChainOrigin>
|
||||||
|
for Result<frame_system::RawOrigin<ThisChainAccountId>, ThisChainOrigin>
|
||||||
|
{
|
||||||
|
fn from(
|
||||||
|
origin: ThisChainOrigin,
|
||||||
|
) -> Result<frame_system::RawOrigin<ThisChainAccountId>, ThisChainOrigin> {
|
||||||
|
origin.clone().0.map_err(|_| origin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Decode, Encode)]
|
#[derive(Debug, PartialEq, Decode, Encode)]
|
||||||
struct BridgedChainAccountId(u32);
|
struct BridgedChainAccountId(u32);
|
||||||
@@ -845,6 +899,18 @@ mod tests {
|
|||||||
struct BridgedChainSignature(u32);
|
struct BridgedChainSignature(u32);
|
||||||
#[derive(Debug, PartialEq, Decode, Encode)]
|
#[derive(Debug, PartialEq, Decode, Encode)]
|
||||||
enum BridgedChainCall {}
|
enum BridgedChainCall {}
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
struct BridgedChainOrigin;
|
||||||
|
|
||||||
|
impl From<BridgedChainOrigin>
|
||||||
|
for Result<frame_system::RawOrigin<BridgedChainAccountId>, BridgedChainOrigin>
|
||||||
|
{
|
||||||
|
fn from(
|
||||||
|
_origin: BridgedChainOrigin,
|
||||||
|
) -> Result<frame_system::RawOrigin<BridgedChainAccountId>, BridgedChainOrigin> {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! impl_wrapped_balance {
|
macro_rules! impl_wrapped_balance {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
@@ -922,9 +988,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ThisChainWithMessages for ThisChain {
|
impl ThisChainWithMessages for ThisChain {
|
||||||
|
type Origin = ThisChainOrigin;
|
||||||
type Call = ThisChainCall;
|
type Call = ThisChainCall;
|
||||||
|
|
||||||
fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
|
fn is_message_accepted(_send_origin: &Self::Origin, lane: &LaneId) -> bool {
|
||||||
lane == TEST_LANE_ID
|
lane == TEST_LANE_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -982,9 +1049,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ThisChainWithMessages for BridgedChain {
|
impl ThisChainWithMessages for BridgedChain {
|
||||||
|
type Origin = BridgedChainOrigin;
|
||||||
type Call = BridgedChainCall;
|
type Call = BridgedChainCall;
|
||||||
|
|
||||||
fn is_outbound_lane_enabled(_lane: &LaneId) -> bool {
|
fn is_message_accepted(_send_origin: &Self::Origin, _lane: &LaneId) -> bool {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1096,6 +1164,7 @@ mod tests {
|
|||||||
source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
||||||
&payload,
|
&payload,
|
||||||
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
||||||
|
None,
|
||||||
),
|
),
|
||||||
Ok(ThisChainBalance(EXPECTED_MINIMAL_FEE)),
|
Ok(ThisChainBalance(EXPECTED_MINIMAL_FEE)),
|
||||||
);
|
);
|
||||||
@@ -1107,6 +1176,7 @@ mod tests {
|
|||||||
source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
||||||
&payload_with_pay_on_target,
|
&payload_with_pay_on_target,
|
||||||
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
.expect(
|
.expect(
|
||||||
"estimate_message_dispatch_and_delivery_fee failed for pay-at-target-chain message",
|
"estimate_message_dispatch_and_delivery_fee failed for pay-at-target-chain message",
|
||||||
@@ -1121,7 +1191,7 @@ mod tests {
|
|||||||
// and now check that the verifier checks the fee
|
// and now check that the verifier checks the fee
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::Root,
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::Root)),
|
||||||
&ThisChainBalance(1),
|
&ThisChainBalance(1),
|
||||||
TEST_LANE_ID,
|
TEST_LANE_ID,
|
||||||
&test_lane_outbound_data(),
|
&test_lane_outbound_data(),
|
||||||
@@ -1130,7 +1200,7 @@ mod tests {
|
|||||||
Err(source::TOO_LOW_FEE)
|
Err(source::TOO_LOW_FEE)
|
||||||
);
|
);
|
||||||
assert!(source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
assert!(source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::Root,
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::Root)),
|
||||||
&ThisChainBalance(1_000_000),
|
&ThisChainBalance(1_000_000),
|
||||||
TEST_LANE_ID,
|
TEST_LANE_ID,
|
||||||
&test_lane_outbound_data(),
|
&test_lane_outbound_data(),
|
||||||
@@ -1153,7 +1223,7 @@ mod tests {
|
|||||||
// and now check that the verifier checks the fee
|
// and now check that the verifier checks the fee
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::Signed(ThisChainAccountId(0)),
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::Signed(ThisChainAccountId(0)))),
|
||||||
&ThisChainBalance(1_000_000),
|
&ThisChainBalance(1_000_000),
|
||||||
TEST_LANE_ID,
|
TEST_LANE_ID,
|
||||||
&test_lane_outbound_data(),
|
&test_lane_outbound_data(),
|
||||||
@@ -1163,7 +1233,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::None,
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::None)),
|
||||||
&ThisChainBalance(1_000_000),
|
&ThisChainBalance(1_000_000),
|
||||||
TEST_LANE_ID,
|
TEST_LANE_ID,
|
||||||
&test_lane_outbound_data(),
|
&test_lane_outbound_data(),
|
||||||
@@ -1172,7 +1242,7 @@ mod tests {
|
|||||||
Err(source::BAD_ORIGIN)
|
Err(source::BAD_ORIGIN)
|
||||||
);
|
);
|
||||||
assert!(source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
assert!(source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::Root,
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::Root)),
|
||||||
&ThisChainBalance(1_000_000),
|
&ThisChainBalance(1_000_000),
|
||||||
TEST_LANE_ID,
|
TEST_LANE_ID,
|
||||||
&test_lane_outbound_data(),
|
&test_lane_outbound_data(),
|
||||||
@@ -1195,7 +1265,7 @@ mod tests {
|
|||||||
// and now check that the verifier checks the fee
|
// and now check that the verifier checks the fee
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::Signed(ThisChainAccountId(0)),
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::Signed(ThisChainAccountId(0)))),
|
||||||
&ThisChainBalance(1_000_000),
|
&ThisChainBalance(1_000_000),
|
||||||
TEST_LANE_ID,
|
TEST_LANE_ID,
|
||||||
&test_lane_outbound_data(),
|
&test_lane_outbound_data(),
|
||||||
@@ -1204,7 +1274,7 @@ mod tests {
|
|||||||
Err(source::BAD_ORIGIN)
|
Err(source::BAD_ORIGIN)
|
||||||
);
|
);
|
||||||
assert!(source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
assert!(source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::Signed(ThisChainAccountId(1)),
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::Signed(ThisChainAccountId(1)))),
|
||||||
&ThisChainBalance(1_000_000),
|
&ThisChainBalance(1_000_000),
|
||||||
TEST_LANE_ID,
|
TEST_LANE_ID,
|
||||||
&test_lane_outbound_data(),
|
&test_lane_outbound_data(),
|
||||||
@@ -1217,13 +1287,13 @@ mod tests {
|
|||||||
fn message_is_rejected_when_sent_using_disabled_lane() {
|
fn message_is_rejected_when_sent_using_disabled_lane() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::Root,
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::Root)),
|
||||||
&ThisChainBalance(1_000_000),
|
&ThisChainBalance(1_000_000),
|
||||||
b"dsbl",
|
b"dsbl",
|
||||||
&test_lane_outbound_data(),
|
&test_lane_outbound_data(),
|
||||||
®ular_outbound_message_payload(),
|
®ular_outbound_message_payload(),
|
||||||
),
|
),
|
||||||
Err(source::OUTBOUND_LANE_DISABLED)
|
Err(source::MESSAGE_REJECTED_BY_OUTBOUND_LANE)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1231,7 +1301,7 @@ mod tests {
|
|||||||
fn message_is_rejected_when_there_are_too_many_pending_messages_at_outbound_lane() {
|
fn message_is_rejected_when_there_are_too_many_pending_messages_at_outbound_lane() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
source::FromThisChainMessageVerifier::<OnThisChainBridge>::verify_message(
|
||||||
&Sender::Root,
|
&ThisChainOrigin(Ok(frame_system::RawOrigin::Root)),
|
||||||
&ThisChainBalance(1_000_000),
|
&ThisChainBalance(1_000_000),
|
||||||
TEST_LANE_ID,
|
TEST_LANE_ID,
|
||||||
&OutboundLaneData {
|
&OutboundLaneData {
|
||||||
@@ -1573,4 +1643,21 @@ mod tests {
|
|||||||
100 + 50 * 10 + 777,
|
100 + 50 * 10 + 777,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn conversion_rate_override_works() {
|
||||||
|
let payload = regular_outbound_message_payload();
|
||||||
|
let regular_fee = source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
||||||
|
&payload,
|
||||||
|
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
let overrided_fee = source::estimate_message_dispatch_and_delivery_fee::<OnThisChainBridge>(
|
||||||
|
&payload,
|
||||||
|
OnThisChainBridge::RELAYER_FEE_PERCENT,
|
||||||
|
Some(FixedU128::from_float((BRIDGED_CHAIN_TO_THIS_CHAIN_BALANCE_RATE * 2) as f64)),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(regular_fee < overrided_fee);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,40 +20,310 @@
|
|||||||
#![cfg(feature = "runtime-benchmarks")]
|
#![cfg(feature = "runtime-benchmarks")]
|
||||||
|
|
||||||
use crate::messages::{
|
use crate::messages::{
|
||||||
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
|
source::{FromBridgedChainMessagesDeliveryProof, FromThisChainMessagePayload},
|
||||||
AccountIdOf, BalanceOf, BridgedChain, HashOf, MessageBridge, ThisChain,
|
target::FromBridgedChainMessagesProof,
|
||||||
|
AccountIdOf, BalanceOf, BridgedChain, CallOf, HashOf, MessageBridge, RawStorageProof,
|
||||||
|
SignatureOf, SignerOf, ThisChain,
|
||||||
};
|
};
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageData, MessageKey, MessagePayload};
|
use bp_messages::{storage_keys, MessageData, MessageKey, MessagePayload};
|
||||||
use bp_runtime::ChainId;
|
use bp_runtime::{messages::DispatchFeePayment, ChainId};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use ed25519_dalek::{PublicKey, SecretKey, Signer, KEYPAIR_LENGTH, SECRET_KEY_LENGTH};
|
use ed25519_dalek::{PublicKey, SecretKey, Signer, KEYPAIR_LENGTH, SECRET_KEY_LENGTH};
|
||||||
use frame_support::weights::Weight;
|
use frame_support::{
|
||||||
|
traits::Currency,
|
||||||
|
weights::{GetDispatchInfo, Weight},
|
||||||
|
};
|
||||||
use pallet_bridge_messages::benchmarking::{
|
use pallet_bridge_messages::benchmarking::{
|
||||||
MessageDeliveryProofParams, MessageProofParams, ProofSize,
|
MessageDeliveryProofParams, MessageParams, MessageProofParams, ProofSize,
|
||||||
};
|
};
|
||||||
use sp_core::Hasher;
|
use sp_core::Hasher;
|
||||||
use sp_runtime::traits::Header;
|
use sp_runtime::traits::{Header, IdentifyAccount, MaybeSerializeDeserialize, Zero};
|
||||||
use sp_std::prelude::*;
|
use sp_std::{fmt::Debug, prelude::*};
|
||||||
use sp_trie::{record_all_keys, trie_types::TrieDBMutV1, LayoutV1, MemoryDB, Recorder, TrieMut};
|
use sp_trie::{record_all_keys, trie_types::TrieDBMutV1, LayoutV1, MemoryDB, Recorder, TrieMut};
|
||||||
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
|
/// Return this chain account, used to dispatch message.
|
||||||
|
pub fn dispatch_account<B>() -> AccountIdOf<ThisChain<B>>
|
||||||
|
where
|
||||||
|
B: MessageBridge,
|
||||||
|
SignerOf<ThisChain<B>>:
|
||||||
|
From<sp_core::ed25519::Public> + IdentifyAccount<AccountId = AccountIdOf<ThisChain<B>>>,
|
||||||
|
{
|
||||||
|
let this_raw_public = PublicKey::from(&dispatch_account_secret());
|
||||||
|
let this_public: SignerOf<ThisChain<B>> =
|
||||||
|
sp_core::ed25519::Public::from_raw(this_raw_public.to_bytes()).into();
|
||||||
|
this_public.into_account()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return public key of this chain account, used to dispatch message.
|
||||||
|
pub fn dispatch_account_secret() -> SecretKey {
|
||||||
|
// key from the repo example (https://docs.rs/ed25519-dalek/1.0.1/ed25519_dalek/struct.SecretKey.html)
|
||||||
|
SecretKey::from_bytes(&[
|
||||||
|
157, 097, 177, 157, 239, 253, 090, 096, 186, 132, 074, 244, 146, 236, 044, 196, 068, 073,
|
||||||
|
197, 105, 123, 050, 105, 025, 112, 059, 172, 003, 028, 174, 127, 096,
|
||||||
|
])
|
||||||
|
.expect("harcoded key is valid")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Prepare outbound message for the `send_message` call.
|
||||||
|
pub fn prepare_outbound_message<B>(
|
||||||
|
params: MessageParams<AccountIdOf<ThisChain<B>>>,
|
||||||
|
) -> FromThisChainMessagePayload<B>
|
||||||
|
where
|
||||||
|
B: MessageBridge,
|
||||||
|
BalanceOf<ThisChain<B>>: From<u64>,
|
||||||
|
{
|
||||||
|
let message_payload = vec![0; params.size as usize];
|
||||||
|
let dispatch_origin = bp_message_dispatch::CallOrigin::SourceAccount(params.sender_account);
|
||||||
|
|
||||||
|
FromThisChainMessagePayload::<B> {
|
||||||
|
spec_version: 0,
|
||||||
|
weight: params.size as _,
|
||||||
|
origin: dispatch_origin,
|
||||||
|
call: message_payload,
|
||||||
|
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Prepare proof of messages for the `receive_messages_proof` call.
|
||||||
|
///
|
||||||
|
/// In addition to returning valid messages proof, environment is prepared to verify this message
|
||||||
|
/// proof.
|
||||||
|
pub fn prepare_message_proof<R, BI, FI, B, BH, BHH>(
|
||||||
|
params: MessageProofParams,
|
||||||
|
version: &RuntimeVersion,
|
||||||
|
endow_amount: BalanceOf<ThisChain<B>>,
|
||||||
|
) -> (FromBridgedChainMessagesProof<HashOf<BridgedChain<B>>>, Weight)
|
||||||
|
where
|
||||||
|
R: frame_system::Config<AccountId = AccountIdOf<ThisChain<B>>>
|
||||||
|
+ pallet_balances::Config<BI, Balance = BalanceOf<ThisChain<B>>>
|
||||||
|
+ pallet_bridge_grandpa::Config<FI>,
|
||||||
|
R::BridgedChain: bp_runtime::Chain<Header = BH>,
|
||||||
|
B: MessageBridge,
|
||||||
|
BI: 'static,
|
||||||
|
FI: 'static,
|
||||||
|
BH: Header<Hash = HashOf<BridgedChain<B>>>,
|
||||||
|
BHH: Hasher<Out = HashOf<BridgedChain<B>>>,
|
||||||
|
AccountIdOf<ThisChain<B>>: PartialEq + sp_std::fmt::Debug,
|
||||||
|
AccountIdOf<BridgedChain<B>>: From<[u8; 32]>,
|
||||||
|
BalanceOf<ThisChain<B>>: Debug + MaybeSerializeDeserialize,
|
||||||
|
CallOf<ThisChain<B>>: From<frame_system::Call<R>> + GetDispatchInfo,
|
||||||
|
HashOf<BridgedChain<B>>: Copy + Default,
|
||||||
|
SignatureOf<ThisChain<B>>: From<sp_core::ed25519::Signature>,
|
||||||
|
SignerOf<ThisChain<B>>: Clone
|
||||||
|
+ From<sp_core::ed25519::Public>
|
||||||
|
+ IdentifyAccount<AccountId = AccountIdOf<ThisChain<B>>>,
|
||||||
|
{
|
||||||
|
// we'll be dispatching the same call at This chain
|
||||||
|
let remark = match params.size {
|
||||||
|
ProofSize::Minimal(ref size) => vec![0u8; *size as _],
|
||||||
|
_ => vec![],
|
||||||
|
};
|
||||||
|
let call: CallOf<ThisChain<B>> = frame_system::Call::remark { remark }.into();
|
||||||
|
let call_weight = call.get_dispatch_info().weight;
|
||||||
|
|
||||||
|
// message payload needs to be signed, because we use `TargetAccount` call origin
|
||||||
|
// (which is 'heaviest' to verify)
|
||||||
|
let bridged_account_id: AccountIdOf<BridgedChain<B>> = [0u8; 32].into();
|
||||||
|
let (this_raw_public, this_raw_signature) = ed25519_sign(
|
||||||
|
&call,
|
||||||
|
&bridged_account_id,
|
||||||
|
version.spec_version,
|
||||||
|
B::BRIDGED_CHAIN_ID,
|
||||||
|
B::THIS_CHAIN_ID,
|
||||||
|
);
|
||||||
|
let this_public: SignerOf<ThisChain<B>> =
|
||||||
|
sp_core::ed25519::Public::from_raw(this_raw_public).into();
|
||||||
|
let this_signature: SignatureOf<ThisChain<B>> =
|
||||||
|
sp_core::ed25519::Signature::from_raw(this_raw_signature).into();
|
||||||
|
|
||||||
|
// if dispatch fee is paid at this chain, endow relayer account
|
||||||
|
if params.dispatch_fee_payment == DispatchFeePayment::AtTargetChain {
|
||||||
|
assert_eq!(this_public.clone().into_account(), dispatch_account::<B>());
|
||||||
|
pallet_balances::Pallet::<R, BI>::make_free_balance_be(
|
||||||
|
&this_public.clone().into_account(),
|
||||||
|
endow_amount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare message payload that is stored in the Bridged chain storage
|
||||||
|
let message_payload = bp_message_dispatch::MessagePayload {
|
||||||
|
spec_version: version.spec_version,
|
||||||
|
weight: call_weight,
|
||||||
|
origin: bp_message_dispatch::CallOrigin::<
|
||||||
|
AccountIdOf<BridgedChain<B>>,
|
||||||
|
SignerOf<ThisChain<B>>,
|
||||||
|
SignatureOf<ThisChain<B>>,
|
||||||
|
>::TargetAccount(bridged_account_id, this_public, this_signature),
|
||||||
|
dispatch_fee_payment: params.dispatch_fee_payment.clone(),
|
||||||
|
call: call.encode(),
|
||||||
|
}
|
||||||
|
.encode();
|
||||||
|
|
||||||
|
// finally - prepare storage proof and update environment
|
||||||
|
let (state_root, storage_proof) =
|
||||||
|
prepare_messages_storage_proof::<B, BHH>(¶ms, message_payload);
|
||||||
|
let bridged_header_hash = insert_bridged_chain_header::<R, FI, B, BH>(state_root);
|
||||||
|
|
||||||
|
(
|
||||||
|
FromBridgedChainMessagesProof {
|
||||||
|
bridged_header_hash,
|
||||||
|
storage_proof,
|
||||||
|
lane: params.lane,
|
||||||
|
nonces_start: *params.message_nonces.start(),
|
||||||
|
nonces_end: *params.message_nonces.end(),
|
||||||
|
},
|
||||||
|
call_weight
|
||||||
|
.checked_mul(
|
||||||
|
params.message_nonces.end().saturating_sub(*params.message_nonces.start()) + 1,
|
||||||
|
)
|
||||||
|
.expect("too many messages requested by benchmark"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call.
|
||||||
|
pub fn prepare_message_delivery_proof<R, FI, B, BH, BHH>(
|
||||||
|
params: MessageDeliveryProofParams<AccountIdOf<ThisChain<B>>>,
|
||||||
|
) -> FromBridgedChainMessagesDeliveryProof<HashOf<BridgedChain<B>>>
|
||||||
|
where
|
||||||
|
R: pallet_bridge_grandpa::Config<FI>,
|
||||||
|
R::BridgedChain: bp_runtime::Chain<Header = BH>,
|
||||||
|
FI: 'static,
|
||||||
|
B: MessageBridge,
|
||||||
|
BH: Header<Hash = HashOf<BridgedChain<B>>>,
|
||||||
|
BHH: Hasher<Out = HashOf<BridgedChain<B>>>,
|
||||||
|
HashOf<BridgedChain<B>>: Copy + Default,
|
||||||
|
{
|
||||||
|
// prepare Bridged chain storage with inbound lane state
|
||||||
|
let storage_key =
|
||||||
|
storage_keys::inbound_lane_data_key(B::BRIDGED_MESSAGES_PALLET_NAME, ¶ms.lane).0;
|
||||||
|
let mut root = Default::default();
|
||||||
|
let mut mdb = MemoryDB::default();
|
||||||
|
{
|
||||||
|
let mut trie = TrieDBMutV1::<BHH>::new(&mut mdb, &mut root);
|
||||||
|
trie.insert(&storage_key, ¶ms.inbound_lane_data.encode())
|
||||||
|
.map_err(|_| "TrieMut::insert has failed")
|
||||||
|
.expect("TrieMut::insert should not fail in benchmarks");
|
||||||
|
}
|
||||||
|
root = grow_trie(root, &mut mdb, params.size);
|
||||||
|
|
||||||
|
// generate storage proof to be delivered to This chain
|
||||||
|
let mut proof_recorder = Recorder::<BHH::Out>::new();
|
||||||
|
record_all_keys::<LayoutV1<BHH>, _>(&mdb, &root, &mut proof_recorder)
|
||||||
|
.map_err(|_| "record_all_keys has failed")
|
||||||
|
.expect("record_all_keys should not fail in benchmarks");
|
||||||
|
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
||||||
|
|
||||||
|
// finally insert header with given state root to our storage
|
||||||
|
let bridged_header_hash = insert_bridged_chain_header::<R, FI, B, BH>(root);
|
||||||
|
|
||||||
|
FromBridgedChainMessagesDeliveryProof {
|
||||||
|
bridged_header_hash: bridged_header_hash.into(),
|
||||||
|
storage_proof,
|
||||||
|
lane: params.lane,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Prepare storage proof of given messages.
|
||||||
|
///
|
||||||
|
/// Returns state trie root and nodes with prepared messages.
|
||||||
|
fn prepare_messages_storage_proof<B, BHH>(
|
||||||
|
params: &MessageProofParams,
|
||||||
|
message_payload: MessagePayload,
|
||||||
|
) -> (HashOf<BridgedChain<B>>, RawStorageProof)
|
||||||
|
where
|
||||||
|
B: MessageBridge,
|
||||||
|
BHH: Hasher<Out = HashOf<BridgedChain<B>>>,
|
||||||
|
HashOf<BridgedChain<B>>: Copy + Default,
|
||||||
|
{
|
||||||
|
// prepare Bridged chain storage with messages and (optionally) outbound lane state
|
||||||
|
let message_count =
|
||||||
|
params.message_nonces.end().saturating_sub(*params.message_nonces.start()) + 1;
|
||||||
|
let mut storage_keys = Vec::with_capacity(message_count as usize + 1);
|
||||||
|
let mut root = Default::default();
|
||||||
|
let mut mdb = MemoryDB::default();
|
||||||
|
{
|
||||||
|
let mut trie = TrieDBMutV1::<BHH>::new(&mut mdb, &mut root);
|
||||||
|
|
||||||
|
// insert messages
|
||||||
|
for nonce in params.message_nonces.clone() {
|
||||||
|
let message_key = MessageKey { lane_id: params.lane, nonce };
|
||||||
|
let message_data = MessageData {
|
||||||
|
fee: BalanceOf::<BridgedChain<B>>::from(0),
|
||||||
|
payload: message_payload.clone(),
|
||||||
|
};
|
||||||
|
let storage_key = storage_keys::message_key(
|
||||||
|
B::BRIDGED_MESSAGES_PALLET_NAME,
|
||||||
|
&message_key.lane_id,
|
||||||
|
message_key.nonce,
|
||||||
|
)
|
||||||
|
.0;
|
||||||
|
trie.insert(&storage_key, &message_data.encode())
|
||||||
|
.map_err(|_| "TrieMut::insert has failed")
|
||||||
|
.expect("TrieMut::insert should not fail in benchmarks");
|
||||||
|
storage_keys.push(storage_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert outbound lane state
|
||||||
|
if let Some(ref outbound_lane_data) = params.outbound_lane_data {
|
||||||
|
let storage_key =
|
||||||
|
storage_keys::outbound_lane_data_key(B::BRIDGED_MESSAGES_PALLET_NAME, ¶ms.lane)
|
||||||
|
.0;
|
||||||
|
trie.insert(&storage_key, &outbound_lane_data.encode())
|
||||||
|
.map_err(|_| "TrieMut::insert has failed")
|
||||||
|
.expect("TrieMut::insert should not fail in benchmarks");
|
||||||
|
storage_keys.push(storage_key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
root = grow_trie(root, &mut mdb, params.size);
|
||||||
|
|
||||||
|
// generate storage proof to be delivered to This chain
|
||||||
|
let mut proof_recorder = Recorder::<BHH::Out>::new();
|
||||||
|
record_all_keys::<LayoutV1<BHH>, _>(&mdb, &root, &mut proof_recorder)
|
||||||
|
.map_err(|_| "record_all_keys has failed")
|
||||||
|
.expect("record_all_keys should not fail in benchmarks");
|
||||||
|
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
||||||
|
|
||||||
|
(root, storage_proof)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Insert Bridged chain header with given state root into storage of GRANDPA pallet at This chain.
|
||||||
|
fn insert_bridged_chain_header<R, FI, B, BH>(
|
||||||
|
state_root: HashOf<BridgedChain<B>>,
|
||||||
|
) -> HashOf<BridgedChain<B>>
|
||||||
|
where
|
||||||
|
R: pallet_bridge_grandpa::Config<FI>,
|
||||||
|
R::BridgedChain: bp_runtime::Chain<Header = BH>,
|
||||||
|
FI: 'static,
|
||||||
|
B: MessageBridge,
|
||||||
|
BH: Header<Hash = HashOf<BridgedChain<B>>>,
|
||||||
|
HashOf<BridgedChain<B>>: Default,
|
||||||
|
{
|
||||||
|
let bridged_header = BH::new(
|
||||||
|
Zero::zero(),
|
||||||
|
Default::default(),
|
||||||
|
state_root,
|
||||||
|
Default::default(),
|
||||||
|
Default::default(),
|
||||||
|
);
|
||||||
|
let bridged_header_hash = bridged_header.hash();
|
||||||
|
pallet_bridge_grandpa::initialize_for_benchmarks::<R, FI>(bridged_header);
|
||||||
|
bridged_header_hash
|
||||||
|
}
|
||||||
|
|
||||||
/// Generate ed25519 signature to be used in
|
/// Generate ed25519 signature to be used in
|
||||||
/// `pallet_brdige_call_dispatch::CallOrigin::TargetAccount`.
|
/// `pallet_brdige_call_dispatch::CallOrigin::TargetAccount`.
|
||||||
///
|
///
|
||||||
/// Returns public key of the signer and the signature itself.
|
/// Returns public key of the signer and the signature itself.
|
||||||
pub fn ed25519_sign(
|
fn ed25519_sign(
|
||||||
target_call: &impl Encode,
|
target_call: &impl Encode,
|
||||||
source_account_id: &impl Encode,
|
source_account_id: &impl Encode,
|
||||||
target_spec_version: u32,
|
target_spec_version: u32,
|
||||||
source_chain_id: ChainId,
|
source_chain_id: ChainId,
|
||||||
target_chain_id: ChainId,
|
target_chain_id: ChainId,
|
||||||
) -> ([u8; 32], [u8; 64]) {
|
) -> ([u8; 32], [u8; 64]) {
|
||||||
// key from the repo example (https://docs.rs/ed25519-dalek/1.0.1/ed25519_dalek/struct.SecretKey.html)
|
let target_secret = dispatch_account_secret();
|
||||||
let target_secret = SecretKey::from_bytes(&[
|
|
||||||
157, 097, 177, 157, 239, 253, 090, 096, 186, 132, 074, 244, 146, 236, 044, 196, 068, 073,
|
|
||||||
197, 105, 123, 050, 105, 025, 112, 059, 172, 003, 028, 174, 127, 096,
|
|
||||||
])
|
|
||||||
.expect("harcoded key is valid");
|
|
||||||
let target_public: PublicKey = (&target_secret).into();
|
let target_public: PublicKey = (&target_secret).into();
|
||||||
|
|
||||||
let mut target_pair_bytes = [0u8; KEYPAIR_LENGTH];
|
let mut target_pair_bytes = [0u8; KEYPAIR_LENGTH];
|
||||||
@@ -76,131 +346,6 @@ pub fn ed25519_sign(
|
|||||||
(target_public.to_bytes(), target_origin_signature.to_bytes())
|
(target_public.to_bytes(), target_origin_signature.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepare proof of messages for the `receive_messages_proof` call.
|
|
||||||
pub fn prepare_message_proof<B, H, R, FI, MM, ML, MH>(
|
|
||||||
params: MessageProofParams,
|
|
||||||
make_bridged_message_storage_key: MM,
|
|
||||||
make_bridged_outbound_lane_data_key: ML,
|
|
||||||
make_bridged_header: MH,
|
|
||||||
message_dispatch_weight: Weight,
|
|
||||||
message_payload: MessagePayload,
|
|
||||||
) -> (FromBridgedChainMessagesProof<HashOf<BridgedChain<B>>>, Weight)
|
|
||||||
where
|
|
||||||
B: MessageBridge,
|
|
||||||
H: Hasher,
|
|
||||||
R: pallet_bridge_grandpa::Config<FI>,
|
|
||||||
FI: 'static,
|
|
||||||
<R::BridgedChain as bp_runtime::Chain>::Hash: Into<HashOf<BridgedChain<B>>>,
|
|
||||||
MM: Fn(MessageKey) -> Vec<u8>,
|
|
||||||
ML: Fn(LaneId) -> Vec<u8>,
|
|
||||||
MH: Fn(H::Out) -> <R::BridgedChain as bp_runtime::Chain>::Header,
|
|
||||||
{
|
|
||||||
// prepare Bridged chain storage with messages and (optionally) outbound lane state
|
|
||||||
let message_count =
|
|
||||||
params.message_nonces.end().saturating_sub(*params.message_nonces.start()) + 1;
|
|
||||||
let mut storage_keys = Vec::with_capacity(message_count as usize + 1);
|
|
||||||
let mut root = Default::default();
|
|
||||||
let mut mdb = MemoryDB::default();
|
|
||||||
{
|
|
||||||
let mut trie = TrieDBMutV1::<H>::new(&mut mdb, &mut root);
|
|
||||||
|
|
||||||
// insert messages
|
|
||||||
for nonce in params.message_nonces.clone() {
|
|
||||||
let message_key = MessageKey { lane_id: params.lane, nonce };
|
|
||||||
let message_data = MessageData {
|
|
||||||
fee: BalanceOf::<BridgedChain<B>>::from(0),
|
|
||||||
payload: message_payload.clone(),
|
|
||||||
};
|
|
||||||
let storage_key = make_bridged_message_storage_key(message_key);
|
|
||||||
trie.insert(&storage_key, &message_data.encode())
|
|
||||||
.map_err(|_| "TrieMut::insert has failed")
|
|
||||||
.expect("TrieMut::insert should not fail in benchmarks");
|
|
||||||
storage_keys.push(storage_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert outbound lane state
|
|
||||||
if let Some(outbound_lane_data) = params.outbound_lane_data {
|
|
||||||
let storage_key = make_bridged_outbound_lane_data_key(params.lane);
|
|
||||||
trie.insert(&storage_key, &outbound_lane_data.encode())
|
|
||||||
.map_err(|_| "TrieMut::insert has failed")
|
|
||||||
.expect("TrieMut::insert should not fail in benchmarks");
|
|
||||||
storage_keys.push(storage_key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
root = grow_trie(root, &mut mdb, params.size);
|
|
||||||
|
|
||||||
// generate storage proof to be delivered to This chain
|
|
||||||
let mut proof_recorder = Recorder::<H::Out>::new();
|
|
||||||
record_all_keys::<LayoutV1<H>, _>(&mdb, &root, &mut proof_recorder)
|
|
||||||
.map_err(|_| "record_all_keys has failed")
|
|
||||||
.expect("record_all_keys should not fail in benchmarks");
|
|
||||||
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
|
||||||
|
|
||||||
// prepare Bridged chain header and insert it into the Substrate pallet
|
|
||||||
let bridged_header = make_bridged_header(root);
|
|
||||||
let bridged_header_hash = bridged_header.hash();
|
|
||||||
pallet_bridge_grandpa::initialize_for_benchmarks::<R, FI>(bridged_header);
|
|
||||||
|
|
||||||
(
|
|
||||||
FromBridgedChainMessagesProof {
|
|
||||||
bridged_header_hash: bridged_header_hash.into(),
|
|
||||||
storage_proof,
|
|
||||||
lane: params.lane,
|
|
||||||
nonces_start: *params.message_nonces.start(),
|
|
||||||
nonces_end: *params.message_nonces.end(),
|
|
||||||
},
|
|
||||||
message_dispatch_weight
|
|
||||||
.checked_mul(message_count)
|
|
||||||
.expect("too many messages requested by benchmark"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call.
|
|
||||||
pub fn prepare_message_delivery_proof<B, H, R, FI, ML, MH>(
|
|
||||||
params: MessageDeliveryProofParams<AccountIdOf<ThisChain<B>>>,
|
|
||||||
make_bridged_inbound_lane_data_key: ML,
|
|
||||||
make_bridged_header: MH,
|
|
||||||
) -> FromBridgedChainMessagesDeliveryProof<HashOf<BridgedChain<B>>>
|
|
||||||
where
|
|
||||||
B: MessageBridge,
|
|
||||||
H: Hasher,
|
|
||||||
R: pallet_bridge_grandpa::Config<FI>,
|
|
||||||
FI: 'static,
|
|
||||||
<R::BridgedChain as bp_runtime::Chain>::Hash: Into<HashOf<BridgedChain<B>>>,
|
|
||||||
ML: Fn(LaneId) -> Vec<u8>,
|
|
||||||
MH: Fn(H::Out) -> <R::BridgedChain as bp_runtime::Chain>::Header,
|
|
||||||
{
|
|
||||||
// prepare Bridged chain storage with inbound lane state
|
|
||||||
let storage_key = make_bridged_inbound_lane_data_key(params.lane);
|
|
||||||
let mut root = Default::default();
|
|
||||||
let mut mdb = MemoryDB::default();
|
|
||||||
{
|
|
||||||
let mut trie = TrieDBMutV1::<H>::new(&mut mdb, &mut root);
|
|
||||||
trie.insert(&storage_key, ¶ms.inbound_lane_data.encode())
|
|
||||||
.map_err(|_| "TrieMut::insert has failed")
|
|
||||||
.expect("TrieMut::insert should not fail in benchmarks");
|
|
||||||
}
|
|
||||||
root = grow_trie(root, &mut mdb, params.size);
|
|
||||||
|
|
||||||
// generate storage proof to be delivered to This chain
|
|
||||||
let mut proof_recorder = Recorder::<H::Out>::new();
|
|
||||||
record_all_keys::<LayoutV1<H>, _>(&mdb, &root, &mut proof_recorder)
|
|
||||||
.map_err(|_| "record_all_keys has failed")
|
|
||||||
.expect("record_all_keys should not fail in benchmarks");
|
|
||||||
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
|
||||||
|
|
||||||
// prepare Bridged chain header and insert it into the Substrate pallet
|
|
||||||
let bridged_header = make_bridged_header(root);
|
|
||||||
let bridged_header_hash = bridged_header.hash();
|
|
||||||
pallet_bridge_grandpa::initialize_for_benchmarks::<R, FI>(bridged_header);
|
|
||||||
|
|
||||||
FromBridgedChainMessagesDeliveryProof {
|
|
||||||
bridged_header_hash: bridged_header_hash.into(),
|
|
||||||
storage_proof,
|
|
||||||
lane: params.lane,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Populate trie with dummy keys+values until trie has at least given size.
|
/// Populate trie with dummy keys+values until trie has at least given size.
|
||||||
fn grow_trie<H: Hasher>(mut root: H::Out, mdb: &mut MemoryDB<H>, trie_size: ProofSize) -> H::Out {
|
fn grow_trie<H: Hasher>(mut root: H::Out, mdb: &mut MemoryDB<H>, trie_size: ProofSize) -> H::Out {
|
||||||
let (iterations, leaf_size, minimal_trie_size) = match trie_size {
|
let (iterations, leaf_size, minimal_trie_size) = match trie_size {
|
||||||
@@ -222,8 +367,8 @@ fn grow_trie<H: Hasher>(mut root: H::Out, mdb: &mut MemoryDB<H>, trie_size: Proo
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut trie = TrieDBMutV1::<H>::from_existing(mdb, &mut root)
|
let mut trie = TrieDBMutV1::<H>::from_existing(mdb, &mut root)
|
||||||
.map_err(|_| "TrieDBMut::from_existing has failed")
|
.map_err(|_| "TrieDBMutV1::from_existing has failed")
|
||||||
.expect("TrieDBMut::from_existing should not fail in benchmarks");
|
.expect("TrieDBMutV1::from_existing should not fail in benchmarks");
|
||||||
for _ in 0..iterations {
|
for _ in 0..iterations {
|
||||||
trie.insert(&key_index.encode(), &vec![42u8; leaf_size as _])
|
trie.insert(&key_index.encode(), &vec![42u8; leaf_size as _])
|
||||||
.map_err(|_| "TrieMut::insert has failed")
|
.map_err(|_| "TrieMut::insert has failed")
|
||||||
|
|||||||
@@ -48,21 +48,17 @@ notice = "warn"
|
|||||||
# A list of advisory IDs to ignore. Note that ignored advisories will still
|
# A list of advisory IDs to ignore. Note that ignored advisories will still
|
||||||
# output a note when they are encountered.
|
# output a note when they are encountered.
|
||||||
ignore = [
|
ignore = [
|
||||||
# yaml-rust < clap. Not feasible to upgrade and also not possible to trigger in practice.
|
|
||||||
"RUSTSEC-2018-0006",
|
|
||||||
"RUSTSEC-2020-0070",
|
"RUSTSEC-2020-0070",
|
||||||
# Comes from honggfuzz via storage-proof-fuzzer: 'memmap'
|
# Comes from honggfuzz via storage-proof-fuzzer: 'memmap'
|
||||||
"RUSTSEC-2020-0077",
|
"RUSTSEC-2020-0077",
|
||||||
# Comes from time: 'stweb' (will be fixed in upcoming time 0.3)
|
|
||||||
"RUSTSEC-2020-0056",
|
|
||||||
# net2 (origin: Substrate RPC crates)
|
# net2 (origin: Substrate RPC crates)
|
||||||
"RUSTSEC-2020-0016",
|
"RUSTSEC-2020-0016",
|
||||||
# Wasmtime (origin: Substrate executor crates)
|
|
||||||
"RUSTSEC-2021-0110",
|
|
||||||
# time (origin: Substrate RPC + benchmarking crates)
|
# time (origin: Substrate RPC + benchmarking crates)
|
||||||
"RUSTSEC-2020-0071",
|
"RUSTSEC-2020-0071",
|
||||||
# chrono (origin: Substrate benchmarking + cli + ...)
|
# chrono (origin: Substrate benchmarking + cli + ...)
|
||||||
"RUSTSEC-2020-0159",
|
"RUSTSEC-2020-0159",
|
||||||
|
# lru 0.6.6 (origin: libp2p)
|
||||||
|
"RUSTSEC-2021-0130",
|
||||||
]
|
]
|
||||||
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
|
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
|
||||||
# lower than the range specified will be ignored. Note that ignored advisories
|
# lower than the range specified will be ignored. Note that ignored advisories
|
||||||
|
|||||||
+22
-9
@@ -64,11 +64,18 @@
|
|||||||
"steppedLine": false,
|
"steppedLine": false,
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"expr": "label_replace(label_replace(Millau_to_Rialto_MessageLane_00000000_best_block_numbers{type=~\"target|target_at_source\"}, \"type\", \"At Rialto\", \"type\", \"target\"), \"type\", \"At Millau\", \"type\", \"target_at_source\")",
|
"expr": "Millau_to_Rialto_MessageLane_00000000_best_target_block_number",
|
||||||
"instant": false,
|
"instant": false,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "{{type}}",
|
"legendFormat": "At Rialto",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "Millau_to_Rialto_MessageLane_00000000_best_target_at_source_block_number",
|
||||||
|
"instant": false,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "At Millau",
|
||||||
|
"refId": "B"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"thresholds": [],
|
"thresholds": [],
|
||||||
@@ -158,10 +165,16 @@
|
|||||||
"steppedLine": false,
|
"steppedLine": false,
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"expr": "label_replace(label_replace(Millau_to_Rialto_MessageLane_00000000_best_block_numbers{type=~\"source|source_at_target\"}, \"type\", \"At Millau\", \"type\", \"source\"), \"type\", \"At Rialto\", \"type\", \"source_at_target\")",
|
"expr": "Millau_to_Rialto_MessageLane_00000000_best_source_block_number",
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "{{type}}",
|
"legendFormat": "At Millau",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "Millau_to_Rialto_MessageLane_00000000_best_source_at_target_block_number",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "At Rialto",
|
||||||
|
"refId": "B"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"thresholds": [],
|
"thresholds": [],
|
||||||
@@ -531,7 +544,7 @@
|
|||||||
"refId": "A"
|
"refId": "A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"expr": "increase(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[1m])",
|
"expr": "increase(Millau_to_Rialto_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[1m]) OR on() vector(0)",
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "Messages delivered to Rialto in last 1m",
|
"legendFormat": "Messages delivered to Rialto in last 1m",
|
||||||
"refId": "B"
|
"refId": "B"
|
||||||
@@ -954,7 +967,7 @@
|
|||||||
"refId": "A"
|
"refId": "A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"expr": "increase(Millau_to_Rialto_MessageLane_00000001_lane_state_nonces{type=\"target_latest_received\"}[10m])",
|
"expr": "increase(Millau_to_Rialto_MessageLane_00000001_lane_state_nonces{type=\"target_latest_received\"}[10m]) OR on() vector(0)",
|
||||||
"hide": true,
|
"hide": true,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "Messages generated in last 5 minutes",
|
"legendFormat": "Messages generated in last 5 minutes",
|
||||||
@@ -1097,7 +1110,7 @@
|
|||||||
"refId": "A"
|
"refId": "A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"expr": "increase(Millau_to_Rialto_MessageLane_00000001_lane_state_nonces{type=\"source_latest_confirmed\"}[10m])",
|
"expr": "increase(Millau_to_Rialto_MessageLane_00000001_lane_state_nonces{type=\"source_latest_confirmed\"}[10m]) OR on() vector(0)",
|
||||||
"hide": true,
|
"hide": true,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "",
|
"legendFormat": "",
|
||||||
@@ -1241,7 +1254,7 @@
|
|||||||
"refId": "A"
|
"refId": "A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"expr": "increase(Millau_to_Rialto_MessageLane_73776170_lane_state_nonces{type=\"target_latest_received\"}[20m])",
|
"expr": "increase(Millau_to_Rialto_MessageLane_73776170_lane_state_nonces{type=\"target_latest_received\"}[20m]) OR on() vector(0)",
|
||||||
"hide": true,
|
"hide": true,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "Messages generated in last 5 minutes",
|
"legendFormat": "Messages generated in last 5 minutes",
|
||||||
@@ -1349,7 +1362,7 @@
|
|||||||
"refId": "A"
|
"refId": "A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"expr": "increase(Millau_to_Rialto_MessageLane_73776170_lane_state_nonces{type=\"source_latest_confirmed\"}[10m])",
|
"expr": "increase(Millau_to_Rialto_MessageLane_73776170_lane_state_nonces{type=\"source_latest_confirmed\"}[10m]) OR on() vector(0)",
|
||||||
"hide": true,
|
"hide": true,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "",
|
"legendFormat": "",
|
||||||
|
|||||||
+20
-7
@@ -64,11 +64,18 @@
|
|||||||
"steppedLine": false,
|
"steppedLine": false,
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"expr": "label_replace(label_replace(Rialto_to_Millau_MessageLane_00000000_best_block_numbers{type=~\"target|target_at_source\"}, \"type\", \"At Millau\", \"type\", \"target\"), \"type\", \"At Rialto\", \"type\", \"target_at_source\")",
|
"expr": "Rialto_to_Millau_MessageLane_00000000_best_target_block_number",
|
||||||
"instant": false,
|
"instant": false,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "{{type}}",
|
"legendFormat": "At Millau",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "Rialto_to_Millau_MessageLane_00000000_best_target_at_source_block_number",
|
||||||
|
"instant": false,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "At Rialto",
|
||||||
|
"refId": "B"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"thresholds": [],
|
"thresholds": [],
|
||||||
@@ -158,10 +165,16 @@
|
|||||||
"steppedLine": false,
|
"steppedLine": false,
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"expr": "label_replace(label_replace(Rialto_to_Millau_MessageLane_00000000_best_block_numbers{type=~\"source|source_at_target\"}, \"type\", \"At Rialto\", \"type\", \"source\"), \"type\", \"At Millau\", \"type\", \"source_at_target\")",
|
"expr": "Rialto_to_Millau_MessageLane_00000000_best_source_block_number",
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "{{type}}",
|
"legendFormat": "At Rialto",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "Rialto_to_Millau_MessageLane_00000000_best_source_at_target_block_number",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "At Millau",
|
||||||
|
"refId": "B"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"thresholds": [],
|
"thresholds": [],
|
||||||
@@ -522,7 +535,7 @@
|
|||||||
"refId": "A"
|
"refId": "A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"expr": "increase(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[1m])",
|
"expr": "increase(Rialto_to_Millau_MessageLane_00000000_lane_state_nonces{type=\"target_latest_received\"}[1m]) OR on() vector(0)",
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "Messages delivered to Millau in last 1m",
|
"legendFormat": "Messages delivered to Millau in last 1m",
|
||||||
"refId": "B"
|
"refId": "B"
|
||||||
@@ -945,7 +958,7 @@
|
|||||||
"refId": "A"
|
"refId": "A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"expr": "increase(Rialto_to_Millau_MessageLane_00000001_lane_state_nonces{type=\"target_latest_received\"}[10m])",
|
"expr": "increase(Rialto_to_Millau_MessageLane_00000001_lane_state_nonces{type=\"target_latest_received\"}[10m]) OR on() vector(0)",
|
||||||
"hide": true,
|
"hide": true,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "Messages generated in last 5 minutes",
|
"legendFormat": "Messages generated in last 5 minutes",
|
||||||
@@ -1089,7 +1102,7 @@
|
|||||||
"refId": "A"
|
"refId": "A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"expr": "increase(Rialto_to_Millau_MessageLane_00000001_lane_state_nonces{type=\"source_latest_confirmed\"}[10m])",
|
"expr": "increase(Rialto_to_Millau_MessageLane_00000001_lane_state_nonces{type=\"source_latest_confirmed\"}[10m]) OR on() vector(0)",
|
||||||
"hide": true,
|
"hide": true,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "",
|
"legendFormat": "",
|
||||||
|
|||||||
+619
-14
@@ -15,7 +15,6 @@
|
|||||||
"editable": true,
|
"editable": true,
|
||||||
"gnetId": null,
|
"gnetId": null,
|
||||||
"graphTooltip": 0,
|
"graphTooltip": 0,
|
||||||
"id": 9,
|
|
||||||
"links": [],
|
"links": [],
|
||||||
"panels": [
|
"panels": [
|
||||||
{
|
{
|
||||||
@@ -25,7 +24,9 @@
|
|||||||
"dashes": false,
|
"dashes": false,
|
||||||
"datasource": "Prometheus",
|
"datasource": "Prometheus",
|
||||||
"fieldConfig": {
|
"fieldConfig": {
|
||||||
"defaults": {},
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
"overrides": []
|
"overrides": []
|
||||||
},
|
},
|
||||||
"fill": 1,
|
"fill": 1,
|
||||||
@@ -54,7 +55,7 @@
|
|||||||
"alertThreshold": true
|
"alertThreshold": true
|
||||||
},
|
},
|
||||||
"percentage": false,
|
"percentage": false,
|
||||||
"pluginVersion": "7.5.3",
|
"pluginVersion": "7.1.3",
|
||||||
"pointradius": 2,
|
"pointradius": 2,
|
||||||
"points": false,
|
"points": false,
|
||||||
"renderer": "flot",
|
"renderer": "flot",
|
||||||
@@ -129,7 +130,9 @@
|
|||||||
"dashes": false,
|
"dashes": false,
|
||||||
"datasource": "Prometheus",
|
"datasource": "Prometheus",
|
||||||
"fieldConfig": {
|
"fieldConfig": {
|
||||||
"defaults": {},
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
"overrides": []
|
"overrides": []
|
||||||
},
|
},
|
||||||
"fill": 1,
|
"fill": 1,
|
||||||
@@ -158,7 +161,7 @@
|
|||||||
"alertThreshold": true
|
"alertThreshold": true
|
||||||
},
|
},
|
||||||
"percentage": false,
|
"percentage": false,
|
||||||
"pluginVersion": "7.5.3",
|
"pluginVersion": "7.1.3",
|
||||||
"pointradius": 2,
|
"pointradius": 2,
|
||||||
"points": false,
|
"points": false,
|
||||||
"renderer": "flot",
|
"renderer": "flot",
|
||||||
@@ -169,7 +172,7 @@
|
|||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"exemplar": true,
|
"exemplar": true,
|
||||||
"expr": "kusama_to_base_conversion_rate{instance='relay-millau-rialto:9616'} / polkadot_to_base_conversion_rate{instance='relay-millau-rialto:9616'}",
|
"expr": "polkadot_to_base_conversion_rate{instance='relay-millau-rialto:9616'} / kusama_to_base_conversion_rate{instance='relay-millau-rialto:9616'}",
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "Outside of runtime (actually Polkadot -> Kusama)",
|
"legendFormat": "Outside of runtime (actually Polkadot -> Kusama)",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -233,7 +236,9 @@
|
|||||||
"dashes": false,
|
"dashes": false,
|
||||||
"datasource": "Prometheus",
|
"datasource": "Prometheus",
|
||||||
"fieldConfig": {
|
"fieldConfig": {
|
||||||
"defaults": {},
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
"overrides": []
|
"overrides": []
|
||||||
},
|
},
|
||||||
"fill": 1,
|
"fill": 1,
|
||||||
@@ -262,7 +267,7 @@
|
|||||||
"alertThreshold": true
|
"alertThreshold": true
|
||||||
},
|
},
|
||||||
"percentage": false,
|
"percentage": false,
|
||||||
"pluginVersion": "7.5.3",
|
"pluginVersion": "7.1.3",
|
||||||
"pointradius": 2,
|
"pointradius": 2,
|
||||||
"points": false,
|
"points": false,
|
||||||
"renderer": "flot",
|
"renderer": "flot",
|
||||||
@@ -337,7 +342,9 @@
|
|||||||
"dashes": false,
|
"dashes": false,
|
||||||
"datasource": "Prometheus",
|
"datasource": "Prometheus",
|
||||||
"fieldConfig": {
|
"fieldConfig": {
|
||||||
"defaults": {},
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
"overrides": []
|
"overrides": []
|
||||||
},
|
},
|
||||||
"fill": 1,
|
"fill": 1,
|
||||||
@@ -366,7 +373,7 @@
|
|||||||
"alertThreshold": true
|
"alertThreshold": true
|
||||||
},
|
},
|
||||||
"percentage": false,
|
"percentage": false,
|
||||||
"pluginVersion": "7.5.3",
|
"pluginVersion": "7.1.3",
|
||||||
"pointradius": 2,
|
"pointradius": 2,
|
||||||
"points": false,
|
"points": false,
|
||||||
"renderer": "flot",
|
"renderer": "flot",
|
||||||
@@ -377,7 +384,7 @@
|
|||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"exemplar": true,
|
"exemplar": true,
|
||||||
"expr": "polkadot_to_base_conversion_rate{instance='relay-millau-rialto:9616'} / kusama_to_base_conversion_rate{instance='relay-millau-rialto:9616'}",
|
"expr": "kusama_to_base_conversion_rate{instance='relay-millau-rialto:9616'} / polkadot_to_base_conversion_rate{instance='relay-millau-rialto:9616'}",
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "Outside of runtime (actually Kusama -> Polkadot)",
|
"legendFormat": "Outside of runtime (actually Kusama -> Polkadot)",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -433,22 +440,620 @@
|
|||||||
"align": false,
|
"align": false,
|
||||||
"alignLevel": null
|
"alignLevel": null
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alert": {
|
||||||
|
"alertRuleTags": {},
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
1000
|
||||||
|
],
|
||||||
|
"type": "lt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "and"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"A",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "last"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
1000
|
||||||
|
],
|
||||||
|
"type": "lt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "or"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"B",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "last"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"executionErrorState": "alerting",
|
||||||
|
"for": "5m",
|
||||||
|
"frequency": "1m",
|
||||||
|
"handler": 1,
|
||||||
|
"name": "At-Rialto relay balances are too low",
|
||||||
|
"noDataState": "no_data",
|
||||||
|
"notifications": []
|
||||||
|
},
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": "Prometheus",
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 16
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 8,
|
||||||
|
"legend": {
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "7.1.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "at_Rialto_relay_balance",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "Relay account balance",
|
||||||
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "at_Rialto_messages_pallet_owner_balance",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "Messages pallet owner balance",
|
||||||
|
"refId": "B"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [
|
||||||
|
{
|
||||||
|
"colorMode": "critical",
|
||||||
|
"fill": true,
|
||||||
|
"line": true,
|
||||||
|
"op": "lt",
|
||||||
|
"value": 1000
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timeFrom": null,
|
||||||
|
"timeRegions": [],
|
||||||
|
"timeShift": null,
|
||||||
|
"title": "Rialto relay balances",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"buckets": null,
|
||||||
|
"mode": "time",
|
||||||
|
"name": null,
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false,
|
||||||
|
"alignLevel": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alert": {
|
||||||
|
"alertRuleTags": {},
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
1000
|
||||||
|
],
|
||||||
|
"type": "lt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "and"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"A",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "last"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
1000
|
||||||
|
],
|
||||||
|
"type": "lt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "and"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"B",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "last"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"executionErrorState": "alerting",
|
||||||
|
"for": "5m",
|
||||||
|
"frequency": "1m",
|
||||||
|
"handler": 1,
|
||||||
|
"name": "At-Millau relay balances are too low",
|
||||||
|
"noDataState": "no_data",
|
||||||
|
"notifications": []
|
||||||
|
},
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": "Prometheus",
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 12,
|
||||||
|
"y": 16
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 9,
|
||||||
|
"legend": {
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "7.1.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "at_Millau_relay_balance",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "Relay account balance",
|
||||||
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "at_Millau_messages_pallet_owner_balance",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "Messages pallet owner balance",
|
||||||
|
"refId": "B"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [
|
||||||
|
{
|
||||||
|
"colorMode": "critical",
|
||||||
|
"fill": true,
|
||||||
|
"line": true,
|
||||||
|
"op": "lt",
|
||||||
|
"value": 1000
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timeFrom": null,
|
||||||
|
"timeRegions": [],
|
||||||
|
"timeShift": null,
|
||||||
|
"title": "Millau relay balances",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"buckets": null,
|
||||||
|
"mode": "time",
|
||||||
|
"name": null,
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false,
|
||||||
|
"alignLevel": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alert": {
|
||||||
|
"alertRuleTags": {},
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"type": "gt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "and"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"A",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "max"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"executionErrorState": "alerting",
|
||||||
|
"for": "5m",
|
||||||
|
"frequency": "1m",
|
||||||
|
"handler": 1,
|
||||||
|
"name": "Whether with-Rialto-grandpa-pallet and Rialto itself are on different forks alert",
|
||||||
|
"noDataState": "no_data",
|
||||||
|
"notifications": []
|
||||||
|
},
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": "Prometheus",
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 24
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 11,
|
||||||
|
"legend": {
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "7.1.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "Rialto_to_Millau_MessageLane_00000000_is_source_and_source_at_target_using_different_forks",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "On different forks?",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [
|
||||||
|
{
|
||||||
|
"colorMode": "critical",
|
||||||
|
"fill": true,
|
||||||
|
"line": true,
|
||||||
|
"op": "gt",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timeFrom": null,
|
||||||
|
"timeRegions": [],
|
||||||
|
"timeShift": null,
|
||||||
|
"title": "Whether with-Rialto-grandpa-pallet and Rialto itself are on different forks",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"buckets": null,
|
||||||
|
"mode": "time",
|
||||||
|
"name": null,
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false,
|
||||||
|
"alignLevel": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alert": {
|
||||||
|
"alertRuleTags": {},
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"type": "gt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "and"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"A",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "max"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"executionErrorState": "alerting",
|
||||||
|
"for": "5m",
|
||||||
|
"frequency": "1m",
|
||||||
|
"handler": 1,
|
||||||
|
"name": "Whether with-Rialto-grandpa-pallet and Rialto itself are on different forks alert",
|
||||||
|
"noDataState": "no_data",
|
||||||
|
"notifications": []
|
||||||
|
},
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": "Prometheus",
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 12,
|
||||||
|
"x": 12,
|
||||||
|
"y": 24
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 12,
|
||||||
|
"legend": {
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "7.1.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "Millau_to_Rialto_MessageLane_00000000_is_source_and_source_at_target_using_different_forks",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "On different forks?",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [
|
||||||
|
{
|
||||||
|
"colorMode": "critical",
|
||||||
|
"fill": true,
|
||||||
|
"line": true,
|
||||||
|
"op": "gt",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timeFrom": null,
|
||||||
|
"timeRegions": [],
|
||||||
|
"timeShift": null,
|
||||||
|
"title": "Whether with-Millau-grandpa-pallet and Millau itself are on different forks",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"buckets": null,
|
||||||
|
"mode": "time",
|
||||||
|
"name": null,
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false,
|
||||||
|
"alignLevel": null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"refresh": "10s",
|
"refresh": "10s",
|
||||||
"schemaVersion": 27,
|
"schemaVersion": 26,
|
||||||
"style": "dark",
|
"style": "dark",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"templating": {
|
"templating": {
|
||||||
"list": []
|
"list": []
|
||||||
},
|
},
|
||||||
"time": {
|
"time": {
|
||||||
"from": "now-1h",
|
"from": "now-15m",
|
||||||
"to": "now"
|
"to": "now"
|
||||||
},
|
},
|
||||||
"timepicker": {},
|
"timepicker": {},
|
||||||
"timezone": "",
|
"timezone": "",
|
||||||
"title": "Rialto+Millau maintenance dashboard",
|
"title": "Rialto+Millau maintenance dashboard",
|
||||||
"uid": "7AuyrjlMz",
|
"uid": "7AuyrjlMz",
|
||||||
"version": 2
|
"version": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ services:
|
|||||||
LETSENCRYPT_EMAIL: admin@parity.io
|
LETSENCRYPT_EMAIL: admin@parity.io
|
||||||
volumes:
|
volumes:
|
||||||
- ./bridges/rialto-millau/dashboard/grafana:/etc/grafana/dashboards/rialto-millau:ro
|
- ./bridges/rialto-millau/dashboard/grafana:/etc/grafana/dashboards/rialto-millau:ro
|
||||||
|
- ./networks/dashboard/grafana/beefy-dashboard.json:/etc/grafana/dashboards/beefy.json
|
||||||
|
|
||||||
prometheus-metrics:
|
prometheus-metrics:
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
+1
-3
@@ -1,9 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -xeu
|
set -xeu
|
||||||
|
|
||||||
sleep 60
|
sleep 15
|
||||||
curl -v http://millau-node-bob:9933/health
|
|
||||||
curl -v http://rialto-node-bob:9933/health
|
|
||||||
|
|
||||||
MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000}
|
MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000}
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -1,9 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -xeu
|
set -xeu
|
||||||
|
|
||||||
sleep 60
|
sleep 15
|
||||||
curl -v http://millau-node-bob:9933/health
|
|
||||||
curl -v http://rialto-node-bob:9933/health
|
|
||||||
|
|
||||||
MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000}
|
MESSAGE_LANE=${MSG_EXCHANGE_GEN_LANE:-00000000}
|
||||||
|
|
||||||
|
|||||||
+19
-4
@@ -34,16 +34,13 @@ LARGE_MESSAGES_TIME=0
|
|||||||
# start sending message packs in a hour
|
# start sending message packs in a hour
|
||||||
BUNCH_OF_MESSAGES_TIME=3600
|
BUNCH_OF_MESSAGES_TIME=3600
|
||||||
|
|
||||||
# give conversion rate updater some time to update Millau->Rialto conversion rate in Rialto
|
|
||||||
# (initially rate=1 and rational relayer won't deliver any messages if it'll be changed to larger value)
|
|
||||||
sleep 180
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
rand_sleep
|
rand_sleep
|
||||||
echo "Sending Remark from Rialto to Millau using Target Origin"
|
echo "Sending Remark from Rialto to Millau using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
remark
|
remark
|
||||||
|
|
||||||
@@ -51,6 +48,7 @@ do
|
|||||||
echo "Sending Remark from Rialto to Millau using Target Origin using secondary lane: $SECONDARY_MESSAGE_LANE"
|
echo "Sending Remark from Rialto to Millau using Target Origin using secondary lane: $SECONDARY_MESSAGE_LANE"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $SECONDARY_MESSAGE_LANE \
|
--lane $SECONDARY_MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
--dispatch-fee-payment at-target-chain \
|
--dispatch-fee-payment at-target-chain \
|
||||||
remark
|
remark
|
||||||
@@ -60,6 +58,7 @@ do
|
|||||||
echo "Sending Transfer from Rialto to Millau using Target Origin"
|
echo "Sending Transfer from Rialto to Millau using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
transfer \
|
transfer \
|
||||||
--amount 1000000000 \
|
--amount 1000000000 \
|
||||||
@@ -69,6 +68,7 @@ do
|
|||||||
echo "Sending Remark from Rialto to Millau using Source Origin"
|
echo "Sending Remark from Rialto to Millau using Source Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Source \
|
--origin Source \
|
||||||
remark
|
remark
|
||||||
|
|
||||||
@@ -76,6 +76,7 @@ do
|
|||||||
echo "Sending Transfer from Rialto to Millau using Source Origin"
|
echo "Sending Transfer from Rialto to Millau using Source Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Source \
|
--origin Source \
|
||||||
transfer \
|
transfer \
|
||||||
--amount 1000000000 \
|
--amount 1000000000 \
|
||||||
@@ -89,6 +90,7 @@ do
|
|||||||
echo "Sending Maximal Size Remark from Rialto to Millau using Target Origin"
|
echo "Sending Maximal Size Remark from Rialto to Millau using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
remark \
|
remark \
|
||||||
--remark-size=max
|
--remark-size=max
|
||||||
@@ -97,6 +99,7 @@ do
|
|||||||
echo "Sending Maximal Dispatch Weight Remark from Rialto to Millau using Target Origin"
|
echo "Sending Maximal Dispatch Weight Remark from Rialto to Millau using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
--dispatch-weight=max \
|
--dispatch-weight=max \
|
||||||
remark
|
remark
|
||||||
@@ -105,6 +108,7 @@ do
|
|||||||
echo "Sending Maximal Size and Dispatch Weight Remark from Rialto to Millau using Target Origin"
|
echo "Sending Maximal Size and Dispatch Weight Remark from Rialto to Millau using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
--dispatch-weight=max \
|
--dispatch-weight=max \
|
||||||
remark \
|
remark \
|
||||||
@@ -116,10 +120,21 @@ do
|
|||||||
if [ $SECONDS -ge $BUNCH_OF_MESSAGES_TIME ]; then
|
if [ $SECONDS -ge $BUNCH_OF_MESSAGES_TIME ]; then
|
||||||
BUNCH_OF_MESSAGES_TIME=$((SECONDS + 7200))
|
BUNCH_OF_MESSAGES_TIME=$((SECONDS + 7200))
|
||||||
|
|
||||||
|
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override metric --origin Target remark 2>&1`
|
||||||
|
echo $SEND_MESSAGE_OUTPUT
|
||||||
|
ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)"
|
||||||
|
if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then
|
||||||
|
ACTUAL_CONVERSION_RATE=${BASH_REMATCH[1]}
|
||||||
|
else
|
||||||
|
echo "Unable to find conversion rate in send-message output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
for i in $(seq 1 $MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE);
|
for i in $(seq 1 $MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE);
|
||||||
do
|
do
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override $ACTUAL_CONVERSION_RATE \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
remark
|
remark
|
||||||
done
|
done
|
||||||
|
|||||||
+20
-5
@@ -34,16 +34,13 @@ LARGE_MESSAGES_TIME=0
|
|||||||
# start sending message packs in a hour
|
# start sending message packs in a hour
|
||||||
BUNCH_OF_MESSAGES_TIME=3600
|
BUNCH_OF_MESSAGES_TIME=3600
|
||||||
|
|
||||||
# give conversion rate updater some time to update Rialto->Millau conversion rate in Millau
|
|
||||||
# (initially rate=1 and rational relayer won't deliver any messages if it'll be changed to larger value)
|
|
||||||
sleep 180
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
rand_sleep
|
rand_sleep
|
||||||
echo "Sending Remark from Millau to Rialto using Target Origin"
|
echo "Sending Remark from Millau to Rialto using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
remark
|
remark
|
||||||
|
|
||||||
@@ -51,6 +48,7 @@ do
|
|||||||
echo "Sending Remark from Millau to Rialto using Target Origin using secondary lane: $SECONDARY_MESSAGE_LANE"
|
echo "Sending Remark from Millau to Rialto using Target Origin using secondary lane: $SECONDARY_MESSAGE_LANE"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $SECONDARY_MESSAGE_LANE \
|
--lane $SECONDARY_MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
--dispatch-fee-payment at-target-chain \
|
--dispatch-fee-payment at-target-chain \
|
||||||
remark
|
remark
|
||||||
@@ -60,6 +58,7 @@ do
|
|||||||
echo "Sending Transfer from Millau to Rialto using Target Origin"
|
echo "Sending Transfer from Millau to Rialto using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
transfer \
|
transfer \
|
||||||
--amount 1000000000 \
|
--amount 1000000000 \
|
||||||
@@ -69,6 +68,7 @@ do
|
|||||||
echo "Sending Remark from Millau to Rialto using Source Origin"
|
echo "Sending Remark from Millau to Rialto using Source Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Source \
|
--origin Source \
|
||||||
remark
|
remark
|
||||||
|
|
||||||
@@ -76,6 +76,7 @@ do
|
|||||||
echo "Sending Transfer from Millau to Rialto using Source Origin"
|
echo "Sending Transfer from Millau to Rialto using Source Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Source \
|
--origin Source \
|
||||||
transfer \
|
transfer \
|
||||||
--amount 1000000000 \
|
--amount 1000000000 \
|
||||||
@@ -89,6 +90,7 @@ do
|
|||||||
echo "Sending Maximal Size Remark from Millau to Rialto using Target Origin"
|
echo "Sending Maximal Size Remark from Millau to Rialto using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
remark \
|
remark \
|
||||||
--remark-size=max
|
--remark-size=max
|
||||||
@@ -97,6 +99,7 @@ do
|
|||||||
echo "Sending Maximal Dispatch Weight Remark from Millau to Rialto using Target Origin"
|
echo "Sending Maximal Dispatch Weight Remark from Millau to Rialto using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
--dispatch-weight=max \
|
--dispatch-weight=max \
|
||||||
remark
|
remark
|
||||||
@@ -105,6 +108,7 @@ do
|
|||||||
echo "Sending Maximal Size and Dispatch Weight Remark from Millau to Rialto using Target Origin"
|
echo "Sending Maximal Size and Dispatch Weight Remark from Millau to Rialto using Target Origin"
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override metric \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
--dispatch-weight=max \
|
--dispatch-weight=max \
|
||||||
remark \
|
remark \
|
||||||
@@ -116,10 +120,21 @@ do
|
|||||||
if [ $SECONDS -ge $BUNCH_OF_MESSAGES_TIME ]; then
|
if [ $SECONDS -ge $BUNCH_OF_MESSAGES_TIME ]; then
|
||||||
BUNCH_OF_MESSAGES_TIME=$((SECONDS + 7200))
|
BUNCH_OF_MESSAGES_TIME=$((SECONDS + 7200))
|
||||||
|
|
||||||
for i in $(seq 1 $MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE);
|
SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override metric --origin Target remark 2>&1`
|
||||||
|
echo $SEND_MESSAGE_OUTPUT
|
||||||
|
ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)"
|
||||||
|
if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then
|
||||||
|
ACTUAL_CONVERSION_RATE=${BASH_REMATCH[1]}
|
||||||
|
else
|
||||||
|
echo "Unable to find conversion rate in send-message output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in $(seq 2 $MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE);
|
||||||
do
|
do
|
||||||
$SEND_MESSAGE \
|
$SEND_MESSAGE \
|
||||||
--lane $MESSAGE_LANE \
|
--lane $MESSAGE_LANE \
|
||||||
|
--conversion-rate-override $ACTUAL_CONVERSION_RATE \
|
||||||
--origin Target \
|
--origin Target \
|
||||||
remark
|
remark
|
||||||
done
|
done
|
||||||
|
|||||||
+1
-2
@@ -1,8 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -xeu
|
set -xeu
|
||||||
|
|
||||||
sleep 20
|
sleep 15
|
||||||
curl -v http://millau-node-alice:9933/health
|
|
||||||
|
|
||||||
# //Dave is signing Millau -> Rialto message-send transactions, which are causing problems.
|
# //Dave is signing Millau -> Rialto message-send transactions, which are causing problems.
|
||||||
#
|
#
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -xeu
|
set -xeu
|
||||||
|
|
||||||
sleep 60
|
sleep 15
|
||||||
curl -v http://millau-node-alice:9933/health
|
|
||||||
curl -v http://rialto-node-alice:9933/health
|
|
||||||
|
|
||||||
/home/user/substrate-relay init-bridge millau-to-rialto \
|
/home/user/substrate-relay init-bridge millau-to-rialto \
|
||||||
--source-host millau-node-alice \
|
--source-host millau-node-alice \
|
||||||
@@ -27,10 +25,12 @@ sleep 6
|
|||||||
--millau-port 9944 \
|
--millau-port 9944 \
|
||||||
--millau-signer //Charlie \
|
--millau-signer //Charlie \
|
||||||
--millau-messages-pallet-owner=//RialtoMessagesOwner \
|
--millau-messages-pallet-owner=//RialtoMessagesOwner \
|
||||||
|
--millau-transactions-mortality=64 \
|
||||||
--rialto-host rialto-node-alice \
|
--rialto-host rialto-node-alice \
|
||||||
--rialto-port 9944 \
|
--rialto-port 9944 \
|
||||||
--rialto-signer //Charlie \
|
--rialto-signer //Charlie \
|
||||||
--rialto-messages-pallet-owner=//MillauMessagesOwner \
|
--rialto-messages-pallet-owner=//MillauMessagesOwner \
|
||||||
|
--rialto-transactions-mortality=64 \
|
||||||
--lane=00000000 \
|
--lane=00000000 \
|
||||||
--lane=73776170 \
|
--lane=73776170 \
|
||||||
--prometheus-host=0.0.0.0
|
--prometheus-host=0.0.0.0
|
||||||
|
|||||||
+2
-4
@@ -23,10 +23,6 @@ rand_sleep() {
|
|||||||
echo "Woke up at $NOW"
|
echo "Woke up at $NOW"
|
||||||
}
|
}
|
||||||
|
|
||||||
# give conversion rate updater some time to update Rialto->Millau conversion rate in Millau
|
|
||||||
# (initially rate=1 and rational relayer won't deliver any messages if it'll be changed to larger value)
|
|
||||||
sleep 180
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
rand_sleep
|
rand_sleep
|
||||||
@@ -42,6 +38,8 @@ do
|
|||||||
--target-port $TARGET_PORT \
|
--target-port $TARGET_PORT \
|
||||||
--target-signer //WithMillauTokenSwap \
|
--target-signer //WithMillauTokenSwap \
|
||||||
--target-balance 200000 \
|
--target-balance 200000 \
|
||||||
|
--target-to-source-conversion-rate-override metric \
|
||||||
|
--source-to-target-conversion-rate-override metric \
|
||||||
lock-until-block \
|
lock-until-block \
|
||||||
--blocks-before-expire 32
|
--blocks-before-expire 32
|
||||||
done
|
done
|
||||||
|
|||||||
+124
-37
@@ -99,7 +99,7 @@
|
|||||||
"steppedLine": false,
|
"steppedLine": false,
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"expr": "max(Westend_to_Millau_Sync_best_block_numbers{node=\"source\"}) - max(Westend_to_Millau_Sync_best_block_numbers{node=\"target\"})",
|
"expr": "max(Westend_to_Millau_Sync_best_source_block_number) - max(Westend_to_Millau_Sync_best_source_at_target_block_number)",
|
||||||
"format": "table",
|
"format": "table",
|
||||||
"instant": false,
|
"instant": false,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
@@ -237,7 +237,7 @@
|
|||||||
"steppedLine": false,
|
"steppedLine": false,
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"expr": "max_over_time(Westend_to_Millau_Sync_best_block_numbers{node=\"source\"}[10m])-min_over_time(Westend_to_Millau_Sync_best_block_numbers{node=\"source\"}[10m])",
|
"expr": "max_over_time(Westend_to_Millau_Sync_best_source_block_number[10m])-min_over_time(Westend_to_Millau_Sync_best_source_block_number[10m])",
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "Number of new Headers on Westend (Last 10 Mins)",
|
"legendFormat": "Number of new Headers on Westend (Last 10 Mins)",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -341,13 +341,22 @@
|
|||||||
"pluginVersion": "7.1.3",
|
"pluginVersion": "7.1.3",
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"expr": "Westend_to_Millau_Sync_best_block_numbers",
|
"expr": "Westend_to_Millau_Sync_best_source_block_number",
|
||||||
"format": "time_series",
|
"format": "time_series",
|
||||||
"instant": true,
|
"instant": true,
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"intervalFactor": 1,
|
"intervalFactor": 1,
|
||||||
"legendFormat": "Best Known Header on {{node}} Node",
|
"legendFormat": "Best Known Westend Header at Westend",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "Westend_to_Millau_Sync_best_source_at_target_block_number",
|
||||||
|
"format": "time_series",
|
||||||
|
"instant": true,
|
||||||
|
"interval": "",
|
||||||
|
"intervalFactor": 1,
|
||||||
|
"legendFormat": "Best Known Westend Header at Millau",
|
||||||
|
"refId": "B"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"timeFrom": null,
|
"timeFrom": null,
|
||||||
@@ -513,61 +522,139 @@
|
|||||||
"type": "gauge"
|
"type": "gauge"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"alert": {
|
||||||
|
"alertRuleTags": {},
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"type": "gt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "and"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"A",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "max"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"executionErrorState": "alerting",
|
||||||
|
"for": "5m",
|
||||||
|
"frequency": "1m",
|
||||||
|
"handler": 1,
|
||||||
|
"name": "Whether with-Westend-grandpa-pallet and Westend itself are on different forks alert",
|
||||||
|
"noDataState": "no_data",
|
||||||
|
"notifications": []
|
||||||
|
},
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
"datasource": "Prometheus",
|
"datasource": "Prometheus",
|
||||||
"description": "",
|
|
||||||
"fieldConfig": {
|
"fieldConfig": {
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"custom": {},
|
"custom": {}
|
||||||
"mappings": [],
|
|
||||||
"thresholds": {
|
|
||||||
"mode": "absolute",
|
|
||||||
"steps": [
|
|
||||||
{
|
|
||||||
"color": "green",
|
|
||||||
"value": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"color": "red",
|
|
||||||
"value": 80
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"overrides": []
|
"overrides": []
|
||||||
},
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
"gridPos": {
|
"gridPos": {
|
||||||
"h": 10,
|
"h": 10,
|
||||||
"w": 12,
|
"w": 12,
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 14
|
"y": 14
|
||||||
},
|
},
|
||||||
"id": 4,
|
"hiddenSeries": false,
|
||||||
"options": {
|
"id": 18,
|
||||||
"displayMode": "gradient",
|
"legend": {
|
||||||
"orientation": "auto",
|
"avg": false,
|
||||||
"reduceOptions": {
|
"current": false,
|
||||||
"calcs": [
|
"max": false,
|
||||||
"mean"
|
"min": false,
|
||||||
],
|
"show": true,
|
||||||
"fields": "",
|
"total": false,
|
||||||
"values": false
|
"values": false
|
||||||
},
|
|
||||||
"showUnfilled": true
|
|
||||||
},
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"percentage": false,
|
||||||
"pluginVersion": "7.1.3",
|
"pluginVersion": "7.1.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"expr": "Westend_to_Millau_Sync_blocks_in_state",
|
"expr": "Westend_to_Millau_Sync_is_source_and_source_at_target_using_different_forks",
|
||||||
"instant": true,
|
|
||||||
"interval": "",
|
"interval": "",
|
||||||
"legendFormat": "{{state}}",
|
"legendFormat": "On different forks?",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"thresholds": [
|
||||||
|
{
|
||||||
|
"colorMode": "critical",
|
||||||
|
"fill": true,
|
||||||
|
"line": true,
|
||||||
|
"op": "gt",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
"timeFrom": null,
|
"timeFrom": null,
|
||||||
|
"timeRegions": [],
|
||||||
"timeShift": null,
|
"timeShift": null,
|
||||||
"title": "Queued Headers in Relay",
|
"title": "Whether with-Westend-grandpa-pallet and Westend itself are on different forks",
|
||||||
"type": "bargauge"
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"buckets": null,
|
||||||
|
"mode": "time",
|
||||||
|
"name": null,
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false,
|
||||||
|
"alignLevel": null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"aliasColors": {},
|
"aliasColors": {},
|
||||||
|
|||||||
+1
-3
@@ -1,9 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -xeu
|
set -xeu
|
||||||
|
|
||||||
sleep 60
|
sleep 15
|
||||||
curl -v http://millau-node-alice:9933/health
|
|
||||||
curl -v https://westend-rpc.polkadot.io:443/health
|
|
||||||
|
|
||||||
/home/user/substrate-relay init-bridge westend-to-millau \
|
/home/user/substrate-relay init-bridge westend-to-millau \
|
||||||
--source-host westend-rpc.polkadot.io \
|
--source-host westend-rpc.polkadot.io \
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ RIALTO_PORT="${RIALTO_PORT:-9944}"
|
|||||||
|
|
||||||
RUST_LOG=bridge=debug \
|
RUST_LOG=bridge=debug \
|
||||||
./target/debug/substrate-relay relay-messages millau-to-rialto \
|
./target/debug/substrate-relay relay-messages millau-to-rialto \
|
||||||
|
--relayer-mode=altruistic \
|
||||||
--lane 00000000 \
|
--lane 00000000 \
|
||||||
--source-host localhost \
|
--source-host localhost \
|
||||||
--source-port $MILLAU_PORT \
|
--source-port $MILLAU_PORT \
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ RIALTO_PORT="${RIALTO_PORT:-9944}"
|
|||||||
|
|
||||||
RUST_LOG=bridge=debug \
|
RUST_LOG=bridge=debug \
|
||||||
./target/debug/substrate-relay relay-messages rialto-to-millau \
|
./target/debug/substrate-relay relay-messages rialto-to-millau \
|
||||||
|
--relayer-mode=altruistic \
|
||||||
--lane 00000000 \
|
--lane 00000000 \
|
||||||
--source-host localhost \
|
--source-host localhost \
|
||||||
--source-port $RIALTO_PORT \
|
--source-port $RIALTO_PORT \
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ RUST_LOG=bridge=debug \
|
|||||||
--target-host localhost \
|
--target-host localhost \
|
||||||
--target-port $RIALTO_PORT \
|
--target-port $RIALTO_PORT \
|
||||||
--target-signer //Alice \
|
--target-signer //Alice \
|
||||||
|
--source-version-mode Bundle \
|
||||||
|
--target-version-mode Bundle
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
RUST_LOG=bridge=debug \
|
RUST_LOG=bridge=debug \
|
||||||
|
|||||||
@@ -0,0 +1,539 @@
|
|||||||
|
{
|
||||||
|
"annotations": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"builtIn": 1,
|
||||||
|
"datasource": "-- Grafana --",
|
||||||
|
"enable": true,
|
||||||
|
"hide": true,
|
||||||
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
|
"name": "Annotations & Alerts",
|
||||||
|
"type": "dashboard"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"editable": true,
|
||||||
|
"gnetId": null,
|
||||||
|
"graphTooltip": 0,
|
||||||
|
"links": [],
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"alert": {
|
||||||
|
"alertRuleTags": {},
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"type": "lt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "and"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"C",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "max"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"executionErrorState": "alerting",
|
||||||
|
"for": "5m",
|
||||||
|
"frequency": "1m",
|
||||||
|
"handler": 1,
|
||||||
|
"name": "Beefy best blocks not advancing",
|
||||||
|
"noDataState": "no_data",
|
||||||
|
"notifications": []
|
||||||
|
},
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": "Prometheus",
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {
|
||||||
|
"align": null
|
||||||
|
},
|
||||||
|
"mappings": [],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 14,
|
||||||
|
"w": 12,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 2,
|
||||||
|
"legend": {
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "7.1.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "polkadot_beefy_best_block",
|
||||||
|
"legendFormat": "Rialto(Charlie)",
|
||||||
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "substrate_beefy_best_block",
|
||||||
|
"legendFormat": "Millau(Charlie)",
|
||||||
|
"refId": "B"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "max_over_time(substrate_beefy_best_block[5m]) - min_over_time(substrate_beefy_best_block[5m])",
|
||||||
|
"hide": true,
|
||||||
|
"legendFormat": "Millau Best Beefy blocks count in last 5 minutes",
|
||||||
|
"refId": "C"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "max_over_time(polkadot_beefy_best_block[5m]) - min_over_time(polkadot_beefy_best_block[5m])",
|
||||||
|
"hide": true,
|
||||||
|
"legendFormat": "Rialto Best Beefy blocks count in last 5 minutes",
|
||||||
|
"refId": "D"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [
|
||||||
|
{
|
||||||
|
"colorMode": "critical",
|
||||||
|
"fill": true,
|
||||||
|
"line": true,
|
||||||
|
"op": "lt",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timeFrom": null,
|
||||||
|
"timeRegions": [],
|
||||||
|
"timeShift": null,
|
||||||
|
"title": "Beefy Best block",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"buckets": null,
|
||||||
|
"mode": "time",
|
||||||
|
"name": null,
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false,
|
||||||
|
"alignLevel": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": "Prometheus",
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {},
|
||||||
|
"mappings": [],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "yellow",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "yellow",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 14,
|
||||||
|
"w": 11,
|
||||||
|
"x": 12,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 4,
|
||||||
|
"options": {
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area",
|
||||||
|
"justifyMode": "auto",
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"mean"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"textMode": "auto"
|
||||||
|
},
|
||||||
|
"pluginVersion": "7.1.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "polkadot_beefy_should_vote_on",
|
||||||
|
"legendFormat": "Rialto(Charlie) Should-Vote-On",
|
||||||
|
"refId": "C"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "polkadot_beefy_round_concluded",
|
||||||
|
"legendFormat": "Rialto(Charlie) Round-Concluded",
|
||||||
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "substrate_beefy_should_vote_on",
|
||||||
|
"legendFormat": "Millau(Charlie) Should-Vote-On",
|
||||||
|
"refId": "D"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "substrate_beefy_round_concluded",
|
||||||
|
"legendFormat": "Millau(Charlie) Round-Concluded",
|
||||||
|
"refId": "B"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timeFrom": null,
|
||||||
|
"timeShift": null,
|
||||||
|
"title": "Beefy Voting Rounds",
|
||||||
|
"type": "stat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": "Prometheus",
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 18,
|
||||||
|
"x": 0,
|
||||||
|
"y": 14
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 6,
|
||||||
|
"legend": {
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "7.1.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "polkadot_beefy_votes_sent",
|
||||||
|
"legendFormat": "Rialto (node Charlie)",
|
||||||
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "substrate_beefy_votes_sent",
|
||||||
|
"legendFormat": "Millau (node Charlie)",
|
||||||
|
"refId": "B"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [],
|
||||||
|
"timeFrom": null,
|
||||||
|
"timeRegions": [],
|
||||||
|
"timeShift": null,
|
||||||
|
"title": "Beefy Votes Sent",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"buckets": null,
|
||||||
|
"mode": "time",
|
||||||
|
"name": null,
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false,
|
||||||
|
"alignLevel": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alert": {
|
||||||
|
"alertRuleTags": {},
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"evaluator": {
|
||||||
|
"params": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"type": "gt"
|
||||||
|
},
|
||||||
|
"operator": {
|
||||||
|
"type": "or"
|
||||||
|
},
|
||||||
|
"query": {
|
||||||
|
"params": [
|
||||||
|
"B",
|
||||||
|
"5m",
|
||||||
|
"now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"reducer": {
|
||||||
|
"params": [],
|
||||||
|
"type": "max"
|
||||||
|
},
|
||||||
|
"type": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"executionErrorState": "alerting",
|
||||||
|
"for": "5m",
|
||||||
|
"frequency": "1m",
|
||||||
|
"handler": 1,
|
||||||
|
"name": "Beefy Skipped Sessions alert",
|
||||||
|
"noDataState": "no_data",
|
||||||
|
"notifications": []
|
||||||
|
},
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": "Prometheus",
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {
|
||||||
|
"align": null
|
||||||
|
},
|
||||||
|
"mappings": [],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 8,
|
||||||
|
"w": 5,
|
||||||
|
"x": 18,
|
||||||
|
"y": 14
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 8,
|
||||||
|
"legend": {
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "7.1.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "polkadot_beefy_skipped_sessions",
|
||||||
|
"legendFormat": "Rialto(Charlie)",
|
||||||
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "substrate_beefy_skipped_sessions",
|
||||||
|
"legendFormat": "Millau(Charlie)",
|
||||||
|
"refId": "B"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [
|
||||||
|
{
|
||||||
|
"colorMode": "critical",
|
||||||
|
"fill": true,
|
||||||
|
"line": true,
|
||||||
|
"op": "gt",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timeFrom": null,
|
||||||
|
"timeRegions": [],
|
||||||
|
"timeShift": null,
|
||||||
|
"title": "Beefy Skipped Sessions",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"buckets": null,
|
||||||
|
"mode": "time",
|
||||||
|
"name": null,
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"label": null,
|
||||||
|
"logBase": 1,
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false,
|
||||||
|
"alignLevel": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"refresh": "5s",
|
||||||
|
"schemaVersion": 26,
|
||||||
|
"style": "dark",
|
||||||
|
"tags": [],
|
||||||
|
"templating": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"time": {
|
||||||
|
"from": "now-5m",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
|
"timepicker": {
|
||||||
|
"refresh_intervals": [
|
||||||
|
"5s",
|
||||||
|
"10s",
|
||||||
|
"30s",
|
||||||
|
"1m",
|
||||||
|
"5m",
|
||||||
|
"15m",
|
||||||
|
"30m",
|
||||||
|
"1h",
|
||||||
|
"2h",
|
||||||
|
"1d"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timezone": "",
|
||||||
|
"title": "Beefy",
|
||||||
|
"uid": "j6cRDRh7z",
|
||||||
|
"version": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
- targets:
|
||||||
|
- millau-node-charlie:9615
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
- targets:
|
||||||
|
- rialto-node-charlie:9615
|
||||||
+1
-3
@@ -1,9 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -xeu
|
set -xeu
|
||||||
|
|
||||||
sleep 60
|
sleep 15
|
||||||
curl -v http://rialto-node-alice:9933/health
|
|
||||||
curl -v http://rialto-parachain-collator-alice:9933/health
|
|
||||||
|
|
||||||
/home/user/substrate-relay register-parachain rialto-parachain \
|
/home/user/substrate-relay register-parachain rialto-parachain \
|
||||||
--parachain-host rialto-parachain-collator-alice \
|
--parachain-host rialto-parachain-collator-alice \
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ services:
|
|||||||
- --alice
|
- --alice
|
||||||
- --node-key=0f900c89f4e626f4a217302ab8c7d213737d00627115f318ad6fb169717ac8e0
|
- --node-key=0f900c89f4e626f4a217302ab8c7d213737d00627115f318ad6fb169717ac8e0
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
environment:
|
environment:
|
||||||
@@ -35,6 +36,7 @@ services:
|
|||||||
- --bob
|
- --bob
|
||||||
- --node-key=db383639ff2905d79f8e936fd5dc4416ef46b514b2f83823ec3c42753d7557bb
|
- --node-key=db383639ff2905d79f8e936fd5dc4416ef46b514b2f83823ec3c42753d7557bb
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
ports:
|
ports:
|
||||||
@@ -50,11 +52,14 @@ services:
|
|||||||
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
|
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
|
||||||
- --charlie
|
- --charlie
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
|
- --prometheus-external
|
||||||
ports:
|
ports:
|
||||||
- "20133:9933"
|
- "20133:9933"
|
||||||
- "20144:9944"
|
- "20144:9944"
|
||||||
|
- "20615:9615"
|
||||||
|
|
||||||
millau-node-dave:
|
millau-node-dave:
|
||||||
<<: *millau-bridge-node
|
<<: *millau-bridge-node
|
||||||
@@ -65,6 +70,7 @@ services:
|
|||||||
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
|
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
|
||||||
- --dave
|
- --dave
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
ports:
|
ports:
|
||||||
@@ -80,8 +86,16 @@ services:
|
|||||||
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
|
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
|
||||||
- --eve
|
- --eve
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
ports:
|
ports:
|
||||||
- "20333:9933"
|
- "20333:9933"
|
||||||
- "20344:9944"
|
- "20344:9944"
|
||||||
|
|
||||||
|
# Note: These are being overridden from the top level `monitoring` compose file.
|
||||||
|
prometheus-metrics:
|
||||||
|
volumes:
|
||||||
|
- ./networks/dashboard/prometheus/millau-targets.yml:/etc/prometheus/targets-millau-nodes.yml
|
||||||
|
depends_on:
|
||||||
|
- millau-node-charlie
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ services:
|
|||||||
- --alice
|
- --alice
|
||||||
- --node-key=79cf382988364291a7968ae7825c01f68c50d679796a8983237d07fe0ccf363b
|
- --node-key=79cf382988364291a7968ae7825c01f68c50d679796a8983237d07fe0ccf363b
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
environment:
|
environment:
|
||||||
@@ -35,6 +36,7 @@ services:
|
|||||||
- --bob
|
- --bob
|
||||||
- --node-key=4f9d0146dd9b7b3bf5a8089e3880023d1df92057f89e96e07bb4d8c2ead75bbd
|
- --node-key=4f9d0146dd9b7b3bf5a8089e3880023d1df92057f89e96e07bb4d8c2ead75bbd
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
ports:
|
ports:
|
||||||
@@ -50,11 +52,14 @@ services:
|
|||||||
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
|
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
|
||||||
- --charlie
|
- --charlie
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
|
- --prometheus-external
|
||||||
ports:
|
ports:
|
||||||
- "10133:9933"
|
- "10133:9933"
|
||||||
- "10144:9944"
|
- "10144:9944"
|
||||||
|
- "10615:9615"
|
||||||
|
|
||||||
rialto-node-dave:
|
rialto-node-dave:
|
||||||
<<: *rialto-bridge-node
|
<<: *rialto-bridge-node
|
||||||
@@ -65,6 +70,7 @@ services:
|
|||||||
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
|
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
|
||||||
- --dave
|
- --dave
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
ports:
|
ports:
|
||||||
@@ -80,6 +86,7 @@ services:
|
|||||||
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
|
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
|
||||||
- --eve
|
- --eve
|
||||||
- --rpc-cors=all
|
- --rpc-cors=all
|
||||||
|
- --enable-offchain-indexing=true
|
||||||
- --unsafe-rpc-external
|
- --unsafe-rpc-external
|
||||||
- --unsafe-ws-external
|
- --unsafe-ws-external
|
||||||
ports:
|
ports:
|
||||||
@@ -93,6 +100,13 @@ services:
|
|||||||
- ./networks/entrypoints:/entrypoints
|
- ./networks/entrypoints:/entrypoints
|
||||||
- rialto-share:/rialto-share:z
|
- rialto-share:/rialto-share:z
|
||||||
|
|
||||||
|
# Note: These are being overridden from the top level `monitoring` compose file.
|
||||||
|
prometheus-metrics:
|
||||||
|
volumes:
|
||||||
|
- ./networks/dashboard/prometheus/rialto-targets.yml:/etc/prometheus/targets-rialto-nodes.yml
|
||||||
|
depends_on:
|
||||||
|
- rialto-node-charlie
|
||||||
|
|
||||||
# we're using `/rialto-share` to expose Rialto chain spec to those who are interested. Right
|
# we're using `/rialto-share` to expose Rialto chain spec to those who are interested. Right
|
||||||
# now it is Rialto Parachain collator nodes. Local + tmpfs combination allows sharing writable
|
# now it is Rialto Parachain collator nodes. Local + tmpfs combination allows sharing writable
|
||||||
# in-memory volumes, which are dropped when containers are stopped.
|
# in-memory volumes, which are dropped when containers are stopped.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name = "storage-proof-fuzzer"
|
name = "storage-proof-fuzzer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@@ -19,6 +19,7 @@ bp-runtime = { path = "../../primitives/runtime" }
|
|||||||
# Substrate Dependencies
|
# Substrate Dependencies
|
||||||
|
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ fn craft_known_storage_proof(input_vec: Vec<(Vec<u8>, Vec<u8>)>) -> (H256, Stora
|
|||||||
let storage_proof_vec =
|
let storage_proof_vec =
|
||||||
vec![(None, input_vec.iter().map(|x| (x.0.clone(), Some(x.1.clone()))).collect())];
|
vec![(None, input_vec.iter().map(|x| (x.0.clone(), Some(x.1.clone()))).collect())];
|
||||||
log::info!("Storage proof vec {:?}", storage_proof_vec);
|
log::info!("Storage proof vec {:?}", storage_proof_vec);
|
||||||
let backend = <InMemoryBackend<Blake2Hasher>>::from(storage_proof_vec);
|
let state_version = sp_runtime::StateVersion::default();
|
||||||
let root = backend.storage_root(std::iter::empty()).0;
|
let backend = <InMemoryBackend<Blake2Hasher>>::from((storage_proof_vec, state_version));
|
||||||
|
let root = backend.storage_root(std::iter::empty(), state_version).0;
|
||||||
let vector_element_proof = StorageProof::new(
|
let vector_element_proof = StorageProof::new(
|
||||||
prove_read(backend, input_vec.iter().map(|x| x.0.as_slice()))
|
prove_read(backend, input_vec.iter().map(|x| x.0.as_slice()))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ name = "pallet-bridge-dispatch"
|
|||||||
description = "A Substrate Runtime module that dispatches a bridge message, treating it simply as encoded Call"
|
description = "A Substrate Runtime module that dispatches a bridge message, treating it simply as encoded Call"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
||||||
log = { version = "0.4.14", default-features = false }
|
log = { version = "0.4.14", default-features = false }
|
||||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
|
|
||||||
# Bridge dependencies
|
# Bridge dependencies
|
||||||
|
|
||||||
|
|||||||
@@ -649,8 +649,7 @@ mod tests {
|
|||||||
fn should_fail_on_weight_mismatch() {
|
fn should_fail_on_weight_mismatch() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
let id = [0; 4];
|
let id = [0; 4];
|
||||||
let call =
|
let call = Call::System(frame_system::Call::set_heap_pages { pages: 42 });
|
||||||
Call::System(frame_system::Call::remark_with_event { remark: vec![1, 2, 3] });
|
|
||||||
let call_weight = call.get_dispatch_info().weight;
|
let call_weight = call.get_dispatch_info().weight;
|
||||||
let mut message = prepare_root_message(call);
|
let mut message = prepare_root_message(call);
|
||||||
message.weight = 7;
|
message.weight = 7;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name = "pallet-bridge-grandpa"
|
name = "pallet-bridge-grandpa"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@@ -12,7 +12,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
|
|||||||
finality-grandpa = { version = "0.15.0", default-features = false }
|
finality-grandpa = { version = "0.15.0", default-features = false }
|
||||||
log = { version = "0.4.14", default-features = false }
|
log = { version = "0.4.14", default-features = false }
|
||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
serde = { version = "1.0", optional = true }
|
serde = { version = "1.0", optional = true }
|
||||||
|
|
||||||
# Bridge Dependencies
|
# Bridge Dependencies
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ pub mod pallet {
|
|||||||
/// runtime methods may still be used to do that (i.e. democracy::referendum to update halt
|
/// runtime methods may still be used to do that (i.e. democracy::referendum to update halt
|
||||||
/// flag directly or call the `halt_operations`).
|
/// flag directly or call the `halt_operations`).
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
pub(super) type PalletOwner<T: Config<I>, I: 'static = ()> =
|
pub type PalletOwner<T: Config<I>, I: 'static = ()> =
|
||||||
StorageValue<_, T::AccountId, OptionQuery>;
|
StorageValue<_, T::AccountId, OptionQuery>;
|
||||||
|
|
||||||
/// If true, all pallet transactions are failed immediately.
|
/// If true, all pallet transactions are failed immediately.
|
||||||
@@ -627,7 +627,10 @@ mod tests {
|
|||||||
JustificationGeneratorParams, ALICE, BOB,
|
JustificationGeneratorParams, ALICE, BOB,
|
||||||
};
|
};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use frame_support::{assert_err, assert_noop, assert_ok, weights::PostDispatchInfo};
|
use frame_support::{
|
||||||
|
assert_err, assert_noop, assert_ok, storage::generator::StorageValue,
|
||||||
|
weights::PostDispatchInfo,
|
||||||
|
};
|
||||||
use sp_runtime::{Digest, DigestItem, DispatchError};
|
use sp_runtime::{Digest, DigestItem, DispatchError};
|
||||||
|
|
||||||
fn initialize_substrate_bridge() {
|
fn initialize_substrate_bridge() {
|
||||||
@@ -1146,4 +1149,17 @@ mod tests {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn storage_keys_computed_properly() {
|
||||||
|
assert_eq!(
|
||||||
|
IsHalted::<TestRuntime>::storage_value_final_key().to_vec(),
|
||||||
|
bp_header_chain::storage_keys::is_halted_key("Grandpa").0,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
BestFinalized::<TestRuntime>::storage_value_final_key().to_vec(),
|
||||||
|
bp_header_chain::storage_keys::best_finalized_hash_key("Grandpa").0,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,13 @@ impl Chain for TestBridgedChain {
|
|||||||
type Balance = u64;
|
type Balance = u64;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type Signature = Signature;
|
type Signature = Signature;
|
||||||
|
|
||||||
|
fn max_extrinsic_size() -> u32 {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
fn max_extrinsic_weight() -> Weight {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_test<T>(test: impl FnOnce() -> T) -> T {
|
pub fn run_test<T>(test: impl FnOnce() -> T) -> T {
|
||||||
|
|||||||
@@ -16,14 +16,14 @@
|
|||||||
|
|
||||||
//! Autogenerated weights for `pallet_bridge_grandpa`
|
//! Autogenerated weights for `pallet_bridge_grandpa`
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2021-06-03, STEPS: [50, ], REPEAT: 20
|
//! DATE: 2021-12-28, STEPS: 50, REPEAT: 20
|
||||||
//! LOW RANGE: [], HIGH RANGE: []
|
//! LOW RANGE: [], HIGH RANGE: []
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
||||||
//! CHAIN: Some("dev"), DB CACHE: 128
|
//! CHAIN: Some("dev"), DB CACHE: 128
|
||||||
|
|
||||||
// Executed Command:
|
// Executed Command:
|
||||||
// target/release/rialto-bridge-node
|
// target/release/millau-bridge-node
|
||||||
// benchmark
|
// benchmark
|
||||||
// --chain=dev
|
// --chain=dev
|
||||||
// --steps=50
|
// --steps=50
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
// --wasm-execution=Compiled
|
// --wasm-execution=Compiled
|
||||||
// --heap-pages=4096
|
// --heap-pages=4096
|
||||||
// --output=./modules/grandpa/src/weights.rs
|
// --output=./modules/grandpa/src/weights.rs
|
||||||
// --template=./.maintain/rialto-weight-template.hbs
|
// --template=./.maintain/millau-weight-template.hbs
|
||||||
|
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
#![allow(unused_parens)]
|
#![allow(unused_parens)]
|
||||||
@@ -51,13 +51,13 @@ pub trait WeightInfo {
|
|||||||
fn submit_finality_proof(p: u32, v: u32) -> Weight;
|
fn submit_finality_proof(p: u32, v: u32) -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Weights for `pallet_bridge_grandpa` using the Rialto node and recommended hardware.
|
/// Weights for `pallet_bridge_grandpa` using the Millau node and recommended hardware.
|
||||||
pub struct RialtoWeight<T>(PhantomData<T>);
|
pub struct MillauWeight<T>(PhantomData<T>);
|
||||||
impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
||||||
fn submit_finality_proof(p: u32, v: u32) -> Weight {
|
fn submit_finality_proof(p: u32, v: u32) -> Weight {
|
||||||
(0 as Weight)
|
(115_651_000 as Weight)
|
||||||
.saturating_add((59_692_000 as Weight).saturating_mul(p as Weight))
|
.saturating_add((61_465_000 as Weight).saturating_mul(p as Weight))
|
||||||
.saturating_add((6_876_000 as Weight).saturating_mul(v as Weight))
|
.saturating_add((3_438_000 as Weight).saturating_mul(v as Weight))
|
||||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(6 as Weight))
|
.saturating_add(T::DbWeight::get().writes(6 as Weight))
|
||||||
}
|
}
|
||||||
@@ -66,9 +66,9 @@ impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
|||||||
// For backwards compatibility and tests
|
// For backwards compatibility and tests
|
||||||
impl WeightInfo for () {
|
impl WeightInfo for () {
|
||||||
fn submit_finality_proof(p: u32, v: u32) -> Weight {
|
fn submit_finality_proof(p: u32, v: u32) -> Weight {
|
||||||
(0 as Weight)
|
(115_651_000 as Weight)
|
||||||
.saturating_add((59_692_000 as Weight).saturating_mul(p as Weight))
|
.saturating_add((61_465_000 as Weight).saturating_mul(p as Weight))
|
||||||
.saturating_add((6_876_000 as Weight).saturating_mul(v as Weight))
|
.saturating_add((3_438_000 as Weight).saturating_mul(v as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ name = "pallet-bridge-messages"
|
|||||||
description = "Module that allows bridged chains to exchange messages using lane concept."
|
description = "Module that allows bridged chains to exchange messages using lane concept."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
|
bitvec = { version = "1", default-features = false, features = ["alloc"] }
|
||||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
||||||
log = { version = "0.4.14", default-features = false }
|
log = { version = "0.4.14", default-features = false }
|
||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||||
|
|
||||||
# Bridge dependencies
|
# Bridge dependencies
|
||||||
@@ -30,8 +30,6 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master
|
|||||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex = "0.4"
|
|
||||||
hex-literal = "0.3"
|
|
||||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|
||||||
|
|||||||
@@ -294,9 +294,8 @@ Where:
|
|||||||
*\* - In all benchmarks all received messages are dispatched and their dispatch cost is near to zero*
|
*\* - In all benchmarks all received messages are dispatched and their dispatch cost is near to zero*
|
||||||
|
|
||||||
*\*\* - Trie leafs are assumed to have minimal values. The proof is derived from the minimal proof
|
*\*\* - Trie leafs are assumed to have minimal values. The proof is derived from the minimal proof
|
||||||
by including more trie nodes. That's because according to `receive_message_proofs_with_large_leaf`
|
by including more trie nodes. That's because according to our additioal benchmarks, increasing proof
|
||||||
and `receive_message_proofs_with_extra_nodes` benchmarks, increasing proof by including more nodes
|
by including more nodes has slightly larger impact on performance than increasing values stored in leafs*.
|
||||||
has slightly larger impact on performance than increasing values stored in leafs*.
|
|
||||||
|
|
||||||
#### Weight formula
|
#### Weight formula
|
||||||
|
|
||||||
|
|||||||
@@ -30,15 +30,7 @@ use bp_runtime::messages::DispatchFeePayment;
|
|||||||
use frame_benchmarking::{account, benchmarks_instance_pallet};
|
use frame_benchmarking::{account, benchmarks_instance_pallet};
|
||||||
use frame_support::{traits::Get, weights::Weight};
|
use frame_support::{traits::Get, weights::Weight};
|
||||||
use frame_system::RawOrigin;
|
use frame_system::RawOrigin;
|
||||||
use sp_std::{
|
use sp_std::{collections::vec_deque::VecDeque, convert::TryInto, ops::RangeInclusive, prelude::*};
|
||||||
collections::{btree_map::BTreeMap, vec_deque::VecDeque},
|
|
||||||
convert::TryInto,
|
|
||||||
ops::RangeInclusive,
|
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Fee paid by submitter for single message delivery.
|
|
||||||
pub const MESSAGE_FEE: u64 = 100_000_000_000;
|
|
||||||
|
|
||||||
const SEED: u32 = 0;
|
const SEED: u32 = 0;
|
||||||
|
|
||||||
@@ -46,6 +38,7 @@ const SEED: u32 = 0;
|
|||||||
pub struct Pallet<T: Config<I>, I: 'static>(crate::Pallet<T, I>);
|
pub struct Pallet<T: Config<I>, I: 'static>(crate::Pallet<T, I>);
|
||||||
|
|
||||||
/// Proof size requirements.
|
/// Proof size requirements.
|
||||||
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum ProofSize {
|
pub enum ProofSize {
|
||||||
/// The proof is expected to be minimal. If value size may be changed, then it is expected to
|
/// The proof is expected to be minimal. If value size may be changed, then it is expected to
|
||||||
/// have given size.
|
/// have given size.
|
||||||
@@ -59,6 +52,7 @@ pub enum ProofSize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Benchmark-specific message parameters.
|
/// Benchmark-specific message parameters.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct MessageParams<ThisAccountId> {
|
pub struct MessageParams<ThisAccountId> {
|
||||||
/// Size of the message payload.
|
/// Size of the message payload.
|
||||||
pub size: u32,
|
pub size: u32,
|
||||||
@@ -67,6 +61,7 @@ pub struct MessageParams<ThisAccountId> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Benchmark-specific message proof parameters.
|
/// Benchmark-specific message proof parameters.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct MessageProofParams {
|
pub struct MessageProofParams {
|
||||||
/// Id of the lane.
|
/// Id of the lane.
|
||||||
pub lane: LaneId,
|
pub lane: LaneId,
|
||||||
@@ -81,6 +76,7 @@ pub struct MessageProofParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Benchmark-specific message delivery proof parameters.
|
/// Benchmark-specific message delivery proof parameters.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct MessageDeliveryProofParams<ThisChainAccountId> {
|
pub struct MessageDeliveryProofParams<ThisChainAccountId> {
|
||||||
/// Id of the lane.
|
/// Id of the lane.
|
||||||
pub lane: LaneId,
|
pub lane: LaneId,
|
||||||
@@ -104,6 +100,10 @@ pub trait Config<I: 'static>: crate::Config<I> {
|
|||||||
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee;
|
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee;
|
||||||
/// Create given account and give it enough balance for test purposes.
|
/// Create given account and give it enough balance for test purposes.
|
||||||
fn endow_account(account: &Self::AccountId);
|
fn endow_account(account: &Self::AccountId);
|
||||||
|
/// Fee paid by submitter for single message delivery.
|
||||||
|
fn message_fee() -> Self::OutboundMessageFee {
|
||||||
|
100_000_000_000_000.into()
|
||||||
|
}
|
||||||
/// Prepare message to send over lane.
|
/// Prepare message to send over lane.
|
||||||
fn prepare_outbound_message(
|
fn prepare_outbound_message(
|
||||||
params: MessageParams<Self::AccountId>,
|
params: MessageParams<Self::AccountId>,
|
||||||
@@ -139,8 +139,10 @@ benchmarks_instance_pallet! {
|
|||||||
// added.
|
// added.
|
||||||
send_minimal_message_worst_case {
|
send_minimal_message_worst_case {
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
|
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||||
let sender = account("sender", 0, SEED);
|
let sender = account("sender", 0, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
|
T::endow_account(&relayers_fund_id);
|
||||||
|
|
||||||
// 'send' messages that are to be pruned when our message is sent
|
// 'send' messages that are to be pruned when our message is sent
|
||||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||||
@@ -155,7 +157,7 @@ benchmarks_instance_pallet! {
|
|||||||
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
|
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::Pallet::<T, I>::outbound_latest_generated_nonce(T::bench_lane_id()),
|
crate::OutboundLanes::<T, I>::get(&T::bench_lane_id()).latest_generated_nonce,
|
||||||
T::MaxMessagesToPruneAtOnce::get() + 1,
|
T::MaxMessagesToPruneAtOnce::get() + 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -170,8 +172,10 @@ benchmarks_instance_pallet! {
|
|||||||
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
||||||
send_1_kb_message_worst_case {
|
send_1_kb_message_worst_case {
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
|
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||||
let sender = account("sender", 0, SEED);
|
let sender = account("sender", 0, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
|
T::endow_account(&relayers_fund_id);
|
||||||
|
|
||||||
// 'send' messages that are to be pruned when our message is sent
|
// 'send' messages that are to be pruned when our message is sent
|
||||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||||
@@ -192,7 +196,7 @@ benchmarks_instance_pallet! {
|
|||||||
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
|
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::Pallet::<T, I>::outbound_latest_generated_nonce(T::bench_lane_id()),
|
crate::OutboundLanes::<T, I>::get(&T::bench_lane_id()).latest_generated_nonce,
|
||||||
T::MaxMessagesToPruneAtOnce::get() + 1,
|
T::MaxMessagesToPruneAtOnce::get() + 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -207,8 +211,10 @@ benchmarks_instance_pallet! {
|
|||||||
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
||||||
send_16_kb_message_worst_case {
|
send_16_kb_message_worst_case {
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
|
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||||
let sender = account("sender", 0, SEED);
|
let sender = account("sender", 0, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
|
T::endow_account(&relayers_fund_id);
|
||||||
|
|
||||||
// 'send' messages that are to be pruned when our message is sent
|
// 'send' messages that are to be pruned when our message is sent
|
||||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||||
@@ -229,7 +235,7 @@ benchmarks_instance_pallet! {
|
|||||||
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
|
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::Pallet::<T, I>::outbound_latest_generated_nonce(T::bench_lane_id()),
|
crate::OutboundLanes::<T, I>::get(&T::bench_lane_id()).latest_generated_nonce,
|
||||||
T::MaxMessagesToPruneAtOnce::get() + 1,
|
T::MaxMessagesToPruneAtOnce::get() + 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -240,8 +246,10 @@ benchmarks_instance_pallet! {
|
|||||||
//
|
//
|
||||||
// Result of this benchmark is directly used by weight formula of the call.
|
// Result of this benchmark is directly used by weight formula of the call.
|
||||||
maximal_increase_message_fee {
|
maximal_increase_message_fee {
|
||||||
|
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||||
let sender = account("sender", 42, SEED);
|
let sender = account("sender", 42, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
|
T::endow_account(&relayers_fund_id);
|
||||||
|
|
||||||
let additional_fee = T::account_balance(&sender);
|
let additional_fee = T::account_balance(&sender);
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
@@ -259,8 +267,10 @@ benchmarks_instance_pallet! {
|
|||||||
increase_message_fee {
|
increase_message_fee {
|
||||||
let i in 0..T::maximal_message_size().try_into().unwrap_or_default();
|
let i in 0..T::maximal_message_size().try_into().unwrap_or_default();
|
||||||
|
|
||||||
|
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||||
let sender = account("sender", 42, SEED);
|
let sender = account("sender", 42, SEED);
|
||||||
T::endow_account(&sender);
|
T::endow_account(&sender);
|
||||||
|
T::endow_account(&relayers_fund_id);
|
||||||
|
|
||||||
let additional_fee = T::account_balance(&sender);
|
let additional_fee = T::account_balance(&sender);
|
||||||
let lane_id = T::bench_lane_id();
|
let lane_id = T::bench_lane_id();
|
||||||
@@ -283,6 +293,7 @@ benchmarks_instance_pallet! {
|
|||||||
receive_single_message_proof {
|
receive_single_message_proof {
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
let relayer_id_on_source = T::bridged_relayer_id();
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
let relayer_id_on_target = account("relayer", 0, SEED);
|
||||||
|
T::endow_account(&relayer_id_on_target);
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
// mark messages 1..=20 as delivered
|
||||||
receive_messages::<T, I>(20);
|
receive_messages::<T, I>(20);
|
||||||
@@ -297,7 +308,7 @@ benchmarks_instance_pallet! {
|
|||||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||||
21,
|
21,
|
||||||
);
|
);
|
||||||
assert!(T::is_message_dispatched(21));
|
assert!(T::is_message_dispatched(21));
|
||||||
@@ -317,6 +328,7 @@ benchmarks_instance_pallet! {
|
|||||||
receive_two_messages_proof {
|
receive_two_messages_proof {
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
let relayer_id_on_source = T::bridged_relayer_id();
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
let relayer_id_on_target = account("relayer", 0, SEED);
|
||||||
|
T::endow_account(&relayer_id_on_target);
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
// mark messages 1..=20 as delivered
|
||||||
receive_messages::<T, I>(20);
|
receive_messages::<T, I>(20);
|
||||||
@@ -331,7 +343,7 @@ benchmarks_instance_pallet! {
|
|||||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 2, dispatch_weight)
|
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 2, dispatch_weight)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||||
22,
|
22,
|
||||||
);
|
);
|
||||||
assert!(T::is_message_dispatched(22));
|
assert!(T::is_message_dispatched(22));
|
||||||
@@ -351,6 +363,7 @@ benchmarks_instance_pallet! {
|
|||||||
receive_single_message_proof_with_outbound_lane_state {
|
receive_single_message_proof_with_outbound_lane_state {
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
let relayer_id_on_source = T::bridged_relayer_id();
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
let relayer_id_on_target = account("relayer", 0, SEED);
|
||||||
|
T::endow_account(&relayer_id_on_target);
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
// mark messages 1..=20 as delivered
|
||||||
receive_messages::<T, I>(20);
|
receive_messages::<T, I>(20);
|
||||||
@@ -368,14 +381,9 @@ benchmarks_instance_pallet! {
|
|||||||
});
|
});
|
||||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
let lane_state = crate::InboundLanes::<T, I>::get(&T::bench_lane_id());
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
assert_eq!(lane_state.last_delivered_nonce(), 21);
|
||||||
21,
|
assert_eq!(lane_state.last_confirmed_nonce, 20);
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
crate::Pallet::<T, I>::inbound_latest_confirmed_nonce(T::bench_lane_id()),
|
|
||||||
20,
|
|
||||||
);
|
|
||||||
assert!(T::is_message_dispatched(21));
|
assert!(T::is_message_dispatched(21));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,6 +399,7 @@ benchmarks_instance_pallet! {
|
|||||||
receive_single_message_proof_1_kb {
|
receive_single_message_proof_1_kb {
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
let relayer_id_on_source = T::bridged_relayer_id();
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
let relayer_id_on_target = account("relayer", 0, SEED);
|
||||||
|
T::endow_account(&relayer_id_on_target);
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
// mark messages 1..=20 as delivered
|
||||||
receive_messages::<T, I>(20);
|
receive_messages::<T, I>(20);
|
||||||
@@ -405,7 +414,7 @@ benchmarks_instance_pallet! {
|
|||||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||||
21,
|
21,
|
||||||
);
|
);
|
||||||
assert!(T::is_message_dispatched(21));
|
assert!(T::is_message_dispatched(21));
|
||||||
@@ -425,6 +434,7 @@ benchmarks_instance_pallet! {
|
|||||||
receive_single_message_proof_16_kb {
|
receive_single_message_proof_16_kb {
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
let relayer_id_on_source = T::bridged_relayer_id();
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
let relayer_id_on_target = account("relayer", 0, SEED);
|
||||||
|
T::endow_account(&relayer_id_on_target);
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
// mark messages 1..=20 as delivered
|
||||||
receive_messages::<T, I>(20);
|
receive_messages::<T, I>(20);
|
||||||
@@ -439,7 +449,7 @@ benchmarks_instance_pallet! {
|
|||||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||||
21,
|
21,
|
||||||
);
|
);
|
||||||
assert!(T::is_message_dispatched(21));
|
assert!(T::is_message_dispatched(21));
|
||||||
@@ -458,6 +468,7 @@ benchmarks_instance_pallet! {
|
|||||||
receive_single_prepaid_message_proof {
|
receive_single_prepaid_message_proof {
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
let relayer_id_on_source = T::bridged_relayer_id();
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
let relayer_id_on_target = account("relayer", 0, SEED);
|
||||||
|
T::endow_account(&relayer_id_on_target);
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
// mark messages 1..=20 as delivered
|
||||||
receive_messages::<T, I>(20);
|
receive_messages::<T, I>(20);
|
||||||
@@ -472,7 +483,7 @@ benchmarks_instance_pallet! {
|
|||||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||||
21,
|
21,
|
||||||
);
|
);
|
||||||
assert!(T::is_message_dispatched(21));
|
assert!(T::is_message_dispatched(21));
|
||||||
@@ -512,7 +523,7 @@ benchmarks_instance_pallet! {
|
|||||||
verify {
|
verify {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
T::account_balance(&relayer_id),
|
T::account_balance(&relayer_id),
|
||||||
relayer_balance + MESSAGE_FEE.into(),
|
relayer_balance + T::message_fee(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,310 +613,16 @@ benchmarks_instance_pallet! {
|
|||||||
ensure_relayer_rewarded::<T, I>(&relayer1_id, &relayer1_balance);
|
ensure_relayer_rewarded::<T, I>(&relayer1_id, &relayer1_balance);
|
||||||
ensure_relayer_rewarded::<T, I>(&relayer2_id, &relayer2_balance);
|
ensure_relayer_rewarded::<T, I>(&relayer2_id, &relayer2_balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Benchmarks for manual checks.
|
|
||||||
//
|
|
||||||
|
|
||||||
// Benchmark `send_message` extrinsic with following conditions:
|
|
||||||
// * outbound lane already has state, so it needs to be read and decoded;
|
|
||||||
// * relayers fund account does not exists (in practice it needs to exist in production environment);
|
|
||||||
// * maximal number of messages is being pruned during the call;
|
|
||||||
// * message size varies from minimal to maximal for the target chain.
|
|
||||||
//
|
|
||||||
// Results of this benchmark may be used to check how message size affects `send_message` performance.
|
|
||||||
send_messages_of_various_lengths {
|
|
||||||
let i in 0..T::maximal_message_size().try_into().unwrap_or_default();
|
|
||||||
|
|
||||||
let lane_id = T::bench_lane_id();
|
|
||||||
let sender = account("sender", 0, SEED);
|
|
||||||
T::endow_account(&sender);
|
|
||||||
|
|
||||||
// 'send' messages that are to be pruned when our message is sent
|
|
||||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
|
||||||
send_regular_message::<T, I>();
|
|
||||||
}
|
|
||||||
confirm_message_delivery::<T, I>(T::MaxMessagesToPruneAtOnce::get());
|
|
||||||
|
|
||||||
let (payload, fee) = T::prepare_outbound_message(MessageParams {
|
|
||||||
size: i as _,
|
|
||||||
sender_account: sender.clone(),
|
|
||||||
});
|
|
||||||
}: send_message(RawOrigin::Signed(sender), lane_id, payload, fee)
|
|
||||||
verify {
|
|
||||||
assert_eq!(
|
|
||||||
crate::Pallet::<T, I>::outbound_latest_generated_nonce(T::bench_lane_id()),
|
|
||||||
T::MaxMessagesToPruneAtOnce::get() + 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Benchmark `receive_messages_proof` extrinsic with multiple minimal-weight messages and following conditions:
|
|
||||||
// * proof does not include outbound lane state proof;
|
|
||||||
// * inbound lane already has state, so it needs to be read and decoded;
|
|
||||||
// * message is successfully dispatched;
|
|
||||||
// * message requires all heavy checks done by dispatcher.
|
|
||||||
//
|
|
||||||
// This benchmarks gives us an approximation of single message delivery weight. It is similar to the
|
|
||||||
// `weight(receive_two_messages_proof) - weight(receive_single_message_proof)`. So it may be used
|
|
||||||
// to verify that the other approximation is correct.
|
|
||||||
receive_multiple_messages_proof {
|
|
||||||
let i in 1..64;
|
|
||||||
|
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
|
||||||
let messages_count = i as _;
|
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
|
||||||
receive_messages::<T, I>(20);
|
|
||||||
|
|
||||||
let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams {
|
|
||||||
lane: T::bench_lane_id(),
|
|
||||||
message_nonces: 21..=(20 + i as MessageNonce),
|
|
||||||
outbound_lane_data: None,
|
|
||||||
size: ProofSize::Minimal(EXPECTED_DEFAULT_MESSAGE_LENGTH),
|
|
||||||
dispatch_fee_payment: DispatchFeePayment::AtTargetChain,
|
|
||||||
});
|
|
||||||
}: receive_messages_proof(
|
|
||||||
RawOrigin::Signed(relayer_id_on_target),
|
|
||||||
relayer_id_on_source,
|
|
||||||
proof,
|
|
||||||
messages_count,
|
|
||||||
dispatch_weight
|
|
||||||
)
|
|
||||||
verify {
|
|
||||||
assert_eq!(
|
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
|
||||||
20 + i as MessageNonce,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following conditions:
|
|
||||||
// * proof does not include outbound lane state proof;
|
|
||||||
// * inbound lane already has state, so it needs to be read and decoded;
|
|
||||||
// * message is successfully dispatched;
|
|
||||||
// * message requires all heavy checks done by dispatcher.
|
|
||||||
//
|
|
||||||
// Results of this benchmark may be used to check how proof size affects `receive_message_proof` performance.
|
|
||||||
receive_message_proofs_with_extra_nodes {
|
|
||||||
let i in 0..T::maximal_message_size();
|
|
||||||
|
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
|
||||||
let messages_count = 1u32;
|
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
|
||||||
receive_messages::<T, I>(20);
|
|
||||||
|
|
||||||
let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams {
|
|
||||||
lane: T::bench_lane_id(),
|
|
||||||
message_nonces: 21..=21,
|
|
||||||
outbound_lane_data: None,
|
|
||||||
size: ProofSize::HasExtraNodes(i as _),
|
|
||||||
dispatch_fee_payment: DispatchFeePayment::AtTargetChain,
|
|
||||||
});
|
|
||||||
}: receive_messages_proof(
|
|
||||||
RawOrigin::Signed(relayer_id_on_target),
|
|
||||||
relayer_id_on_source,
|
|
||||||
proof,
|
|
||||||
messages_count,
|
|
||||||
dispatch_weight
|
|
||||||
)
|
|
||||||
verify {
|
|
||||||
assert_eq!(
|
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
|
||||||
21,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following conditions:
|
|
||||||
// * proof does not include outbound lane state proof;
|
|
||||||
// * inbound lane already has state, so it needs to be read and decoded;
|
|
||||||
// * message is successfully dispatched;
|
|
||||||
// * message requires all heavy checks done by dispatcher.
|
|
||||||
//
|
|
||||||
// Results of this benchmark may be used to check how message size affects `receive_message_proof` performance.
|
|
||||||
receive_message_proofs_with_large_leaf {
|
|
||||||
let i in 0..T::maximal_message_size();
|
|
||||||
|
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
|
||||||
let messages_count = 1u32;
|
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
|
||||||
receive_messages::<T, I>(20);
|
|
||||||
|
|
||||||
let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams {
|
|
||||||
lane: T::bench_lane_id(),
|
|
||||||
message_nonces: 21..=21,
|
|
||||||
outbound_lane_data: None,
|
|
||||||
size: ProofSize::HasLargeLeaf(i as _),
|
|
||||||
dispatch_fee_payment: DispatchFeePayment::AtTargetChain,
|
|
||||||
});
|
|
||||||
}: receive_messages_proof(
|
|
||||||
RawOrigin::Signed(relayer_id_on_target),
|
|
||||||
relayer_id_on_source,
|
|
||||||
proof,
|
|
||||||
messages_count,
|
|
||||||
dispatch_weight
|
|
||||||
)
|
|
||||||
verify {
|
|
||||||
assert_eq!(
|
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
|
||||||
21,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Benchmark `receive_messages_proof` extrinsic with multiple minimal-weight messages and following conditions:
|
|
||||||
// * proof includes outbound lane state proof;
|
|
||||||
// * inbound lane already has state, so it needs to be read and decoded;
|
|
||||||
// * message is successfully dispatched;
|
|
||||||
// * message requires all heavy checks done by dispatcher.
|
|
||||||
//
|
|
||||||
// This benchmarks gives us an approximation of outbound lane state delivery weight. It is similar to the
|
|
||||||
// `weight(receive_single_message_proof_with_outbound_lane_state) - weight(receive_single_message_proof)`.
|
|
||||||
// So it may be used to verify that the other approximation is correct.
|
|
||||||
receive_multiple_messages_proof_with_outbound_lane_state {
|
|
||||||
let i in 1..128;
|
|
||||||
|
|
||||||
let relayer_id_on_source = T::bridged_relayer_id();
|
|
||||||
let relayer_id_on_target = account("relayer", 0, SEED);
|
|
||||||
let messages_count = i as _;
|
|
||||||
|
|
||||||
// mark messages 1..=20 as delivered
|
|
||||||
receive_messages::<T, I>(20);
|
|
||||||
|
|
||||||
let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams {
|
|
||||||
lane: T::bench_lane_id(),
|
|
||||||
message_nonces: 21..=20 + i as MessageNonce,
|
|
||||||
outbound_lane_data: Some(OutboundLaneData {
|
|
||||||
oldest_unpruned_nonce: 21,
|
|
||||||
latest_received_nonce: 20,
|
|
||||||
latest_generated_nonce: 21,
|
|
||||||
}),
|
|
||||||
size: ProofSize::Minimal(0),
|
|
||||||
dispatch_fee_payment: DispatchFeePayment::AtTargetChain,
|
|
||||||
});
|
|
||||||
}: receive_messages_proof(
|
|
||||||
RawOrigin::Signed(relayer_id_on_target),
|
|
||||||
relayer_id_on_source,
|
|
||||||
proof,
|
|
||||||
messages_count,
|
|
||||||
dispatch_weight
|
|
||||||
)
|
|
||||||
verify {
|
|
||||||
assert_eq!(
|
|
||||||
crate::Pallet::<T, I>::inbound_latest_received_nonce(T::bench_lane_id()),
|
|
||||||
20 + i as MessageNonce,
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
crate::Pallet::<T, I>::inbound_latest_confirmed_nonce(T::bench_lane_id()),
|
|
||||||
20,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Benchmark `receive_messages_delivery_proof` extrinsic where single relayer delivers multiple messages.
|
|
||||||
receive_delivery_proof_for_multiple_messages_by_single_relayer {
|
|
||||||
// there actually should be used value of `MaxUnrewardedRelayerEntriesAtInboundLane` from the bridged
|
|
||||||
// chain, but we're more interested in additional weight/message than in max weight
|
|
||||||
let i in 1..T::MaxUnrewardedRelayerEntriesAtInboundLane::get()
|
|
||||||
.try_into()
|
|
||||||
.expect("Value of MaxUnrewardedRelayerEntriesAtInboundLane is too large");
|
|
||||||
|
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let relayer_id: T::AccountId = account("relayer", 0, SEED);
|
|
||||||
let relayer_balance = T::account_balance(&relayer_id);
|
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
// send messages that we're going to confirm
|
|
||||||
for _ in 1..=i {
|
|
||||||
send_regular_message::<T, I>();
|
|
||||||
}
|
|
||||||
|
|
||||||
let relayers_state = UnrewardedRelayersState {
|
|
||||||
unrewarded_relayer_entries: 1,
|
|
||||||
messages_in_oldest_entry: 1,
|
|
||||||
total_messages: i as MessageNonce,
|
|
||||||
};
|
|
||||||
let mut delivered_messages = DeliveredMessages::new(1, true);
|
|
||||||
for nonce in 2..=i {
|
|
||||||
delivered_messages.note_dispatched_message(true);
|
|
||||||
}
|
|
||||||
let proof = T::prepare_message_delivery_proof(MessageDeliveryProofParams {
|
|
||||||
lane: T::bench_lane_id(),
|
|
||||||
inbound_lane_data: InboundLaneData {
|
|
||||||
relayers: vec![UnrewardedRelayer {
|
|
||||||
relayer: relayer_id.clone(),
|
|
||||||
messages: delivered_messages,
|
|
||||||
}].into_iter().collect(),
|
|
||||||
last_confirmed_nonce: 0,
|
|
||||||
},
|
|
||||||
size: ProofSize::Minimal(0),
|
|
||||||
});
|
|
||||||
}: receive_messages_delivery_proof(RawOrigin::Signed(relayer_id.clone()), proof, relayers_state)
|
|
||||||
verify {
|
|
||||||
ensure_relayer_rewarded::<T, I>(&relayer_id, &relayer_balance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Benchmark `receive_messages_delivery_proof` extrinsic where every relayer delivers single messages.
|
|
||||||
receive_delivery_proof_for_multiple_messages_by_multiple_relayers {
|
|
||||||
// there actually should be used value of `MaxUnconfirmedMessagesAtInboundLane` from the bridged
|
|
||||||
// chain, but we're more interested in additional weight/message than in max weight
|
|
||||||
let i in 1..T::MaxUnconfirmedMessagesAtInboundLane::get()
|
|
||||||
.try_into()
|
|
||||||
.expect("Value of MaxUnconfirmedMessagesAtInboundLane is too large ");
|
|
||||||
|
|
||||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
|
||||||
let confirmation_relayer_id = account("relayer", 0, SEED);
|
|
||||||
let relayers: BTreeMap<T::AccountId, T::OutboundMessageFee> = (1..=i)
|
|
||||||
.map(|j| {
|
|
||||||
let relayer_id = account("relayer", j + 1, SEED);
|
|
||||||
let relayer_balance = T::account_balance(&relayer_id);
|
|
||||||
(relayer_id, relayer_balance)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
T::endow_account(&relayers_fund_id);
|
|
||||||
|
|
||||||
// send messages that we're going to confirm
|
|
||||||
for _ in 1..=i {
|
|
||||||
send_regular_message::<T, I>();
|
|
||||||
}
|
|
||||||
|
|
||||||
let relayers_state = UnrewardedRelayersState {
|
|
||||||
unrewarded_relayer_entries: i as MessageNonce,
|
|
||||||
messages_in_oldest_entry: 1,
|
|
||||||
total_messages: i as MessageNonce,
|
|
||||||
};
|
|
||||||
let proof = T::prepare_message_delivery_proof(MessageDeliveryProofParams {
|
|
||||||
lane: T::bench_lane_id(),
|
|
||||||
inbound_lane_data: InboundLaneData {
|
|
||||||
relayers: relayers
|
|
||||||
.keys()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(j, relayer)| UnrewardedRelayer {
|
|
||||||
relayer: relayer.clone(),
|
|
||||||
messages: DeliveredMessages::new(j as MessageNonce + 1, true),
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
last_confirmed_nonce: 0,
|
|
||||||
},
|
|
||||||
size: ProofSize::Minimal(0),
|
|
||||||
});
|
|
||||||
}: receive_messages_delivery_proof(RawOrigin::Signed(confirmation_relayer_id), proof, relayers_state)
|
|
||||||
verify {
|
|
||||||
for (relayer_id, prev_balance) in relayers {
|
|
||||||
ensure_relayer_rewarded::<T, I>(&relayer_id, &prev_balance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_regular_message<T: Config<I>, I: 'static>() {
|
fn send_regular_message<T: Config<I>, I: 'static>() {
|
||||||
let mut outbound_lane = outbound_lane::<T, I>(T::bench_lane_id());
|
let mut outbound_lane = outbound_lane::<T, I>(T::bench_lane_id());
|
||||||
outbound_lane.send_message(MessageData { payload: vec![], fee: MESSAGE_FEE.into() });
|
outbound_lane.send_message(MessageData { payload: vec![], fee: T::message_fee() });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_regular_message_with_payload<T: Config<I>, I: 'static>(payload: Vec<u8>) {
|
fn send_regular_message_with_payload<T: Config<I>, I: 'static>(payload: Vec<u8>) {
|
||||||
let mut outbound_lane = outbound_lane::<T, I>(T::bench_lane_id());
|
let mut outbound_lane = outbound_lane::<T, I>(T::bench_lane_id());
|
||||||
outbound_lane.send_message(MessageData { payload, fee: MESSAGE_FEE.into() });
|
outbound_lane.send_message(MessageData { payload, fee: T::message_fee() });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn confirm_message_delivery<T: Config<I>, I: 'static>(nonce: MessageNonce) {
|
fn confirm_message_delivery<T: Config<I>, I: 'static>(nonce: MessageNonce) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
use crate::OutboundMessages;
|
use crate::OutboundMessages;
|
||||||
|
|
||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
source_chain::{MessageDeliveryAndDispatchPayment, RelayersRewards, Sender},
|
source_chain::{MessageDeliveryAndDispatchPayment, RelayersRewards, SenderOrigin},
|
||||||
LaneId, MessageKey, MessageNonce, UnrewardedRelayer,
|
LaneId, MessageKey, MessageNonce, UnrewardedRelayer,
|
||||||
};
|
};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
@@ -31,6 +31,10 @@ use num_traits::{SaturatingAdd, Zero};
|
|||||||
use sp_runtime::traits::Saturating;
|
use sp_runtime::traits::Saturating;
|
||||||
use sp_std::{collections::vec_deque::VecDeque, fmt::Debug, ops::RangeInclusive};
|
use sp_std::{collections::vec_deque::VecDeque, fmt::Debug, ops::RangeInclusive};
|
||||||
|
|
||||||
|
/// Error that occurs when message fee is non-zero, but payer is not defined.
|
||||||
|
const NON_ZERO_MESSAGE_FEE_CANT_BE_PAID_BY_NONE: &str =
|
||||||
|
"Non-zero message fee can't be paid by <None>";
|
||||||
|
|
||||||
/// Instant message payments made in given currency.
|
/// Instant message payments made in given currency.
|
||||||
///
|
///
|
||||||
/// The balance is initially reserved in a special `relayers-fund` account, and transferred
|
/// The balance is initially reserved in a special `relayers-fund` account, and transferred
|
||||||
@@ -44,42 +48,50 @@ use sp_std::{collections::vec_deque::VecDeque, fmt::Debug, ops::RangeInclusive};
|
|||||||
/// to the relayer account.
|
/// to the relayer account.
|
||||||
/// NOTE It's within relayer's interest to keep their balance above ED as well, to make sure they
|
/// NOTE It's within relayer's interest to keep their balance above ED as well, to make sure they
|
||||||
/// can receive the payment.
|
/// can receive the payment.
|
||||||
pub struct InstantCurrencyPayments<T, I, Currency, GetConfirmationFee, RootAccount> {
|
pub struct InstantCurrencyPayments<T, I, Currency, GetConfirmationFee> {
|
||||||
_phantom: sp_std::marker::PhantomData<(T, I, Currency, GetConfirmationFee, RootAccount)>,
|
_phantom: sp_std::marker::PhantomData<(T, I, Currency, GetConfirmationFee)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, I, Currency, GetConfirmationFee, RootAccount>
|
impl<T, I, Currency, GetConfirmationFee>
|
||||||
MessageDeliveryAndDispatchPayment<T::AccountId, Currency::Balance>
|
MessageDeliveryAndDispatchPayment<T::Origin, T::AccountId, Currency::Balance>
|
||||||
for InstantCurrencyPayments<T, I, Currency, GetConfirmationFee, RootAccount>
|
for InstantCurrencyPayments<T, I, Currency, GetConfirmationFee>
|
||||||
where
|
where
|
||||||
T: frame_system::Config + crate::Config<I>,
|
T: frame_system::Config + crate::Config<I>,
|
||||||
I: 'static,
|
I: 'static,
|
||||||
|
T::Origin: SenderOrigin<T::AccountId>,
|
||||||
Currency: CurrencyT<T::AccountId, Balance = T::OutboundMessageFee>,
|
Currency: CurrencyT<T::AccountId, Balance = T::OutboundMessageFee>,
|
||||||
Currency::Balance: From<MessageNonce>,
|
Currency::Balance: From<MessageNonce>,
|
||||||
GetConfirmationFee: Get<Currency::Balance>,
|
GetConfirmationFee: Get<Currency::Balance>,
|
||||||
RootAccount: Get<Option<T::AccountId>>,
|
|
||||||
{
|
{
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
|
|
||||||
fn pay_delivery_and_dispatch_fee(
|
fn pay_delivery_and_dispatch_fee(
|
||||||
submitter: &Sender<T::AccountId>,
|
submitter: &T::Origin,
|
||||||
fee: &Currency::Balance,
|
fee: &Currency::Balance,
|
||||||
relayer_fund_account: &T::AccountId,
|
relayer_fund_account: &T::AccountId,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
|
let submitter_account = match submitter.linked_account() {
|
||||||
|
Some(submitter_account) => submitter_account,
|
||||||
|
None if !fee.is_zero() => {
|
||||||
|
// if we'll accept some message that has declared that the `fee` has been paid but
|
||||||
|
// it isn't actually paid, then it'll lead to problems with delivery confirmation
|
||||||
|
// payments (see `pay_relayer_rewards` && `confirmation_relayer` in particular)
|
||||||
|
return Err(NON_ZERO_MESSAGE_FEE_CANT_BE_PAID_BY_NONE)
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
// message lane verifier has accepted the message before, so this message
|
||||||
|
// is unpaid **by design**
|
||||||
|
// => let's just do nothing
|
||||||
|
return Ok(())
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if !frame_system::Pallet::<T>::account_exists(relayer_fund_account) {
|
if !frame_system::Pallet::<T>::account_exists(relayer_fund_account) {
|
||||||
return Err("The relayer fund account must exist for the message lanes pallet to work correctly.");
|
return Err("The relayer fund account must exist for the message lanes pallet to work correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let root_account = RootAccount::get();
|
|
||||||
let account = match submitter {
|
|
||||||
Sender::Signed(submitter) => submitter,
|
|
||||||
Sender::Root | Sender::None => root_account
|
|
||||||
.as_ref()
|
|
||||||
.ok_or("Sending messages using Root or None origin is disallowed.")?,
|
|
||||||
};
|
|
||||||
|
|
||||||
Currency::transfer(
|
Currency::transfer(
|
||||||
account,
|
&submitter_account,
|
||||||
relayer_fund_account,
|
relayer_fund_account,
|
||||||
*fee,
|
*fee,
|
||||||
// it's fine for the submitter to go below Existential Deposit and die.
|
// it's fine for the submitter to go below Existential Deposit and die.
|
||||||
@@ -226,7 +238,9 @@ fn pay_relayer_reward<Currency, AccountId>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::mock::{run_test, AccountId as TestAccountId, Balance as TestBalance, TestRuntime};
|
use crate::mock::{
|
||||||
|
run_test, AccountId as TestAccountId, Balance as TestBalance, Origin, TestRuntime,
|
||||||
|
};
|
||||||
use bp_messages::source_chain::RelayerRewards;
|
use bp_messages::source_chain::RelayerRewards;
|
||||||
|
|
||||||
type Balances = pallet_balances::Pallet<TestRuntime>;
|
type Balances = pallet_balances::Pallet<TestRuntime>;
|
||||||
@@ -245,6 +259,48 @@ mod tests {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pay_delivery_and_dispatch_fee_fails_on_non_zero_fee_and_unknown_payer() {
|
||||||
|
frame_support::parameter_types! {
|
||||||
|
const GetConfirmationFee: TestBalance = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
run_test(|| {
|
||||||
|
let result = InstantCurrencyPayments::<
|
||||||
|
TestRuntime,
|
||||||
|
(),
|
||||||
|
Balances,
|
||||||
|
GetConfirmationFee,
|
||||||
|
>::pay_delivery_and_dispatch_fee(
|
||||||
|
&Origin::root(),
|
||||||
|
&100,
|
||||||
|
&RELAYERS_FUND_ACCOUNT,
|
||||||
|
);
|
||||||
|
assert_eq!(result, Err(NON_ZERO_MESSAGE_FEE_CANT_BE_PAID_BY_NONE));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pay_delivery_and_dispatch_succeeds_on_zero_fee_and_unknown_payer() {
|
||||||
|
frame_support::parameter_types! {
|
||||||
|
const GetConfirmationFee: TestBalance = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
run_test(|| {
|
||||||
|
let result = InstantCurrencyPayments::<
|
||||||
|
TestRuntime,
|
||||||
|
(),
|
||||||
|
Balances,
|
||||||
|
GetConfirmationFee,
|
||||||
|
>::pay_delivery_and_dispatch_fee(
|
||||||
|
&Origin::root(),
|
||||||
|
&0,
|
||||||
|
&RELAYERS_FUND_ACCOUNT,
|
||||||
|
);
|
||||||
|
assert!(result.is_ok());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn confirmation_relayer_is_rewarded_if_it_has_also_delivered_messages() {
|
fn confirmation_relayer_is_rewarded_if_it_has_also_delivered_messages() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
|
|||||||
@@ -170,12 +170,14 @@ pub mod pallet {
|
|||||||
type TargetHeaderChain: TargetHeaderChain<Self::OutboundPayload, Self::AccountId>;
|
type TargetHeaderChain: TargetHeaderChain<Self::OutboundPayload, Self::AccountId>;
|
||||||
/// Message payload verifier.
|
/// Message payload verifier.
|
||||||
type LaneMessageVerifier: LaneMessageVerifier<
|
type LaneMessageVerifier: LaneMessageVerifier<
|
||||||
|
Self::Origin,
|
||||||
Self::AccountId,
|
Self::AccountId,
|
||||||
Self::OutboundPayload,
|
Self::OutboundPayload,
|
||||||
Self::OutboundMessageFee,
|
Self::OutboundMessageFee,
|
||||||
>;
|
>;
|
||||||
/// Message delivery payment.
|
/// Message delivery payment.
|
||||||
type MessageDeliveryAndDispatchPayment: MessageDeliveryAndDispatchPayment<
|
type MessageDeliveryAndDispatchPayment: MessageDeliveryAndDispatchPayment<
|
||||||
|
Self::Origin,
|
||||||
Self::AccountId,
|
Self::AccountId,
|
||||||
Self::OutboundMessageFee,
|
Self::OutboundMessageFee,
|
||||||
>;
|
>;
|
||||||
@@ -276,16 +278,12 @@ pub mod pallet {
|
|||||||
payload: T::OutboundPayload,
|
payload: T::OutboundPayload,
|
||||||
delivery_and_dispatch_fee: T::OutboundMessageFee,
|
delivery_and_dispatch_fee: T::OutboundMessageFee,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
crate::send_message::<T, I>(
|
crate::send_message::<T, I>(origin, lane_id, payload, delivery_and_dispatch_fee).map(
|
||||||
origin.into().map_err(|_| BadOrigin)?,
|
|sent_message| PostDispatchInfo {
|
||||||
lane_id,
|
actual_weight: Some(sent_message.weight),
|
||||||
payload,
|
pays_fee: Pays::Yes,
|
||||||
delivery_and_dispatch_fee,
|
},
|
||||||
)
|
)
|
||||||
.map(|sent_message| PostDispatchInfo {
|
|
||||||
actual_weight: Some(sent_message.weight),
|
|
||||||
pays_fee: Pays::Yes,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pay additional fee for the message.
|
/// Pay additional fee for the message.
|
||||||
@@ -313,17 +311,15 @@ pub mod pallet {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// withdraw additional fee from submitter
|
// withdraw additional fee from submitter
|
||||||
let submitter = origin.into().map_err(|_| BadOrigin)?;
|
|
||||||
T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee(
|
T::MessageDeliveryAndDispatchPayment::pay_delivery_and_dispatch_fee(
|
||||||
&submitter,
|
&origin,
|
||||||
&additional_fee,
|
&additional_fee,
|
||||||
&relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>(),
|
&relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>(),
|
||||||
)
|
)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "runtime::bridge-messages",
|
target: "runtime::bridge-messages",
|
||||||
"Submitter {:?} can't pay additional fee {:?} for the message {:?}/{:?} to {:?}: {:?}",
|
"Submitter can't pay additional fee {:?} for the message {:?}/{:?} to {:?}: {:?}",
|
||||||
submitter,
|
|
||||||
additional_fee,
|
additional_fee,
|
||||||
lane_id,
|
lane_id,
|
||||||
nonce,
|
nonce,
|
||||||
@@ -764,67 +760,6 @@ pub mod pallet {
|
|||||||
) -> Option<MessageData<T::OutboundMessageFee>> {
|
) -> Option<MessageData<T::OutboundMessageFee>> {
|
||||||
OutboundMessages::<T, I>::get(MessageKey { lane_id: lane, nonce })
|
OutboundMessages::<T, I>::get(MessageKey { lane_id: lane, nonce })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get nonce of the latest generated message at given outbound lane.
|
|
||||||
pub fn outbound_latest_generated_nonce(lane: LaneId) -> MessageNonce {
|
|
||||||
OutboundLanes::<T, I>::get(&lane).latest_generated_nonce
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get nonce of the latest confirmed message at given outbound lane.
|
|
||||||
pub fn outbound_latest_received_nonce(lane: LaneId) -> MessageNonce {
|
|
||||||
OutboundLanes::<T, I>::get(&lane).latest_received_nonce
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get nonce of the latest received message at given inbound lane.
|
|
||||||
pub fn inbound_latest_received_nonce(lane: LaneId) -> MessageNonce {
|
|
||||||
InboundLanes::<T, I>::get(&lane).last_delivered_nonce()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get nonce of the latest confirmed message at given inbound lane.
|
|
||||||
pub fn inbound_latest_confirmed_nonce(lane: LaneId) -> MessageNonce {
|
|
||||||
InboundLanes::<T, I>::get(&lane).last_confirmed_nonce
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get state of unrewarded relayers set.
|
|
||||||
pub fn inbound_unrewarded_relayers_state(
|
|
||||||
lane: bp_messages::LaneId,
|
|
||||||
) -> bp_messages::UnrewardedRelayersState {
|
|
||||||
let relayers = InboundLanes::<T, I>::get(&lane).relayers;
|
|
||||||
bp_messages::UnrewardedRelayersState {
|
|
||||||
unrewarded_relayer_entries: relayers.len() as _,
|
|
||||||
messages_in_oldest_entry: relayers
|
|
||||||
.front()
|
|
||||||
.map(|entry| 1 + entry.messages.end - entry.messages.begin)
|
|
||||||
.unwrap_or(0),
|
|
||||||
total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Getting storage keys for messages and lanes states. These keys are normally used when building
|
|
||||||
/// messages and lanes states proofs.
|
|
||||||
pub mod storage_keys {
|
|
||||||
use super::*;
|
|
||||||
use sp_core::storage::StorageKey;
|
|
||||||
|
|
||||||
/// Storage key of the outbound message in the runtime storage.
|
|
||||||
pub fn message_key(pallet_prefix: &str, lane: &LaneId, nonce: MessageNonce) -> StorageKey {
|
|
||||||
bp_runtime::storage_map_final_key_blake2_128concat(
|
|
||||||
pallet_prefix,
|
|
||||||
"OutboundMessages",
|
|
||||||
&MessageKey { lane_id: *lane, nonce }.encode(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Storage key of the outbound message lane state in the runtime storage.
|
|
||||||
pub fn outbound_lane_data_key(pallet_prefix: &str, lane: &LaneId) -> StorageKey {
|
|
||||||
bp_runtime::storage_map_final_key_blake2_128concat(pallet_prefix, "OutboundLanes", lane)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Storage key of the inbound message lane state in the runtime storage.
|
|
||||||
pub fn inbound_lane_data_key(pallet_prefix: &str, lane: &LaneId) -> StorageKey {
|
|
||||||
bp_runtime::storage_map_final_key_blake2_128concat(pallet_prefix, "InboundLanes", lane)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,6 +776,7 @@ pub fn relayer_fund_account_id<AccountId, AccountIdConverter: Convert<H256, Acco
|
|||||||
|
|
||||||
impl<T, I>
|
impl<T, I>
|
||||||
bp_messages::source_chain::MessagesBridge<
|
bp_messages::source_chain::MessagesBridge<
|
||||||
|
T::Origin,
|
||||||
T::AccountId,
|
T::AccountId,
|
||||||
T::OutboundMessageFee,
|
T::OutboundMessageFee,
|
||||||
T::OutboundPayload,
|
T::OutboundPayload,
|
||||||
@@ -852,7 +788,7 @@ where
|
|||||||
type Error = sp_runtime::DispatchErrorWithPostInfo<PostDispatchInfo>;
|
type Error = sp_runtime::DispatchErrorWithPostInfo<PostDispatchInfo>;
|
||||||
|
|
||||||
fn send_message(
|
fn send_message(
|
||||||
sender: bp_messages::source_chain::Sender<T::AccountId>,
|
sender: T::Origin,
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
message: T::OutboundPayload,
|
message: T::OutboundPayload,
|
||||||
delivery_and_dispatch_fee: T::OutboundMessageFee,
|
delivery_and_dispatch_fee: T::OutboundMessageFee,
|
||||||
@@ -863,7 +799,7 @@ where
|
|||||||
|
|
||||||
/// Function that actually sends message.
|
/// Function that actually sends message.
|
||||||
fn send_message<T: Config<I>, I: 'static>(
|
fn send_message<T: Config<I>, I: 'static>(
|
||||||
submitter: bp_messages::source_chain::Sender<T::AccountId>,
|
submitter: T::Origin,
|
||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: T::OutboundPayload,
|
payload: T::OutboundPayload,
|
||||||
delivery_and_dispatch_fee: T::OutboundMessageFee,
|
delivery_and_dispatch_fee: T::OutboundMessageFee,
|
||||||
@@ -917,9 +853,8 @@ fn send_message<T: Config<I>, I: 'static>(
|
|||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "runtime::bridge-messages",
|
target: "runtime::bridge-messages",
|
||||||
"Message to lane {:?} is rejected because submitter {:?} is unable to pay fee {:?}: {:?}",
|
"Message to lane {:?} is rejected because submitter is unable to pay fee {:?}: {:?}",
|
||||||
lane_id,
|
lane_id,
|
||||||
submitter,
|
|
||||||
delivery_and_dispatch_fee,
|
delivery_and_dispatch_fee,
|
||||||
err,
|
err,
|
||||||
);
|
);
|
||||||
@@ -1160,9 +1095,12 @@ mod tests {
|
|||||||
REGULAR_PAYLOAD, TEST_LANE_ID, TEST_RELAYER_A, TEST_RELAYER_B,
|
REGULAR_PAYLOAD, TEST_LANE_ID, TEST_RELAYER_A, TEST_RELAYER_B,
|
||||||
};
|
};
|
||||||
use bp_messages::{UnrewardedRelayer, UnrewardedRelayersState};
|
use bp_messages::{UnrewardedRelayer, UnrewardedRelayersState};
|
||||||
use frame_support::{assert_noop, assert_ok, weights::Weight};
|
use frame_support::{
|
||||||
|
assert_noop, assert_ok,
|
||||||
|
storage::generator::{StorageMap, StorageValue},
|
||||||
|
weights::Weight,
|
||||||
|
};
|
||||||
use frame_system::{EventRecord, Pallet as System, Phase};
|
use frame_system::{EventRecord, Pallet as System, Phase};
|
||||||
use hex_literal::hex;
|
|
||||||
use sp_runtime::DispatchError;
|
use sp_runtime::DispatchError;
|
||||||
|
|
||||||
fn get_ready_for_events() {
|
fn get_ready_for_events() {
|
||||||
@@ -1170,6 +1108,20 @@ mod tests {
|
|||||||
System::<TestRuntime>::reset_events();
|
System::<TestRuntime>::reset_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn inbound_unrewarded_relayers_state(
|
||||||
|
lane: bp_messages::LaneId,
|
||||||
|
) -> bp_messages::UnrewardedRelayersState {
|
||||||
|
let relayers = InboundLanes::<TestRuntime, ()>::get(&lane).relayers;
|
||||||
|
bp_messages::UnrewardedRelayersState {
|
||||||
|
unrewarded_relayer_entries: relayers.len() as _,
|
||||||
|
messages_in_oldest_entry: relayers
|
||||||
|
.front()
|
||||||
|
.map(|entry| 1 + entry.messages.end - entry.messages.begin)
|
||||||
|
.unwrap_or(0),
|
||||||
|
total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn send_regular_message() -> Weight {
|
fn send_regular_message() -> Weight {
|
||||||
get_ready_for_events();
|
get_ready_for_events();
|
||||||
|
|
||||||
@@ -1614,7 +1566,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Pallet::<TestRuntime>::inbound_unrewarded_relayers_state(TEST_LANE_ID),
|
inbound_unrewarded_relayers_state(TEST_LANE_ID),
|
||||||
UnrewardedRelayersState {
|
UnrewardedRelayersState {
|
||||||
unrewarded_relayer_entries: 2,
|
unrewarded_relayer_entries: 2,
|
||||||
messages_in_oldest_entry: 1,
|
messages_in_oldest_entry: 1,
|
||||||
@@ -1649,7 +1601,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Pallet::<TestRuntime>::inbound_unrewarded_relayers_state(TEST_LANE_ID),
|
inbound_unrewarded_relayers_state(TEST_LANE_ID),
|
||||||
UnrewardedRelayersState {
|
UnrewardedRelayersState {
|
||||||
unrewarded_relayer_entries: 2,
|
unrewarded_relayer_entries: 2,
|
||||||
messages_in_oldest_entry: 1,
|
messages_in_oldest_entry: 1,
|
||||||
@@ -1890,45 +1842,6 @@ mod tests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn storage_message_key_computed_properly() {
|
|
||||||
// If this test fails, then something has been changed in module storage that is breaking
|
|
||||||
// all previously crafted messages proofs.
|
|
||||||
let storage_key = storage_keys::message_key("BridgeMessages", &*b"test", 42).0;
|
|
||||||
assert_eq!(
|
|
||||||
storage_key,
|
|
||||||
hex!("dd16c784ebd3390a9bc0357c7511ed018a395e6242c6813b196ca31ed0547ea79446af0e09063bd4a7874aef8a997cec746573742a00000000000000").to_vec(),
|
|
||||||
"Unexpected storage key: {}",
|
|
||||||
hex::encode(&storage_key),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn outbound_lane_data_key_computed_properly() {
|
|
||||||
// If this test fails, then something has been changed in module storage that is breaking
|
|
||||||
// all previously crafted outbound lane state proofs.
|
|
||||||
let storage_key = storage_keys::outbound_lane_data_key("BridgeMessages", &*b"test").0;
|
|
||||||
assert_eq!(
|
|
||||||
storage_key,
|
|
||||||
hex!("dd16c784ebd3390a9bc0357c7511ed0196c246acb9b55077390e3ca723a0ca1f44a8995dd50b6657a037a7839304535b74657374").to_vec(),
|
|
||||||
"Unexpected storage key: {}",
|
|
||||||
hex::encode(&storage_key),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn inbound_lane_data_key_computed_properly() {
|
|
||||||
// If this test fails, then something has been changed in module storage that is breaking
|
|
||||||
// all previously crafted inbound lane state proofs.
|
|
||||||
let storage_key = storage_keys::inbound_lane_data_key("BridgeMessages", &*b"test").0;
|
|
||||||
assert_eq!(
|
|
||||||
storage_key,
|
|
||||||
hex!("dd16c784ebd3390a9bc0357c7511ed01e5f83cf83f2127eb47afdc35d6e43fab44a8995dd50b6657a037a7839304535b74657374").to_vec(),
|
|
||||||
"Unexpected storage key: {}",
|
|
||||||
hex::encode(&storage_key),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn actual_dispatch_weight_does_not_overlow() {
|
fn actual_dispatch_weight_does_not_overlow() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
@@ -2362,4 +2275,30 @@ mod tests {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn storage_keys_computed_properly() {
|
||||||
|
assert_eq!(
|
||||||
|
PalletOperatingMode::<TestRuntime>::storage_value_final_key().to_vec(),
|
||||||
|
bp_messages::storage_keys::operating_mode_key("Messages").0,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
OutboundMessages::<TestRuntime>::storage_map_final_key(MessageKey {
|
||||||
|
lane_id: TEST_LANE_ID,
|
||||||
|
nonce: 42
|
||||||
|
}),
|
||||||
|
bp_messages::storage_keys::message_key("Messages", &TEST_LANE_ID, 42).0,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
OutboundLanes::<TestRuntime>::storage_map_final_key(TEST_LANE_ID),
|
||||||
|
bp_messages::storage_keys::outbound_lane_data_key("Messages", &TEST_LANE_ID).0,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
InboundLanes::<TestRuntime>::storage_map_final_key(TEST_LANE_ID),
|
||||||
|
bp_messages::storage_keys::inbound_lane_data_key("Messages", &TEST_LANE_ID).0,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use bitvec::prelude::*;
|
|||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
source_chain::{
|
source_chain::{
|
||||||
LaneMessageVerifier, MessageDeliveryAndDispatchPayment, OnDeliveryConfirmed,
|
LaneMessageVerifier, MessageDeliveryAndDispatchPayment, OnDeliveryConfirmed,
|
||||||
OnMessageAccepted, Sender, TargetHeaderChain,
|
OnMessageAccepted, SenderOrigin, TargetHeaderChain,
|
||||||
},
|
},
|
||||||
target_chain::{
|
target_chain::{
|
||||||
DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain,
|
DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain,
|
||||||
@@ -194,6 +194,16 @@ impl Config for TestRuntime {
|
|||||||
type BridgedChainId = TestBridgedChainId;
|
type BridgedChainId = TestBridgedChainId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SenderOrigin<AccountId> for Origin {
|
||||||
|
fn linked_account(&self) -> Option<AccountId> {
|
||||||
|
match self.caller {
|
||||||
|
OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) =>
|
||||||
|
Some(submitter.clone()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Size for TestPayload {
|
impl Size for TestPayload {
|
||||||
fn size_hint(&self) -> u32 {
|
fn size_hint(&self) -> u32 {
|
||||||
16 + self.extra.len() as u32
|
16 + self.extra.len() as u32
|
||||||
@@ -294,11 +304,13 @@ impl TargetHeaderChain<TestPayload, TestRelayer> for TestTargetHeaderChain {
|
|||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct TestLaneMessageVerifier;
|
pub struct TestLaneMessageVerifier;
|
||||||
|
|
||||||
impl LaneMessageVerifier<AccountId, TestPayload, TestMessageFee> for TestLaneMessageVerifier {
|
impl LaneMessageVerifier<Origin, AccountId, TestPayload, TestMessageFee>
|
||||||
|
for TestLaneMessageVerifier
|
||||||
|
{
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
|
|
||||||
fn verify_message(
|
fn verify_message(
|
||||||
_submitter: &Sender<AccountId>,
|
_submitter: &Origin,
|
||||||
delivery_and_dispatch_fee: &TestMessageFee,
|
delivery_and_dispatch_fee: &TestMessageFee,
|
||||||
_lane: &LaneId,
|
_lane: &LaneId,
|
||||||
_lane_outbound_data: &OutboundLaneData,
|
_lane_outbound_data: &OutboundLaneData,
|
||||||
@@ -324,8 +336,8 @@ impl TestMessageDeliveryAndDispatchPayment {
|
|||||||
|
|
||||||
/// Returns true if given fee has been paid by given submitter.
|
/// Returns true if given fee has been paid by given submitter.
|
||||||
pub fn is_fee_paid(submitter: AccountId, fee: TestMessageFee) -> bool {
|
pub fn is_fee_paid(submitter: AccountId, fee: TestMessageFee) -> bool {
|
||||||
frame_support::storage::unhashed::get(b":message-fee:") ==
|
let raw_origin: Result<frame_system::RawOrigin<_>, _> = Origin::signed(submitter).into();
|
||||||
Some((Sender::Signed(submitter), fee))
|
frame_support::storage::unhashed::get(b":message-fee:") == Some((raw_origin.unwrap(), fee))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if given relayer has been rewarded with given balance. The reward-paid flag is
|
/// Returns true if given relayer has been rewarded with given balance. The reward-paid flag is
|
||||||
@@ -336,13 +348,13 @@ impl TestMessageDeliveryAndDispatchPayment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageDeliveryAndDispatchPayment<AccountId, TestMessageFee>
|
impl MessageDeliveryAndDispatchPayment<Origin, AccountId, TestMessageFee>
|
||||||
for TestMessageDeliveryAndDispatchPayment
|
for TestMessageDeliveryAndDispatchPayment
|
||||||
{
|
{
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
|
|
||||||
fn pay_delivery_and_dispatch_fee(
|
fn pay_delivery_and_dispatch_fee(
|
||||||
submitter: &Sender<AccountId>,
|
submitter: &Origin,
|
||||||
fee: &TestMessageFee,
|
fee: &TestMessageFee,
|
||||||
_relayer_fund_account: &AccountId,
|
_relayer_fund_account: &AccountId,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
@@ -350,7 +362,8 @@ impl MessageDeliveryAndDispatchPayment<AccountId, TestMessageFee>
|
|||||||
return Err(TEST_ERROR)
|
return Err(TEST_ERROR)
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_support::storage::unhashed::put(b":message-fee:", &(submitter, fee));
|
let raw_origin: Result<frame_system::RawOrigin<_>, _> = submitter.clone().into();
|
||||||
|
frame_support::storage::unhashed::put(b":message-fee:", &(raw_origin.unwrap(), fee));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,14 @@
|
|||||||
|
|
||||||
//! Autogenerated weights for `pallet_bridge_messages`
|
//! Autogenerated weights for `pallet_bridge_messages`
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2021-06-18, STEPS: [50, ], REPEAT: 20
|
//! DATE: 2021-12-28, STEPS: 50, REPEAT: 20
|
||||||
//! LOW RANGE: [], HIGH RANGE: []
|
//! LOW RANGE: [], HIGH RANGE: []
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
||||||
//! CHAIN: Some("dev"), DB CACHE: 128
|
//! CHAIN: Some("dev"), DB CACHE: 128
|
||||||
|
|
||||||
// Executed Command:
|
// Executed Command:
|
||||||
// target/release/rialto-bridge-node
|
// target/release/millau-bridge-node
|
||||||
// benchmark
|
// benchmark
|
||||||
// --chain=dev
|
// --chain=dev
|
||||||
// --steps=50
|
// --steps=50
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
// --wasm-execution=Compiled
|
// --wasm-execution=Compiled
|
||||||
// --heap-pages=4096
|
// --heap-pages=4096
|
||||||
// --output=./modules/messages/src/weights.rs
|
// --output=./modules/messages/src/weights.rs
|
||||||
// --template=./.maintain/rialto-weight-template.hbs
|
// --template=./.maintain/millau-weight-template.hbs
|
||||||
|
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
#![allow(unused_parens)]
|
#![allow(unused_parens)]
|
||||||
@@ -62,252 +62,155 @@ pub trait WeightInfo {
|
|||||||
fn receive_delivery_proof_for_single_message() -> Weight;
|
fn receive_delivery_proof_for_single_message() -> Weight;
|
||||||
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight;
|
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight;
|
||||||
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight;
|
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight;
|
||||||
fn send_messages_of_various_lengths(i: u32) -> Weight;
|
|
||||||
fn receive_multiple_messages_proof(i: u32) -> Weight;
|
|
||||||
fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight;
|
|
||||||
fn receive_message_proofs_with_large_leaf(i: u32) -> Weight;
|
|
||||||
fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight;
|
|
||||||
fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight;
|
|
||||||
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Weights for `pallet_bridge_messages` using the Rialto node and recommended hardware.
|
/// Weights for `pallet_bridge_messages` using the Millau node and recommended hardware.
|
||||||
pub struct RialtoWeight<T>(PhantomData<T>);
|
pub struct MillauWeight<T>(PhantomData<T>);
|
||||||
impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
||||||
fn send_minimal_message_worst_case() -> Weight {
|
fn send_minimal_message_worst_case() -> Weight {
|
||||||
(159_305_000 as Weight)
|
(117_480_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
||||||
}
|
}
|
||||||
fn send_1_kb_message_worst_case() -> Weight {
|
fn send_1_kb_message_worst_case() -> Weight {
|
||||||
(164_394_000 as Weight)
|
(128_391_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
||||||
}
|
}
|
||||||
fn send_16_kb_message_worst_case() -> Weight {
|
fn send_16_kb_message_worst_case() -> Weight {
|
||||||
(223_521_000 as Weight)
|
(149_149_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
||||||
}
|
}
|
||||||
fn maximal_increase_message_fee() -> Weight {
|
fn maximal_increase_message_fee() -> Weight {
|
||||||
(6_781_470_000 as Weight)
|
(6_015_058_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn increase_message_fee(i: u32) -> Weight {
|
fn increase_message_fee(i: u32) -> Weight {
|
||||||
(114_963_000 as Weight)
|
(0 as Weight)
|
||||||
.saturating_add((6_000 as Weight).saturating_mul(i as Weight))
|
.saturating_add((2_000 as Weight).saturating_mul(i as Weight))
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_message_proof() -> Weight {
|
fn receive_single_message_proof() -> Weight {
|
||||||
(206_769_000 as Weight)
|
(179_892_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_two_messages_proof() -> Weight {
|
fn receive_two_messages_proof() -> Weight {
|
||||||
(343_982_000 as Weight)
|
(291_793_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
|
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
|
||||||
(223_738_000 as Weight)
|
(192_191_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_message_proof_1_kb() -> Weight {
|
fn receive_single_message_proof_1_kb() -> Weight {
|
||||||
(235_369_000 as Weight)
|
(202_104_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_message_proof_16_kb() -> Weight {
|
fn receive_single_message_proof_16_kb() -> Weight {
|
||||||
(510_338_000 as Weight)
|
(357_144_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_prepaid_message_proof() -> Weight {
|
fn receive_single_prepaid_message_proof() -> Weight {
|
||||||
(141_536_000 as Weight)
|
(122_648_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_delivery_proof_for_single_message() -> Weight {
|
fn receive_delivery_proof_for_single_message() -> Weight {
|
||||||
(128_805_000 as Weight)
|
(107_631_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
|
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
|
||||||
(137_143_000 as Weight)
|
(113_885_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
|
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
|
||||||
(193_108_000 as Weight)
|
(155_151_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(8 as Weight))
|
.saturating_add(T::DbWeight::get().reads(8 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||||
}
|
}
|
||||||
fn send_messages_of_various_lengths(i: u32) -> Weight {
|
|
||||||
(133_632_000 as Weight)
|
|
||||||
.saturating_add((4_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_multiple_messages_proof(i: u32) -> Weight {
|
|
||||||
(0 as Weight)
|
|
||||||
.saturating_add((145_006_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight {
|
|
||||||
(486_301_000 as Weight)
|
|
||||||
.saturating_add((10_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_message_proofs_with_large_leaf(i: u32) -> Weight {
|
|
||||||
(178_139_000 as Weight)
|
|
||||||
.saturating_add((7_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight {
|
|
||||||
(0 as Weight)
|
|
||||||
.saturating_add((150_844_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight {
|
|
||||||
(113_140_000 as Weight)
|
|
||||||
.saturating_add((7_656_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight {
|
|
||||||
(97_424_000 as Weight)
|
|
||||||
.saturating_add((63_128_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(i as Weight)))
|
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
|
||||||
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For backwards compatibility and tests
|
// For backwards compatibility and tests
|
||||||
impl WeightInfo for () {
|
impl WeightInfo for () {
|
||||||
fn send_minimal_message_worst_case() -> Weight {
|
fn send_minimal_message_worst_case() -> Weight {
|
||||||
(159_305_000 as Weight)
|
(117_480_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
||||||
}
|
}
|
||||||
fn send_1_kb_message_worst_case() -> Weight {
|
fn send_1_kb_message_worst_case() -> Weight {
|
||||||
(164_394_000 as Weight)
|
(128_391_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
||||||
}
|
}
|
||||||
fn send_16_kb_message_worst_case() -> Weight {
|
fn send_16_kb_message_worst_case() -> Weight {
|
||||||
(223_521_000 as Weight)
|
(149_149_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
||||||
}
|
}
|
||||||
fn maximal_increase_message_fee() -> Weight {
|
fn maximal_increase_message_fee() -> Weight {
|
||||||
(6_781_470_000 as Weight)
|
(6_015_058_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn increase_message_fee(i: u32) -> Weight {
|
fn increase_message_fee(i: u32) -> Weight {
|
||||||
(114_963_000 as Weight)
|
(0 as Weight)
|
||||||
.saturating_add((6_000 as Weight).saturating_mul(i as Weight))
|
.saturating_add((2_000 as Weight).saturating_mul(i as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_message_proof() -> Weight {
|
fn receive_single_message_proof() -> Weight {
|
||||||
(206_769_000 as Weight)
|
(179_892_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_two_messages_proof() -> Weight {
|
fn receive_two_messages_proof() -> Weight {
|
||||||
(343_982_000 as Weight)
|
(291_793_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
|
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
|
||||||
(223_738_000 as Weight)
|
(192_191_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_message_proof_1_kb() -> Weight {
|
fn receive_single_message_proof_1_kb() -> Weight {
|
||||||
(235_369_000 as Weight)
|
(202_104_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_message_proof_16_kb() -> Weight {
|
fn receive_single_message_proof_16_kb() -> Weight {
|
||||||
(510_338_000 as Weight)
|
(357_144_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_single_prepaid_message_proof() -> Weight {
|
fn receive_single_prepaid_message_proof() -> Weight {
|
||||||
(141_536_000 as Weight)
|
(122_648_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_delivery_proof_for_single_message() -> Weight {
|
fn receive_delivery_proof_for_single_message() -> Weight {
|
||||||
(128_805_000 as Weight)
|
(107_631_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
|
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
|
||||||
(137_143_000 as Weight)
|
(113_885_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
|
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
|
||||||
(193_108_000 as Weight)
|
(155_151_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(8 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(8 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||||
}
|
}
|
||||||
fn send_messages_of_various_lengths(i: u32) -> Weight {
|
|
||||||
(133_632_000 as Weight)
|
|
||||||
.saturating_add((4_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_multiple_messages_proof(i: u32) -> Weight {
|
|
||||||
(0 as Weight)
|
|
||||||
.saturating_add((145_006_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight {
|
|
||||||
(486_301_000 as Weight)
|
|
||||||
.saturating_add((10_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_message_proofs_with_large_leaf(i: u32) -> Weight {
|
|
||||||
(178_139_000 as Weight)
|
|
||||||
.saturating_add((7_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight {
|
|
||||||
(0 as Weight)
|
|
||||||
.saturating_add((150_844_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight {
|
|
||||||
(113_140_000 as Weight)
|
|
||||||
.saturating_add((7_656_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
|
||||||
}
|
|
||||||
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight {
|
|
||||||
(97_424_000 as Weight)
|
|
||||||
.saturating_add((63_128_000 as Weight).saturating_mul(i as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(i as Weight)))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
|
||||||
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ impl WeightInfoExt for () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: frame_system::Config> WeightInfoExt for crate::weights::RialtoWeight<T> {
|
impl<T: frame_system::Config> WeightInfoExt for crate::weights::MillauWeight<T> {
|
||||||
fn expected_extra_storage_proof_size() -> u32 {
|
fn expected_extra_storage_proof_size() -> u32 {
|
||||||
EXTRA_STORAGE_PROOF_SIZE
|
EXTRA_STORAGE_PROOF_SIZE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ name = "pallet-shift-session-manager"
|
|||||||
description = "A Substrate Runtime module that selects 2/3 of initial validators for every session"
|
description = "A Substrate Runtime module that selects 2/3 of initial validators for every session"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
||||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
|
|
||||||
# Substrate Dependencies
|
# Substrate Dependencies
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::generate_store(pub(super) trait Store)]
|
#[pallet::generate_store(pub(super) trait Store)]
|
||||||
|
#[pallet::without_storage_info]
|
||||||
pub struct Pallet<T>(PhantomData<T>);
|
pub struct Pallet<T>(PhantomData<T>);
|
||||||
|
|
||||||
#[pallet::hooks]
|
#[pallet::hooks]
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ name = "pallet-bridge-token-swap"
|
|||||||
description = "An Substrate pallet that allows parties on different chains (bridged using messages pallet) to swap their tokens"
|
description = "An Substrate pallet that allows parties on different chains (bridged using messages pallet) to swap their tokens"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
||||||
log = { version = "0.4.14", default-features = false }
|
log = { version = "0.4.14", default-features = false }
|
||||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
serde = { version = "1.0", optional = true }
|
serde = { version = "1.0", optional = true }
|
||||||
|
|
||||||
# Bridge dependencies
|
# Bridge dependencies
|
||||||
@@ -55,5 +55,5 @@ std = [
|
|||||||
"sp-std/std",
|
"sp-std/std",
|
||||||
]
|
]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking/runtime-benchmarks",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -18,19 +18,19 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
swap_account_id, target_account_at_this_chain, BridgedAccountIdOf, BridgedAccountPublicOf,
|
swap_account_id, target_account_at_this_chain, BridgedAccountIdOf, BridgedAccountPublicOf,
|
||||||
BridgedAccountSignatureOf, BridgedBalanceOf, Call, Pallet, ThisChainBalance,
|
BridgedAccountSignatureOf, BridgedBalanceOf, Call, Origin, Pallet, ThisChainBalance,
|
||||||
TokenSwapCreationOf, TokenSwapOf,
|
TokenSwapCreationOf, TokenSwapOf,
|
||||||
};
|
};
|
||||||
|
|
||||||
use bp_token_swap::{TokenSwap, TokenSwapCreation, TokenSwapState, TokenSwapType};
|
use bp_token_swap::{TokenSwap, TokenSwapCreation, TokenSwapState, TokenSwapType};
|
||||||
use codec::Encode;
|
use codec::{Decode, Encode};
|
||||||
use frame_benchmarking::{account, benchmarks_instance_pallet};
|
use frame_benchmarking::{account, benchmarks_instance_pallet};
|
||||||
use frame_support::{traits::Currency, Parameter};
|
use frame_support::{traits::Currency, Parameter};
|
||||||
use frame_system::RawOrigin;
|
use frame_system::RawOrigin;
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_io::hashing::blake2_256;
|
use sp_io::hashing::blake2_256;
|
||||||
use sp_runtime::traits::Bounded;
|
use sp_runtime::traits::{Bounded, TrailingZeroInput};
|
||||||
use sp_std::vec::Vec;
|
use sp_std::{boxed::Box, vec::Vec};
|
||||||
|
|
||||||
const SEED: u32 = 0;
|
const SEED: u32 = 0;
|
||||||
|
|
||||||
@@ -43,8 +43,9 @@ pub trait Config<I: 'static>: crate::Config<I> {
|
|||||||
benchmarks_instance_pallet! {
|
benchmarks_instance_pallet! {
|
||||||
where_clause {
|
where_clause {
|
||||||
where
|
where
|
||||||
BridgedAccountPublicOf<T, I>: Default + Parameter,
|
Origin<T, I>: Into<T::Origin>,
|
||||||
BridgedAccountSignatureOf<T, I>: Default,
|
BridgedAccountPublicOf<T, I>: Decode + Parameter,
|
||||||
|
BridgedAccountSignatureOf<T, I>: Decode,
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -138,8 +139,8 @@ fn test_swap_hash<T: Config<I>, I: 'static>(sender: T::AccountId, is_create: boo
|
|||||||
/// Returns test token swap creation params.
|
/// Returns test token swap creation params.
|
||||||
fn test_swap_creation<T: Config<I>, I: 'static>() -> TokenSwapCreationOf<T, I>
|
fn test_swap_creation<T: Config<I>, I: 'static>() -> TokenSwapCreationOf<T, I>
|
||||||
where
|
where
|
||||||
BridgedAccountPublicOf<T, I>: Default,
|
BridgedAccountPublicOf<T, I>: Decode,
|
||||||
BridgedAccountSignatureOf<T, I>: Default,
|
BridgedAccountSignatureOf<T, I>: Decode,
|
||||||
{
|
{
|
||||||
TokenSwapCreation {
|
TokenSwapCreation {
|
||||||
target_public_at_bridged_chain: target_public_at_bridged_chain::<T, I>(),
|
target_public_at_bridged_chain: target_public_at_bridged_chain::<T, I>(),
|
||||||
@@ -176,20 +177,22 @@ fn target_balance_to_swap<T: Config<I>, I: 'static>() -> BridgedBalanceOf<T, I>
|
|||||||
/// Public key of `target_account_at_bridged_chain`.
|
/// Public key of `target_account_at_bridged_chain`.
|
||||||
fn target_public_at_bridged_chain<T: Config<I>, I: 'static>() -> BridgedAccountPublicOf<T, I>
|
fn target_public_at_bridged_chain<T: Config<I>, I: 'static>() -> BridgedAccountPublicOf<T, I>
|
||||||
where
|
where
|
||||||
BridgedAccountPublicOf<T, I>: Default,
|
BridgedAccountPublicOf<T, I>: Decode,
|
||||||
{
|
{
|
||||||
Default::default()
|
BridgedAccountPublicOf::<T, I>::decode(&mut TrailingZeroInput::zeroes())
|
||||||
|
.expect("failed to decode `BridgedAccountPublicOf` from zeroes")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Signature of `target_account_at_bridged_chain` over message.
|
/// Signature of `target_account_at_bridged_chain` over message.
|
||||||
fn bridged_currency_transfer_signature<T: Config<I>, I: 'static>() -> BridgedAccountSignatureOf<T, I>
|
fn bridged_currency_transfer_signature<T: Config<I>, I: 'static>() -> BridgedAccountSignatureOf<T, I>
|
||||||
where
|
where
|
||||||
BridgedAccountSignatureOf<T, I>: Default,
|
BridgedAccountSignatureOf<T, I>: Decode,
|
||||||
{
|
{
|
||||||
Default::default()
|
BridgedAccountSignatureOf::<T, I>::decode(&mut TrailingZeroInput::zeroes())
|
||||||
|
.expect("failed to decode `BridgedAccountSignatureOf` from zeroes")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Account at the bridged chain that is participating in the swap.
|
/// Account at the bridged chain that is participating in the swap.
|
||||||
fn target_account_at_bridged_chain<T: Config<I>, I: 'static>() -> BridgedAccountIdOf<T, I> {
|
fn target_account_at_bridged_chain<T: Config<I>, I: 'static>() -> BridgedAccountIdOf<T, I> {
|
||||||
Default::default()
|
account("target_account_at_bridged_chain", 0, SEED)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,16 +70,18 @@ use bp_runtime::{messages::DispatchFeePayment, ChainId};
|
|||||||
use bp_token_swap::{
|
use bp_token_swap::{
|
||||||
RawBridgedTransferCall, TokenSwap, TokenSwapCreation, TokenSwapState, TokenSwapType,
|
RawBridgedTransferCall, TokenSwap, TokenSwapCreation, TokenSwapState, TokenSwapType,
|
||||||
};
|
};
|
||||||
use codec::Encode;
|
use codec::{Decode, Encode};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
fail,
|
fail,
|
||||||
traits::{Currency, ExistenceRequirement},
|
traits::{Currency, ExistenceRequirement},
|
||||||
weights::PostDispatchInfo,
|
weights::PostDispatchInfo,
|
||||||
|
RuntimeDebug,
|
||||||
};
|
};
|
||||||
|
use scale_info::TypeInfo;
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_io::hashing::blake2_256;
|
use sp_io::hashing::blake2_256;
|
||||||
use sp_runtime::traits::{Convert, Saturating};
|
use sp_runtime::traits::{Convert, Saturating};
|
||||||
use sp_std::boxed::Box;
|
use sp_std::{boxed::Box, marker::PhantomData};
|
||||||
use weights::WeightInfo;
|
use weights::WeightInfo;
|
||||||
|
|
||||||
pub use weights_ext::WeightInfoExt;
|
pub use weights_ext::WeightInfoExt;
|
||||||
@@ -98,6 +100,21 @@ pub use pallet::*;
|
|||||||
/// Name of the `PendingSwaps` storage map.
|
/// Name of the `PendingSwaps` storage map.
|
||||||
pub const PENDING_SWAPS_MAP_NAME: &str = "PendingSwaps";
|
pub const PENDING_SWAPS_MAP_NAME: &str = "PendingSwaps";
|
||||||
|
|
||||||
|
/// Origin for the token swap pallet.
|
||||||
|
#[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo)]
|
||||||
|
pub enum RawOrigin<AccountId, I> {
|
||||||
|
/// The call is originated by the token swap account.
|
||||||
|
TokenSwap {
|
||||||
|
/// Id of the account that has started the swap.
|
||||||
|
source_account_at_this_chain: AccountId,
|
||||||
|
/// Id of the account that holds the funds during this swap. The message fee is paid from
|
||||||
|
/// this account funds.
|
||||||
|
swap_account_at_this_chain: AccountId,
|
||||||
|
},
|
||||||
|
/// Dummy to manage the fact we have instancing.
|
||||||
|
_Phantom(PhantomData<I>),
|
||||||
|
}
|
||||||
|
|
||||||
// comes from #[pallet::event]
|
// comes from #[pallet::event]
|
||||||
#[allow(clippy::unused_unit)]
|
#[allow(clippy::unused_unit)]
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
@@ -126,6 +143,7 @@ pub mod pallet {
|
|||||||
type OutboundMessageLaneId: Get<LaneId>;
|
type OutboundMessageLaneId: Get<LaneId>;
|
||||||
/// Messages bridge with Bridged chain.
|
/// Messages bridge with Bridged chain.
|
||||||
type MessagesBridge: MessagesBridge<
|
type MessagesBridge: MessagesBridge<
|
||||||
|
Self::Origin,
|
||||||
Self::AccountId,
|
Self::AccountId,
|
||||||
<Self::ThisCurrency as Currency<Self::AccountId>>::Balance,
|
<Self::ThisCurrency as Currency<Self::AccountId>>::Balance,
|
||||||
MessagePayloadOf<Self, I>,
|
MessagePayloadOf<Self, I>,
|
||||||
@@ -182,6 +200,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::generate_store(pub(super) trait Store)]
|
#[pallet::generate_store(pub(super) trait Store)]
|
||||||
|
#[pallet::without_storage_info]
|
||||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||||
|
|
||||||
#[pallet::hooks]
|
#[pallet::hooks]
|
||||||
@@ -191,6 +210,7 @@ pub mod pallet {
|
|||||||
impl<T: Config<I>, I: 'static> Pallet<T, I>
|
impl<T: Config<I>, I: 'static> Pallet<T, I>
|
||||||
where
|
where
|
||||||
BridgedAccountPublicOf<T, I>: Parameter,
|
BridgedAccountPublicOf<T, I>: Parameter,
|
||||||
|
Origin<T, I>: Into<T::Origin>,
|
||||||
{
|
{
|
||||||
/// Start token swap procedure.
|
/// Start token swap procedure.
|
||||||
///
|
///
|
||||||
@@ -312,7 +332,11 @@ pub mod pallet {
|
|||||||
// `Currency::transfer` call on the bridged chain, but no checks are made - it is
|
// `Currency::transfer` call on the bridged chain, but no checks are made - it is
|
||||||
// the transaction submitter to ensure it is valid.
|
// the transaction submitter to ensure it is valid.
|
||||||
let send_message_result = T::MessagesBridge::send_message(
|
let send_message_result = T::MessagesBridge::send_message(
|
||||||
bp_messages::source_chain::Sender::from(Some(swap_account.clone())),
|
RawOrigin::TokenSwap {
|
||||||
|
source_account_at_this_chain: swap.source_account_at_this_chain.clone(),
|
||||||
|
swap_account_at_this_chain: swap_account.clone(),
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
T::OutboundMessageLaneId::get(),
|
T::OutboundMessageLaneId::get(),
|
||||||
bp_message_dispatch::MessagePayload {
|
bp_message_dispatch::MessagePayload {
|
||||||
spec_version: bridged_chain_spec_version,
|
spec_version: bridged_chain_spec_version,
|
||||||
@@ -515,6 +539,10 @@ pub mod pallet {
|
|||||||
InvalidClaimant,
|
InvalidClaimant,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Origin for the token swap pallet.
|
||||||
|
#[pallet::origin]
|
||||||
|
pub type Origin<T, I = ()> = RawOrigin<<T as frame_system::Config>::AccountId, I>;
|
||||||
|
|
||||||
/// Pending token swaps states.
|
/// Pending token swaps states.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
pub type PendingSwaps<T: Config<I>, I: 'static = ()> =
|
pub type PendingSwaps<T: Config<I>, I: 'static = ()> =
|
||||||
@@ -639,7 +667,7 @@ pub mod pallet {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::mock::*;
|
use crate::mock::*;
|
||||||
use frame_support::{assert_noop, assert_ok};
|
use frame_support::{assert_noop, assert_ok, storage::generator::StorageMap};
|
||||||
|
|
||||||
const CAN_START_BLOCK_NUMBER: u64 = 10;
|
const CAN_START_BLOCK_NUMBER: u64 = 10;
|
||||||
const CAN_CLAIM_BLOCK_NUMBER: u64 = CAN_START_BLOCK_NUMBER + 1;
|
const CAN_CLAIM_BLOCK_NUMBER: u64 = CAN_START_BLOCK_NUMBER + 1;
|
||||||
@@ -687,7 +715,7 @@ mod tests {
|
|||||||
|
|
||||||
fn start_test_swap() {
|
fn start_test_swap() {
|
||||||
assert_ok!(Pallet::<TestRuntime>::create_swap(
|
assert_ok!(Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
Box::new(TokenSwapCreation {
|
Box::new(TokenSwapCreation {
|
||||||
target_public_at_bridged_chain: bridged_chain_account_public(),
|
target_public_at_bridged_chain: bridged_chain_account_public(),
|
||||||
@@ -712,7 +740,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::create_swap(
|
Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT + 1),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT + 1),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
Box::new(test_swap_creation()),
|
Box::new(test_swap_creation()),
|
||||||
),
|
),
|
||||||
@@ -728,7 +756,7 @@ mod tests {
|
|||||||
swap.source_balance_at_this_chain = ExistentialDeposit::get() - 1;
|
swap.source_balance_at_this_chain = ExistentialDeposit::get() - 1;
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::create_swap(
|
Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
swap,
|
swap,
|
||||||
Box::new(test_swap_creation()),
|
Box::new(test_swap_creation()),
|
||||||
),
|
),
|
||||||
@@ -744,7 +772,7 @@ mod tests {
|
|||||||
swap.source_balance_at_this_chain = THIS_CHAIN_ACCOUNT_BALANCE + 1;
|
swap.source_balance_at_this_chain = THIS_CHAIN_ACCOUNT_BALANCE + 1;
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::create_swap(
|
Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
swap,
|
swap,
|
||||||
Box::new(test_swap_creation()),
|
Box::new(test_swap_creation()),
|
||||||
),
|
),
|
||||||
@@ -762,7 +790,7 @@ mod tests {
|
|||||||
swap_creation.bridged_currency_transfer = transfer;
|
swap_creation.bridged_currency_transfer = transfer;
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::create_swap(
|
Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
Box::new(swap_creation),
|
Box::new(swap_creation),
|
||||||
),
|
),
|
||||||
@@ -775,14 +803,14 @@ mod tests {
|
|||||||
fn create_swap_fails_if_swap_is_active() {
|
fn create_swap_fails_if_swap_is_active() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
assert_ok!(Pallet::<TestRuntime>::create_swap(
|
assert_ok!(Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
Box::new(test_swap_creation()),
|
Box::new(test_swap_creation()),
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::create_swap(
|
Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
Box::new(test_swap_creation()),
|
Box::new(test_swap_creation()),
|
||||||
),
|
),
|
||||||
@@ -797,7 +825,7 @@ mod tests {
|
|||||||
frame_system::Pallet::<TestRuntime>::set_block_number(CAN_START_BLOCK_NUMBER + 1);
|
frame_system::Pallet::<TestRuntime>::set_block_number(CAN_START_BLOCK_NUMBER + 1);
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::create_swap(
|
Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
Box::new(test_swap_creation()),
|
Box::new(test_swap_creation()),
|
||||||
),
|
),
|
||||||
@@ -811,7 +839,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
frame_system::Pallet::<TestRuntime>::set_block_number(CAN_START_BLOCK_NUMBER);
|
frame_system::Pallet::<TestRuntime>::set_block_number(CAN_START_BLOCK_NUMBER);
|
||||||
assert_ok!(Pallet::<TestRuntime>::create_swap(
|
assert_ok!(Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
Box::new(test_swap_creation()),
|
Box::new(test_swap_creation()),
|
||||||
));
|
));
|
||||||
@@ -825,7 +853,7 @@ mod tests {
|
|||||||
frame_system::Pallet::<TestRuntime>::reset_events();
|
frame_system::Pallet::<TestRuntime>::reset_events();
|
||||||
|
|
||||||
assert_ok!(Pallet::<TestRuntime>::create_swap(
|
assert_ok!(Pallet::<TestRuntime>::create_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
Box::new(test_swap_creation()),
|
Box::new(test_swap_creation()),
|
||||||
));
|
));
|
||||||
@@ -857,7 +885,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::claim_swap(
|
Pallet::<TestRuntime>::claim_swap(
|
||||||
Origin::signed(
|
mock::Origin::signed(
|
||||||
1 + target_account_at_this_chain::<TestRuntime, ()>(&test_swap())
|
1 + target_account_at_this_chain::<TestRuntime, ()>(&test_swap())
|
||||||
),
|
),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
@@ -874,7 +902,9 @@ mod tests {
|
|||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::claim_swap(
|
Pallet::<TestRuntime>::claim_swap(
|
||||||
Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(&test_swap())),
|
mock::Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(
|
||||||
|
&test_swap()
|
||||||
|
)),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
),
|
),
|
||||||
Error::<TestRuntime, ()>::SwapIsPending
|
Error::<TestRuntime, ()>::SwapIsPending
|
||||||
@@ -889,7 +919,9 @@ mod tests {
|
|||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::claim_swap(
|
Pallet::<TestRuntime>::claim_swap(
|
||||||
Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(&test_swap())),
|
mock::Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(
|
||||||
|
&test_swap()
|
||||||
|
)),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
),
|
),
|
||||||
Error::<TestRuntime, ()>::SwapIsFailed
|
Error::<TestRuntime, ()>::SwapIsFailed
|
||||||
@@ -902,7 +934,9 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::claim_swap(
|
Pallet::<TestRuntime>::claim_swap(
|
||||||
Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(&test_swap())),
|
mock::Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(
|
||||||
|
&test_swap()
|
||||||
|
)),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
),
|
),
|
||||||
Error::<TestRuntime, ()>::SwapIsInactive
|
Error::<TestRuntime, ()>::SwapIsInactive
|
||||||
@@ -918,7 +952,9 @@ mod tests {
|
|||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::claim_swap(
|
Pallet::<TestRuntime>::claim_swap(
|
||||||
Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(&test_swap())),
|
mock::Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(
|
||||||
|
&test_swap()
|
||||||
|
)),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
),
|
),
|
||||||
Error::<TestRuntime, ()>::FailedToTransferFromSwapAccount
|
Error::<TestRuntime, ()>::FailedToTransferFromSwapAccount
|
||||||
@@ -936,7 +972,9 @@ mod tests {
|
|||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::claim_swap(
|
Pallet::<TestRuntime>::claim_swap(
|
||||||
Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(&test_swap())),
|
mock::Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(
|
||||||
|
&test_swap()
|
||||||
|
)),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
),
|
),
|
||||||
Error::<TestRuntime, ()>::SwapIsTemporaryLocked
|
Error::<TestRuntime, ()>::SwapIsTemporaryLocked
|
||||||
@@ -954,7 +992,7 @@ mod tests {
|
|||||||
frame_system::Pallet::<TestRuntime>::reset_events();
|
frame_system::Pallet::<TestRuntime>::reset_events();
|
||||||
|
|
||||||
assert_ok!(Pallet::<TestRuntime>::claim_swap(
|
assert_ok!(Pallet::<TestRuntime>::claim_swap(
|
||||||
Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(&test_swap())),
|
mock::Origin::signed(target_account_at_this_chain::<TestRuntime, ()>(&test_swap())),
|
||||||
test_swap(),
|
test_swap(),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -990,7 +1028,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::cancel_swap(
|
Pallet::<TestRuntime>::cancel_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT + 1),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT + 1),
|
||||||
test_swap()
|
test_swap()
|
||||||
),
|
),
|
||||||
Error::<TestRuntime, ()>::MismatchedSwapSourceOrigin
|
Error::<TestRuntime, ()>::MismatchedSwapSourceOrigin
|
||||||
@@ -1004,7 +1042,10 @@ mod tests {
|
|||||||
start_test_swap();
|
start_test_swap();
|
||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::cancel_swap(Origin::signed(THIS_CHAIN_ACCOUNT), test_swap()),
|
Pallet::<TestRuntime>::cancel_swap(
|
||||||
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
|
test_swap()
|
||||||
|
),
|
||||||
Error::<TestRuntime, ()>::SwapIsPending
|
Error::<TestRuntime, ()>::SwapIsPending
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1017,7 +1058,10 @@ mod tests {
|
|||||||
receive_test_swap_confirmation(true);
|
receive_test_swap_confirmation(true);
|
||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::cancel_swap(Origin::signed(THIS_CHAIN_ACCOUNT), test_swap()),
|
Pallet::<TestRuntime>::cancel_swap(
|
||||||
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
|
test_swap()
|
||||||
|
),
|
||||||
Error::<TestRuntime, ()>::SwapIsConfirmed
|
Error::<TestRuntime, ()>::SwapIsConfirmed
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1027,7 +1071,10 @@ mod tests {
|
|||||||
fn cancel_swap_fails_if_swap_is_inactive() {
|
fn cancel_swap_fails_if_swap_is_inactive() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::cancel_swap(Origin::signed(THIS_CHAIN_ACCOUNT), test_swap()),
|
Pallet::<TestRuntime>::cancel_swap(
|
||||||
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
|
test_swap()
|
||||||
|
),
|
||||||
Error::<TestRuntime, ()>::SwapIsInactive
|
Error::<TestRuntime, ()>::SwapIsInactive
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1044,7 +1091,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Pallet::<TestRuntime>::cancel_swap(Origin::signed(THIS_CHAIN_ACCOUNT), test_swap()),
|
Pallet::<TestRuntime>::cancel_swap(
|
||||||
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
|
test_swap()
|
||||||
|
),
|
||||||
Error::<TestRuntime, ()>::FailedToTransferFromSwapAccount
|
Error::<TestRuntime, ()>::FailedToTransferFromSwapAccount
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1060,7 +1110,7 @@ mod tests {
|
|||||||
frame_system::Pallet::<TestRuntime>::reset_events();
|
frame_system::Pallet::<TestRuntime>::reset_events();
|
||||||
|
|
||||||
assert_ok!(Pallet::<TestRuntime>::cancel_swap(
|
assert_ok!(Pallet::<TestRuntime>::cancel_swap(
|
||||||
Origin::signed(THIS_CHAIN_ACCOUNT),
|
mock::Origin::signed(THIS_CHAIN_ACCOUNT),
|
||||||
test_swap()
|
test_swap()
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -1130,4 +1180,12 @@ mod tests {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn storage_keys_computed_properly() {
|
||||||
|
assert_eq!(
|
||||||
|
PendingSwaps::<TestRuntime>::storage_map_final_key(test_swap_hash()),
|
||||||
|
bp_token_swap::storage_keys::pending_swaps_key("TokenSwap", test_swap_hash()).0,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ frame_support::construct_runtime! {
|
|||||||
{
|
{
|
||||||
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
|
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
|
||||||
Balances: pallet_balances::{Pallet, Call, Event<T>},
|
Balances: pallet_balances::{Pallet, Call, Event<T>},
|
||||||
TokenSwap: pallet_bridge_token_swap::{Pallet, Call, Event<T>},
|
TokenSwap: pallet_bridge_token_swap::{Pallet, Call, Event<T>, Origin<T>},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,22 +143,34 @@ impl bp_runtime::Chain for BridgedChain {
|
|||||||
type Balance = BridgedBalance;
|
type Balance = BridgedBalance;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type Signature = BridgedAccountSignature;
|
type Signature = BridgedAccountSignature;
|
||||||
|
|
||||||
|
fn max_extrinsic_size() -> u32 {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
fn max_extrinsic_weight() -> Weight {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TestMessagesBridge;
|
pub struct TestMessagesBridge;
|
||||||
|
|
||||||
impl MessagesBridge<AccountId, Balance, MessagePayloadOf<TestRuntime, ()>> for TestMessagesBridge {
|
impl MessagesBridge<Origin, AccountId, Balance, MessagePayloadOf<TestRuntime, ()>>
|
||||||
|
for TestMessagesBridge
|
||||||
|
{
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn send_message(
|
fn send_message(
|
||||||
sender: frame_system::RawOrigin<AccountId>,
|
sender: Origin,
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
message: MessagePayloadOf<TestRuntime, ()>,
|
message: MessagePayloadOf<TestRuntime, ()>,
|
||||||
delivery_and_dispatch_fee: Balance,
|
delivery_and_dispatch_fee: Balance,
|
||||||
) -> Result<SendMessageArtifacts, Self::Error> {
|
) -> Result<SendMessageArtifacts, Self::Error> {
|
||||||
assert_ne!(sender, frame_system::RawOrigin::Signed(THIS_CHAIN_ACCOUNT));
|
|
||||||
assert_eq!(lane, OutboundMessageLaneId::get());
|
assert_eq!(lane, OutboundMessageLaneId::get());
|
||||||
assert_eq!(delivery_and_dispatch_fee, SWAP_DELIVERY_AND_DISPATCH_FEE);
|
assert_eq!(delivery_and_dispatch_fee, SWAP_DELIVERY_AND_DISPATCH_FEE);
|
||||||
|
match sender.caller {
|
||||||
|
OriginCaller::TokenSwap(_) => (),
|
||||||
|
_ => panic!("unexpected origin"),
|
||||||
|
}
|
||||||
match message.call[0] {
|
match message.call[0] {
|
||||||
OK_TRANSFER_CALL => Ok(SendMessageArtifacts { nonce: MESSAGE_NONCE, weight: 0 }),
|
OK_TRANSFER_CALL => Ok(SendMessageArtifacts { nonce: MESSAGE_NONCE, weight: 0 }),
|
||||||
BAD_TRANSFER_CALL => Err(()),
|
BAD_TRANSFER_CALL => Err(()),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
//! Autogenerated weights for `pallet_bridge_token_swap`
|
//! Autogenerated weights for `pallet_bridge_token_swap`
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2021-10-06, STEPS: 50, REPEAT: 20
|
//! DATE: 2021-12-28, STEPS: 50, REPEAT: 20
|
||||||
//! LOW RANGE: [], HIGH RANGE: []
|
//! LOW RANGE: [], HIGH RANGE: []
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
||||||
//! CHAIN: Some("dev"), DB CACHE: 128
|
//! CHAIN: Some("dev"), DB CACHE: 128
|
||||||
@@ -57,17 +57,17 @@ pub trait WeightInfo {
|
|||||||
pub struct MillauWeight<T>(PhantomData<T>);
|
pub struct MillauWeight<T>(PhantomData<T>);
|
||||||
impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
||||||
fn create_swap() -> Weight {
|
fn create_swap() -> Weight {
|
||||||
(116_040_000 as Weight)
|
(90_368_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||||
}
|
}
|
||||||
fn claim_swap() -> Weight {
|
fn claim_swap() -> Weight {
|
||||||
(102_882_000 as Weight)
|
(88_397_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn cancel_swap() -> Weight {
|
fn cancel_swap() -> Weight {
|
||||||
(99_434_000 as Weight)
|
(91_253_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
@@ -76,17 +76,17 @@ impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
|||||||
// For backwards compatibility and tests
|
// For backwards compatibility and tests
|
||||||
impl WeightInfo for () {
|
impl WeightInfo for () {
|
||||||
fn create_swap() -> Weight {
|
fn create_swap() -> Weight {
|
||||||
(116_040_000 as Weight)
|
(90_368_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||||
}
|
}
|
||||||
fn claim_swap() -> Weight {
|
fn claim_swap() -> Weight {
|
||||||
(102_882_000 as Weight)
|
(88_397_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
fn cancel_swap() -> Weight {
|
fn cancel_swap() -> Weight {
|
||||||
(99_434_000 as Weight)
|
(91_253_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "bp-kusama"
|
|||||||
description = "Primitives of Kusama runtime."
|
description = "Primitives of Kusama runtime."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -19,6 +19,7 @@ bp-runtime = { path = "../runtime", default-features = false }
|
|||||||
|
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
frame-support = { 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 }
|
||||||
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ std = [
|
|||||||
"bp-runtime/std",
|
"bp-runtime/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"sp-api/std",
|
"sp-api/std",
|
||||||
|
"sp-runtime/std",
|
||||||
"sp-std/std",
|
"sp-std/std",
|
||||||
"sp-version/std",
|
"sp-version/std",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -18,10 +18,11 @@
|
|||||||
// RuntimeApi generated functions
|
// RuntimeApi generated functions
|
||||||
#![allow(clippy::too_many_arguments)]
|
#![allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce};
|
||||||
use frame_support::weights::{
|
use frame_support::weights::{
|
||||||
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::FixedU128;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
@@ -35,10 +36,11 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
spec_name: sp_version::create_runtime_str!("kusama"),
|
spec_name: sp_version::create_runtime_str!("kusama"),
|
||||||
impl_name: sp_version::create_runtime_str!("parity-kusama"),
|
impl_name: sp_version::create_runtime_str!("parity-kusama"),
|
||||||
authoring_version: 2,
|
authoring_version: 2,
|
||||||
spec_version: 9100,
|
spec_version: 9180,
|
||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: sp_version::create_apis_vec![[]],
|
apis: sp_version::create_apis_vec![[]],
|
||||||
transaction_version: 5,
|
transaction_version: 11,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: This needs to be kept up to date with the Kusama runtime found in the Polkadot repo.
|
// NOTE: This needs to be kept up to date with the Kusama runtime found in the Polkadot repo.
|
||||||
@@ -79,17 +81,22 @@ pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 30_000;
|
|||||||
/// conditions.
|
/// conditions.
|
||||||
pub const SESSION_LENGTH: BlockNumber = time_units::HOURS;
|
pub const SESSION_LENGTH: BlockNumber = time_units::HOURS;
|
||||||
|
|
||||||
/// Name of the With-Polkadot messages pallet instance in the Kusama runtime.
|
/// Name of the With-Kusama GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
pub const WITH_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages";
|
pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa";
|
||||||
|
/// Name of the With-Kusama messages pallet instance that is deployed at bridged chains.
|
||||||
|
pub const WITH_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages";
|
||||||
|
|
||||||
|
/// Name of the transaction payment pallet at the Kusama runtime.
|
||||||
|
pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment";
|
||||||
|
|
||||||
/// Name of the DOT->KSM conversion rate stored in the Kusama runtime.
|
/// Name of the DOT->KSM conversion rate stored in the Kusama runtime.
|
||||||
pub const POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME: &str =
|
pub const POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME: &str =
|
||||||
"PolkadotToKusamaConversionRate";
|
"PolkadotToKusamaConversionRate";
|
||||||
|
/// Name of the Polkadot fee multiplier parameter, stored in the Polkadot runtime.
|
||||||
|
pub const POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME: &str = "PolkadotFeeMultiplier";
|
||||||
|
|
||||||
/// Name of the `KusamaFinalityApi::best_finalized` runtime method.
|
/// Name of the `KusamaFinalityApi::best_finalized` runtime method.
|
||||||
pub const BEST_FINALIZED_KUSAMA_HEADER_METHOD: &str = "KusamaFinalityApi_best_finalized";
|
pub const BEST_FINALIZED_KUSAMA_HEADER_METHOD: &str = "KusamaFinalityApi_best_finalized";
|
||||||
/// Name of the `KusamaFinalityApi::is_known_header` runtime method.
|
|
||||||
pub const IS_KNOWN_KUSAMA_HEADER_METHOD: &str = "KusamaFinalityApi_is_known_header";
|
|
||||||
|
|
||||||
/// Name of the `ToKusamaOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
/// Name of the `ToKusamaOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||||
/// method.
|
/// method.
|
||||||
@@ -97,22 +104,6 @@ pub const TO_KUSAMA_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
|||||||
"ToKusamaOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToKusamaOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method.
|
/// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "ToKusamaOutboundLaneApi_message_details";
|
pub const TO_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "ToKusamaOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToKusamaOutboundLaneApi::latest_generated_nonce` runtime method.
|
|
||||||
pub const TO_KUSAMA_LATEST_GENERATED_NONCE_METHOD: &str =
|
|
||||||
"ToKusamaOutboundLaneApi_latest_generated_nonce";
|
|
||||||
/// Name of the `ToKusamaOutboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const TO_KUSAMA_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"ToKusamaOutboundLaneApi_latest_received_nonce";
|
|
||||||
|
|
||||||
/// Name of the `FromKusamaInboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const FROM_KUSAMA_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"FromKusamaInboundLaneApi_latest_received_nonce";
|
|
||||||
/// Name of the `FromKusamaInboundLaneApi::latest_onfirmed_nonce` runtime method.
|
|
||||||
pub const FROM_KUSAMA_LATEST_CONFIRMED_NONCE_METHOD: &str =
|
|
||||||
"FromKusamaInboundLaneApi_latest_confirmed_nonce";
|
|
||||||
/// Name of the `FromKusamaInboundLaneApi::unrewarded_relayers_state` runtime method.
|
|
||||||
pub const FROM_KUSAMA_UNREWARDED_RELAYERS_STATE: &str =
|
|
||||||
"FromKusamaInboundLaneApi_unrewarded_relayers_state";
|
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about the finalized Kusama headers.
|
/// API for querying information about the finalized Kusama headers.
|
||||||
@@ -122,8 +113,6 @@ sp_api::decl_runtime_apis! {
|
|||||||
pub trait KusamaFinalityApi {
|
pub trait KusamaFinalityApi {
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||||
fn best_finalized() -> (BlockNumber, Hash);
|
fn best_finalized() -> (BlockNumber, Hash);
|
||||||
/// Returns true if the header is known to the runtime.
|
|
||||||
fn is_known_header(hash: Hash) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Outbound message lane API for messages that are sent to Kusama chain.
|
/// Outbound message lane API for messages that are sent to Kusama chain.
|
||||||
@@ -143,6 +132,7 @@ sp_api::decl_runtime_apis! {
|
|||||||
fn estimate_message_delivery_and_dispatch_fee(
|
fn estimate_message_delivery_and_dispatch_fee(
|
||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
|
kusama_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
/// messages in given inclusive range.
|
/// messages in given inclusive range.
|
||||||
@@ -154,22 +144,5 @@ sp_api::decl_runtime_apis! {
|
|||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
|
||||||
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inbound message lane API for messages sent by Kusama chain.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are receiving messages from Kusama chain, not the
|
|
||||||
/// Kusama runtime itself.
|
|
||||||
pub trait FromKusamaInboundLaneApi {
|
|
||||||
/// Returns nonce of the latest message, received by given lane.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Nonce of the latest message that has been confirmed to the bridged chain.
|
|
||||||
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// State of the unrewarded relayers set at given lane.
|
|
||||||
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "bp-millau"
|
|||||||
description = "Primitives of Millau runtime."
|
description = "Primitives of Millau runtime."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -14,10 +14,10 @@ bp-messages = { path = "../messages", default-features = false }
|
|||||||
bp-runtime = { path = "../runtime", default-features = false }
|
bp-runtime = { path = "../runtime", default-features = false }
|
||||||
fixed-hash = { version = "0.7.0", default-features = false }
|
fixed-hash = { version = "0.7.0", default-features = false }
|
||||||
hash256-std-hasher = { version = "0.15.2", default-features = false }
|
hash256-std-hasher = { version = "0.15.2", default-features = false }
|
||||||
impl-codec = { version = "0.5.1", default-features = false }
|
impl-codec = { version = "0.6", default-features = false }
|
||||||
impl-serde = { version = "0.3.1", optional = true }
|
impl-serde = { version = "0.3.1", optional = true }
|
||||||
parity-util-mem = { version = "0.10", default-features = false, features = ["primitive-types"] }
|
parity-util-mem = { version = "0.11", default-features = false, features = ["primitive-types"] }
|
||||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||||
|
|
||||||
# Substrate Based Dependencies
|
# Substrate Based Dependencies
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
mod millau_hash;
|
mod millau_hash;
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||||
@@ -28,13 +28,13 @@ use frame_support::{
|
|||||||
};
|
};
|
||||||
use frame_system::limits;
|
use frame_system::limits;
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_core::Hasher as HasherT;
|
use sp_core::{storage::StateVersion, Hasher as HasherT};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{Convert, IdentifyAccount, Verify},
|
traits::{Convert, IdentifyAccount, Verify},
|
||||||
MultiSignature, MultiSigner, Perbill,
|
FixedU128, MultiSignature, MultiSigner, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_trie::{trie_types::Layout, TrieConfiguration};
|
use sp_trie::{LayoutV0, LayoutV1, TrieConfiguration};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -66,11 +66,11 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
|||||||
/// Represents the portion of a block that will be used by Normal extrinsics.
|
/// Represents the portion of a block that will be used by Normal extrinsics.
|
||||||
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||||
|
|
||||||
/// Maximal number of unrewarded relayer entries at inbound lane.
|
/// Maximal number of unrewarded relayer entries in Millau confirmation transaction.
|
||||||
pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 1024;
|
pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 128;
|
||||||
|
|
||||||
/// Maximal number of unconfirmed messages at inbound lane.
|
/// Maximal number of unconfirmed messages in Millau confirmation transaction.
|
||||||
pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 1024;
|
pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 128;
|
||||||
|
|
||||||
/// Weight of single regular message delivery transaction on Millau chain.
|
/// Weight of single regular message delivery transaction on Millau chain.
|
||||||
///
|
///
|
||||||
@@ -101,7 +101,7 @@ pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000
|
|||||||
/// chain. Don't put too much reserve there, because it is used to **decrease**
|
/// chain. Don't put too much reserve there, because it is used to **decrease**
|
||||||
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
|
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
|
||||||
/// transactions cheaper.
|
/// transactions cheaper.
|
||||||
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
|
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 700_000_000;
|
||||||
|
|
||||||
/// The target length of a session (how often authorities change) on Millau measured in of number of
|
/// The target length of a session (how often authorities change) on Millau measured in of number of
|
||||||
/// blocks.
|
/// blocks.
|
||||||
@@ -170,6 +170,17 @@ impl Chain for Millau {
|
|||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
type Index = Index;
|
type Index = Index;
|
||||||
type Signature = Signature;
|
type Signature = Signature;
|
||||||
|
|
||||||
|
fn max_extrinsic_size() -> u32 {
|
||||||
|
*BlockLength::get().max.get(DispatchClass::Normal)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn max_extrinsic_weight() -> Weight {
|
||||||
|
BlockWeights::get()
|
||||||
|
.get(DispatchClass::Normal)
|
||||||
|
.max_extrinsic
|
||||||
|
.unwrap_or(Weight::MAX)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Millau Hasher (Blake2-256 ++ Keccak-256) implementation.
|
/// Millau Hasher (Blake2-256 ++ Keccak-256) implementation.
|
||||||
@@ -193,12 +204,18 @@ impl sp_core::Hasher for BlakeTwoAndKeccak256 {
|
|||||||
impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 {
|
impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 {
|
||||||
type Output = MillauHash;
|
type Output = MillauHash;
|
||||||
|
|
||||||
fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>) -> Self::Output {
|
fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>, state_version: StateVersion) -> Self::Output {
|
||||||
Layout::<BlakeTwoAndKeccak256>::trie_root(input)
|
match state_version {
|
||||||
|
StateVersion::V0 => LayoutV0::<BlakeTwoAndKeccak256>::trie_root(input),
|
||||||
|
StateVersion::V1 => LayoutV1::<BlakeTwoAndKeccak256>::trie_root(input),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ordered_trie_root(input: Vec<Vec<u8>>) -> Self::Output {
|
fn ordered_trie_root(input: Vec<Vec<u8>>, state_version: StateVersion) -> Self::Output {
|
||||||
Layout::<BlakeTwoAndKeccak256>::ordered_trie_root(input)
|
match state_version {
|
||||||
|
StateVersion::V0 => LayoutV0::<BlakeTwoAndKeccak256>::ordered_trie_root(input),
|
||||||
|
StateVersion::V1 => LayoutV1::<BlakeTwoAndKeccak256>::ordered_trie_root(input),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,21 +261,14 @@ frame_support::parameter_types! {
|
|||||||
.build_or_panic();
|
.build_or_panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the maximum weight (compute time) that a Normal extrinsic on the Millau chain can use.
|
/// Name of the With-Millau GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
pub fn max_extrinsic_weight() -> Weight {
|
pub const WITH_MILLAU_GRANDPA_PALLET_NAME: &str = "BridgeMillauGrandpa";
|
||||||
BlockWeights::get()
|
/// Name of the With-Millau messages pallet instance that is deployed at bridged chains.
|
||||||
.get(DispatchClass::Normal)
|
pub const WITH_MILLAU_MESSAGES_PALLET_NAME: &str = "BridgeMillauMessages";
|
||||||
.max_extrinsic
|
|
||||||
.unwrap_or(Weight::MAX)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the maximum length in bytes that a Normal extrinsic on the Millau chain requires.
|
/// Name of the Rialto->Millau (actually DOT->KSM) conversion rate stored in the Millau runtime.
|
||||||
pub fn max_extrinsic_size() -> u32 {
|
pub const RIALTO_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME: &str = "RialtoToMillauConversionRate";
|
||||||
*BlockLength::get().max.get(DispatchClass::Normal)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Name of the With-Rialto messages pallet instance in the Millau runtime.
|
|
||||||
pub const WITH_RIALTO_MESSAGES_PALLET_NAME: &str = "BridgeRialtoMessages";
|
|
||||||
/// Name of the With-Rialto token swap pallet instance in the Millau runtime.
|
/// Name of the With-Rialto token swap pallet instance in the Millau runtime.
|
||||||
pub const WITH_RIALTO_TOKEN_SWAP_PALLET_NAME: &str = "BridgeRialtoTokenSwap";
|
pub const WITH_RIALTO_TOKEN_SWAP_PALLET_NAME: &str = "BridgeRialtoTokenSwap";
|
||||||
|
|
||||||
@@ -271,22 +281,6 @@ pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
|||||||
"ToMillauOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToMillauOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToMillauOutboundLaneApi::message_details` runtime method.
|
/// Name of the `ToMillauOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_MILLAU_MESSAGE_DETAILS_METHOD: &str = "ToMillauOutboundLaneApi_message_details";
|
pub const TO_MILLAU_MESSAGE_DETAILS_METHOD: &str = "ToMillauOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToMillauOutboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const TO_MILLAU_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"ToMillauOutboundLaneApi_latest_received_nonce";
|
|
||||||
/// Name of the `ToMillauOutboundLaneApi::latest_generated_nonce` runtime method.
|
|
||||||
pub const TO_MILLAU_LATEST_GENERATED_NONCE_METHOD: &str =
|
|
||||||
"ToMillauOutboundLaneApi_latest_generated_nonce";
|
|
||||||
|
|
||||||
/// Name of the `FromMillauInboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const FROM_MILLAU_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"FromMillauInboundLaneApi_latest_received_nonce";
|
|
||||||
/// Name of the `FromMillauInboundLaneApi::latest_onfirmed_nonce` runtime method.
|
|
||||||
pub const FROM_MILLAU_LATEST_CONFIRMED_NONCE_METHOD: &str =
|
|
||||||
"FromMillauInboundLaneApi_latest_confirmed_nonce";
|
|
||||||
/// Name of the `FromMillauInboundLaneApi::unrewarded_relayers_state` runtime method.
|
|
||||||
pub const FROM_MILLAU_UNREWARDED_RELAYERS_STATE: &str =
|
|
||||||
"FromMillauInboundLaneApi_unrewarded_relayers_state";
|
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about the finalized Millau headers.
|
/// API for querying information about the finalized Millau headers.
|
||||||
@@ -296,8 +290,6 @@ sp_api::decl_runtime_apis! {
|
|||||||
pub trait MillauFinalityApi {
|
pub trait MillauFinalityApi {
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||||
fn best_finalized() -> (BlockNumber, Hash);
|
fn best_finalized() -> (BlockNumber, Hash);
|
||||||
/// Returns true if the header is known to the runtime.
|
|
||||||
fn is_known_header(hash: Hash) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Outbound message lane API for messages that are sent to Millau chain.
|
/// Outbound message lane API for messages that are sent to Millau chain.
|
||||||
@@ -317,6 +309,7 @@ sp_api::decl_runtime_apis! {
|
|||||||
fn estimate_message_delivery_and_dispatch_fee(
|
fn estimate_message_delivery_and_dispatch_fee(
|
||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
|
millau_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
/// messages in given inclusive range.
|
/// messages in given inclusive range.
|
||||||
@@ -328,23 +321,6 @@ sp_api::decl_runtime_apis! {
|
|||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
|
||||||
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inbound message lane API for messages sent by Millau chain.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are receiving messages from Millau chain, not the
|
|
||||||
/// Millau runtime itself.
|
|
||||||
pub trait FromMillauInboundLaneApi {
|
|
||||||
/// Returns nonce of the latest message, received by given lane.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Nonce of the latest message that has been confirmed to the bridged chain.
|
|
||||||
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// State of the unrewarded relayers set at given lane.
|
|
||||||
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,9 +332,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn maximal_account_size_does_not_overflow_constant() {
|
fn maximal_account_size_does_not_overflow_constant() {
|
||||||
assert!(
|
assert!(
|
||||||
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize >= AccountId::default().encode().len(),
|
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize >= AccountId::from([0u8; 32]).encode().len(),
|
||||||
"Actual maximal size of encoded AccountId ({}) overflows expected ({})",
|
"Actual maximal size of encoded AccountId ({}) overflows expected ({})",
|
||||||
AccountId::default().encode().len(),
|
AccountId::from([0u8; 32]).encode().len(),
|
||||||
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "bp-polkadot"
|
|||||||
description = "Primitives of Polkadot runtime."
|
description = "Primitives of Polkadot runtime."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -19,6 +19,7 @@ bp-runtime = { path = "../runtime", default-features = false }
|
|||||||
|
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
frame-support = { 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 }
|
||||||
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ std = [
|
|||||||
"bp-runtime/std",
|
"bp-runtime/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"sp-api/std",
|
"sp-api/std",
|
||||||
|
"sp-runtime/std",
|
||||||
"sp-std/std",
|
"sp-std/std",
|
||||||
"sp-version/std",
|
"sp-version/std",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -18,10 +18,11 @@
|
|||||||
// RuntimeApi generated functions
|
// RuntimeApi generated functions
|
||||||
#![allow(clippy::too_many_arguments)]
|
#![allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce};
|
||||||
use frame_support::weights::{
|
use frame_support::weights::{
|
||||||
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::FixedU128;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
@@ -35,10 +36,11 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
spec_name: sp_version::create_runtime_str!("polkadot"),
|
spec_name: sp_version::create_runtime_str!("polkadot"),
|
||||||
impl_name: sp_version::create_runtime_str!("parity-polkadot"),
|
impl_name: sp_version::create_runtime_str!("parity-polkadot"),
|
||||||
authoring_version: 0,
|
authoring_version: 0,
|
||||||
spec_version: 9100,
|
spec_version: 9180,
|
||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: sp_version::create_apis_vec![[]],
|
apis: sp_version::create_apis_vec![[]],
|
||||||
transaction_version: 7,
|
transaction_version: 12,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: This needs to be kept up to date with the Polkadot runtime found in the Polkadot repo.
|
// NOTE: This needs to be kept up to date with the Polkadot runtime found in the Polkadot repo.
|
||||||
@@ -79,17 +81,22 @@ pub const EXISTENTIAL_DEPOSIT: Balance = 10_000_000_000;
|
|||||||
/// conditions.
|
/// conditions.
|
||||||
pub const SESSION_LENGTH: BlockNumber = 4 * time_units::HOURS;
|
pub const SESSION_LENGTH: BlockNumber = 4 * time_units::HOURS;
|
||||||
|
|
||||||
/// Name of the With-Kusama messages pallet instance in the Polkadot runtime.
|
/// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
pub const WITH_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages";
|
pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa";
|
||||||
|
/// Name of the With-Polkadot messages pallet instance that is deployed at bridged chains.
|
||||||
|
pub const WITH_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages";
|
||||||
|
|
||||||
/// Name of the KSM->DOT conversion rate stored in the Polkadot runtime.
|
/// Name of the transaction payment pallet at the Polkadot runtime.
|
||||||
|
pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment";
|
||||||
|
|
||||||
|
/// Name of the KSM->DOT conversion rate parameter, stored in the Polkadot runtime.
|
||||||
pub const KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME: &str =
|
pub const KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME: &str =
|
||||||
"KusamaToPolkadotConversionRate";
|
"KusamaToPolkadotConversionRate";
|
||||||
|
/// Name of the Kusama fee multiplier parameter, stored in the Polkadot runtime.
|
||||||
|
pub const KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME: &str = "KusamaFeeMultiplier";
|
||||||
|
|
||||||
/// Name of the `PolkadotFinalityApi::best_finalized` runtime method.
|
/// Name of the `PolkadotFinalityApi::best_finalized` runtime method.
|
||||||
pub const BEST_FINALIZED_POLKADOT_HEADER_METHOD: &str = "PolkadotFinalityApi_best_finalized";
|
pub const BEST_FINALIZED_POLKADOT_HEADER_METHOD: &str = "PolkadotFinalityApi_best_finalized";
|
||||||
/// Name of the `PolkadotFinalityApi::is_known_header` runtime method.
|
|
||||||
pub const IS_KNOWN_POLKADOT_HEADER_METHOD: &str = "PolkadotFinalityApi_is_known_header";
|
|
||||||
|
|
||||||
/// Name of the `ToPolkadotOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
/// Name of the `ToPolkadotOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||||
/// method.
|
/// method.
|
||||||
@@ -97,22 +104,6 @@ pub const TO_POLKADOT_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
|||||||
"ToPolkadotOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToPolkadotOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method.
|
/// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_POLKADOT_MESSAGE_DETAILS_METHOD: &str = "ToPolkadotOutboundLaneApi_message_details";
|
pub const TO_POLKADOT_MESSAGE_DETAILS_METHOD: &str = "ToPolkadotOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToPolkadotOutboundLaneApi::latest_generated_nonce` runtime method.
|
|
||||||
pub const TO_POLKADOT_LATEST_GENERATED_NONCE_METHOD: &str =
|
|
||||||
"ToPolkadotOutboundLaneApi_latest_generated_nonce";
|
|
||||||
/// Name of the `ToPolkadotOutboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const TO_POLKADOT_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"ToPolkadotOutboundLaneApi_latest_received_nonce";
|
|
||||||
|
|
||||||
/// Name of the `FromPolkadotInboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const FROM_POLKADOT_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"FromPolkadotInboundLaneApi_latest_received_nonce";
|
|
||||||
/// Name of the `FromPolkadotInboundLaneApi::latest_onfirmed_nonce` runtime method.
|
|
||||||
pub const FROM_POLKADOT_LATEST_CONFIRMED_NONCE_METHOD: &str =
|
|
||||||
"FromPolkadotInboundLaneApi_latest_confirmed_nonce";
|
|
||||||
/// Name of the `FromPolkadotInboundLaneApi::unrewarded_relayers_state` runtime method.
|
|
||||||
pub const FROM_POLKADOT_UNREWARDED_RELAYERS_STATE: &str =
|
|
||||||
"FromPolkadotInboundLaneApi_unrewarded_relayers_state";
|
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about the finalized Polkadot headers.
|
/// API for querying information about the finalized Polkadot headers.
|
||||||
@@ -122,8 +113,6 @@ sp_api::decl_runtime_apis! {
|
|||||||
pub trait PolkadotFinalityApi {
|
pub trait PolkadotFinalityApi {
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||||
fn best_finalized() -> (BlockNumber, Hash);
|
fn best_finalized() -> (BlockNumber, Hash);
|
||||||
/// Returns true if the header is known to the runtime.
|
|
||||||
fn is_known_header(hash: Hash) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Outbound message lane API for messages that are sent to Polkadot chain.
|
/// Outbound message lane API for messages that are sent to Polkadot chain.
|
||||||
@@ -143,6 +132,7 @@ sp_api::decl_runtime_apis! {
|
|||||||
fn estimate_message_delivery_and_dispatch_fee(
|
fn estimate_message_delivery_and_dispatch_fee(
|
||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
|
polkadot_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
/// messages in given inclusive range.
|
/// messages in given inclusive range.
|
||||||
@@ -154,22 +144,5 @@ sp_api::decl_runtime_apis! {
|
|||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
|
||||||
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inbound message lane API for messages sent by Polkadot chain.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are receiving messages from Polkadot chain, not the
|
|
||||||
/// Polkadot runtime itself.
|
|
||||||
pub trait FromPolkadotInboundLaneApi {
|
|
||||||
/// Returns nonce of the latest message, received by given lane.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Nonce of the latest message that has been confirmed to the bridged chain.
|
|
||||||
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// State of the unrewarded relayers set at given lane.
|
|
||||||
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "bp-rialto-parachain"
|
|||||||
description = "Primitives of Rialto parachain runtime."
|
description = "Primitives of Rialto parachain runtime."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -90,6 +90,17 @@ impl Chain for RialtoParachain {
|
|||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
type Index = Index;
|
type Index = Index;
|
||||||
type Signature = Signature;
|
type Signature = Signature;
|
||||||
|
|
||||||
|
fn max_extrinsic_size() -> u32 {
|
||||||
|
*BlockLength::get().max.get(DispatchClass::Normal)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn max_extrinsic_weight() -> Weight {
|
||||||
|
BlockWeights::get()
|
||||||
|
.get(DispatchClass::Normal)
|
||||||
|
.max_extrinsic
|
||||||
|
.unwrap_or(Weight::MAX)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
@@ -111,16 +122,3 @@ frame_support::parameter_types! {
|
|||||||
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
|
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
|
||||||
.build_or_panic();
|
.build_or_panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the maximum weight (compute time) that a Normal extrinsic on the Millau chain can use.
|
|
||||||
pub fn max_extrinsic_weight() -> Weight {
|
|
||||||
BlockWeights::get()
|
|
||||||
.get(DispatchClass::Normal)
|
|
||||||
.max_extrinsic
|
|
||||||
.unwrap_or(Weight::MAX)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the maximum length in bytes that a Normal extrinsic on the Millau chain requires.
|
|
||||||
pub fn max_extrinsic_size() -> u32 {
|
|
||||||
*BlockLength::get().max.get(DispatchClass::Normal)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "bp-rialto"
|
|||||||
description = "Primitives of Rialto runtime."
|
description = "Primitives of Rialto runtime."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
// RuntimeApi generated functions
|
// RuntimeApi generated functions
|
||||||
#![allow(clippy::too_many_arguments)]
|
#![allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||||
@@ -28,7 +28,7 @@ use frame_system::limits;
|
|||||||
use sp_core::Hasher as HasherT;
|
use sp_core::Hasher as HasherT;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{BlakeTwo256, Convert, IdentifyAccount, Verify},
|
traits::{BlakeTwo256, Convert, IdentifyAccount, Verify},
|
||||||
MultiSignature, MultiSigner, Perbill,
|
FixedU128, MultiSignature, MultiSigner, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
@@ -57,11 +57,11 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
|||||||
/// Represents the portion of a block that will be used by Normal extrinsics.
|
/// Represents the portion of a block that will be used by Normal extrinsics.
|
||||||
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||||
|
|
||||||
/// Maximal number of unrewarded relayer entries at inbound lane.
|
/// Maximal number of unrewarded relayer entries in Rialto confirmation transaction.
|
||||||
pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 128;
|
pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024;
|
||||||
|
|
||||||
/// Maximal number of unconfirmed messages at inbound lane.
|
/// Maximal number of unconfirmed messages in Rialto confirmation transaction.
|
||||||
pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 128;
|
pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 1024;
|
||||||
|
|
||||||
/// Weight of single regular message delivery transaction on Rialto chain.
|
/// Weight of single regular message delivery transaction on Rialto chain.
|
||||||
///
|
///
|
||||||
@@ -92,7 +92,7 @@ pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000
|
|||||||
/// chain. Don't put too much reserve there, because it is used to **decrease**
|
/// chain. Don't put too much reserve there, because it is used to **decrease**
|
||||||
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
|
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
|
||||||
/// transactions cheaper.
|
/// transactions cheaper.
|
||||||
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
|
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 700_000_000;
|
||||||
|
|
||||||
/// The target length of a session (how often authorities change) on Rialto measured in of number of
|
/// The target length of a session (how often authorities change) on Rialto measured in of number of
|
||||||
/// blocks.
|
/// blocks.
|
||||||
@@ -169,6 +169,17 @@ impl Chain for Rialto {
|
|||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
type Index = Index;
|
type Index = Index;
|
||||||
type Signature = Signature;
|
type Signature = Signature;
|
||||||
|
|
||||||
|
fn max_extrinsic_size() -> u32 {
|
||||||
|
*BlockLength::get().max.get(DispatchClass::Normal)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn max_extrinsic_weight() -> Weight {
|
||||||
|
BlockWeights::get()
|
||||||
|
.get(DispatchClass::Normal)
|
||||||
|
.max_extrinsic
|
||||||
|
.unwrap_or(Weight::MAX)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 256-bit hash into an AccountId.
|
/// Convert a 256-bit hash into an AccountId.
|
||||||
@@ -213,21 +224,13 @@ frame_support::parameter_types! {
|
|||||||
.build_or_panic();
|
.build_or_panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the maximum weight (compute time) that a Normal extrinsic on the Millau chain can use.
|
/// Name of the With-Rialto GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
pub fn max_extrinsic_weight() -> Weight {
|
pub const WITH_RIALTO_GRANDPA_PALLET_NAME: &str = "BridgeRialtoGrandpa";
|
||||||
BlockWeights::get()
|
/// Name of the With-Rialto messages pallet instance that is deployed at bridged chains.
|
||||||
.get(DispatchClass::Normal)
|
pub const WITH_RIALTO_MESSAGES_PALLET_NAME: &str = "BridgeRialtoMessages";
|
||||||
.max_extrinsic
|
|
||||||
.unwrap_or(Weight::MAX)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the maximum length in bytes that a Normal extrinsic on the Millau chain requires.
|
/// Name of the Millau->Rialto (actually KSM->DOT) conversion rate stored in the Rialto runtime.
|
||||||
pub fn max_extrinsic_size() -> u32 {
|
pub const MILLAU_TO_RIALTO_CONVERSION_RATE_PARAMETER_NAME: &str = "MillauToRialtoConversionRate";
|
||||||
*BlockLength::get().max.get(DispatchClass::Normal)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Name of the With-Millau messages pallet instance in the Rialto runtime.
|
|
||||||
pub const WITH_MILLAU_MESSAGES_PALLET_NAME: &str = "BridgeMillauMessages";
|
|
||||||
|
|
||||||
/// Name of the parachain registrar pallet in the Rialto runtime.
|
/// Name of the parachain registrar pallet in the Rialto runtime.
|
||||||
pub const PARAS_REGISTRAR_PALLET_NAME: &str = "Registrar";
|
pub const PARAS_REGISTRAR_PALLET_NAME: &str = "Registrar";
|
||||||
@@ -244,22 +247,6 @@ pub const TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
|||||||
"ToRialtoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToRialtoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method.
|
/// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_RIALTO_MESSAGE_DETAILS_METHOD: &str = "ToRialtoOutboundLaneApi_message_details";
|
pub const TO_RIALTO_MESSAGE_DETAILS_METHOD: &str = "ToRialtoOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToRialtoOutboundLaneApi::latest_generated_nonce` runtime method.
|
|
||||||
pub const TO_RIALTO_LATEST_GENERATED_NONCE_METHOD: &str =
|
|
||||||
"ToRialtoOutboundLaneApi_latest_generated_nonce";
|
|
||||||
/// Name of the `ToRialtoOutboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const TO_RIALTO_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"ToRialtoOutboundLaneApi_latest_received_nonce";
|
|
||||||
|
|
||||||
/// Name of the `FromRialtoInboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const FROM_RIALTO_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"FromRialtoInboundLaneApi_latest_received_nonce";
|
|
||||||
/// Name of the `FromRialtoInboundLaneApi::latest_onfirmed_nonce` runtime method.
|
|
||||||
pub const FROM_RIALTO_LATEST_CONFIRMED_NONCE_METHOD: &str =
|
|
||||||
"FromRialtoInboundLaneApi_latest_confirmed_nonce";
|
|
||||||
/// Name of the `FromRialtoInboundLaneApi::unrewarded_relayers_state` runtime method.
|
|
||||||
pub const FROM_RIALTO_UNREWARDED_RELAYERS_STATE: &str =
|
|
||||||
"FromRialtoInboundLaneApi_unrewarded_relayers_state";
|
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about the finalized Rialto headers.
|
/// API for querying information about the finalized Rialto headers.
|
||||||
@@ -269,8 +256,6 @@ sp_api::decl_runtime_apis! {
|
|||||||
pub trait RialtoFinalityApi {
|
pub trait RialtoFinalityApi {
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||||
fn best_finalized() -> (BlockNumber, Hash);
|
fn best_finalized() -> (BlockNumber, Hash);
|
||||||
/// Returns true if the header is known to the runtime.
|
|
||||||
fn is_known_header(hash: Hash) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Outbound message lane API for messages that are sent to Rialto chain.
|
/// Outbound message lane API for messages that are sent to Rialto chain.
|
||||||
@@ -290,6 +275,7 @@ sp_api::decl_runtime_apis! {
|
|||||||
fn estimate_message_delivery_and_dispatch_fee(
|
fn estimate_message_delivery_and_dispatch_fee(
|
||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
|
rialto_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
/// messages in given inclusive range.
|
/// messages in given inclusive range.
|
||||||
@@ -301,23 +287,6 @@ sp_api::decl_runtime_apis! {
|
|||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
|
||||||
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inbound message lane API for messages sent by Rialto chain.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are receiving messages from Rialto chain, not the
|
|
||||||
/// Rialto runtime itself.
|
|
||||||
pub trait FromRialtoInboundLaneApi {
|
|
||||||
/// Returns nonce of the latest message, received by given lane.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Nonce of the latest message that has been confirmed to the bridged chain.
|
|
||||||
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// State of the unrewarded relayers set at given lane.
|
|
||||||
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,9 +298,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn maximal_account_size_does_not_overflow_constant() {
|
fn maximal_account_size_does_not_overflow_constant() {
|
||||||
assert!(
|
assert!(
|
||||||
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize >= AccountId::default().encode().len(),
|
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize >= AccountId::from([0u8; 32]).encode().len(),
|
||||||
"Actual maximal size of encoded AccountId ({}) overflows expected ({})",
|
"Actual maximal size of encoded AccountId ({}) overflows expected ({})",
|
||||||
AccountId::default().encode().len(),
|
AccountId::from([0u8; 32]).encode().len(),
|
||||||
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "bp-rococo"
|
|||||||
description = "Primitives of Rococo runtime."
|
description = "Primitives of Rococo runtime."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -18,10 +18,11 @@
|
|||||||
// RuntimeApi generated functions
|
// RuntimeApi generated functions
|
||||||
#![allow(clippy::too_many_arguments)]
|
#![allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce};
|
||||||
use frame_support::weights::{
|
use frame_support::weights::{
|
||||||
Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::FixedU128;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
@@ -30,19 +31,19 @@ pub use bp_polkadot_core::*;
|
|||||||
/// Rococo Chain
|
/// Rococo Chain
|
||||||
pub type Rococo = PolkadotLike;
|
pub type Rococo = PolkadotLike;
|
||||||
|
|
||||||
/// The target length of a session (how often authorities change) on Westend measured in of number
|
/// The target length of a session (how often authorities change) on Rococo measured in of number
|
||||||
/// of blocks.
|
/// of blocks.
|
||||||
///
|
///
|
||||||
/// Note that since this is a target sessions may change before/after this time depending on network
|
/// Note that since this is a target sessions may change before/after this time depending on network
|
||||||
/// conditions.
|
/// conditions.
|
||||||
pub const SESSION_LENGTH: BlockNumber = 10 * time_units::MINUTES;
|
pub const SESSION_LENGTH: BlockNumber = time_units::HOURS;
|
||||||
|
|
||||||
// NOTE: This needs to be kept up to date with the Rococo runtime found in the Polkadot repo.
|
// NOTE: This needs to be kept up to date with the Rococo runtime found in the Polkadot repo.
|
||||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||||
spec_name: sp_version::create_runtime_str!("rococo"),
|
spec_name: sp_version::create_runtime_str!("rococo"),
|
||||||
impl_name: sp_version::create_runtime_str!("parity-rococo-v1.6"),
|
impl_name: sp_version::create_runtime_str!("parity-rococo-v2.0"),
|
||||||
authoring_version: 0,
|
authoring_version: 0,
|
||||||
spec_version: 9100,
|
spec_version: 9180,
|
||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: sp_version::create_apis_vec![[]],
|
apis: sp_version::create_apis_vec![[]],
|
||||||
transaction_version: 0,
|
transaction_version: 0,
|
||||||
@@ -73,13 +74,13 @@ pub fn derive_account_from_wococo_id(id: bp_runtime::SourceAccount<AccountId>) -
|
|||||||
AccountIdConverter::convert(encoded_id)
|
AccountIdConverter::convert(encoded_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Name of the With-Wococo messages pallet instance in the Rococo runtime.
|
/// Name of the With-Rococo GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
pub const WITH_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessages";
|
pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa";
|
||||||
|
/// Name of the With-Rococo messages pallet instance that is deployed at bridged chains.
|
||||||
|
pub const WITH_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages";
|
||||||
|
|
||||||
/// Name of the `RococoFinalityApi::best_finalized` runtime method.
|
/// Name of the `RococoFinalityApi::best_finalized` runtime method.
|
||||||
pub const BEST_FINALIZED_ROCOCO_HEADER_METHOD: &str = "RococoFinalityApi_best_finalized";
|
pub const BEST_FINALIZED_ROCOCO_HEADER_METHOD: &str = "RococoFinalityApi_best_finalized";
|
||||||
/// Name of the `RococoFinalityApi::is_known_header` runtime method.
|
|
||||||
pub const IS_KNOWN_ROCOCO_HEADER_METHOD: &str = "RococoFinalityApi_is_known_header";
|
|
||||||
|
|
||||||
/// Name of the `ToRococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
/// Name of the `ToRococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||||
/// method.
|
/// method.
|
||||||
@@ -87,22 +88,9 @@ pub const TO_ROCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
|||||||
"ToRococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToRococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToRococoOutboundLaneApi::message_details` runtime method.
|
/// Name of the `ToRococoOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "ToRococoOutboundLaneApi_message_details";
|
pub const TO_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "ToRococoOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToRococoOutboundLaneApi::latest_generated_nonce` runtime method.
|
|
||||||
pub const TO_ROCOCO_LATEST_GENERATED_NONCE_METHOD: &str =
|
|
||||||
"ToRococoOutboundLaneApi_latest_generated_nonce";
|
|
||||||
/// Name of the `ToRococoOutboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const TO_ROCOCO_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"ToRococoOutboundLaneApi_latest_received_nonce";
|
|
||||||
|
|
||||||
/// Name of the `FromRococoInboundLaneApi::latest_received_nonce` runtime method.
|
/// Existential deposit on Rococo.
|
||||||
pub const FROM_ROCOCO_LATEST_RECEIVED_NONCE_METHOD: &str =
|
pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 100;
|
||||||
"FromRococoInboundLaneApi_latest_received_nonce";
|
|
||||||
/// Name of the `FromRococoInboundLaneApi::latest_onfirmed_nonce` runtime method.
|
|
||||||
pub const FROM_ROCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str =
|
|
||||||
"FromRococoInboundLaneApi_latest_confirmed_nonce";
|
|
||||||
/// Name of the `FromRococoInboundLaneApi::unrewarded_relayers_state` runtime method.
|
|
||||||
pub const FROM_ROCOCO_UNREWARDED_RELAYERS_STATE: &str =
|
|
||||||
"FromRococoInboundLaneApi_unrewarded_relayers_state";
|
|
||||||
|
|
||||||
/// Weight of pay-dispatch-fee operation for inbound messages at Rococo chain.
|
/// Weight of pay-dispatch-fee operation for inbound messages at Rococo chain.
|
||||||
///
|
///
|
||||||
@@ -121,8 +109,6 @@ sp_api::decl_runtime_apis! {
|
|||||||
pub trait RococoFinalityApi {
|
pub trait RococoFinalityApi {
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||||
fn best_finalized() -> (BlockNumber, Hash);
|
fn best_finalized() -> (BlockNumber, Hash);
|
||||||
/// Returns true if the header is known to the runtime.
|
|
||||||
fn is_known_header(hash: Hash) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Outbound message lane API for messages that are sent to Rococo chain.
|
/// Outbound message lane API for messages that are sent to Rococo chain.
|
||||||
@@ -142,6 +128,7 @@ sp_api::decl_runtime_apis! {
|
|||||||
fn estimate_message_delivery_and_dispatch_fee(
|
fn estimate_message_delivery_and_dispatch_fee(
|
||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
|
rococo_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
/// messages in given inclusive range.
|
/// messages in given inclusive range.
|
||||||
@@ -153,22 +140,5 @@ sp_api::decl_runtime_apis! {
|
|||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
|
||||||
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inbound message lane API for messages sent by Rococo chain.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are receiving messages from Rococo chain, not the
|
|
||||||
/// Rococo runtime itself.
|
|
||||||
pub trait FromRococoInboundLaneApi {
|
|
||||||
/// Returns nonce of the latest message, received by given lane.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Nonce of the latest message that has been confirmed to the bridged chain.
|
|
||||||
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// State of the unrewarded relayers set at given lane.
|
|
||||||
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,17 @@ name = "bp-westend"
|
|||||||
description = "Primitives of Westend runtime."
|
description = "Primitives of Westend runtime."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive"] }
|
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
|
||||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
smallvec = "1.7"
|
smallvec = "1.7"
|
||||||
|
|
||||||
# Bridge Dependencies
|
# Bridge Dependencies
|
||||||
|
|
||||||
bp-header-chain = { path = "../header-chain", default-features = false }
|
bp-header-chain = { path = "../header-chain", default-features = false }
|
||||||
bp-messages = { path = "../messages", default-features = false }
|
|
||||||
bp-polkadot-core = { path = "../polkadot-core", default-features = false }
|
bp-polkadot-core = { path = "../polkadot-core", default-features = false }
|
||||||
bp-runtime = { path = "../runtime", default-features = false }
|
bp-runtime = { path = "../runtime", default-features = false }
|
||||||
|
|
||||||
@@ -30,7 +29,6 @@ sp-version = { git = "https://github.com/paritytech/substrate", branch = "master
|
|||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
"bp-header-chain/std",
|
"bp-header-chain/std",
|
||||||
"bp-messages/std",
|
|
||||||
"bp-polkadot-core/std",
|
"bp-polkadot-core/std",
|
||||||
"bp-runtime/std",
|
"bp-runtime/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
// RuntimeApi generated functions
|
// RuntimeApi generated functions
|
||||||
#![allow(clippy::too_many_arguments)]
|
#![allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
|
||||||
use frame_support::weights::{
|
use frame_support::weights::{
|
||||||
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
|
||||||
};
|
};
|
||||||
@@ -54,10 +53,11 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
spec_name: sp_version::create_runtime_str!("westend"),
|
spec_name: sp_version::create_runtime_str!("westend"),
|
||||||
impl_name: sp_version::create_runtime_str!("parity-westend"),
|
impl_name: sp_version::create_runtime_str!("parity-westend"),
|
||||||
authoring_version: 2,
|
authoring_version: 2,
|
||||||
spec_version: 51,
|
spec_version: 9140,
|
||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: sp_version::create_apis_vec![[]],
|
apis: sp_version::create_apis_vec![[]],
|
||||||
transaction_version: 5,
|
transaction_version: 8,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Westend Runtime `Call` enum.
|
/// Westend Runtime `Call` enum.
|
||||||
@@ -86,33 +86,11 @@ pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -
|
|||||||
AccountIdConverter::convert(encoded_id)
|
AccountIdConverter::convert(encoded_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Name of the With-Westend GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
|
pub const WITH_WESTEND_GRANDPA_PALLET_NAME: &str = "BridgeWestendGrandpa";
|
||||||
|
|
||||||
/// Name of the `WestendFinalityApi::best_finalized` runtime method.
|
/// Name of the `WestendFinalityApi::best_finalized` runtime method.
|
||||||
pub const BEST_FINALIZED_WESTEND_HEADER_METHOD: &str = "WestendFinalityApi_best_finalized";
|
pub const BEST_FINALIZED_WESTEND_HEADER_METHOD: &str = "WestendFinalityApi_best_finalized";
|
||||||
/// Name of the `WestendFinalityApi::is_known_header` runtime method.
|
|
||||||
pub const IS_KNOWN_WESTEND_HEADER_METHOD: &str = "WestendFinalityApi_is_known_header";
|
|
||||||
|
|
||||||
/// Name of the `ToWestendOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
|
||||||
/// method.
|
|
||||||
pub const TO_WESTEND_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
|
||||||
"ToWestendOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
|
||||||
/// Name of the `ToWestendOutboundLaneApi::message_details` runtime method.
|
|
||||||
pub const TO_WESTEND_MESSAGE_DETAILS_METHOD: &str = "ToWestendOutboundLaneApi_message_details";
|
|
||||||
/// Name of the `ToWestendOutboundLaneApi::latest_generated_nonce` runtime method.
|
|
||||||
pub const TO_WESTEND_LATEST_GENERATED_NONCE_METHOD: &str =
|
|
||||||
"ToWestendOutboundLaneApi_latest_generated_nonce";
|
|
||||||
/// Name of the `ToWestendOutboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const TO_WESTEND_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"ToWestendOutboundLaneApi_latest_received_nonce";
|
|
||||||
|
|
||||||
/// Name of the `FromWestendInboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const FROM_WESTEND_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"FromWestendInboundLaneApi_latest_received_nonce";
|
|
||||||
/// Name of the `FromWestendInboundLaneApi::latest_onfirmed_nonce` runtime method.
|
|
||||||
pub const FROM_WESTEND_LATEST_CONFIRMED_NONCE_METHOD: &str =
|
|
||||||
"FromWestendInboundLaneApi_latest_confirmed_nonce";
|
|
||||||
/// Name of the `FromWestendInboundLaneApi::unrewarded_relayers_state` runtime method.
|
|
||||||
pub const FROM_WESTEND_UNREWARDED_RELAYERS_STATE: &str =
|
|
||||||
"FromWestendInboundLaneApi_unrewarded_relayers_state";
|
|
||||||
|
|
||||||
/// The target length of a session (how often authorities change) on Westend measured in of number
|
/// The target length of a session (how often authorities change) on Westend measured in of number
|
||||||
/// of blocks.
|
/// of blocks.
|
||||||
@@ -129,54 +107,5 @@ sp_api::decl_runtime_apis! {
|
|||||||
pub trait WestendFinalityApi {
|
pub trait WestendFinalityApi {
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||||
fn best_finalized() -> (BlockNumber, Hash);
|
fn best_finalized() -> (BlockNumber, Hash);
|
||||||
/// Returns true if the header is known to the runtime.
|
|
||||||
fn is_known_header(hash: Hash) -> bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Outbound message lane API for messages that are sent to Westend chain.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are sending messages to Westend chain, not the
|
|
||||||
/// Westend runtime itself.
|
|
||||||
pub trait ToWestendOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
|
||||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
|
||||||
/// this chain.
|
|
||||||
///
|
|
||||||
/// Returns `None` if message is too expensive to be sent to Westend from this chain.
|
|
||||||
///
|
|
||||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
|
||||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
|
||||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
|
||||||
/// to the target chain.
|
|
||||||
fn estimate_message_delivery_and_dispatch_fee(
|
|
||||||
lane_id: LaneId,
|
|
||||||
payload: OutboundPayload,
|
|
||||||
) -> Option<OutboundMessageFee>;
|
|
||||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
|
||||||
/// messages in given inclusive range.
|
|
||||||
///
|
|
||||||
/// If some (or all) messages are missing from the storage, they'll also will
|
|
||||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
|
||||||
fn message_details(
|
|
||||||
lane: LaneId,
|
|
||||||
begin: MessageNonce,
|
|
||||||
end: MessageNonce,
|
|
||||||
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
|
||||||
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inbound message lane API for messages sent by Westend chain.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are receiving messages from Westend chain, not the
|
|
||||||
/// Westend runtime itself.
|
|
||||||
pub trait FromWestendInboundLaneApi {
|
|
||||||
/// Returns nonce of the latest message, received by given lane.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Nonce of the latest message that has been confirmed to the bridged chain.
|
|
||||||
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// State of the unrewarded relayers set at given lane.
|
|
||||||
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name = "bp-wococo"
|
|||||||
description = "Primitives of Wococo runtime."
|
description = "Primitives of Wococo runtime."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -18,16 +18,24 @@
|
|||||||
// RuntimeApi generated functions
|
// RuntimeApi generated functions
|
||||||
#![allow(clippy::too_many_arguments)]
|
#![allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce};
|
||||||
|
use sp_runtime::FixedU128;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
pub use bp_polkadot_core::*;
|
pub use bp_polkadot_core::*;
|
||||||
// Rococo runtime = Wococo runtime
|
// Rococo runtime = Wococo runtime
|
||||||
pub use bp_rococo::{WeightToFee, PAY_INBOUND_DISPATCH_FEE_WEIGHT, SESSION_LENGTH, VERSION};
|
pub use bp_rococo::{WeightToFee, EXISTENTIAL_DEPOSIT, PAY_INBOUND_DISPATCH_FEE_WEIGHT, VERSION};
|
||||||
|
|
||||||
/// Wococo Chain
|
/// Wococo Chain
|
||||||
pub type Wococo = PolkadotLike;
|
pub type Wococo = PolkadotLike;
|
||||||
|
|
||||||
|
/// The target length of a session (how often authorities change) on Wococo measured in of number
|
||||||
|
/// of blocks.
|
||||||
|
///
|
||||||
|
/// Note that since this is a target sessions may change before/after this time depending on network
|
||||||
|
/// conditions.
|
||||||
|
pub const SESSION_LENGTH: BlockNumber = time_units::MINUTES;
|
||||||
|
|
||||||
// We use this to get the account on Wococo (target) which is derived from Rococo's (source)
|
// We use this to get the account on Wococo (target) which is derived from Rococo's (source)
|
||||||
// account.
|
// account.
|
||||||
pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {
|
||||||
@@ -35,13 +43,13 @@ pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -
|
|||||||
AccountIdConverter::convert(encoded_id)
|
AccountIdConverter::convert(encoded_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Name of the With-Rococo messages pallet instance in the Wococo runtime.
|
/// Name of the With-Wococo GRANDPA pallet instance that is deployed at bridged chains.
|
||||||
pub const WITH_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages";
|
pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa";
|
||||||
|
/// Name of the With-Wococo messages pallet instance that is deployed at bridged chains.
|
||||||
|
pub const WITH_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessages";
|
||||||
|
|
||||||
/// Name of the `WococoFinalityApi::best_finalized` runtime method.
|
/// Name of the `WococoFinalityApi::best_finalized` runtime method.
|
||||||
pub const BEST_FINALIZED_WOCOCO_HEADER_METHOD: &str = "WococoFinalityApi_best_finalized";
|
pub const BEST_FINALIZED_WOCOCO_HEADER_METHOD: &str = "WococoFinalityApi_best_finalized";
|
||||||
/// Name of the `WococoFinalityApi::is_known_header` runtime method.
|
|
||||||
pub const IS_KNOWN_WOCOCO_HEADER_METHOD: &str = "WococoFinalityApi_is_known_header";
|
|
||||||
|
|
||||||
/// Name of the `ToWococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
/// Name of the `ToWococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||||
/// method.
|
/// method.
|
||||||
@@ -49,22 +57,6 @@ pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
|||||||
"ToWococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToWococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToWococoOutboundLaneApi::message_details` runtime method.
|
/// Name of the `ToWococoOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "ToWococoOutboundLaneApi_message_details";
|
pub const TO_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "ToWococoOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToWococoOutboundLaneApi::latest_generated_nonce` runtime method.
|
|
||||||
pub const TO_WOCOCO_LATEST_GENERATED_NONCE_METHOD: &str =
|
|
||||||
"ToWococoOutboundLaneApi_latest_generated_nonce";
|
|
||||||
/// Name of the `ToWococoOutboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const TO_WOCOCO_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"ToWococoOutboundLaneApi_latest_received_nonce";
|
|
||||||
|
|
||||||
/// Name of the `FromWococoInboundLaneApi::latest_received_nonce` runtime method.
|
|
||||||
pub const FROM_WOCOCO_LATEST_RECEIVED_NONCE_METHOD: &str =
|
|
||||||
"FromWococoInboundLaneApi_latest_received_nonce";
|
|
||||||
/// Name of the `FromWococoInboundLaneApi::latest_onfirmed_nonce` runtime method.
|
|
||||||
pub const FROM_WOCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str =
|
|
||||||
"FromWococoInboundLaneApi_latest_confirmed_nonce";
|
|
||||||
/// Name of the `FromWococoInboundLaneApi::unrewarded_relayers_state` runtime method.
|
|
||||||
pub const FROM_WOCOCO_UNREWARDED_RELAYERS_STATE: &str =
|
|
||||||
"FromWococoInboundLaneApi_unrewarded_relayers_state";
|
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about the finalized Wococo headers.
|
/// API for querying information about the finalized Wococo headers.
|
||||||
@@ -74,8 +66,6 @@ sp_api::decl_runtime_apis! {
|
|||||||
pub trait WococoFinalityApi {
|
pub trait WococoFinalityApi {
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||||
fn best_finalized() -> (BlockNumber, Hash);
|
fn best_finalized() -> (BlockNumber, Hash);
|
||||||
/// Returns true if the header is known to the runtime.
|
|
||||||
fn is_known_header(hash: Hash) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Outbound message lane API for messages that are sent to Wococo chain.
|
/// Outbound message lane API for messages that are sent to Wococo chain.
|
||||||
@@ -95,6 +85,7 @@ sp_api::decl_runtime_apis! {
|
|||||||
fn estimate_message_delivery_and_dispatch_fee(
|
fn estimate_message_delivery_and_dispatch_fee(
|
||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
|
wococo_to_this_conversion_rate: Option<FixedU128>,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
/// messages in given inclusive range.
|
/// messages in given inclusive range.
|
||||||
@@ -106,22 +97,5 @@ sp_api::decl_runtime_apis! {
|
|||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
|
||||||
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inbound message lane API for messages sent by Wococo chain.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are receiving messages from Wococo chain, not the
|
|
||||||
/// Wococo runtime itself.
|
|
||||||
pub trait FromWococoInboundLaneApi {
|
|
||||||
/// Returns nonce of the latest message, received by given lane.
|
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// Nonce of the latest message that has been confirmed to the bridged chain.
|
|
||||||
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
|
|
||||||
/// State of the unrewarded relayers set at given lane.
|
|
||||||
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,19 @@ name = "bp-header-chain"
|
|||||||
description = "A common interface for describing what a bridge pallet should be able to do."
|
description = "A common interface for describing what a bridge pallet should be able to do."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
||||||
finality-grandpa = { version = "0.15.0", default-features = false }
|
finality-grandpa = { version = "0.15.0", default-features = false }
|
||||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
|
||||||
serde = { version = "1.0", optional = true }
|
serde = { version = "1.0", optional = true }
|
||||||
|
|
||||||
|
# Bridge dependencies
|
||||||
|
|
||||||
|
bp-runtime = { path = "../runtime", default-features = false }
|
||||||
|
|
||||||
# Substrate Dependencies
|
# Substrate Dependencies
|
||||||
|
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
@@ -23,10 +27,13 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_matches = "1.5"
|
assert_matches = "1.5"
|
||||||
bp-test-utils = { path = "../test-utils" }
|
bp-test-utils = { path = "../test-utils" }
|
||||||
|
hex = "0.4"
|
||||||
|
hex-literal = "0.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
|
"bp-runtime/std",
|
||||||
"codec/std",
|
"codec/std",
|
||||||
"finality-grandpa/std",
|
"finality-grandpa/std",
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use sp_runtime::{generic::OpaqueDigestItemId, traits::Header as HeaderT, Runtime
|
|||||||
use sp_std::boxed::Box;
|
use sp_std::boxed::Box;
|
||||||
|
|
||||||
pub mod justification;
|
pub mod justification;
|
||||||
|
pub mod storage_keys;
|
||||||
|
|
||||||
/// A type that can be used as a parameter in a dispatchable function.
|
/// A type that can be used as a parameter in a dispatchable function.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Parity Bridges Common.
|
||||||
|
|
||||||
|
// Parity Bridges Common 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.
|
||||||
|
|
||||||
|
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Storage keys of bridge GRANDPA pallet.
|
||||||
|
|
||||||
|
/// Name of the `IsHalted` storage value.
|
||||||
|
pub const IS_HALTED_VALUE_NAME: &str = "IsHalted";
|
||||||
|
/// Name of the `BestFinalized` storage value.
|
||||||
|
pub const BEST_FINALIZED_VALUE_NAME: &str = "BestFinalized";
|
||||||
|
|
||||||
|
use sp_core::storage::StorageKey;
|
||||||
|
|
||||||
|
/// Storage key of the `IsHalted` flag in the runtime storage.
|
||||||
|
pub fn is_halted_key(pallet_prefix: &str) -> StorageKey {
|
||||||
|
StorageKey(
|
||||||
|
bp_runtime::storage_value_final_key(
|
||||||
|
pallet_prefix.as_bytes(),
|
||||||
|
IS_HALTED_VALUE_NAME.as_bytes(),
|
||||||
|
)
|
||||||
|
.to_vec(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Storage key of the best finalized header hash value in the runtime storage.
|
||||||
|
pub fn best_finalized_hash_key(pallet_prefix: &str) -> StorageKey {
|
||||||
|
StorageKey(
|
||||||
|
bp_runtime::storage_value_final_key(
|
||||||
|
pallet_prefix.as_bytes(),
|
||||||
|
BEST_FINALIZED_VALUE_NAME.as_bytes(),
|
||||||
|
)
|
||||||
|
.to_vec(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use hex_literal::hex;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn is_halted_key_computed_properly() {
|
||||||
|
// If this test fails, then something has been changed in module storage that is breaking
|
||||||
|
// compatibility with previous pallet.
|
||||||
|
let storage_key = is_halted_key("BridgeGrandpa").0;
|
||||||
|
assert_eq!(
|
||||||
|
storage_key,
|
||||||
|
hex!("0b06f475eddb98cf933a12262e0388de9611a984bbd04e2fd39f97bbc006115f").to_vec(),
|
||||||
|
"Unexpected storage key: {}",
|
||||||
|
hex::encode(&storage_key),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn best_finalized_hash_key_computed_properly() {
|
||||||
|
// If this test fails, then something has been changed in module storage that is breaking
|
||||||
|
// compatibility with previous pallet.
|
||||||
|
let storage_key = best_finalized_hash_key("BridgeGrandpa").0;
|
||||||
|
assert_eq!(
|
||||||
|
storage_key,
|
||||||
|
hex!("0b06f475eddb98cf933a12262e0388dea4ebafdd473c549fdb24c5c991c5591c").to_vec(),
|
||||||
|
"Unexpected storage key: {}",
|
||||||
|
hex::encode(&storage_key),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user