Skip to content
Snippets Groups Projects
Commit e2a07052 authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'release/runtime-100'

parents 4e451756 e16ccd5f
No related branches found
No related tags found
No related merge requests found
Showing
with 155 additions and 67 deletions
...@@ -2227,6 +2227,7 @@ dependencies = [ ...@@ -2227,6 +2227,7 @@ dependencies = [
"pallet-membership", "pallet-membership",
"pallet-multisig", "pallet-multisig",
"pallet-offences", "pallet-offences",
"pallet-preimage",
"pallet-provide-randomness", "pallet-provide-randomness",
"pallet-proxy", "pallet-proxy",
"pallet-scheduler", "pallet-scheduler",
...@@ -2295,6 +2296,7 @@ dependencies = [ ...@@ -2295,6 +2296,7 @@ dependencies = [
"pallet-membership", "pallet-membership",
"pallet-multisig", "pallet-multisig",
"pallet-offences", "pallet-offences",
"pallet-preimage",
"pallet-provide-randomness", "pallet-provide-randomness",
"pallet-proxy", "pallet-proxy",
"pallet-scheduler", "pallet-scheduler",
...@@ -2507,6 +2509,7 @@ dependencies = [ ...@@ -2507,6 +2509,7 @@ dependencies = [
"pallet-membership", "pallet-membership",
"pallet-multisig", "pallet-multisig",
"pallet-offences", "pallet-offences",
"pallet-preimage",
"pallet-provide-randomness", "pallet-provide-randomness",
"pallet-proxy", "pallet-proxy",
"pallet-scheduler", "pallet-scheduler",
...@@ -5095,6 +5098,22 @@ dependencies = [ ...@@ -5095,6 +5098,22 @@ dependencies = [
"sp-std", "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]] [[package]]
name = "pallet-provide-randomness" name = "pallet-provide-randomness"
version = "3.0.0" version = "3.0.0"
......
Feature: Balance transfer Feature: Balance transfer
Scenario: If alice sends 5 ĞD to Dave, Dave will get 5 ĞD Scenario: Create a new account with enough founds
Given alice have 10 ĞD
When alice send 5 ĞD to dave When alice send 5 ĞD to dave
Then dave should have 5 ĞD 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
...@@ -162,7 +162,7 @@ pub mod pallet { ...@@ -162,7 +162,7 @@ pub mod pallet {
// If the account is not self-sufficient, it must pay the account creation fees // 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 account_data = frame_system::Pallet::<T>::get(&account_id);
let price = T::NewAccountPrice::get(); 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: // The account can pay the new account price, we should:
// 1. Increment providers to create the account for frame_system point of view // 1. Increment providers to create the account for frame_system point of view
// 2. Withdraw the "new account price" amount // 2. Withdraw the "new account price" amount
...@@ -198,13 +198,11 @@ pub mod pallet { ...@@ -198,13 +198,11 @@ pub mod pallet {
total_weight += 200_000; total_weight += 200_000;
} }
} else { } 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 = let balance_to_suppr =
account_data.free.saturating_add(account_data.reserved); account_data.free.saturating_add(account_data.reserved);
// Force account data supression // Force account data supression
frame_system::Account::<T>::mutate(&account_id, |a| { frame_system::Account::<T>::remove(&account_id);
a.data.set_balances(Default::default())
});
Self::deposit_event(Event::ForceDestroy { Self::deposit_event(Event::ForceDestroy {
who: account_id, who: account_id,
balance: balance_to_suppr, balance: balance_to_suppr,
......
...@@ -186,13 +186,24 @@ where ...@@ -186,13 +186,24 @@ where
fn on_event(membership_event: &sp_membership::Event<IdtyIndex, MetaData>) -> Weight { fn on_event(membership_event: &sp_membership::Event<IdtyIndex, MetaData>) -> Weight {
match membership_event { match membership_event {
sp_membership::Event::<IdtyIndex, MetaData>::MembershipAcquired(_, _) => {} sp_membership::Event::<IdtyIndex, MetaData>::MembershipAcquired(_, _) => {}
sp_membership::Event::<IdtyIndex, MetaData>::MembershipExpired(idty_index) // Membership expiration cases:
| sp_membership::Event::<IdtyIndex, MetaData>::MembershipRevoked(idty_index) => { // 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 { Self::dispath_idty_call(pallet_identity::Call::remove_identity {
idty_index: *idty_index, idty_index: *idty_index,
idty_name: None, 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>::MembershipRenewed(_) => {}
sp_membership::Event::<IdtyIndex, MetaData>::MembershipRequested(idty_index) => { sp_membership::Event::<IdtyIndex, MetaData>::MembershipRequested(idty_index) => {
let idty_cert_meta = let idty_cert_meta =
...@@ -296,14 +307,10 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::OnRemovedCert<IdtyI ...@@ -296,14 +307,10 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::OnRemovedCert<IdtyI
&& pallet_membership::Pallet::<T, I>::is_member(&receiver) && pallet_membership::Pallet::<T, I>::is_member(&receiver)
{ {
// Revoke receiver membership and disable their identity // Revoke receiver membership and disable their identity
if let Err(e) = pallet_membership::Pallet::<T, I>::revoke_membership( Self::dispath_idty_call(pallet_identity::Call::remove_identity {
RawOrigin::Root.into(), idty_index: receiver,
Some(receiver), idty_name: None,
) { });
sp_std::if_std! {
println!("fail to revoke membership: {:?}", e)
}
}
} }
0 0
} }
......
...@@ -187,6 +187,18 @@ fn test_new_idty_validation() { ...@@ -187,6 +187,18 @@ fn test_new_idty_validation() {
topics: vec![], 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() { ...@@ -271,7 +283,7 @@ fn test_idty_membership_expire_them_requested() {
// Alice can't renew it's cert to Charlie // Alice can't renew it's cert to Charlie
assert_err!( assert_err!(
Cert::add_cert(Origin::signed(1), 3), Cert::add_cert(Origin::signed(1), 3),
pallet_certification::Error::<Test, Instance1>::CertNotAllowed pallet_certification::Error::<Test, Instance1>::ReceiverNotFound
); );
}); });
} }
...@@ -379,7 +379,7 @@ pub mod pallet { ...@@ -379,7 +379,7 @@ pub mod pallet {
Error::<T>::InvalidRevocationProof Error::<T>::InvalidRevocationProof
); );
if let Some(idty_index) = <IdentityIndexOf<T>>::take(&payload.owner_key) { 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()) Ok(().into())
} else { } else {
Err(Error::<T>::IdtyNotFound.into()) Err(Error::<T>::IdtyNotFound.into())
...@@ -394,7 +394,7 @@ pub mod pallet { ...@@ -394,7 +394,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
ensure_root(origin)?; ensure_root(origin)?;
Self::do_remove_identity(idty_index, None); Self::do_remove_identity(idty_index);
if let Some(idty_name) = idty_name { if let Some(idty_name) = idty_name {
<IdentitiesNames<T>>::remove(idty_name); <IdentitiesNames<T>>::remove(idty_name);
} }
...@@ -499,15 +499,12 @@ pub mod pallet { ...@@ -499,15 +499,12 @@ pub mod pallet {
// INTERNAL FUNCTIONS // // INTERNAL FUNCTIONS //
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
pub(super) fn do_remove_identity( pub(super) fn do_remove_identity(idty_index: T::IdtyIndex) -> Weight {
idty_index: T::IdtyIndex, if let Some(idty_val) = Identities::<T>::get(idty_index) {
maybe_owner_key: Option<&T::AccountId>, let _ = T::RemoveIdentityConsumers::remove_idty_consumers(idty_index);
) -> Weight { IdentityIndexOf::<T>::remove(&idty_val.owner_key);
if let Some(idty_val) = Identities::<T>::take(idty_index) { // Identity should be removed after the consumers of the identity
T::RemoveIdentityConsumers::remove_idty_consumers(idty_index); Identities::<T>::remove(idty_index);
if let Some(owner_key) = maybe_owner_key {
IdentityIndexOf::<T>::remove(owner_key);
}
frame_system::Pallet::<T>::dec_sufficients(&idty_val.owner_key); frame_system::Pallet::<T>::dec_sufficients(&idty_val.owner_key);
Self::deposit_event(Event::IdtyRemoved { idty_index }); Self::deposit_event(Event::IdtyRemoved { idty_index });
T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Removed); T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Removed);
...@@ -529,8 +526,7 @@ pub mod pallet { ...@@ -529,8 +526,7 @@ pub mod pallet {
for (idty_index, idty_status) in IdentitiesRemovableOn::<T>::take(block_number) { for (idty_index, idty_status) in IdentitiesRemovableOn::<T>::take(block_number) {
if let Ok(idty_val) = <Identities<T>>::try_get(idty_index) { if let Ok(idty_val) = <Identities<T>>::try_get(idty_index) {
if idty_val.removable_on == block_number && idty_val.status == idty_status { if idty_val.removable_on == block_number && idty_val.status == idty_status {
total_weight += total_weight += Self::do_remove_identity(idty_index)
Self::do_remove_identity(idty_index, Some(&idty_val.owner_key))
} }
} }
} }
......
...@@ -77,7 +77,7 @@ impl Default for IdtyStatus { ...@@ -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)] #[derive(Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
pub struct IdtyValue<BlockNumber, AccountId> { pub struct IdtyValue<BlockNumber, AccountId> {
pub next_creatable_identity_on: BlockNumber, pub next_creatable_identity_on: BlockNumber,
......
...@@ -405,10 +405,12 @@ pub mod pallet { ...@@ -405,10 +405,12 @@ pub mod pallet {
let mut total_weight: Weight = 0; let mut total_weight: Weight = 0;
for idty_id in PendingMembershipsExpireOn::<T, I>::take(block_number) { for idty_id in PendingMembershipsExpireOn::<T, I>::take(block_number) {
PendingMembership::<T, I>::remove(&idty_id); if PendingMembership::<T, I>::take(&idty_id).is_some() {
Self::deposit_event(Event::PendingMembershipExpired(idty_id)); Self::deposit_event(Event::PendingMembershipExpired(idty_id));
total_weight += total_weight += T::OnEvent::on_event(
T::OnEvent::on_event(&sp_membership::Event::PendingMembershipExpired(idty_id)); &sp_membership::Event::PendingMembershipExpired(idty_id),
);
}
} }
total_weight total_weight
......
...@@ -83,6 +83,7 @@ macro_rules! pallets_config { ...@@ -83,6 +83,7 @@ macro_rules! pallets_config {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
BlockWeights::get().max_block; BlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 50; pub const MaxScheduledPerBlock: u32 = 50;
pub const NoPreimagePostponement: Option<u32> = Some(10);
} }
impl pallet_scheduler::Config for Runtime { impl pallet_scheduler::Config for Runtime {
type Event = Event; type Event = Event;
...@@ -94,7 +95,7 @@ macro_rules! pallets_config { ...@@ -94,7 +95,7 @@ macro_rules! pallets_config {
type OriginPrivilegeCmp = EqualPrivilegeOnly; type OriginPrivilegeCmp = EqualPrivilegeOnly;
type MaxScheduledPerBlock = MaxScheduledPerBlock; type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>; type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type PreimageProvider = (); type PreimageProvider = Preimage;
type NoPreimagePostponement = (); type NoPreimagePostponement = ();
} }
...@@ -257,6 +258,30 @@ macro_rules! pallets_config { ...@@ -257,6 +258,30 @@ macro_rules! pallets_config {
type MaxAuthorities = MaxAuthorities; 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 // // UTILITIES //
impl pallet_atomic_swap::Config for Runtime { impl pallet_atomic_swap::Config for Runtime {
......
...@@ -52,6 +52,7 @@ std = [ ...@@ -52,6 +52,7 @@ std = [
'pallet-provide-randomness/std', 'pallet-provide-randomness/std',
'pallet-im-online/std', 'pallet-im-online/std',
'pallet-multisig/std', 'pallet-multisig/std',
'pallet-preimage/std',
'pallet-proxy/std', 'pallet-proxy/std',
'pallet-session/std', 'pallet-session/std',
'pallet-sudo/std', 'pallet-sudo/std',
...@@ -147,6 +148,7 @@ pallet-grandpa = { git = 'https://github.com/librelois/substrate.git', branch = ...@@ -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-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-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-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-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-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 } pallet-session = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
......
...@@ -47,6 +47,7 @@ use frame_system::EnsureRoot; ...@@ -47,6 +47,7 @@ use frame_system::EnsureRoot;
use pallet_grandpa::fg_primitives; use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use sp_api::impl_runtime_apis; use sp_api::impl_runtime_apis;
use sp_core::u32_trait::*;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys}; use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys};
use sp_runtime::{ use sp_runtime::{
...@@ -221,6 +222,8 @@ construct_runtime!( ...@@ -221,6 +222,8 @@ construct_runtime!(
// Governance stuff. // Governance stuff.
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, 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 // Universal dividend
UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30,
......
...@@ -52,6 +52,7 @@ std = [ ...@@ -52,6 +52,7 @@ std = [
'pallet-provide-randomness/std', 'pallet-provide-randomness/std',
'pallet-im-online/std', 'pallet-im-online/std',
'pallet-multisig/std', 'pallet-multisig/std',
'pallet-preimage/std',
'pallet-proxy/std', 'pallet-proxy/std',
'pallet-session/std', 'pallet-session/std',
'pallet-sudo/std', 'pallet-sudo/std',
...@@ -147,6 +148,7 @@ pallet-grandpa = { git = 'https://github.com/librelois/substrate.git', branch = ...@@ -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-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-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-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-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-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 } pallet-session = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
......
...@@ -233,12 +233,6 @@ common_runtime::pallets_config! { ...@@ -233,12 +233,6 @@ common_runtime::pallets_config! {
type Event = Event; type Event = Event;
type Call = Call; 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. // Create the runtime by composing the FRAME pallets that were previously configured.
...@@ -277,6 +271,7 @@ construct_runtime!( ...@@ -277,6 +271,7 @@ construct_runtime!(
// Governance stuff // Governance stuff
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20,
UpgradeOrigin: pallet_upgrade_origin::{Pallet, Call, Event} = 21, UpgradeOrigin: pallet_upgrade_origin::{Pallet, Call, Event} = 21,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22,
// Universal dividend // Universal dividend
UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30,
......
...@@ -97,10 +97,6 @@ fn test_remove_identity() { ...@@ -97,10 +97,6 @@ fn test_remove_identity() {
System::events()[0].event, System::events()[0].event,
Event::Membership(pallet_membership::Event::MembershipRevoked(4)) Event::Membership(pallet_membership::Event::MembershipRevoked(4))
); );
/*println!(
"{}",
get_account_id_from_seed::<sp_core::sr25519::Public>("Charlie")
);*/
assert_eq!( assert_eq!(
System::events()[1].event, System::events()[1].event,
Event::System(frame_system::Event::KilledAccount { Event::System(frame_system::Event::KilledAccount {
...@@ -111,7 +107,17 @@ fn test_remove_identity() { ...@@ -111,7 +107,17 @@ fn test_remove_identity() {
System::events()[2].event, System::events()[2].event,
Event::Identity(pallet_identity::Event::IdtyRemoved { idty_index: 4 }) 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() { ...@@ -155,11 +161,11 @@ fn test_create_new_account_with_insufficient_balance() {
.execute_with(|| { .execute_with(|| {
run_to_block(2); 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( assert_ok!(Balances::transfer(
frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(),
MultiAddress::Id(AccountKeyring::Eve.to_account_id()), MultiAddress::Id(AccountKeyring::Eve.to_account_id()),
200 400
)); ));
let events = System::events(); let events = System::events();
//println!("{:#?}", events); //println!("{:#?}", events);
...@@ -168,7 +174,7 @@ fn test_create_new_account_with_insufficient_balance() { ...@@ -168,7 +174,7 @@ fn test_create_new_account_with_insufficient_balance() {
System::events()[0].event, System::events()[0].event,
Event::Balances(pallet_balances::Event::Endowed { Event::Balances(pallet_balances::Event::Endowed {
account: AccountKeyring::Eve.to_account_id(), account: AccountKeyring::Eve.to_account_id(),
free_balance: 200, free_balance: 400,
}) })
); );
assert_eq!( assert_eq!(
...@@ -176,7 +182,7 @@ fn test_create_new_account_with_insufficient_balance() { ...@@ -176,7 +182,7 @@ fn test_create_new_account_with_insufficient_balance() {
Event::Balances(pallet_balances::Event::Transfer { Event::Balances(pallet_balances::Event::Transfer {
from: AccountKeyring::Alice.to_account_id(), from: AccountKeyring::Alice.to_account_id(),
to: AccountKeyring::Eve.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() { ...@@ -190,25 +196,25 @@ fn test_create_new_account_with_insufficient_balance() {
System::events()[0].event, System::events()[0].event,
Event::Account(pallet_duniter_account::Event::ForceDestroy { Event::Account(pallet_duniter_account::Event::ForceDestroy {
who: AccountKeyring::Eve.to_account_id(), who: AccountKeyring::Eve.to_account_id(),
balance: 200, balance: 400,
}) })
); );
assert_eq!( assert_eq!(
System::events()[1].event, System::events()[1].event,
Event::Balances(pallet_balances::Event::Deposit { Event::Balances(pallet_balances::Event::Deposit {
who: Treasury::account_id(), who: Treasury::account_id(),
amount: 200, amount: 400,
}) })
); );
assert_eq!( assert_eq!(
System::events()[2].event, System::events()[2].event,
Event::Treasury(pallet_treasury::Event::Deposit { value: 200 }) Event::Treasury(pallet_treasury::Event::Deposit { value: 400 })
); );
assert_eq!( assert_eq!(
Balances::free_balance(AccountKeyring::Eve.to_account_id()), Balances::free_balance(AccountKeyring::Eve.to_account_id()),
0 0
); );
assert_eq!(Balances::free_balance(Treasury::account_id()), 400); assert_eq!(Balances::free_balance(Treasury::account_id()), 600);
}); });
} }
......
...@@ -52,6 +52,7 @@ std = [ ...@@ -52,6 +52,7 @@ std = [
'pallet-provide-randomness/std', 'pallet-provide-randomness/std',
'pallet-im-online/std', 'pallet-im-online/std',
'pallet-multisig/std', 'pallet-multisig/std',
'pallet-preimage/std',
'pallet-proxy/std', 'pallet-proxy/std',
'pallet-session/std', 'pallet-session/std',
'pallet-sudo/std', 'pallet-sudo/std',
...@@ -147,6 +148,7 @@ pallet-grandpa = { git = 'https://github.com/librelois/substrate.git', branch = ...@@ -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-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-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-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-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-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 } pallet-session = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
......
...@@ -47,6 +47,7 @@ use frame_system::EnsureRoot; ...@@ -47,6 +47,7 @@ use frame_system::EnsureRoot;
use pallet_grandpa::fg_primitives; use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use sp_api::impl_runtime_apis; use sp_api::impl_runtime_apis;
use sp_core::u32_trait::*;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys}; use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys};
use sp_runtime::{ use sp_runtime::{
...@@ -222,6 +223,8 @@ construct_runtime!( ...@@ -222,6 +223,8 @@ construct_runtime!(
// Governance stuff. // Governance stuff.
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, 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 // Universal dividend
UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30, UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 30,
......
...@@ -57,12 +57,6 @@ pub(super) fn release_runtime(_spec_version: u32) -> Result<()> { ...@@ -57,12 +57,6 @@ pub(super) fn release_runtime(_spec_version: u32) -> Result<()> {
// TODO: create and push a git tag runtime-{spec_version} // 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 // Build the new runtime
println!("Build gdev-runtime… (take a while)"); println!("Build gdev-runtime… (take a while)");
let output = Command::new("docker") let output = Command::new("docker")
...@@ -89,7 +83,7 @@ pub(super) fn release_runtime(_spec_version: u32) -> Result<()> { ...@@ -89,7 +83,7 @@ pub(super) fn release_runtime(_spec_version: u32) -> Result<()> {
std::str::from_utf8(&output.stdout)? std::str::from_utf8(&output.stdout)?
.lines() .lines()
.last() .last()
.ok_or(anyhow!("empty srtool output"))?, .ok_or_else(|| anyhow!("empty srtool output"))?,
) )
.with_context(|| "Fail to parse srtool json output")?; .with_context(|| "Fail to parse srtool json output")?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment