From 98b4c6dcfc5dd0eac6535d49a386c203e8a62948 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 14 Feb 2024 17:58:01 +0100 Subject: [PATCH 1/6] feat(xcm): Add Paseo NetworkId for the new testnet --- polkadot/xcm/src/v4/junction.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/polkadot/xcm/src/v4/junction.rs b/polkadot/xcm/src/v4/junction.rs index b5d10484aa021..946e26aafd7dd 100644 --- a/polkadot/xcm/src/v4/junction.rs +++ b/polkadot/xcm/src/v4/junction.rs @@ -136,6 +136,8 @@ pub enum NetworkId { Westend, /// The Rococo testnet Relay-chain. Rococo, + /// The Paseo testnet Relay-chain. + Paseo, /// The Wococo testnet Relay-chain. Wococo, /// An Ethereum network specified by its chain ID. From a11dd8bfff3003c211e677f7f28f6b88facde1a7 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 14 Feb 2024 18:45:06 +0100 Subject: [PATCH 2/6] fix(xcm): Fix conversion functions from v4::NetworkId to v3::NetworkId --- polkadot/xcm/src/v3/junction.rs | 21 ++++++++++++--------- polkadot/xcm/src/v3/mod.rs | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/polkadot/xcm/src/v3/junction.rs b/polkadot/xcm/src/v3/junction.rs index e9e51941b1ac0..1ee795de4b108 100644 --- a/polkadot/xcm/src/v3/junction.rs +++ b/polkadot/xcm/src/v3/junction.rs @@ -107,14 +107,16 @@ impl TryFrom for NetworkId { impl From for Option { fn from(new: NewNetworkId) -> Self { - Some(NetworkId::from(new)) + NetworkId::try_from(new).ok() } } -impl From for NetworkId { - fn from(new: NewNetworkId) -> Self { +impl TryFrom for NetworkId { + type Error = (); + + fn try_from(new: NewNetworkId) -> Result { use NewNetworkId::*; - match new { + Ok(match new { ByGenesis(hash) => Self::ByGenesis(hash), ByFork { block_number, block_hash } => Self::ByFork { block_number, block_hash }, Polkadot => Self::Polkadot, @@ -126,7 +128,8 @@ impl From for NetworkId { BitcoinCore => Self::BitcoinCore, BitcoinCash => Self::BitcoinCash, PolkadotBulletin => Self::PolkadotBulletin, - } + Paseo => return Err(()), + }) } } @@ -448,17 +451,17 @@ impl TryFrom for Junction { Ok(match value { Parachain(id) => Self::Parachain(id), AccountId32 { network: maybe_network, id } => - Self::AccountId32 { network: maybe_network.map(|network| network.into()), id }, + Self::AccountId32 { network: maybe_network.map(|network| network.try_into()).transpose()?, id }, AccountIndex64 { network: maybe_network, index } => - Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index }, + Self::AccountIndex64 { network: maybe_network.map(|network| network.try_into()).transpose()?, index }, AccountKey20 { network: maybe_network, key } => - Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key }, + Self::AccountKey20 { network: maybe_network.map(|network| network.try_into()).transpose()?, key }, PalletInstance(index) => Self::PalletInstance(index), GeneralIndex(id) => Self::GeneralIndex(id), GeneralKey { length, data } => Self::GeneralKey { length, data }, OnlyChild => Self::OnlyChild, Plurality { id, part } => Self::Plurality { id, part }, - GlobalConsensus(network) => Self::GlobalConsensus(network.into()), + GlobalConsensus(network) => Self::GlobalConsensus(network.try_into()?), }) } } diff --git a/polkadot/xcm/src/v3/mod.rs b/polkadot/xcm/src/v3/mod.rs index d4e2da07a25ac..a6f3fbb6160e9 100644 --- a/polkadot/xcm/src/v3/mod.rs +++ b/polkadot/xcm/src/v3/mod.rs @@ -1446,7 +1446,7 @@ impl TryFrom> for Instruction { ClearTransactStatus => Self::ClearTransactStatus, UniversalOrigin(junction) => Self::UniversalOrigin(junction.try_into()?), ExportMessage { network, destination, xcm } => Self::ExportMessage { - network: network.into(), + network: network.try_into()?, destination: destination.try_into()?, xcm: xcm.try_into()?, }, From 3fc20b958410f4a5b14bcdb6c5e134d6d2cbd1f0 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 14 Feb 2024 18:54:54 +0100 Subject: [PATCH 3/6] docs: Add PRdoc --- prdoc/pr_3328.prdoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 prdoc/pr_3328.prdoc diff --git a/prdoc/pr_3328.prdoc b/prdoc/pr_3328.prdoc new file mode 100644 index 0000000000000..2fbdb9a749337 --- /dev/null +++ b/prdoc/pr_3328.prdoc @@ -0,0 +1,13 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Add Paseo NetworkId to XCM + +doc: + - audience: Runtime Dev + description: | + A new NetworkId was added to XCMv4 for the new [Paseo testnet](https://forum.polkadot.network/t/the-new-polkadot-community-testnet/4956). + Conversion from v4::NetworkId to v3::NetworkId is now fallible because of this extra variant. + +crates: + - staging-xcm From 9c34c1812665f7398cd65955a7fe61ed5a5880d5 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 14 Feb 2024 17:56:25 +0000 Subject: [PATCH 4/6] ".git/.scripts/commands/fmt/fmt.sh" --- polkadot/xcm/src/v3/junction.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/polkadot/xcm/src/v3/junction.rs b/polkadot/xcm/src/v3/junction.rs index 1ee795de4b108..c251523e174e6 100644 --- a/polkadot/xcm/src/v3/junction.rs +++ b/polkadot/xcm/src/v3/junction.rs @@ -450,12 +450,18 @@ impl TryFrom for Junction { use NewJunction::*; Ok(match value { Parachain(id) => Self::Parachain(id), - AccountId32 { network: maybe_network, id } => - Self::AccountId32 { network: maybe_network.map(|network| network.try_into()).transpose()?, id }, - AccountIndex64 { network: maybe_network, index } => - Self::AccountIndex64 { network: maybe_network.map(|network| network.try_into()).transpose()?, index }, - AccountKey20 { network: maybe_network, key } => - Self::AccountKey20 { network: maybe_network.map(|network| network.try_into()).transpose()?, key }, + AccountId32 { network: maybe_network, id } => Self::AccountId32 { + network: maybe_network.map(|network| network.try_into()).transpose()?, + id, + }, + AccountIndex64 { network: maybe_network, index } => Self::AccountIndex64 { + network: maybe_network.map(|network| network.try_into()).transpose()?, + index, + }, + AccountKey20 { network: maybe_network, key } => Self::AccountKey20 { + network: maybe_network.map(|network| network.try_into()).transpose()?, + key, + }, PalletInstance(index) => Self::PalletInstance(index), GeneralIndex(id) => Self::GeneralIndex(id), GeneralKey { length, data } => Self::GeneralKey { length, data }, From cf10fa461df9d958cdd79841b233e39ee4d9cca6 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 14 Feb 2024 19:09:14 +0100 Subject: [PATCH 5/6] fix(prdoc): Add properties to crate list --- prdoc/pr_3328.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_3328.prdoc b/prdoc/pr_3328.prdoc index 2fbdb9a749337..3490994f98750 100644 --- a/prdoc/pr_3328.prdoc +++ b/prdoc/pr_3328.prdoc @@ -10,4 +10,4 @@ doc: Conversion from v4::NetworkId to v3::NetworkId is now fallible because of this extra variant. crates: - - staging-xcm + - name: "staging-xcm" From ebba527d2032f97733c4c8be4cfa2af892d05c70 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Wed, 14 Feb 2024 20:00:17 +0100 Subject: [PATCH 6/6] fix(xcm::v4::NetworkId): Moved Paseo NetworkId to last --- polkadot/xcm/src/v4/junction.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/src/v4/junction.rs b/polkadot/xcm/src/v4/junction.rs index 946e26aafd7dd..d3d6d4ee58802 100644 --- a/polkadot/xcm/src/v4/junction.rs +++ b/polkadot/xcm/src/v4/junction.rs @@ -136,8 +136,6 @@ pub enum NetworkId { Westend, /// The Rococo testnet Relay-chain. Rococo, - /// The Paseo testnet Relay-chain. - Paseo, /// The Wococo testnet Relay-chain. Wococo, /// An Ethereum network specified by its chain ID. @@ -152,6 +150,8 @@ pub enum NetworkId { BitcoinCash, /// The Polkadot Bulletin chain. PolkadotBulletin, + /// The Paseo testnet Relay-chain. + Paseo, } impl From for Option {