Skip to content
Snippets Groups Projects
Commit e58b1b3d authored by Svyatoslav Nikolsky's avatar Svyatoslav Nikolsky
Browse files

Merge branch 'master' into xcm-over-bridge

parents a36fb709 594ebac6
No related merge requests found
Showing
with 722 additions and 605 deletions
This diff is collapsed.
...@@ -189,7 +189,7 @@ You will also see the message lane relayers listening for new messages. ...@@ -189,7 +189,7 @@ You will also see the message lane relayers listening for new messages.
``` ```
# Message Relayer Logs # Message Relayer Logs
[Millau_to_Rialto_MessageLane_00000000] [date] DEBUG bridge Asking Millau::ReceivingConfirmationsDelivery about best message nonces [Millau_to_Rialto_MessageLane_0x52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7] [date] DEBUG bridge Asking Millau::ReceivingConfirmationsDelivery about best message nonces
[...] [date] INFO bridge Synced Some(2) of Some(3) nonces in Millau::MessagesDelivery -> Rialto::MessagesDelivery race [...] [date] INFO bridge Synced Some(2) of Some(3) nonces in Millau::MessagesDelivery -> Rialto::MessagesDelivery race
[...] [date] DEBUG bridge Asking Millau::MessagesDelivery about message nonces [...] [date] DEBUG bridge Asking Millau::MessagesDelivery about message nonces
[...] [date] DEBUG bridge Received best nonces from Millau::ReceivingConfirmationsDelivery: TargetClientNonces { latest_nonce: 0, nonces_data: () } [...] [date] DEBUG bridge Received best nonces from Millau::ReceivingConfirmationsDelivery: TargetClientNonces { latest_nonce: 0, nonces_data: () }
......
...@@ -16,6 +16,7 @@ serde_json = "1.0.97" ...@@ -16,6 +16,7 @@ serde_json = "1.0.97"
# Bridge dependencies # Bridge dependencies
bp-messages = { path = "../../../primitives/messages" } bp-messages = { path = "../../../primitives/messages" }
bridge-runtime-common = { path = "../../runtime-common" }
millau-runtime = { path = "../runtime" } millau-runtime = { path = "../runtime" }
# Substrate Dependencies # Substrate Dependencies
......
...@@ -14,10 +14,12 @@ ...@@ -14,10 +14,12 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use bridge_runtime_common::messages_xcm_extension::XcmBlobHauler;
use millau_runtime::{ use millau_runtime::{
AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig, AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig,
BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GenesisConfig, GrandpaConfig, BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GrandpaConfig,
SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY, RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig,
WASM_BINARY,
}; };
use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_beefy::crypto::AuthorityId as BeefyId; use sp_consensus_beefy::crypto::AuthorityId as BeefyId;
...@@ -41,7 +43,7 @@ const RIALTO_MESSAGES_PALLET_OWNER: &str = "Rialto.MessagesOwner"; ...@@ -41,7 +43,7 @@ const RIALTO_MESSAGES_PALLET_OWNER: &str = "Rialto.MessagesOwner";
const RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER: &str = "RialtoParachain.MessagesOwner"; const RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER: &str = "RialtoParachain.MessagesOwner";
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>; pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;
/// The chain specification option. This is expected to come in from the CLI and /// The chain specification option. This is expected to come in from the CLI and
/// is little more than one of a number of alternatives which can easily be converted /// is little more than one of a number of alternatives which can easily be converted
...@@ -193,8 +195,8 @@ fn testnet_genesis( ...@@ -193,8 +195,8 @@ fn testnet_genesis(
root_key: AccountId, root_key: AccountId,
endowed_accounts: Vec<AccountId>, endowed_accounts: Vec<AccountId>,
_enable_println: bool, _enable_println: bool,
) -> GenesisConfig { ) -> RuntimeGenesisConfig {
GenesisConfig { RuntimeGenesisConfig {
system: SystemConfig { system: SystemConfig {
code: WASM_BINARY.expect("Millau development WASM not available").to_vec(), code: WASM_BINARY.expect("Millau development WASM not available").to_vec(),
}, },
...@@ -222,14 +224,17 @@ fn testnet_genesis( ...@@ -222,14 +224,17 @@ fn testnet_genesis(
}, },
bridge_rialto_messages: BridgeRialtoMessagesConfig { bridge_rialto_messages: BridgeRialtoMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(RIALTO_MESSAGES_PALLET_OWNER)), owner: Some(get_account_id_from_seed::<sr25519::Public>(RIALTO_MESSAGES_PALLET_OWNER)),
opened_lanes: vec![bp_messages::LaneId::default()], opened_lanes: vec![millau_runtime::rialto_messages::ToRialtoXcmBlobHauler::xcm_lane()],
..Default::default() ..Default::default()
}, },
bridge_rialto_parachain_messages: BridgeRialtoParachainMessagesConfig { bridge_rialto_parachain_messages: BridgeRialtoParachainMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>( owner: Some(get_account_id_from_seed::<sr25519::Public>(
RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER, RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER,
)), )),
opened_lanes: vec![bp_messages::LaneId::default()], opened_lanes: vec![
millau_runtime::rialto_parachain_messages::ToRialtoParachainXcmBlobHauler::xcm_lane(
),
],
..Default::default() ..Default::default()
}, },
xcm_pallet: Default::default(), xcm_pallet: Default::default(),
......
...@@ -44,7 +44,7 @@ use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo}; ...@@ -44,7 +44,7 @@ use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo};
use sp_api::impl_runtime_apis; use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_beefy::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet}; use sp_consensus_beefy::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
use sp_core::OpaqueMetadata; use sp_core::{ConstBool, OpaqueMetadata};
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys,
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys}, traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
...@@ -229,6 +229,7 @@ impl pallet_aura::Config for Runtime { ...@@ -229,6 +229,7 @@ impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId; type AuthorityId = AuraId;
type MaxAuthorities = ConstU32<10>; type MaxAuthorities = ConstU32<10>;
type DisabledValidators = (); type DisabledValidators = ();
type AllowMultipleBlocksPerSlot = ConstBool<false>;
} }
impl pallet_beefy::Config for Runtime { impl pallet_beefy::Config for Runtime {
...@@ -483,7 +484,6 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run ...@@ -483,7 +484,6 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
} }
parameter_types! { parameter_types! {
pub const RialtoParachainMessagesLane: bp_messages::LaneId = rialto_parachain_messages::XCM_LANE;
pub const RialtoParasPalletName: &'static str = bp_rialto::PARAS_PALLET_NAME; pub const RialtoParasPalletName: &'static str = bp_rialto::PARAS_PALLET_NAME;
pub const WestendParasPalletName: &'static str = bp_westend::PARAS_PALLET_NAME; pub const WestendParasPalletName: &'static str = bp_westend::PARAS_PALLET_NAME;
pub const MaxRialtoParaHeadDataSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE; pub const MaxRialtoParaHeadDataSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;
...@@ -585,7 +585,7 @@ pub type PriorityBoostPerMessage = ConstU64<327_319_648>; ...@@ -585,7 +585,7 @@ pub type PriorityBoostPerMessage = ConstU64<327_319_648>;
pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages< pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages<
Runtime, Runtime,
RefundableParachain<WithRialtoParachainsInstance, bp_rialto_parachain::RialtoParachain>, RefundableParachain<WithRialtoParachainsInstance, bp_rialto_parachain::RialtoParachain>,
RefundableMessagesLane<WithRialtoParachainMessagesInstance, RialtoParachainMessagesLane>, RefundableMessagesLane<Runtime, WithRialtoParachainMessagesInstance>,
ActualFeeRefund<Runtime>, ActualFeeRefund<Runtime>,
PriorityBoostPerMessage, PriorityBoostPerMessage,
StrBridgeRefundRialtoPara2000Lane0Msgs, StrBridgeRefundRialtoPara2000Lane0Msgs,
......
...@@ -19,13 +19,14 @@ ...@@ -19,13 +19,14 @@
use crate::{Runtime, WithRialtoMessagesInstance}; use crate::{Runtime, WithRialtoMessagesInstance};
use bp_messages::LaneId; use bp_messages::LaneId;
use bridge_runtime_common::messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}; use bridge_runtime_common::messages_xcm_extension::{
LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter,
};
use frame_support::{parameter_types, weights::Weight}; use frame_support::{parameter_types, weights::Weight};
use pallet_bridge_relayers::WeightInfoExt as _; use pallet_bridge_relayers::WeightInfoExt as _;
use sp_core::Get;
use xcm_builder::HaulBlobExporter; use xcm_builder::HaulBlobExporter;
/// Default lane that is used to send messages to Rialto.
pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]);
/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge /// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual /// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual
/// tests, confirming that we don't break encoding somewhere between. /// tests, confirming that we don't break encoding somewhere between.
...@@ -60,7 +61,7 @@ impl XcmBlobHauler for ToRialtoXcmBlobHauler { ...@@ -60,7 +61,7 @@ impl XcmBlobHauler for ToRialtoXcmBlobHauler {
type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithRialtoMessagesInstance>; type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithRialtoMessagesInstance>;
fn xcm_lane() -> LaneId { fn xcm_lane() -> LaneId {
XCM_LANE LaneIdFromChainId::<Runtime, WithRialtoMessagesInstance>::get()
} }
} }
...@@ -80,6 +81,7 @@ impl pallet_bridge_messages::WeightInfoExt for crate::weights::RialtoMessagesWei ...@@ -80,6 +81,7 @@ impl pallet_bridge_messages::WeightInfoExt for crate::weights::RialtoMessagesWei
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::{RialtoGrandpaInstance, Runtime, WithRialtoMessagesInstance}; use crate::{RialtoGrandpaInstance, Runtime, WithRialtoMessagesInstance};
use bridge_runtime_common::{ use bridge_runtime_common::{
...@@ -121,4 +123,15 @@ mod tests { ...@@ -121,4 +123,15 @@ mod tests {
}, },
}); });
} }
#[test]
fn rialto_millau_bridge_identifier_did_not_changed() {
// there's nothing criminal if it is changed, but then thou need to fix it across
// all deployments scripts, alerts and so on
assert_eq!(
*ToRialtoXcmBlobHauler::xcm_lane().as_ref(),
hex_literal::hex!("52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7")
.into(),
);
}
} }
...@@ -19,13 +19,14 @@ ...@@ -19,13 +19,14 @@
use crate::{Runtime, WithRialtoParachainMessagesInstance}; use crate::{Runtime, WithRialtoParachainMessagesInstance};
use bp_messages::LaneId; use bp_messages::LaneId;
use bridge_runtime_common::messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}; use bridge_runtime_common::messages_xcm_extension::{
LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter,
};
use frame_support::{parameter_types, weights::Weight}; use frame_support::{parameter_types, weights::Weight};
use pallet_bridge_relayers::WeightInfoExt as _; use pallet_bridge_relayers::WeightInfoExt as _;
use sp_core::Get;
use xcm_builder::HaulBlobExporter; use xcm_builder::HaulBlobExporter;
/// Default lane that is used to send messages to Rialto parachain.
pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]);
/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge /// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual /// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual
/// tests, confirming that we don't break encoding somewhere between. /// tests, confirming that we don't break encoding somewhere between.
...@@ -61,7 +62,7 @@ impl XcmBlobHauler for ToRialtoParachainXcmBlobHauler { ...@@ -61,7 +62,7 @@ impl XcmBlobHauler for ToRialtoParachainXcmBlobHauler {
pallet_bridge_messages::Pallet<Runtime, WithRialtoParachainMessagesInstance>; pallet_bridge_messages::Pallet<Runtime, WithRialtoParachainMessagesInstance>;
fn xcm_lane() -> LaneId { fn xcm_lane() -> LaneId {
XCM_LANE LaneIdFromChainId::<Runtime, WithRialtoParachainMessagesInstance>::get()
} }
} }
...@@ -83,6 +84,7 @@ impl pallet_bridge_messages::WeightInfoExt ...@@ -83,6 +84,7 @@ impl pallet_bridge_messages::WeightInfoExt
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::{ use crate::{
PriorityBoostPerMessage, RialtoGrandpaInstance, Runtime, PriorityBoostPerMessage, RialtoGrandpaInstance, Runtime,
WithRialtoParachainMessagesInstance, WithRialtoParachainMessagesInstance,
...@@ -134,4 +136,15 @@ mod tests { ...@@ -134,4 +136,15 @@ mod tests {
PriorityBoostPerMessage, PriorityBoostPerMessage,
>(1_000_000); >(1_000_000);
} }
#[test]
fn rialto_parachain_millau_bridge_identifier_did_not_changed() {
// there's nothing criminal if it is changed, but then thou need to fix it across
// all deployments scripts, alerts and so on
assert_eq!(
*ToRialtoParachainXcmBlobHauler::xcm_lane().as_ref(),
hex_literal::hex!("6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de")
.into(),
);
}
} }
...@@ -141,6 +141,7 @@ impl xcm_executor::Config for XcmConfig { ...@@ -141,6 +141,7 @@ impl xcm_executor::Config for XcmConfig {
type UniversalAliases = Nothing; type UniversalAliases = Nothing;
type CallDispatcher = RuntimeCall; type CallDispatcher = RuntimeCall;
type SafeCallFilter = Everything; type SafeCallFilter = Everything;
type Aliasers = Nothing;
} }
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
...@@ -244,7 +245,9 @@ mod tests { ...@@ -244,7 +245,9 @@ mod tests {
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
LaneId, MessageKey, OutboundLaneData, LaneId, MessageKey, OutboundLaneData,
}; };
use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; use bridge_runtime_common::messages_xcm_extension::{
XcmBlobHauler, XcmBlobMessageDispatchResult,
};
use codec::Encode; use codec::Encode;
use pallet_bridge_messages::OutboundLanes; use pallet_bridge_messages::OutboundLanes;
use xcm_executor::XcmExecutor; use xcm_executor::XcmExecutor;
...@@ -268,16 +271,15 @@ mod tests { ...@@ -268,16 +271,15 @@ mod tests {
fn xcm_messages_to_rialto_are_sent_using_bridge_exporter() { fn xcm_messages_to_rialto_are_sent_using_bridge_exporter() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// ensure that the there are no messages queued // ensure that the there are no messages queued
let lane_id = crate::rialto_messages::ToRialtoXcmBlobHauler::xcm_lane();
OutboundLanes::<Runtime, WithRialtoMessagesInstance>::insert( OutboundLanes::<Runtime, WithRialtoMessagesInstance>::insert(
crate::rialto_messages::XCM_LANE, lane_id,
OutboundLaneData::opened(), OutboundLaneData::opened(),
); );
assert_eq!( assert_eq!(
OutboundLanes::<Runtime, WithRialtoMessagesInstance>::get( OutboundLanes::<Runtime, WithRialtoMessagesInstance>::get(lane_id)
crate::rialto_messages::XCM_LANE .unwrap()
) .latest_generated_nonce,
.unwrap()
.latest_generated_nonce,
0, 0,
); );
...@@ -294,11 +296,9 @@ mod tests { ...@@ -294,11 +296,9 @@ mod tests {
// ensure that the message has been queued // ensure that the message has been queued
assert_eq!( assert_eq!(
OutboundLanes::<Runtime, WithRialtoMessagesInstance>::get( OutboundLanes::<Runtime, WithRialtoMessagesInstance>::get(lane_id)
crate::rialto_messages::XCM_LANE .unwrap()
) .latest_generated_nonce,
.unwrap()
.latest_generated_nonce,
1, 1,
); );
}) })
...@@ -308,16 +308,16 @@ mod tests { ...@@ -308,16 +308,16 @@ mod tests {
fn xcm_messages_to_rialto_parachain_are_sent_using_bridge_exporter() { fn xcm_messages_to_rialto_parachain_are_sent_using_bridge_exporter() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// ensure that the there are no messages queued // ensure that the there are no messages queued
let lane_id =
crate::rialto_parachain_messages::ToRialtoParachainXcmBlobHauler::xcm_lane();
OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::insert( OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::insert(
crate::rialto_parachain_messages::XCM_LANE, lane_id,
OutboundLaneData::opened(), OutboundLaneData::opened(),
); );
assert_eq!( assert_eq!(
OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::get( OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::get(lane_id)
crate::rialto_parachain_messages::XCM_LANE .unwrap()
) .latest_generated_nonce,
.unwrap()
.latest_generated_nonce,
0, 0,
); );
...@@ -334,17 +334,15 @@ mod tests { ...@@ -334,17 +334,15 @@ mod tests {
// ensure that the message has been queued // ensure that the message has been queued
assert_eq!( assert_eq!(
OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::get( OutboundLanes::<Runtime, WithRialtoParachainMessagesInstance>::get(lane_id)
crate::rialto_parachain_messages::XCM_LANE .unwrap()
) .latest_generated_nonce,
.unwrap()
.latest_generated_nonce,
1, 1,
); );
}) })
} }
fn prepare_inbound_bridge_message() -> DispatchMessage<Vec<u8>> { fn prepare_inbound_bridge_message(lane_id: LaneId) -> DispatchMessage<Vec<u8>> {
let xcm = xcm::VersionedXcm::<RuntimeCall>::V3(vec![Instruction::Trap(42)].into()); let xcm = xcm::VersionedXcm::<RuntimeCall>::V3(vec![Instruction::Trap(42)].into());
let location = let location =
xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get()))); xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get())));
...@@ -352,14 +350,16 @@ mod tests { ...@@ -352,14 +350,16 @@ mod tests {
// or public fields, so just tuple // or public fields, so just tuple
let bridge_message = (location, xcm).encode(); let bridge_message = (location, xcm).encode();
DispatchMessage { DispatchMessage {
key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, key: MessageKey { lane_id, nonce: 1 },
data: DispatchMessageData { payload: Ok(bridge_message) }, data: DispatchMessageData { payload: Ok(bridge_message) },
} }
} }
#[test] #[test]
fn xcm_messages_from_rialto_are_dispatched() { fn xcm_messages_from_rialto_are_dispatched() {
let incoming_message = prepare_inbound_bridge_message(); let incoming_message = prepare_inbound_bridge_message(
crate::rialto_messages::ToRialtoXcmBlobHauler::xcm_lane(),
);
// we care only about handing message to the XCM dispatcher, so we don't care about its // we care only about handing message to the XCM dispatcher, so we don't care about its
// actual dispatch // actual dispatch
...@@ -372,7 +372,9 @@ mod tests { ...@@ -372,7 +372,9 @@ mod tests {
#[test] #[test]
fn xcm_messages_from_rialto_parachain_are_dispatched() { fn xcm_messages_from_rialto_parachain_are_dispatched() {
let incoming_message = prepare_inbound_bridge_message(); let incoming_message = prepare_inbound_bridge_message(
crate::rialto_parachain_messages::ToRialtoParachainXcmBlobHauler::xcm_lane(),
);
// we care only about handing message to the XCM dispatcher, so we don't care about its // we care only about handing message to the XCM dispatcher, so we don't care about its
// actual dispatch // actual dispatch
......
...@@ -28,6 +28,7 @@ jsonrpsee = { version = "0.16.2", features = ["server"] } ...@@ -28,6 +28,7 @@ jsonrpsee = { version = "0.16.2", features = ["server"] }
# Local Dependencies # Local Dependencies
bp-messages = { path = "../../../primitives/messages" } bp-messages = { path = "../../../primitives/messages" }
bridge-runtime-common = { path = "../../runtime-common" }
rialto-parachain-runtime = { path = '../runtime' } rialto-parachain-runtime = { path = '../runtime' }
# Substrate Dependencies # Substrate Dependencies
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use bridge_runtime_common::messages_xcm_extension::XcmBlobHauler;
use cumulus_primitives_core::ParaId; use cumulus_primitives_core::ParaId;
use rialto_parachain_runtime::{AccountId, AuraId, BridgeMillauMessagesConfig, Signature}; use rialto_parachain_runtime::{AccountId, AuraId, BridgeMillauMessagesConfig, Signature};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
...@@ -35,7 +36,7 @@ const MILLAU_MESSAGES_PALLET_OWNER: &str = "Millau.MessagesOwner"; ...@@ -35,7 +36,7 @@ const MILLAU_MESSAGES_PALLET_OWNER: &str = "Millau.MessagesOwner";
/// Specialized `ChainSpec` for the normal parachain runtime. /// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = pub type ChainSpec =
sc_service::GenericChainSpec<rialto_parachain_runtime::GenesisConfig, Extensions>; sc_service::GenericChainSpec<rialto_parachain_runtime::RuntimeGenesisConfig, Extensions>;
/// Helper function to generate a crypto pair from seed /// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public { pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
...@@ -176,8 +177,8 @@ fn testnet_genesis( ...@@ -176,8 +177,8 @@ fn testnet_genesis(
initial_authorities: Vec<AuraId>, initial_authorities: Vec<AuraId>,
endowed_accounts: Vec<AccountId>, endowed_accounts: Vec<AccountId>,
id: ParaId, id: ParaId,
) -> rialto_parachain_runtime::GenesisConfig { ) -> rialto_parachain_runtime::RuntimeGenesisConfig {
rialto_parachain_runtime::GenesisConfig { rialto_parachain_runtime::RuntimeGenesisConfig {
system: rialto_parachain_runtime::SystemConfig { system: rialto_parachain_runtime::SystemConfig {
code: rialto_parachain_runtime::WASM_BINARY code: rialto_parachain_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!") .expect("WASM binary was not build, please build it!")
...@@ -192,7 +193,9 @@ fn testnet_genesis( ...@@ -192,7 +193,9 @@ fn testnet_genesis(
aura_ext: Default::default(), aura_ext: Default::default(),
bridge_millau_messages: BridgeMillauMessagesConfig { bridge_millau_messages: BridgeMillauMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(MILLAU_MESSAGES_PALLET_OWNER)), owner: Some(get_account_id_from_seed::<sr25519::Public>(MILLAU_MESSAGES_PALLET_OWNER)),
opened_lanes: vec![bp_messages::LaneId::default()], opened_lanes: vec![
rialto_parachain_runtime::millau_messages::ToMillauXcmBlobHauler::xcm_lane(),
],
..Default::default() ..Default::default()
}, },
} }
......
...@@ -286,7 +286,7 @@ pub fn run() -> Result<()> { ...@@ -286,7 +286,7 @@ pub fn run() -> Result<()> {
let id = ParaId::from(cli.parachain_id.or(para_id).expect("Missing ParaId")); let id = ParaId::from(cli.parachain_id.or(para_id).expect("Missing ParaId"));
let parachain_account = let parachain_account =
AccountIdConversion::<polkadot_primitives::v4::AccountId>::into_account_truncating(&id); AccountIdConversion::<polkadot_primitives::v5::AccountId>::into_account_truncating(&id);
let state_version = let state_version =
RelayChainCli::native_runtime_version(&config.chain_spec).state_version(); RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
......
...@@ -31,7 +31,7 @@ use codec::{Decode, Encode}; ...@@ -31,7 +31,7 @@ use codec::{Decode, Encode};
use cumulus_pallet_parachain_system::AnyRelayNumber; use cumulus_pallet_parachain_system::AnyRelayNumber;
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_api::impl_runtime_apis; use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_core::{crypto::KeyTypeId, ConstBool, OpaqueMetadata};
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, Block as BlockT, DispatchInfoOf, SignedExtension}, traits::{AccountIdLookup, Block as BlockT, DispatchInfoOf, SignedExtension},
...@@ -461,6 +461,7 @@ impl Config for XcmConfig { ...@@ -461,6 +461,7 @@ impl Config for XcmConfig {
type UniversalAliases = Nothing; type UniversalAliases = Nothing;
type CallDispatcher = RuntimeCall; type CallDispatcher = RuntimeCall;
type SafeCallFilter = Everything; type SafeCallFilter = Everything;
type Aliasers = Nothing;
} }
/// No local origins on this chain are allowed to dispatch XCM sends/executions. /// No local origins on this chain are allowed to dispatch XCM sends/executions.
...@@ -529,6 +530,7 @@ impl pallet_aura::Config for Runtime { ...@@ -529,6 +530,7 @@ impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId; type AuthorityId = AuraId;
type DisabledValidators = (); type DisabledValidators = ();
type MaxAuthorities = MaxAuthorities; type MaxAuthorities = MaxAuthorities;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
} }
impl pallet_bridge_relayers::Config for Runtime { impl pallet_bridge_relayers::Config for Runtime {
...@@ -839,14 +841,15 @@ cumulus_pallet_parachain_system::register_validate_block!( ...@@ -839,14 +841,15 @@ cumulus_pallet_parachain_system::register_validate_block!(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::millau_messages::{FromMillauMessageDispatch, XCM_LANE}; use crate::millau_messages::FromMillauMessageDispatch;
use bp_messages::{ use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
LaneId, MessageKey, OutboundLaneData, MessageKey, OutboundLaneData,
}; };
use bp_runtime::Chain; use bp_runtime::Chain;
use bridge_runtime_common::{ use bridge_runtime_common::{
integrity::check_additional_signed, messages_xcm_extension::XcmBlobMessageDispatchResult, integrity::check_additional_signed,
messages_xcm_extension::{XcmBlobHauler, XcmBlobMessageDispatchResult},
}; };
use codec::Encode; use codec::Encode;
use pallet_bridge_messages::OutboundLanes; use pallet_bridge_messages::OutboundLanes;
...@@ -880,12 +883,13 @@ mod tests { ...@@ -880,12 +883,13 @@ mod tests {
fn xcm_messages_to_millau_are_sent_using_bridge_exporter() { fn xcm_messages_to_millau_are_sent_using_bridge_exporter() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// ensure that the there are no messages queued // ensure that the there are no messages queued
let lane_id = crate::millau_messages::ToMillauXcmBlobHauler::xcm_lane();
OutboundLanes::<Runtime, WithMillauMessagesInstance>::insert( OutboundLanes::<Runtime, WithMillauMessagesInstance>::insert(
XCM_LANE, lane_id,
OutboundLaneData::opened(), OutboundLaneData::opened(),
); );
assert_eq!( assert_eq!(
OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(XCM_LANE) OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(lane_id)
.unwrap() .unwrap()
.latest_generated_nonce, .latest_generated_nonce,
0, 0,
...@@ -904,7 +908,7 @@ mod tests { ...@@ -904,7 +908,7 @@ mod tests {
// ensure that the message has been queued // ensure that the message has been queued
assert_eq!( assert_eq!(
OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(XCM_LANE) OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(lane_id)
.unwrap() .unwrap()
.latest_generated_nonce, .latest_generated_nonce,
1, 1,
...@@ -918,9 +922,10 @@ mod tests { ...@@ -918,9 +922,10 @@ mod tests {
xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get()))); xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get())));
// this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor
// or public fields, so just tuple // or public fields, so just tuple
let xcm_lane = crate::millau_messages::ToMillauXcmBlobHauler::xcm_lane();
let bridge_message = (location, xcm).encode(); let bridge_message = (location, xcm).encode();
DispatchMessage { DispatchMessage {
key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, key: MessageKey { lane_id: xcm_lane, nonce: 1 },
data: DispatchMessageData { payload: Ok(bridge_message) }, data: DispatchMessageData { payload: Ok(bridge_message) },
} }
} }
......
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
use crate::{Runtime, WithMillauMessagesInstance}; use crate::{Runtime, WithMillauMessagesInstance};
use bp_messages::LaneId; use bp_messages::LaneId;
use bridge_runtime_common::messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}; use bridge_runtime_common::messages_xcm_extension::{
LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter,
};
use frame_support::{parameter_types, weights::Weight}; use frame_support::{parameter_types, weights::Weight};
use sp_core::Get;
use xcm_builder::HaulBlobExporter; use xcm_builder::HaulBlobExporter;
/// Default lane that is used to send messages to Millau.
pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]);
/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge /// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual /// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual
/// tests, confirming that we don't break encoding somewhere between. /// tests, confirming that we don't break encoding somewhere between.
...@@ -59,12 +60,13 @@ impl XcmBlobHauler for ToMillauXcmBlobHauler { ...@@ -59,12 +60,13 @@ impl XcmBlobHauler for ToMillauXcmBlobHauler {
type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithMillauMessagesInstance>; type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithMillauMessagesInstance>;
fn xcm_lane() -> LaneId { fn xcm_lane() -> LaneId {
XCM_LANE LaneIdFromChainId::<Runtime, WithMillauMessagesInstance>::get()
} }
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance}; use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance};
use bridge_runtime_common::{ use bridge_runtime_common::{
assert_complete_bridge_types, assert_complete_bridge_types,
...@@ -109,4 +111,15 @@ mod tests { ...@@ -109,4 +111,15 @@ mod tests {
}, },
}); });
} }
#[test]
fn rialto_parachain_millau_bridge_identifier_did_not_changed() {
// there's nothing criminal if it is changed, but then thou need to fix it across
// all deployments scripts, alerts and so on
assert_eq!(
*ToMillauXcmBlobHauler::xcm_lane().as_ref(),
hex_literal::hex!("6aa61bff567db6b5d5f0cb815ee6d8f5ac630e222a95700cb3d594134e3805de")
.into(),
);
}
} }
...@@ -15,6 +15,7 @@ serde_json = "1.0.97" ...@@ -15,6 +15,7 @@ serde_json = "1.0.97"
# Bridge dependencies # Bridge dependencies
bp-messages = { path = "../../../primitives/messages" } bp-messages = { path = "../../../primitives/messages" }
bridge-runtime-common = { path = "../../runtime-common" }
rialto-runtime = { path = "../runtime" } rialto-runtime = { path = "../runtime" }
# Substrate Dependencies # Substrate Dependencies
......
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
// You should have received a copy of the GNU General Public License // 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/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use polkadot_primitives::v4::{AssignmentId, ValidatorId}; use bridge_runtime_common::messages_xcm_extension::XcmBlobHauler;
use polkadot_primitives::v5::{AssignmentId, ValidatorId};
use rialto_runtime::{ use rialto_runtime::{
AccountId, BabeConfig, BalancesConfig, BeefyConfig, BridgeMillauMessagesConfig, AccountId, BabeConfig, BalancesConfig, BeefyConfig, BridgeMillauMessagesConfig,
ConfigurationConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, ConfigurationConfig, GrandpaConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys,
SudoConfig, SystemConfig, WASM_BINARY, Signature, SudoConfig, SystemConfig, WASM_BINARY,
}; };
use serde_json::json; use serde_json::json;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
...@@ -41,7 +42,7 @@ const MILLAU_MESSAGES_PALLET_OWNER: &str = "Millau.MessagesOwner"; ...@@ -41,7 +42,7 @@ const MILLAU_MESSAGES_PALLET_OWNER: &str = "Millau.MessagesOwner";
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = pub type ChainSpec =
sc_service::GenericChainSpec<GenesisConfig, polkadot_service::chain_spec::Extensions>; sc_service::GenericChainSpec<RuntimeGenesisConfig, polkadot_service::chain_spec::Extensions>;
/// The chain specification option. This is expected to come in from the CLI and /// The chain specification option. This is expected to come in from the CLI and
/// is little more than one of a number of alternatives which can easily be converted /// is little more than one of a number of alternatives which can easily be converted
...@@ -200,8 +201,8 @@ fn testnet_genesis( ...@@ -200,8 +201,8 @@ fn testnet_genesis(
root_key: AccountId, root_key: AccountId,
endowed_accounts: Vec<AccountId>, endowed_accounts: Vec<AccountId>,
_enable_println: bool, _enable_println: bool,
) -> GenesisConfig { ) -> RuntimeGenesisConfig {
GenesisConfig { RuntimeGenesisConfig {
system: SystemConfig { system: SystemConfig {
code: WASM_BINARY.expect("Rialto development WASM not available").to_vec(), code: WASM_BINARY.expect("Rialto development WASM not available").to_vec(),
}, },
...@@ -243,8 +244,8 @@ fn testnet_genesis( ...@@ -243,8 +244,8 @@ fn testnet_genesis(
validation_upgrade_cooldown: 2u32, validation_upgrade_cooldown: 2u32,
validation_upgrade_delay: 2, validation_upgrade_delay: 2,
code_retention_period: 1200, code_retention_period: 1200,
max_code_size: polkadot_primitives::v4::MAX_CODE_SIZE, max_code_size: polkadot_primitives::v5::MAX_CODE_SIZE,
max_pov_size: polkadot_primitives::v4::MAX_POV_SIZE, max_pov_size: polkadot_primitives::v5::MAX_POV_SIZE,
max_head_data_size: 32 * 1024, max_head_data_size: 32 * 1024,
group_rotation_frequency: 20, group_rotation_frequency: 20,
chain_availability_period: 4, chain_availability_period: 4,
...@@ -277,7 +278,7 @@ fn testnet_genesis( ...@@ -277,7 +278,7 @@ fn testnet_genesis(
paras: Default::default(), paras: Default::default(),
bridge_millau_messages: BridgeMillauMessagesConfig { bridge_millau_messages: BridgeMillauMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(MILLAU_MESSAGES_PALLET_OWNER)), owner: Some(get_account_id_from_seed::<sr25519::Public>(MILLAU_MESSAGES_PALLET_OWNER)),
opened_lanes: vec![bp_messages::LaneId::default()], opened_lanes: vec![rialto_runtime::millau_messages::ToMillauXcmBlobHauler::xcm_lane()],
..Default::default() ..Default::default()
}, },
xcm_pallet: Default::default(), xcm_pallet: Default::default(),
......
...@@ -71,6 +71,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "maste ...@@ -71,6 +71,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "maste
[dev-dependencies] [dev-dependencies]
bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] } bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] }
env_logger = "0.10" env_logger = "0.10"
hex-literal = "0.4"
static_assertions = "1.1" static_assertions = "1.1"
[build-dependencies] [build-dependencies]
......
...@@ -752,55 +752,55 @@ impl_runtime_apis! { ...@@ -752,55 +752,55 @@ impl_runtime_apis! {
} }
impl polkadot_primitives::runtime_api::ParachainHost<Block, Hash, BlockNumber> for Runtime { impl polkadot_primitives::runtime_api::ParachainHost<Block, Hash, BlockNumber> for Runtime {
fn validators() -> Vec<polkadot_primitives::v4::ValidatorId> { fn validators() -> Vec<polkadot_primitives::v5::ValidatorId> {
polkadot_runtime_parachains::runtime_api_impl::v4::validators::<Runtime>() polkadot_runtime_parachains::runtime_api_impl::v5::validators::<Runtime>()
} }
fn validator_groups() -> (Vec<Vec<polkadot_primitives::v4::ValidatorIndex>>, polkadot_primitives::v4::GroupRotationInfo<BlockNumber>) { fn validator_groups() -> (Vec<Vec<polkadot_primitives::v5::ValidatorIndex>>, polkadot_primitives::v5::GroupRotationInfo<BlockNumber>) {
polkadot_runtime_parachains::runtime_api_impl::v4::validator_groups::<Runtime>() polkadot_runtime_parachains::runtime_api_impl::v5::validator_groups::<Runtime>()
} }
fn availability_cores() -> Vec<polkadot_primitives::v4::CoreState<Hash, BlockNumber>> { fn availability_cores() -> Vec<polkadot_primitives::v5::CoreState<Hash, BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v4::availability_cores::<Runtime>() polkadot_runtime_parachains::runtime_api_impl::v5::availability_cores::<Runtime>()
} }
fn persisted_validation_data(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption) fn persisted_validation_data(para_id: polkadot_primitives::v5::Id, assumption: polkadot_primitives::v5::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v4::PersistedValidationData<Hash, BlockNumber>> { -> Option<polkadot_primitives::v5::PersistedValidationData<Hash, BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v4::persisted_validation_data::<Runtime>(para_id, assumption) polkadot_runtime_parachains::runtime_api_impl::v5::persisted_validation_data::<Runtime>(para_id, assumption)
} }
fn assumed_validation_data( fn assumed_validation_data(
para_id: polkadot_primitives::v4::Id, para_id: polkadot_primitives::v5::Id,
expected_persisted_validation_data_hash: Hash, expected_persisted_validation_data_hash: Hash,
) -> Option<(polkadot_primitives::v4::PersistedValidationData<Hash, BlockNumber>, polkadot_primitives::v4::ValidationCodeHash)> { ) -> Option<(polkadot_primitives::v5::PersistedValidationData<Hash, BlockNumber>, polkadot_primitives::v5::ValidationCodeHash)> {
polkadot_runtime_parachains::runtime_api_impl::v4::assumed_validation_data::<Runtime>( polkadot_runtime_parachains::runtime_api_impl::v5::assumed_validation_data::<Runtime>(
para_id, para_id,
expected_persisted_validation_data_hash, expected_persisted_validation_data_hash,
) )
} }
fn check_validation_outputs( fn check_validation_outputs(
para_id: polkadot_primitives::v4::Id, para_id: polkadot_primitives::v5::Id,
outputs: polkadot_primitives::v4::CandidateCommitments, outputs: polkadot_primitives::v5::CandidateCommitments,
) -> bool { ) -> bool {
polkadot_runtime_parachains::runtime_api_impl::v4::check_validation_outputs::<Runtime>(para_id, outputs) polkadot_runtime_parachains::runtime_api_impl::v5::check_validation_outputs::<Runtime>(para_id, outputs)
} }
fn session_index_for_child() -> polkadot_primitives::v4::SessionIndex { fn session_index_for_child() -> polkadot_primitives::v5::SessionIndex {
polkadot_runtime_parachains::runtime_api_impl::v4::session_index_for_child::<Runtime>() polkadot_runtime_parachains::runtime_api_impl::v5::session_index_for_child::<Runtime>()
} }
fn validation_code(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption) fn validation_code(para_id: polkadot_primitives::v5::Id, assumption: polkadot_primitives::v5::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v4::ValidationCode> { -> Option<polkadot_primitives::v5::ValidationCode> {
polkadot_runtime_parachains::runtime_api_impl::v4::validation_code::<Runtime>(para_id, assumption) polkadot_runtime_parachains::runtime_api_impl::v5::validation_code::<Runtime>(para_id, assumption)
} }
fn candidate_pending_availability(para_id: polkadot_primitives::v4::Id) -> Option<polkadot_primitives::v4::CommittedCandidateReceipt<Hash>> { fn candidate_pending_availability(para_id: polkadot_primitives::v5::Id) -> Option<polkadot_primitives::v5::CommittedCandidateReceipt<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v4::candidate_pending_availability::<Runtime>(para_id) polkadot_runtime_parachains::runtime_api_impl::v5::candidate_pending_availability::<Runtime>(para_id)
} }
fn candidate_events() -> Vec<polkadot_primitives::v4::CandidateEvent<Hash>> { fn candidate_events() -> Vec<polkadot_primitives::v5::CandidateEvent<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v4::candidate_events::<Runtime, _>(|ev| { polkadot_runtime_parachains::runtime_api_impl::v5::candidate_events::<Runtime, _>(|ev| {
match ev { match ev {
RuntimeEvent::Inclusion(ev) => { RuntimeEvent::Inclusion(ev) => {
Some(ev) Some(ev)
...@@ -810,54 +810,75 @@ impl_runtime_apis! { ...@@ -810,54 +810,75 @@ impl_runtime_apis! {
}) })
} }
fn session_info(index: polkadot_primitives::v4::SessionIndex) -> Option<polkadot_primitives::v4::SessionInfo> { fn session_info(index: polkadot_primitives::v5::SessionIndex) -> Option<polkadot_primitives::v5::SessionInfo> {
polkadot_runtime_parachains::runtime_api_impl::v4::session_info::<Runtime>(index) polkadot_runtime_parachains::runtime_api_impl::v5::session_info::<Runtime>(index)
} }
fn dmq_contents(recipient: polkadot_primitives::v4::Id) -> Vec<polkadot_primitives::v4::InboundDownwardMessage<BlockNumber>> { fn dmq_contents(recipient: polkadot_primitives::v5::Id) -> Vec<polkadot_primitives::v5::InboundDownwardMessage<BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v4::dmq_contents::<Runtime>(recipient) polkadot_runtime_parachains::runtime_api_impl::v5::dmq_contents::<Runtime>(recipient)
} }
fn inbound_hrmp_channels_contents( fn inbound_hrmp_channels_contents(
recipient: polkadot_primitives::v4::Id recipient: polkadot_primitives::v5::Id
) -> BTreeMap<polkadot_primitives::v4::Id, Vec<polkadot_primitives::v4::InboundHrmpMessage<BlockNumber>>> { ) -> BTreeMap<polkadot_primitives::v5::Id, Vec<polkadot_primitives::v5::InboundHrmpMessage<BlockNumber>>> {
polkadot_runtime_parachains::runtime_api_impl::v4::inbound_hrmp_channels_contents::<Runtime>(recipient) polkadot_runtime_parachains::runtime_api_impl::v5::inbound_hrmp_channels_contents::<Runtime>(recipient)
} }
fn validation_code_by_hash(hash: polkadot_primitives::v4::ValidationCodeHash) -> Option<polkadot_primitives::v4::ValidationCode> { fn validation_code_by_hash(hash: polkadot_primitives::v5::ValidationCodeHash) -> Option<polkadot_primitives::v5::ValidationCode> {
polkadot_runtime_parachains::runtime_api_impl::v4::validation_code_by_hash::<Runtime>(hash) polkadot_runtime_parachains::runtime_api_impl::v5::validation_code_by_hash::<Runtime>(hash)
} }
fn on_chain_votes() -> Option<polkadot_primitives::v4::ScrapedOnChainVotes<Hash>> { fn on_chain_votes() -> Option<polkadot_primitives::v5::ScrapedOnChainVotes<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v4::on_chain_votes::<Runtime>() polkadot_runtime_parachains::runtime_api_impl::v5::on_chain_votes::<Runtime>()
} }
fn submit_pvf_check_statement(stmt: polkadot_primitives::v4::PvfCheckStatement, signature: polkadot_primitives::v4::ValidatorSignature) { fn submit_pvf_check_statement(stmt: polkadot_primitives::v5::PvfCheckStatement, signature: polkadot_primitives::v5::ValidatorSignature) {
polkadot_runtime_parachains::runtime_api_impl::v4::submit_pvf_check_statement::<Runtime>(stmt, signature) polkadot_runtime_parachains::runtime_api_impl::v5::submit_pvf_check_statement::<Runtime>(stmt, signature)
} }
fn pvfs_require_precheck() -> Vec<polkadot_primitives::v4::ValidationCodeHash> { fn pvfs_require_precheck() -> Vec<polkadot_primitives::v5::ValidationCodeHash> {
polkadot_runtime_parachains::runtime_api_impl::v4::pvfs_require_precheck::<Runtime>() polkadot_runtime_parachains::runtime_api_impl::v5::pvfs_require_precheck::<Runtime>()
} }
fn validation_code_hash(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption) fn validation_code_hash(para_id: polkadot_primitives::v5::Id, assumption: polkadot_primitives::v5::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v4::ValidationCodeHash> -> Option<polkadot_primitives::v5::ValidationCodeHash>
{ {
polkadot_runtime_parachains::runtime_api_impl::v4::validation_code_hash::<Runtime>(para_id, assumption) polkadot_runtime_parachains::runtime_api_impl::v5::validation_code_hash::<Runtime>(para_id, assumption)
} }
fn disputes() -> Vec<(polkadot_primitives::v4::SessionIndex, polkadot_primitives::v4::CandidateHash, polkadot_primitives::v4::DisputeState<BlockNumber>)> { fn disputes() -> Vec<(polkadot_primitives::v5::SessionIndex, polkadot_primitives::v5::CandidateHash, polkadot_primitives::v5::DisputeState<BlockNumber>)> {
polkadot_runtime_parachains::runtime_api_impl::v4::get_session_disputes::<Runtime>() polkadot_runtime_parachains::runtime_api_impl::v5::get_session_disputes::<Runtime>()
} }
fn session_executor_params(session_index: polkadot_primitives::v4::SessionIndex) -> Option<polkadot_primitives::v4::ExecutorParams> { fn session_executor_params(session_index: polkadot_primitives::v5::SessionIndex) -> Option<polkadot_primitives::v5::ExecutorParams> {
polkadot_runtime_parachains::runtime_api_impl::v4::session_executor_params::<Runtime>(session_index) polkadot_runtime_parachains::runtime_api_impl::v5::session_executor_params::<Runtime>(session_index)
}
fn unapplied_slashes(
) -> Vec<(polkadot_primitives::v5::SessionIndex, polkadot_primitives::v5::CandidateHash, polkadot_primitives::v5::slashing::PendingSlashes)> {
polkadot_runtime_parachains::runtime_api_impl::v5::unapplied_slashes::<Runtime>()
}
fn key_ownership_proof(
_validator_id: polkadot_primitives::v5::ValidatorId,
) -> Option<polkadot_primitives::v5::slashing::OpaqueKeyOwnershipProof> {
unimplemented!("Not used at Rialto")
}
fn submit_report_dispute_lost(
dispute_proof: polkadot_primitives::v5::slashing::DisputeProof,
key_ownership_proof: polkadot_primitives::v5::slashing::OpaqueKeyOwnershipProof,
) -> Option<()> {
polkadot_runtime_parachains::runtime_api_impl::v5::submit_unsigned_slashing_report::<Runtime>(
dispute_proof,
key_ownership_proof,
)
} }
} }
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime { impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
fn authorities() -> Vec<AuthorityDiscoveryId> { fn authorities() -> Vec<AuthorityDiscoveryId> {
polkadot_runtime_parachains::runtime_api_impl::v4::relevant_authority_ids::<Runtime>() polkadot_runtime_parachains::runtime_api_impl::v5::relevant_authority_ids::<Runtime>()
} }
} }
......
...@@ -19,12 +19,13 @@ ...@@ -19,12 +19,13 @@
use crate::{Runtime, WithMillauMessagesInstance}; use crate::{Runtime, WithMillauMessagesInstance};
use bp_messages::LaneId; use bp_messages::LaneId;
use bridge_runtime_common::messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}; use bridge_runtime_common::messages_xcm_extension::{
LaneIdFromChainId, XcmBlobHauler, XcmBlobHaulerAdapter,
};
use frame_support::{parameter_types, weights::Weight}; use frame_support::{parameter_types, weights::Weight};
use sp_core::Get;
use xcm_builder::HaulBlobExporter; use xcm_builder::HaulBlobExporter;
/// Lane that is used for XCM messages exchange.
pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]);
/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge /// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual /// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual
/// tests, confirming that we don't break encoding somewhere between. /// tests, confirming that we don't break encoding somewhere between.
...@@ -59,12 +60,13 @@ impl XcmBlobHauler for ToMillauXcmBlobHauler { ...@@ -59,12 +60,13 @@ impl XcmBlobHauler for ToMillauXcmBlobHauler {
type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithMillauMessagesInstance>; type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithMillauMessagesInstance>;
fn xcm_lane() -> LaneId { fn xcm_lane() -> LaneId {
XCM_LANE LaneIdFromChainId::<Runtime, WithMillauMessagesInstance>::get()
} }
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance}; use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance};
use bridge_runtime_common::{ use bridge_runtime_common::{
assert_complete_bridge_types, assert_complete_bridge_types,
...@@ -105,4 +107,15 @@ mod tests { ...@@ -105,4 +107,15 @@ mod tests {
}, },
}); });
} }
#[test]
fn rialto_millau_bridge_identifier_did_not_changed() {
// there's nothing criminal if it is changed, but then thou need to fix it across
// all deployments scripts, alerts and so on
assert_eq!(
*ToMillauXcmBlobHauler::xcm_lane().as_ref(),
hex_literal::hex!("52011894c856c0c613a2ad2395dfbb509090f6b7a6aef9359adb75aa26a586c7")
.into(),
);
}
} }
...@@ -27,7 +27,7 @@ use frame_support::{ ...@@ -27,7 +27,7 @@ use frame_support::{
weights::{Weight, WeightMeter}, weights::{Weight, WeightMeter},
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use polkadot_primitives::v4::{ValidatorId, ValidatorIndex}; use polkadot_primitives::v5::{ValidatorId, ValidatorIndex};
use polkadot_runtime_common::{paras_registrar, paras_sudo_wrapper, slots}; use polkadot_runtime_common::{paras_registrar, paras_sudo_wrapper, slots};
use polkadot_runtime_parachains::{ use polkadot_runtime_parachains::{
configuration as parachains_configuration, disputes as parachains_disputes, configuration as parachains_configuration, disputes as parachains_disputes,
......
...@@ -137,6 +137,7 @@ impl xcm_executor::Config for XcmConfig { ...@@ -137,6 +137,7 @@ impl xcm_executor::Config for XcmConfig {
type UniversalAliases = Nothing; type UniversalAliases = Nothing;
type CallDispatcher = RuntimeCall; type CallDispatcher = RuntimeCall;
type SafeCallFilter = Everything; type SafeCallFilter = Everything;
type Aliasers = Nothing;
} }
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
...@@ -191,15 +192,14 @@ impl pallet_xcm::Config for Runtime { ...@@ -191,15 +192,14 @@ impl pallet_xcm::Config for Runtime {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{ use crate::{millau_messages::FromMillauMessageDispatch, WithMillauMessagesInstance};
millau_messages::{FromMillauMessageDispatch, XCM_LANE},
WithMillauMessagesInstance,
};
use bp_messages::{ use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
LaneId, MessageKey, OutboundLaneData, MessageKey, OutboundLaneData,
};
use bridge_runtime_common::messages_xcm_extension::{
XcmBlobHauler, XcmBlobMessageDispatchResult,
}; };
use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult;
use codec::Encode; use codec::Encode;
use pallet_bridge_messages::OutboundLanes; use pallet_bridge_messages::OutboundLanes;
use xcm_executor::XcmExecutor; use xcm_executor::XcmExecutor;
...@@ -223,12 +223,13 @@ mod tests { ...@@ -223,12 +223,13 @@ mod tests {
fn xcm_messages_to_millau_are_sent_using_bridge_exporter() { fn xcm_messages_to_millau_are_sent_using_bridge_exporter() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// ensure that the there are no messages queued // ensure that the there are no messages queued
let lane_id = crate::millau_messages::ToMillauXcmBlobHauler::xcm_lane();
OutboundLanes::<Runtime, WithMillauMessagesInstance>::insert( OutboundLanes::<Runtime, WithMillauMessagesInstance>::insert(
XCM_LANE, lane_id,
OutboundLaneData::opened(), OutboundLaneData::opened(),
); );
assert_eq!( assert_eq!(
OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(XCM_LANE) OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(lane_id)
.unwrap() .unwrap()
.latest_generated_nonce, .latest_generated_nonce,
0, 0,
...@@ -247,7 +248,7 @@ mod tests { ...@@ -247,7 +248,7 @@ mod tests {
// ensure that the message has been queued // ensure that the message has been queued
assert_eq!( assert_eq!(
OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(XCM_LANE) OutboundLanes::<Runtime, WithMillauMessagesInstance>::get(lane_id)
.unwrap() .unwrap()
.latest_generated_nonce, .latest_generated_nonce,
1, 1,
...@@ -262,8 +263,9 @@ mod tests { ...@@ -262,8 +263,9 @@ mod tests {
// this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor
// or public fields, so just tuple // or public fields, so just tuple
let bridge_message = (location, xcm).encode(); let bridge_message = (location, xcm).encode();
let lane_id = crate::millau_messages::ToMillauXcmBlobHauler::xcm_lane();
DispatchMessage { DispatchMessage {
key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, key: MessageKey { lane_id, nonce: 1 },
data: DispatchMessageData { payload: Ok(bridge_message) }, data: DispatchMessageData { payload: Ok(bridge_message) },
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment