From 3dc35abfa5df6400879a0eb141ef44b0061b15b5 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Wed, 22 Jan 2025 10:45:56 +0100 Subject: [PATCH] fix tests --- end2end-tests/tests/cucumber_tests.rs | 2 +- node/src/rpc.rs | 1 + node/src/service/client.rs | 13 +++++-------- pallets/authority-members/src/lib.rs | 1 + pallets/authority-members/src/mock.rs | 18 ++---------------- pallets/certification/src/lib.rs | 1 + pallets/certification/src/mock.rs | 18 ++---------------- pallets/distance/src/lib.rs | 1 + pallets/distance/src/mock.rs | 18 +++--------------- pallets/duniter-account/src/lib.rs | 1 + pallets/duniter-test-parameters/src/lib.rs | 1 + pallets/duniter-wot/src/lib.rs | 1 + pallets/duniter-wot/src/mock.rs | 18 ++---------------- pallets/identity/src/lib.rs | 1 + pallets/identity/src/mock.rs | 18 ++---------------- pallets/membership/src/lib.rs | 1 + pallets/membership/src/mock.rs | 18 ++---------------- pallets/offences/src/lib.rs | 1 + pallets/offences/src/mock.rs | 18 ++---------------- pallets/oneshot-account/src/lib.rs | 1 + pallets/oneshot-account/src/mock.rs | 19 ++++--------------- pallets/provide-randomness/src/lib.rs | 1 + pallets/quota/src/lib.rs | 1 + pallets/quota/src/mock.rs | 19 ++++--------------- pallets/smith-members/src/lib.rs | 1 + pallets/smith-members/src/mock.rs | 17 ++--------------- pallets/universal-dividend/src/lib.rs | 1 + pallets/universal-dividend/src/mock.rs | 18 +++--------------- pallets/upgrade-origin/src/lib.rs | 1 + runtime/common/src/apis.rs | 2 +- runtime/common/src/constants.rs | 11 +++++------ runtime/common/src/handlers.rs | 1 + runtime/g1/src/lib.rs | 6 +++--- runtime/gdev/src/lib.rs | 6 +++--- runtime/gdev/tests/common/mod.rs | 22 +++++++++++++--------- runtime/gtest/src/lib.rs | 6 +++--- 36 files changed, 79 insertions(+), 205 deletions(-) diff --git a/end2end-tests/tests/cucumber_tests.rs b/end2end-tests/tests/cucumber_tests.rs index 58a532b2d..c65302732 100644 --- a/end2end-tests/tests/cucumber_tests.rs +++ b/end2end-tests/tests/cucumber_tests.rs @@ -631,7 +631,7 @@ async fn main() { .before(move |feature, _rule, scenario, world| { let mut genesis_conf_file_path = PathBuf::new(); genesis_conf_file_path.push("cucumber-genesis"); - genesis_conf_file_path.push(&format!( + genesis_conf_file_path.push(format!( "{}.json", genesis_conf_name(&feature.tags, &scenario.tags) )); diff --git a/node/src/rpc.rs b/node/src/rpc.rs index f5e6f09b2..2b05e5b5f 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -15,6 +15,7 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. //! A collection of node-specific RPC methods. +//! //! Substrate provides the `sc-rpc` crate, which defines the core RPC layer //! used by Substrate nodes. This file extends those RPC definitions with //! capabilities that are specific to this project's runtime configuration. diff --git a/node/src/service/client.rs b/node/src/service/client.rs index 108f31f00..99b01cf1f 100644 --- a/node/src/service/client.rs +++ b/node/src/service/client.rs @@ -16,8 +16,8 @@ use common_runtime::{AccountId, Balance, Block, BlockNumber, Hash, Header, Index}; use sc_client_api::{ - AuxStore, Backend as BackendT, BlockBackend, BlockchainEvents, KeysIter, MerkleValue, - PairsIter, UsageProvider, + AuxStore, Backend as BackendT, BlockchainEvents, KeysIter, MerkleValue, PairsIter, + UsageProvider, }; use sp_api::{CallApiAt, ProvideRuntimeApi}; use sp_blockchain::{HeaderBackend, HeaderMetadata}; @@ -26,7 +26,7 @@ use sp_core::{Encode, Pair}; use sp_runtime::{ generic::SignedBlock, traits::{BlakeTwo256, Block as BlockT}, - Justifications, SaturatedConversion, + Justifications, }; use sp_storage::{ChildInfo, StorageData, StorageKey}; use std::sync::Arc; @@ -328,14 +328,11 @@ impl BenchmarkCallSigner<super::runtime_executor::runtime::RuntimeCall, sp_core: frame_system::CheckTxVersion::<super::runtime_executor::runtime::Runtime>::new(), frame_system::CheckGenesis::<super::runtime_executor::runtime::Runtime>::new(), frame_system::CheckEra::<super::runtime_executor::runtime::Runtime>::from( - sp_runtime::generic::Era::mortal( - period, - self.chain_info().best_number.saturated_into(), - ), + sp_runtime::generic::Era::mortal(period, current_block), ), pallet_oneshot_account::CheckNonce::<super::runtime_executor::runtime::Runtime>::from( frame_system::CheckNonce::<super::runtime_executor::runtime::Runtime>::from(nonce), - ), // TODO + ), frame_system::CheckWeight::<super::runtime_executor::runtime::Runtime>::new(), pallet_transaction_payment::ChargeTransactionPayment::< super::runtime_executor::runtime::Runtime, diff --git a/pallets/authority-members/src/lib.rs b/pallets/authority-members/src/lib.rs index f4118ee3a..b69c0d729 100644 --- a/pallets/authority-members/src/lib.rs +++ b/pallets/authority-members/src/lib.rs @@ -68,6 +68,7 @@ use frame_support::traits::Get; use scale_info::prelude::{collections::BTreeMap, vec, vec::Vec}; use sp_runtime::traits::{Convert, IsMember}; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/authority-members/src/mock.rs b/pallets/authority-members/src/mock.rs index 8afd17edf..1a582ef73 100644 --- a/pallets/authority-members/src/mock.rs +++ b/pallets/authority-members/src/mock.rs @@ -16,7 +16,7 @@ use super::*; use crate::{self as pallet_authority_members}; -use frame_support::{pallet_prelude::*, parameter_types, traits::Everything}; +use frame_support::{derive_impl, pallet_prelude::*, parameter_types, traits::Everything}; use frame_system as system; use pallet_offences::{traits::OnOffenceHandler, SlashStrategy}; use pallet_session::ShouldEndSession; @@ -60,36 +60,22 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { - type AccountData = (); type AccountId = AccountId; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } pub struct TestSessionHandler; diff --git a/pallets/certification/src/lib.rs b/pallets/certification/src/lib.rs index 204c8cb08..c8301d221 100644 --- a/pallets/certification/src/lib.rs +++ b/pallets/certification/src/lib.rs @@ -49,6 +49,7 @@ use frame_support::{pallet_prelude::*, traits::StorageVersion}; use scale_info::prelude::{collections::BTreeMap, fmt::Debug, vec::Vec}; use sp_runtime::traits::AtLeast32BitUnsigned; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/certification/src/mock.rs b/pallets/certification/src/mock.rs index 7f24b214b..5f89fa530 100644 --- a/pallets/certification/src/mock.rs +++ b/pallets/certification/src/mock.rs @@ -16,7 +16,7 @@ use crate::{self as pallet_certification}; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{Everything, OnFinalize, OnInitialize}, }; use frame_system as system; @@ -43,36 +43,22 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { - type AccountData = (); type AccountId = AccountId; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } parameter_types! { diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs index 738ee5909..497aa8a9c 100644 --- a/pallets/distance/src/lib.rs +++ b/pallets/distance/src/lib.rs @@ -103,6 +103,7 @@ pub const MAX_EVALUATIONS_PER_SESSION: u32 = 1_300; // See https://git.duniter.o /// Maximum number of evaluators in an evaluation period. pub const MAX_EVALUATORS_PER_SESSION: u32 = 100; +#[allow(unreachable_patterns)] #[frame_support::pallet()] pub mod pallet { use super::*; diff --git a/pallets/distance/src/mock.rs b/pallets/distance/src/mock.rs index 5198424e0..e804df741 100644 --- a/pallets/distance/src/mock.rs +++ b/pallets/distance/src/mock.rs @@ -17,7 +17,7 @@ use crate::{self as pallet_distance}; use core::marker::PhantomData; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{Everything, OnFinalize, OnInitialize}, }; use frame_system as system; @@ -66,36 +66,23 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { type AccountData = AccountData<u64>; type AccountId = AccountId; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } pub struct TestSessionHandler; @@ -199,6 +186,7 @@ parameter_types! { impl pallet_balances::Config for Test { type AccountStore = System; type Balance = Balance; + type DoneSlashHandler = (); type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type FreezeIdentifier = (); diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index 94c05ec6f..82fb57f09 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -61,6 +61,7 @@ use scale_info::prelude::{ }; use sp_runtime::traits::{DispatchInfoOf, PostDispatchInfoOf, Saturating}; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/duniter-test-parameters/src/lib.rs b/pallets/duniter-test-parameters/src/lib.rs index 346a88230..b2bbc8bcc 100644 --- a/pallets/duniter-test-parameters/src/lib.rs +++ b/pallets/duniter-test-parameters/src/lib.rs @@ -66,6 +66,7 @@ pub mod types { } } +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index 1a560bdf6..d05504a24 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -61,6 +61,7 @@ use pallet_membership::MembershipRemovalReason; type IdtyIndex = u32; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index ddb4bf63f..a3c550632 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -16,7 +16,7 @@ use super::*; use crate::{self as pallet_duniter_wot}; -use frame_support::{parameter_types, traits::Everything}; +use frame_support::{derive_impl, parameter_types, traits::Everything}; use frame_system as system; use sp_core::H256; use sp_runtime::{ @@ -47,36 +47,22 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { - type AccountData = (); type AccountId = AccountId; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } // DuniterWot diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index 805c3ec42..579fe685c 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -83,6 +83,7 @@ pub const REVOCATION_PAYLOAD_PREFIX: [u8; 4] = [b'r', b'e', b'v', b'o']; // link = link (identity with account) pub const LINK_IDTY_PAYLOAD_PREFIX: [u8; 4] = [b'l', b'i', b'n', b'k']; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/identity/src/mock.rs b/pallets/identity/src/mock.rs index 92380ce2c..70758bc81 100644 --- a/pallets/identity/src/mock.rs +++ b/pallets/identity/src/mock.rs @@ -17,7 +17,7 @@ use super::*; use crate::{self as pallet_identity}; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{Everything, OnFinalize, OnInitialize}, }; use frame_system as system; @@ -54,36 +54,22 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { - type AccountData = (); type AccountId = AccountId; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } parameter_types! { diff --git a/pallets/membership/src/lib.rs b/pallets/membership/src/lib.rs index 0a096b0a3..ffbd6b879 100644 --- a/pallets/membership/src/lib.rs +++ b/pallets/membership/src/lib.rs @@ -69,6 +69,7 @@ pub enum MembershipRemovalReason { System, } +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/membership/src/mock.rs b/pallets/membership/src/mock.rs index 6269ed615..208e663f5 100644 --- a/pallets/membership/src/mock.rs +++ b/pallets/membership/src/mock.rs @@ -16,7 +16,7 @@ use crate::{self as pallet_membership}; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{Everything, OnFinalize, OnInitialize}, }; use frame_system as system; @@ -44,36 +44,22 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { - type AccountData = (); type AccountId = AccountId; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } parameter_types! { diff --git a/pallets/offences/src/lib.rs b/pallets/offences/src/lib.rs index 8b2d32cc4..ab9c03ca6 100644 --- a/pallets/offences/src/lib.rs +++ b/pallets/offences/src/lib.rs @@ -65,6 +65,7 @@ pub enum SlashStrategy { Blacklist, } +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/offences/src/mock.rs b/pallets/offences/src/mock.rs index 49611fb08..ac5db8b17 100644 --- a/pallets/offences/src/mock.rs +++ b/pallets/offences/src/mock.rs @@ -17,7 +17,7 @@ use crate::{self as pallet_offences, Config, SlashStrategy}; use codec::Encode; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{ConstU32, ConstU64}, weights::{constants::RocksDbWeight, Weight}, }; @@ -59,36 +59,22 @@ frame_support::construct_runtime!( } ); +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Runtime { - type AccountData = (); type AccountId = u64; type BaseCallFilter = frame_support::traits::Everything; type Block = Block; type BlockHashCount = ConstU64<250>; - type BlockLength = (); - type BlockWeights = (); type DbWeight = RocksDbWeight; type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); - type SS58Prefix = (); - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } impl Config for Runtime { diff --git a/pallets/oneshot-account/src/lib.rs b/pallets/oneshot-account/src/lib.rs index 34b912d16..1b6735fb1 100644 --- a/pallets/oneshot-account/src/lib.rs +++ b/pallets/oneshot-account/src/lib.rs @@ -48,6 +48,7 @@ use sp_runtime::traits::{DispatchInfoOf, PostDispatchInfoOf, Saturating, StaticL type AccountIdOf<T> = <T as frame_system::Config>::AccountId; type BalanceOf<T> = <<T as Config>::Currency as fungible::Inspect<AccountIdOf<T>>>::Balance; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/oneshot-account/src/mock.rs b/pallets/oneshot-account/src/mock.rs index d742e3343..aa75a5568 100644 --- a/pallets/oneshot-account/src/mock.rs +++ b/pallets/oneshot-account/src/mock.rs @@ -15,7 +15,7 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. use crate::{self as pallet_oneshot_account}; -use frame_support::{parameter_types, traits::Everything, weights::IdentityFee}; +use frame_support::{derive_impl, parameter_types, traits::Everything, weights::IdentityFee}; use frame_system as system; use pallet_transaction_payment::FungibleAdapter; use sp_core::{ConstU32, H256}; @@ -43,36 +43,23 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { type AccountData = pallet_balances::AccountData<Balance>; type AccountId = u64; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } parameter_types! { @@ -83,6 +70,7 @@ parameter_types! { impl pallet_balances::Config for Test { type AccountStore = System; type Balance = Balance; + type DoneSlashHandler = (); type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type FreezeIdentifier = (); @@ -101,6 +89,7 @@ impl pallet_transaction_payment::Config for Test { type OnChargeTransaction = OneshotAccount; type OperationalFeeMultiplier = frame_support::traits::ConstU8<5>; type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); type WeightToFee = IdentityFee<u64>; } impl pallet_oneshot_account::Config for Test { diff --git a/pallets/provide-randomness/src/lib.rs b/pallets/provide-randomness/src/lib.rs index 20dcfa91b..1534f1e95 100644 --- a/pallets/provide-randomness/src/lib.rs +++ b/pallets/provide-randomness/src/lib.rs @@ -53,6 +53,7 @@ impl OnFilledRandomness for () { } } +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/quota/src/lib.rs b/pallets/quota/src/lib.rs index 67340ef67..9ea7aa210 100644 --- a/pallets/quota/src/lib.rs +++ b/pallets/quota/src/lib.rs @@ -59,6 +59,7 @@ use scale_info::prelude::vec::Vec; use sp_runtime::traits::Zero; pub use weights::WeightInfo; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/quota/src/mock.rs b/pallets/quota/src/mock.rs index a21f3b85c..f39b053df 100644 --- a/pallets/quota/src/mock.rs +++ b/pallets/quota/src/mock.rs @@ -19,7 +19,7 @@ use super::*; pub use crate::pallet as pallet_quota; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{Everything, OnFinalize, OnInitialize}, }; use frame_system as system; @@ -75,36 +75,24 @@ parameter_types! { pub const BlockHashCount: u64 = 250; pub const SS58Prefix: u8 = 42; } + +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { type AccountData = pallet_balances::AccountData<Balance>; type AccountId = AccountId; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } // BALANCES // @@ -115,6 +103,7 @@ parameter_types! { impl pallet_balances::Config for Test { type AccountStore = System; type Balance = Balance; + type DoneSlashHandler = (); type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type FreezeIdentifier = (); diff --git a/pallets/smith-members/src/lib.rs b/pallets/smith-members/src/lib.rs index e7c48962a..d9246b0cc 100644 --- a/pallets/smith-members/src/lib.rs +++ b/pallets/smith-members/src/lib.rs @@ -96,6 +96,7 @@ pub enum SmithStatus { Excluded, } +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/smith-members/src/mock.rs b/pallets/smith-members/src/mock.rs index 27ecfe885..388f71147 100644 --- a/pallets/smith-members/src/mock.rs +++ b/pallets/smith-members/src/mock.rs @@ -16,6 +16,7 @@ use crate::{self as pallet_smith_members}; use frame_support::{ + derive_impl, pallet_prelude::Hooks, parameter_types, traits::{ConstU32, ConstU64}, @@ -41,36 +42,22 @@ frame_support::construct_runtime!( } ); +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Runtime { - type AccountData = (); type AccountId = u64; type BaseCallFilter = frame_support::traits::Everything; type Block = Block; type BlockHashCount = ConstU64<250>; - type BlockLength = (); - type BlockWeights = (); type DbWeight = RocksDbWeight; type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); - type SS58Prefix = (); - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } pub struct EveryoneExceptIdZero; diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs index 6fda9a68c..c0a034725 100644 --- a/pallets/universal-dividend/src/lib.rs +++ b/pallets/universal-dividend/src/lib.rs @@ -56,6 +56,7 @@ use sp_arithmetic::{ }; use sp_runtime::traits::{Get, MaybeSerializeDeserialize, StaticLookup}; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/universal-dividend/src/mock.rs b/pallets/universal-dividend/src/mock.rs index 233ec61e7..077f6694b 100644 --- a/pallets/universal-dividend/src/mock.rs +++ b/pallets/universal-dividend/src/mock.rs @@ -17,7 +17,7 @@ use super::*; use crate::{self as pallet_universal_dividend}; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{Everything, OnFinalize, OnInitialize}, }; use frame_system as system; @@ -48,36 +48,23 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl system::Config for Test { type AccountData = pallet_balances::AccountData<Balance>; type AccountId = u32; type BaseCallFilter = Everything; type Block = Block; type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type DbWeight = (); type Hash = H256; type Hashing = BlakeTwo256; type Lookup = IdentityLookup<Self::AccountId>; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = (); type Nonce = u64; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); type PalletInfo = PalletInfo; - type PostInherents = (); - type PostTransactions = (); - type PreInherents = (); type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - type RuntimeTask = (); type SS58Prefix = SS58Prefix; - type SingleBlockMigrations = (); - type SystemWeightInfo = (); - type Version = (); } parameter_types! { @@ -99,6 +86,7 @@ parameter_types! { impl pallet_balances::Config for Test { type AccountStore = System; type Balance = Balance; + type DoneSlashHandler = (); type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type FreezeIdentifier = (); diff --git a/pallets/upgrade-origin/src/lib.rs b/pallets/upgrade-origin/src/lib.rs index b9d0e0479..20fb15f45 100644 --- a/pallets/upgrade-origin/src/lib.rs +++ b/pallets/upgrade-origin/src/lib.rs @@ -30,6 +30,7 @@ use frame_support::{ use scale_info::prelude::boxed::Box; use sp_runtime::traits::Dispatchable; +#[allow(unreachable_patterns)] #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index 0a50497c6..7853aacb3 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -276,7 +276,7 @@ macro_rules! runtime_apis { config: frame_benchmarking::BenchmarkConfig ) -> Result< Vec<frame_benchmarking::BenchmarkBatch>, - sp_runtime::RuntimeString, + scale_info::prelude::string::String, > { use frame_benchmarking::{Benchmarking, BenchmarkBatch}; use frame_support::traits::TrackedStorageKey; diff --git a/runtime/common/src/constants.rs b/runtime/common/src/constants.rs index a9f31004c..851dc98ad 100644 --- a/runtime/common/src/constants.rs +++ b/runtime/common/src/constants.rs @@ -18,11 +18,10 @@ use crate::{Balance, BlockNumber}; use sp_runtime::Perbill; /// This determines the average expected block time that we are targeting. -/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`. -/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked -/// up by `pallet_babe` to implement `fn slot_duration()`. -/// -/// Change this to adjust the block time. +// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`. +// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked +// up by `pallet_babe` to implement `fn slot_duration()`. +// Change this to adjust the block time. pub const MILLISECS_PER_BLOCK: u64 = 6000; pub const SECS_PER_BLOCK: u64 = MILLISECS_PER_BLOCK / 1_000; @@ -41,7 +40,7 @@ pub const YEARS: BlockNumber = (SECS_PER_YEAR / SECS_PER_BLOCK) as BlockNumber; // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); -/// The BABE epoch configuration at genesis. +// The BABE epoch configuration at genesis. pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = sp_consensus_babe::BabeEpochConfiguration { c: PRIMARY_PROBABILITY, diff --git a/runtime/common/src/handlers.rs b/runtime/common/src/handlers.rs index 46c61afa6..078bb6d7c 100644 --- a/runtime/common/src/handlers.rs +++ b/runtime/common/src/handlers.rs @@ -95,6 +95,7 @@ impl< } /// Runtime handler for OnRemoveMembership, calling all implementations of +/// /// OnRemoveMembership and implementing logic at the runtime level. /// As the weight accounting is not trivial in this handler, the weight is /// done at the handler level. diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 4a4f4488c..e24d78ba1 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -56,7 +56,7 @@ use sp_core::OpaqueMetadata; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, + generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Cow, Perquintill, @@ -298,7 +298,7 @@ where type Extension = TxExtension; fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic { - generic::UncheckedExtrinsic::new_transaction(call, extension).into() + generic::UncheckedExtrinsic::new_transaction(call, extension) } } @@ -307,7 +307,7 @@ where RuntimeCall: From<LocalCall>, { fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic { - generic::UncheckedExtrinsic::new_bare(call).into() + generic::UncheckedExtrinsic::new_bare(call) } } diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index c6b87f43c..6447396cb 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -56,7 +56,7 @@ use sp_core::OpaqueMetadata; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, + generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Cow, Perquintill, @@ -342,7 +342,7 @@ where type Extension = TxExtension; fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic { - generic::UncheckedExtrinsic::new_transaction(call, extension).into() + generic::UncheckedExtrinsic::new_transaction(call, extension) } } @@ -351,7 +351,7 @@ where RuntimeCall: From<LocalCall>, { fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic { - generic::UncheckedExtrinsic::new_bare(call).into() + generic::UncheckedExtrinsic::new_bare(call) } } diff --git a/runtime/gdev/tests/common/mod.rs b/runtime/gdev/tests/common/mod.rs index 82b5ade8d..1345f8ffb 100644 --- a/runtime/gdev/tests/common/mod.rs +++ b/runtime/gdev/tests/common/mod.rs @@ -30,7 +30,7 @@ use sp_membership::MembershipData; use sp_runtime::{ generic::SignedPayload, testing::{Digest, DigestItem}, - traits::{Extrinsic, IdentifyAccount, Verify}, + traits::{ExtrinsicLike, IdentifyAccount, Verify}, }; use std::collections::BTreeMap; @@ -492,25 +492,29 @@ pub fn get_unchecked_extrinsic( tip: Balance, nonce: u32, ) -> gdev_runtime::UncheckedExtrinsic { - let extra: gdev_runtime::SignedExtra = ( + let tx_ext: gdev_runtime::TxExtension = ( frame_system::CheckNonZeroSender::<gdev_runtime::Runtime>::new(), frame_system::CheckSpecVersion::<gdev_runtime::Runtime>::new(), frame_system::CheckTxVersion::<gdev_runtime::Runtime>::new(), frame_system::CheckGenesis::<gdev_runtime::Runtime>::new(), - frame_system::CheckMortality::<gdev_runtime::Runtime>::from( - sp_runtime::generic::Era::mortal(era, block), + frame_system::CheckEra::<gdev_runtime::Runtime>::from(sp_runtime::generic::Era::mortal( + era, block, + )), + pallet_oneshot_account::CheckNonce::<gdev_runtime::Runtime>::from( + frame_system::CheckNonce::<gdev_runtime::Runtime>::from(nonce), ), - frame_system::CheckNonce::<gdev_runtime::Runtime>::from(nonce).into(), frame_system::CheckWeight::<gdev_runtime::Runtime>::new(), pallet_transaction_payment::ChargeTransactionPayment::<gdev_runtime::Runtime>::from(tip), + //frame_metadata_hash_extension::CheckMetadataHash::<gdev_runtime::Runtime>::new(false), TODO ); - let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap(); + let payload = SignedPayload::new(call.clone(), tx_ext.clone()).unwrap(); let origin = signer; let sig = payload.using_encoded(|payload| origin.pair().sign(payload)); - gdev_runtime::UncheckedExtrinsic::new( + gdev_runtime::UncheckedExtrinsic::new_signed( call, - Some((origin.to_account_id().into(), sig.into(), extra)), + origin.to_account_id().into(), + sig.into(), + tx_ext, ) - .unwrap() } diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index f4e44e95b..a6f1cd70c 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -55,7 +55,7 @@ use sp_core::OpaqueMetadata; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, + generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Cow, Perquintill, @@ -305,7 +305,7 @@ where type Extension = TxExtension; fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic { - generic::UncheckedExtrinsic::new_transaction(call, extension).into() + generic::UncheckedExtrinsic::new_transaction(call, extension) } } @@ -314,7 +314,7 @@ where RuntimeCall: From<LocalCall>, { fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic { - generic::UncheckedExtrinsic::new_bare(call).into() + generic::UncheckedExtrinsic::new_bare(call) } } -- GitLab