forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parachains finality relay (paritytech#1199)
- Loading branch information
Showing
26 changed files
with
1,814 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[package] | ||
name = "bp-parachains" | ||
description = "Primitives of parachains module." | ||
version = "0.1.0" | ||
authors = ["Parity Technologies <admin@parity.io>"] | ||
edition = "2018" | ||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0" | ||
|
||
[dependencies] | ||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } | ||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } | ||
serde = { version = "1.0", optional = true, features = ["derive"] } | ||
|
||
# Bridge dependencies | ||
|
||
bp-polkadot-core = { path = "../polkadot-core", default-features = false } | ||
bp-runtime = { path = "../runtime", default-features = false } | ||
|
||
# Substrate dependencies | ||
|
||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } | ||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"bp-polkadot-core/std", | ||
"bp-runtime/std", | ||
"codec/std", | ||
"frame-support/std", | ||
"scale-info/std", | ||
"serde", | ||
"sp-core/std", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2019-2021 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity Bridges Common. | ||
|
||
// Parity Bridges Common 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. | ||
|
||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Primitives of parachains module. | ||
|
||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
use bp_polkadot_core::{ | ||
parachains::{ParaHash, ParaId}, | ||
BlockNumber as RelayBlockNumber, | ||
}; | ||
use codec::{Decode, Encode}; | ||
use frame_support::{Blake2_128Concat, RuntimeDebug, Twox64Concat}; | ||
use scale_info::TypeInfo; | ||
use sp_core::storage::StorageKey; | ||
|
||
/// Best known parachain head hash. | ||
#[derive(Clone, Decode, Encode, PartialEq, RuntimeDebug, TypeInfo)] | ||
pub struct BestParaHeadHash { | ||
/// Number of relay block where this head has been read. | ||
/// | ||
/// Parachain head is opaque to relay chain. So we can't simply decode it as a header of | ||
/// parachains and call `block_number()` on it. Instead, we're using the fact that parachain | ||
/// head is always built on top of previous head (because it is blockchain) and relay chain | ||
/// always imports parachain heads in order. What it means for us is that at any given | ||
/// **finalized** relay block `B`, head of parachain will be ancestor (or the same) of all | ||
/// parachain heads available at descendants of `B`. | ||
pub at_relay_block_number: RelayBlockNumber, | ||
/// Hash of parachain head. | ||
pub head_hash: ParaHash, | ||
} | ||
|
||
/// Returns runtime storage key of given parachain head at the source chain. | ||
/// | ||
/// The head is stored by the `paras` pallet in the `Heads` map. | ||
pub fn parachain_head_storage_key_at_source( | ||
paras_pallet_name: &str, | ||
para_id: ParaId, | ||
) -> StorageKey { | ||
bp_runtime::storage_map_final_key::<Twox64Concat>(paras_pallet_name, "Heads", ¶_id.encode()) | ||
} | ||
|
||
/// Returns runtime storage key of best known parachain head at the target chain. | ||
/// | ||
/// The head is stored by the `pallet-bridge-parachains` pallet in the `BestParaHeads` map. | ||
pub fn parachain_head_storage_key_at_target( | ||
bridge_parachains_pallet_name: &str, | ||
para_id: ParaId, | ||
) -> StorageKey { | ||
bp_runtime::storage_map_final_key::<Blake2_128Concat>( | ||
bridge_parachains_pallet_name, | ||
"BestParaHeads", | ||
¶_id.encode(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
bridges/relays/bin-substrate/src/chains/rialto_parachains_to_millau.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2019-2021 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity Bridges Common. | ||
|
||
// Parity Bridges Common 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. | ||
|
||
// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Rialto-to-Millau parachains sync entrypoint. | ||
|
||
use parachains_relay::ParachainsPipeline; | ||
use relay_millau_client::Millau; | ||
use relay_rialto_client::Rialto; | ||
use substrate_relay_helper::parachains_target::DirectSubmitParachainHeadsCallBuilder; | ||
|
||
/// Rialto-to-Millau parachains sync description. | ||
#[derive(Clone, Debug)] | ||
pub struct RialtoToMillauParachains; | ||
|
||
impl ParachainsPipeline for RialtoToMillauParachains { | ||
type SourceChain = Rialto; | ||
type TargetChain = Millau; | ||
} | ||
|
||
/// `submit_parachain_heads` call builder for Rialto-to-Millau parachains sync pipeline. | ||
pub type RialtoToMillauParachainsSubmitParachainHeadsCallBuilder = | ||
DirectSubmitParachainHeadsCallBuilder< | ||
RialtoToMillauParachains, | ||
millau_runtime::Runtime, | ||
millau_runtime::WitRialtoParachainsInstance, | ||
>; |
Oops, something went wrong.