Skip to content

Commit 557ecbc

Browse files
authored
Fix sized messages (Follow-up on #2064) (#2103)
* Use wasm execution on millau and rialto It's safer like this since here are some errors that aren't caught when using native execution * Revert "Revert "Fix max-size messages at test chains (#2064)" (#2077)" This reverts commit 8c8adaf. * Adjustments
1 parent 54f587a commit 557ecbc

9 files changed

Lines changed: 165 additions & 45 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/runtime-common/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,21 @@ pub enum CustomNetworkId {
159159
RialtoParachain,
160160
}
161161

162+
impl TryFrom<bp_runtime::ChainId> for CustomNetworkId {
163+
type Error = ();
164+
165+
fn try_from(chain: bp_runtime::ChainId) -> Result<Self, Self::Error> {
166+
Ok(match chain {
167+
bp_runtime::MILLAU_CHAIN_ID => Self::Millau,
168+
bp_runtime::RIALTO_CHAIN_ID => Self::Rialto,
169+
bp_runtime::RIALTO_PARACHAIN_CHAIN_ID => Self::RialtoParachain,
170+
_ => return Err(()),
171+
})
172+
}
173+
}
174+
162175
impl CustomNetworkId {
176+
/// Converts self to XCM' network id.
163177
pub const fn as_network_id(&self) -> NetworkId {
164178
match *self {
165179
CustomNetworkId::Millau => NetworkId::Kusama,

deployments/networks/millau.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ services:
1111
image: ${MILLAU_BRIDGE_NODE_IMAGE:-paritytech/millau-bridge-node}
1212
entrypoint:
1313
- /home/user/millau-bridge-node
14-
- --execution=Native
1514
- --chain=local
1615
- --bootnodes=/dns4/millau-node-bob/tcp/30333/p2p/12D3KooWM5LFR5ne4yTQ4sBSXJ75M4bDo2MAhAW2GhL3i8fe5aRb
1716
- --alice
@@ -32,7 +31,6 @@ services:
3231
<<: *millau-bridge-node
3332
entrypoint:
3433
- /home/user/millau-bridge-node
35-
- --execution=Native
3634
- --chain=local
3735
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
3836
- --bob
@@ -51,7 +49,6 @@ services:
5149
<<: *millau-bridge-node
5250
entrypoint:
5351
- /home/user/millau-bridge-node
54-
- --execution=Native
5552
- --chain=local
5653
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
5754
- --charlie
@@ -69,7 +66,6 @@ services:
6966
<<: *millau-bridge-node
7067
entrypoint:
7168
- /home/user/millau-bridge-node
72-
- --execution=Native
7369
- --chain=local
7470
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
7571
- --dave
@@ -87,7 +83,6 @@ services:
8783
<<: *millau-bridge-node
8884
entrypoint:
8985
- /home/user/millau-bridge-node
90-
- --execution=Native
9186
- --chain=local
9287
- --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H
9388
- --eve

deployments/networks/rialto.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ services:
1111
image: ${RIALTO_BRIDGE_NODE_IMAGE:-paritytech/rialto-bridge-node}
1212
entrypoint:
1313
- /home/user/rialto-bridge-node
14-
- --execution=Native
1514
- --chain=local
1615
- --bootnodes=/dns4/rialto-node-bob/tcp/30333/p2p/12D3KooWSEpHJj29HEzgPFcRYVc5X3sEuP3KgiUoqJNCet51NiMX
1716
- --alice
@@ -32,7 +31,6 @@ services:
3231
<<: *rialto-bridge-node
3332
entrypoint:
3433
- /home/user/rialto-bridge-node
35-
- --execution=Native
3634
- --chain=local
3735
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
3836
- --bob
@@ -51,7 +49,6 @@ services:
5149
<<: *rialto-bridge-node
5250
entrypoint:
5351
- /home/user/rialto-bridge-node
54-
- --execution=Native
5552
- --chain=local
5653
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
5754
- --charlie
@@ -69,7 +66,6 @@ services:
6966
<<: *rialto-bridge-node
7067
entrypoint:
7168
- /home/user/rialto-bridge-node
72-
- --execution=Native
7369
- --chain=local
7470
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
7571
- --dave
@@ -87,7 +83,6 @@ services:
8783
<<: *rialto-bridge-node
8884
entrypoint:
8985
- /home/user/rialto-bridge-node
90-
- --execution=Native
9186
- --chain=local
9287
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
9388
- --eve
@@ -105,7 +100,6 @@ services:
105100
<<: *rialto-bridge-node
106101
entrypoint:
107102
- /home/user/rialto-bridge-node
108-
- --execution=Native
109103
- --chain=local
110104
- --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE
111105
- --ferdie

relays/bin-substrate/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ relay-utils = { path = "../utils" }
4949
relay-westend-client = { path = "../client-westend" }
5050
relay-wococo-client = { path = "../client-wococo" }
5151
rialto-runtime = { path = "../../bin/rialto/runtime" }
52+
# we are not using this runtime to craft callsour transactions, but we still need it
53+
# to prepare large XCM messages
54+
rialto-parachain-runtime = { path = "../../bin/rialto-parachain/runtime" }
5255
substrate-relay-helper = { path = "../lib-substrate-relay" }
5356

5457
# Substrate Dependencies
@@ -62,8 +65,8 @@ polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch =
6265
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
6366
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", branch = "master" }
6467
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" }
65-
xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
66-
68+
xcm = { git = "https://github.com/paritytech/polkadot", branch = "master" }
69+
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "master" }
6770

6871
[dev-dependencies]
6972
bp-test-utils = { path = "../../primitives/test-utils" }

relays/bin-substrate/src/chains/millau.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,38 @@
1818
1919
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
2020
use bp_runtime::EncodedOrDecodedCall;
21+
use bridge_runtime_common::CustomNetworkId;
2122
use relay_millau_client::Millau;
2223
use relay_substrate_client::SimpleRuntimeVersion;
24+
use xcm_executor::traits::ExportXcm;
2325

2426
impl CliEncodeMessage for Millau {
27+
fn encode_wire_message(
28+
target: xcm::v3::NetworkId,
29+
at_target_xcm: xcm::v3::Xcm<()>,
30+
) -> anyhow::Result<Vec<u8>> {
31+
anyhow::ensure!(
32+
[
33+
CustomNetworkId::Rialto.as_network_id(),
34+
CustomNetworkId::RialtoParachain.as_network_id()
35+
]
36+
.contains(&target),
37+
anyhow::format_err!("Unsupported target chain: {:?}", target)
38+
);
39+
40+
Ok(millau_runtime::xcm_config::ToRialtoOrRialtoParachainSwitchExporter::validate(
41+
target,
42+
0,
43+
&mut Some(Self::dummy_universal_source()?),
44+
&mut Some(target.into()),
45+
&mut Some(at_target_xcm),
46+
)
47+
.map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))?
48+
.0
49+
.1
50+
.0)
51+
}
52+
2553
fn encode_execute_xcm(
2654
message: xcm::VersionedXcm<Self::Call>,
2755
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {

relays/bin-substrate/src/chains/rialto.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,33 @@
1818
1919
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
2020
use bp_runtime::EncodedOrDecodedCall;
21+
use bridge_runtime_common::CustomNetworkId;
2122
use relay_rialto_client::Rialto;
2223
use relay_substrate_client::SimpleRuntimeVersion;
24+
use xcm_executor::traits::ExportXcm;
2325

2426
impl CliEncodeMessage for Rialto {
27+
fn encode_wire_message(
28+
target: xcm::v3::NetworkId,
29+
at_target_xcm: xcm::v3::Xcm<()>,
30+
) -> anyhow::Result<Vec<u8>> {
31+
anyhow::ensure!(
32+
target == CustomNetworkId::Millau.as_network_id(),
33+
anyhow::format_err!("Unsupported target chain: {:?}", target)
34+
);
35+
36+
Ok(rialto_runtime::millau_messages::ToMillauBlobExporter::validate(
37+
target,
38+
0,
39+
&mut Some(Self::dummy_universal_source()?),
40+
&mut Some(target.into()),
41+
&mut Some(at_target_xcm),
42+
)
43+
.map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))?
44+
.0
45+
.0)
46+
}
47+
2548
fn encode_execute_xcm(
2649
message: xcm::VersionedXcm<Self::Call>,
2750
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {

relays/bin-substrate/src/chains/rialto_parachain.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,33 @@
1818
1919
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
2020
use bp_runtime::EncodedOrDecodedCall;
21+
use bridge_runtime_common::CustomNetworkId;
2122
use relay_rialto_parachain_client::RialtoParachain;
2223
use relay_substrate_client::SimpleRuntimeVersion;
24+
use xcm_executor::traits::ExportXcm;
2325

2426
impl CliEncodeMessage for RialtoParachain {
27+
fn encode_wire_message(
28+
target: xcm::v3::NetworkId,
29+
at_target_xcm: xcm::v3::Xcm<()>,
30+
) -> anyhow::Result<Vec<u8>> {
31+
anyhow::ensure!(
32+
target == CustomNetworkId::Millau.as_network_id(),
33+
anyhow::format_err!("Unsupported target chain: {:?}", target)
34+
);
35+
36+
Ok(rialto_parachain_runtime::millau_messages::ToMillauBlobExporter::validate(
37+
target,
38+
0,
39+
&mut Some(Self::dummy_universal_source()?),
40+
&mut Some(target.into()),
41+
&mut Some(at_target_xcm),
42+
)
43+
.map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))?
44+
.0
45+
.0)
46+
}
47+
2548
fn encode_execute_xcm(
2649
message: xcm::VersionedXcm<Self::Call>,
2750
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {

0 commit comments

Comments
 (0)