Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: runtimes, clippy
  • Loading branch information
wischli committed Sep 7, 2022
commit 89ba1e5e63b09ff5311fa68b3605ab728cff9de2
16 changes: 8 additions & 8 deletions pallets/did/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ fn check_successful_authentication_key_max_public_keys_update() {
fn check_reused_key_authentication_key_update() {
let old_auth_key = get_ed25519_authentication_key(true);
let alice_did = get_did_identifier_from_ed25519_key(old_auth_key.public());
let old_delegation_key = old_auth_key.clone();
let old_delegation_key = old_auth_key;
let new_auth_key = get_ed25519_authentication_key(false);

let mut old_did_details = generate_base_did_details::<Test>(DidVerificationKey::from(old_auth_key.public()));
Expand Down Expand Up @@ -892,7 +892,7 @@ fn check_reused_key_authentication_key_update() {
fn check_max_keys_authentication_key_update_error() {
let old_auth_key = get_ed25519_authentication_key(true);
let alice_did = get_did_identifier_from_ed25519_key(old_auth_key.public());
let delegation_key = old_auth_key.clone();
let delegation_key = old_auth_key;
let new_auth_key = get_ed25519_authentication_key(false);
let key_agreement_keys = get_key_agreement_keys::<Test>(MaxTotalKeyAgreementKeys::get());

Expand Down Expand Up @@ -1028,7 +1028,7 @@ fn check_successful_delegation_key_max_public_keys_update() {
fn check_reused_key_delegation_key_update() {
let old_auth_key = get_ed25519_authentication_key(true);
let alice_did = get_did_identifier_from_ed25519_key(old_auth_key.public());
let old_del_key = old_auth_key.clone();
let old_del_key = old_auth_key;
let new_del_key = get_sr25519_delegation_key(true);

let mut old_did_details = generate_base_did_details::<Test>(DidVerificationKey::from(old_auth_key.public()));
Expand Down Expand Up @@ -1099,7 +1099,7 @@ fn check_max_public_keys_delegation_key_addition_error() {
fn check_max_public_keys_reused_key_delegation_key_update_error() {
let auth_key = get_ed25519_authentication_key(true);
let alice_did = get_did_identifier_from_ed25519_key(auth_key.public());
let old_del_key = auth_key.clone();
let old_del_key = auth_key;
let new_del_key = get_sr25519_delegation_key(true);
let key_agreement_keys = get_key_agreement_keys::<Test>(MaxTotalKeyAgreementKeys::get());

Expand Down Expand Up @@ -1180,7 +1180,7 @@ fn check_successful_delegation_key_deletion() {
#[test]
fn check_successful_reused_delegation_key_deletion() {
let auth_key = get_ed25519_authentication_key(true);
let old_del_key = auth_key.clone();
let old_del_key = auth_key;
let alice_did = get_did_identifier_from_ed25519_key(auth_key.public());

let mut old_did_details = generate_base_did_details::<Test>(DidVerificationKey::from(auth_key.public()));
Expand Down Expand Up @@ -1315,7 +1315,7 @@ fn check_successful_attestation_key_max_public_keys_update() {
fn check_reused_key_attestation_key_update() {
let old_auth_key = get_ed25519_authentication_key(true);
let alice_did = get_did_identifier_from_ed25519_key(old_auth_key.public());
let old_att_key = old_auth_key.clone();
let old_att_key = old_auth_key;
let new_att_key = get_sr25519_attestation_key(true);

let mut old_did_details = generate_base_did_details::<Test>(DidVerificationKey::from(old_auth_key.public()));
Expand Down Expand Up @@ -1386,7 +1386,7 @@ fn check_max_public_keys_attestation_key_addition_error() {
fn check_max_public_keys_reused_key_attestation_key_update_error() {
let auth_key = get_ed25519_authentication_key(true);
let alice_did = get_did_identifier_from_ed25519_key(auth_key.public());
let old_att_key = auth_key.clone();
let old_att_key = auth_key;
let new_att_key = get_sr25519_delegation_key(true);
let key_agreement_keys = get_key_agreement_keys::<Test>(MaxTotalKeyAgreementKeys::get());

Expand Down Expand Up @@ -1467,7 +1467,7 @@ fn check_successful_attestation_key_deletion() {
#[test]
fn check_successful_reused_attestation_key_deletion() {
let auth_key = get_ed25519_authentication_key(true);
let old_att_key = auth_key.clone();
let old_att_key = auth_key;
let alice_did = get_did_identifier_from_ed25519_key(auth_key.public());

let mut old_did_details = generate_base_did_details::<Test>(DidVerificationKey::from(auth_key.public()));
Expand Down
2 changes: 0 additions & 2 deletions pallets/parachain-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use crate::{self as stake, types::NegativeImbalanceOf};
use frame_support::{
construct_runtime, parameter_types,
traits::{Currency, GenesisBuild, OnFinalize, OnInitialize, OnUnbalanced},
weights::Weight,
};
use pallet_authorship::EventHandler;
use sp_consensus_aura::sr25519::AuthorityId;
Expand Down Expand Up @@ -67,7 +66,6 @@ construct_runtime!(

parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
pub const SS58Prefix: u8 = 42;
Expand Down
21 changes: 14 additions & 7 deletions runtimes/clone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ use crate::xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin};

#[cfg(feature = "std")]
use sp_version::NativeVersion;
// TODO: Enable after adding delegation pallet
// #[cfg(feature = "runtime-benchmarks")]
// use {frame_system::EnsureSigned, kilt_support::signature::AlwaysVerify,
// runtime_common::benchmarks::DummySignature};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand All @@ -82,7 +78,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
authoring_version: 0,
spec_version: 10720,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
#[cfg(feature = "disable-runtime-api")]
apis: sp_version::create_apis_vec![[]],
transaction_version: 0,
state_version: 0,
};
Expand Down Expand Up @@ -701,12 +700,20 @@ impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade spiritnet runtime.");
log::info!("try-runtime::on_runtime_upgrade polkadot.");
let weight = Executive::try_runtime_upgrade().unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block_no_check(block: Block) -> Weight {
Executive::execute_block_no_check(block)

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::polkadot", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
}
}
}
Expand Down
18 changes: 12 additions & 6 deletions runtimes/common/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use frame_support::{
traits::{Currency, Get, Imbalance, OnUnbalanced},
weights::{
DispatchClass, WeightToFee as WeightToFeeT, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial, Weight,
DispatchClass, Weight, WeightToFee as WeightToFeeT, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial,
},
};
use pallet_balances::WeightInfo;
Expand Down Expand Up @@ -105,12 +105,18 @@ where

// TODO: transfer_keep_alive is 288 byte long?
let tx_len: u64 = 288;
let byte_fee: Balance = <R as pallet_transaction_payment::Config>::LengthToFee::weight_to_fee(&Weight::from_ref_time(tx_len)).into();
let base_weight: Weight =<R as frame_system::Config>::BlockWeights::get()
let byte_fee: Balance =
<R as pallet_transaction_payment::Config>::LengthToFee::weight_to_fee(&Weight::from_ref_time(tx_len))
.into();
let base_weight: Weight = <R as frame_system::Config>::BlockWeights::get()
.get(DispatchClass::Normal)
.base_extrinsic;
let base_weight_fee: Balance = <R as pallet_transaction_payment::Config>::LengthToFee::weight_to_fee(&base_weight).into();
let tx_weight_fee: Balance = <R as pallet_transaction_payment::Config>::LengthToFee::weight_to_fee(&<R as pallet_balances::Config>::WeightInfo::transfer_keep_alive()).into();
let base_weight_fee: Balance =
<R as pallet_transaction_payment::Config>::LengthToFee::weight_to_fee(&base_weight).into();
let tx_weight_fee: Balance = <R as pallet_transaction_payment::Config>::LengthToFee::weight_to_fee(
&<R as pallet_balances::Config>::WeightInfo::transfer_keep_alive(),
)
.into();
let unbalanced_fee: Balance = base_weight_fee.saturating_add(tx_weight_fee);

let wanted_weight_fee: Balance = wanted_fee.saturating_sub(byte_fee);
Expand Down
4 changes: 2 additions & 2 deletions runtimes/common/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// If you feel like getting in touch with us, you can do so at [email protected]

use core::marker::PhantomData;
use frame_support::{log, match_types, parameter_types, weights::Weight};
use frame_support::{log, match_types, parameter_types};
use polkadot_parachain::primitives::Sibling;
use xcm::latest::prelude::*;
use xcm_builder::{
Expand All @@ -30,7 +30,7 @@ use crate::AccountId;

parameter_types! {
// One XCM operation is 1_000_000_000 weight, almost certainly a conservative estimate.
pub UnitWeightCost: u64 = 1_000_000_000 as u64;
pub UnitWeightCost: u64 = 1_000_000_000u64;
pub const MaxInstructions: u32 = 100;
}

Expand Down
17 changes: 14 additions & 3 deletions runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
authoring_version: 4,
spec_version: 10720,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
#[cfg(feature = "disable-runtime-api")]
apis: sp_version::create_apis_vec![[]],
transaction_version: 4,
state_version: 0,
};
Expand Down Expand Up @@ -1356,12 +1359,20 @@ impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade peregrine runtime.");
log::info!("try-runtime::on_runtime_upgrade polkadot.");
let weight = Executive::try_runtime_upgrade().unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block_no_check(block: Block) -> Weight {
Executive::execute_block_no_check(block)

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::polkadot", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
}
}
}
Expand Down
17 changes: 14 additions & 3 deletions runtimes/spiritnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
authoring_version: 1,
spec_version: 10720,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
#[cfg(feature = "disable-runtime-api")]
apis: sp_version::create_apis_vec![[]],
transaction_version: 3,
state_version: 0,
};
Expand Down Expand Up @@ -1348,12 +1351,20 @@ impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade spiritnet runtime.");
log::info!("try-runtime::on_runtime_upgrade polkadot.");
let weight = Executive::try_runtime_upgrade().unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block_no_check(block: Block) -> Weight {
Executive::execute_block_no_check(block)

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::polkadot", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
}
}
}
Expand Down
26 changes: 19 additions & 7 deletions runtimes/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ pub use did;
pub use pallet_balances::Call as BalancesCall;
pub use pallet_web3_names;

#[cfg(feature = "std")]
use sp_version::NativeVersion;

#[cfg(feature = "try-runtime")]
use frame_support::pallet_prelude::Weight;
#[cfg(feature = "runtime-benchmarks")]
use frame_system::EnsureSigned;
#[cfg(feature = "std")]
use sp_version::NativeVersion;

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand Down Expand Up @@ -118,7 +119,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
authoring_version: 4,
spec_version: 10720,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
#[cfg(feature = "disable-runtime-api")]
apis: sp_version::create_apis_vec![[]],
transaction_version: 4,
state_version: 0,
};
Expand Down Expand Up @@ -1057,13 +1061,21 @@ impl_runtime_apis! {

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (frame_support::pallet_prelude::Weight, frame_support::pallet_prelude::Weight) {
log::info!("try-runtime::on_runtime_upgrade standalone runtime.");
fn on_runtime_upgrade() -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade polkadot.");
let weight = Executive::try_runtime_upgrade().unwrap();
(weight, runtime_common::BlockWeights::get().max_block)
}
fn execute_block_no_check(block: Block) -> frame_support::pallet_prelude::Weight {
Executive::execute_block_no_check(block)

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::polkadot", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
}
}
}
5 changes: 2 additions & 3 deletions support/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
//! Provides means of of handling relaychain related utilities and
//! business logic such as finalizing XCM calls.

#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::unused_unit)]

use codec::{Decode, Encode, FullCodec};
use frame_support::{traits::Get};
pub use cumulus_primitives_core::ParaId;
use frame_support::traits::Get;
use frame_system::Config;
use scale_info::TypeInfo;
use sp_std::{boxed::Box, marker::PhantomData, prelude::*};
use xcm::latest::prelude::*;
pub use cumulus_primitives_core::ParaId;

use crate::traits::RelayCallBuilder;

Expand Down
2 changes: 1 addition & 1 deletion support/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use frame_support::dispatch::Weight;
use scale_info::TypeInfo;

#[cfg(any(test, feature = "mock", feature = "runtime-benchmarks"))]
use {sp_runtime::traits::Zero, sp_std::marker::PhantomData};
use sp_std::marker::PhantomData;

/// The Result of the signature verification.
pub type SignatureVerificationResult = Result<(), SignatureVerificationError>;
Expand Down