Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b77ee8d
XCM: Automatic Version Negotiation
gavofyork Aug 28, 2021
eb367fd
Introduce the version instructions and subscription trait
gavofyork Aug 28, 2021
806f685
Notification and subscription data migration
gavofyork Aug 28, 2021
5fe6ac9
Version change subscriptions
gavofyork Aug 29, 2021
6e8e885
Fixes
gavofyork Aug 29, 2021
3dc6612
Formatting
gavofyork Aug 29, 2021
69da3ee
Spelling
gavofyork Aug 29, 2021
185ccb1
Fixes
gavofyork Aug 29, 2021
8f1b970
Fixes
gavofyork Aug 29, 2021
d63ef5c
Automatic unsubscription
gavofyork Aug 29, 2021
cc93b10
Formatting
gavofyork Aug 30, 2021
332b660
Expose remote origin in VM and ensure it is unchanged from actual ori…
gavofyork Aug 30, 2021
cb0fc45
Barrier
gavofyork Aug 30, 2021
24d0d39
Unsubscription extrinsic
gavofyork Aug 30, 2021
4cc58ab
Remove top_level param
gavofyork Aug 30, 2021
74ea2ff
Formatting
gavofyork Aug 30, 2021
22bb608
Fixes
gavofyork Aug 30, 2021
33aa24d
Automatic subscription
gavofyork Aug 30, 2021
f995f45
Formatting
gavofyork Aug 30, 2021
6c59e8c
Spelling
gavofyork Aug 30, 2021
198e0d5
Unit tests for XCM executor
gavofyork Aug 30, 2021
0a8ab6c
Formatting
gavofyork Aug 30, 2021
d2cc8e4
Spellin
gavofyork Aug 30, 2021
fa0e479
Unit test for XCM pallet subscriber side
gavofyork Aug 30, 2021
dcfb371
Formatting
gavofyork Aug 30, 2021
97439b0
More tests
gavofyork Aug 30, 2021
2cad1c5
Formatting
gavofyork Aug 30, 2021
02ab113
Fixes
gavofyork Aug 31, 2021
2258b45
Subscription-side tests
gavofyork Aug 31, 2021
b2b6c7b
Formatting
gavofyork Aug 31, 2021
5dd7d1a
Unit tests for XCM pallet
gavofyork Aug 31, 2021
ef175d5
Formatting
gavofyork Aug 31, 2021
be9a6ee
Update roadmap/implementers-guide/src/types/overseer-protocol.md
gavofyork Aug 31, 2021
fef43f3
Remove commented code
gavofyork Aug 31, 2021
da5b790
Merge branch 'gav-xcm-version-negotiation' of github.com:paritytech/p…
gavofyork Aug 31, 2021
08197f1
Grumbles
gavofyork Sep 1, 2021
49ff8c4
Multi-stage XCM version migration
gavofyork Sep 1, 2021
314943b
Formatting
gavofyork Sep 1, 2021
d536597
v1 subscriptions backport
gavofyork Sep 1, 2021
c016c36
Warning
gavofyork Sep 1, 2021
3ca4adb
Spelling
gavofyork Sep 2, 2021
fbb59cf
Fix grumbles
gavofyork Sep 2, 2021
c210313
Formatting
gavofyork Sep 2, 2021
3543b4d
Avoid running through old notifications
gavofyork Sep 2, 2021
84ff995
Formatting
gavofyork Sep 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix grumbles
  • Loading branch information
