Skip to content

Commit dcbf2b2

Browse files
authored
Finer control of origins in pallet-account-fix (#3005)
* finer origin control * update runtime
1 parent f138676 commit dcbf2b2

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

pallets/account-fix/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,20 @@ pub mod pallet {
5050
#[pallet::config]
5151
pub trait Config: frame_system::Config + pallet_balances::Config {
5252
type Currency: ReservableCurrency<Self::AccountId>;
53+
type IncConsumerOrigin: EnsureOrigin<Self::RuntimeOrigin>;
54+
type AddBalanceOrigin: EnsureOrigin<Self::RuntimeOrigin>;
5355
type BurnOrigin: EnsureOrigin<Self::RuntimeOrigin>;
5456
}
5557

5658
#[pallet::call]
5759
impl<T: Config> Pallet<T> {
5860
#[pallet::call_index(0)]
59-
#[pallet::weight(Weight::from_parts(20_000_000u64 * (who.len() as u64), 0))]
61+
#[pallet::weight(Weight::from_parts(195_000_000 * (who.len() as u64), 0))]
6062
pub fn inc_consumers(
6163
origin: OriginFor<T>,
6264
who: Vec<T::AccountId>,
6365
) -> DispatchResultWithPostInfo {
64-
ensure_root(origin)?;
66+
let _ = T::IncConsumerOrigin::ensure_origin(origin)?;
6567
for i in &who {
6668
frame_system::Pallet::<T>::inc_consumers(i)?;
6769
}
@@ -70,14 +72,14 @@ pub mod pallet {
7072

7173
/// add some balance of an existing account
7274
#[pallet::call_index(1)]
73-
#[pallet::weight({10_000})]
74-
pub fn set_balance(
75+
#[pallet::weight({195_000_000})]
76+
pub fn add_balance(
7577
origin: OriginFor<T>,
7678
who: AccountIdLookupOf<T>,
7779
#[pallet::compact] add_free: BalanceOf<T>,
7880
#[pallet::compact] add_reserved: BalanceOf<T>,
7981
) -> DispatchResultWithPostInfo {
80-
ensure_root(origin)?;
82+
let _ = T::AddBalanceOrigin::ensure_origin(origin)?;
8183
let who = T::Lookup::lookup(who)?;
8284
let add_total = add_free + add_reserved;
8385

runtime/litentry/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
220220
impl_name: create_runtime_str!("litentry-parachain"),
221221
authoring_version: 1,
222222
// same versioning-mechanism as polkadot: use last digit for minor updates
223-
spec_version: 9194,
223+
spec_version: 9195,
224224
impl_version: 0,
225225
apis: RUNTIME_API_VERSIONS,
226226
transaction_version: 1,
@@ -731,7 +731,9 @@ impl pallet_identity::Config for Runtime {
731731

732732
impl pallet_account_fix::Config for Runtime {
733733
type Currency = Balances;
734-
type BurnOrigin = EnsureRootOrTwoThirdsTechnicalCommittee;
734+
type IncConsumerOrigin = EnsureRootOrTwoThirdsTechnicalCommittee;
735+
type AddBalanceOrigin = EnsureRoot<AccountId>;
736+
type BurnOrigin = EnsureRoot<AccountId>;
735737
}
736738

737739
parameter_types! {
@@ -1257,9 +1259,7 @@ impl Contains<RuntimeCall> for BaseCallFilter {
12571259
RuntimeCall::CouncilMembership(_) |
12581260
RuntimeCall::TechnicalCommittee(_) |
12591261
RuntimeCall::TechnicalCommitteeMembership(_) |
1260-
RuntimeCall::Utility(_) |
1261-
// Temp: should be removed after the one-time burn
1262-
RuntimeCall::AccountFix(pallet_account_fix::Call::burn { .. })
1262+
RuntimeCall::Utility(_)
12631263
) {
12641264
// always allow core calls
12651265
return true

runtime/rococo/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
223223
impl_name: create_runtime_str!("rococo-parachain"),
224224
authoring_version: 1,
225225
// same versioning-mechanism as polkadot: use last digit for minor updates
226-
spec_version: 9194,
226+
spec_version: 9195,
227227
impl_version: 0,
228228
apis: RUNTIME_API_VERSIONS,
229229
transaction_version: 1,
@@ -783,7 +783,9 @@ impl pallet_sudo::Config for Runtime {
783783

784784
impl pallet_account_fix::Config for Runtime {
785785
type Currency = Balances;
786-
type BurnOrigin = EnsureRootOrTwoThirdsTechnicalCommittee;
786+
type IncConsumerOrigin = EnsureRootOrTwoThirdsTechnicalCommittee;
787+
type AddBalanceOrigin = EnsureRoot<AccountId>;
788+
type BurnOrigin = EnsureRoot<AccountId>;
787789
}
788790

789791
parameter_types! {
@@ -1300,9 +1302,7 @@ impl Contains<RuntimeCall> for BaseCallFilter {
13001302
RuntimeCall::CouncilMembership(_) |
13011303
RuntimeCall::TechnicalCommittee(_) |
13021304
RuntimeCall::TechnicalCommitteeMembership(_) |
1303-
RuntimeCall::Utility(_) |
1304-
// Temp: should be removed after the one-time burn
1305-
RuntimeCall::AccountFix(pallet_account_fix::Call::burn { .. })
1305+
RuntimeCall::Utility(_)
13061306
) {
13071307
// always allow core calls
13081308
return true

tee-worker/ts-tests/integration-tests/common/utils/assertion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export async function assertVc(context: IntegrationTestContext, subject: CorePri
148148
// check runtime version is present
149149
assert.deepEqual(
150150
vcPayloadJson.issuer.runtimeVersion,
151-
{ parachain: 9194, sidechain: 109 },
151+
{ parachain: 9195, sidechain: 109 },
152152
'Check VC runtime version: it should equal the current defined versions'
153153
);
154154

0 commit comments

Comments
 (0)