diff --git a/Cargo.lock b/Cargo.lock index 02763f3d9..9ebd7fb8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4947,7 +4947,7 @@ dependencies = [ [[package]] name = "hyperbridge" -version = "0.1.5" +version = "0.1.6" dependencies = [ "clap", "cumulus-client-cli", diff --git a/README.md b/README.md index a9737e2fe..5c0c717c3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Hyperbridge -Hyperbridge is a hyper-scalable, bridge network. Powered by zkSNARKs, Secured by Polkadot. +Hyperbridge is a hyper-scalable, interoperability coprocessor. ## Running a local tesnet with zombienet 1. Download the zombienet binary for your os from https://github.com/paritytech/zombienet diff --git a/parachain/chainspec/gargantua.json b/parachain/chainspec/gargantua.json index 0f0ad5e63..761656cdd 100644 --- a/parachain/chainspec/gargantua.json +++ b/parachain/chainspec/gargantua.json @@ -1,10 +1,12 @@ { "name": "Hyperbridge (Gargantua)", - "id": "gargantua", + "id": "gargantuan", "chainType": "Live", - "bootNodes": [], + "bootNodes": [ + " /ip4/34.78.130.110/tcp/30333/p2p/12D3KooWMRRsnAgJ1hjxCj3uJXPkauHqhP2BbbP4M5XF8xVJpeLX" + ], "telemetryEndpoints": null, - "protocolId": "gargantua", + "protocolId": "gargantuan", "properties": { "ss58Format": 42, "tokenDecimals": 12, diff --git a/parachain/modules/ismp/pallet/src/lib.rs b/parachain/modules/ismp/pallet/src/lib.rs index 8e5c828f2..ef2d5d07e 100644 --- a/parachain/modules/ismp/pallet/src/lib.rs +++ b/parachain/modules/ismp/pallet/src/lib.rs @@ -279,7 +279,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_n: BlockNumberFor) -> Weight { - // return Mmr finalization weight here + // todo: return correct Mmr finalization weight here ::WeightInfo::on_finalize(Self::number_of_leaves() as u32) } @@ -785,11 +785,6 @@ impl Pallet { Nodes::::insert(pos, node) } - /// Returns the number of leaves in the mmr - fn get_num_leaves() -> LeafIndex { - NumberOfLeaves::::get() - } - /// Set the number of leaves in the mmr fn set_num_leaves(num_leaves: LeafIndex) { NumberOfLeaves::::put(num_leaves) diff --git a/parachain/modules/ismp/pallet/src/mmr/mmr.rs b/parachain/modules/ismp/pallet/src/mmr/mmr.rs index 15d6c71bd..cad1aae17 100644 --- a/parachain/modules/ismp/pallet/src/mmr/mmr.rs +++ b/parachain/modules/ismp/pallet/src/mmr/mmr.rs @@ -20,7 +20,7 @@ use crate::{ utils::NodesUtils, }, primitives::{Error, Proof}, - Config, + Config, Pallet, }; use ismp::mmr::{DataOrHash, Leaf, MmrHasher, NodeIndex}; use sp_core::H256; @@ -36,7 +36,6 @@ where Storage: mmr_lib::MMRStore, { mmr: mmr_lib::MMR>, Storage>, - leaves: NodeIndex, } impl Mmr @@ -47,7 +46,7 @@ where /// Create a pointer to an existing MMR with given number of leaves. pub fn new(leaves: NodeIndex) -> Self { let size = NodesUtils::new(leaves).size(); - Self { mmr: mmr_lib::MMR::new(size, Default::default()), leaves } + Self { mmr: mmr_lib::MMR::new(size, Default::default()) } } } @@ -61,10 +60,10 @@ where /// Returns the element position (index) and number of leaves in the MMR. pub fn push(mut self, leaf: Leaf) -> Option<(NodeIndex, NodeIndex)> { let position = self.mmr.push(DataOrHash::Data(leaf)).map_err(|_| Error::Push).ok()?; - let num_leaves = self.leaves + 1; - self.leaves = num_leaves; + // Leaf index for the new leaf is the previous number of leaves + let leaf_index = Pallet::::number_of_leaves(); self.mmr.commit().ok()?; - Some((position, num_leaves)) + Some((position, leaf_index)) } /// Calculate the new MMR's root hash. @@ -96,7 +95,7 @@ where }) .collect::, Error>>()?; log::trace!(target: "runtime::mmr", "Positions {:?}", positions); - let leaf_count = self.leaves; + let leaf_count = Pallet::::number_of_leaves(); self.mmr .gen_proof(positions.clone()) .map_err(|_| Error::GenerateProof) diff --git a/parachain/modules/ismp/pallet/src/mmr/storage.rs b/parachain/modules/ismp/pallet/src/mmr/storage.rs index 91126af16..e066e9745 100644 --- a/parachain/modules/ismp/pallet/src/mmr/storage.rs +++ b/parachain/modules/ismp/pallet/src/mmr/storage.rs @@ -94,7 +94,7 @@ where elems.iter().map(|elem| elem.hash::>()).collect::>() ); - let leaves = Pallet::::get_num_leaves(); + let leaves = Pallet::::number_of_leaves(); let size = NodesUtils::new(leaves).size(); if pos != size { diff --git a/parachain/node/Cargo.toml b/parachain/node/Cargo.toml index 9e78dd7a8..4267aad6c 100644 --- a/parachain/node/Cargo.toml +++ b/parachain/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hyperbridge" -version = "0.1.5" +version = "0.1.6" authors = ["Polytope Labs "] description = "The hyperbridge coprocessor node" edition = "2021" diff --git a/parachain/node/src/command.rs b/parachain/node/src/command.rs index 98a38c9eb..6b28722ab 100644 --- a/parachain/node/src/command.rs +++ b/parachain/node/src/command.rs @@ -40,7 +40,7 @@ fn load_spec(id: &str) -> std::result::Result, String> { let id = u32::from_str(id).expect("can't parse Id into u32"); Box::new(chain_spec::development_config(id)) }, - "gargantua" => Box::new(chain_spec::ChainSpec::from_json_bytes( + "gargantua" | "gargantuan" => Box::new(chain_spec::ChainSpec::from_json_bytes( include_bytes!("../../chainspec/gargantua.json").to_vec(), )?), "" | "local" => Box::new(chain_spec::local_testnet_config()),