mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 14:31:02 +00:00
* drop Rialto <> Millau bridges * clippy
This commit is contained in:
committed by
Bastian Köcher
parent
1c2b6b21da
commit
7a8c87a450
@@ -1,75 +0,0 @@
|
||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Millau chain specification for CLI.
|
||||
|
||||
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
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: xcm::v3::NetworkId,
|
||||
at_target_xcm: xcm::v3::Xcm<()>,
|
||||
) -> anyhow::Result<Vec<u8>> {
|
||||
anyhow::ensure!(
|
||||
[
|
||||
CustomNetworkId::Rialto.as_network_id(),
|
||||
CustomNetworkId::RialtoParachain.as_network_id()
|
||||
]
|
||||
.contains(&target),
|
||||
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>> {
|
||||
Ok(millau_runtime::RuntimeCall::XcmPallet(millau_runtime::XcmCall::execute {
|
||||
message: Box::new(message),
|
||||
max_weight: Self::estimate_execute_xcm_weight(),
|
||||
})
|
||||
.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl CliChain for Millau {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion::from_runtime_version(&millau_runtime::VERSION));
|
||||
}
|
||||
|
||||
/// TODO: Note: I know this does not belong here, but I don't want to add it to the
|
||||
/// `chain-asset-hub-westend` or `chain-westend`, because we wont use it for production and I don't
|
||||
/// want to bring this to the bridges subtree now. Anyway, we plan to retire millau/rialto, so this
|
||||
/// hack will disappear with that.
|
||||
impl CliChain for crate::bridges::westend_millau::westend_parachains_to_millau::relay_asset_hub_westend_client::AssetHubWestend {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
@@ -17,95 +17,8 @@
|
||||
//! Chain-specific relayer configuration.
|
||||
|
||||
mod kusama;
|
||||
mod millau;
|
||||
mod polkadot;
|
||||
mod polkadot_bulletin;
|
||||
mod rialto;
|
||||
mod rialto_parachain;
|
||||
mod rococo;
|
||||
mod westend;
|
||||
mod wococo;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cli::encode_message;
|
||||
use bp_messages::source_chain::TargetHeaderChain;
|
||||
use bp_runtime::Chain as _;
|
||||
use codec::Encode;
|
||||
use relay_millau_client::Millau;
|
||||
use relay_rialto_client::Rialto;
|
||||
use relay_substrate_client::{ChainWithTransactions, SignParam, UnsignedTransaction};
|
||||
|
||||
#[test]
|
||||
fn maximal_rialto_to_millau_message_size_is_computed_correctly() {
|
||||
use rialto_runtime::millau_messages::MillauAsTargetHeaderChain;
|
||||
|
||||
let maximal_message_size = encode_message::compute_maximal_message_size(
|
||||
bp_rialto::Rialto::max_extrinsic_size(),
|
||||
bp_millau::Millau::max_extrinsic_size(),
|
||||
);
|
||||
|
||||
let message = vec![42; maximal_message_size as _];
|
||||
assert_eq!(MillauAsTargetHeaderChain::verify_message(&message), Ok(()));
|
||||
|
||||
let message = vec![42; (maximal_message_size + 1) as _];
|
||||
assert!(MillauAsTargetHeaderChain::verify_message(&message).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn maximal_size_remark_to_rialto_is_generated_correctly() {
|
||||
assert!(
|
||||
bridge_runtime_common::messages::target::maximal_incoming_message_size(
|
||||
bp_rialto::Rialto::max_extrinsic_size()
|
||||
) > bp_millau::Millau::max_extrinsic_size(),
|
||||
"We can't actually send maximal messages to Rialto from Millau, because Millau extrinsics can't be that large",
|
||||
)
|
||||
}
|
||||
#[test]
|
||||
fn rialto_tx_extra_bytes_constant_is_correct() {
|
||||
let rialto_call = rialto_runtime::RuntimeCall::System(rialto_runtime::SystemCall::remark {
|
||||
remark: vec![],
|
||||
});
|
||||
let rialto_tx = Rialto::sign_transaction(
|
||||
SignParam {
|
||||
spec_version: 1,
|
||||
transaction_version: 1,
|
||||
genesis_hash: Default::default(),
|
||||
signer: sp_keyring::AccountKeyring::Alice.pair(),
|
||||
},
|
||||
UnsignedTransaction::new(rialto_call.clone().into(), 0),
|
||||
)
|
||||
.unwrap();
|
||||
let extra_bytes_in_transaction = rialto_tx.encode().len() - rialto_call.encode().len();
|
||||
assert!(
|
||||
bp_rialto::TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction,
|
||||
"Hardcoded number of extra bytes in Rialto transaction {} is lower than actual value: {}",
|
||||
bp_rialto::TX_EXTRA_BYTES,
|
||||
extra_bytes_in_transaction,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn millau_tx_extra_bytes_constant_is_correct() {
|
||||
let millau_call = millau_runtime::RuntimeCall::System(millau_runtime::SystemCall::remark {
|
||||
remark: vec![],
|
||||
});
|
||||
let millau_tx = Millau::sign_transaction(
|
||||
SignParam {
|
||||
spec_version: 0,
|
||||
transaction_version: 0,
|
||||
genesis_hash: Default::default(),
|
||||
signer: sp_keyring::AccountKeyring::Alice.pair(),
|
||||
},
|
||||
UnsignedTransaction::new(millau_call.clone().into(), 0),
|
||||
)
|
||||
.unwrap();
|
||||
let extra_bytes_in_transaction = millau_tx.encode().len() - millau_call.encode().len();
|
||||
assert!(
|
||||
bp_millau::TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction,
|
||||
"Hardcoded number of extra bytes in Millau transaction {} is lower than actual value: {}",
|
||||
bp_millau::TX_EXTRA_BYTES,
|
||||
extra_bytes_in_transaction,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Rialto chain specification for CLI.
|
||||
|
||||
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
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: xcm::v3::NetworkId,
|
||||
at_target_xcm: xcm::v3::Xcm<()>,
|
||||
) -> anyhow::Result<Vec<u8>> {
|
||||
anyhow::ensure!(
|
||||
target == CustomNetworkId::Millau.as_network_id(),
|
||||
anyhow::format_err!("Unsupported target chain: {:?}", 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>> {
|
||||
Ok(rialto_runtime::RuntimeCall::XcmPallet(rialto_runtime::XcmCall::execute {
|
||||
message: Box::new(message),
|
||||
max_weight: Self::estimate_execute_xcm_weight(),
|
||||
})
|
||||
.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl CliChain for Rialto {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
|
||||
Some(SimpleRuntimeVersion::from_runtime_version(&rialto_runtime::VERSION));
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Bridges Common.
|
||||
|
||||
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity Bridges Common is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Rialto parachain specification for CLI.
|
||||
|
||||
use crate::cli::{encode_message::CliEncodeMessage, CliChain};
|
||||
use bp_runtime::EncodedOrDecodedCall;
|
||||
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: xcm::v3::NetworkId,
|
||||
at_target_xcm: xcm::v3::Xcm<()>,
|
||||
) -> anyhow::Result<Vec<u8>> {
|
||||
anyhow::ensure!(
|
||||
target == CustomNetworkId::Millau.as_network_id(),
|
||||
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>> {
|
||||
type RuntimeCall = relay_rialto_parachain_client::RuntimeCall;
|
||||
type XcmCall = relay_rialto_parachain_client::runtime_types::pallet_xcm::pallet::Call;
|
||||
|
||||
let xcm_call = XcmCall::execute {
|
||||
message: Box::new(unsafe { std::mem::transmute(message) }),
|
||||
max_weight: Self::estimate_execute_xcm_weight(),
|
||||
};
|
||||
|
||||
Ok(RuntimeCall::PolkadotXcm(xcm_call).into())
|
||||
}
|
||||
}
|
||||
|
||||
impl CliChain for RialtoParachain {
|
||||
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> = None;
|
||||
}
|
||||
Reference in New Issue
Block a user