Skip to content

Commit

Permalink
FIx comliation error for node code
Browse files Browse the repository at this point in the history
  • Loading branch information
imstar15 committed Aug 9, 2024
1 parent d8e96ab commit 8dc9681
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 167 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

11 changes: 9 additions & 2 deletions node/src/chain_spec/turing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,13 @@ fn testnet_genesis(
code: turing_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: turing_runtime::BalancesConfig { balances: endowed_accounts },
parachain_info: turing_runtime::ParachainInfoConfig { parachain_id: para_id },
parachain_info: turing_runtime::ParachainInfoConfig {
parachain_id: para_id,
..Default::default()
},
session: turing_runtime::SessionConfig {
keys: invulnerables
.iter()
Expand Down Expand Up @@ -290,7 +294,10 @@ fn testnet_genesis(
phantom: Default::default(),
},
parachain_system: Default::default(),
polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) },
polkadot_xcm: PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
treasury: Default::default(),
// valve: ValveConfig { start_with_valve_closed: false, closed_gates: pallet_gates_closed },
// vesting: VestingConfig { vesting_schedule },
Expand Down
8 changes: 4 additions & 4 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ pub enum Subcommand {
subcommand_negates_reqs = true
)]
pub struct Cli {
#[clap(subcommand)]
#[command(subcommand)]
pub subcommand: Option<Subcommand>,

#[clap(flatten)]
#[command(flatten)]
pub run: cumulus_client_cli::RunCmd,

/// Disable automatic hardware benchmarks.
Expand All @@ -60,11 +60,11 @@ pub struct Cli {
///
/// The results are then printed out in the logs, and also sent as part of
/// telemetry, if telemetry is enabled.
#[clap(long)]
#[arg(long)]
pub no_hardware_benchmarks: bool,

/// Relay chain arguments
#[clap(raw = true)]
#[arg(raw = true)]
pub relay_chain_args: Vec<String>,
}

Expand Down
55 changes: 40 additions & 15 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ impl SubstrateCli for Cli {
}
}

impl Cli {
fn runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
#[cfg(not(feature = "turing-node"))]
panic!("{}", service::TURING_RUNTIME_NOT_AVAILABLE);

#[cfg(feature = "turing-node")]
return &service::turing_runtime::VERSION;
}
}

impl SubstrateCli for RelayChainCli {
fn impl_name() -> String {
"OAK Collator".into()
Expand Down Expand Up @@ -268,17 +278,24 @@ pub fn run() -> Result<()> {
})
},
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
with_runtime_or_err!(chain_spec, {
{
runner.sync_run(|_config| {
let spec =
cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::runtime_version(&spec).state_version();
cmd.run::<Block>(&*spec, &state_version)
})
}
})

