diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index 7474f3ab..23259ea2 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -46,7 +46,7 @@ impl Extensions { /// Helper function to generate a crypto pair from seed pub fn get_public_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) + TPublic::Pair::from_string(&format!("//{seed}"), None) .expect("static values are valid; qed") .public() } diff --git a/node/src/chain_spec/stout.rs b/node/src/chain_spec/stout.rs index 5a7cf8c6..13a6055f 100644 --- a/node/src/chain_spec/stout.rs +++ b/node/src/chain_spec/stout.rs @@ -114,11 +114,11 @@ fn testnet_genesis( }, balances: BalancesConfig { // Configure endowed accounts with initial balance of 1 << 60. - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), + balances: endowed_accounts.into_iter().map(|k| (k, 1 << 60)).collect(), }, parachain_info: stout_runtime::ParachainInfoConfig { parachain_id: id }, collator_selection: stout_runtime::CollatorSelectionConfig { - invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), + invulnerables: invulnerables.iter().map(|(acc, _)| acc).cloned().collect(), candidacy_bond: EXISTENTIAL_DEPOSIT * 16, ..Default::default() }, @@ -146,7 +146,7 @@ fn testnet_genesis( }, assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, council: CouncilConfig { - members: invulnerables.iter().map(|x| x.0.clone()).collect::>(), + members: invulnerables.into_iter().map(|x| x.0).collect::>(), phantom: Default::default(), }, dex: Default::default(), diff --git a/node/src/chain_spec/trappist.rs b/node/src/chain_spec/trappist.rs index 291562f4..997fcdd0 100644 --- a/node/src/chain_spec/trappist.rs +++ b/node/src/chain_spec/trappist.rs @@ -167,11 +167,11 @@ pub fn testnet_genesis( }, balances: BalancesConfig { // Configure endowed accounts with initial balance of 1 << 60. - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), + balances: endowed_accounts.into_iter().map(|k| (k, 1 << 60)).collect(), }, parachain_info: trappist_runtime::ParachainInfoConfig { parachain_id: id }, collator_selection: trappist_runtime::CollatorSelectionConfig { - invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), + invulnerables: invulnerables.iter().map(|(acc, _)| acc).cloned().collect(), candidacy_bond: EXISTENTIAL_DEPOSIT * 16, ..Default::default() }, @@ -202,7 +202,7 @@ pub fn testnet_genesis( }, assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, council: CouncilConfig { - members: invulnerables.iter().map(|x| x.0.clone()).collect::>(), + members: invulnerables.into_iter().map(|x| x.0).collect::>(), phantom: Default::default(), }, treasury: Default::default(), @@ -276,32 +276,25 @@ fn trappist_live_genesis( balances: BalancesConfig { balances: endowed_accounts .iter() - .cloned() - .chain(std::iter::once(root_key.clone())) - .map(|k| { - if k == root_key { - (k, 1_000_000_000_000_000_000) - } else { - (k, 1_500_000_000_000_000_000) - } - }) + .map(|x| (x.clone(), 1_500_000_000_000_000_000)) + .chain(std::iter::once((root_key.clone(), 1_000_000_000_000_000_000))) .collect(), }, parachain_info: trappist_runtime::ParachainInfoConfig { parachain_id: id }, collator_selection: trappist_runtime::CollatorSelectionConfig { - invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), + invulnerables: invulnerables.iter().map(|(acc, _)| acc).cloned().collect(), candidacy_bond: EXISTENTIAL_DEPOSIT * 16, ..Default::default() }, democracy: Default::default(), session: SessionConfig { keys: invulnerables - .iter() + .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc.clone(), // validator id - session_keys(aura.clone()), // session keys + acc.clone(), // account id + acc, // validator id + session_keys(aura), // session keys ) }) .collect(), @@ -319,7 +312,7 @@ fn trappist_live_genesis( assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, council: CouncilConfig { // We set the endowed accounts with balance as members of the council. - members: endowed_accounts.iter().map(|x| x.clone()).collect::>(), + members: endowed_accounts, phantom: Default::default(), }, treasury: Default::default(), diff --git a/node/src/main.rs b/node/src/main.rs index 9c3e50a0..d5943dec 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -15,6 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! Trappist Node CLI. + #![warn(missing_docs)] #![warn(unused_extern_crates)] diff --git a/node/src/service.rs b/node/src/service.rs index b5d53586..2279d20c 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -707,37 +707,41 @@ where <::Pair as Pair>::Signature: TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, { - let client2 = client.clone(); + let aura_verifier = { + let client = client.clone(); - let aura_verifier = move || { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap(); + move || { + let slot_duration = + cumulus_client_consensus_aura::slot_duration(client.as_ref()).unwrap(); - Box::new( - cumulus_client_consensus_aura::build_verifier::<::Pair, _, _, _>( - cumulus_client_consensus_aura::BuildVerifierParams { - client: client2.clone(), - create_inherent_data_providers: move |_, _| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + Box::new(cumulus_client_consensus_aura::build_verifier::< + ::Pair, + _, + _, + _, + >(cumulus_client_consensus_aura::BuildVerifierParams { + client, + create_inherent_data_providers: move |_, _| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - let slot = + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( *timestamp, slot_duration, ); - Ok((slot, timestamp)) - }, - telemetry: telemetry_handle, + Ok((slot, timestamp)) }, - ), - ) as Box<_> + telemetry: telemetry_handle, + })) as Box<_> + } }; let relay_chain_verifier = - Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) })) as Box<_>; + Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) })); let verifier = Verifier { - client: client.clone(), + client, relay_chain_verifier, aura_verifier: BuildOnAccess::Uninitialized(Some(Box::new(aura_verifier))), _phantom: PhantomData, diff --git a/pallets/lockdown-mode/src/lib.rs b/pallets/lockdown-mode/src/lib.rs index 47760a0c..d130eea7 100644 --- a/pallets/lockdown-mode/src/lib.rs +++ b/pallets/lockdown-mode/src/lib.rs @@ -67,7 +67,7 @@ pub mod pallet { #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { - LockdownModeStatus::::put(&self.initial_status); + LockdownModeStatus::::put(self.initial_status); } } @@ -149,11 +149,7 @@ pub mod pallet { impl Contains for Pallet { fn contains(call: &T::RuntimeCall) -> bool { - if LockdownModeStatus::::get() { - T::BlackListedCalls::contains(call) - } else { - return true - } + !LockdownModeStatus::::get() || T::BlackListedCalls::contains(call) } } diff --git a/runtime/trappist/src/constants.rs b/runtime/trappist/src/constants.rs index ac4a9be6..747c9fef 100644 --- a/runtime/trappist/src/constants.rs +++ b/runtime/trappist/src/constants.rs @@ -35,10 +35,9 @@ pub mod currency { /// Fee-related. pub mod fee { - use super::currency::CENTS; use frame_support::weights::{ - constants::{ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}, - WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, + constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, + WeightToFeePolynomial, }; use polkadot_core_primitives::Balance; use smallvec::smallvec; diff --git a/runtime/trappist/src/impls.rs b/runtime/trappist/src/impls.rs index 573e6e85..d1379c91 100644 --- a/runtime/trappist/src/impls.rs +++ b/runtime/trappist/src/impls.rs @@ -78,17 +78,17 @@ where pub struct RuntimeBlackListedCalls; impl Contains for RuntimeBlackListedCalls { fn contains(call: &RuntimeCall) -> bool { - match call { - RuntimeCall::Balances(_) => false, - RuntimeCall::Assets(_) => false, - RuntimeCall::Dex(_) => false, - RuntimeCall::PolkadotXcm(_) => false, - RuntimeCall::Treasury(_) => false, - RuntimeCall::Contracts(_) => false, - RuntimeCall::Uniques(_) => false, - RuntimeCall::AssetRegistry(_) => false, - _ => true, - } + !matches!( + call, + RuntimeCall::Balances(_) | + RuntimeCall::Assets(_) | + RuntimeCall::Dex(_) | + RuntimeCall::PolkadotXcm(_) | + RuntimeCall::Treasury(_) | + RuntimeCall::Contracts(_) | + RuntimeCall::Uniques(_) | + RuntimeCall::AssetRegistry(_) + ) } } diff --git a/runtime/trappist/src/weights/block_weights.rs b/runtime/trappist/src/weights/block_weights.rs index fdf980cb..b3a67e8c 100644 --- a/runtime/trappist/src/weights/block_weights.rs +++ b/runtime/trappist/src/weights/block_weights.rs @@ -16,7 +16,7 @@ // limitations under the License. //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-08 (Y/M/D) +//! DATE: 2023-06-09 (Y/M/D) //! HOSTNAME: `kalan-x1x`, CPU: `12th Gen Intel(R) Core(TM) i7-12800H` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Trappist Development` @@ -28,9 +28,13 @@ // target/debug/trappist-node // benchmark // overhead -// --chain -// dev +// --chain=trappist-dev +// --execution=wasm +// --wasm-execution=compiled // --weight-path=./runtime/trappist/src/weights +// --warmup=10 +// --repeat=100 +// --header=./templates/file_header.txt use sp_core::parameter_types; use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight}; @@ -40,17 +44,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 5_120_602, 10_113_574 - /// Average: 6_901_058 - /// Median: 6_276_001 - /// Std-Dev: 1393716.66 + /// Min, Max: 3_950_018, 4_495_760 + /// Average: 4_098_356 + /// Median: 4_070_795 + /// Std-Dev: 83926.18 /// /// Percentiles nanoseconds: - /// 99th: 9_958_901 - /// 95th: 8_509_417 - /// 75th: 8_216_945 + /// 99th: 4_389_302 + /// 95th: 4_241_334 + /// 75th: 4_137_615 pub const BlockExecutionWeight: Weight = - Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(6_901_058)); + Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(4_098_356)); } #[cfg(test)] diff --git a/runtime/trappist/src/weights/extrinsic_weights.rs b/runtime/trappist/src/weights/extrinsic_weights.rs index 9d2700c4..4671bc5c 100644 --- a/runtime/trappist/src/weights/extrinsic_weights.rs +++ b/runtime/trappist/src/weights/extrinsic_weights.rs @@ -16,7 +16,7 @@ // limitations under the License. //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-08 (Y/M/D) +//! DATE: 2023-06-09 (Y/M/D) //! HOSTNAME: `kalan-x1x`, CPU: `12th Gen Intel(R) Core(TM) i7-12800H` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Trappist Development` @@ -28,9 +28,13 @@ // target/debug/trappist-node // benchmark // overhead -// --chain -// dev +// --chain=trappist-dev +// --execution=wasm +// --wasm-execution=compiled // --weight-path=./runtime/trappist/src/weights +// --warmup=10 +// --repeat=100 +// --header=./templates/file_header.txt use sp_core::parameter_types; use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight}; @@ -40,17 +44,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 1_538_002, 2_494_865 - /// Average: 1_980_785 - /// Median: 2_006_809 - /// Std-Dev: 131423.95 + /// Min, Max: 921_024, 963_714 + /// Average: 930_758 + /// Median: 928_324 + /// Std-Dev: 7978.85 /// /// Percentiles nanoseconds: - /// 99th: 2_378_849 - /// 95th: 2_080_265 - /// 75th: 2_030_767 + /// 99th: 958_566 + /// 95th: 948_841 + /// 75th: 932_871 pub const ExtrinsicBaseWeight: Weight = - Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(1_980_785)); + Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(930_758)); } #[cfg(test)] diff --git a/runtime/trappist/src/weights/xcm/mod.rs b/runtime/trappist/src/weights/xcm/mod.rs index c5f226ee..37ec6ac8 100644 --- a/runtime/trappist/src/weights/xcm/mod.rs +++ b/runtime/trappist/src/weights/xcm/mod.rs @@ -22,7 +22,7 @@ use crate::Runtime; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::{cmp, prelude::*}; +use sp_std::cmp; use xcm::{ latest::{prelude::*, Weight as XCMWeight}, DoubleEncoded, @@ -37,8 +37,7 @@ const MAX_ASSETS: u32 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight { let weight = match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64), }; weight.ref_time() @@ -47,7 +46,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight { - weight.saturating_mul(self.inner().into_iter().count() as u64).ref_time() + weight.saturating_mul(self.inner().iter().count() as u64).ref_time() } } @@ -119,7 +118,7 @@ impl XcmWeightInfo for TrappistXcmWeight { _dest: &MultiLocation, ) -> XCMWeight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64).ref_time(); + let hardcoded_weight = Weight::from_ref_time(1_000_000_000).ref_time(); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); cmp::min(hardcoded_weight, weight) } @@ -147,7 +146,7 @@ impl XcmWeightInfo for TrappistXcmWeight { _xcm: &Xcm<()>, ) -> XCMWeight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64).ref_time(); + let hardcoded_weight = Weight::from_ref_time(200_000_000).ref_time(); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()); cmp::min(hardcoded_weight, weight) } diff --git a/templates/file_header.txt b/templates/file_header.txt index 1deb6fd2..cebb54a9 100644 --- a/templates/file_header.txt +++ b/templates/file_header.txt @@ -13,4 +13,4 @@ // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and -// limitations under the License. \ No newline at end of file +// limitations under the License.