Skip to content

Commit

Permalink
Fix XCMP delivery issues
Browse files Browse the repository at this point in the history
* Runtime API agnostic parachain client (use fake RuntimeAPI)
* Added dedicated XCM config for polkadot runtime variant
  • Loading branch information
akru committed Sep 27, 2024
1 parent 5820c27 commit 492b059
Show file tree
Hide file tree
Showing 15 changed files with 583 additions and 288 deletions.
43 changes: 32 additions & 11 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ homepage.workspace = true
repository.workspace = true

[workspace.package]
version = "3.0.0"
version = "3.1.0"
edition = "2021"
authors = ["Airalab <research@robonomics.network>"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion chains/kusama-parachain.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Robonomics",
"name": "Robonomics Kusama",
"id": "robonomics",
"chainType": "Live",
"bootNodes": [
Expand Down
2 changes: 1 addition & 1 deletion chains/kusama-parachain.raw.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Robonomics",
"name": "Robonomics Kusama",
"id": "robonomics",
"chainType": "Live",
"bootNodes": [
Expand Down
4 changes: 1 addition & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ serde = { workspace = true }

robonomics-primitives = { path = "../primitives" }
robonomics-service = { path = "./service" }
generic-runtime = { path = "./generic-runtime" }
dev-runtime = { path = "../runtime/dev" }
main-runtime = { path = "../runtime/main" }

# substrate
sc-cli = { workspace = true }
Expand All @@ -34,7 +34,6 @@ frame-benchmarking-cli = { workspace = true }

# polkadot
polkadot-cli = { workspace = true }
xcm = { workspace = true }

# cumulus
cumulus-client-cli = { workspace = true }
Expand All @@ -47,5 +46,4 @@ substrate-build-script-utils = { workspace = true }
runtime-benchmarks = [
"sc-service/runtime-benchmarks",
"dev-runtime/runtime-benchmarks",
"main-runtime/runtime-benchmarks",
]
32 changes: 32 additions & 0 deletions node/generic-runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "generic-runtime"
version.workspace = true
authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
robonomics-primitives = { path = "../../primitives" }
frame-support = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-core = { workspace = true }
sp-std = { workspace = true }
sp-session = { workspace = true }
sp-runtime = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-inherents = { workspace = true }
sp-offchain = { workspace = true }
sp-version = { workspace = true }
cumulus-primitives-core = { workspace = true }

[features]
try-runtime = []
runtime-benchmarks = []
155 changes: 155 additions & 0 deletions node/generic-runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright 2018-2024 Robonomics Network <research@robonomics.network>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////////
//! Generic Robonomics runtime inerface.
use frame_support::weights::Weight;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use robonomics_primitives::{AccountId, Balance, Block, Nonce};
use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
use sp_inherents::{CheckInherentsResult, InherentData};
use sp_runtime::{
traits::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
};
use sp_version::RuntimeVersion;

pub struct Runtime;

impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
unimplemented!()
}

fn execute_block(_block: Block) {
unimplemented!()
}

fn initialize_block(_header: &<Block as BlockT>::Header) {
unimplemented!()
}
}

impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
unimplemented!()
}

fn metadata_at_version(_version: u32) -> Option<OpaqueMetadata> {
unimplemented!()
}

fn metadata_versions() -> sp_std::vec::Vec<u32> {
unimplemented!()
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(_header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
unimplemented!()
}
}

impl sp_block_builder::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(_extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
unimplemented!()
}

fn finalize_block() -> <Block as BlockT>::Header {
unimplemented!()
}

fn inherent_extrinsics(_data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
unimplemented!()
}

fn check_inherents(_block: Block, _data: InherentData) -> CheckInherentsResult {
unimplemented!()
}
}

impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
fn account_nonce(_account: AccountId) -> Nonce {
unimplemented!()
}
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(_seed: Option<Vec<u8>>) -> Vec<u8> {
unimplemented!()
}

fn decode_session_keys(_encoded: Vec<u8>) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
unimplemented!()
}
}

impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
Block,
Balance,
> for Runtime {
fn query_info(_uxt: <Block as BlockT>::Extrinsic, _len: u32) -> RuntimeDispatchInfo<Balance> {
unimplemented!()
}
fn query_fee_details(_uxt: <Block as BlockT>::Extrinsic, _len: u32) -> FeeDetails<Balance> {
unimplemented!()
}
fn query_weight_to_fee(_weight: Weight) -> Balance {
unimplemented!()
}
fn query_length_to_fee(_length: u32) -> Balance {
unimplemented!()
}
}

impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(_source: TransactionSource, _tx: <Block as BlockT>::Extrinsic, _block_hash: <Block as BlockT>::Hash) -> TransactionValidity {
unimplemented!()
}
}

impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(_header: &<Block as BlockT>::Header) {
unimplemented!()
}
}

#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn benchmark_metadata(_extra: bool) -> (Vec<frame_benchmarking::BenchmarkList>, Vec<frame_support::traits::StorageInfo>) {
unimplemented!()
}

fn dispatch_benchmark(_config: frame_benchmarking::BenchmarkConfig) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
unimplemented!()
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(_checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
unimplemented!()
}

fn execute_block(_block: Block, _state_root_check: bool, _signature_check: bool, _select: frame_try_runtime::TryStateSelect) -> Weight {
unimplemented!()
}
}
}
Loading

0 comments on commit 492b059

Please sign in to comment.