// let runner = cli.create_runner(cmd)?;
// let chain_spec = &runner.config().chain_spec;
// with_runtime_or_err!(chain_spec, {
// {
// runner.sync_run(|_config| {
// let spec =
// cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
// let state_version = Cli::native_runtime_version(&spec).state_version();
// cmd.run::<Block>(&*spec, state_version)
// })
// }
// runner.sync_run(|_config| {
// let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
// let state_version = Cli::native_runtime_version(&spec).state_version();
// cmd.run::<Block>(&*spec, &state_version)
// })
// let runner = cli.create_runner(cmd)?;
// runner.sync_run(|config| {
Expand All @@ -293,11 +310,19 @@ pub fn run() -> Result<()> {
// cmd.run(&*config.chain_spec, &*partials.client)
// })

let runner = cli.create_runner(cmd)?;
runner.sync_run(|_config| {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run(&*spec)
})
// let runner = cli.create_runner(cmd)?;
// runner.sync_run(|_config| {
// let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
// let state_version = Cli::runtime_version(&spec).state_version();
// cmd.run::<turing_runtime::Block>(&*spec, &state_version)
// })

// let runner = cli.create_runner(cmd)?;
// runner.sync_run(|_config| {
// let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
// let state_version = Cli::native_runtime_version(&spec).state_version();
// cmd.run::<Block>(&*spec, state_version)
// })
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
let runner = cli.create_runner(cmd)?;
Expand Down
6 changes: 3 additions & 3 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ where
+ 'static,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_automation_time_rpc::AutomationTimeRuntimeApi<Block, AccountId, Hash, Balance>,
// C::Api: pallet_automation_time_rpc::AutomationTimeRuntimeApi<Block, AccountId, Hash, Balance>,
C::Api: pallet_automation_price_rpc::AutomationPriceRuntimeApi<Block, AccountId, Hash, Balance>,
C::Api: pallet_xcmp_handler_rpc::XcmpHandlerRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
{
use pallet_automation_price_rpc::{AutomationPrice, AutomationPriceApiServer};
use pallet_automation_time_rpc::{AutomationTime, AutomationTimeApiServer};
// use pallet_automation_time_rpc::{AutomationTime, AutomationTimeApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use pallet_xcmp_handler_rpc::{XcmpHandler, XcmpHandlerApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};
Expand All @@ -60,7 +60,7 @@ where

module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(AutomationTime::new(client.clone()).into_rpc())?;
// module.merge(AutomationTime::new(client.clone()).into_rpc())?;
module.merge(AutomationPrice::new(client.clone()).into_rpc())?;
module.merge(XcmpHandler::new(client).into_rpc())?;

Expand Down
62 changes: 30 additions & 32 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ use substrate_prometheus_endpoint::Registry;

use polkadot_service::CollatorPair;

#[cfg(not(feature = "runtime-benchmarks"))]
type HostFunctions = sp_io::SubstrateHostFunctions;

#[cfg(feature = "runtime-benchmarks")]
type HostFunctions =
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);

#[allow(dead_code)]
pub const NEUMANN_RUNTIME_NOT_AVAILABLE: &str =
"Neumann runtime is not available. Please compile the node with `--features neumann-node` to enable it.";
Expand Down Expand Up @@ -111,11 +118,10 @@ pub use turing_executor::*;

type FullBackend = TFullBackend<Block>;

type FullClient<RuntimeApi, ExecutorDispatch> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
pub type FullClient<RuntimeApi> = TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<HostFunctions>>;

type ParachainBlockImport<RuntimeApi, ExecutorDispatch> =
TParachainBlockImport<Block, Arc<FullClient<RuntimeApi, ExecutorDispatch>>, FullBackend>;
type ParachainBlockImport<RuntimeApi> =
TParachainBlockImport<Block, Arc<FullClient<RuntimeApi>>, FullBackend>;

/// Starts a `ServiceBuilder` for a full service.
///
Expand All @@ -127,18 +133,18 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
build_import_queue: BIQ,
) -> Result<
PartialComponents<
FullClient<RuntimeApi, Executor>,
FullClient<RuntimeApi>,
FullBackend,
(),
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, Executor>>,
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi>>,
(Option<Telemetry>, Option<TelemetryWorkerHandle>),
>,
sc_service::Error,
>
where
RuntimeApi:
ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
ConstructRuntimeApi<Block, FullClient<RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block>
Expand All @@ -148,8 +154,8 @@ where
sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
BIQ: FnOnce(
ParachainBlockImport<RuntimeApi, Executor>,
Arc<FullClient<RuntimeApi, Executor>>,
ParachainBlockImport<RuntimeApi>,
Arc<FullClient<RuntimeApi>>,
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
Expand Down Expand Up @@ -255,19 +261,18 @@ where
///
/// This is the actual implementation that is abstract over the executor and the runtime api.
#[sc_tracing::logging::prefix_logs_with("Parachain")]
async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
async fn start_node_impl<RuntimeApi, Executor, BIQ, BIC>(
parachain_config: Configuration,
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
_rpc_ext_builder: RB,
build_import_queue: BIQ,
build_consensus: BIC,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, Executor>>)>
) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi>>)>
where
RuntimeApi:
ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
ConstructRuntimeApi<Block, FullClient<RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block>
Expand All @@ -277,19 +282,14 @@ where
+ cumulus_primitives_core::CollectCollationInfo<Block>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_automation_time_rpc::AutomationTimeRuntimeApi<Block, AccountId, Hash, Balance>
// + pallet_automation_time_rpc::AutomationTimeRuntimeApi<Block, AccountId, Hash, Balance>
+ pallet_automation_price_rpc::AutomationPriceRuntimeApi<Block, AccountId, Hash, Balance>
+ pallet_xcmp_handler_rpc::XcmpHandlerRuntimeApi<Block, Balance>,
sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
RB: Fn(
Arc<TFullClient<Block, RuntimeApi, Executor>>,
) -> Result<RpcModule<()>, sc_service::Error>
+ Send
+ 'static,
BIQ: FnOnce(
ParachainBlockImport<RuntimeApi, Executor>,
Arc<FullClient<RuntimeApi, Executor>>,
ParachainBlockImport<RuntimeApi>,
Arc<FullClient<RuntimeApi>>,
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
Expand All @@ -298,13 +298,13 @@ where
sc_service::Error,
> + 'static,
BIC: FnOnce(
ParachainBlockImport<RuntimeApi, Executor>,
Arc<FullClient<RuntimeApi, Executor>>,
ParachainBlockImport<RuntimeApi>,
Arc<FullClient<RuntimeApi>>,
Option<&Registry>,
Option<TelemetryHandle>,
&TaskManager,
Arc<dyn RelayChainInterface>,
Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, Executor>>>,
Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi>>>,
Arc<SyncingService<Block>>,
KeystorePtr,
bool,
Expand Down Expand Up @@ -466,9 +466,9 @@ where

/// Build the import queue for the parachain runtime.
#[allow(clippy::type_complexity)]
pub fn parachain_build_import_queue<RuntimeApi, Executor>(
block_import: ParachainBlockImport<RuntimeApi, Executor>,
client: Arc<FullClient<RuntimeApi, Executor>>,
pub fn parachain_build_import_queue<RuntimeApi>(
block_import: ParachainBlockImport<RuntimeApi>,
client: Arc<FullClient<RuntimeApi>>,
config: &Configuration,
telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager,
Expand All @@ -478,7 +478,7 @@ pub fn parachain_build_import_queue<RuntimeApi, Executor>(
>
where
RuntimeApi:
ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
ConstructRuntimeApi<Block, FullClient<RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block>
Expand All @@ -492,7 +492,6 @@ where
+ pallet_automation_price_rpc::AutomationPriceRuntimeApi<Block, AccountId, Hash, Balance>
+ pallet_xcmp_handler_rpc::XcmpHandlerRuntimeApi<Block, Balance>,
RuntimeApi::RuntimeApi: sp_consensus_aura::AuraApi<Block, AuraId>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
{
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;

Expand Down Expand Up @@ -525,10 +524,10 @@ pub async fn start_parachain_node<RuntimeApi, Executor>(
collator_options: CollatorOptions,
id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, Executor>>)>
) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi>>)>
where
RuntimeApi:
ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
ConstructRuntimeApi<Block, FullClient<RuntimeApi>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block>
Expand All @@ -549,7 +548,6 @@ where
polkadot_config,
collator_options,
id,
|_| Ok(RpcModule::new(())),
parachain_build_import_queue,
|block_import,
client,
Expand Down
1 change: 1 addition & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-fe
## Polkdadot deps
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }

## ORML deps
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v1.1.0" }
Expand Down
Loading

0 comments on commit 8dc9681

Please sign in to comment.