mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 06:57:58 +00:00
Add MaxTipAmount for pallet-tips (#1709)
Last week we experienced a governance attack. Surprisingly, there was no upper limit on the tip amount. Due to the mechanism of pallet-fragment-election, the council members will be refreshed immediately. Attacker is easy to control the council and give a large tip amount.
This commit is contained in:
@@ -172,6 +172,7 @@ impl Config for Test {
|
||||
type TipFindersFee = TipFindersFee;
|
||||
type TipReportDepositBase = ConstU64<1>;
|
||||
type DataDepositPerByte = ConstU64<1>;
|
||||
type MaxTipAmount = ConstU64<10_000_000>;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
@@ -183,6 +184,7 @@ impl Config<Instance1> for Test {
|
||||
type TipFindersFee = TipFindersFee;
|
||||
type TipReportDepositBase = ConstU64<1>;
|
||||
type DataDepositPerByte = ConstU64<1>;
|
||||
type MaxTipAmount = ConstU64<10_000_000>;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
@@ -396,6 +398,23 @@ fn tip_median_calculation_works() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tip_large_should_fail() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_ok!(Tips::tip_new(RuntimeOrigin::signed(10), b"awesome.dot".to_vec(), 3, 0));
|
||||
let h = tip_hash();
|
||||
assert_noop!(
|
||||
Tips::tip(
|
||||
RuntimeOrigin::signed(12),
|
||||
h,
|
||||
<<Test as Config>::MaxTipAmount as Get<u64>>::get() + 1
|
||||
),
|
||||
Error::<Test>::MaxTipAmountExceeded
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tip_changing_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user