mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22: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
@@ -2,17 +2,17 @@
|
||||
name = "rialto-runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
homepage = "https://substrate.dev"
|
||||
repository = "https://github.com/paritytech/parity-bridges-common/"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[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"
|
||||
libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] }
|
||||
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"] }
|
||||
|
||||
# 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 }
|
||||
|
||||
[dev-dependencies]
|
||||
bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] }
|
||||
libsecp256k1 = { version = "0.7", features = ["hmac"] }
|
||||
static_assertions = "1.1"
|
||||
|
||||
[build-dependencies]
|
||||
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,
|
||||
traits::{AccountIdLookup, Block as BlockT, Keccak256, NumberFor, OpaqueKeys},
|
||||
transaction_validity::{TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult, FixedPointNumber, MultiSignature, MultiSigner, Perquintill,
|
||||
ApplyExtrinsicResult, FixedPointNumber, FixedU128, MultiSignature, MultiSigner, Perquintill,
|
||||
};
|
||||
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||
#[cfg(feature = "std")]
|
||||
@@ -140,6 +140,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
impl_version: 1,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 1,
|
||||
state_version: 1,
|
||||
};
|
||||
|
||||
/// 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
|
||||
/// call per block.
|
||||
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.
|
||||
///
|
||||
/// 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 MaxRequests = MaxRequests;
|
||||
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 {}
|
||||
@@ -434,9 +421,9 @@ impl pallet_shift_session_manager::Config for Runtime {}
|
||||
parameter_types! {
|
||||
pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
|
||||
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 =
|
||||
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
|
||||
pub const GetDeliveryConfirmationTransactionFee: Balance =
|
||||
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 {
|
||||
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 MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||
@@ -469,10 +456,9 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
|
||||
type MessageDeliveryAndDispatchPayment =
|
||||
pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
|
||||
Runtime,
|
||||
(),
|
||||
WithMillauMessagesInstance,
|
||||
pallet_balances::Pallet<Runtime>,
|
||||
GetDeliveryConfirmationTransactionFee,
|
||||
RootAccountForPayments,
|
||||
>;
|
||||
type OnMessageAccepted = ();
|
||||
type OnDeliveryConfirmed = ();
|
||||
@@ -568,7 +554,7 @@ pub type Executive = frame_executive::Executive<
|
||||
Block,
|
||||
frame_system::ChainContext<Runtime>,
|
||||
Runtime,
|
||||
AllPallets,
|
||||
AllPalletsWithSystem,
|
||||
>;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -633,7 +619,7 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||
fn validator_set() -> ValidatorSet<BeefyId> {
|
||||
fn validator_set() -> Option<ValidatorSet<BeefyId>> {
|
||||
Beefy::validator_set()
|
||||
}
|
||||
}
|
||||
@@ -676,10 +662,6 @@ impl_runtime_apis! {
|
||||
let header = BridgeMillauGrandpa::best_finalized();
|
||||
(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 {
|
||||
@@ -752,10 +734,7 @@ impl_runtime_apis! {
|
||||
polkadot_runtime_parachains::runtime_api_impl::v2::validators::<Runtime>()
|
||||
}
|
||||
|
||||
fn validator_groups() -> (
|
||||
Vec<Vec<polkadot_primitives::v2::ValidatorIndex>>,
|
||||
polkadot_primitives::v2::GroupRotationInfo<BlockNumber>,
|
||||
) {
|
||||
fn validator_groups() -> (Vec<Vec<polkadot_primitives::v2::ValidatorIndex>>, polkadot_primitives::v2::GroupRotationInfo<BlockNumber>) {
|
||||
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>()
|
||||
}
|
||||
|
||||
fn persisted_validation_data(
|
||||
para_id: polkadot_primitives::v2::Id,
|
||||
assumption: polkadot_primitives::v2::OccupiedCoreAssumption,
|
||||
)
|
||||
fn persisted_validation_data(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption)
|
||||
-> Option<polkadot_primitives::v2::PersistedValidationData<Hash, BlockNumber>> {
|
||||
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,
|
||||
expected_persisted_validation_data_hash: Hash,
|
||||
) -> 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(
|
||||
@@ -789,17 +768,12 @@ impl_runtime_apis! {
|
||||
polkadot_runtime_parachains::runtime_api_impl::v2::session_index_for_child::<Runtime>()
|
||||
}
|
||||
|
||||
fn validation_code(
|
||||
para_id: polkadot_primitives::v2::Id,
|
||||
assumption: polkadot_primitives::v2::OccupiedCoreAssumption,
|
||||
)
|
||||
fn validation_code(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption)
|
||||
-> Option<polkadot_primitives::v2::ValidationCode> {
|
||||
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code::<Runtime>(para_id, assumption)
|
||||
}
|
||||
|
||||
fn candidate_pending_availability(
|
||||
para_id: polkadot_primitives::v2::Id,
|
||||
) -> Option<polkadot_primitives::v2::CommittedCandidateReceipt<Hash>> {
|
||||
fn candidate_pending_availability(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)
|
||||
}
|
||||
|
||||
@@ -818,9 +792,7 @@ impl_runtime_apis! {
|
||||
polkadot_runtime_parachains::runtime_api_impl::v2::session_info::<Runtime>(index)
|
||||
}
|
||||
|
||||
fn dmq_contents(
|
||||
recipient: polkadot_primitives::v2::Id,
|
||||
) -> Vec<polkadot_primitives::v2::InboundDownwardMessage<BlockNumber>> {
|
||||
fn dmq_contents(recipient: polkadot_primitives::v2::Id) -> Vec<polkadot_primitives::v2::InboundDownwardMessage<BlockNumber>> {
|
||||
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)
|
||||
}
|
||||
|
||||
fn validation_code_by_hash(
|
||||
hash: polkadot_primitives::v2::ValidationCodeHash,
|
||||
) -> Option<polkadot_primitives::v2::ValidationCode> {
|
||||
fn validation_code_by_hash(hash: polkadot_primitives::v2::ValidationCodeHash) -> Option<polkadot_primitives::v2::ValidationCode> {
|
||||
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_by_hash::<Runtime>(hash)
|
||||
}
|
||||
|
||||
fn on_chain_votes() -> Option<polkadot_primitives::v2::ScrapedOnChainVotes<Hash>> {
|
||||
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 {
|
||||
@@ -910,10 +894,12 @@ impl_runtime_apis! {
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
_lane_id: bp_messages::LaneId,
|
||||
payload: ToMillauMessagePayload,
|
||||
millau_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<Balance> {
|
||||
estimate_message_dispatch_and_delivery_fee::<WithMillauMessageBridge>(
|
||||
&payload,
|
||||
WithMillauMessageBridge::RELAYER_FEE_PERCENT,
|
||||
millau_to_this_conversion_rate,
|
||||
).ok()
|
||||
}
|
||||
|
||||
@@ -928,243 +914,6 @@ impl_runtime_apis! {
|
||||
WithMillauMessageBridge,
|
||||
>(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)]
|
||||
mod tests {
|
||||
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]
|
||||
fn call_size() {
|
||||
const DOT_MAX_CALL_SZ: usize = 230;
|
||||
assert!(core::mem::size_of::<pallet_bridge_grandpa::Call<Runtime>>() <= DOT_MAX_CALL_SZ);
|
||||
// FIXME: get this down to 230. https://github.com/paritytech/grandpa-bridge-gadget/issues/359
|
||||
const BEEFY_MAX_CALL_SZ: usize = 232;
|
||||
assert!(core::mem::size_of::<pallet_bridge_messages::Call<Runtime>>() <= BEEFY_MAX_CALL_SZ);
|
||||
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
|
||||
);
|
||||
// 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 bp_messages::{
|
||||
source_chain::TargetHeaderChain,
|
||||
source_chain::{SenderOrigin, TargetHeaderChain},
|
||||
target_chain::{ProvedMessages, SourceHeaderChain},
|
||||
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 codec::{Decode, Encode};
|
||||
use frame_support::{
|
||||
@@ -86,16 +86,19 @@ impl MessageBridge for WithMillauMessageBridge {
|
||||
const RELAYER_FEE_PERCENT: u32 = 10;
|
||||
const THIS_CHAIN_ID: ChainId = RIALTO_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 BridgedChain = Millau;
|
||||
|
||||
fn bridged_balance_to_this_balance(bridged_balance: bp_millau::Balance) -> bp_rialto::Balance {
|
||||
bp_rialto::Balance::try_from(
|
||||
MillauToRialtoConversionRate::get().saturating_mul_int(bridged_balance),
|
||||
)
|
||||
.unwrap_or(bp_rialto::Balance::MAX)
|
||||
fn bridged_balance_to_this_balance(
|
||||
bridged_balance: bp_millau::Balance,
|
||||
bridged_to_this_conversion_rate_override: Option<FixedU128>,
|
||||
) -> bp_rialto::Balance {
|
||||
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 {
|
||||
type Origin = crate::Origin;
|
||||
type Call = crate::Call;
|
||||
|
||||
fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
|
||||
*lane == [0, 0, 0, 0] || *lane == [0, 0, 0, 1]
|
||||
fn is_message_accepted(send_origin: &Self::Origin, lane: &LaneId) -> bool {
|
||||
send_origin.linked_account().is_some() && (*lane == [0, 0, 0, 0] || *lane == [0, 0, 0, 1])
|
||||
}
|
||||
|
||||
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce {
|
||||
@@ -170,13 +174,13 @@ impl messages::ChainWithMessages for Millau {
|
||||
|
||||
impl messages::BridgedChainWithMessages for Millau {
|
||||
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> {
|
||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||
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`
|
||||
@@ -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.
|
||||
#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)]
|
||||
pub enum RialtoToMillauMessagesParameter {
|
||||
@@ -291,15 +308,23 @@ impl MessagesParameter for RialtoToMillauMessagesParameter {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
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_messages::{
|
||||
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
|
||||
MessageKey,
|
||||
};
|
||||
use bp_runtime::{derive_account_id, messages::DispatchFeePayment, SourceAccount};
|
||||
use bridge_runtime_common::messages::target::{
|
||||
FromBridgedChainEncodedMessageCall, FromBridgedChainMessagePayload,
|
||||
use bp_runtime::{derive_account_id, messages::DispatchFeePayment, Chain, SourceAccount};
|
||||
use bridge_runtime_common::{
|
||||
assert_complete_bridge_types,
|
||||
integrity::{
|
||||
assert_complete_bridge_constants, AssertBridgeMessagesPalletConstants,
|
||||
AssertBridgePalletNames, AssertChainConstants, AssertCompleteBridgeConstants,
|
||||
},
|
||||
messages::target::{FromBridgedChainEncodedMessageCall, FromBridgedChainMessagePayload},
|
||||
};
|
||||
use frame_support::{
|
||||
traits::Currency,
|
||||
@@ -316,7 +341,7 @@ mod tests {
|
||||
SystemConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||
ext.execute_with(|| {
|
||||
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_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
|
||||
&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.
|
||||
|
||||
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_system::EnsureRoot;
|
||||
@@ -29,6 +32,15 @@ use polkadot_runtime_parachains::{
|
||||
paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
|
||||
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 ;)
|
||||
pub struct RewardValidators;
|
||||
@@ -49,6 +61,7 @@ impl parachains_hrmp::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type Currency = Balances;
|
||||
type WeightInfo = parachains_hrmp::TestWeightInfo;
|
||||
}
|
||||
|
||||
impl parachains_inclusion::Config for Runtime {
|
||||
@@ -65,10 +78,15 @@ impl parachains_initializer::Config for Runtime {
|
||||
|
||||
impl parachains_origin::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
|
||||
}
|
||||
|
||||
impl parachains_paras::Config for Runtime {
|
||||
type Origin = Origin;
|
||||
type Event = Event;
|
||||
type WeightInfo = parachains_paras::TestWeightInfo;
|
||||
type UnsignedPriority = ParasUnsignedPriority;
|
||||
type NextSessionRotation = Babe;
|
||||
}
|
||||
|
||||
impl parachains_paras_inherent::Config for Runtime {
|
||||
@@ -90,6 +108,7 @@ impl parachains_ump::Config for Runtime {
|
||||
type UmpSink = ();
|
||||
type FirstMessageFactorPercent = FirstMessageFactorPercent;
|
||||
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
|
||||
@@ -120,6 +139,7 @@ impl slots::Config for Runtime {
|
||||
type LeasePeriod = LeasePeriod;
|
||||
type WeightInfo = slots::TestWeightInfo;
|
||||
type LeaseOffset = ();
|
||||
type ForceOrigin = EnsureRoot<AccountId>;
|
||||
}
|
||||
|
||||
impl paras_sudo_wrapper::Config for Runtime {}
|
||||
|
||||
Reference in New Issue
Block a user