You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.8 KiB
105 lines
2.8 KiB
4 years ago
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||
|
pragma solidity >=0.6.11;
|
||
|
|
||
3 years ago
|
// ============ Internal Imports ============
|
||
|
import {IUpdaterManager} from "../interfaces/IUpdaterManager.sol";
|
||
|
import {Home} from "./Home.sol";
|
||
|
// ============ External Imports ============
|
||
4 years ago
|
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
||
3 years ago
|
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
||
4 years ago
|
|
||
3 years ago
|
/**
|
||
|
* @title UpdaterManager
|
||
|
* @author Celo Labs Inc.
|
||
|
* @notice MVP / centralized version of contract
|
||
|
* that will manage Updater bonding, slashing,
|
||
|
* selection and rotation
|
||
|
*/
|
||
4 years ago
|
contract UpdaterManager is IUpdaterManager, Ownable {
|
||
3 years ago
|
// ============ Internal Storage ============
|
||
|
|
||
|
// address of home contract
|
||
4 years ago
|
address internal home;
|
||
|
|
||
3 years ago
|
// ============ Private Storage ============
|
||
|
|
||
|
// address of the current updater
|
||
|
address private _updater;
|
||
|
|
||
|
// ============ Events ============
|
||
|
|
||
4 years ago
|
/**
|
||
3 years ago
|
* @notice Emitted when a new home is set
|
||
4 years ago
|
* @param home The address of the new home contract
|
||
|
*/
|
||
|
event NewHome(address home);
|
||
|
|
||
3 years ago
|
/**
|
||
|
* @notice Emitted when slashUpdater is called
|
||
|
*/
|
||
|
event FakeSlashed(address reporter);
|
||
|
|
||
|
// ============ Modifiers ============
|
||
4 years ago
|
|
||
3 years ago
|
/**
|
||
|
* @notice Require that the function is called
|
||
|
* by the Home contract
|
||
|
*/
|
||
4 years ago
|
modifier onlyHome() {
|
||
|
require(msg.sender == home, "!home");
|
||
|
_;
|
||
|
}
|
||
|
|
||
3 years ago
|
// ============ Constructor ============
|
||
|
|
||
|
constructor(address _updaterAddress) payable Ownable() {
|
||
|
_updater = _updaterAddress;
|
||
|
}
|
||
|
|
||
|
// ============ External Functions ============
|
||
|
|
||
4 years ago
|
/**
|
||
3 years ago
|
* @notice Set the address of the a new home contract
|
||
|
* @dev only callable by trusted owner
|
||
4 years ago
|
* @param _home The address of the new home contract
|
||
|
*/
|
||
|
function setHome(address _home) external onlyOwner {
|
||
|
require(Address.isContract(_home), "!contract home");
|
||
|
home = _home;
|
||
|
|
||
|
emit NewHome(_home);
|
||
|
}
|
||
|
|
||
|
/**
|
||
3 years ago
|
* @notice Set the address of a new updater
|
||
|
* @dev only callable by trusted owner
|
||
|
* @param _updaterAddress The address of the new updater
|
||
4 years ago
|
*/
|
||
|
function setUpdater(address _updaterAddress) external onlyOwner {
|
||
|
_updater = _updaterAddress;
|
||
4 years ago
|
Home(home).setUpdater(_updaterAddress);
|
||
4 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* @notice Slashes the updater
|
||
3 years ago
|
* @dev Currently does nothing, functionality will be implemented later
|
||
|
* when updater bonding and rotation are also implemented
|
||
4 years ago
|
* @param _reporter The address of the entity that reported the updater fraud
|
||
|
*/
|
||
|
function slashUpdater(address payable _reporter)
|
||
|
external
|
||
|
override
|
||
|
onlyHome
|
||
3 years ago
|
{
|
||
|
emit FakeSlashed(_reporter);
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
/**
|
||
|
* @notice Get address of current updater
|
||
|
* @return the updater address
|
||
|
*/
|
||
4 years ago
|
function updater() external view override returns (address) {
|
||
|
return _updater;
|
||
|
}
|
||
4 years ago
|
}
|