Skip to content

Commit b4d61ae

Browse files
committed
Add safety guardrail to user distribute delays
1 parent 80f3ae0 commit b4d61ae

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

contracts/contract/dao/protocol/settings/RocketDAOProtocolSettingsMegapool.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ contract RocketDAOProtocolSettingsMegapool is RocketDAOProtocolSettings, RocketD
5050
require(_value >= 0.01 ether && _value <= 0.5 ether, "Value must be >= 0.01 ETH & <= 0.5 ETH");
5151
} else if (settingKey == keccak256(bytes("user.distribute.delay"))) {
5252
require(_value >= 225 && _value <= 13500, "Value must be >= 225 & <= 13500 epochs");
53+
require(_value <= getSettingUint("user.distribute.delay.shortfall"), "Value must be <= user.distribute.delay.shortfall");
5354
} else if (settingKey == keccak256(bytes("user.distribute.delay.shortfall"))) {
5455
require(_value >= 6750 && _value <= 40500, "Value must be >= 6750 & <= 40500 epochs");
56+
require(_value >= getSettingUint("user.distribute.delay"), "Value must be >= user.distribute.delay");
5557
} else if (settingKey == keccak256(bytes("megapool.penalty.threshold"))) {
5658
require(_value >= 0.51 ether, "Penalty threshold must be 51% or higher");
5759
}

test/dao/dao-protocol-tests.js

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import {
55
setDAOProtocolBootstrapEnableGovernance,
66
setDaoProtocolBootstrapModeDisabled,
77
setDAOProtocolBootstrapSecurityInvite,
8-
setDAOProtocolBootstrapSetting, setDAOProtocolBootstrapSettingAddressList,
8+
setDAOProtocolBootstrapSetting,
9+
setDAOProtocolBootstrapSettingAddressList,
910
setDAOProtocolBootstrapSettingMulti,
1011
} from './scenario-dao-protocol-bootstrap';
1112
import {
1213
RocketDAOProtocolSettingsAuction,
1314
RocketDAOProtocolSettingsDeposit,
1415
RocketDAOProtocolSettingsInflation,
16+
RocketDAOProtocolSettingsMegapool,
1517
RocketDAOProtocolSettingsMinipool,
1618
RocketDAOProtocolSettingsNetwork,
1719
RocketDAOProtocolSettingsProposals,
@@ -40,14 +42,7 @@ import {
4042
setDaoProtocolNodeShareSecurityCouncilAdder,
4143
setDaoProtocolVoterShare,
4244
} from './scenario-dao-protocol';
43-
import {
44-
getNodeCount,
45-
nodeSetDelegate,
46-
nodeStakeRPL,
47-
registerNode,
48-
setRPLLockingAllowed,
49-
} from '../_helpers/node';
50-
import { getMinipoolMinimumRPLStake } from '../_helpers/minipool';
45+
import { getNodeCount, nodeSetDelegate, nodeStakeRPL, registerNode, setRPLLockingAllowed } from '../_helpers/node';
5146
import { mintRPL } from '../_helpers/tokens';
5247
import { userDeposit } from '../_helpers/deposit';
5348
import {
@@ -199,6 +194,29 @@ export default function() {
199194
});
200195
});
201196

197+
it(printTitle('guardian', 'cannot update "user.distribute.delay.shortfall" lower than "user.distribute.delay"'), async () => {
198+
await setDAOProtocolBootstrapSetting(RocketDAOProtocolSettingsMegapool, 'user.distribute.delay.shortfall', 10000, {
199+
from: owner,
200+
})
201+
await setDAOProtocolBootstrapSetting(RocketDAOProtocolSettingsMegapool, 'user.distribute.delay', 8000, {
202+
from: owner,
203+
});
204+
// Cannot set delay with shortfall lower
205+
await shouldRevert(
206+
setDAOProtocolBootstrapSetting(RocketDAOProtocolSettingsMegapool, 'user.distribute.delay.shortfall', 7000, {
207+
from: owner,
208+
}),
209+
'Was able to set delay with shortfall lower than regular delay',
210+
'Value must be >= user.distribute.delay');
211+
// Cannot set regular delay higher
212+
await shouldRevert(
213+
setDAOProtocolBootstrapSetting(RocketDAOProtocolSettingsMegapool, 'user.distribute.delay', 11000, {
214+
from: owner,
215+
}),
216+
'Was able to set delay higher than delay with shortfall',
217+
'Value must be <= user.distribute.delay.shortfall');
218+
});
219+
202220
// Verify each setting contract is enabled correctly. These settings are tested in greater detail in the relevent contracts
203221
it(printTitle('guardian', 'updates multiple settings at once while bootstrap mode is enabled'), async () => {
204222
// Set via bootstrapping
@@ -302,7 +320,7 @@ export default function() {
302320
const deposits = Array(validatorCount).fill({
303321
bondAmount: '4'.ether,
304322
useExpressTicket: false,
305-
})
323+
});
306324
await nodeDepositMulti(node, deposits);
307325
// Allow RPL locking by default
308326
await setRPLLockingAllowed(node, true, { from: node });
@@ -779,7 +797,7 @@ export default function() {
779797
await shouldRevert(
780798
nodeSetDelegate(nodes[1].address, { from: nodes[0] }),
781799
'Was able to set delegate to same value',
782-
'Delegate already set to value'
800+
'Delegate already set to value',
783801
);
784802
});
785803

