Skip to content

Commit

Permalink
Integrated hyperbridge with 2407
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmishra2005 committed Jan 9, 2025
1 parent 58f96d9 commit 84c552d
Show file tree
Hide file tree
Showing 25 changed files with 837 additions and 33 deletions.
368 changes: 363 additions & 5 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,15 @@ pallet-erc20 = { path = "pallets/erc20", default-features = false }
pallet-erc721 = { path = "pallets/erc721", default-features = false }
pallet-origins = { path = "pallets/origins", default-features = false }

ismp = { default-features = false, version = "0.2.2" }
pallet-ismp = { default-features = false, version = "1.15.3" }
pallet-ismp-rpc = { default-features = false, version = "1.15.3" }
pallet-ismp-runtime-api = { default-features = false, version = "1.15.3" }
pallet-hyperbridge = { default-features = false, version = "1.15.3" }
ismp-grandpa = { default-features = false, version = "1.15.4" }
frame-metadata-hash-extension = { default-features = false, version = "0.5.0" }
sp-mmr-primitives = { default-features = false, version = "34.0.0" }
anyhow = { version = "1.0", default-features = false }

[profile.release]
panic = "unwind"
6 changes: 4 additions & 2 deletions node/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ repository.workspace = true
futures = { workspace = true }

# Substrate dependencies
ddc-primitives = { workspace = true, default-features = true }
frame-benchmarking = { workspace = true, default-features = true }
frame-system = { workspace = true, default-features = true }
frame-system-rpc-runtime-api = { workspace = true, default-features = true }
ddc-primitives = { workspace = true, default-features = true }
pallet-transaction-payment = { workspace = true, default-features = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = true }
sc-client-api = { workspace = true, default-features = true }
Expand All @@ -29,6 +29,7 @@ sp-blockchain = { workspace = true, default-features = true }
sp-consensus = { workspace = true, default-features = true }
sp-consensus-babe = { workspace = true, default-features = true }
sp-consensus-grandpa = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-inherents = { workspace = true, default-features = true }
sp-offchain = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
Expand All @@ -40,7 +41,8 @@ sp-transaction-pool = { workspace = true, default-features = true }
# Local
cere-dev-runtime = { workspace = true, optional = true }
cere-runtime = { workspace = true, optional = true }

pallet-ismp = { workspace = true, default-features = true }
pallet-ismp-runtime-api = { workspace = true, default-features = true }
[features]
default = ["cere"]
cere = ["cere-runtime"]
Expand Down
3 changes: 3 additions & 0 deletions node/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub use sc_executor::NativeElseWasmExecutor;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_blockchain::{HeaderBackend, HeaderMetadata};
use sp_consensus::BlockStatus;
use sp_core::H256;
use sp_runtime::{
generic::SignedBlock,
traits::{BlakeTwo256, Block as BlockT, NumberFor},
Expand Down Expand Up @@ -512,6 +513,7 @@ pub trait RuntimeApiCollection:
+ sp_block_builder::BlockBuilder<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ pallet_ismp_runtime_api::IsmpRuntimeApi<Block, H256>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
Expand All @@ -527,6 +529,7 @@ impl<Api> RuntimeApiCollection for Api where
+ sp_block_builder::BlockBuilder<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ pallet_ismp_runtime_api::IsmpRuntimeApi<Block, H256>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
Expand Down
4 changes: 4 additions & 0 deletions node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ sp-block-builder = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
sp-consensus = { workspace = true, default-features = true }
sp-consensus-babe = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-keystore = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
substrate-frame-rpc-system = { workspace = true, default-features = true }
substrate-state-trie-migration-rpc = { workspace = true, default-features = true }

pallet-ismp-rpc = { workspace = true, default-features = true }
pallet-ismp-runtime-api = { workspace = true, default-features = true }
21 changes: 15 additions & 6 deletions node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

use std::sync::Arc;

use jsonrpsee::RpcModule;
use ddc_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Nonce};
use sc_client_api::AuxStore;
use jsonrpsee::RpcModule;
use pallet_ismp_rpc::{IsmpApiServer, IsmpRpcHandler};
use sc_client_api::{AuxStore, BlockBackend, ProofProvider};
use sc_consensus_grandpa::{
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
};
Expand All @@ -22,6 +23,7 @@ use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_consensus::SelectChain;
use sp_consensus_babe::BabeApi;
use sp_core::H256;
use sp_keystore::KeystorePtr;

/// Extra dependencies for BABE.
Expand Down Expand Up @@ -61,12 +63,14 @@ pub struct FullDeps<C, P, SC, B> {
pub babe: BabeDeps,
/// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps<B>,
/// Backend used by the node.
pub backend: Arc<B>,
}

/// Instantiate all full RPC extensions.
pub fn create_full<C, P, SC, B>(
deps: FullDeps<C, P, SC, B>,
backend: Arc<B>,
_backend: Arc<B>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
Expand All @@ -77,10 +81,13 @@ where
+ Sync
+ Send
+ 'static,
C: BlockBackend<Block>,
C: ProofProvider<Block>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BabeApi<Block>,
C::Api: BlockBuilder<Block>,
C::Api: pallet_ismp_runtime_api::IsmpRuntimeApi<Block, H256>,
P: TransactionPool + 'static,
SC: SelectChain<Block> + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
Expand All @@ -95,7 +102,8 @@ where
use substrate_state_trie_migration_rpc::StateMigrationApiServer;

let mut io = RpcModule::new(());
let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa } = deps;
let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa, backend } =
deps;

