Skip to content

Commit

Permalink
fix: building.
Browse files Browse the repository at this point in the history
  • Loading branch information
nakul1010 committed Aug 1, 2023
1 parent 251a0b9 commit 106e412
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 80 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack//open-runtime-mod
orml-xcm = { git = "https://github.com/open-web3-stack//open-runtime-module-library", branch = "polkadot-v1.0.0" }
orml-xtokens = { git = "https://github.com/open-web3-stack//open-runtime-module-library", branch = "polkadot-v1.0.0" }

#ToDo: Change to commit id instead of master
[patch."https://github.com/paritytech/frontier"]
fc-api = { git = "https://github.com/paritytech//frontier", branch = "master" }
fc-cli = { git = "https://github.com/paritytech//frontier", branch = "master" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cumulus_primitives_core::MultiLocation;
use frame_support::traits::GenesisBuild;
pub use interlay_runtime_parachain::{xcm_config::*, *};
use polkadot_primitives::v4::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_primitives::v5::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_runtime_parachains::{configuration::HostConfiguration, paras::ParaKind};
pub use primitives::{
CurrencyId::Token,
Expand Down
6 changes: 3 additions & 3 deletions parachain/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ impl RelayChainCli {
) -> Self {
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone());
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot"));
let base_path = para_config.base_path.path().join("polkadot");
Self {
base_path,
base_path: Some(base_path),
chain_id,
base: polkadot_cli::RunCmd::parse_from(relay_chain_args),
base: clap::Parser::parse_from(relay_chain_args),
}
}
}
62 changes: 17 additions & 45 deletions parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, NetworkParams, Result,
RuntimeVersion, SharedParams, SubstrateCli,
};
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use sc_service::{
config::{BasePath, PrometheusConfig},
Configuration, TaskManager,
Expand Down Expand Up @@ -156,16 +157,6 @@ impl SubstrateCli for Cli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id, self.instant_seal)
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
if chain_spec.is_interlay() {
&interlay_runtime::VERSION
} else if chain_spec.is_kintsugi() {
&kintsugi_runtime::VERSION
} else {
panic!("Chain should be either kintsugi or interlay");
}
}
}

impl SubstrateCli for RelayChainCli {
Expand Down Expand Up @@ -202,10 +193,6 @@ impl SubstrateCli for RelayChainCli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name().to_string()].iter()).load_spec(id)
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
polkadot_cli::Cli::native_runtime_version(chain_spec)
}
}

fn write_to_file_or_stdout(raw: bool, output: &Option<PathBuf>, raw_bytes: Vec<u8>) -> Result<()> {
Expand Down Expand Up @@ -319,9 +306,19 @@ pub fn run() -> Result<()> {
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
if runner.config().chain_spec.is_interlay() {
runner.sync_run(|config| cmd.run::<Block, InterlayRuntimeExecutor>(config))
runner.sync_run(|config| {
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<InterlayRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,
>>(config)
})
} else if runner.config().chain_spec.is_kintsugi() {
runner.sync_run(|config| cmd.run::<Block, KintsugiRuntimeExecutor>(config))
runner.sync_run(|config| {
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<KintsugiRuntimeExecutor as NativeExecutionDispatch>::ExtendHostFunctions,
>>(config)
})
} else {
Err("Chain doesn't support benchmarking".into())
}
Expand Down Expand Up @@ -406,10 +403,9 @@ pub fn run() -> Result<()> {
let chain_spec = &runner.config().chain_spec;

with_runtime_or_err!(chain_spec, {
return 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)
return runner.sync_run(|config| {
let partials = new_partial::<RuntimeApi, Executor>(&config, &cli.eth, false)?;
cmd.run::<Block>(&*config.chain_spec, &*partials.client)
});
})
}
Expand Down Expand Up @@ -504,7 +500,7 @@ async fn start_node(cli: Cli, config: Configuration) -> sc_service::error::Resul

let id = ParaId::from(para_id.unwrap_or(DEFAULT_PARA_ID));

let parachain_account = AccountIdConversion::<polkadot_primitives::v4::AccountId>::into_account_truncating(&id);
let parachain_account = AccountIdConversion::<polkadot_primitives::v5::AccountId>::into_account_truncating(&id);

let tokio_handle = config.tokio_handle.clone();
let polkadot_config = SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
Expand Down Expand Up @@ -540,14 +536,6 @@ impl DefaultConfigurationValues for RelayChainCli {
30334
}

fn rpc_ws_listen_port() -> u16 {
9945
}

fn rpc_http_listen_port() -> u16 {
9934
}

fn prometheus_listen_port() -> u16 {
9616
}
Expand Down Expand Up @@ -577,18 +565,6 @@ impl CliConfiguration<Self> for RelayChainCli {
.or_else(|| self.base_path.clone().map(Into::into)))
}

fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
self.base.base.rpc_http(default_listen_port)
}

fn rpc_ipc(&self) -> Result<Option<String>> {
self.base.base.rpc_ipc()
}

fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
self.base.base.rpc_ws(default_listen_port)
}

fn prometheus_config(
&self,
default_listen_port: u16,
Expand Down Expand Up @@ -632,10 +608,6 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.rpc_methods()
}

fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
self.base.base.rpc_ws_max_connections()
}

fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
self.base.base.rpc_cors(is_dev)
}
Expand Down
8 changes: 2 additions & 6 deletions parachain/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ use std::{
pub type FrontierBackend = fc_db::Backend<Block>;

pub fn db_config_dir(config: &Configuration) -> PathBuf {
let application = &config.impl_name;
config
.base_path
.as_ref()
.map(|base_path| base_path.config_dir(config.chain_spec.id()))
.unwrap_or_else(|| BasePath::from_project("", "", application).config_dir(config.chain_spec.id()))
let _application = &config.impl_name;
config.base_path.config_dir(config.chain_spec.id())
}

pub fn open_frontier_backend<C>(
Expand Down
4 changes: 4 additions & 0 deletions parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ where

let params = new_partial(&parachain_config, &eth_config, false)?;
let (mut telemetry, telemetry_worker_handle, frontier_backend, overrides) = params.other;
let net_config = sc_network::config::FullNetworkConfiguration::new(&parachain_config.network);

let client = params.client.clone();
let backend = params.backend.clone();
Expand All @@ -422,6 +423,7 @@ where
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &parachain_config,
net_config,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
Expand Down Expand Up @@ -697,10 +699,12 @@ where
transaction_pool,
other: (mut telemetry, _telemetry_worker_handle, frontier_backend, overrides),
} = new_partial::<RuntimeApi, Executor>(&config, &eth_config, true)?;
let net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);

let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
net_config,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
Expand Down

0 comments on commit 106e412

Please sign in to comment.