Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clippy and update Rust #299

Merged
merged 11 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
RUST_STABLE_VERSION=1.76.0
RUST_NIGHTLY_VERSION=2024-03-14
RUST_STABLE_VERSION=1.77.0
RUST_NIGHTLY_VERSION=2024-04-14
1 change: 1 addition & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ jobs:
- name: Clippy
run: cargo +nightly-$RUST_NIGHTLY_VERSION clippy --all-targets --locked -q
env:
RUSTFLAGS: "-D warnings"
SKIP_WASM_BUILD: 1
2 changes: 1 addition & 1 deletion chain-spec-generator/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct EmptyChainSpecWithId {

pub fn from_json_file(filepath: &str, supported: String) -> Result<Box<dyn ChainSpec>, String> {
let path = std::path::PathBuf::from(&filepath);
let file = std::fs::File::open(&filepath).expect("Failed to open file");
let file = std::fs::File::open(filepath).expect("Failed to open file");
let reader = std::io::BufReader::new(file);
let chain_spec: EmptyChainSpecWithId = serde_json::from_reader(reader)
.expect("Failed to read 'json' file with ChainSpec configuration");
Expand Down
40 changes: 14 additions & 26 deletions chain-spec-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,63 +38,51 @@ fn main() -> Result<(), String> {

let supported_chains =
HashMap::<_, Box<dyn Fn() -> Result<Box<dyn ChainSpec>, String>>>::from([
(
"polkadot-dev",
Box::new(|| relay_chain_specs::polkadot_development_config()) as Box<_>,
),
("polkadot-dev", Box::new(relay_chain_specs::polkadot_development_config) as Box<_>),
(
"polkadot-local",
Box::new(|| relay_chain_specs::polkadot_local_testnet_config()) as Box<_>,
),
("kusama-dev", Box::new(|| relay_chain_specs::kusama_development_config()) as Box<_>),
(
"kusama-local",
Box::new(|| relay_chain_specs::kusama_local_testnet_config()) as Box<_>,
Box::new(relay_chain_specs::polkadot_local_testnet_config) as Box<_>,
),
("kusama-dev", Box::new(relay_chain_specs::kusama_development_config) as Box<_>),
("kusama-local", Box::new(relay_chain_specs::kusama_local_testnet_config) as Box<_>),
(
"asset-hub-kusama-local",
Box::new(|| system_parachains_specs::asset_hub_kusama_local_testnet_config())
as Box<_>,
Box::new(system_parachains_specs::asset_hub_kusama_local_testnet_config) as Box<_>,
),
(
"asset-hub-polkadot-local",
Box::new(|| system_parachains_specs::asset_hub_polkadot_local_testnet_config())
Box::new(system_parachains_specs::asset_hub_polkadot_local_testnet_config)
as Box<_>,
),
(
"collectives-polkadot-local",
Box::new(|| system_parachains_specs::collectives_polkadot_local_testnet_config())
Box::new(system_parachains_specs::collectives_polkadot_local_testnet_config)
as Box<_>,
),
(
"bridge-hub-polkadot-local",
Box::new(|| system_parachains_specs::bridge_hub_polkadot_local_testnet_config())
Box::new(system_parachains_specs::bridge_hub_polkadot_local_testnet_config)
as Box<_>,
),
(
"bridge-hub-kusama-local",
Box::new(|| system_parachains_specs::bridge_hub_kusama_local_testnet_config())
as Box<_>,
Box::new(system_parachains_specs::bridge_hub_kusama_local_testnet_config) as Box<_>,
),
(
"glutton-kusama-local",
Box::new(|| system_parachains_specs::glutton_kusama_local_testnet_config())
as Box<_>,
Box::new(system_parachains_specs::glutton_kusama_local_testnet_config) as Box<_>,
),
(
"encointer-kusama-local",
Box::new(|| system_parachains_specs::encointer_kusama_local_testnet_config())
as Box<_>,
Box::new(system_parachains_specs::encointer_kusama_local_testnet_config) as Box<_>,
),
(
"coretime-kusama-local",
Box::new(|| system_parachains_specs::coretime_kusama_local_testnet_config())
as Box<_>,
Box::new(system_parachains_specs::coretime_kusama_local_testnet_config) as Box<_>,
),
(
"people-kusama-local",
Box::new(|| system_parachains_specs::people_kusama_local_testnet_config())
as Box<_>,
Box::new(system_parachains_specs::people_kusama_local_testnet_config) as Box<_>,
),
]);

Expand All @@ -104,7 +92,7 @@ fn main() -> Result<(), String> {
Ok(())
} else {
let supported = supported_chains.keys().enumerate().fold(String::new(), |c, (n, k)| {
let extra = (n + 1 < supported_chains.len()).then(|| ", ").unwrap_or("");
let extra = if n + 1 < supported_chains.len() { ", " } else { "" };
format!("{c}{k}{extra}")
});
if cli.chain.ends_with(".json") {
Expand Down
2 changes: 2 additions & 0 deletions chain-spec-generator/src/relay_chain_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ fn testnet_accounts() -> Vec<AccountId> {
]
}

#[allow(clippy::type_complexity)]
pub fn polkadot_testnet_genesis(
initial_authorities: Vec<(
AccountId,
Expand Down Expand Up @@ -242,6 +243,7 @@ pub fn polkadot_testnet_genesis(
})
}

#[allow(clippy::type_complexity)]
pub fn kusama_testnet_genesis(
initial_authorities: Vec<(
AccountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ mod validators {
use super::*;
use parachains_common::AccountId;

#[allow(clippy::type_complexity)]
pub fn initial_authorities() -> Vec<(
AccountId,
AccountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ mod validators {
use super::*;
use parachains_common::AccountId;

#[allow(clippy::type_complexity)]
pub fn initial_authorities() -> Vec<(
AccountId,
AccountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) {
RuntimeEvent::Balances(
pallet_balances::Event::Burned { who, amount }
) => {
who: *who == sov_penpal_on_ahk.clone().into(),
who: *who == sov_penpal_on_ahk.clone(),
amount: *amount == t.args.amount,
},
RuntimeEvent::Balances(pallet_balances::Event::Minted { .. }) => {},
Expand Down Expand Up @@ -267,7 +267,7 @@ fn para_to_para_limited_reserve_transfer_assets(t: ParaToParaTest) -> DispatchRe
/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work
#[test]
fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
let signed_origin = <Kusama as Chain>::RuntimeOrigin::signed(KusamaSender::get().into());
let signed_origin = <Kusama as Chain>::RuntimeOrigin::signed(KusamaSender::get());
let destination = Kusama::child_location_of(AssetHubKusama::para_id());
let beneficiary: Location =
AccountId32Junction { network: None, id: AssetHubKusamaReceiver::get().into() }.into();
Expand Down Expand Up @@ -301,7 +301,7 @@ fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
fn reserve_transfer_native_asset_from_system_para_to_relay_fails() {
// Init values for System Parachain
let signed_origin =
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get().into());
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get());
let destination = AssetHubKusama::parent_location();
let beneficiary_id = KusamaReceiver::get();
let beneficiary: Location =
Expand Down Expand Up @@ -444,7 +444,7 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
let sov_penpal_on_ahk = AssetHubKusama::sovereign_account_id_of(penpal_location_as_seen_by_ahk);

// fund the Penpal's SA on AHK with the native tokens held in reserve
AssetHubKusama::fund_accounts(vec![(sov_penpal_on_ahk.into(), amount_to_send * 2)]);
AssetHubKusama::fund_accounts(vec![(sov_penpal_on_ahk, amount_to_send * 2)]);

test.set_assertion::<PenpalA>(para_to_system_para_sender_assertions);
test.set_assertion::<AssetHubKusama>(para_to_system_para_receiver_assertions);
Expand Down Expand Up @@ -527,7 +527,7 @@ fn reserve_transfer_assets_from_system_para_to_para() {
// Create SA-of-Penpal-on-AHK with ED.
let penpal_location = AssetHubKusama::sibling_location_of(PenpalA::para_id());
let sov_penpal_on_ahk = AssetHubKusama::sovereign_account_id_of(penpal_location);
AssetHubKusama::fund_accounts(vec![(sov_penpal_on_ahk.into(), KUSAMA_ED)]);
AssetHubKusama::fund_accounts(vec![(sov_penpal_on_ahk, KUSAMA_ED)]);

let sender_balance_before = test.sender.balance;
let receiver_balance_before = test.receiver.balance;
Expand Down Expand Up @@ -598,7 +598,7 @@ fn reserve_transfer_native_asset_from_para_to_para() {
let sov_of_sender_on_relay = Kusama::sovereign_account_id_of(sender_as_seen_by_relay);

// fund the PenpalA's SA on Kusama with the native tokens held in reserve
Kusama::fund_accounts(vec![(sov_of_sender_on_relay.into(), amount_to_send * 2)]);
Kusama::fund_accounts(vec![(sov_of_sender_on_relay, amount_to_send * 2)]);

test.set_assertion::<PenpalA>(para_to_para_sender_assertions);
test.set_assertion::<Kusama>(para_to_para_relay_hop_assertions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn send_transact_as_superuser_from_relay_to_system_para_works() {
ASSET_ID,
ASSET_MIN_BALANCE,
true,
AssetHubKusamaSender::get().into(),
AssetHubKusamaSender::get(),
Some(Weight::from_parts(1_019_445_000, 200_000)),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
RuntimeEvent::Balances(
pallet_balances::Event::Burned { who, amount }
) => {
who: *who == sov_penpal_on_ahk.clone().into(),
who: *who == sov_penpal_on_ahk.clone(),
amount: *amount == t.args.amount,
},
RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. }) => {
Expand Down Expand Up @@ -383,8 +383,8 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() {
fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
// Init values for Relay Chain
let amount_to_send: Balance = ASSET_HUB_KUSAMA_ED * 1000;
let destination = AssetHubKusama::parent_location().into();
let beneficiary_id = KusamaReceiver::get().into();
let destination = AssetHubKusama::parent_location();
let beneficiary_id = KusamaReceiver::get();
let assets = (Parent, amount_to_send).into();

let test_args = TestContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use crate::*;
use emulated_integration_tests_common::accounts::{ALICE, BOB};
use frame_support::traits::fungibles::{Create, Inspect, Mutate};
use frame_support::traits::fungibles::{Create, Mutate};
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use xcm_executor::traits::ConvertLocation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) {
RuntimeEvent::Balances(
pallet_balances::Event::Burned { who, amount }
) => {
who: *who == sov_penpal_on_ahp.clone().into(),
who: *who == sov_penpal_on_ahp.clone(),
amount: *amount == t.args.amount,
},
RuntimeEvent::Balances(pallet_balances::Event::Minted { .. }) => {},
Expand Down Expand Up @@ -267,7 +267,7 @@ fn para_to_para_limited_reserve_transfer_assets(t: ParaToParaTest) -> DispatchRe
/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work
#[test]
fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
let signed_origin = <Polkadot as Chain>::RuntimeOrigin::signed(PolkadotSender::get().into());
let signed_origin = <Polkadot as Chain>::RuntimeOrigin::signed(PolkadotSender::get());
let destination = Polkadot::child_location_of(AssetHubPolkadot::para_id());
let beneficiary: Location =
AccountId32Junction { network: None, id: AssetHubPolkadotReceiver::get().into() }.into();
Expand Down Expand Up @@ -301,7 +301,7 @@ fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
fn reserve_transfer_native_asset_from_system_para_to_relay_fails() {
// Init values for System Parachain
let signed_origin =
<AssetHubPolkadot as Chain>::RuntimeOrigin::signed(AssetHubPolkadotSender::get().into());
<AssetHubPolkadot as Chain>::RuntimeOrigin::signed(AssetHubPolkadotSender::get());
let destination = AssetHubPolkadot::parent_location();
let beneficiary_id = PolkadotReceiver::get();
let beneficiary: Location =
Expand Down Expand Up @@ -445,7 +445,7 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
AssetHubPolkadot::sovereign_account_id_of(penpal_location_as_seen_by_ahp);

// fund the Penpal's SA on AHP with the native tokens held in reserve
AssetHubPolkadot::fund_accounts(vec![(sov_penpal_on_ahp.into(), amount_to_send * 2)]);
AssetHubPolkadot::fund_accounts(vec![(sov_penpal_on_ahp, amount_to_send * 2)]);

test.set_assertion::<PenpalB>(para_to_system_para_sender_assertions);
test.set_assertion::<AssetHubPolkadot>(para_to_system_para_receiver_assertions);
Expand Down Expand Up @@ -528,7 +528,7 @@ fn reserve_transfer_assets_from_system_para_to_para() {
// Create SA-of-Penpal-on-AHP with ED.
let penpal_location = AssetHubPolkadot::sibling_location_of(PenpalB::para_id());
let sov_penpal_on_ahp = AssetHubPolkadot::sovereign_account_id_of(penpal_location);
AssetHubPolkadot::fund_accounts(vec![(sov_penpal_on_ahp.into(), POLKADOT_ED)]);
AssetHubPolkadot::fund_accounts(vec![(sov_penpal_on_ahp, POLKADOT_ED)]);

let sender_balance_before = test.sender.balance;
let receiver_balance_before = test.receiver.balance;
Expand Down Expand Up @@ -599,7 +599,7 @@ fn reserve_transfer_native_asset_from_para_to_para() {
let sov_of_sender_on_relay = Polkadot::sovereign_account_id_of(sender_as_seen_by_relay);

// fund the PenpalB's SA on Polkadot with the native tokens held in reserve
Polkadot::fund_accounts(vec![(sov_of_sender_on_relay.into(), amount_to_send * 2)]);
Polkadot::fund_accounts(vec![(sov_of_sender_on_relay, amount_to_send * 2)]);

test.set_assertion::<PenpalB>(para_to_para_sender_assertions);
test.set_assertion::<Polkadot>(para_to_para_relay_hop_assertions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn send_transact_as_superuser_from_relay_to_system_para_works() {
ASSET_ID,
ASSET_MIN_BALANCE,
true,
AssetHubPolkadotSender::get().into(),
AssetHubPolkadotSender::get(),
Some(Weight::from_parts(1_019_445_000, 200_000)),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use crate::*;
use polkadot_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub;
use sp_runtime::ModuleError;
use system_parachains_constants::polkadot::currency::SYSTEM_PARA_EXISTENTIAL_DEPOSIT;

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
RuntimeEvent::Balances(
pallet_balances::Event::Burned { who, amount }
) => {
who: *who == sov_penpal_on_ahk.clone().into(),
who: *who == sov_penpal_on_ahk.clone(),
amount: *amount == t.args.amount,
},
RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. }) => {
Expand Down Expand Up @@ -383,8 +383,8 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() {
fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
// Init values for Relay Chain
let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000;
let destination = AssetHubPolkadot::parent_location().into();
let beneficiary_id = PolkadotReceiver::get().into();
let destination = AssetHubPolkadot::parent_location();
let beneficiary_id = PolkadotReceiver::get();
let assets = (Parent, amount_to_send).into();

let test_args = TestContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use crate::*;
use emulated_integration_tests_common::accounts::{ALICE, BOB};
use frame_support::traits::fungibles::{Create, Inspect, Mutate};
use frame_support::traits::fungibles::{Create, Mutate};
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use xcm_executor::traits::ConvertLocation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub(crate) fn send_asset_from_asset_hub_kusama(
(id, amount): (Location, u128),
) -> DispatchResult {
let signed_origin =
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get().into());
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get());

let beneficiary: Location =
AccountId32Junction { network: None, id: AssetHubPolkadotReceiver::get().into() }.into();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
// fund the AHK's SA on BHK for paying bridge transport fees
BridgeHubKusama::fund_para_sovereign(AssetHubKusama::para_id(), 10_000_000_000_000u128);
// fund sender
AssetHubKusama::fund_accounts(vec![(AssetHubKusamaSender::get().into(), amount * 10)]);
AssetHubKusama::fund_accounts(vec![(AssetHubKusamaSender::get(), amount * 10)]);

// send XCM from AssetHubKusama - fails - destination version not known
assert_err!(
Expand Down
Loading
Loading