Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
substrate ismp compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
dharjeezy committed Sep 15, 2023
1 parent 3beee3f commit c55a13f
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 220 deletions.
513 changes: 323 additions & 190 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions ismp-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive"
ismp = { git = "https://github.com/polytope-labs/ismp-rs", branch = "main", default-features = false }

# substrate
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-support = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
frame-system = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-core = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }

# local
pallet-ismp = { path = "../pallet-ismp", default-features = false }
Expand Down
20 changes: 10 additions & 10 deletions pallet-ismp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ authors = ["Polytope Labs <hello@polytope.technology>"]

[dependencies]
# substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, optional = true }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false, optional = true }

# polytope labs
ismp-rs = { package = "ismp", git = "https://github.com/polytope-labs/ismp-rs", branch = "main", default-features = false }
Expand All @@ -33,7 +33,7 @@ ismp-primitives = { path = "./primitives", default-features = false }

[dev-dependencies]
env_logger = "0.10.0"
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
ismp-testsuite = { git = "https://github.com/polytope-labs/ismp-rs", branch = "main" }

[features]
Expand Down
12 changes: 6 additions & 6 deletions pallet-ismp/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ pallet-ismp = { path = ".." }
ismp-runtime-api = { path = "../runtime-api" }
ismp-primitives = { path = "../primitives" }

frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
4 changes: 2 additions & 2 deletions pallet-ismp/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ authors = ["Polytope Labs <hello@polytope.technology>"]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-ismp = { path = "..", default-features = false }
ismp-primitives = { path = "../primitives", default-features = false }
ismp-rs = { package = "ismp", git = "https://github.com/polytope-labs/ismp-rs", branch = "main", default-features = false }
Expand Down
11 changes: 6 additions & 5 deletions pallet-ismp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ use codec::{Decode, Encode};
use core::time::Duration;
use frame_support::{
dispatch::{DispatchResult, DispatchResultWithPostInfo, Pays, PostDispatchInfo},
log::debug,
traits::{Get, UnixTime},
RuntimeDebug,
};
use ismp_rs::{
consensus::{ConsensusClientId, StateMachineId},
Expand All @@ -54,19 +52,22 @@ use ismp_rs::{
messaging::CreateConsensusState,
router::{Request, Response},
};
use log::debug;
use sp_core::{offchain::StorageKind, H256};
// Re-export pallet items so that they can be accessed from the crate namespace.
use crate::{
errors::{HandlingError, ModuleCallbackResult},
mmr::mmr::Mmr,
weight_info::get_weight,
};
use frame_system::pallet_prelude::BlockNumberFor;
use ismp_primitives::{
mmr::{DataOrHash, Leaf, LeafIndex, NodeIndex},
LeafIndexQuery,
};
use ismp_rs::{host::IsmpHost, messaging::Message};
pub use pallet::*;
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;

// Definition of the pallet logic, to be aggregated at runtime definition through
Expand Down Expand Up @@ -271,12 +272,12 @@ pub mod pallet {
// Pallet implements [`Hooks`] trait to define some logic to execute in some context.
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(_n: T::BlockNumber) -> Weight {
fn on_initialize(_n: BlockNumberFor<T>) -> Weight {
// return Mmr finalization weight here
<T as Config>::WeightInfo::on_finalize(Self::number_of_leaves() as u32)
}

fn on_finalize(_n: T::BlockNumber) {
fn on_finalize(_n: BlockNumberFor<T>) {
// Only finalize if mmr was modified
let leaves = Self::number_of_leaves();
let root = if leaves != 0 {
Expand All @@ -301,7 +302,7 @@ pub mod pallet {
<frame_system::Pallet<T>>::deposit_log(digest);
}

fn offchain_worker(_n: T::BlockNumber) {}
fn offchain_worker(_n: BlockNumberFor<T>) {}
}

/// Params to update the unbonding period for a consensus state
Expand Down
2 changes: 1 addition & 1 deletion pallet-ismp/src/mmr/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

//! An MMR storage implementation.
use codec::Encode;
use frame_support::log::{debug, trace};
use ismp_primitives::mmr::{DataOrHash, NodeIndex};
use log::{debug, trace};
use mmr_lib::helper;
use sp_core::offchain::StorageKind;
use sp_std::iter::Peekable;
Expand Down
3 changes: 2 additions & 1 deletion pallet-ismp/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

//! Pallet primitives
use codec::{Decode, Encode};
use frame_support::{weights::Weight, PalletId, RuntimeDebug};
use frame_support::{weights::Weight, PalletId};
use ismp_primitives::mmr::{LeafIndex, NodeIndex};
use ismp_rs::consensus::{ConsensusClient, ConsensusClientId};
use scale_info::TypeInfo;
use sp_core::{
crypto::{AccountId32, ByteArray},
H160,
};
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;

/// An MMR proof data for a group of leaves.
Expand Down

0 comments on commit c55a13f

Please sign in to comment.