-
Notifications
You must be signed in to change notification settings - Fork 4
Chaosnet #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Chaosnet #188
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| pragma solidity 0.8.9; | ||
|
|
||
| /// @title Chaosnet | ||
| /// @notice This is a beta staker program for stakers willing to go the extra | ||
| /// mile with monitoring, share their logs with the dev team, and allow to more | ||
| /// carefully monitor the bootstrapping network. As the network matures, the | ||
| /// beta program will be ended. | ||
| contract Chaosnet { | ||
| /// @notice Indicates if the chaosnet is active. The chaosnet is active | ||
| /// after the contract deployment and can be ended with a call to | ||
| /// `deactivateChaosnet()`. Once deactivated chaosnet can not be activated | ||
| /// again. | ||
| bool public isChaosnetActive; | ||
|
|
||
| /// @notice Indicates if the given operator is a beta operator for chaosnet. | ||
| mapping(address => bool) public isBetaOperator; | ||
|
dimpar marked this conversation as resolved.
|
||
|
|
||
| /// @notice Address controlling chaosnet status and beta operator addresses. | ||
| address public chaosnetMaestro; | ||
|
dimpar marked this conversation as resolved.
Outdated
|
||
|
|
||
| event BetaOperatorsAdded(address[] operators); | ||
|
|
||
| event ChaosnetMaestroRoleTransferred( | ||
| address oldChaosnetMaestro, | ||
| address newChaosnetMaestro | ||
| ); | ||
|
|
||
| event ChaosnetDeactivated(); | ||
|
|
||
| constructor() { | ||
| _transferChaosnetMaestro(msg.sender); | ||
|
dimpar marked this conversation as resolved.
Outdated
|
||
| isChaosnetActive = true; | ||
| } | ||
|
|
||
| modifier onlyChaosnetMaestro() { | ||
| require(msg.sender == chaosnetMaestro, "Not the chaosnet maestro"); | ||
| _; | ||
| } | ||
|
|
||
| /// @notice Adds beta operator to chaosnet. Can be called only by the | ||
| /// chaosnet maestro. | ||
| function addBetaOperators(address[] calldata operators) | ||
|
dimpar marked this conversation as resolved.
|
||
| public | ||
| onlyChaosnetMaestro | ||
| { | ||
| for (uint256 i = 0; i < operators.length; i++) { | ||
| isBetaOperator[operators[i]] = true; | ||
|
dimpar marked this conversation as resolved.
|
||
| } | ||
|
|
||
| emit BetaOperatorsAdded(operators); | ||
| } | ||
|
|
||
| /// @notice Deactivates the chaosnet. Can be called only by the chaosnet | ||
| /// maestro. Once deactivated chaosnet can not be activated again. | ||
| function deactivateChaosnet() public onlyChaosnetMaestro { | ||
| require(isChaosnetActive, "Chaosnet is not active"); | ||
| isChaosnetActive = false; | ||
| emit ChaosnetDeactivated(); | ||
| } | ||
|
|
||
| /// @notice Transfers the chaosnet maestro role to another non-zero address. | ||
| function transferChaosnetMaestroRole(address newChaosnetMaestro) | ||
| public | ||
| onlyChaosnetMaestro | ||
| { | ||
| require( | ||
| newChaosnetMaestro != address(0), | ||
| "New chaosnet maestro must not be zero address" | ||
| ); | ||
| _transferChaosnetMaestro(newChaosnetMaestro); | ||
| } | ||
|
|
||
| function _transferChaosnetMaestro(address newChaosnetMaestro) internal { | ||
| address oldChaosnetMaestro = chaosnetMaestro; | ||
| chaosnetMaestro = newChaosnetMaestro; | ||
| emit ChaosnetMaestroRoleTransferred(oldChaosnetMaestro, newChaosnetMaestro); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.