Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -252,20 +252,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::AccountKeyring 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 emitted."
);

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)]
Copy link
Copy Markdown
Contributor

@bkontur bkontur Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth to add some ensuring unit-test, that encoded variants from a new version are backwards compatible, e.g. xcm::v5::NetworkId::Ethereum(chain: 1).encode() == xcm::v4::NetworkId::Ethereum(chain: 1).encode()?

Do we even need/want to be backwards-compatible this way between version? Shouldn't some migration for data fix this?

Copy link
Copy Markdown
Contributor Author

@franciscoaguirre franciscoaguirre Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely be compatible. I'm intrigued now about how the conversion functions we have were not enough to fix this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so definitely we need some tests for that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely be compatible. I'm intrigued now about how the convertersion functions we have were not enough to fix this

so where exactly is the issue if we do have conversion functions?

I think this could be fixed on snowbridge code side without needing to change indexes - I am willing to bet they are encoding/decoding without checking actual version and that's why it's failing.

Unfortunately, since the index change has been released in 2503, we have to backport it to 2412 or revert it and patch in 2503 to be consistent with xcm v5 locations encoding. So either way, we're cornered into yanking and patching crates.

I think patching 2412 is less work than patching 2503 so I am approving this PR, but this situation is not ok, and we have to get our shit together with managing these stable branches.

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_8194.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
Loading