Skip to content

Commit

Permalink
Unify formatting with cumulus and encointer (#71)
Browse files Browse the repository at this point in the history
* unify rustfmt with encointer for simpler diff

* cargo fmt

* unify paritytech/cumulus.git -> paritytech/cumulus
  • Loading branch information
clangenb authored Feb 11, 2022
1 parent 492bfc1 commit f3be167
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 186 deletions.
25 changes: 23 additions & 2 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
hard_tabs=true
imports_granularity= "Crate"
# Basic
hard_tabs = true
max_width = 100
use_small_heuristics = "Max"

# Imports
imports_granularity = "Crate"
reorder_imports = true

# Consistency
newline_style = "Unix"

# Misc
binop_separator = "Back"
chain_width = 80
match_arm_blocks = false
match_arm_leading_pipes = "Preserve"
match_block_trailing_comma = true
reorder_impl_items = false
spaces_around_ranges = false
trailing_comma = "Vertical"
trailing_semicolon = false
use_field_init_shorthand = true
18 changes: 9 additions & 9 deletions polkadot-parachains/integritee-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = '2021'
serde = { version = "1.0.132", default-features = false, optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "2.3.1", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
parachain-info = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }

# Substrate dependencies
Expand Down Expand Up @@ -43,14 +43,14 @@ pallet-aura = { git = "https://github.com/paritytech/substrate", default-feature
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16" }

# Cumulus dependencies
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }

# Polkadot dependencies
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.16" }
Expand Down
5 changes: 1 addition & 4 deletions polkadot-parachains/integritee-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion {
runtime_version: VERSION,
can_author_with: Default::default(),
}
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}

/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers.
Expand Down
16 changes: 8 additions & 8 deletions polkadot-parachains/shell-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = '2021'
serde = { version = "1.0.132", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "2.3.1", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
parachain-info = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }

# Substrate dependencies
Expand Down Expand Up @@ -43,13 +43,13 @@ pallet-vesting = { git = "https://github.com/paritytech/substrate", default-feat
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.16" }

# Cumulus dependencies
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.16", default-features = false }

# Polkadot dependencies
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.16" }
Expand Down
5 changes: 1 addition & 4 deletions polkadot-parachains/shell-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion {
runtime_version: VERSION,
can_author_with: Default::default(),
}
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}

/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers.
Expand Down
49 changes: 13 additions & 36 deletions polkadot-parachains/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,10 @@ pub fn shell_chain_spec(
relay_chain: RelayChain,
) -> ShellChainSpec {
let (root, endowed, authorities) = match genesis_keys {
GenesisKeys::Integritee => (
IntegriteeKeys::root(),
vec![IntegriteeKeys::root()],
IntegriteeKeys::authorities(),
),
GenesisKeys::WellKnown => (
WellKnownKeys::root(),
WellKnownKeys::endowed(),
WellKnownKeys::authorities(),
),
GenesisKeys::Integritee =>
(IntegriteeKeys::root(), vec![IntegriteeKeys::root()], IntegriteeKeys::authorities()),
GenesisKeys::WellKnown =>
(WellKnownKeys::root(), WellKnownKeys::endowed(), WellKnownKeys::authorities()),
};

let chain_name = "Integritee Shell".to_string();
Expand All @@ -138,16 +132,10 @@ pub fn integritee_chain_spec(
relay_chain: RelayChain,
) -> IntegriteeChainSpec {
let (root, endowed, authorities) = match genesis_keys {
GenesisKeys::Integritee => (
IntegriteeKeys::root(),
vec![IntegriteeKeys::root()],
IntegriteeKeys::authorities(),
),
GenesisKeys::WellKnown => (
WellKnownKeys::root(),
WellKnownKeys::endowed(),
WellKnownKeys::authorities(),
),
GenesisKeys::Integritee =>
(IntegriteeKeys::root(), vec![IntegriteeKeys::root()], IntegriteeKeys::authorities()),
GenesisKeys::WellKnown =>
(WellKnownKeys::root(), WellKnownKeys::endowed(), WellKnownKeys::authorities()),
};

let chain_name = "Integritee Network".to_string();
Expand Down Expand Up @@ -191,10 +179,7 @@ fn chain_spec<F: Fn() -> GenesisConfig + 'static + Send + Sync, GenesisConfig>(
)
.unwrap(),
),
Extensions {
relay_chain: relay_chain.into(),
para_id: para_id.into(),
},
Extensions { relay_chain: relay_chain.into(), para_id: para_id.into() },
)
}

