|
| 1 | +pragma solidity 0.7.6; |
| 2 | + |
| 3 | +// SPDX-License-Identifier: GPL-3.0-only |
| 4 | + |
| 5 | +import "@openzeppelin/contracts/math/SafeMath.sol"; |
| 6 | + |
| 7 | +import "./RocketDAONodeTrustedSettings.sol"; |
| 8 | +import "../../../../interface/dao/node/settings/RocketDAONodeTrustedSettingsMinipoolInterface.sol"; |
| 9 | +import "../../../../interface/dao/protocol/settings/RocketDAOProtocolSettingsMinipoolInterface.sol"; |
| 10 | + |
| 11 | + |
| 12 | +// The Trusted Node DAO Minipool settings |
| 13 | +contract RocketDAONodeTrustedSettingsMinipool is RocketDAONodeTrustedSettings, RocketDAONodeTrustedSettingsMinipoolInterface { |
| 14 | + |
| 15 | + using SafeMath for uint; |
| 16 | + |
| 17 | + // Construct |
| 18 | + constructor(RocketStorageInterface _rocketStorageAddress) RocketDAONodeTrustedSettings(_rocketStorageAddress, "minipool") { |
| 19 | + // Set version |
| 20 | + version = 1; |
| 21 | + |
| 22 | + // If deployed during initial deployment, initialise now (otherwise must be called after upgrade) |
| 23 | + if (!_rocketStorageAddress.getDeployedStatus()){ |
| 24 | + initialise(); |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + |
| 29 | + // Initialise |
| 30 | + function initialise() public { |
| 31 | + // Initialize settings on deployment |
| 32 | + require(!getBool(keccak256(abi.encodePacked(settingNameSpace, "deployed"))), "Already initialised"); |
| 33 | + // Init settings |
| 34 | + setSettingUint("minipool.scrub.period", 12 hours); |
| 35 | + setSettingUint("minipool.scrub.quorum", 0.51 ether); |
| 36 | + setSettingBool("minipool.scrub.penalty.enabled", false); |
| 37 | + // Settings initialised |
| 38 | + setBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")), true); |
| 39 | + } |
| 40 | + |
| 41 | + |
| 42 | + // Update a setting, overrides inherited setting method with extra checks for this contract |
| 43 | + function setSettingUint(string memory _settingPath, uint256 _value) override public onlyDAONodeTrustedProposal { |
| 44 | + // Some safety guards for certain settings |
| 45 | + if(getBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")))) { |
| 46 | + if(keccak256(abi.encodePacked(_settingPath)) == keccak256(abi.encodePacked("minipool.scrub.period"))) { |
| 47 | + RocketDAOProtocolSettingsMinipoolInterface rocketDAOProtocolSettingsMinipool = RocketDAOProtocolSettingsMinipoolInterface(getContractAddress("rocketDAOProtocolSettingsMinipool")); |
| 48 | + require(_value <= (rocketDAOProtocolSettingsMinipool.getLaunchTimeout().sub(1 hours)), "Scrub period must be less than launch timeout"); |
| 49 | + } |
| 50 | + } |
| 51 | + // Update setting now |
| 52 | + setUint(keccak256(abi.encodePacked(settingNameSpace, _settingPath)), _value); |
| 53 | + } |
| 54 | + |
| 55 | + // Getters |
| 56 | + |
| 57 | + // How long minipools must wait before moving to staking status (can be scrubbed by ODAO before then) |
| 58 | + function getScrubPeriod() override external view returns (uint256) { |
| 59 | + return getSettingUint("minipool.scrub.period"); |
| 60 | + } |
| 61 | + |
| 62 | + // The required number of trusted nodes to vote to scrub a minipool |
| 63 | + function getScrubQuorum() override external view returns (uint256) { |
| 64 | + return getSettingUint("minipool.scrub.quorum"); |
| 65 | + } |
| 66 | + |
| 67 | + // True if scrubbing results in an RPL penalty for the node operator |
| 68 | + function getScrubPenaltyEnabled() override external view returns (bool) { |
| 69 | + return getSettingBool("minipool.scrub.penalty.enabled"); |
| 70 | + } |
| 71 | +} |
0 commit comments