Skip to content

Commit

Permalink
Generating stage2 proof (#131)
Browse files Browse the repository at this point in the history
* comment for generating stage2

* Adding ability to grab ParaMerkleProof.. wasm trap error..

* fixing bug with paraId

* fixing proof generation

* small refactorings
  • Loading branch information
coax1d authored Mar 5, 2024
1 parent bf8863a commit eeaded5
Show file tree
Hide file tree
Showing 8 changed files with 1,269 additions and 1,940 deletions.
2,886 changes: 1,048 additions & 1,838 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ panic = "unwind"
members = [
"node",
"pallets/*",
"runtime",
"runtime", "subxt_test",
"xcmp_relayer",
]
resolver = "2"
Expand Down Expand Up @@ -132,6 +132,7 @@ polkadot-cli = { git = "https://github.com/coax1d/polkadot-sdk", branch = "xcmp_
polkadot-primitives = { git = "https://github.com/coax1d/polkadot-sdk", branch = "xcmp_customized_sdk", default-features = false }
pallet-xcm = { git = "https://github.com/coax1d/polkadot-sdk", default-features = false, branch = "xcmp_customized_sdk" }
polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/coax1d/polkadot-sdk", default-features = false, branch = "xcmp_customized_sdk" }
polkadot-runtime-parachains = { git = "https://github.com/coax1d/polkadot-sdk", default-features = false, branch = "xcmp_customized_sdk" }
polkadot-runtime-common = { git = "https://github.com/coax1d/polkadot-sdk", default-features = false, branch = "xcmp_customized_sdk" }
xcm = { package = "staging-xcm", git = "https://github.com/coax1d/polkadot-sdk", default-features = false, branch = "xcmp_customized_sdk" }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/coax1d/polkadot-sdk", default-features = false, branch = "xcmp_customized_sdk" }
Expand Down
20 changes: 18 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,27 @@ PARACHAIN_PID=$!
echo "Parachain started with PID: $PARACHAIN_PID"
sleep 5

nohup ./bin/polkadot --alice --tmp --allow-private-ip --discover-local --chain zombienet/rococo-local.json --rpc-port 54886 &

RELAYCHAIN_PID=$!

echo "Relaychain started with PID: $RELAYCHAIN_PID"
sleep 5

echo "Now building Relayer"
cargo build --release -p xcmp_relayer

if [ $? -eq 0 ]; then
echo "Building Parachain Succeeded"
echo "Building Relayer Succeeded"
else
echo "Building Parachain Failed"
echo "Building Relayer Failed"
kill $PARACHAIN_PID
kill $RELAYCHAIN_PID
exit 1
fi

kill $PARACHAIN_PID
kill $RELAYCHAIN_PID

sleep 2

Expand All @@ -96,4 +106,10 @@ else
echo "Parachain node killed successfully"
fi

if kill -0 $RELAYCHAIN_PID 2>/dev/null; then
echo "Relaychain node could not be killed"
else
echo "Relaychain node killed successfully"
fi

echo "Build complete!!"
4 changes: 4 additions & 0 deletions pallets/xcmp_message_stuffer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ sp-runtime = { workspace = true, default-features = false }
sp-mmr-primitives = { workspace = true }
sp-api = { workspace = true }

# Polkadot
polkadot-runtime-parachains = { workspace = true }

# Cumulus
cumulus-primitives-core = { workspace = true, default-features = false }

Expand All @@ -52,6 +55,7 @@ default = ["std"]
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
std = [
"parity-scale-codec/std",
"polkadot-runtime-parachains/std",
"cumulus-pallet-parachain-system/std",
"cumulus-primitives-core/std",
"frame-benchmarking/std",
Expand Down
10 changes: 5 additions & 5 deletions pallets/xcmp_message_stuffer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use frame_system::pallet_prelude::*;
use cumulus_primitives_core::{ParaId, GetBeefyRoot};
use sp_runtime::traits::{Hash as HashT, Keccak256};
use sp_core::H256;
use polkadot_runtime_parachains::paras::ParaMerkleProof;

use sp_mmr_primitives::{Proof, EncodableOpaqueLeaf, DataOrHash};
use scale_info::prelude::vec::Vec;
Expand All @@ -32,7 +33,6 @@ pub trait XcmpMessageProvider<Hash> {

type XcmpMessages<T, I> = <<T as crate::Config<I>>::XcmpDataProvider as XcmpMessageProvider<<T as frame_system::Config>::Hash>>::XcmpMessages;
type MmrProof = Proof<H256>;
type LeafOf<T, I> = <crate::Pallet<T, I> as LeafDataProvider>::LeafData;
type ChannelId = u64;
type BinaryMerkleProof = ();

Expand All @@ -42,7 +42,7 @@ pub struct XcmpProof {
// TODO: Probably should rename each of these stages to some fancy name
// TODO: Remove tuples
pub stage_1: (MmrProof, Vec<EncodableOpaqueLeaf>),
pub stage_2: BinaryMerkleProof,
pub stage_2: ParaMerkleProof,
pub stage_3: BinaryMerkleProof,
pub stage_4: (MmrProof, Vec<EncodableOpaqueLeaf>),
}
Expand Down Expand Up @@ -124,7 +124,7 @@ pub mod pallet {
// TODO: This will
#[pallet::call_index(0)]
#[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().writes(1))]
pub fn submit_xcmp_proof(origin: OriginFor<T>, mmr_proof: MmrProof, leaves: Vec<EncodableOpaqueLeaf>, channel_id: u64) -> DispatchResult {
pub fn submit_test_proof(origin: OriginFor<T>, mmr_proof: MmrProof, leaves: Vec<EncodableOpaqueLeaf>, channel_id: u64) -> DispatchResult {
ensure_signed(origin)?;

log::info!(
Expand Down Expand Up @@ -183,7 +183,7 @@ pub mod pallet {
/// TODO: Change to support multiple leaves..
#[pallet::call_index(2)]
#[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().writes(1))]
pub fn submit_big_proof(origin: OriginFor<T>, xcmp_proof: XcmpProof, beefy_root_targeted: H256) -> DispatchResult {
pub fn submit_xcmp_proof(origin: OriginFor<T>, xcmp_proof: XcmpProof, beefy_root_targeted: H256) -> DispatchResult {
ensure_signed(origin)?;

log::info!(
Expand Down Expand Up @@ -282,7 +282,7 @@ pub mod pallet {
pub struct OnNewRootSatisfier<T>(PhantomData<T>);

impl<T> pallet_mmr::primitives::OnNewRoot<sp_consensus_beefy::MmrRootHash> for OnNewRootSatisfier<T> {
fn on_new_root(root: &sp_consensus_beefy::MmrRootHash) {
fn on_new_root(_root: &sp_consensus_beefy::MmrRootHash) {

}
}
Expand Down
1 change: 1 addition & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sp-mmr-primitives = { workspace = true }
# Polkadot
pallet-xcm = { workspace = true }
polkadot-parachain = { workspace = true }
polkadot-runtime-parachains = { workspace = true }
polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
Expand Down
2 changes: 2 additions & 0 deletions xcmp_relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description = "Relayer for XCMP"
[dependencies]
runtime = { path = "../runtime", package = "parachain-template-runtime" }

polkadot-runtime-parachains = { workspace = true }
polkadot-parachain = { workspace = true }
serde_json = { workspace = true }
parity-scale-codec = { workspace = true }
jsonrpsee = { workspace = true }
Expand Down
Loading

0 comments on commit eeaded5

Please sign in to comment.