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

Commit

Permalink
Sync part.1 (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier authored and jiguantong committed Sep 29, 2022
1 parent dd5b1bb commit dc74f6d
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 6 deletions.
3 changes: 0 additions & 3 deletions bin/runtime-common/src/lanes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@ 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 Pangolin and Pangolin Parachain Alpha.
pub const PANGOLIN_PANGOLIN_PARACHAIN_ALPHA_LANE: LaneId = *b"plpa";

/// Identifier of bridge between Crab and Crab Parachain.
pub const CRAB_CRAB_PARACHAIN_LANE: LaneId = *b"pacr";
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>>;
}
}
3 changes: 0 additions & 3 deletions primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ pub const PANGOLIN_CHAIN_ID: ChainId = *b"pagl";
/// Bridge-with-PangolinParachain instance id.
pub const PANGOLIN_PARACHAIN_CHAIN_ID: ChainId = *b"pglp";

/// Bridge-with-PangolinParachainAlpha instance id.
pub const PANGOLIN_PARACHAIN_ALPHA_CHAIN_ID: ChainId = *b"pgpa";

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

Expand Down

0 comments on commit dc74f6d

Please sign in to comment.