Expand All @@ -217,14 +202,10 @@ fn integritee_genesis_config(
.map(|k| (k, 10_000_000__000_000_000_000))
.collect(),
},
sudo: parachain_runtime::SudoConfig {
key: Some(root_key),
},
sudo: parachain_runtime::SudoConfig { key: Some(root_key) },
vesting: Default::default(),
parachain_info: parachain_runtime::ParachainInfoConfig { parachain_id: id },
aura: parachain_runtime::AuraConfig {
authorities: initial_authorities,
},
aura: parachain_runtime::AuraConfig { authorities: initial_authorities },
aura_ext: Default::default(),
parachain_system: Default::default(),
}
Expand All @@ -249,15 +230,11 @@ fn shell_genesis_config(
.map(|k| (k, 10_000_000__000_000_000_000))
.collect(),
},
sudo: shell_runtime::SudoConfig {
key: Some(root_key),
},
sudo: shell_runtime::SudoConfig { key: Some(root_key) },
vesting: Default::default(),
parachain_info: shell_runtime::ParachainInfoConfig { parachain_id },
parachain_system: Default::default(),
aura: shell_runtime::AuraConfig {
authorities: initial_authorities,
},
aura: shell_runtime::AuraConfig { authorities: initial_authorities },
aura_ext: Default::default(),
}
}
Expand Down
11 changes: 2 additions & 9 deletions polkadot-parachains/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,7 @@ 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"));
Self {
base_path,
chain_id,
base: polkadot_cli::RunCmd::from_iter(relay_chain_args),
}
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot"));
Self { base_path, chain_id, base: polkadot_cli::RunCmd::from_iter(relay_chain_args) }
}
}
42 changes: 14 additions & 28 deletions polkadot-parachains/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,27 @@ pub fn run() -> Result<()> {
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
}
},
Some(Subcommand::CheckBlock(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.import_queue))
})
}
},
Some(Subcommand::ExportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, config.database))
})
}
},
Some(Subcommand::ExportState(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, config.chain_spec))
})
}
},
Some(Subcommand::ImportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.import_queue))
})
}
},
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;

Expand All @@ -283,7 +283,7 @@ pub fn run() -> Result<()> {

cmd.run(config, polkadot_config)
})
}
},
Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.backend))
}),
Expand All @@ -310,7 +310,7 @@ pub fn run() -> Result<()> {
}

Ok(())
}
},
Some(Subcommand::ExportGenesisWasm(params)) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
Expand All @@ -331,8 +331,8 @@ pub fn run() -> Result<()> {
}

Ok(())
}
Some(Subcommand::Benchmark(cmd)) => {
},
Some(Subcommand::Benchmark(cmd)) =>
if cfg!(feature = "runtime-benchmarks") {
let runner = cli.create_runner(cmd)?;
if runner.config().chain_spec.is_shell() {
Expand All @@ -347,8 +347,7 @@ pub fn run() -> Result<()> {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
}
}
},
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
None => {
let runner = cli.create_runner(&cli.run.normalize())?;
Expand Down Expand Up @@ -386,14 +385,7 @@ pub fn run() -> Result<()> {
info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
info!("Parachain genesis state: {}", genesis_state);
info!(
"Is collating: {}",
if config.role.is_authority() {
"yes"
} else {
"no"
}
);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });

if config.chain_spec.is_shell() {
crate::service::start_parachain_node::<
Expand All @@ -415,7 +407,7 @@ pub fn run() -> Result<()> {
.map_err(Into::into)
}
})
}
},
}
}

Expand Down Expand Up @@ -478,9 +470,7 @@ impl CliConfiguration<Self> for RelayChainCli {
default_listen_port: u16,
chain_spec: &Box<dyn ChainSpec>,
) -> Result<Option<PrometheusConfig>> {
self.base
.base
.prometheus_config(default_listen_port, chain_spec)
self.base.base.prometheus_config(default_listen_port, chain_spec)
}

fn init<F>(
Expand All @@ -499,11 +489,7 @@ impl CliConfiguration<Self> for RelayChainCli {
fn chain_id(&self, is_dev: bool) -> Result<String> {
let chain_id = self.base.base.chain_id(is_dev)?;

Ok(if chain_id.is_empty() {
self.chain_id.clone().unwrap_or_default()
} else {
chain_id
})
Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id })
}

fn role(&self, is_dev: bool) -> Result<sc_service::Role> {
Expand Down
16 changes: 3 additions & 13 deletions polkadot-parachains/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,10 @@ where
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};

let mut io = jsonrpc_core::IoHandler::default();
let FullDeps {
client,
pool,
deny_unsafe,
} = deps;
let FullDeps { client, pool, deny_unsafe } = deps;

io.extend_with(SystemApi::to_delegate(FullSystem::new(
client.clone(),
pool,
deny_unsafe,
)));
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
client.clone(),
)));
io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe)));
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone())));

io
}
Loading

0 comments on commit f3be167

Please sign in to comment.