mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
ci: add quick-check with rustfmt (#615)
* ci: add quick-check with clippy and rustfmt * chore: rustfmt round * chore: set the same rustfmt config than substrate * chore: fix formatting * cI: remove clippy * ci: switch to nightly for the checks * ci: fix toolchains and naming * ci: Limit the check to formatting * chore: fix formatting * Update .rustfmt.toml * Update .rustfmt.toml Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -107,9 +107,7 @@ fn init_block_builder<'a>(
|
||||
)
|
||||
.expect("Put validation function params failed");
|
||||
|
||||
let inherents = block_builder
|
||||
.create_inherents(inherent_data)
|
||||
.expect("Creates inherents");
|
||||
let inherents = block_builder.create_inherents(inherent_data).expect("Creates inherents");
|
||||
|
||||
inherents
|
||||
.into_iter()
|
||||
@@ -138,10 +136,8 @@ impl InitBlockBuilder for Client {
|
||||
validation_data: Option<PersistedValidationData<PHash, PBlockNumber>>,
|
||||
relay_sproof_builder: RelayStateSproofBuilder,
|
||||
) -> BlockBuilder<Block, Client, Backend> {
|
||||
let last_timestamp = self
|
||||
.runtime_api()
|
||||
.get_last_timestamp(&at)
|
||||
.expect("Get last timestamp");
|
||||
let last_timestamp =
|
||||
self.runtime_api().get_last_timestamp(&at).expect("Get last timestamp");
|
||||
|
||||
let timestamp = last_timestamp + cumulus_test_runtime::MinimumPeriod::get();
|
||||
|
||||
|
||||
+5
-16
@@ -128,10 +128,8 @@ pub fn generate_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(),
|
||||
@@ -144,14 +142,7 @@ pub fn generate_extrinsic(
|
||||
let raw_payload = SignedPayload::from_raw(
|
||||
function.clone(),
|
||||
extra.clone(),
|
||||
(
|
||||
VERSION.spec_version,
|
||||
genesis_block,
|
||||
current_block_hash,
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
),
|
||||
(VERSION.spec_version, genesis_block, current_block_hash, (), (), ()),
|
||||
);
|
||||
let signature = raw_payload.using_encoded(|e| origin.sign(e));
|
||||
|
||||
@@ -170,10 +161,8 @@ pub fn transfer(
|
||||
dest: sp_keyring::AccountKeyring,
|
||||
value: Balance,
|
||||
) -> UncheckedExtrinsic {
|
||||
let function = Call::Balances(pallet_balances::Call::transfer {
|
||||
dest: dest.public().into(),
|
||||
value,
|
||||
});
|
||||
let function =
|
||||
Call::Balances(pallet_balances::Call::transfer { dest: dest.public().into(), value });
|
||||
|
||||
generate_extrinsic(client, origin, function)
|
||||
}
|
||||
|
||||
@@ -81,10 +81,7 @@ impl RelayStateSproofBuilder {
|
||||
}
|
||||
|
||||
self.hrmp_channels
|
||||
.entry(relay_chain::v1::HrmpChannelId {
|
||||
sender,
|
||||
recipient: self.para_id,
|
||||
})
|
||||
.entry(relay_chain::v1::HrmpChannelId { sender, recipient: self.para_id })
|
||||
.or_insert_with(|| AbridgedHrmpChannel {
|
||||
max_capacity: 0,
|
||||
max_total_size: 0,
|
||||
@@ -97,10 +94,7 @@ impl RelayStateSproofBuilder {
|
||||
|
||||
pub fn into_state_root_and_proof(
|
||||
self,
|
||||
) -> (
|
||||
polkadot_primitives::v1::Hash,
|
||||
sp_state_machine::StorageProof,
|
||||
) {
|
||||
) -> (polkadot_primitives::v1::Hash, sp_state_machine::StorageProof) {
|
||||
let (db, root) = MemoryDB::<HashFor<polkadot_primitives::v1::Block>>::default_with_root();
|
||||
let mut backend = sp_state_machine::TrieBackend::new(db, root);
|
||||
|
||||
@@ -113,10 +107,7 @@ impl RelayStateSproofBuilder {
|
||||
backend.insert(vec![(None, vec![(key, Some(value))])]);
|
||||
};
|
||||
|
||||
insert(
|
||||
relay_chain::well_known_keys::ACTIVE_CONFIG.to_vec(),
|
||||
self.host_config.encode(),
|
||||
);
|
||||
insert(relay_chain::well_known_keys::ACTIVE_CONFIG.to_vec(), self.host_config.encode());
|
||||
if let Some(dmq_mqc_head) = self.dmq_mqc_head {
|
||||
insert(
|
||||
relay_chain::well_known_keys::dmq_mqc_head(self.para_id),
|
||||
@@ -150,16 +141,10 @@ impl RelayStateSproofBuilder {
|
||||
);
|
||||
}
|
||||
for (channel, metadata) in self.hrmp_channels {
|
||||
insert(
|
||||
relay_chain::well_known_keys::hrmp_channels(channel),
|
||||
metadata.encode(),
|
||||
);
|
||||
insert(relay_chain::well_known_keys::hrmp_channels(channel), metadata.encode());
|
||||
}
|
||||
|
||||
insert(
|
||||
relay_chain::well_known_keys::CURRENT_SLOT.to_vec(),
|
||||
self.current_slot.encode(),
|
||||
);
|
||||
insert(relay_chain::well_known_keys::CURRENT_SLOT.to_vec(), self.current_slot.encode());
|
||||
}
|
||||
|
||||
let root = backend.root().clone();
|
||||
|
||||
@@ -27,7 +27,7 @@ const SKIP_ENV: &str = "SKIP_BUILD";
|
||||
|
||||
fn main() {
|
||||
if env::var(SKIP_ENV).is_ok() {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("`OUT_DIR` is set by cargo"));
|
||||
@@ -35,11 +35,8 @@ fn main() {
|
||||
let project = create_project(&out_dir);
|
||||
build_project(&project.join("Cargo.toml"));
|
||||
|
||||
fs::copy(
|
||||
project.join("target/release").join(PROJECT_NAME),
|
||||
out_dir.join(PROJECT_NAME),
|
||||
)
|
||||
.expect("Copies validation worker");
|
||||
fs::copy(project.join("target/release").join(PROJECT_NAME), out_dir.join(PROJECT_NAME))
|
||||
.expect("Copies validation worker");
|
||||
}
|
||||
|
||||
fn find_cargo_lock() -> PathBuf {
|
||||
@@ -49,7 +46,7 @@ fn find_cargo_lock() -> PathBuf {
|
||||
|
||||
loop {
|
||||
if path.join("Cargo.lock").exists() {
|
||||
return path.join("Cargo.lock");
|
||||
return path.join("Cargo.lock")
|
||||
}
|
||||
|
||||
if !path.pop() {
|
||||
@@ -109,7 +106,7 @@ fn build_project(cargo_toml: &Path) {
|
||||
.status();
|
||||
|
||||
match status.map(|s| s.success()) {
|
||||
Ok(true) => {}
|
||||
Ok(true) => {},
|
||||
// Use `process.exit(1)` to have a clean error output.
|
||||
_ => process::exit(1),
|
||||
}
|
||||
|
||||
@@ -113,10 +113,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 ~10% of the block weight is consumed by `on_initalize` handlers.
|
||||
@@ -421,11 +418,8 @@ impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
|
||||
) -> sp_inherents::CheckInherentsResult {
|
||||
if relay_state_proof.read_slot().expect("Reads slot") == 1337u64 {
|
||||
let mut res = sp_inherents::CheckInherentsResult::new();
|
||||
res.put_error(
|
||||
[1u8; 8],
|
||||
&sp_inherents::MakeFatalError::from("You are wrong"),
|
||||
)
|
||||
.expect("Puts error");
|
||||
res.put_error([1u8; 8], &sp_inherents::MakeFatalError::from("You are wrong"))
|
||||
.expect("Puts error");
|
||||
res
|
||||
} else {
|
||||
let relay_chain_slot = relay_state_proof
|
||||
|
||||
@@ -70,9 +70,7 @@ pub fn get_chain_spec(id: ParaId) -> ChainSpec {
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Extensions {
|
||||
para_id: id.into(),
|
||||
},
|
||||
Extensions { para_id: id.into() },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -110,11 +108,7 @@ fn testnet_genesis(
|
||||
},
|
||||
parachain_system: Default::default(),
|
||||
balances: cumulus_test_runtime::BalancesConfig {
|
||||
balances: endowed_accounts
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|k| (k, 1 << 60))
|
||||
.collect(),
|
||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||
},
|
||||
sudo: cumulus_test_runtime::SudoConfig { key: root_key },
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use codec::Encode;
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use cumulus_client_service::genesis::generate_genesis_block;
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use cumulus_test_runtime::Block;
|
||||
use polkadot_primitives::v0::HeadData;
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
|
||||
+38
-72
@@ -181,7 +181,7 @@ where
|
||||
+ 'static,
|
||||
{
|
||||
if matches!(parachain_config.role, Role::Light) {
|
||||
return Err("Light client not supported!".into());
|
||||
return Err("Light client not supported!".into())
|
||||
}
|
||||
|
||||
let mut parachain_config = prepare_node_config(parachain_config);
|
||||
@@ -274,37 +274,35 @@ where
|
||||
let relay_chain_client = relay_chain_full_node.client.clone();
|
||||
let relay_chain_backend = relay_chain_full_node.backend.clone();
|
||||
|
||||
Box::new(
|
||||
cumulus_client_consensus_relay_chain::RelayChainConsensus::new(
|
||||
para_id,
|
||||
proposer_factory,
|
||||
move |_, (relay_parent, validation_data)| {
|
||||
let parachain_inherent =
|
||||
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
|
||||
relay_parent,
|
||||
&*relay_chain_client,
|
||||
&*relay_chain_backend,
|
||||
&validation_data,
|
||||
para_id,
|
||||
);
|
||||
Box::new(cumulus_client_consensus_relay_chain::RelayChainConsensus::new(
|
||||
para_id,
|
||||
proposer_factory,
|
||||
move |_, (relay_parent, validation_data)| {
|
||||
let parachain_inherent =
|
||||
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
|
||||
relay_parent,
|
||||
&*relay_chain_client,
|
||||
&*relay_chain_backend,
|
||||
&validation_data,
|
||||
para_id,
|
||||
);
|
||||
|
||||
async move {
|
||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
async move {
|
||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
let parachain_inherent = parachain_inherent.ok_or_else(|| {
|
||||
Box::<dyn std::error::Error + Send + Sync>::from(String::from(
|
||||
"error",
|
||||
))
|
||||
})?;
|
||||
Ok((time, parachain_inherent))
|
||||
}
|
||||
},
|
||||
client.clone(),
|
||||
relay_chain_full_node.client.clone(),
|
||||
relay_chain_full_node.backend.clone(),
|
||||
),
|
||||
)
|
||||
}
|
||||
let parachain_inherent = parachain_inherent.ok_or_else(|| {
|
||||
Box::<dyn std::error::Error + Send + Sync>::from(String::from(
|
||||
"error",
|
||||
))
|
||||
})?;
|
||||
Ok((time, parachain_inherent))
|
||||
}
|
||||
},
|
||||
client.clone(),
|
||||
relay_chain_full_node.client.clone(),
|
||||
relay_chain_full_node.backend.clone(),
|
||||
))
|
||||
},
|
||||
Consensus::Null => Box::new(NullConsensus),
|
||||
};
|
||||
|
||||
@@ -466,8 +464,7 @@ impl TestNodeBuilder {
|
||||
mut self,
|
||||
nodes: impl IntoIterator<Item = &'a polkadot_test_service::PolkadotTestNode>,
|
||||
) -> Self {
|
||||
self.relay_chain_nodes
|
||||
.extend(nodes.into_iter().map(|n| n.addr.clone()));
|
||||
self.relay_chain_nodes.extend(nodes.into_iter().map(|n| n.addr.clone()));
|
||||
self
|
||||
}
|
||||
|
||||
@@ -501,8 +498,7 @@ impl TestNodeBuilder {
|
||||
/// Build the [`TestNode`].
|
||||
pub async fn build(self) -> TestNode {
|
||||
let parachain_config = node_config(
|
||||
self.storage_update_func_parachain
|
||||
.unwrap_or_else(|| Box::new(|| ())),
|
||||
self.storage_update_func_parachain.unwrap_or_else(|| Box::new(|| ())),
|
||||
self.tokio_handle.clone(),
|
||||
self.key.clone(),
|
||||
self.parachain_nodes,
|
||||
@@ -512,8 +508,7 @@ impl TestNodeBuilder {
|
||||
)
|
||||
.expect("could not generate Configuration");
|
||||
let mut relay_chain_config = polkadot_test_service::node_config(
|
||||
self.storage_update_func_relay_chain
|
||||
.unwrap_or_else(|| Box::new(|| ())),
|
||||
self.storage_update_func_relay_chain.unwrap_or_else(|| Box::new(|| ())),
|
||||
self.tokio_handle,
|
||||
self.key,
|
||||
self.relay_chain_nodes,
|
||||
@@ -539,13 +534,7 @@ impl TestNodeBuilder {
|
||||
let peer_id = network.local_peer_id().clone();
|
||||
let addr = MultiaddrWithPeerId { multiaddr, peer_id };
|
||||
|
||||
TestNode {
|
||||
task_manager,
|
||||
client,
|
||||
network,
|
||||
addr,
|
||||
rpc_handlers,
|
||||
}
|
||||
TestNode { task_manager, client, network, addr, rpc_handlers }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,18 +555,11 @@ pub fn node_config(
|
||||
) -> Result<Configuration, ServiceError> {
|
||||
let base_path = BasePath::new_temp_dir()?;
|
||||
let root = base_path.path().to_path_buf();
|
||||
let role = if is_collator {
|
||||
Role::Authority
|
||||
} else {
|
||||
Role::Full
|
||||
};
|
||||
let role = if is_collator { Role::Authority } else { Role::Full };
|
||||
let key_seed = key.to_seed();
|
||||
let mut spec = Box::new(chain_spec::get_chain_spec(para_id));
|
||||
|
||||
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);
|
||||
@@ -614,10 +596,7 @@ pub fn node_config(
|
||||
network: network_config,
|
||||
keystore: KeystoreConfig::InMemory,
|
||||
keystore_remote: Default::default(),
|
||||
database: DatabaseSource::RocksDb {
|
||||
path: root.join("db"),
|
||||
cache_size: 128,
|
||||
},
|
||||
database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 },
|
||||
state_cache_size: 67108864,
|
||||
state_cache_child_ratio: None,
|
||||
state_pruning: PruningMode::ArchiveAll,
|
||||
@@ -643,10 +622,7 @@ pub fn node_config(
|
||||
prometheus_config: None,
|
||||
telemetry_endpoints: None,
|
||||
default_heap_pages: None,
|
||||
offchain_worker: OffchainWorkerConfig {
|
||||
enabled: true,
|
||||
indexing_enabled: false,
|
||||
},
|
||||
offchain_worker: OffchainWorkerConfig { enabled: true, indexing_enabled: false },
|
||||
force_authoring: false,
|
||||
disable_grandpa: false,
|
||||
dev_key_seed: Some(key_seed),
|
||||
@@ -685,10 +661,7 @@ impl TestNode {
|
||||
let call = frame_system::Call::set_code { code: validation };
|
||||
|
||||
self.send_extrinsic(
|
||||
runtime::SudoCall::sudo_unchecked_weight {
|
||||
call: Box::new(call.into()),
|
||||
weight: 1_000,
|
||||
},
|
||||
runtime::SudoCall::sudo_unchecked_weight { call: Box::new(call.into()), weight: 1_000 },
|
||||
Sr25519Keyring::Alice,
|
||||
)
|
||||
.await
|
||||
@@ -726,14 +699,7 @@ pub fn construct_extrinsic(
|
||||
let raw_payload = runtime::SignedPayload::from_raw(
|
||||
function.clone(),
|
||||
extra.clone(),
|
||||
(
|
||||
runtime::VERSION.spec_version,
|
||||
genesis_block,
|
||||
current_block_hash,
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
),
|
||||
(runtime::VERSION.spec_version, genesis_block, current_block_hash, (), (), ()),
|
||||
);
|
||||
let signature = raw_payload.using_encoded(|e| caller.sign(e));
|
||||
runtime::UncheckedExtrinsic::new_signed(
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use cumulus_test_service::{initial_head_data, run_relay_chain_validator_node, Keyring::*};
|
||||
use futures::{join, StreamExt};
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sc_client_api::BlockchainEvents;
|
||||
use sp_runtime::generic::BlockId;
|
||||
|
||||
#[substrate_test_utils::test]
|
||||
#[ignore]
|
||||
@@ -95,7 +95,7 @@ async fn test_runtime_upgrade() {
|
||||
.expect("Runtime version exists");
|
||||
|
||||
if expected_runtime_version == runtime_version {
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user