From bbc6edc8607c9337fcb21376153b42178657fdbd Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 6 Feb 2024 13:17:28 +0300 Subject: [PATCH] Backport latest PRs from polkadot sdk (#2824) * backport https://github.com/paritytech/polkadot-sdk/pull/3034 * backport https://github.com/paritytech/polkadot-sdk/pull/3072 * backport https://github.com/paritytech/polkadot-sdk/pull/3175 * backport https://github.com/paritytech/polkadot-sdk/pull/2949 * Cargo.lock * fix invalid copypaste --- bin/runtime-common/Cargo.toml | 2 +- modules/grandpa/Cargo.toml | 2 +- modules/messages/Cargo.toml | 2 +- modules/parachains/Cargo.toml | 2 +- modules/relayers/Cargo.toml | 2 +- modules/xcm-bridge-hub-router/Cargo.toml | 2 +- modules/xcm-bridge-hub/Cargo.toml | 2 +- primitives/chain-asset-hub-rococo/Cargo.toml | 2 +- primitives/chain-asset-hub-westend/Cargo.toml | 2 +- .../chain-bridge-hub-cumulus/Cargo.toml | 2 +- .../chain-bridge-hub-cumulus/src/lib.rs | 26 +++++++++++++++++++ primitives/chain-bridge-hub-kusama/Cargo.toml | 2 +- .../chain-bridge-hub-polkadot/Cargo.toml | 2 +- primitives/chain-bridge-hub-rococo/Cargo.toml | 2 +- primitives/chain-bridge-hub-rococo/src/lib.rs | 6 ++--- .../chain-bridge-hub-westend/Cargo.toml | 2 +- .../chain-bridge-hub-westend/src/lib.rs | 4 +-- primitives/chain-kusama/Cargo.toml | 2 +- primitives/chain-polkadot-bulletin/Cargo.toml | 2 +- primitives/chain-polkadot/Cargo.toml | 2 +- primitives/chain-rococo/Cargo.toml | 2 +- primitives/chain-westend/Cargo.toml | 2 +- primitives/header-chain/Cargo.toml | 2 +- primitives/messages/Cargo.toml | 2 +- primitives/parachains/Cargo.toml | 2 +- primitives/polkadot-core/Cargo.toml | 2 +- primitives/relayers/Cargo.toml | 2 +- primitives/runtime/Cargo.toml | 2 +- primitives/test-utils/Cargo.toml | 2 +- primitives/xcm-bridge-hub-router/Cargo.toml | 2 +- primitives/xcm-bridge-hub/Cargo.toml | 2 +- 31 files changed, 59 insertions(+), 33 deletions(-) diff --git a/bin/runtime-common/Cargo.toml b/bin/runtime-common/Cargo.toml index b642f738d6e..88bd3422d0e 100644 --- a/bin/runtime-common/Cargo.toml +++ b/bin/runtime-common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bridge-runtime-common" -version = "0.1.0" +version = "0.7.0" description = "Common types and functions that may be used by substrate-based runtimes of all bridged chains" authors.workspace = true edition.workspace = true diff --git a/modules/grandpa/Cargo.toml b/modules/grandpa/Cargo.toml index e7e8c5c6fe7..b1480c70246 100644 --- a/modules/grandpa/Cargo.toml +++ b/modules/grandpa/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-bridge-grandpa" -version = "0.1.0" +version = "0.7.0" description = "Module implementing GRANDPA on-chain light client used for bridging consensus of substrate-based chains." authors.workspace = true edition.workspace = true diff --git a/modules/messages/Cargo.toml b/modules/messages/Cargo.toml index 01dd3dbcbde..9d7a1e3b9d3 100644 --- a/modules/messages/Cargo.toml +++ b/modules/messages/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pallet-bridge-messages" description = "Module that allows bridged chains to exchange messages using lane concept." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/modules/parachains/Cargo.toml b/modules/parachains/Cargo.toml index 239f5262c8b..d44b434bff7 100644 --- a/modules/parachains/Cargo.toml +++ b/modules/parachains/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-bridge-parachains" -version = "0.1.0" +version = "0.7.0" description = "Module that allows bridged relay chains to exchange information on their parachains' heads." authors.workspace = true edition.workspace = true diff --git a/modules/relayers/Cargo.toml b/modules/relayers/Cargo.toml index 73cc343a193..b0c32f4c7df 100644 --- a/modules/relayers/Cargo.toml +++ b/modules/relayers/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pallet-bridge-relayers" description = "Module used to store relayer rewards and coordinate relayers set." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/modules/xcm-bridge-hub-router/Cargo.toml b/modules/xcm-bridge-hub-router/Cargo.toml index 6d3e1c5ab45..56e9ae8f08c 100644 --- a/modules/xcm-bridge-hub-router/Cargo.toml +++ b/modules/xcm-bridge-hub-router/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pallet-xcm-bridge-hub-router" description = "Bridge hub interface for sibling/parent chains with dynamic fees support." -version = "0.1.0" +version = "0.5.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/modules/xcm-bridge-hub/Cargo.toml b/modules/xcm-bridge-hub/Cargo.toml index 4dac474413a..86644f8e4c9 100644 --- a/modules/xcm-bridge-hub/Cargo.toml +++ b/modules/xcm-bridge-hub/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pallet-xcm-bridge-hub" description = "Module that adds dynamic bridges/lanes support to XCM infrastucture at the bridge hub." -version = "0.1.0" +version = "0.2.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-asset-hub-rococo/Cargo.toml b/primitives/chain-asset-hub-rococo/Cargo.toml index c4da8ee0eaf..ad0eb39f9e3 100644 --- a/primitives/chain-asset-hub-rococo/Cargo.toml +++ b/primitives/chain-asset-hub-rococo/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-asset-hub-rococo" description = "Primitives of AssetHubRococo parachain runtime." -version = "0.1.0" +version = "0.4.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-asset-hub-westend/Cargo.toml b/primitives/chain-asset-hub-westend/Cargo.toml index a148cf31ca7..15b17f4d02d 100644 --- a/primitives/chain-asset-hub-westend/Cargo.toml +++ b/primitives/chain-asset-hub-westend/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-asset-hub-westend" description = "Primitives of AssetHubWestend parachain runtime." -version = "0.1.0" +version = "0.3.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-bridge-hub-cumulus/Cargo.toml b/primitives/chain-bridge-hub-cumulus/Cargo.toml index 08f561b4f5c..82c87d8bc13 100644 --- a/primitives/chain-bridge-hub-cumulus/Cargo.toml +++ b/primitives/chain-bridge-hub-cumulus/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-bridge-hub-cumulus" description = "Primitives for BridgeHub parachain runtimes." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-bridge-hub-cumulus/src/lib.rs b/primitives/chain-bridge-hub-cumulus/src/lib.rs index 285f0020481..c49aa4b8563 100644 --- a/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -57,6 +57,12 @@ const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(constants::WEIGHT_REF_TI .saturating_div(2) .set_proof_size(polkadot_primitives::MAX_POV_SIZE as u64); +/// We allow for 2 seconds of compute with a 6 second average block. +const MAXIMUM_BLOCK_WEIGHT_FOR_ASYNC_BACKING: Weight = Weight::from_parts( + constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), + polkadot_primitives::MAX_POV_SIZE as u64, +); + /// All cumulus bridge hubs assume that about 5 percent of the block weight is consumed by /// `on_initialize` handlers. This is used to limit the maximal weight of a single extrinsic. /// @@ -96,6 +102,26 @@ parameter_types! { }) .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) .build_or_panic(); + + /// Weight limit of the Cumulus-based bridge hub blocks when async backing is enabled. + pub BlockWeightsForAsyncBacking: limits::BlockWeights = limits::BlockWeights::builder() + .base_block(BlockExecutionWeight::get()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get(); + }) + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT_FOR_ASYNC_BACKING); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT_FOR_ASYNC_BACKING); + // Operational transactions have an extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT_FOR_ASYNC_BACKING`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT_FOR_ASYNC_BACKING - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT_FOR_ASYNC_BACKING, + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); } /// Public key of the chain account that may be used to verify signatures. diff --git a/primitives/chain-bridge-hub-kusama/Cargo.toml b/primitives/chain-bridge-hub-kusama/Cargo.toml index 4e1b3a6334c..2075fe2543c 100644 --- a/primitives/chain-bridge-hub-kusama/Cargo.toml +++ b/primitives/chain-bridge-hub-kusama/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-bridge-hub-kusama" description = "Primitives of BridgeHubKusama parachain runtime." -version = "0.1.0" +version = "0.6.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-bridge-hub-polkadot/Cargo.toml b/primitives/chain-bridge-hub-polkadot/Cargo.toml index 2f53cca46a8..edef6e61237 100644 --- a/primitives/chain-bridge-hub-polkadot/Cargo.toml +++ b/primitives/chain-bridge-hub-polkadot/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-bridge-hub-polkadot" description = "Primitives of BridgeHubPolkadot parachain runtime." -version = "0.1.0" +version = "0.6.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-bridge-hub-rococo/Cargo.toml b/primitives/chain-bridge-hub-rococo/Cargo.toml index e4bbc1a0898..0370fa1c6bb 100644 --- a/primitives/chain-bridge-hub-rococo/Cargo.toml +++ b/primitives/chain-bridge-hub-rococo/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-bridge-hub-rococo" description = "Primitives of BridgeHubRococo parachain runtime." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-bridge-hub-rococo/src/lib.rs b/primitives/chain-bridge-hub-rococo/src/lib.rs index 7b109f30fe0..c4e697fbe95 100644 --- a/primitives/chain-bridge-hub-rococo/src/lib.rs +++ b/primitives/chain-bridge-hub-rococo/src/lib.rs @@ -50,7 +50,7 @@ impl Chain for BridgeHubRococo { } fn max_extrinsic_weight() -> Weight { - BlockWeights::get() + BlockWeightsForAsyncBacking::get() .get(DispatchClass::Normal) .max_extrinsic .unwrap_or(Weight::MAX) @@ -99,7 +99,7 @@ frame_support::parameter_types! { /// The XCM fee that is paid for executing XCM program (with `ExportMessage` instruction) at the Rococo /// BridgeHub. /// (initially was calculated by test `BridgeHubRococo::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`) - pub const BridgeHubRococoBaseXcmFeeInRocs: u128 = 1_640_102_205; + pub const BridgeHubRococoBaseXcmFeeInRocs: u128 = 59_034_266; /// Transaction fee that is paid at the Rococo BridgeHub for delivering single inbound message. /// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_complex_message_delivery_transaction` + `33%`) @@ -107,5 +107,5 @@ frame_support::parameter_types! { /// Transaction fee that is paid at the Rococo BridgeHub for delivering single outbound message confirmation. /// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_complex_message_confirmation_transaction` + `33%`) - pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 4_045_736_577; + pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 5_380_829_647; } diff --git a/primitives/chain-bridge-hub-westend/Cargo.toml b/primitives/chain-bridge-hub-westend/Cargo.toml index 333e49883f8..ea452d89dba 100644 --- a/primitives/chain-bridge-hub-westend/Cargo.toml +++ b/primitives/chain-bridge-hub-westend/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-bridge-hub-westend" description = "Primitives of BridgeHubWestend parachain runtime." -version = "0.1.0" +version = "0.3.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-bridge-hub-westend/src/lib.rs b/primitives/chain-bridge-hub-westend/src/lib.rs index 83d4d6e33a7..4af895cc6d3 100644 --- a/primitives/chain-bridge-hub-westend/src/lib.rs +++ b/primitives/chain-bridge-hub-westend/src/lib.rs @@ -49,7 +49,7 @@ impl Chain for BridgeHubWestend { } fn max_extrinsic_weight() -> Weight { - BlockWeights::get() + BlockWeightsForAsyncBacking::get() .get(DispatchClass::Normal) .max_extrinsic .unwrap_or(Weight::MAX) @@ -90,7 +90,7 @@ frame_support::parameter_types! { /// The XCM fee that is paid for executing XCM program (with `ExportMessage` instruction) at the Westend /// BridgeHub. /// (initially was calculated by test `BridgeHubWestend::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`) - pub const BridgeHubWestendBaseXcmFeeInWnds: u128 = 492_077_333_333; + pub const BridgeHubWestendBaseXcmFeeInWnds: u128 = 17_756_830_000; /// Transaction fee that is paid at the Westend BridgeHub for delivering single inbound message. /// (initially was calculated by test `BridgeHubWestend::can_calculate_fee_for_complex_message_delivery_transaction` + `33%`) diff --git a/primitives/chain-kusama/Cargo.toml b/primitives/chain-kusama/Cargo.toml index ed057098813..465acf121d4 100644 --- a/primitives/chain-kusama/Cargo.toml +++ b/primitives/chain-kusama/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-kusama" description = "Primitives of Kusama runtime." -version = "0.1.0" +version = "0.5.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-polkadot-bulletin/Cargo.toml b/primitives/chain-polkadot-bulletin/Cargo.toml index 3fe83b8cae7..86f05624d01 100644 --- a/primitives/chain-polkadot-bulletin/Cargo.toml +++ b/primitives/chain-polkadot-bulletin/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-polkadot-bulletin" description = "Primitives of Polkadot Bulletin chain runtime." -version = "0.1.0" +version = "0.4.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-polkadot/Cargo.toml b/primitives/chain-polkadot/Cargo.toml index 5180c34d932..20080a7901b 100644 --- a/primitives/chain-polkadot/Cargo.toml +++ b/primitives/chain-polkadot/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-polkadot" description = "Primitives of Polkadot runtime." -version = "0.1.0" +version = "0.5.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-rococo/Cargo.toml b/primitives/chain-rococo/Cargo.toml index 7d78b3ff513..459ee6f9f05 100644 --- a/primitives/chain-rococo/Cargo.toml +++ b/primitives/chain-rococo/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-rococo" description = "Primitives of Rococo runtime." -version = "0.1.0" +version = "0.6.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/chain-westend/Cargo.toml b/primitives/chain-westend/Cargo.toml index 23cfc8de9d7..4710da7bb33 100644 --- a/primitives/chain-westend/Cargo.toml +++ b/primitives/chain-westend/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-westend" description = "Primitives of Westend runtime." -version = "0.1.0" +version = "0.3.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/header-chain/Cargo.toml b/primitives/header-chain/Cargo.toml index 415b165101d..e42959164e4 100644 --- a/primitives/header-chain/Cargo.toml +++ b/primitives/header-chain/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-header-chain" description = "A common interface for describing what a bridge pallet should be able to do." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/messages/Cargo.toml b/primitives/messages/Cargo.toml index 02388a30e74..1092be13d89 100644 --- a/primitives/messages/Cargo.toml +++ b/primitives/messages/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-messages" description = "Primitives of messages module." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/parachains/Cargo.toml b/primitives/parachains/Cargo.toml index 524b95e3b6f..e62ae6a8d42 100644 --- a/primitives/parachains/Cargo.toml +++ b/primitives/parachains/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-parachains" description = "Primitives of parachains module." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/polkadot-core/Cargo.toml b/primitives/polkadot-core/Cargo.toml index 7b8b92b62fc..5ef9920d7f1 100644 --- a/primitives/polkadot-core/Cargo.toml +++ b/primitives/polkadot-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-polkadot-core" description = "Primitives of Polkadot-like runtime." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/relayers/Cargo.toml b/primitives/relayers/Cargo.toml index 5eedf738a41..19aed6b038b 100644 --- a/primitives/relayers/Cargo.toml +++ b/primitives/relayers/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-relayers" description = "Primitives of relayers module." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 08749268958..211737e4efc 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-runtime" description = "Primitives that may be used at (bridges) runtime level." -version = "0.1.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/test-utils/Cargo.toml b/primitives/test-utils/Cargo.toml index 3c24e1fed0f..1b3ac9ee697 100644 --- a/primitives/test-utils/Cargo.toml +++ b/primitives/test-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bp-test-utils" -version = "0.1.0" +version = "0.7.0" description = "Utilities for testing substrate-based runtime bridge code" authors.workspace = true edition.workspace = true diff --git a/primitives/xcm-bridge-hub-router/Cargo.toml b/primitives/xcm-bridge-hub-router/Cargo.toml index 8000e48992c..a9f584e2a03 100644 --- a/primitives/xcm-bridge-hub-router/Cargo.toml +++ b/primitives/xcm-bridge-hub-router/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-xcm-bridge-hub-router" description = "Primitives of the xcm-bridge-hub fee pallet." -version = "0.1.0" +version = "0.6.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/primitives/xcm-bridge-hub/Cargo.toml b/primitives/xcm-bridge-hub/Cargo.toml index b2dc09bdf8c..1a5bb742eed 100644 --- a/primitives/xcm-bridge-hub/Cargo.toml +++ b/primitives/xcm-bridge-hub/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bp-xcm-bridge-hub" description = "Primitives of the xcm-bridge-hub pallet." -version = "0.1.0" +version = "0.2.0" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0"