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.
Introduce Minimal Header Chain: Proving Interface (paritytech#287)
* Add header-chain primitive crate * Make MinimalHeaderChain functionaly the same as PeerBlockchain * Use a better doc comment for MinimalHeaderChain * Fix benchmark compilation * Rust Fmt * Remove Substrate based dependencies * Rename MinimalHeaderChain to BaseHeaderChain
- Loading branch information
Showing
8 changed files
with
82 additions
and
26 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,18 @@ | ||
[package] | ||
name = "bp-header-chain" | ||
description = "A common interface for describing what a bridge pallet should be able to do." | ||
version = "0.1.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
edition = "2018" | ||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0" | ||
|
||
[dependencies.parity-scale-codec] | ||
version = "1.3.1" | ||
default-features = false | ||
features = ["derive"] | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"parity-scale-codec/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,44 @@ | ||
// Copyright 2019-2020 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/>. | ||
|
||
//! Defines traits which represent a common interface for Substrate pallets which want to | ||
//! incorporate bridge functionality. | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
use core::clone::Clone; | ||
use core::cmp::Eq; | ||
use core::fmt::Debug; | ||
use parity_scale_codec::{Codec, EncodeLike}; | ||
|
||
/// A type that can be used as a parameter in a dispatchable function. | ||
/// | ||
/// When using `decl_module` all arguments for call functions must implement this trait. | ||
pub trait Parameter: Codec + EncodeLike + Clone + Eq + Debug {} | ||
impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + Debug {} | ||
|
||
/// A base trait for pallets which want to keep track of a full set of headers from a bridged chain. | ||
pub trait BaseHeaderChain { | ||
/// Transaction type. | ||
type Transaction: Parameter; | ||
/// Transaction inclusion proof type. | ||
type TransactionInclusionProof: Parameter; | ||
|
||
/// Verify that transaction is a part of given block. | ||
/// | ||
/// Returns Some(transaction) if proof is valid and None otherwise. | ||
fn verify_transaction_inclusion_proof(proof: &Self::TransactionInclusionProof) -> Option<Self::Transaction>; | ||
} |