Fix max-size messages at test chains (#2064)

* fix max-size messages submit for test chains

* impl review suggestions
This commit is contained in:
Svyatoslav Nikolsky
2023-04-26 08:57:49 +03:00
committed by Bastian Köcher
parent 47addd738b
commit 65b2196c6b
6 changed files with 160 additions and 31 deletions
@@ -17,11 +17,36 @@
//! Millau chain specification for CLI.
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
use bp_runtime::EncodedOrDecodedCall;
use bp_runtime::{ChainId, EncodedOrDecodedCall, RIALTO_CHAIN_ID, RIALTO_PARACHAIN_CHAIN_ID};
use bridge_runtime_common::CustomNetworkId;
use relay_millau_client::Millau;
use relay_substrate_client::SimpleRuntimeVersion;
use xcm_executor::traits::ExportXcm;
impl CliEncodeMessage for Millau {
fn encode_wire_message(
target: ChainId,
at_target_xcm: xcm::v3::Xcm<()>,
) -> anyhow::Result<Vec<u8>> {
let target = match target {
RIALTO_CHAIN_ID => CustomNetworkId::Rialto.as_network_id(),
RIALTO_PARACHAIN_CHAIN_ID => CustomNetworkId::RialtoParachain.as_network_id(),
_ => return Err(anyhow::format_err!("Unsupported target chain: {:?}", target)),
};
Ok(millau_runtime::xcm_config::ToRialtoOrRialtoParachainSwitchExporter::validate(
target,
0,
&mut Some(Self::dummy_universal_source()?),
&mut Some(target.into()),
&mut Some(at_target_xcm),
)
.map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))?
.0
.1
.0)
}
fn encode_execute_xcm(
message: xcm::VersionedXcm<Self::Call>,
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
@@ -17,11 +17,34 @@
//! Rialto chain specification for CLI.
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
use bp_runtime::EncodedOrDecodedCall;
use bp_runtime::{ChainId, EncodedOrDecodedCall, MILLAU_CHAIN_ID};
use bridge_runtime_common::CustomNetworkId;
use relay_rialto_client::Rialto;
use relay_substrate_client::SimpleRuntimeVersion;
use xcm_executor::traits::ExportXcm;
impl CliEncodeMessage for Rialto {
fn encode_wire_message(
target: ChainId,
at_target_xcm: xcm::v3::Xcm<()>,
) -> anyhow::Result<Vec<u8>> {
let target = match target {
MILLAU_CHAIN_ID => CustomNetworkId::Millau.as_network_id(),
_ => return Err(anyhow::format_err!("Unsupported target chian: {:?}", target)),
};
Ok(rialto_runtime::millau_messages::ToMillauBlobExporter::validate(
target,
0,
&mut Some(Self::dummy_universal_source()?),
&mut Some(target.into()),
&mut Some(at_target_xcm),
)
.map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))?
.0
.0)
}
fn encode_execute_xcm(
message: xcm::VersionedXcm<Self::Call>,
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
@@ -17,11 +17,34 @@
//! Rialto parachain specification for CLI.
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
use bp_runtime::EncodedOrDecodedCall;
use bp_runtime::{ChainId, EncodedOrDecodedCall, MILLAU_CHAIN_ID};
use bridge_runtime_common::CustomNetworkId;
use relay_rialto_parachain_client::RialtoParachain;
use relay_substrate_client::SimpleRuntimeVersion;
use xcm_executor::traits::ExportXcm;
impl CliEncodeMessage for RialtoParachain {
fn encode_wire_message(
target: ChainId,
at_target_xcm: xcm::v3::Xcm<()>,
) -> anyhow::Result<Vec<u8>> {
let target = match target {
MILLAU_CHAIN_ID => CustomNetworkId::Millau.as_network_id(),
_ => return Err(anyhow::format_err!("Unsupported target chain: {:?}", target)),
};
Ok(rialto_parachain_runtime::millau_messages::ToMillauBlobExporter::validate(
target,
0,
&mut Some(Self::dummy_universal_source()?),
&mut Some(target.into()),
&mut Some(at_target_xcm),
)
.map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))?
.0
.0)
}
fn encode_execute_xcm(
message: xcm::VersionedXcm<Self::Call>,
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {