Fix for BridgedSignedAccountId32AsNative

This commit is contained in:
Branislav Kontur
2023-01-05 23:10:42 +01:00
parent 0985898e45
commit c3195d205b
4 changed files with 31 additions and 13 deletions
@@ -91,7 +91,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 9301,
spec_version: 9302,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 8,
@@ -87,7 +87,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("westmint"),
impl_name: create_runtime_str!("westmint"),
authoring_version: 1,
spec_version: 9301,
spec_version: 9302,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 8,
@@ -399,24 +399,38 @@ where
kind: OriginKind,
) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into();
log::trace!(
target: "xcm::origin_conversion",
"BridgedSignedAccountId32AsNative origin: {:?}, kind: {:?}",
origin, kind,
);
if let OriginKind::SovereignAccount = kind {
match origin {
// this represents remote relaychain
MultiLocation {
parents: 2,
interior:
X2(
GlobalConsensus(remote_network),
AccountId32 { network: Some(account_remote_network), id: _id },
AccountId32 { network: _network, id: _id },
),
} |
// this represents remote parachain
MultiLocation {
parents: 2,
interior:
X3(
GlobalConsensus(remote_network),
Parachain(_),
AccountId32 { network: _network, id: _id },
),
} => {
// TODO:check-parameter - hack - configured local bridge-hub behaves on behalf of any origin from configured bridged network (just to pass Transact/System::remark_with_event - ensure_signed)
// find configured local bridge_hub for remote network
let bridge_hub_location = BridgedNetworks::get()
.iter()
.find(|(_, configured_bridged_network)| match configured_bridged_network {
GlobalConsensus(bridged_network) =>
bridged_network.eq(&account_remote_network) &&
bridged_network.eq(&remote_network),
GlobalConsensus(bridged_network) => bridged_network.eq(&remote_network),
_ => false,
})
.map(|(bridge_hub_location, _)| bridge_hub_location.clone());
@@ -330,13 +330,17 @@ fn test_receive_bridged_xcm_transact_with_remark_with_event_works() {
let origin = MultiLocation { parents: 1, interior: X1(Parachain(1014)) };
let xcm = Xcm(vec![
UniversalOrigin(GlobalConsensus(Rococo)),
DescendOrigin(X1(AccountId32 {
network: Some(Rococo),
id: [
28, 189, 45, 67, 83, 10, 68, 112, 90, 208, 136, 175, 49, 62, 24, 248, 11,
83, 239, 22, 179, 97, 119, 205, 75, 119, 184, 70, 242, 165, 240, 124,
],
})),
DescendOrigin(X2(
Parachain(1000),
AccountId32 {
network: Some(Rococo),
id: [
28, 189, 45, 67, 83, 10, 68, 112, 90, 208, 136, 175, 49, 62, 24, 248,
11, 83, 239, 22, 179, 97, 119, 205, 75, 119, 184, 70, 242, 165, 240,
124,
],
},
)),
Transact {
origin_kind: OriginKind::SovereignAccount,
require_weight_at_most: 1000000000,