From 7e391b0eb274c797fa01e22a87c15bfb7526cf51 Mon Sep 17 00:00:00 2001 From: ron Date: Sat, 16 Nov 2024 00:39:20 +0800 Subject: [PATCH 1/7] For compatibility with V4 --- polkadot/xcm/src/v5/junction.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/polkadot/xcm/src/v5/junction.rs b/polkadot/xcm/src/v5/junction.rs index 952b61cd9ffed..d86a762fcf445 100644 --- a/polkadot/xcm/src/v5/junction.rs +++ b/polkadot/xcm/src/v5/junction.rs @@ -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, } From 7674e4c514d69c77c428963f542ae22e5c9eef2a Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 19 Nov 2024 21:46:01 +0800 Subject: [PATCH 2/7] Add prdoc --- prdoc/pr_6503.prdoc | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 prdoc/pr_6503.prdoc diff --git a/prdoc/pr_6503.prdoc b/prdoc/pr_6503.prdoc new file mode 100644 index 0000000000000..a618e44a2e323 --- /dev/null +++ b/prdoc/pr_6503.prdoc @@ -0,0 +1,10 @@ +title: "xcm: minor fix for compatibility with V4" + +doc: + - audience: ["Runtime Dev", "Runtime User"] + description: | + "To make NetworkId compatibility with V4" + +crates: +- name: staging-xcm + bump: patch From c02974c756651a256b848ca461158d8a9215216b Mon Sep 17 00:00:00 2001 From: Ron Date: Wed, 20 Nov 2024 21:52:43 +0800 Subject: [PATCH 3/7] Update prdoc/pr_6503.prdoc Co-authored-by: Adrian Catangiu --- prdoc/pr_6503.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_6503.prdoc b/prdoc/pr_6503.prdoc index a618e44a2e323..e092a29776b0c 100644 --- a/prdoc/pr_6503.prdoc +++ b/prdoc/pr_6503.prdoc @@ -3,7 +3,7 @@ title: "xcm: minor fix for compatibility with V4" doc: - audience: ["Runtime Dev", "Runtime User"] description: | - "To make NetworkId compatibility with V4" + "Following the removal of `NetworkId::Rococo` and `NetworkId::Westend`, fix `xcm::v5::NetworkId` encoding/decoding to be compatible with `xcm::v4::NetworkId`" crates: - name: staging-xcm From 22fdc98eb50af09196393d26a2a5e8826b05bca9 Mon Sep 17 00:00:00 2001 From: Ron Date: Mon, 25 Nov 2024 20:56:12 +0800 Subject: [PATCH 4/7] Update prdoc/pr_6503.prdoc Co-authored-by: Francisco Aguirre --- prdoc/pr_6503.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_6503.prdoc b/prdoc/pr_6503.prdoc index e092a29776b0c..dc296a93f0eb2 100644 --- a/prdoc/pr_6503.prdoc +++ b/prdoc/pr_6503.prdoc @@ -3,7 +3,7 @@ title: "xcm: minor fix for compatibility with V4" doc: - audience: ["Runtime Dev", "Runtime User"] description: | - "Following the removal of `NetworkId::Rococo` and `NetworkId::Westend`, fix `xcm::v5::NetworkId` encoding/decoding to be compatible with `xcm::v4::NetworkId`" + 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 From d9c4152932d27faba8c89db97cddd5c2c39e6fa1 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 26 Nov 2024 14:28:50 +0800 Subject: [PATCH 5/7] Fix breaking test --- .../pallets/inbound-queue/src/test.rs | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index 76d0b98e9eb46..205e3816f22c2 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -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::*; @@ -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: [ - 11, 25, 133, 51, 23, 68, 111, 211, 132, 94, 254, 17, 194, 252, 198, 233, 10, 193, - 156, 93, 72, 140, 65, 69, 79, 155, 154, 28, 141, 166, 171, 255, - ], - fee_burned: 110000000000, - } - .into()]); + let events = frame_system::Pallet::::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!( From 9ede51133e09dfaf548ef2b7af103a97d52ee042 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 26 Nov 2024 16:25:50 +0800 Subject: [PATCH 6/7] Fix clippy --- .../snowbridge/pallets/inbound-queue/src/mock.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs index 675d4b6915937..eed0656e9ca7f 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs @@ -248,20 +248,6 @@ impl inbound_queue::Config for Test { type AssetTransactor = SuccessfulTransactor; } -pub fn last_events(n: usize) -> Vec { - frame_system::Pallet::::events() - .into_iter() - .rev() - .take(n) - .rev() - .map(|e| e.event) - .collect() -} - -pub fn expect_events(e: Vec) { - assert_eq!(last_events(e.len()), e); -} - pub fn setup() { System::set_block_number(1); Balances::mint_into( From 8176bfe6d3759bf1d8e7beb5d91434ecc927c456 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 6 Dec 2024 23:50:57 +0800 Subject: [PATCH 7/7] Fix test --- .../pallets/inbound-queue/src/test.rs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index c439ab3d1c40d..7d0e9e957b3ae 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -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: [ - 97, 161, 116, 204, 182, 115, 192, 144, 130, 243, 240, 193, 122, 154, 108, 91, 247, - 41, 226, 237, 202, 158, 238, 239, 210, 8, 147, 131, 84, 146, 171, 176, - ], - fee_burned: 110000000000, - } - .into()]); + + let events = frame_system::Pallet::::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!(