Skip to content

Commit

Permalink
XCMv5: Fix for compatibility with V4 (#6503)
Browse files Browse the repository at this point in the history
## Description

Our smoke tests transfer `WETH` from Sepolia to Westend-AssetHub breaks,
try to reregister `WETH` on AH but fails as following:


https://bridgehub-westend.subscan.io/xcm_message/westend-4796d6b3600aca32ef63b9953acf6a456cfd2fbe

https://assethub-westend.subscan.io/extrinsic/9731267-0?event=9731267-2

The reason is that the transact call encoded on BH to register the asset

https://github.com/paritytech/polkadot-sdk/blob/a77940bac783108fcae783c553528c8d5328e5b2/bridges/snowbridge/primitives/router/src/inbound/mod.rs#L282-L289
```
0x3500020209079edaa8020300fff9976782d46cc05630d1f6ebab18b2324d6b1400ce796ae65569a670d0c1cc1ac12515a3ce21b5fbf729d63d7b289baad070139d01000000000000000000000000000000
```

the `asset_id` which is the xcm location can't be decoded on AH in V5

Issue initial post in
https://matrix.to/#/!qUtSTcfMJzBdPmpFKa:parity.io/$RNMAxIIOKGtBAqkgwiFuQf4eNaYpmOK-Pfw4d6vv1aU?via=parity.io&via=matrix.org&via=web3.foundation

---------

Co-authored-by: Adrian Catangiu <[email protected]>
Co-authored-by: Francisco Aguirre <[email protected]>
  • Loading branch information
3 people authored Dec 10, 2024
1 parent 65a4e5e commit fe4846f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
14 changes: 0 additions & 14 deletions bridges/snowbridge/pallets/inbound-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,6 @@ impl inbound_queue::Config for Test {
type AssetTransactor = SuccessfulTransactor;
}

pub fn last_events(n: usize) -> Vec<RuntimeEvent> {
frame_system::Pallet::<Test>::events()
.into_iter()
.rev()
.take(n)
.rev()
.map(|e| e.event)
.collect()
}

pub fn expect_events(e: Vec<RuntimeEvent>) {
assert_eq!(last_events(e.len()), e);
}

pub fn setup() {
System::set_block_number(1);
Balances::mint_into(
Expand Down
23 changes: 11 additions & 12 deletions bridges/snowbridge/pallets/inbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sp_keyring::Sr25519Keyring as Keyring;
use sp_runtime::DispatchError;
use sp_std::convert::From;

use crate::{Error, Event as InboundQueueEvent};
use crate::Error;

use crate::mock::*;

Expand All @@ -35,17 +35,16 @@ fn test_submit_happy_path() {
assert_eq!(Balances::balance(&channel_sovereign), initial_fund);

assert_ok!(InboundQueue::submit(origin.clone(), message.clone()));
expect_events(vec![InboundQueueEvent::MessageReceived {
channel_id: hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539")
.into(),
nonce: 1,
message_id: [
118, 166, 139, 182, 84, 52, 165, 189, 54, 14, 178, 73, 2, 228, 192, 97, 153, 201,
4, 75, 151, 15, 82, 6, 164, 187, 162, 133, 26, 183, 186, 126,
],
fee_burned: 110000000000,
}
.into()]);

let events = frame_system::Pallet::<Test>::events();
assert!(
events.iter().any(|event| matches!(
event.event,
RuntimeEvent::InboundQueue(Event::MessageReceived { nonce, ..})
if nonce == 1
)),
"no event emit."
);

let delivery_cost = InboundQueue::calculate_delivery_cost(message.encode().len() as u32);
assert!(
Expand Down
4 changes: 4 additions & 0 deletions polkadot/xcm/src/v5/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,20 @@ pub enum NetworkId {
/// The Kusama canary-net Relay-chain.
Kusama,
/// An Ethereum network specified by its chain ID.
#[codec(index = 7)]
Ethereum {
/// The EIP-155 chain ID.
#[codec(compact)]
chain_id: u64,
},
/// The Bitcoin network, including hard-forks supported by Bitcoin Core development team.
#[codec(index = 8)]
BitcoinCore,
/// The Bitcoin network, including hard-forks supported by Bitcoin Cash developers.
#[codec(index = 9)]
BitcoinCash,
/// The Polkadot Bulletin chain.
#[codec(index = 10)]
PolkadotBulletin,
}

Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_6503.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: "xcm: minor fix for compatibility with V4"

doc:
- audience: ["Runtime Dev", "Runtime User"]
description: |
Following the removal of `Rococo`, `Westend` and `Wococo` from `NetworkId`, fixed `xcm::v5::NetworkId` encoding/decoding to be compatible with `xcm::v4::NetworkId`

crates:
- name: staging-xcm
bump: patch

0 comments on commit fe4846f

Please sign in to comment.