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

Commit

Permalink
Code clean
Browse files Browse the repository at this point in the history
  • Loading branch information
fewensa committed Jun 29, 2022
1 parent eeb4a62 commit 2e806ef
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 845 deletions.
1 change: 0 additions & 1 deletion bin/runtime-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod messages;
pub mod messages_api;
pub mod messages_benchmarking;

#[cfg(feature = "integrity-test")]
Expand Down
51 changes: 0 additions & 51 deletions bin/runtime-common/src/messages_api.rs

This file was deleted.

90 changes: 0 additions & 90 deletions primitives/chain-crab-parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,102 +21,12 @@
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!("Crab Parachain"),
impl_name: sp_runtime::create_runtime_str!("Darwinia Crab Parachain"),
authoring_version: 1,
spec_version: 4,
impl_version: 1,
apis: sp_version::create_apis_vec![[]],
transaction_version: 1,
state_version: 0,
};

pub const EXISTENTIAL_DEPOSIT: Balance = 0;
}
pub use copy_paste_from_darwinia::*;

pub use bp_darwinia_core::*;

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

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

/// Name of the With-CrabParachain messages pallet instance that is deployed at bridged chains.
pub const WITH_CRAB_PARACHAIN_MESSAGES_PALLET_NAME: &str = "BridgeCrabParachainMessages";

/// Name of the `CrabParachainFinalityApi::best_finalized` runtime method.
pub const BEST_FINALIZED_CRAB_PARACHAIN_HEADER_METHOD: &str =
"CrabParachainFinalityApi_best_finalized";

/// Name of the `ToCrabParachainOutboundLaneApi::message_details` runtime method.
pub const TO_CRAB_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
"ToCrabParachainOutboundLaneApi_message_details";
/// Name of the `ToCrabParachainOutboundLaneApi::latest_received_nonce` runtime method.
pub const TO_CRAB_PARACHAIN_LATEST_RECEIVED_NONCE_METHOD: &str =
"ToCrabParachainOutboundLaneApi_latest_received_nonce";
/// Name of the `ToCrabParachainOutboundLaneApi::latest_generated_nonce` runtime method.
pub const TO_CRAB_PARACHAIN_LATEST_GENERATED_NONCE_METHOD: &str =
"ToCrabParachainOutboundLaneApi_latest_generated_nonce";

/// Name of the `FromCrabParachainInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_CRAB_PARACHAIN_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromCrabParachainInboundLaneApi_latest_received_nonce";
/// Name of the `FromCrabParachainInboundLaneApi::latest_onfirmed_nonce` runtime method.
pub const FROM_CRAB_PARACHAIN_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromCrabParachainInboundLaneApi_latest_confirmed_nonce";
/// Name of the `FromCrabParachainInboundLaneApi::unrewarded_relayers_state` runtime method.
pub const FROM_CRAB_PARACHAIN_UNREWARDED_RELAYERS_STATE: &str =
"FromCrabParachainInboundLaneApi_unrewarded_relayers_state";

sp_api::decl_runtime_apis! {
/// API for querying information about the finalized CrabParachain headers.
///
/// This API is implemented by runtimes that are bridging with the CrabParachain chain, not the
/// CrabParachain runtime itself.
pub trait CrabParachainFinalityApi {
/// 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 CrabParachain chain.
///
/// This API is implemented by runtimes that are sending messages to CrabParachain chain, not the
/// CrabParachain runtime itself.
pub trait ToCrabParachainOutboundLaneApi<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>>;
/// Returns nonce of the latest message, received by bridged chain.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Returns nonce of the latest message, generated by given lane.
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
}

/// Inbound message lane API for messages sent by CrabParachain chain.
///
/// This API is implemented by runtimes that are receiving messages from CrabParachain chain, not the
/// CrabParachain runtime itself.
pub trait FromCrabParachainInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane.
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
}
}
92 changes: 0 additions & 92 deletions primitives/chain-crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@
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!("Crab"),
impl_name: sp_runtime::create_runtime_str!("Darwinia Crab"),
authoring_version: 0,
spec_version: 12_0_0,
impl_version: 0,
apis: sp_version::create_apis_vec![[]],
transaction_version: 0,
state_version: 0,
};

pub const EXISTENTIAL_DEPOSIT: Balance = 0;

Expand All @@ -43,84 +30,5 @@ pub use copy_paste_from_darwinia::*;

pub use bp_darwinia_core::*;

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

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

/// Name of the With-Crab GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_CRAB_GRANDPA_PALLET_NAME: &str = "BridgeCrabGrandpa";
/// Name of the With-Crab messages pallet instance that is deployed at bridged chains.
pub const WITH_CRAB_MESSAGES_PALLET_NAME: &str = "BridgeCrabMessages";
/// Name of the With-Crab parachains bridge pallet name in the Crab runtime.
pub const BRIDGE_PARAS_PALLET_NAME: &str = "BridgeCrabParachains";

/// Name of the `CrabFinalityApi::best_finalized` runtime method.
pub const BEST_FINALIZED_CRAB_HEADER_METHOD: &str = "CrabFinalityApi_best_finalized";

/// Name of the `ToCrabOutboundLaneApi::message_details` runtime method.
pub const TO_CRAB_MESSAGE_DETAILS_METHOD: &str = "ToCrabOutboundLaneApi_message_details";
/// Name of the `ToCrabOutboundLaneApi::latest_received_nonce` runtime method.
pub const TO_CRAB_LATEST_RECEIVED_NONCE_METHOD: &str =
"ToCrabOutboundLaneApi_latest_received_nonce";
/// Name of the `ToCrabOutboundLaneApi::latest_generated_nonce` runtime method.
pub const TO_CRAB_LATEST_GENERATED_NONCE_METHOD: &str =
"ToCrabOutboundLaneApi_latest_generated_nonce";

