cargo +nightly fmt (#3540)

* cargo +nightly fmt

* add cargo-fmt check to ci

* update ci

* fmt

* fmt

* skip macro

* ignore bridges
This commit is contained in:
Shawn Tabrizi
2021-08-02 12:47:33 +02:00
committed by GitHub
parent 30e3012270
commit ff5d56fb76
350 changed files with 20617 additions and 21266 deletions
+6 -22
View File
@@ -16,14 +16,14 @@
//! Chain specifications for the test runtime.
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use babe_primitives::AuthorityId as BabeId;
use grandpa::AuthorityId as GrandpaId;
use pallet_staking::Forcing;
use polkadot_primitives::v1::{ValidatorId, AccountId, AssignmentId, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_primitives::v1::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions};
use polkadot_test_runtime::{constants::currency::DOTS, BABE_GENESIS_EPOCH_CONFIG};
use sc_chain_spec::{ChainSpec, ChainType};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_core::sr25519;
use sp_runtime::Perbill;
@@ -51,10 +51,7 @@ pub fn polkadot_local_testnet_config() -> PolkadotChainSpec {
/// Local testnet genesis config (multivalidator Alice + Bob)
pub fn polkadot_local_testnet_genesis() -> polkadot_test_runtime::GenesisConfig {
polkadot_testnet_genesis(
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
vec![get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
@@ -120,10 +117,7 @@ fn polkadot_testnet_genesis(
},
indices: runtime::IndicesConfig { indices: vec![] },
balances: runtime::BalancesConfig {
balances: endowed_accounts
.iter()
.map(|k| (k.clone(), ENDOWMENT))
.collect(),
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
},
session: runtime::SessionConfig {
keys: initial_authorities
@@ -148,14 +142,7 @@ fn polkadot_testnet_genesis(
validator_count: 2,
stakers: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.1.clone(),
STASH,
runtime::StakerStatus::Validator,
)
})
.map(|x| (x.0.clone(), x.1.clone(), STASH, runtime::StakerStatus::Validator))
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::NotForcing,
@@ -168,10 +155,7 @@ fn polkadot_testnet_genesis(
},
grandpa: Default::default(),
authority_discovery: runtime::AuthorityDiscoveryConfig { keys: vec![] },
claims: runtime::ClaimsConfig {
claims: vec![],
vesting: vec![],
},
claims: runtime::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: runtime::VestingConfig { vesting: vec![] },
sudo: runtime::SudoConfig { key: root_key },
parachains_configuration: runtime::ParachainsConfigurationConfig {
+37 -78
View File
@@ -22,20 +22,17 @@ pub mod chain_spec;
pub use chain_spec::*;
use futures::future::Future;
use polkadot_node_primitives::{CollationGenerationConfig, CollatorFn};
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
use polkadot_overseer::Handle;
use polkadot_primitives::v1::{
Id as ParaId, HeadData, ValidationCode, Balance, CollatorPair,
};
use polkadot_primitives::v1::{Balance, CollatorPair, HeadData, Id as ParaId, ValidationCode};
use polkadot_runtime_common::BlockHashCount;
use polkadot_service::{
Error, NewFull, FullClient, ClientHandle, ExecuteWithClient, IsCollator,
};
use polkadot_node_subsystem::messages::{CollatorProtocolMessage, CollationGenerationMessage};
use polkadot_test_runtime::{
Runtime, SignedExtra, SignedPayload, VERSION, ParasSudoWrapperCall, SudoCall, UncheckedExtrinsic,
};
use polkadot_node_primitives::{CollatorFn, CollationGenerationConfig};
use polkadot_runtime_parachains::paras::ParaGenesisArgs;
use polkadot_service::{ClientHandle, Error, ExecuteWithClient, FullClient, IsCollator, NewFull};
use polkadot_test_runtime::{
ParasSudoWrapperCall, Runtime, SignedExtra, SignedPayload, SudoCall, UncheckedExtrinsic,
VERSION,
};
use sc_chain_spec::ChainSpec;
use sc_client_api::execution_extensions::ExecutionStrategies;
use sc_executor::native_executor_instance;
@@ -45,16 +42,18 @@ use sc_network::{
};
use service::{
config::{DatabaseConfig, KeystoreConfig, MultiaddrWithPeerId, WasmExecutionMethod},
RpcHandlers, TaskExecutor, TaskManager, KeepBlocks, TransactionStorageMode,
BasePath, Configuration, KeepBlocks, Role, RpcHandlers, TaskExecutor, TaskManager,
TransactionStorageMode,
};
use service::{BasePath, Configuration, Role};
use sp_arithmetic::traits::SaturatedConversion;
use sp_blockchain::HeaderBackend;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{codec::Encode, generic, traits::IdentifyAccount, MultiSigner};
use sp_state_machine::BasicExternalities;
use std::{sync::Arc, path::PathBuf};
use substrate_test_client::{BlockchainEventsExt, RpcHandlersExt, RpcTransactionOutput, RpcTransactionError};
use std::{path::PathBuf, sync::Arc};
use substrate_test_client::{
BlockchainEventsExt, RpcHandlersExt, RpcTransactionError, RpcTransactionOutput,
};
native_executor_instance!(
pub PolkadotTestExecutor,
@@ -74,10 +73,7 @@ pub fn new_full(
config: Configuration,
is_collator: IsCollator,
worker_program_path: Option<PathBuf>,
) -> Result<
NewFull<Arc<Client>>,
Error,
> {
) -> Result<NewFull<Arc<Client>>, Error> {
polkadot_service::new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor, _>(
config,
is_collator,
@@ -115,17 +111,10 @@ pub fn node_config(
) -> Configuration {
let base_path = BasePath::new_temp_dir().expect("could not create temporary directory");
let root = base_path.path();
let role = if is_validator {
Role::Authority
} else {
Role::Full
};
let role = if is_validator { Role::Authority } else { Role::Full };
let key_seed = key.to_seed();
let mut spec = polkadot_local_testnet_config();
let mut storage = spec
.as_storage_builder()
.build_storage()
.expect("could not build storage");
let mut storage = spec.as_storage_builder().build_storage().expect("could not build storage");
BasicExternalities::execute_with_storage(&mut storage, storage_update_func);
spec.set_storage(storage);
@@ -142,13 +131,9 @@ pub fn node_config(
network_config.allow_non_globals_in_dht = true;
let addr: multiaddr::Multiaddr = multiaddr::Protocol::Memory(rand::random()).into();
network_config
.listen_addresses
.push(addr.clone());
network_config.listen_addresses.push(addr.clone());
network_config
.public_addresses
.push(addr);
network_config.public_addresses.push(addr);
network_config.transport = TransportConfig::MemoryOnly;
@@ -161,10 +146,7 @@ pub fn node_config(
network: network_config,
keystore: KeystoreConfig::InMemory,
keystore_remote: Default::default(),
database: DatabaseConfig::RocksDb {
path: root.join("db"),
cache_size: 128,
},
database: DatabaseConfig::RocksDb { path: root.join("db"), cache_size: 128 },
state_cache_size: 16777216,
state_cache_child_ratio: None,
state_pruning: Default::default(),
@@ -224,19 +206,14 @@ pub fn run_validator_node(
let config = node_config(storage_update_func, task_executor, key, boot_nodes, true);
let multiaddr = config.network.listen_addresses[0].clone();
let NewFull { task_manager, client, network, rpc_handlers, overseer_handle, .. } =
new_full(config, IsCollator::No, worker_program_path).expect("could not create Polkadot test service");
new_full(config, IsCollator::No, worker_program_path)
.expect("could not create Polkadot test service");
let overseer_handle = overseer_handle.expect("test node must have an overseer handle");
let peer_id = network.local_peer_id().clone();
let addr = MultiaddrWithPeerId { multiaddr, peer_id };
PolkadotTestNode {
task_manager,
client,
overseer_handle,
addr,
rpc_handlers,
}
PolkadotTestNode { task_manager, client, overseer_handle, addr, rpc_handlers }
}
/// Run a test collator node that uses the test runtime.
@@ -260,27 +237,15 @@ pub fn run_collator_node(
) -> PolkadotTestNode {
let config = node_config(storage_update_func, task_executor, key, boot_nodes, false);
let multiaddr = config.network.listen_addresses[0].clone();
let NewFull {
task_manager,
client,
network,
rpc_handlers,
overseer_handle,
..
} = new_full(config, IsCollator::Yes(collator_pair), None)
.expect("could not create Polkadot test service");
let NewFull { task_manager, client, network, rpc_handlers, overseer_handle, .. } =
new_full(config, IsCollator::Yes(collator_pair), None)
.expect("could not create Polkadot test service");
let overseer_handle = overseer_handle.expect("test node must have an overseer handle");
let peer_id = network.local_peer_id().clone();
let addr = MultiaddrWithPeerId { multiaddr, peer_id };
PolkadotTestNode {
task_manager,
client,
overseer_handle,
addr,
rpc_handlers,
}
PolkadotTestNode { task_manager, client, overseer_handle, addr, rpc_handlers }
}
/// A Polkadot test node instance used for testing.
@@ -325,7 +290,9 @@ impl PolkadotTestNode {
},
);
self.send_extrinsic(SudoCall::sudo(Box::new(call.into())), Sr25519Keyring::Alice).await.map(drop)
self.send_extrinsic(SudoCall::sudo(Box::new(call.into())), Sr25519Keyring::Alice)
.await
.map(drop)
}
/// Wait for `count` blocks to be imported in the node and then exit. This function will not return if no blocks
@@ -341,11 +308,7 @@ impl PolkadotTestNode {
para_id: ParaId,
collator: CollatorFn,
) {
let config = CollationGenerationConfig {
key: collator_key,
collator,
para_id,
};
let config = CollationGenerationConfig { key: collator_key, collator, para_id };
self.overseer_handle
.send_msg(CollationGenerationMessage::Initialize(config), "Collator")
@@ -368,10 +331,8 @@ pub fn construct_extrinsic(
let current_block = client.info().best_number.saturated_into();
let genesis_block = client.hash(0).unwrap().unwrap();
let nonce = 0;
let period = BlockHashCount::get()
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let period =
BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
let tip = 0;
let extra: SignedExtra = (
frame_system::CheckSpecVersion::<Runtime>::new(),
@@ -411,12 +372,10 @@ pub fn construct_transfer_extrinsic(
dest: sp_keyring::AccountKeyring,
value: Balance,
) -> UncheckedExtrinsic {
let function = polkadot_test_runtime::Call::Balances(
pallet_balances::Call::transfer(
MultiSigner::from(dest.public()).into_account().into(),
value,
),
);
let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer(
MultiSigner::from(dest.public()).into_account().into(),
value,
));
construct_extrinsic(client, function, origin)
}