Skip to content

Commit

Permalink
MESH-2221: Remove minimum balance for multisigs (#1723)
Browse files Browse the repository at this point in the history
* Remove minimum balance for multisigs

* Remove import

* Update tests

* Fix more tests

* Fix tests

* Linting

* Remove unused error
  • Loading branch information
adamdossa authored Sep 18, 2024
1 parent 5414c35 commit 1cb6198
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 37 deletions.
4 changes: 0 additions & 4 deletions pallets/common/src/traits/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ pub trait Config: CommonConfig + pallet_timestamp::Config + crate::traits::base:
/// POLYX given to primary keys of all new Identities
type InitialPOLYX: Get<<Self::Balances as Currency<Self::AccountId>>::Balance>;

/// Only allow MultiSig primary/secondary keys to be removed from an identity
/// if its POLYX balance is below this limit.
type MultiSigBalanceLimit: Get<<Self::Balances as Currency<Self::AccountId>>::Balance>;

/// Maximum number of authorizations an identity can give.
type MaxGivenAuths: Get<u32>;
}
Expand Down
8 changes: 0 additions & 8 deletions pallets/identity/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use polymesh_common_utilities::group::GroupTrait;
use polymesh_common_utilities::identity::{
CreateChildIdentityWithAuth, SecondaryKeyWithAuth, TargetIdAuthorization,
};
use polymesh_common_utilities::multisig::MultiSigSubTrait as _;
use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee as _, ProtocolOp};
use polymesh_common_utilities::traits::{AccountCallPermissionsData, CheckAccountCallPermissions};
use polymesh_common_utilities::SystematicIssuers;
Expand Down Expand Up @@ -204,13 +203,6 @@ impl<T: Config> Module<T> {
<AccountKeyRefCount<T>>::get(key) == 0,
Error::<T>::AccountKeyIsBeingUsed
);
// Do not allow unlinking MultiSig keys with balance >= 1 POLYX.
if T::MultiSig::is_multisig(key) {
ensure!(
T::Balances::total_balance(key) < T::MultiSigBalanceLimit::get(),
Error::<T>::MultiSigHasBalance
);
}
Ok(())
}

Expand Down
2 changes: 0 additions & 2 deletions pallets/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,6 @@ decl_error! {
NotASigner,
/// Cannot convert a `T::AccountId` to `AnySignature::Signer::AccountId`.
CannotDecodeSignerAccountId,
/// Multisig can not be unlinked from an identity while it still holds POLYX
MultiSigHasBalance,
/// The account key is being used, it can't be unlinked.
AccountKeyIsBeingUsed,
/// A custom scope is too long.
Expand Down
2 changes: 0 additions & 2 deletions pallets/runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ parameter_types! {
pub const TransactionByteFee: Balance = 10 * MILLICENTS;
/// We want the noop transaction to cost 0.03 POLYX
pub const PolyXBaseFee: Balance = 3 * CENTS;
/// MultiSig balance limit: 1 POLYX
pub const MultiSigBalanceLimit: Balance = POLY;
/// The maximum weight of the pips extrinsic `enact_snapshot_results` which equals to
/// `MaximumBlockWeight * AvailableBlockRatio`.
pub const PipsEnactSnapshotMaximumWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_mul(75).saturating_div(100);
Expand Down
1 change: 0 additions & 1 deletion pallets/runtime/develop/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ impl polymesh_common_utilities::traits::identity::Config for Runtime {
type IdentityFn = pallet_identity::Module<Runtime>;
type SchedulerOrigin = OriginCaller;
type InitialPOLYX = InitialPOLYX;
type MultiSigBalanceLimit = polymesh_runtime_common::MultiSigBalanceLimit;
type MaxGivenAuths = MaxGivenAuths;
}

Expand Down
1 change: 0 additions & 1 deletion pallets/runtime/mainnet/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ impl polymesh_common_utilities::traits::identity::Config for Runtime {
type IdentityFn = pallet_identity::Module<Runtime>;
type SchedulerOrigin = OriginCaller;
type InitialPOLYX = InitialPOLYX;
type MultiSigBalanceLimit = polymesh_runtime_common::MultiSigBalanceLimit;
type MaxGivenAuths = MaxGivenAuths;
}

Expand Down
1 change: 0 additions & 1 deletion pallets/runtime/testnet/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ impl polymesh_common_utilities::traits::identity::Config for Runtime {
type IdentityFn = pallet_identity::Module<Runtime>;
type SchedulerOrigin = OriginCaller;
type InitialPOLYX = InitialPOLYX;
type MultiSigBalanceLimit = polymesh_runtime_common::MultiSigBalanceLimit;
type MaxGivenAuths = MaxGivenAuths;
}

Expand Down
11 changes: 0 additions & 11 deletions pallets/runtime/tests/src/identity_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,6 @@ fn do_remove_secondary_keys_test_with_externalities() {
assert_eq!(Identity::get_identity(&ms_address), Some(alice.did));
assert_eq!(Identity::get_identity(&bob_key), None);

// Try removing multisig while it has funds
assert_noop!(
Identity::remove_secondary_keys(alice.origin(), vec![ms_address.clone()]),
Error::MultiSigHasBalance
);

// Check DidRecord.
assert_eq!(Identity::get_identity(&dave_key), None);
assert_eq!(Identity::get_identity(&ms_address), Some(alice.did));
Expand Down Expand Up @@ -838,11 +832,6 @@ fn leave_identity_test_with_externalities() {
ms_address.clone().into(),
2 * POLY
));
// multisig tries leaving identity while it has funds
assert_noop!(
Identity::leave_identity_as_key(Origin::signed(ms_address.clone())),
Error::MultiSigHasBalance
);

// Check DidRecord.
assert_eq!(Identity::get_identity(&dave_key), None);
Expand Down
12 changes: 7 additions & 5 deletions pallets/runtime/tests/src/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,13 @@ fn rotate_multisig_primary_key_with_balance() {
None,
)
.unwrap();
// Fails because the current MultiSig primary_key has a balance.
assert_eq!(
Identity::accept_primary_key(Origin::signed(charlie_key.clone()), auth_id, None),
Err(IdError::MultiSigHasBalance.into()),
);

// Succeeds
assert_ok!(Identity::accept_primary_key(
Origin::signed(charlie_key.clone()),
auth_id,
None
));
});
}

Expand Down
1 change: 0 additions & 1 deletion pallets/runtime/tests/src/staking/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ impl polymesh_common_utilities::traits::identity::Config for Test {
type IdentityFn = pallet_identity::Module<Test>;
type SchedulerOrigin = OriginCaller;
type InitialPOLYX = InitialPOLYX;
type MultiSigBalanceLimit = polymesh_runtime_common::MultiSigBalanceLimit;
type MaxGivenAuths = MaxGivenAuths;
}

Expand Down
1 change: 0 additions & 1 deletion pallets/runtime/tests/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,6 @@ impl polymesh_common_utilities::traits::identity::Config for TestStorage {
type IdentityFn = identity::Module<TestStorage>;
type SchedulerOrigin = OriginCaller;
type InitialPOLYX = InitialPOLYX;
type MultiSigBalanceLimit = polymesh_runtime_common::MultiSigBalanceLimit;
type MaxGivenAuths = MaxGivenAuths;
}

Expand Down

0 comments on commit 1cb6198

Please sign in to comment.