/// Name of the `FromCrabInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_CRAB_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromCrabInboundLaneApi_latest_received_nonce";
/// Name of the `FromCrabInboundLaneApi::latest_cnfirmed_nonce` runtime method.
pub const FROM_CRAB_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromCrabInboundLaneApi_latest_confirmed_nonce";
/// Name of the `FromCrabInboundLaneApi::unrewarded_relayers_state` runtime method.
pub const FROM_CRAB_UNREWARDED_RELAYERS_STATE: &str =
"FromCrabInboundLaneApi_unrewarded_relayers_state";

sp_api::decl_runtime_apis! {
/// API for querying information about the finalized Crab headers.
///
/// This API is implemented by runtimes that are bridging with the Crab chain, not the
/// Crab runtime itself.
pub trait CrabFinalityApi {
/// 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 Crab chain.
///
/// This API is implemented by runtimes that are sending messages to Crab chain, not the
/// Crab runtime itself.
pub trait ToCrabOutboundLaneApi<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>>;
/// Returns nonce of the latest message, received by bridged chain.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Returns nonce of the latest message, generated by given lane.
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
}

/// Inbound message lane API for messages sent by Crab chain.
///
/// This API is implemented by runtimes that are receiving messages from Crab chain, not the
/// Crab runtime itself.
pub trait FromCrabInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane.
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
}
}
93 changes: 0 additions & 93 deletions primitives/chain-darwinia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,6 @@
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!("Darwinia"),
impl_name: sp_runtime::create_runtime_str!("Darwinia"),
authoring_version: 0,
#[allow(clippy::inconsistent_digit_grouping)]
spec_version: 12_0_0,
impl_version: 0,
apis: sp_version::create_apis_vec![[]],
transaction_version: 0,
state_version: 0,
};

pub const EXISTENTIAL_DEPOSIT: Balance = 100 * MICRO;

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

pub use bp_darwinia_core::*;

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

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

/// Name of the With-Darwinia GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_DARWINIA_GRANDPA_PALLET_NAME: &str = "BridgeDarwiniaGrandpa";
/// Name of the With-Darwinia messages pallet instance that is deployed at bridged chains.
pub const WITH_DARWINIA_MESSAGES_PALLET_NAME: &str = "BridgeDarwiniaMessages";
/// Name of the With-Darwinia parachains bridge pallet name in the Darwinia runtime.
pub const BRIDGE_PARAS_PALLET_NAME: &str = "BridgeDarwiniaParachains";

/// Name of the `DarwiniaFinalityApi::best_finalized` runtime method.
pub const BEST_FINALIZED_DARWINIA_HEADER_METHOD: &str = "DarwiniaFinalityApi_best_finalized";

/// Name of the `ToDarwiniaOutboundLaneApi::message_details` runtime method.
pub const TO_DARWINIA_MESSAGE_DETAILS_METHOD: &str = "ToDarwiniaOutboundLaneApi_message_details";
/// Name of the `ToDarwiniaOutboundLaneApi::latest_received_nonce` runtime method.
pub const TO_DARWINIA_LATEST_RECEIVED_NONCE_METHOD: &str =
"ToDarwiniaOutboundLaneApi_latest_received_nonce";
/// Name of the `ToDarwiniaOutboundLaneApi::latest_generated_nonce` runtime method.
pub const TO_DARWINIA_LATEST_GENERATED_NONCE_METHOD: &str =
"ToDarwiniaOutboundLaneApi_latest_generated_nonce";

/// Name of the `FromDarwiniaInboundLaneApi::latest_received_nonce` runtime method.
pub const FROM_DARWINIA_LATEST_RECEIVED_NONCE_METHOD: &str =
"FromDarwiniaInboundLaneApi_latest_received_nonce";
/// Name of the `FromDarwiniaInboundLaneApi::latest_cnfirmed_nonce` runtime method.
pub const FROM_DARWINIA_LATEST_CONFIRMED_NONCE_METHOD: &str =
"FromDarwiniaInboundLaneApi_latest_confirmed_nonce";
/// Name of the `FromDarwiniaInboundLaneApi::unrewarded_relayers_state` runtime method.
pub const FROM_DARWINIA_UNREWARDED_RELAYERS_STATE: &str =
"FromDarwiniaInboundLaneApi_unrewarded_relayers_state";

sp_api::decl_runtime_apis! {
/// API for querying information about the finalized Darwinia headers.
///
/// This API is implemented by runtimes that are bridging with the Darwinia chain, not the
/// Darwinia runtime itself.
pub trait DarwiniaFinalityApi {
/// 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 Darwinia chain.
///
/// This API is implemented by runtimes that are sending messages to Darwinia chain, not the
/// Darwinia runtime itself.
pub trait ToDarwiniaOutboundLaneApi<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>>;
/// Returns nonce of the latest message, received by bridged chain.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Returns nonce of the latest message, generated by given lane.
fn latest_generated_nonce(lane: LaneId) -> MessageNonce;
}

/// Inbound message lane API for messages sent by Darwinia chain.
///
/// This API is implemented by runtimes that are receiving messages from Darwinia chain, not the
/// Darwinia runtime itself.
pub trait FromDarwiniaInboundLaneApi {
/// Returns nonce of the latest message, received by given lane.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Nonce of latest message that has been confirmed to the bridged chain.
fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce;
/// State of the unrewarded relayers set at given lane.
fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState;
}
}
Loading

0 comments on commit 2e806ef

Please sign in to comment.