gavofyork committed Sep 2, 2021
commit fbb59cfaa902464a1db256aad078fd57619d8408
46 changes: 18 additions & 28 deletions xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,6 @@ pub mod pallet {
/// - `origin`: Must be Root.
/// - `location`: The destination that is being described.
/// - `xcm_version`: The latest version of XCM that `location` supports.
///
/// Errors:
/// - `BadLocation`: If the `location` cannot be expressed with the XCM version used by this
/// chain.
#[pallet::weight(100_000_000u64)]
pub fn force_xcm_version(
origin: OriginFor<T>,
Expand Down Expand Up @@ -780,34 +776,31 @@ pub mod pallet {
}

let xcm_version = T::AdvertisedXcmVersion::get();
let response = Response::Version(xcm_version);

if stage == NotifyCurrentTargets {
for (key, mut value) in VersionNotifyTargets::<T>::iter_prefix(XCM_VERSION) {
for (key, value) in VersionNotifyTargets::<T>::iter_prefix(XCM_VERSION) {
let (query_id, max_weight, mut target_xcm_version) = value;
let new_key: MultiLocation =
match (value.2 == xcm_version, key.clone().try_into()) {
(false, Ok(k)) => k,
match key.clone().try_into() {
Ok(k) if target_xcm_version != xcm_version => k,
_ => {
// We don't early return here since we need to be certain that we make some
// progress.
// We don't early return here since we need to be certain that we
// make some progress.
weight_used.saturating_accrue(todo_vnt_already_notified_weight);
continue
},
};
value.2 = xcm_version;
let message = Xcm(vec![QueryResponse {
query_id: value.0,
response: response.clone(),
max_weight: value.1,
}]);
let response = Response::Version(xcm_version);
let message = Xcm(vec![QueryResponse { query_id, response, max_weight }]);
let event = match T::XcmRouter::send_xcm(new_key.clone(), message) {
Ok(()) => {
let value = (query_id, max_weight, xcm_version);
VersionNotifyTargets::<T>::insert(XCM_VERSION, key, value);
Event::VersionChangeNotified(new_key, xcm_version)
},
Err(e) => {
VersionNotifyTargets::<T>::remove(XCM_VERSION, key);
Event::NotifyTargetSendFail(new_key, value.0, e.into())
Event::NotifyTargetSendFail(new_key, query_id, e.into())
},
};
Self::deposit_event(event);
Expand All @@ -820,7 +813,8 @@ pub mod pallet {
}
if stage == MigrateAndNotifyOldTargets {
for v in 0..XCM_VERSION {
for (old_key, mut value) in VersionNotifyTargets::<T>::drain_prefix(v) {
for (old_key, value) in VersionNotifyTargets::<T>::drain_prefix(v) {
let (query_id, max_weight, mut target_xcm_version) = value;
let new_key = match MultiLocation::try_from(old_key.clone()) {
Ok(k) => k,
Err(()) => {
Expand All @@ -836,27 +830,23 @@ pub mod pallet {
};

let versioned_key = LatestVersionedMultiLocation(&new_key);
if value.2 == xcm_version {
if target_xcm_version == xcm_version {
VersionNotifyTargets::<T>::insert(XCM_VERSION, versioned_key, value);
weight_used.saturating_accrue(todo_vnt_migrate_weight);
} else {
// Need to notify target.
value.2 = xcm_version;
let message = Xcm(vec![QueryResponse {
query_id: value.0,
response: response.clone(),
max_weight: value.1,
}]);
let response = Response::Version(xcm_version);
let message = Xcm(vec![QueryResponse { query_id, response, max_weight }]);
let event = match T::XcmRouter::send_xcm(new_key.clone(), message) {
Ok(()) => {
VersionNotifyTargets::<T>::insert(
XCM_VERSION,
versioned_key,
value,
(query_id, max_weight, xcm_version),
);
Event::VersionChangeNotified(new_key, xcm_version)
},
Err(e) => Event::NotifyTargetSendFail(new_key, value.0, e.into()),
Err(e) => Event::NotifyTargetSendFail(new_key, query_id, e.into()),
};
Self::deposit_event(event);
weight_used.saturating_accrue(todo_vnt_notify_migrate_weight);
Expand Down Expand Up @@ -1062,7 +1052,7 @@ pub mod pallet {
impl<T: Config> VersionChangeNotifier for Pallet<T> {
/// Start notifying `location` should the XCM version of this chain change.
///
/// When it does, this type should ensure an `QueryResponse` message is sent with the given
/// When it does, this type should ensure a `QueryResponse` message is sent with the given
/// `query_id` & `max_weight` and with a `response` of `Repsonse::Version`. This should happen
/// until/unless `stop` is called with the correct `query_id`.
///
Expand Down
2 changes: 1 addition & 1 deletion xcm/xcm-executor/src/traits/on_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl OnResponse for () {
pub trait VersionChangeNotifier {
/// Start notifying `location` should the XCM version of this chain change.
///
/// When it does, this type should ensure an `QueryResponse` message is sent with the given
/// When it does, this type should ensure a `QueryResponse` message is sent with the given
/// `query_id` & `max_weight` and with a `response` of `Repsonse::Version`. This should happen
/// until/unless `stop` is called with the correct `query_id`.
///
Expand Down