-
Notifications
You must be signed in to change notification settings - Fork 2
Prepare for Crab<>Crab Parachain #76
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[package] | ||
authors = ["Darwinia Network <hello@darwinia.network>"] | ||
description = "Primitives of Crab Parachain runtime." | ||
edition = "2021" | ||
license = "GPL-3.0" | ||
name = "bp-crab-parachain" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
# darwinia-network | ||
bp-darwinia-core = { default-features = false, path = "../darwinia-core" } | ||
# paritytech | ||
bp-messages = { default-features = false, path = "../messages" } | ||
bp-runtime = { default-features = false, path = "../runtime" } | ||
frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate", branch = "darwinia-v0.12.2" } | ||
sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate", branch = "darwinia-v0.12.2" } | ||
sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate", branch = "darwinia-v0.12.2" } | ||
sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate", branch = "darwinia-v0.12.2" } | ||
sp-version = { default-features = false, git = "https://github.com/darwinia-network/substrate", branch = "darwinia-v0.12.2" } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
# darwinia-network | ||
"bp-darwinia-core/std", | ||
# paritytech | ||
"bp-messages/std", | ||
"bp-runtime/std", | ||
"frame-support/std", | ||
"sp-api/std", | ||
"sp-runtime/std", | ||
"sp-std/std", | ||
"sp-version/std", | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// This file is part of Darwinia. | ||
// | ||
// Copyright (C) 2018-2022 Darwinia Network | ||
// SPDX-License-Identifier: GPL-3.0 | ||
// | ||
// Darwinia 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. | ||
// | ||
// Darwinia 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 Darwinia. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
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, | ||
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How this settings be used? What if crab parachain's spec changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bridger has a startegy related to this setting. If the strategy is Auto, bridger will try to use the latest spec version on the Crab, and ignore this setting. If the strategy is Bundle, bridger will use this setting to communicate with Crab. And if the strategy is Custom, bridger can custom spec_version with the local config file. CC @fewensa There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clean and move this to bridger if it is only used by bridger. |
||
apis: sp_version::create_apis_vec![[]], | ||
transaction_version: 1, | ||
}; | ||
|
||
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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[package] | ||
authors = ["Darwinia Network <hello@darwinia.network>"] | ||
edition = "2021" | ||
license = "GPL-3.0" | ||
name = "relay-crab-parachain-client" | ||
version = "0.1.0" | ||
|
||
|
||
[dependencies] | ||
codec = { package = "parity-scale-codec", version = "2.2.0" } | ||
relay-substrate-client = { path = "../client-substrate" } | ||
relay-utils = { path = "../utils" } | ||
scale-info = { version = "1.0", features = ["derive"] } | ||
|
||
bp-header-chain = { path = "../../primitives/header-chain" } | ||
bp-message-dispatch = { path = "../../primitives/message-dispatch" } | ||
bp-messages = { path = "../../primitives/messages" } | ||
bp-runtime = { path = "../../primitives/runtime" } | ||
bridge-runtime-common = { path = "../../bin/runtime-common" } | ||
pallet-bridge-dispatch = { path = "../../modules/dispatch" } | ||
|
||
bp-darwinia-core = { path = "../../primitives/darwinia-core" } | ||
bp-crab = { path = "../../primitives/chain-crab" } | ||
bp-crab-parachain = { path = "../../primitives/chain-crab-parachain" } | ||
|
||
## Substrate Dependencies | ||
frame-support = { git = "https://github.com/darwinia-network/substrate", branch = "darwinia-v0.12.2" } | ||
sp-core = { git = "https://github.com/darwinia-network/substrate", branch = "darwinia-v0.12.2" } | ||
sp-runtime = { git = "https://github.com/darwinia-network/substrate", branch = "darwinia-v0.12.2" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is the same with other bp-xxx :
https://github.com/darwinia-network/darwinia-bridges-substrate/blob/b703ccef6c49bfae461256937d62a0a77d9a04f5/primitives/chain-pangolin/src/lib.rs#L21
https://github.com/darwinia-network/darwinia-bridges-substrate/blob/b703ccef6c49bfae461256937d62a0a77d9a04f5/primitives/chain-pangoro/src/lib.rs#L21