|
| 1 | +pragma solidity 0.8.9; |
| 2 | + |
| 3 | +/// @title Chaosnet |
| 4 | +/// @notice This is a beta staker program for stakers willing to go the extra |
| 5 | +/// mile with monitoring, share their logs with the dev team, and allow to more |
| 6 | +/// carefully monitor the bootstrapping network. As the network matures, the |
| 7 | +/// beta program will be ended. |
| 8 | +contract Chaosnet { |
| 9 | + /// @notice Indicates if the chaosnet is active. The chaosnet is active |
| 10 | + /// after the contract deployment and can be ended with a call to |
| 11 | + /// `deactivateChaosnet()`. Once deactivated chaosnet can not be activated |
| 12 | + /// again. |
| 13 | + bool public isChaosnetActive; |
| 14 | + |
| 15 | + /// @notice Indicates if the given operator is a beta operator for chaosnet. |
| 16 | + mapping(address => bool) public isBetaOperator; |
| 17 | + |
| 18 | + /// @notice Address controlling chaosnet status and beta operator addresses. |
| 19 | + address public chaosnetOwner; |
| 20 | + |
| 21 | + event BetaOperatorsAdded(address[] operators); |
| 22 | + |
| 23 | + event ChaosnetOwnerRoleTransferred( |
| 24 | + address oldChaosnetOwner, |
| 25 | + address newChaosnetOwner |
| 26 | + ); |
| 27 | + |
| 28 | + event ChaosnetDeactivated(); |
| 29 | + |
| 30 | + constructor() { |
| 31 | + _transferChaosnetOwner(msg.sender); |
| 32 | + isChaosnetActive = true; |
| 33 | + } |
| 34 | + |
| 35 | + modifier onlyChaosnetOwner() { |
| 36 | + require(msg.sender == chaosnetOwner, "Not the chaosnet owner"); |
| 37 | + _; |
| 38 | + } |
| 39 | + |
| 40 | + modifier onlyOnChaosnet() { |
| 41 | + require(isChaosnetActive, "Chaosnet is not active"); |
| 42 | + _; |
| 43 | + } |
| 44 | + |
| 45 | + /// @notice Adds beta operator to chaosnet. Can be called only by the |
| 46 | + /// chaosnet owner when the chaosnet is active. Once the operator is added |
| 47 | + /// as a beta operator, it can not be removed. |
| 48 | + function addBetaOperators(address[] calldata operators) |
| 49 | + public |
| 50 | + onlyOnChaosnet |
| 51 | + onlyChaosnetOwner |
| 52 | + { |
| 53 | + for (uint256 i = 0; i < operators.length; i++) { |
| 54 | + isBetaOperator[operators[i]] = true; |
| 55 | + } |
| 56 | + |
| 57 | + emit BetaOperatorsAdded(operators); |
| 58 | + } |
| 59 | + |
| 60 | + /// @notice Deactivates the chaosnet. Can be called only by the chaosnet |
| 61 | + /// owner. Once deactivated chaosnet can not be activated again. |
| 62 | + function deactivateChaosnet() public onlyOnChaosnet onlyChaosnetOwner { |
| 63 | + isChaosnetActive = false; |
| 64 | + emit ChaosnetDeactivated(); |
| 65 | + } |
| 66 | + |
| 67 | + /// @notice Transfers the chaosnet owner role to another non-zero address. |
| 68 | + function transferChaosnetOwnerRole(address newChaosnetOwner) |
| 69 | + public |
| 70 | + onlyChaosnetOwner |
| 71 | + { |
| 72 | + require( |
| 73 | + newChaosnetOwner != address(0), |
| 74 | + "New chaosnet owner must not be zero address" |
| 75 | + ); |
| 76 | + _transferChaosnetOwner(newChaosnetOwner); |
| 77 | + } |
| 78 | + |
| 79 | + function _transferChaosnetOwner(address newChaosnetOwner) internal { |
| 80 | + address oldChaosnetOwner = chaosnetOwner; |
| 81 | + chaosnetOwner = newChaosnetOwner; |
| 82 | + emit ChaosnetOwnerRoleTransferred(oldChaosnetOwner, newChaosnetOwner); |
| 83 | + } |
| 84 | +} |
0 commit comments