diff --git a/Cargo.lock b/Cargo.lock index 7c703fe1b5143cd4b270ef03e239fc160dfa0145..f7fbb6a6aa5792381f4df4cc842aeac7eb13d9b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2227,6 +2227,7 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-offences", + "pallet-preimage", "pallet-provide-randomness", "pallet-proxy", "pallet-scheduler", @@ -2295,6 +2296,7 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-offences", + "pallet-preimage", "pallet-provide-randomness", "pallet-proxy", "pallet-scheduler", @@ -2507,6 +2509,7 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-offences", + "pallet-preimage", "pallet-provide-randomness", "pallet-proxy", "pallet-scheduler", @@ -5095,6 +5098,22 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-preimage" +version = "4.0.0-dev" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-02#80f060dfad0363af03dbecbe39c6fa9b99042acc" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-provide-randomness" version = "3.0.0" diff --git a/end2end-tests/cucumber-features/balance_transfer.feature b/end2end-tests/cucumber-features/balance_transfer.feature index ecddb1d6655adce4ac683a112edf3c7a4f95d148..21fb3036de0e6b56fb6b842cac58b31be92ce6ae 100644 --- a/end2end-tests/cucumber-features/balance_transfer.feature +++ b/end2end-tests/cucumber-features/balance_transfer.feature @@ -1,6 +1,28 @@ Feature: Balance transfer - Scenario: If alice sends 5 ĞD to Dave, Dave will get 5 ĞD - Given alice have 10 ĞD + Scenario: Create a new account with enough founds When alice send 5 ĞD to dave Then dave should have 5 ĞD + When 1 block later + """ + The blockchain should automatically withdraw account creation tax (3 ĞD) + """ + Then dave should have 2 ĞD + + Scenario: Create a new account without enough founds then retry with enough founds + When alice send 2 ĞD to eve + Then eve should have 2 ĞD + When 1 block later + """ + The blockchain should automatically destroy Evec account + because Eve not have enough founds to pay the new account tax + """ + Then eve should have 0 ĞD + When alice send 5 ĞD to eve + Then eve should have 5 ĞD + When 1 block later + """ + The blockchain should automatically withdraw account creation tax (3 ĞD) + """ + Then eve should have 2 ĞD + diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index 4415778ccff225ffbc539867e4bb4cb671e482bf..c6f0a1888d8c4fe1ec01fb1dacbf4afc1f782aff 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -162,7 +162,7 @@ pub mod pallet { // If the account is not self-sufficient, it must pay the account creation fees let account_data = frame_system::Pallet::<T>::get(&account_id); let price = T::NewAccountPrice::get(); - if account_data.free > price { + if account_data.free >= T::ExistentialDeposit::get() + price { // The account can pay the new account price, we should: // 1. Increment providers to create the account for frame_system point of view // 2. Withdraw the "new account price" amount @@ -198,13 +198,11 @@ pub mod pallet { total_weight += 200_000; } } else { - // The charges could not be deducted, we slash the account + // The charges could not be deducted, we must destroy the account let balance_to_suppr = account_data.free.saturating_add(account_data.reserved); // Force account data supression - frame_system::Account::<T>::mutate(&account_id, |a| { - a.data.set_balances(Default::default()) - }); + frame_system::Account::<T>::remove(&account_id); Self::deposit_event(Event::ForceDestroy { who: account_id, balance: balance_to_suppr, diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index ee23ecf9b9abbb798ae52e732c6a9c1d1a84cea2..ff541ca4f86c24af84618174970731f6403b6ea3 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -186,13 +186,24 @@ where fn on_event(membership_event: &sp_membership::Event<IdtyIndex, MetaData>) -> Weight { match membership_event { sp_membership::Event::<IdtyIndex, MetaData>::MembershipAcquired(_, _) => {} - sp_membership::Event::<IdtyIndex, MetaData>::MembershipExpired(idty_index) - | sp_membership::Event::<IdtyIndex, MetaData>::MembershipRevoked(idty_index) => { - Self::dispath_idty_call(pallet_identity::Call::remove_identity { - idty_index: *idty_index, - idty_name: None, - }); + // Membership expiration cases: + // Triggered by the membership pallet: we should remove the identity only for the main + // wot + sp_membership::Event::<IdtyIndex, MetaData>::MembershipExpired(idty_index) => { + if !T::IsSubWot::get() { + Self::dispath_idty_call(pallet_identity::Call::remove_identity { + idty_index: *idty_index, + idty_name: None, + }); + } } + // Membership revocation cases: + // - Triggered by identity removal: the identity underlying will by removed by the + // caller. + // - Triggered by the membership pallet: it's ondly possible for the sub-wot, so we + // should not remove the underlying identity + // So, in any case, we must do nothing + sp_membership::Event::<IdtyIndex, MetaData>::MembershipRevoked(_) => {} sp_membership::Event::<IdtyIndex, MetaData>::MembershipRenewed(_) => {} sp_membership::Event::<IdtyIndex, MetaData>::MembershipRequested(idty_index) => { let idty_cert_meta = @@ -296,14 +307,10 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::OnRemovedCert<IdtyI && pallet_membership::Pallet::<T, I>::is_member(&receiver) { // Revoke receiver membership and disable their identity - if let Err(e) = pallet_membership::Pallet::<T, I>::revoke_membership( - RawOrigin::Root.into(), - Some(receiver), - ) { - sp_std::if_std! { - println!("fail to revoke membership: {:?}", e) - } - } + Self::dispath_idty_call(pallet_identity::Call::remove_identity { + idty_index: receiver, + idty_name: None, + }); } 0 } diff --git a/pallets/duniter-wot/src/tests.rs b/pallets/duniter-wot/src/tests.rs index 509dc7f076e1e277728c7a3cb80f49ce3618b983..b32fc9ec87e8340a24f5dddcd57f9009ed638991 100644 --- a/pallets/duniter-wot/src/tests.rs +++ b/pallets/duniter-wot/src/tests.rs @@ -187,6 +187,18 @@ fn test_new_idty_validation() { topics: vec![], } ); + + // After PendingMembershipPeriod, Ferdie identity should not expire + run_to_block(6); + assert_eq!( + Identity::identity(6), + Some(pallet_identity::IdtyValue { + next_creatable_identity_on: 0, + owner_key: 6, + removable_on: 0, + status: IdtyStatus::Validated, + }) + ); }); } @@ -271,7 +283,7 @@ fn test_idty_membership_expire_them_requested() { // Alice can't renew it's cert to Charlie assert_err!( Cert::add_cert(Origin::signed(1), 3), - pallet_certification::Error::<Test, Instance1>::CertNotAllowed + pallet_certification::Error::<Test, Instance1>::ReceiverNotFound ); }); } diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index 9a55804fd7dea1abd4d81ee3a5a089dd4a4c40e4..4e2c20fa5aaaa857d99940ece1c561b447c631ee 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -379,7 +379,7 @@ pub mod pallet { Error::<T>::InvalidRevocationProof ); if let Some(idty_index) = <IdentityIndexOf<T>>::take(&payload.owner_key) { - Self::do_remove_identity(idty_index, Some(&payload.owner_key)); + Self::do_remove_identity(idty_index); Ok(().into()) } else { Err(Error::<T>::IdtyNotFound.into()) @@ -394,7 +394,7 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { ensure_root(origin)?; - Self::do_remove_identity(idty_index, None); + Self::do_remove_identity(idty_index); if let Some(idty_name) = idty_name { <IdentitiesNames<T>>::remove(idty_name); } @@ -499,15 +499,12 @@ pub mod pallet { // INTERNAL FUNCTIONS // impl<T: Config> Pallet<T> { - pub(super) fn do_remove_identity( - idty_index: T::IdtyIndex, - maybe_owner_key: Option<&T::AccountId>, - ) -> Weight { - if let Some(idty_val) = Identities::<T>::take(idty_index) { - T::RemoveIdentityConsumers::remove_idty_consumers(idty_index); - if let Some(owner_key) = maybe_owner_key { - IdentityIndexOf::<T>::remove(owner_key); - } + pub(super) fn do_remove_identity(idty_index: T::IdtyIndex) -> Weight { + if let Some(idty_val) = Identities::<T>::get(idty_index) { + let _ = T::RemoveIdentityConsumers::remove_idty_consumers(idty_index); + IdentityIndexOf::<T>::remove(&idty_val.owner_key); + // Identity should be removed after the consumers of the identity + Identities::<T>::remove(idty_index); frame_system::Pallet::<T>::dec_sufficients(&idty_val.owner_key); Self::deposit_event(Event::IdtyRemoved { idty_index }); T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Removed); @@ -529,8 +526,7 @@ pub mod pallet { for (idty_index, idty_status) in IdentitiesRemovableOn::<T>::take(block_number) { if let Ok(idty_val) = <Identities<T>>::try_get(idty_index) { if idty_val.removable_on == block_number && idty_val.status == idty_status { - total_weight += - Self::do_remove_identity(idty_index, Some(&idty_val.owner_key)) + total_weight += Self::do_remove_identity(idty_index) } } } diff --git a/pallets/identity/src/types.rs b/pallets/identity/src/types.rs index 02931d2243441f804253657780a27a050a03cf37..456cf3023c6ebd517c5d9b8b8bf8969abf0dc967 100644 --- a/pallets/identity/src/types.rs +++ b/pallets/identity/src/types.rs @@ -77,7 +77,7 @@ impl Default for IdtyStatus { } } -#[cfg_attr(feature = "std", derive(Deserialize, Serialize))] +#[cfg_attr(feature = "std", derive(Debug, Deserialize, Serialize))] #[derive(Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] pub struct IdtyValue<BlockNumber, AccountId> { pub next_creatable_identity_on: BlockNumber, diff --git a/pallets/membership/src/lib.rs b/pallets/membership/src/lib.rs index 1dc2c7ee876bf807c720a853bd96ceb036619dfc..af1e859d20638bdf9a81d81579350ca352d67dc5 100644 --- a/pallets/membership/src/lib.rs +++ b/pallets/membership/src/lib.rs @@ -405,10 +405,12 @@ pub mod pallet { let mut total_weight: Weight = 0; for idty_id in PendingMembershipsExpireOn::<T, I>::take(block_number) { - PendingMembership::<T, I>::remove(&idty_id); - Self::deposit_event(Event::PendingMembershipExpired(idty_id)); - total_weight += - T::OnEvent::on_event(&sp_membership::Event::PendingMembershipExpired(idty_id)); + if PendingMembership::<T, I>::take(&idty_id).is_some() { + Self::deposit_event(Event::PendingMembershipExpired(idty_id)); + total_weight += T::OnEvent::on_event( + &sp_membership::Event::PendingMembershipExpired(idty_id), + ); + } } total_weight diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index b1284faec893738dc08e2d2775328162477d60be..d7407081c20b576fdfaea8914a972d4501dbf940 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -83,6 +83,7 @@ macro_rules! pallets_config { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; pub const MaxScheduledPerBlock: u32 = 50; + pub const NoPreimagePostponement: Option<u32> = Some(10); } impl pallet_scheduler::Config for Runtime { type Event = Event; @@ -94,7 +95,7 @@ macro_rules! pallets_config { type OriginPrivilegeCmp = EqualPrivilegeOnly; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>; - type PreimageProvider = (); + type PreimageProvider = Preimage; type NoPreimagePostponement = (); } @@ -257,6 +258,30 @@ macro_rules! pallets_config { type MaxAuthorities = MaxAuthorities; } + // ONCHAIN GOVERNANCE // + + impl pallet_upgrade_origin::Config for Runtime { + type Event = Event; + type Call = Call; + type UpgradableOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, SmithsInstance>; + } + + parameter_types! { + pub const PreimageMaxSize: u32 = 4096 * 1024; + pub const PreimageBaseDeposit: Balance = deposit(2, 64); + pub const PreimageByteDeposit: Balance = deposit(0, 1); + } + + impl pallet_preimage::Config for Runtime { + type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>; + type Event = Event; + type Currency = Balances; + type ManagerOrigin = EnsureRoot<AccountId>; + type MaxSize = PreimageMaxSize; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; + } + // UTILITIES // impl pallet_atomic_swap::Config for Runtime { diff --git a/runtime/g1/Cargo.toml b/runtime/g1/Cargo.toml index 2afc82f4113cc160a4b8214b2afa9097ae4a135d..9745564391996f7abfc8811a966e35940c2edee5 100644 --- a/runtime/g1/Cargo.toml +++ b/runtime/g1/Cargo.toml @@ -52,6 +52,7 @@ std = [ 'pallet-provide-randomness/std', 'pallet-im-online/std', 'pallet-multisig/std', + 'pallet-preimage/std', 'pallet-proxy/std', 'pallet-session/std', 'pallet-sudo/std', @@ -147,6 +148,7 @@ pallet-grandpa = { git = 'https://github.com/librelois/substrate.git', branch = pallet-im-online = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-offences = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-multisig = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } +pallet-preimage = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-proxy = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-scheduler = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-session = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 6c64ed3ecc57782e04465e09c87a45a86aac3467..25f3de530ce9151a21d98544dacc72acfbfe45bf 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -47,6 +47,7 @@ use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use sp_api::impl_runtime_apis; +use sp_core::u32_trait::*; use sp_core::OpaqueMetadata; use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys}; use sp_runtime::{ @@ -221,6 +222,8 @@ construct_runtime!( // Governance stuff. Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, + UpgradeOrigin: pallet_upgrade_origin::{Pallet, Call, Event} = 21, + Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, // Universal dividend UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml index 38cae30693162f60d74d4728043f345fa021bc56..ba9dce15db155086702dfb3fdd8995acf70f7140 100644 --- a/runtime/gdev/Cargo.toml +++ b/runtime/gdev/Cargo.toml @@ -52,6 +52,7 @@ std = [ 'pallet-provide-randomness/std', 'pallet-im-online/std', 'pallet-multisig/std', + 'pallet-preimage/std', 'pallet-proxy/std', 'pallet-session/std', 'pallet-sudo/std', @@ -147,6 +148,7 @@ pallet-grandpa = { git = 'https://github.com/librelois/substrate.git', branch = pallet-im-online = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-offences = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-multisig = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } +pallet-preimage = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-proxy = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-scheduler = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-session = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index f062f16ddfda83a63984364d2f5a6cb1b931f52b..f4c3dcd129678b2c69aede06c8ecc404aa097ed0 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -233,12 +233,6 @@ common_runtime::pallets_config! { type Event = Event; type Call = Call; } - - impl pallet_upgrade_origin::Config for Runtime { - type Event = Event; - type Call = Call; - type UpgradableOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, SmithsInstance>; - } } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -277,6 +271,7 @@ construct_runtime!( // Governance stuff Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, UpgradeOrigin: pallet_upgrade_origin::{Pallet, Call, Event} = 21, + Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, // Universal dividend UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 6ffc2f586ac041a0875188afb00441dcc62a753b..6c339a71e1e3e2a5af7fbaad6dfb12c5c7b120ec 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -97,10 +97,6 @@ fn test_remove_identity() { System::events()[0].event, Event::Membership(pallet_membership::Event::MembershipRevoked(4)) ); - /*println!( - "{}", - get_account_id_from_seed::<sp_core::sr25519::Public>("Charlie") - );*/ assert_eq!( System::events()[1].event, Event::System(frame_system::Event::KilledAccount { @@ -111,7 +107,17 @@ fn test_remove_identity() { System::events()[2].event, Event::Identity(pallet_identity::Event::IdtyRemoved { idty_index: 4 }) ); - //println!("{:#?}", events); + + // The identity should be removed from UdAccountsStorage + assert_eq!(UdAccountsStorage::accounts_len(), 3); + assert_eq!( + UdAccountsStorage::accounts_list(), + vec![ + AccountKeyring::Bob.to_account_id(), + AccountKeyring::Charlie.to_account_id(), + AccountKeyring::Alice.to_account_id(), + ] + ); }); } @@ -155,11 +161,11 @@ fn test_create_new_account_with_insufficient_balance() { .execute_with(|| { run_to_block(2); - // Should be able to transfer 2 units to a new account + // Should be able to transfer 4 units to a new account assert_ok!(Balances::transfer( frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), MultiAddress::Id(AccountKeyring::Eve.to_account_id()), - 200 + 400 )); let events = System::events(); //println!("{:#?}", events); @@ -168,7 +174,7 @@ fn test_create_new_account_with_insufficient_balance() { System::events()[0].event, Event::Balances(pallet_balances::Event::Endowed { account: AccountKeyring::Eve.to_account_id(), - free_balance: 200, + free_balance: 400, }) ); assert_eq!( @@ -176,7 +182,7 @@ fn test_create_new_account_with_insufficient_balance() { Event::Balances(pallet_balances::Event::Transfer { from: AccountKeyring::Alice.to_account_id(), to: AccountKeyring::Eve.to_account_id(), - amount: 200, + amount: 400, }) ); @@ -190,25 +196,25 @@ fn test_create_new_account_with_insufficient_balance() { System::events()[0].event, Event::Account(pallet_duniter_account::Event::ForceDestroy { who: AccountKeyring::Eve.to_account_id(), - balance: 200, + balance: 400, }) ); assert_eq!( System::events()[1].event, Event::Balances(pallet_balances::Event::Deposit { who: Treasury::account_id(), - amount: 200, + amount: 400, }) ); assert_eq!( System::events()[2].event, - Event::Treasury(pallet_treasury::Event::Deposit { value: 200 }) + Event::Treasury(pallet_treasury::Event::Deposit { value: 400 }) ); assert_eq!( Balances::free_balance(AccountKeyring::Eve.to_account_id()), 0 ); - assert_eq!(Balances::free_balance(Treasury::account_id()), 400); + assert_eq!(Balances::free_balance(Treasury::account_id()), 600); }); } diff --git a/runtime/gtest/Cargo.toml b/runtime/gtest/Cargo.toml index b95a5c1f45f944001f40a98c1aa1e39db99dbf49..93c347518a7e15c4a4ae7b620f68f4c2a21ecc06 100644 --- a/runtime/gtest/Cargo.toml +++ b/runtime/gtest/Cargo.toml @@ -52,6 +52,7 @@ std = [ 'pallet-provide-randomness/std', 'pallet-im-online/std', 'pallet-multisig/std', + 'pallet-preimage/std', 'pallet-proxy/std', 'pallet-session/std', 'pallet-sudo/std', @@ -147,6 +148,7 @@ pallet-grandpa = { git = 'https://github.com/librelois/substrate.git', branch = pallet-im-online = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-offences = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-multisig = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } +pallet-preimage = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-proxy = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-scheduler = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } pallet-session = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false } diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index f72dc9c19f2ed3d5a688db856764a3a356a3469d..7225730886ba6873c7aef5ba98c49546dc0712ad 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -47,6 +47,7 @@ use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use sp_api::impl_runtime_apis; +use sp_core::u32_trait::*; use sp_core::OpaqueMetadata; use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys}; use sp_runtime::{ @@ -222,6 +223,8 @@ construct_runtime!( // Governance stuff. Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, + UpgradeOrigin: pallet_upgrade_origin::{Pallet, Call, Event} = 21, + Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, // Universal dividend UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, diff --git a/xtask/src/release_runtime.rs b/xtask/src/release_runtime.rs index e4e20a5a73189f25ad9fa9486ac98e1a3af761c6..978ea69827a3ecf44e033ca39407ff2027e9f1b5 100644 --- a/xtask/src/release_runtime.rs +++ b/xtask/src/release_runtime.rs @@ -57,12 +57,6 @@ pub(super) fn release_runtime(_spec_version: u32) -> Result<()> { // TODO: create and push a git tag runtime-{spec_version} - // Get current dir - let pwd = std::env::current_dir()? - .into_os_string() - .into_string() - .map_err(|_| anyhow!("Fail to read current dir path: invalid utf8 string!"))?; - // Build the new runtime println!("Build gdev-runtime… (take a while)"); let output = Command::new("docker") @@ -89,7 +83,7 @@ pub(super) fn release_runtime(_spec_version: u32) -> Result<()> { std::str::from_utf8(&output.stdout)? .lines() .last() - .ok_or(anyhow!("empty srtool output"))?, + .ok_or_else(|| anyhow!("empty srtool output"))?, ) .with_context(|| "Fail to parse srtool json output")?;