Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HeaderChain trait #204

Closed
tomusdrw opened this issue Jul 17, 2020 · 1 comment
Closed

HeaderChain trait #204

tomusdrw opened this issue Jul 17, 2020 · 1 comment
Assignees
Labels
A-feat New feature or request P-Runtime

Comments

@tomusdrw
Copy link
Contributor

tomusdrw commented Jul 17, 2020

Define & implement the HeaderChain interface to cover current and future bridge pallets. Implement HeaderChain for PoA bridge pallet. Proposed interface:

fn import_header_unsigned(Self::Header, Self::Extra);
fn import_headers_signed((Self::Header, Self::Extra)[]);
fn best_block() -> Self::Header;
fn finalized_block() -> Self::Header;
fn earliest_block() -> Self::Header; // earliest useful for proofs
fn by_number(Self::BlockNumber) -> Self::Header;
fn by_hash(Self::BlockHash) -> Self::Header;
fn verify_proof(Self::Proof) -> bool;
// I imagine Proof to be an enum in case multiple things can be proven
// (Transaction, Event, MultipleBlocks, ValidatorSet, etc)

Triggered hooks:

fn on_valid_headers(
	Option<Submitter>, useful: Self::Header[], useless: Self::Header[]
);

fn on_invalid_headers(Option<Submitter>);

Proof for each implementation will most likely be an enum containing different things that can be proven (think Transaction or Event, etc). For that reason it will probably be required to have traits that allow proof creation, like so:

trait TransactionProof<T> { type ProofData; fn new(T::BlockHash, Self::ProofData) -> Self }

trait EventProof<T> { type ProofData; fn new(T::BlockHash, Self::ProofData) -> Self }

So that for instance CurrencyExchange (see #205) can specify someting like this:

/// Blockchain is a trait that is required by CurrencyExchange currently.
impl<T: HeaderChain> Blockchain for T where
 T::Proof: TransactionProof<T>,
{
...
}

```
@tomusdrw
Copy link
Contributor Author

Closed via #287

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-feat New feature or request P-Runtime
Projects
None yet
Development

No branches or pull requests

2 participants