Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 3aae882

Browse files
gavofyorkKiChjangbkonturgirazoki
authored
XCM v3 Companion (#697)
* Fixes * Undiener * Undiener * Undiener * Lockfile * Changes for send returning hash * Include message ID as params to execute_xcm * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Companion fixes * Formatting * Fixes * Formatting * Bump * Bump * Fixes * Formatting * Make the price of UMP/XCMP message sending configurable * cargo fmt * Remove InvertLocation * Formatting * Use ConstantPrice from polkadot-runtime-common * Fix naming * cargo fmt * Fixes * Fixes * Fixes * Add CallDispatcher * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Remove unused import * Remove unused import * XCMv3 fixes (#1710) * Fixes XCMv3 related Fixes XCMv3 (removed query_holding) Fixes XCMv3 - should use _depositable_count? Fixes XCMv3 - removed TrustedReserve Fixes - missing weights for statemine/statemint/westmint [DO-NOT-CHERRY-PICK] tmp return query_holding to aviod conficts to master Fixes - missing functions for pallet_xcm_benchmarks::generic::Config Fixes for XCMv3 benchmarking Fix xcm - removed query_holding * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic * Fix imports * Avoid consuming XCM message for NotApplicable scenario (#1787) * Avoid consuming message for NotApplicable scenario * Avoid consuming message for NotApplicable scenario tests * Add 10 message processing limit to DMP queue * Add 10 message limit to XCMP queue * Always increment the message_processed count whenever a message is processed * Fix formatting * Set an upper limit to the overweight message DMP queue * Add upper limit to XCMP overweight message queue * Fix for missing weight for `fn unpaid_execution()` * Fix - usage of `messages_processed` * Fixes * Fixes * Fixes * cargo fmt * Fixes * Fixes * Fixes * Fixes * Remove unused import * Fixes for gav-xcm-v3 (#1835) * Fix for FungiblesAdapter - trait changes: Contains -> AssetChecking * Fix for missing weight for `fn unpaid_execution()` * Used NonLocalMint for all NonZeroIssuance * Fix * Fixes * Fixes * Fixes * Fixes * Fixes * Fix tests * Fixes * Add SafeCallFilter * Add missing config items * Add TODO * Use () as the PriceForParentDelivery * Fixes * Fixes * Fixes * Fixes * Update transact_origin to transact_origin_and_runtime_call * Add ReachableDest config item to XCM pallet * Update SafeCallFilter to allow remark_with_event in runtime benchmarks * cargo fmt * Update substrate * Fix worst_case_holding * Fix DMQ queue unit tests * Remove unused label * cargo fmt * Actually process incoming XCMs * Fixes * Fixes * Fixes * Fixes - return back Weightless * Added measured benchmarks for `pallet_xcm` (#1968) * Fix Fix Fix * Fix * Fixes for transact benchmark * Fixes add pallet_xcm to benchmarks * Revert remark_with_event * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * Fixes * TMP * Fix for reserve_asset_deposited * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm * Fix * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm * Fix * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm * Fix westmint * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * Fix * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm * Fix for collectives * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm * Fixes for bridge-hubs * Fixes - return back Weightless * Fix - removed MigrateToTrackInactive for contracts-rococo Co-authored-by: command-bot <> * cargo fmt * Fix benchmarks * Bko gav xcm v3 (#1993) * Fix * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm Co-authored-by: command-bot <> * Change AllowUnpaidExecutionFrom to be explicit * xcm-v3 benchmarks, weights, fixes for bridge-hubs (#2035) * Dumy weights to get compile * Change UniversalLocation according to paritytech/polkadot#4097 (Location Inversion Removed) * Fix bridge-hubs weights * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm * ".git/.scripts/bench-bot.sh" xcm bridge-hub-kusama bridge-hubs pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm bridge-hub-kusama bridge-hubs pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm * ".git/.scripts/bench-bot.sh" xcm bridge-hub-rococo bridge-hubs pallet_xcm_benchmarks::fungible * ".git/.scripts/bench-bot.sh" xcm bridge-hub-rococo bridge-hubs pallet_xcm_benchmarks::generic * Change NetworkId to Option<NetworkId> Co-authored-by: command-bot <> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Add event for showing the hash of an UMP sent message (#1228) * Add UpwardMessageSent event in parachain-system * additional fixes * Message Id * Fix errors from merge * fmt * more fmt * Remove todo * more formatting * Fixes * Fixes * Fixes * Fixes * Allow explicit unpaid executions from the relay chains for system parachains (#2060) * Allow explicit unpaid executions from the relay chains for system parachains * Put origin-filtering barriers into WithComputedOrigin * Use ConstU32<8> * Small nits * formatting * cargo fmt * Allow receiving XCMs from any relay chain plurality * Fixes * update lockfile for {"polkadot", "substrate"} * Update polkadot * Add runtime-benchmarks feature Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: girazoki <gorka.irazoki@gmail.com> Co-authored-by: parity-processbot <>
1 parent aae4731 commit 3aae882

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4321
-1480
lines changed

Cargo.lock

+273-255
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/dmp-queue/src/lib.rs

+167-92
Large diffs are not rendered by default.

pallets/dmp-queue/src/migration.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use frame_support::{
2222
traits::StorageVersion,
2323
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
2424
};
25-
use xcm::latest::Weight as XcmWeight;
2625

2726
/// The current storage version.
2827
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
@@ -33,8 +32,15 @@ pub fn migrate_to_latest<T: Config>() -> Weight {
3332
let mut weight = T::DbWeight::get().reads(1);
3433

3534
if StorageVersion::get::<Pallet<T>>() == 0 {
36-
weight += migrate_to_v1::<T>();
35+
weight.saturating_accrue(migrate_to_v1::<T>());
3736
StorageVersion::new(1).put::<Pallet<T>>();
37+
weight.saturating_accrue(T::DbWeight::get().writes(1));
38+
}
39+
40+
if StorageVersion::get::<Pallet<T>>() == 1 {
41+
weight.saturating_accrue(migrate_to_v2::<T>());
42+
StorageVersion::new(2).put::<Pallet<T>>();
43+
weight.saturating_accrue(T::DbWeight::get().writes(1));
3844
}
3945

4046
weight
@@ -46,7 +52,7 @@ mod v0 {
4652

4753
#[derive(Decode, Encode, Debug)]
4854
pub struct ConfigData {
49-
pub max_individual: XcmWeight,
55+
pub max_individual: u64,
5056
}
5157

5258
impl Default for ConfigData {
@@ -78,6 +84,16 @@ pub fn migrate_to_v1<T: Config>() -> Weight {
7884
T::DbWeight::get().reads_writes(1, 1)
7985
}
8086

87+
/// Migrates `Overweight` so that it initializes the storage map's counter.
88+
///
89+
/// NOTE: Only use this function if you know what you're doing. Default to using
90+
/// `migrate_to_latest`.
91+
pub fn migrate_to_v2<T: Config>() -> Weight {
92+
let overweight_messages = <Pallet<T> as Store>::Overweight::initialize_counter() as u64;
93+
94+
T::DbWeight::get().reads_writes(overweight_messages, 1)
95+
}
96+
8197
#[cfg(test)]
8298
mod tests {
8399
use super::*;

pallets/parachain-system/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ sp-version = { git = "https://github.com/paritytech/substrate", default-features
2828

2929
# Polkadot
3030
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, features = [ "wasm-api" ], branch = "master" }
31+
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
3132

3233
# Cumulus
3334
cumulus-pallet-parachain-system-proc-macro = { path = "proc-macro", default-features = false }
@@ -67,6 +68,7 @@ std = [
6768
"sp-state-machine/std",
6869
"sp-std/std",
6970
"sp-trie/std",
71+
"xcm/std",
7072
]
7173

7274
runtime-benchmarks = [

pallets/parachain-system/src/lib.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use sp_runtime::{
5353
},
5454
};
5555
use sp_std::{cmp, collections::btree_map::BTreeMap, prelude::*};
56+
use xcm::latest::XcmHash;
5657

5758
mod migration;
5859
mod relay_state_snapshot;
@@ -480,6 +481,8 @@ pub mod pallet {
480481
DownwardMessagesReceived { count: u32 },
481482
/// Downward messages were processed using the given weight.
482483
DownwardMessagesProcessed { weight_used: Weight, dmq_head: relay_chain::Hash },
484+
/// An upward message was sent to the relay chain.
485+
UpwardMessageSent { message_hash: Option<XcmHash> },
483486
}
484487

485488
#[pallet::error]
@@ -743,7 +746,7 @@ impl<T: Config> GetChannelInfo for Pallet<T> {
743746
// None then it must be that this is an edge-case where a message is attempted to be
744747
// sent at the first block. It should be safe to assume that there are no channels
745748
// opened at all so early. At least, relying on this assumption seems to be a better
746-
// tradeoff, compared to introducing an error variant that the clients should be
749+
// trade-off, compared to introducing an error variant that the clients should be
747750
// prepared to handle.
748751
let index = match channels.binary_search_by_key(&id, |item| item.0) {
749752
Err(_) => return ChannelStatus::Closed,
@@ -1004,7 +1007,7 @@ impl<T: Config> frame_system::SetCode<T> for ParachainSetCode<T> {
10041007
}
10051008

10061009
impl<T: Config> Pallet<T> {
1007-
pub fn send_upward_message(message: UpwardMessage) -> Result<u32, MessageSendError> {
1010+
pub fn send_upward_message(message: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError> {
10081011
// Check if the message fits into the relay-chain constraints.
10091012
//
10101013
// Note, that we are using `host_configuration` here which may be from the previous
@@ -1034,13 +1037,18 @@ impl<T: Config> Pallet<T> {
10341037
// Thus fall through here.
10351038
},
10361039
};
1037-
<PendingUpwardMessages<T>>::append(message);
1038-
Ok(0)
1040+
<PendingUpwardMessages<T>>::append(message.clone());
1041+
1042+
// The relay ump does not use using_encoded
1043+
// We apply the same this to use the same hash
1044+
let hash = sp_io::hashing::blake2_256(&message);
1045+
Self::deposit_event(Event::UpwardMessageSent { message_hash: Some(hash) });
1046+
Ok((0, hash))
10391047
}
10401048
}
10411049

10421050
impl<T: Config> UpwardMessageSender for Pallet<T> {
1043-
fn send_upward_message(message: UpwardMessage) -> Result<u32, MessageSendError> {
1051+
fn send_upward_message(message: UpwardMessage) -> Result<(u32, XcmHash), MessageSendError> {
10441052
Self::send_upward_message(message)
10451053
}
10461054
}

pallets/xcm/src/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ pub mod pallet {
6767
pub enum Event<T: Config> {
6868
/// Downward message is invalid XCM.
6969
/// \[ id \]
70-
InvalidFormat([u8; 8]),
70+
InvalidFormat([u8; 32]),
7171
/// Downward message is unsupported version of XCM.
7272
/// \[ id \]
73-
UnsupportedVersion([u8; 8]),
73+
UnsupportedVersion([u8; 32]),
7474
/// Downward message executed with the given outcome.
7575
/// \[ id, outcome \]
76-
ExecutedDownward([u8; 8], Outcome),
76+
ExecutedDownward([u8; 32], Outcome),
7777
}
7878

7979
/// Origin for the parachains module.
@@ -113,7 +113,7 @@ impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
113113
) -> Weight {
114114
let mut used = Weight::zero();
115115
for (_sent_at, data) in iter {
116-
let id = sp_io::hashing::twox_64(&data[..]);
116+
let id = sp_io::hashing::blake2_256(&data[..]);
117117
let msg = VersionedXcm::<T::RuntimeCall>::decode_all_with_depth_limit(
118118
MAX_XCM_DECODE_DEPTH,
119119
&mut data.as_slice(),
@@ -123,8 +123,8 @@ impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
123123
Err(_) => Pallet::<T>::deposit_event(Event::InvalidFormat(id)),
124124
Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)),
125125
Ok(Ok(x)) => {
126-
let outcome = T::XcmExecutor::execute_xcm(Parent, x, limit.ref_time());
127-
used += Weight::from_ref_time(outcome.weight_used());
126+
let outcome = T::XcmExecutor::execute_xcm(Parent, x, id, limit);
127+
used = used.saturating_add(outcome.weight_used());
128128
Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome));
129129
},
130130
}
@@ -146,7 +146,7 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
146146
) -> Weight {
147147
let mut used = Weight::zero();
148148
for (_sent_at, data) in iter {
149-
let id = sp_io::hashing::twox_64(&data[..]);
149+
let id = sp_io::hashing::blake2_256(&data[..]);
150150
let msg = VersionedXcm::<T::RuntimeCall>::decode_all_with_depth_limit(
151151
MAX_XCM_DECODE_DEPTH,
152152
&mut data.as_slice(),
@@ -157,8 +157,8 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
157157
Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)),
158158
Ok(Ok(x)) => {
159159
let weight_limit = limit.saturating_sub(used);
160-
let outcome = T::XcmExecutor::execute_xcm(Parent, x, weight_limit.ref_time());
161-
used += Weight::from_ref_time(outcome.weight_used());
160+
let outcome = T::XcmExecutor::execute_xcm(Parent, x, id, weight_limit);
161+
used = used.saturating_add(outcome.weight_used());
162162
Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome));
163163
},
164164
}

pallets/xcmp-queue/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ scale-info = { version = "2.3.1", default-features = false, features = ["derive"
1313
# Substrate
1414
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
1515
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
16+
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
1617
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
1718
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
1819

1920
# Polkadot
21+
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
2022
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
2123
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
2224

@@ -30,7 +32,6 @@ frame-benchmarking = { default-features = false, optional = true, git = "https:/
3032

3133
# Substrate
3234
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
33-
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
3435
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
3536

3637
# Polkadot
@@ -48,6 +49,8 @@ std = [
4849
"frame-support/std",
4950
"frame-system/std",
5051
"log/std",
52+
"polkadot-runtime-common/std",
53+
"sp-io/std",
5154
"sp-runtime/std",
5255
"sp-std/std",
5356
"xcm-executor/std",

pallets/xcmp-queue/src/benchmarking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use frame_system::RawOrigin;
2222

2323
benchmarks! {
2424
set_config_with_u32 {}: update_resume_threshold(RawOrigin::Root, 100)
25-
set_config_with_weight {}: update_weight_restrict_decay(RawOrigin::Root, 3_000_000)
25+
set_config_with_weight {}: update_weight_restrict_decay(RawOrigin::Root, Weight::from_ref_time(3_000_000))
2626
}
2727

2828
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);

0 commit comments

Comments
 (0)