Skip to content

Commit 66262af

Browse files
authored
🩹 Send the slashed PLMC to the Blockchain Operation Treasury (#347)
* feat: send the slashed PLMC to the Blockchain Operation Treasury * chore: change name to avoid future confusion * chore: clarify the comment
1 parent 8eb81d3 commit 66262af

File tree

14 files changed

+37
-37
lines changed

14 files changed

+37
-37
lines changed

integration-tests/src/constants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ pub mod polimec {
371371
use super::*;
372372
use crate::{PolimecNet, PolimecOrigin, PolimecRuntime};
373373
use pallet_funding::AcceptedFundingAsset;
374-
use polimec_runtime::{PayMaster, TreasuryAccount};
374+
use polimec_runtime::{BlockchainOperationTreasury, TreasuryAccount};
375375
use xcm::v3::Parent;
376376
use xcm_emulator::TestExt;
377377

@@ -446,7 +446,7 @@ pub mod polimec {
446446
funded_accounts.extend(accounts::init_balances().iter().cloned().map(|k| (k, INITIAL_DEPOSIT)));
447447
funded_accounts.extend(collators::initial_authorities().iter().cloned().map(|(acc, _)| (acc, 20_005 * PLMC)));
448448
funded_accounts.push((TreasuryAccount::get(), 20_005 * PLMC));
449-
funded_accounts.push((PayMaster::get(), 20_005 * PLMC));
449+
funded_accounts.push((BlockchainOperationTreasury::get(), 20_005 * PLMC));
450450

451451
let genesis_config = polimec_runtime::RuntimeGenesisConfig {
452452
system: Default::default(),

integration-tests/src/tests/vest.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use frame_support::traits::fungible::Mutate;
2323
use macros::generate_accounts;
2424
use pallet_funding::assert_close_enough;
2525
use pallet_vesting::VestingInfo;
26-
use polimec_runtime::{Balances, ParachainStaking, PayMaster, RuntimeOrigin, Vesting, PLMC};
26+
use polimec_runtime::{Balances, BlockchainOperationTreasury, ParachainStaking, RuntimeOrigin, Vesting, PLMC};
2727
use sp_runtime::Perquintill;
2828
use xcm_emulator::helpers::get_account_id_from_seed;
2929

@@ -160,7 +160,7 @@ fn dust_to_treasury() {
160160

161161
// Get the total issuance and Treasury balance before the transfer.
162162
let initial_total_issuance = Balances::total_issuance();
163-
let initial_treasury_balance = Balances::free_balance(PayMaster::get());
163+
let initial_treasury_balance = Balances::free_balance(BlockchainOperationTreasury::get());
164164

165165
// Transfer funds from sender to receiver, designed to deplete the sender's balance below the ED.
166166
// The sender account will be killed and the dust will be sent to the treasury.
@@ -176,7 +176,7 @@ fn dust_to_treasury() {
176176
assert_eq!(initial_total_issuance, post_total_issuance);
177177

178178
// Verify the Treasury has received the dust from the sender's account.
179-
let final_treasury_balance = Balances::free_balance(PayMaster::get());
179+
let final_treasury_balance = Balances::free_balance(BlockchainOperationTreasury::get());
180180
assert_eq!(initial_treasury_balance + ED - 1, final_treasury_balance);
181181
})
182182
}

nodes/parachain/src/chain_spec/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn genesis_config(genesis_config_params: GenesisConfigParams) -> serde_json:
8888

8989
let system_accounts = vec![
9090
(
91-
<Runtime as pallet_funding::Config>::ProtocolGrowthTreasury::get(),
91+
<Runtime as pallet_funding::Config>::BlockchainOperationTreasury::get(),
9292
<Runtime as pallet_funding::Config>::NativeCurrency::minimum_balance(),
9393
),
9494
(

pallets/funding/src/benchmarking.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ mod benchmarks {
15401540
let evaluation_to_settle =
15411541
inst.execute(|| Evaluations::<T>::iter_prefix_values((project_id, evaluator.clone())).next().unwrap());
15421542

1543-
let treasury_account = T::ProtocolGrowthTreasury::get();
1543+
let treasury_account = T::BlockchainOperationTreasury::get();
15441544
let free_treasury_plmc = inst.get_free_plmc_balances_for(vec![treasury_account])[0].plmc_amount;
15451545
assert_eq!(free_treasury_plmc, inst.get_ed());
15461546

@@ -1563,7 +1563,7 @@ mod benchmarks {
15631563
.plmc_amount;
15641564
assert_eq!(reserved_plmc, 0.into());
15651565

1566-
let treasury_account = T::ProtocolGrowthTreasury::get();
1566+
let treasury_account = T::BlockchainOperationTreasury::get();
15671567
let free_treasury_plmc = inst.get_free_plmc_balances_for(vec![treasury_account])[0].plmc_amount;
15681568
let ed = inst.get_ed();
15691569
assert_eq!(free_treasury_plmc, slashed_amount + ed);

pallets/funding/src/functions/6_settlement.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl<T: Config> Pallet<T> {
397397

398398
fn slash_evaluator(project_id: ProjectId, evaluation: &EvaluationInfoOf<T>) -> Result<BalanceOf<T>, DispatchError> {
399399
let slash_percentage = T::EvaluatorSlash::get();
400-
let treasury_account = T::ProtocolGrowthTreasury::get();
400+
let treasury_account = T::BlockchainOperationTreasury::get();
401401

402402
// * Calculate variables *
403403
// We need to make sure that the current PLMC bond is always >= than the slash amount.

pallets/funding/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ pub mod pallet {
415415
#[pallet::constant]
416416
type SuccessToSettlementTime: Get<BlockNumberFor<Self>>;
417417

418-
/// Treasury account holding PLMC at TGE.
418+
/// Account that receive the PLMC slashed from failed evaluations.
419419
#[pallet::constant]
420-
type ProtocolGrowthTreasury: Get<AccountIdOf<Self>>;
420+
type BlockchainOperationTreasury: Get<AccountIdOf<Self>>;
421421

422422
/// Treasury account holding the CT fees charged to issuers.
423423
#[pallet::constant]

pallets/funding/src/mock.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ parameter_types! {
307307
];
308308
pub EarlyEvaluationThreshold: Percent = Percent::from_percent(10);
309309
pub EvaluatorSlash: Percent = Percent::from_percent(20);
310-
pub ProtocolGrowthTreasuryAccount: AccountId = AccountId::from(696969u32);
310+
pub BlockchainOperationTreasuryAccount: AccountId = AccountId::from(696969u32);
311311
pub ContributionTreasury: AccountId = AccountId::from(4204204206u32);
312312
}
313313

@@ -400,6 +400,7 @@ impl Config for TestRuntime {
400400
type Balance = Balance;
401401
type BlockNumber = BlockNumber;
402402
type BlockNumberToBalance = ConvertInto;
403+
type BlockchainOperationTreasury = BlockchainOperationTreasuryAccount;
403404
type CommunityFundingDuration = CommunityRoundDuration;
404405
type ContributionTokenCurrency = ContributionTokens;
405406
type ContributionTreasury = ContributionTreasury;
@@ -427,7 +428,6 @@ impl Config for TestRuntime {
427428
type PreImageLimit = ConstU32<1024>;
428429
type Price = FixedU128;
429430
type PriceProvider = ConstPriceProvider;
430-
type ProtocolGrowthTreasury = ProtocolGrowthTreasuryAccount;
431431
type Randomness = RandomnessCollectiveFlip;
432432
type RemainderFundingDuration = RemainderFundingDuration;
433433
type RequiredMaxCapacity = RequiredMaxCapacity;
@@ -470,7 +470,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
470470
balances: vec![
471471
(<TestRuntime as Config>::PalletId::get().into_account_truncating(), ed),
472472
(<TestRuntime as Config>::ContributionTreasury::get(), ed),
473-
(<TestRuntime as Config>::ProtocolGrowthTreasury::get(), ed),
473+
(<TestRuntime as Config>::BlockchainOperationTreasury::get(), ed),
474474
],
475475
},
476476
foreign_assets: ForeignAssetsConfig {

pallets/funding/src/tests/2_evaluation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ mod evaluate_extrinsic {
681681
assert_eq!(evaluation_held_balance, frozen_amount);
682682
assert_eq!(frozen_balance, frozen_amount);
683683

684-
let treasury_account = <TestRuntime as Config>::ProtocolGrowthTreasury::get();
684+
let treasury_account = <TestRuntime as Config>::BlockchainOperationTreasury::get();
685685
let pre_slash_treasury_balance = inst.get_free_plmc_balance_for(treasury_account);
686686

687687
let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();

pallets/linear-release/src/tests.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ fn check_vesting_status_for_multi_schedule_account() {
125125
assert_eq!(Balances::balance_on_hold(&MockRuntimeHoldReason::Reason, &2), 20 * ED);
126126
assert_ok!(Vesting::vested_transfer(Some(4).into(), 2, sched1, MockRuntimeHoldReason::Reason));
127127
assert_eq!(Balances::balance_on_hold(&MockRuntimeHoldReason::Reason, &2), 29 * ED); // Why 29 and not 30? Because sched1 is already unlocking.
128-
// Free balance is the one set in Genesis inside the Balances pallet
129-
// + the one from the vested transfer.
130-
// BUT NOT the one in sched0, since the vesting will start at block #10.
128+
// Free balance is the one set in Genesis inside the Balances pallet
129+
// + the one from the vested transfer.
130+
// BUT NOT the one in sched0, since the vesting will start at block #10.
131131
let balance = Balances::balance(&2);
132132
assert_eq!(balance, ED * (2));
133133
// The most recently added schedule exists.
@@ -193,7 +193,7 @@ fn unvested_balance_should_not_transfer() {
193193
ExtBuilder::default().existential_deposit(10).build().execute_with(|| {
194194
let user1_free_balance = Balances::free_balance(1);
195195
assert_eq!(user1_free_balance, 50); // Account 1 has free balance
196-
// Account 1 has only 5 units vested at block 1 (plus 50 unvested)
196+
// Account 1 has only 5 units vested at block 1 (plus 50 unvested)
197197
assert_eq!(Vesting::vesting_balance(&1, MockRuntimeHoldReason::Reason), Some(5)); // Account 1 cannot send more than vested amount...
198198
assert_noop!(Balances::transfer_allow_death(Some(1).into(), 2, 56), TokenError::FundsUnavailable);
199199
});
@@ -205,13 +205,13 @@ fn vested_balance_should_transfer() {
205205
assert_eq!(System::block_number(), 1);
206206
let user1_free_balance = Balances::free_balance(1);
207207
assert_eq!(user1_free_balance, 50); // Account 1 has free balance
208-
// Account 1 has only 5 units vested at block 1 (plus 50 unvested)
208+
// Account 1 has only 5 units vested at block 1 (plus 50 unvested)
209209
assert_eq!(Vesting::vesting_balance(&1, MockRuntimeHoldReason::Reason), Some(5));
210210
assert_noop!(Balances::transfer_allow_death(Some(1).into(), 2, 45), TokenError::Frozen); // Account 1 free balance - ED is < 45
211211
assert_ok!(Vesting::vest(Some(1).into(), MockRuntimeHoldReason::Reason));
212212
let user1_free_balance = Balances::free_balance(1);
213213
assert_eq!(user1_free_balance, 55); // Account 1 has free balance
214-
// Account 1 has vested 1 unit at block 1 (plus 50 unvested)
214+
// Account 1 has vested 1 unit at block 1 (plus 50 unvested)
215215
assert_ok!(Balances::transfer_allow_death(Some(1).into(), 2, 45)); // After the vest it can now send the 45 UNIT
216216
});
217217
}
@@ -259,7 +259,7 @@ fn vested_balance_should_transfer_using_vest_other() {
259259
ExtBuilder::default().existential_deposit(10).build().execute_with(|| {
260260
let user1_free_balance = Balances::free_balance(1);
261261
assert_eq!(user1_free_balance, 50); // Account 1 has free balance
262-
// Account 1 has only 5 units vested at block 1 (plus 50 unvested)
262+
// Account 1 has only 5 units vested at block 1 (plus 50 unvested)
263263
assert_eq!(Vesting::vesting_balance(&1, MockRuntimeHoldReason::Reason), Some(5));
264264
assert_ok!(Vesting::vest_other(Some(2).into(), 1, MockRuntimeHoldReason::Reason));
265265
assert_ok!(Balances::transfer_allow_death(Some(1).into(), 2, 55 - 10));
@@ -317,7 +317,7 @@ fn extra_balance_should_transfer() {
317317

318318
// Account 2 has no units vested at block 1, but gained 100
319319
assert_ok!(Balances::transfer_allow_death(Some(2).into(), 3, 100 - 10)); // Account 2 can send extra
320-
// units gained
320+
// units gained
321321
});
322322
}
323323

@@ -327,7 +327,7 @@ fn liquid_funds_should_transfer_with_delayed_vesting() {
327327
let user12_free_balance = Balances::free_balance(12);
328328

329329
assert_eq!(user12_free_balance, 1280); // Account 12 has free balance
330-
// Account 12 has liquid funds
330+
// Account 12 has liquid funds
331331
assert_eq!(Vesting::vesting_balance(&12, MockRuntimeHoldReason::Reason), Some(0));
332332

333333
// Account 12 has delayed vesting

pallets/parachain-staking/src/mock.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ parameter_types! {
131131
pub const MinCandidateStk: u128 = 10;
132132
pub const MinDelegatorStk: u128 = 5;
133133
pub const MinDelegation: u128 = 3;
134-
pub const PayMaster: AccountId = 1337;
134+
pub const BlockchainOperationTreasury: AccountId = 1337;
135135
}
136136
impl_opaque_keys! {
137137
pub struct MockSessionKeys {
@@ -176,7 +176,7 @@ impl Config for Test {
176176
type MonetaryGovernanceOrigin = frame_system::EnsureRoot<AccountId>;
177177
type OnCollatorPayout = ();
178178
type OnNewRound = ();
179-
type PayMaster = PayMaster;
179+
type PayMaster = BlockchainOperationTreasury;
180180
type PayoutCollatorReward = ();
181181
type RevokeDelegationDelay = RevokeDelegationDelay;
182182
type RewardPaymentDelay = RewardPaymentDelay;
@@ -223,8 +223,8 @@ impl Default for ExtBuilder {
223223

224224
impl ExtBuilder {
225225
pub(crate) fn with_balances(mut self, mut balances: Vec<(AccountId, Balance)>) -> Self {
226-
if !balances.iter().any(|(acc, _)| *acc == PayMaster::get()) {
227-
balances.push((PayMaster::get(), 300));
226+
if !balances.iter().any(|(acc, _)| *acc == BlockchainOperationTreasury::get()) {
227+
balances.push((BlockchainOperationTreasury::get(), 300));
228228
}
229229
self.balances = balances;
230230
self

pallets/parachain-staking/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2893,7 +2893,7 @@ fn payout_distribution_to_solo_collators() {
28932893
(7, 33),
28942894
(8, 33),
28952895
(9, 33),
2896-
(crate::mock::PayMaster::get(), 1000),
2896+
(crate::mock::BlockchainOperationTreasury::get(), 1000),
28972897
])
28982898
.with_candidates(vec![(1, 100), (2, 90), (3, 80), (4, 70)])
28992899
.build()
@@ -3120,7 +3120,7 @@ fn payouts_follow_delegation_changes() {
31203120
(8, 100),
31213121
(9, 100),
31223122
(10, 100),
3123-
(crate::mock::PayMaster::get(), 1000),
3123+
(crate::mock::BlockchainOperationTreasury::get(), 1000),
31243124
])
31253125
.with_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20)])
31263126
.with_delegations(vec![(6, 1, 10), (7, 1, 10), (8, 2, 10), (9, 2, 10), (10, 1, 10)])

runtimes/polimec/src/custom_migrations/deposit_dust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl frame_support::traits::OnRuntimeUpgrade for DepositDust {
4646
if total_issuance != 100_000_000 * PLMC {
4747
log::info!("⚠️ Correcting total issuance from {} to {}", total_issuance, 100_000_000 * PLMC);
4848
// +1 R
49-
let treasury_account = PayMaster::get();
49+
let treasury_account = BlockchainOperationTreasury::get();
5050
// +1 W
5151
// The values are coming from these `DustLost` events:
5252
// - https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polimec.org#/explorer/query/0x6fec4ce782f42afae1437f53e3382d9e6804692de868a28908ed6b9104bdd536

runtimes/polimec/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ pub struct DustRemovalAdapter;
388388

389389
impl tokens::imbalance::OnUnbalanced<CreditOf<Runtime>> for DustRemovalAdapter {
390390
fn on_nonzero_unbalanced(amount: CreditOf<Runtime>) {
391-
let treasury_account = PayMaster::get();
391+
let treasury_account = BlockchainOperationTreasury::get();
392392
let _ = <Balances as tokens::fungible::Balanced<AccountId>>::resolve(&treasury_account, amount);
393393
}
394394
}
@@ -670,7 +670,7 @@ impl GetElectorate<Balance> for Electorate {
670670
fn get_electorate() -> Balance {
671671
let total_issuance = Balances::total_issuance();
672672
let growth_treasury_balance = Balances::balance(&Treasury::account_id());
673-
let protocol_treasury_balance = Balances::balance(&PayMaster::get());
673+
let protocol_treasury_balance = Balances::balance(&BlockchainOperationTreasury::get());
674674
total_issuance.saturating_sub(growth_treasury_balance).saturating_sub(protocol_treasury_balance)
675675
}
676676
}
@@ -789,7 +789,7 @@ impl pallet_parachain_staking::Config for Runtime {
789789
type MonetaryGovernanceOrigin = frame_system::EnsureRoot<AccountId>;
790790
type OnCollatorPayout = ();
791791
type OnNewRound = ();
792-
type PayMaster = PayMaster;
792+
type PayMaster = BlockchainOperationTreasury;
793793
// We use the default implementation, so we leave () here.
794794
type PayoutCollatorReward = ();
795795
type RevokeDelegationDelay = RevokeDelegationDelay;
@@ -1036,6 +1036,7 @@ impl pallet_funding::Config for Runtime {
10361036
type Balance = Balance;
10371037
type BlockNumber = BlockNumber;
10381038
type BlockNumberToBalance = ConvertInto;
1039+
type BlockchainOperationTreasury = BlockchainOperationTreasury;
10391040
type CommunityFundingDuration = CommunityFundingDuration;
10401041
type ContributionTokenCurrency = ContributionTokens;
10411042
type ContributionTreasury = ContributionTreasuryAccount;
@@ -1063,7 +1064,6 @@ impl pallet_funding::Config for Runtime {
10631064
type PreImageLimit = ConstU32<1024>;
10641065
type Price = Price;
10651066
type PriceProvider = OraclePriceProvider<AssetId, Price, Oracle>;
1066-
type ProtocolGrowthTreasury = TreasuryAccount;
10671067
type Randomness = Random;
10681068
type RemainderFundingDuration = RemainderFundingDuration;
10691069
type RequiredMaxCapacity = RequiredMaxCapacity;

runtimes/shared-configuration/src/fee.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ parameter_types! {
9797
}
9898

9999
ord_parameter_types! {
100-
pub const PayMaster: AccountId =
100+
pub const BlockchainOperationTreasury: AccountId =
101101
AccountIdConversion::<AccountId>::into_account_truncating(&StakingPalletId::get());
102102
}
103103

@@ -125,7 +125,7 @@ where
125125
<R as frame_system::Config>::AccountId: Into<AccountId>,
126126
{
127127
fn on_nonzero_unbalanced(amount: Credit<<R as frame_system::Config>::AccountId, pallet_balances::Pallet<R>>) {
128-
let staking_pot = PayMaster::get().into();
128+
let staking_pot = BlockchainOperationTreasury::get().into();
129129
let _ = <pallet_balances::Pallet<R>>::resolve(&staking_pot, amount);
130130
}
131131
}

0 commit comments

Comments
 (0)