let BabeDeps { babe_worker_handle, keystore } = babe;
let GrandpaDeps {
Expand Down Expand Up @@ -134,12 +142,13 @@ where
io.merge(
substrate_state_trie_migration_rpc::StateMigration::new(
client.clone(),
backend,
backend.clone(),
deny_unsafe,
)
.into_rpc(),
)?;
io.merge(Dev::new(client, deny_unsafe).into_rpc())?;
io.merge(Dev::new(client.clone(), deny_unsafe).into_rpc())?;
io.merge(IsmpRpcHandler::new(client, backend)?.into_rpc())?;

Ok(io)
}
2 changes: 1 addition & 1 deletion node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use cere_dev_runtime as cere_dev;
#[cfg(feature = "cere-dev-native")]
use cere_runtime_common::constants::currency::DOLLARS as TEST_UNITS;
use jsonrpsee::core::__reexports::serde_json;
pub use ddc_primitives::{AccountId, Balance, Block, Signature};
use jsonrpsee::core::__reexports::serde_json;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use sc_chain_spec::ChainSpecExtension;
use sc_service::ChainType;
Expand Down
1 change: 1 addition & 0 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ where
subscription_executor,
finality_provider: finality_proof_provider.clone(),
},
backend: rpc_backend.clone(),
};

cere_rpc::create_full(deps, rpc_backend.clone()).map_err(Into::into)
Expand Down
2 changes: 1 addition & 1 deletion pallets/chainbridge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(clippy::all)]
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]

#![allow(clippy::manual_inspect)]
pub mod weights;
use crate::weights::WeightInfo;

Expand Down
2 changes: 1 addition & 1 deletion pallets/ddc-clusters-gov/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"]

#![allow(clippy::manual_inspect)]
use codec::{Decode, Encode};
#[cfg(feature = "runtime-benchmarks")]
use ddc_primitives::traits::{node::NodeCreator, staking::StakerCreator};
Expand Down
2 changes: 1 addition & 1 deletion pallets/ddc-clusters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! `GenesisConfig` is optional and allow to set some initial nodes in DDC.
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"]

#![allow(clippy::manual_inspect)]
pub mod weights;
use crate::weights::WeightInfo;

Expand Down
2 changes: 1 addition & 1 deletion pallets/ddc-customers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"]

#![allow(clippy::manual_inspect)]
pub mod weights;
use crate::weights::WeightInfo;

Expand Down
2 changes: 1 addition & 1 deletion pallets/ddc-nodes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
//! The DDC Nodes pallet depends on the [`GenesisConfig`]. The
//! `GenesisConfig` is optional and allow to set some initial nodes in DDC.
#![allow(clippy::manual_inspect)]
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"]

#[cfg(test)]
pub(crate) mod mock;
#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion pallets/ddc-payouts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"]

#![allow(clippy::manual_inspect)]
pub mod weights;
use crate::weights::WeightInfo;

Expand Down
2 changes: 1 addition & 1 deletion pallets/ddc-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! `GenesisConfig` is optional and allow to set some initial stakers in DDC.
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"]

#![allow(clippy::manual_inspect)]
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;
#[cfg(any(feature = "runtime-benchmarks", test))]
Expand Down
2 changes: 1 addition & 1 deletion pallets/origins/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Custom origins for governance interventions.
#![allow(clippy::manual_inspect)]
#![cfg_attr(not(feature = "std"), no_std)]

pub use pallet::*;
Expand Down
22 changes: 21 additions & 1 deletion runtime/cere-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ scale-info = { workspace = true }
static_assertions = { workspace = true }

# Substrate dependencies
ddc-primitives = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
frame-election-provider-support = { workspace = true }
frame-executive = { workspace = true }
Expand All @@ -28,7 +29,6 @@ frame-system = { workspace = true }
frame-system-benchmarking = { workspace = true, optional = true }
frame-system-rpc-runtime-api = { workspace = true }
frame-try-runtime = { workspace = true, optional = true }
ddc-primitives = { workspace = true }
pallet-authority-discovery = { workspace = true }
pallet-authorship = { workspace = true }
pallet-babe = { workspace = true }
Expand Down Expand Up @@ -105,6 +105,16 @@ pallet-erc20 = { workspace = true }
pallet-erc721 = { workspace = true }
pallet-origins = { workspace = true }

# Hyperbridge Depedencies
anyhow = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
ismp = { workspace = true }
ismp-grandpa = { workspace = true }
pallet-hyperbridge = { workspace = true }
pallet-ismp = { workspace = true, features = ["unsigned"] }
pallet-ismp-runtime-api = { workspace = true }
sp-mmr-primitives = { workspace = true }

[build-dependencies]
substrate-wasm-builder = { workspace = true, default-features = true }

Expand Down Expand Up @@ -192,6 +202,13 @@ std = [
"pallet-ddc-clusters-gov/std",
"sp-arithmetic/std",
"pallet-origins/std",
"pallet-hyperbridge/std",
"ismp/std",
"pallet-ismp/std",
"pallet-ismp-runtime-api/std",
"ismp-grandpa/std",
"anyhow/std",
"frame-metadata-hash-extension/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down Expand Up @@ -298,4 +315,7 @@ try-runtime = [
"pallet-preimage/try-runtime",
"pallet-origins/try-runtime",
"pallet-ddc-clusters-gov/try-runtime",
"pallet-ismp/try-runtime",
"pallet-hyperbridge/try-runtime",
"ismp-grandpa/try-runtime",
]
Loading

0 comments on commit 84c552d

Please sign in to comment.