-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ComposableFi/david-ingest-mmr-proof
Ingest Mmr With Proof
- Loading branch information
Showing
10 changed files
with
20,167 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
name: CI Check | ||
name: Cargo Check | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
checker: | ||
strategy: | ||
matrix: | ||
go-version: [1.17] | ||
os: [ubuntu-latest] | ||
concurrency: | ||
group: lint-${{ github.ref }} | ||
cancel-in-progress: true | ||
container: | ||
image: paritytech/ci-linux:production | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: ToolChain Selector | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
|
||
- name: Install srtool | ||
|
||
- name: Rustup show | ||
run: | | ||
cargo install --git https://github.com/chevdor/srtool-cli | ||
cargo install --locked --git https://github.com/chevdor/subwasm --tag v0.16.1 | ||
rustup show | ||
- name: Checker | ||
run: | | ||
cargo check --no-default-features --target=wasm32-unknown-unknown | ||
cargo check --no-default-features |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name: Lint | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
linters: | ||
name: Linters | ||
|
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,22 @@ | ||
use sp_std::prelude::*; | ||
#[derive(sp_std::fmt::Debug, PartialEq, Eq)] | ||
pub enum BeefyClientError { | ||
/// Failed to read a value from storage | ||
StorageReadError, | ||
/// Failed to write a value to storage | ||
StorageWriteError, | ||
/// Error decoding some value | ||
DecodingError, | ||
/// Invalid Mmr Update | ||
InvalidMmrUpdate, | ||
/// Incomplete Signature threshold | ||
IncompleteSignatureThreshold, | ||
/// Error recovering public key from signature | ||
InvalidSignature, | ||
/// Some invalid merkle root hash | ||
InvalidRootHash, | ||
/// Some invalid mmr proof | ||
InvalidMmrProof, | ||
/// Invalid authority proof | ||
InvalidAuthorityProof, | ||
} |
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,40 @@ | ||
pub use beefy_primitives::mmr::{BeefyNextAuthoritySet, MmrLeaf}; | ||
use codec::{Decode, Encode}; | ||
use sp_core::H256; | ||
use sp_core_hashing::keccak_256; | ||
use sp_std::prelude::*; | ||
|
||
pub const HASH_LENGTH: usize = 32; | ||
pub type TSignature = [u8; 65]; | ||
pub type Hash = [u8; 32]; | ||
|
||
#[derive(Clone, sp_std::fmt::Debug, PartialEq, Eq, Encode, Decode)] | ||
pub struct SignatureWithAuthorityIndex { | ||
pub signature: TSignature, | ||
pub index: u32, | ||
} | ||
|
||
#[derive(Clone, sp_std::fmt::Debug, PartialEq, Eq, Encode, Decode)] | ||
pub struct SignedCommitment { | ||
pub commitment: beefy_primitives::Commitment<u32>, | ||
pub signatures: Vec<SignatureWithAuthorityIndex>, | ||
} | ||
|
||
#[derive(sp_std::fmt::Debug, Clone, Encode, Decode)] | ||
pub struct MmrUpdateProof { | ||
pub signed_commitment: SignedCommitment, | ||
pub latest_mmr_leaf: MmrLeaf<u32, H256, H256>, | ||
pub mmr_proof: pallet_mmr_primitives::Proof<H256>, | ||
pub authority_proof: Vec<Hash>, | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct KeccakHasher; | ||
|
||
impl rs_merkle::Hasher for KeccakHasher { | ||
type Hash = [u8; 32]; | ||
|
||
fn hash(data: &[u8]) -> [u8; 32] { | ||
keccak_256(data) | ||
} | ||
} |
Oops, something went wrong.