Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Sync part.1 #184

Merged
merged 5 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions bin/runtime-common/src/lanes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use bp_messages::LaneId;

/// Identifier of bridge between Darwinia and Crab.
pub const DARWINIA_CRAB_LANE: LaneId = [0; 4];

// Identifier of bridge between Pangoro and Pangolin.
pub const PANGORO_PANGOLIN_LANE: LaneId = *b"roli";

/// Identifier of bridge between Pangolin and Pangolin Parachain.
pub const PANGOLIN_PANGOLIN_PARACHAIN_LANE: LaneId = *b"pali";

/// Identifier of bridge between Crab and Crab Parachain.
pub const CRAB_CRAB_PARACHAIN_LANE: LaneId = *b"pacr";
1 change: 1 addition & 0 deletions bin/runtime-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@

#![cfg_attr(not(feature = "std"), no_std)]

pub mod lanes;
pub mod messages;
pub mod messages_benchmarking;
58 changes: 58 additions & 0 deletions primitives/chain-pangolin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
mod copy_paste_from_darwinia {
// --- darwinia-network ---
use bp_darwinia_core::*;
// --- paritytech ---
use sp_version::RuntimeVersion;

pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Pangolin"),
impl_name: sp_runtime::create_runtime_str!("Pangolin"),
authoring_version: 0,
#[allow(clippy::inconsistent_digit_grouping)]
spec_version: 2_9_05_0,
impl_version: 0,
apis: sp_version::create_apis_vec![[]],
transaction_version: 0,
state_version: 0,
};

pub const EXISTENTIAL_DEPOSIT: Balance = 0;

Expand All @@ -30,5 +44,49 @@ pub use copy_paste_from_darwinia::*;

pub use bp_darwinia_core::*;

// --- paritytech ---
use bp_messages::{LaneId, MessageDetails, MessageNonce};
use frame_support::Parameter;
use sp_std::prelude::*;

/// Pangolin Chain.
pub type Pangolin = DarwiniaLike;

/// Name of the With-Pangolin GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_PANGOLIN_GRANDPA_PALLET_NAME: &str = "BridgePangolinGrandpa";
/// Name of the With-Pangolin messages pallet instance that is deployed at bridged chains.
pub const WITH_PANGOLIN_MESSAGES_PALLET_NAME: &str = "BridgePangolinMessages";

/// Name of the `PangolinFinalityApi::best_finalized` runtime method.
pub const BEST_FINALIZED_PANGOLIN_HEADER_METHOD: &str = "PangolinFinalityApi_best_finalized";

/// Name of the `ToPangolinOutboundLaneApi::message_details` runtime method.
pub const TO_PANGOLIN_MESSAGE_DETAILS_METHOD: &str = "ToPangolinOutboundLaneApi_message_details";

sp_api::decl_runtime_apis! {
/// API for querying information about the finalized Pangolin headers.
///
/// This API is implemented by runtimes that are bridging with the Pangolin chain, not the
/// Pangolin runtime itself.
pub trait PangolinFinalityApi {
/// Returns number and hash of the best finalized header known to the bridge module.
fn best_finalized() -> (BlockNumber, Hash);
}

/// Outbound message lane API for messages that are sent to Pangolin chain.
///
/// This API is implemented by runtimes that are sending messages to Pangolin chain, not the
/// Pangolin runtime itself.
pub trait ToPangolinOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
/// messages in given inclusive range.
///
/// If some (or all) messages are missing from the storage, they'll also will
/// be missing from the resulting vector. The vector is ordered by the nonce.
fn message_details(
lane: LaneId,
begin: MessageNonce,
end: MessageNonce,
) -> Vec<MessageDetails<OutboundMessageFee>>;
}
}
58 changes: 58 additions & 0 deletions primitives/chain-pangoro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
mod copy_paste_from_darwinia {
// --- darwinia-network ---
use bp_darwinia_core::*;
// --- paritytech ---
use sp_version::RuntimeVersion;

pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Pangoro"),
impl_name: sp_runtime::create_runtime_str!("Pangoro"),
authoring_version: 0,
#[allow(clippy::inconsistent_digit_grouping)]
spec_version: 2_9_05_0,
impl_version: 0,
apis: sp_version::create_apis_vec![[]],
transaction_version: 0,
state_version: 0,
};

pub const EXISTENTIAL_DEPOSIT: Balance = 0;

Expand All @@ -30,5 +44,49 @@ pub use copy_paste_from_darwinia::*;

pub use bp_darwinia_core::*;

// --- paritytech ---
use bp_messages::{LaneId, MessageDetails, MessageNonce};
use frame_support::Parameter;
use sp_std::prelude::*;

/// Pangoro Chain.
pub type Pangoro = DarwiniaLike;

/// Name of the With-Pangoro GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_PANGORO_GRANDPA_PALLET_NAME: &str = "BridgePangoroGrandpa";
/// Name of the With-Pangoro messages pallet instance that is deployed at bridged chains.
pub const WITH_PANGORO_MESSAGES_PALLET_NAME: &str = "BridgePangoroMessages";

/// Name of the `PangoroFinalityApi::best_finalized` runtime method.
pub const BEST_FINALIZED_PANGORO_HEADER_METHOD: &str = "PangoroFinalityApi_best_finalized";

/// Name of the `ToPangoroOutboundLaneApi::message_details` runtime method.
pub const TO_PANGORO_MESSAGE_DETAILS_METHOD: &str = "ToPangoroOutboundLaneApi_message_details";

sp_api::decl_runtime_apis! {
/// API for querying information about the finalized Pangoro headers.
///
/// This API is implemented by runtimes that are bridging with the Pangoro chain, not the
/// Pangoro runtime itself.
pub trait PangoroFinalityApi {
/// Returns number and hash of the best finalized header known to the bridge module.
fn best_finalized() -> (BlockNumber, Hash);
}

/// Outbound message lane API for messages that are sent to Pangoro chain.
///
/// This API is implemented by runtimes that are sending messages to Pangoro chain, not the
/// Pangoro runtime itself.
pub trait ToPangoroOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
/// messages in given inclusive range.
///
/// If some (or all) messages are missing from the storage, they'll also will
/// be missing from the resulting vector. The vector is ordered by the nonce.
fn message_details(
lane: LaneId,
begin: MessageNonce,
end: MessageNonce,
) -> Vec<MessageDetails<OutboundMessageFee>>;
}
}
18 changes: 18 additions & 0 deletions primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ pub const ROCOCO_CHAIN_ID: ChainId = *b"roco";
/// Bridge-with-Wococo instance id.
pub const WOCOCO_CHAIN_ID: ChainId = *b"woco";

/// Bridge-with-Darwinia instance id.
pub const DARWINIA_CHAIN_ID: ChainId = *b"darw";

/// Bridge-with-Crab instance id.
pub const CRAB_CHAIN_ID: ChainId = *b"crab";

/// Bridge-with-Pangoro instance id.
pub const PANGORO_CHAIN_ID: ChainId = *b"pagr";

/// Bridge-with-Pangolin instance id.
pub const PANGOLIN_CHAIN_ID: ChainId = *b"pagl";

/// Bridge-with-PangolinParachain instance id.
pub const PANGOLIN_PARACHAIN_CHAIN_ID: ChainId = *b"pglp";

/// Bridge-with-CrabParachain instance id.
pub const CRAB_PARACHAIN_CHAIN_ID: ChainId = *b"crap";

/// Call-dispatch module prefix.
pub const CALL_DISPATCH_MODULE_PREFIX: &[u8] = b"pallet-bridge/dispatch";

Expand Down