@@ -1030,7 +1048,7 @@ export default function() {
10301048
await shouldRevert(
10311049
daoProtocolExecute(propId, { from: proposer }),
10321050
'Was able to kick non-existing member',
1033-
'This node is not part of the security council'
1051+
'This node is not part of the security council',
10341052
);
10351053
});
10361054

@@ -1587,7 +1605,7 @@ export default function() {
15871605

15881606
describe('With allow listed controller', () => {
15891607
before(async () => {
1590-
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, "network.allow.listed.controllers", [allowListed.address], { from: owner })
1608+
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, 'network.allow.listed.controllers', [allowListed.address], { from: owner });
15911609
});
15921610

15931611
it(printTitle('random', 'fails to update UARS parameters when not on allow list'), async () => {
@@ -1607,14 +1625,14 @@ export default function() {
16071625
});
16081626

16091627
it(printTitle('allow listed', 'fails to update UARS parameter if removed from allow list'), async () => {
1610-
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, "network.allow.listed.controllers", [], { from: owner })
1628+
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, 'network.allow.listed.controllers', [], { from: owner });
16111629
await shouldRevert(setDaoProtocolNodeShareSecurityCouncilAdder('0.005'.ether, {
16121630
from: allowListed,
16131631
}), 'Was able to update node share security council adder', 'Not on allow list');
16141632
});
16151633

16161634
it(printTitle('allow listed', 'fails to set node share security council adder higher than max'), async () => {
1617-
const rocketDAOProtocolSettingsNetwork = await RocketDAOProtocolSettingsNetwork.deployed()
1635+
const rocketDAOProtocolSettingsNetwork = await RocketDAOProtocolSettingsNetwork.deployed();
16181636
const maximum = await rocketDAOProtocolSettingsNetwork.getMaxNodeShareSecurityCouncilAdder();
16191637

16201638
// Set to max works
@@ -1627,7 +1645,7 @@ export default function() {
16271645
});
16281646

16291647
it(printTitle('allow listed', 'fails to set voter share + node share > 100%'), async () => {
1630-
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, "network.allow.listed.controllers", [allowListed.address], { from: owner })
1648+
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, 'network.allow.listed.controllers', [allowListed.address], { from: owner });
16311649

16321650
// Set voter and node to 50%
16331651
await setDaoProtocolNodeCommissionShare('0.5'.ether, { from: allowListed });
@@ -1640,14 +1658,14 @@ export default function() {
16401658
});
16411659

16421660
it(printTitle('allow listed', 'can update node commission share if on allow list'), async () => {
1643-
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, "network.allow.listed.controllers", [allowListed.address], { from: owner })
1661+
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, 'network.allow.listed.controllers', [allowListed.address], { from: owner });
16441662
await setDaoProtocolNodeCommissionShare('0.10'.ether, { from: allowListed });
16451663
});
16461664

16471665
it(printTitle('allow listed', 'can update voter share if on allow list'), async () => {
1648-
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, "network.allow.listed.controllers", [allowListed.address], { from: owner })
1666+
await setDAOProtocolBootstrapSettingAddressList(RocketDAOProtocolSettingsNetwork, 'network.allow.listed.controllers', [allowListed.address], { from: owner });
16491667
await setDaoProtocolVoterShare('0.20'.ether, { from: allowListed });
16501668
});
1651-
})
1669+
});
16521670
});
16531671
}

0 commit comments

Comments
 (0)