|
| 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 chaosnetMaestro; |
| 20 | + |
| 21 | + event BetaOperatorsAdded(address[] operators); |
| 22 | + |
| 23 | + event ChaosnetMaestroRoleTransferred( |
| 24 | + address oldChaosnetMaestro, |
| 25 | + address newChaosnetMaestro |
| 26 | + ); |
| 27 | + |
| 28 | + event ChaosnetDeactivated(); |
| 29 | + |
| 30 | + constructor() { |
| 31 | + _transferChaosnetMaestro(msg.sender); |
| 32 | + isChaosnetActive = true; |
| 33 | + } |
| 34 | + |
| 35 | + modifier onlyChaosnetMaestro() { |
| 36 | + require(msg.sender == chaosnetMaestro, "Not the chaosnet maestro"); |
| 37 | + _; |
| 38 | + } |
| 39 | + |
| 40 | + /// @notice Adds beta operator to chaosnet. Can be called only by the |
| 41 | + /// chaosnet maestro. |
| 42 | + function addBetaOperators(address[] calldata operators) |
| 43 | + public |
| 44 | + onlyChaosnetMaestro |
| 45 | + { |
| 46 | + for (uint256 i = 0; i < operators.length; i++) { |
| 47 | + isBetaOperator[operators[i]] = true; |
| 48 | + } |
| 49 | + |
| 50 | + emit BetaOperatorsAdded(operators); |
| 51 | + } |
| 52 | + |
| 53 | + /// @notice Deactivates the chaosnet. Can be called only by the chaosnet |
| 54 | + /// maestro. Once deactivated chaosnet can not be activated again. |
| 55 | + function deactivateChaosnet() public onlyChaosnetMaestro { |
| 56 | + require(isChaosnetActive, "Chaosnet is not active"); |
| 57 | + isChaosnetActive = false; |
| 58 | + emit ChaosnetDeactivated(); |
| 59 | + } |
| 60 | + |
| 61 | + /// @notice Transfers the chaosnet maestro role to another non-zero address. |
| 62 | + function transferChaosnetMaestroRole(address newChaosnetMaestro) |
| 63 | + public |
| 64 | + onlyChaosnetMaestro |
| 65 | + { |
| 66 | + require( |
| 67 | + newChaosnetMaestro != address(0), |
| 68 | + "New chaosnet maestro must not be zero address" |
| 69 | + ); |
| 70 | + _transferChaosnetMaestro(newChaosnetMaestro); |
| 71 | + } |
| 72 | + |
| 73 | + function _transferChaosnetMaestro(address newChaosnetMaestro) internal { |
| 74 | + address oldChaosnetMaestro = chaosnetMaestro; |
| 75 | + chaosnetMaestro = newChaosnetMaestro; |
| 76 | + emit ChaosnetMaestroRoleTransferred(oldChaosnetMaestro, newChaosnetMaestro); |
| 77 | + } |
| 78 | +} |
0 commit comments