Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
64 changes: 63 additions & 1 deletion Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pallet-ismp-runtime-api = { git = "https://github.com/polytope-labs/hyperbridge.
ismp-parachain-runtime-api = { git = "https://github.com/polytope-labs/hyperbridge.git", tag = "hyperbridge-v1.3.0", default-features = false }
pallet-mmr-tree = { git = "https://github.com/polytope-labs/hyperbridge.git", tag = "hyperbridge-v1.3.0", default-features = false }
pallet-mmr-runtime-api = { git = "https://github.com/polytope-labs/hyperbridge.git", tag = "hyperbridge-v1.3.0", default-features = false }
pallet-mmr-rpc = { git = "https://github.com/polytope-labs/hyperbridge.git", tag = "hyperbridge-v1.3.0", default-features = false }
mmr-gadget = { git = "https://github.com/polytope-labs/hyperbridge.git", tag = "hyperbridge-v1.3.0", default-features = false }
ismp-testsuite = { git = "https://github.com/polytope-labs/hyperbridge.git", tag = "hyperbridge-v1.3.0", default-features = false }

# Local
Expand All @@ -57,6 +59,7 @@ nonfungible-primitives = { path = "./primitives/nonfungible", default-features =
order-primitives = { path = "./primitives/order", default-features = false }
regionx-runtime-common = { path = "./runtime/common", default-features = false }
regionx-kusama-runtime = { path = "./runtime/kusama" }
regionx-westend-runtime = { path = "./runtime/westend" }
pallet-market = { path = "./pallets/market", default-features = false }
pallet-orders = { path = "./pallets/orders", default-features = false }
pallet-processor = { path = "./pallets/processor", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions e2e_tests/ismp.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ async function ismpAddParachain(signer: KeyringPair, regionXApi: ApiPromise) {
}

async function queryRequest(regionxApi: ApiPromise, commitment: string): Promise<IsmpRequest> {
console.log('QUERY REQUEST');
const leafIndex = regionxApi.createType('LeafIndexQuery', { commitment });
console.log('leafIndex: ' + leafIndex);
const requests = await (regionxApi as any).rpc.ismp.queryRequests([leafIndex]);
console.log(requests);
// We only requested a single request so we only get one in the response.
return requests.toJSON()[0] as IsmpRequest;
}
Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/xc-transfer/region-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const PARA_2000_CHILD = 'F7fq1jMZkfuCuoMTyiEVAP2DMpMt18WopgBqTJznLihLNbZ';
async function run(_nodeName: any, networkInfo: any, _jsArgs: any) {
const { wsUri: regionXUri } = networkInfo.nodesByName['regionx-collator01'];
const { wsUri: coretimeUri } = networkInfo.nodesByName['coretime-collator01'];
const { wsUri: relayUri } = networkInfo.nodesByName['kusama-validator01'];
const { wsUri: relayUri } = networkInfo.nodesByName['westend-validator01'];

const regionXApi = await ApiPromise.create({
provider: new WsProvider(regionXUri),
Expand Down
4 changes: 4 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ serde_json = { workspace = true }

# Local
regionx-kusama-runtime = { workspace = true }
regionx-westend-runtime = { workspace = true }
regionx-runtime-common = { workspace = true }

# Polytope Labs
pallet-ismp = { workspace = true, default-features = true }
pallet-ismp-runtime-api = { workspace = true, default-features = true }
pallet-ismp-rpc = { workspace = true, default-features = true }
ismp-parachain-inherent = { workspace = true, default-features = true }
ismp-parachain-runtime-api = { workspace = true, default-features = true }
pallet-mmr-runtime-api = { workspace = true, default-features = true }
pallet-mmr-rpc = { workspace = true, default-features = true }
mmr-gadget = { workspace = true }

[dependencies.polkadot-sdk]
workspace = true
Expand Down
22 changes: 22 additions & 0 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,25 @@ pub fn regionx_kusama_development_chain_spec() -> ChainSpec {
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
.build()
}

pub fn regionx_westend_development_chain_spec() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());

ChainSpec::builder(
regionx_westend_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "westend-local".into(),
// You MUST set this to the correct network!
para_id: 2000,
},
)
.with_name("RegionX Westend Development")
.with_id("regionx-westend-dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
.build()
}
28 changes: 27 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ use sp_runtime::traits::AccountIdConversion;
use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
service::{is_kusama, new_partial, HostFunctions},
service::{is_kusama, is_westend, new_partial, HostFunctions},
};

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
// TODO: Para Id
"regionx-kusama-dev" => Box::new(chain_spec::regionx_kusama_development_chain_spec()),
"regionx-westend-dev" => Box::new(chain_spec::regionx_westend_development_chain_spec()),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}
Expand Down Expand Up @@ -125,6 +126,14 @@ macro_rules! construct_async_run {
{ $( $code )* }.map(|v| (v, task_manager))
})
},
chain if is_westend(chain) => {
runner.async_run(|$config| {
let executor = sc_service::new_wasm_executor::<HostFunctions>(&$config.executor);
let $components = new_partial::<regionx_westend_runtime::RuntimeApi, _>(&$config, executor)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
})
},
chain => panic!("Unknown chain with id: {}", chain),
}
}}
Expand Down Expand Up @@ -193,6 +202,11 @@ pub fn run() -> Result<()> {
new_partial::<regionx_kusama_runtime::RuntimeApi, _>(&config, executor)?;
cmd.run(partials.client)
},
chain if is_westend(chain) => {
let partials =
new_partial::<regionx_westend_runtime::RuntimeApi, _>(&config, executor)?;
cmd.run(partials.client)
},
chain => panic!("Unknown chain with id: {}", chain),
}
})
Expand Down Expand Up @@ -229,6 +243,11 @@ pub fn run() -> Result<()> {
new_partial::<regionx_kusama_runtime::RuntimeApi, _>(&config, executor)?;
cmd.run(partials.client)
},
chain if is_westend(chain) => {
let partials =
new_partial::<regionx_westend_runtime::RuntimeApi, _>(&config, executor)?;
cmd.run(partials.client)
},
chain => panic!("Unknown chain with id: {}", chain),
}
}),
Expand All @@ -252,6 +271,13 @@ pub fn run() -> Result<()> {
let storage = partials.backend.expose_storage();
cmd.run(config, partials.client.clone(), db, storage)
},
chain if is_westend(chain) => {
let partials =
new_partial::<regionx_westend_runtime::RuntimeApi, _>(&config, executor)?;
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();
cmd.run(config, partials.client.clone(), db, storage)
},
chain => panic!("Unknown chain with id: {}", chain),
}
}),
Expand Down
15 changes: 12 additions & 3 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
use polkadot_sdk::*;
use std::sync::Arc;

