Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ members = [
"modules/consensus/sync-committee/primitives",
"modules/consensus/beefy/primitives",
"modules/consensus/beefy/prover",
"modules/consensus/beefy/verifier",
"modules/consensus/geth-primitives",
"modules/consensus/bsc/verifier",
"modules/consensus/bsc/prover",
Expand Down Expand Up @@ -113,7 +114,7 @@ members = [


# Airdrop
"modules/pallets/bridge-drop",
"modules/pallets/bridge-drop", "modules/ismp/clients/beefy",
]

# Config for 'cargo dist'
Expand Down Expand Up @@ -217,6 +218,7 @@ ismp = { version = "2506.1.0", path = "./modules/ismp/core", default-features =
serde-hex-utils = { version = "0.1.0", path = "modules/utils/serde", default-features = false }
crypto-utils = { version = "0.1.0", path = "modules/utils/crypto", default-features = false }
grandpa-verifier-primitives = { version = "2506.1.0", path = "./modules/consensus/grandpa/primitives", default-features = false }
beefy-verifier = { version = "0.1.0", path = "./modules/consensus/beefy/verifier", default-features = false }
grandpa-verifier = { version = "2506.1.0", path = "./modules/consensus/grandpa/verifier", default-features = false }
ismp-grandpa = { version = "2506.1.0", path = "./modules/ismp/clients/grandpa", default-features = false }
ismp-parachain = { version = "2506.1.0", path = "./modules/ismp/clients/parachain/client", default-features = false }
Expand Down Expand Up @@ -369,3 +371,7 @@ features = ["derive"]
[workspace.dependencies.reconnecting-jsonrpsee-ws-client]
version = "0.5.0"
default-features = false

[workspace.dependencies.rs_merkle]
version = "1.2.0"
default-features = false
46 changes: 41 additions & 5 deletions modules/consensus/beefy/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::all)]
#![deny(missing_docs)]
//#![deny(missing_docs)]

use codec::{Decode, Encode};
use polkadot_sdk::*;
Expand Down Expand Up @@ -89,25 +89,25 @@ pub struct PartialMmrLeaf {
pub beefy_next_authority_set: BeefyAuthoritySet<H256>,
}

#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq)]
#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq, Encode, Decode)]
/// Parachain header and metadata needed for merkle inclusion proof
pub struct ParachainHeader {
/// scale encoded parachain header
pub header: Vec<u8>,
/// leaf index for parachain heads proof
pub index: usize,
pub index: u32,
/// ParaId for parachain
pub para_id: u32,
}

#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq)]
#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq, Encode, Decode)]
/// Parachain proofs definition
pub struct ParachainProof {
/// List of parachains we have a proof for
pub parachains: Vec<ParachainHeader>,

/// Proof for parachain header inclusion in the parachain headers root
pub proof: Vec<Vec<(usize, [u8; 32])>>,
pub proof: Vec<Vec<(u32, [u8; 32])>>,
}

#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq)]
Expand All @@ -119,6 +119,42 @@ pub struct ConsensusMessage {
pub mmr: MmrProof,
}

#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq, Encode, Decode)]
pub struct Node {
pub index: u32,
pub hash: H256
}

#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq, Encode, Decode)]
pub struct BeefyMmrLeaf {
pub version: MmrLeafVersion,
pub parent_block_and_hash: (u32, H256),
pub beefy_next_authority_set: BeefyAuthoritySet<H256>,
pub k_index: u32,
pub leaf_index: u32,
pub extra: H256
}

#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq, Encode, Decode)]
pub struct RelaychainProof {
/// Signed commitment
pub signed_commitment: SignedCommitment,
/// Latest leaf added to mmr
pub latest_mmr_leaf: BeefyMmrLeaf,
/// Proof for the latest mmr leaf
pub mmr_proof: Vec<H256>,
/// Proof for authorities in current/next session
pub proof: Vec<Vec<Node>>
}

#[derive(sp_std::fmt::Debug, Clone, PartialEq, Eq, Encode, Decode)]
pub struct BeefyConsensusProof {
// The proof items for the relay chain consensus
pub relay: RelaychainProof,
// The proof items for parachain headers
pub parachain: ParachainProof
}

#[cfg(feature = "std")]
#[derive(Clone, serde::Serialize, serde::Deserialize)]
/// finality proof
Expand Down
44 changes: 44 additions & 0 deletions modules/consensus/beefy/verifier/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "beefy-verifier"
version = "0.1.0"
edition = "2024"
authors = ["Polytope Labs <hello@polytope.technology>"]
description = "Verifier for the BEEFY consensus client"
publish = false

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
log = { workspace = true }
anyhow = { workspace = true, default-features = false }
primitive-types = { workspace = true, features = ["codec"] }
codec = { workspace = true, features = ["derive"], default-features = true }
beefy-verifier-primitives = { workspace = true }
ismp = { workspace = true, default-features = false }
merkle-mountain-range = {workspace = true, default-features = false}
rs_merkle = {workspace = true}

[dependencies.polkadot-sdk]
workspace = true
features = [
"sp-core",
"sp-runtime"
]



[features]
default = ["std"]
std = [
"log/std",
"anyhow/std",
"codec/std",
"ismp/std",
"primitive-types/std",
"beefy-verifier-primitives/std",
"polkadot-sdk/std",
"merkle-mountain-range/std",
"rs_merkle/std"

]
Loading