use regionx_runtime_common::primitives::{opaque::Block, AccountId, Balance, Nonce};
use regionx_runtime_common::primitives::{opaque::Block, AccountId, Balance, BlockNumber, Nonce};

use pallet_ismp_rpc::{IsmpApiServer, IsmpRpcHandler};
use sc_client_api::{AuxStore, BlockBackend, ProofProvider};
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
Expand Down Expand Up @@ -64,10 +63,19 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: BlockBuilder<Block>,
C::Api: pallet_ismp_runtime_api::IsmpRuntimeApi<Block, H256>,
C::Api: pallet_mmr_runtime_api::MmrRuntimeApi<
Block,
H256,
BlockNumber,
pallet_ismp::offchain::Leaf,
>,
P: TransactionPool + Sync + Send + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::StateBackend<sp_runtime::traits::HashingFor<Block>>,

{
use pallet_ismp_rpc::{IsmpApiServer, IsmpRpcHandler};
use pallet_mmr_rpc::{MmrApiServer, MmrRpcHandler};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};

Expand All @@ -76,7 +84,8 @@ where

module.merge(System::new(client.clone(), pool).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(IsmpRpcHandler::new(client, backend.clone())?.into_rpc())?;
module.merge(IsmpRpcHandler::new(client.clone(), backend.clone())?.into_rpc())?;
module.merge(MmrRpcHandler::new(client, backend.clone())?.into_rpc())?;

Ok(module)
}
14 changes: 13 additions & 1 deletion node/src/runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use cumulus_primitives_core::CollectCollationInfo;
use pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi;
use polkadot_sdk::*;
use regionx_runtime_common::primitives::{AccountId, AuraId, Balance, Block, Nonce};
use regionx_runtime_common::primitives::{AccountId, AuraId, Balance, Block, BlockNumber, Nonce};
use sc_offchain::OffchainWorkerApi;
use sp_api::{ApiExt, Metadata};
use sp_block_builder::BlockBuilder;
Expand All @@ -40,6 +40,12 @@ pub trait BaseHostRuntimeApis:
+ ismp_parachain_runtime_api::IsmpParachainApi<Block>
+ cumulus_primitives_aura::AuraUnincludedSegmentApi<Block>
+ pallet_ismp_runtime_api::IsmpRuntimeApi<Block, H256>
+ pallet_mmr_runtime_api::MmrRuntimeApi<
Block,
H256,
BlockNumber,
pallet_ismp::offchain::Leaf,
>
{
}

Expand All @@ -57,5 +63,11 @@ impl<Api> BaseHostRuntimeApis for Api where
+ ismp_parachain_runtime_api::IsmpParachainApi<Block>
+ cumulus_primitives_aura::AuraUnincludedSegmentApi<Block>
+ pallet_ismp_runtime_api::IsmpRuntimeApi<Block, H256>
+ pallet_mmr_runtime_api::MmrRuntimeApi<
Block,
H256,
BlockNumber,
pallet_ismp::offchain::Leaf,
>
{
}
Loading
Loading