github.com/codingfuture/orig-energi3@v0.8.4/energi/contracts/src/SporkRegistryV2.sol (about) 1 // Copyright 2019 The Energi Core Authors 2 // This file is part of Energi Core. 3 // 4 // Energi Core is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Energi Core is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Energi Core. If not, see <http://www.gnu.org/licenses/>. 16 17 // Energi Governance system is the fundamental part of Energi Core. 18 19 // NOTE: It's not allowed to change the compiler due to byte-to-byte 20 // match requirement. 21 pragma solidity 0.5.16; 22 //pragma experimental SMTChecker; 23 24 import { IGovernedContract } from "./IGovernedContract.sol"; 25 import { IGovernedProxy } from "./IGovernedProxy.sol"; 26 import { IUpgradeProposal } from "./IUpgradeProposal.sol"; 27 import { SporkRegistryV1, UpgradeProposalV1 } from "./SporkRegistryV1.sol"; 28 29 // solium-disable security/no-block-members 30 // solium-disable no-empty-blocks 31 32 /** 33 * A special proposal for emergency consensus upgrades. 34 * 35 * NOTE: it MUST NOT change after blockchain launch! 36 */ 37 contract EmergencyProposal is 38 UpgradeProposalV1 39 { 40 constructor( 41 address _parent, 42 IGovernedContract _impl, 43 IGovernedProxy _mnregistry_proxy, 44 uint _period, 45 address payable _feePayer 46 ) 47 public 48 UpgradeProposalV1( 49 _parent, 50 _impl, 51 _mnregistry_proxy, 52 _period, 53 _feePayer 54 ) 55 {} 56 57 function isAccepted() public view returns(bool) { 58 return true; 59 } 60 61 function isFinished() public view returns(bool) { 62 return true; 63 } 64 65 function voteAccept() external { 66 } 67 68 function voteReject() external { 69 } 70 } 71 72 73 /** 74 * Genesis hardcoded version of SporkRegistry 75 * 76 * NOTE: it MUST NOT change after blockchain launch! 77 */ 78 contract SporkRegistryV2 is 79 SporkRegistryV1 80 { 81 // Data for migration 82 //--------------------------------- 83 address public Emergency_signer; 84 //--------------------------------- 85 86 // IGovernedContract 87 //--------------------------------- 88 constructor(address _proxy, IGovernedProxy _mnregistry_proxy, address _emergency_signer) 89 public SporkRegistryV1(_proxy, _mnregistry_proxy) 90 { 91 Emergency_signer = _emergency_signer; 92 } 93 94 // ISporkRegistry 95 //--------------------------------- 96 function createUpgradeProposal(IGovernedContract _impl, uint _period, address payable _fee_payer) 97 external payable 98 returns (IUpgradeProposal proposal) 99 { 100 if (Emergency_signer == _fee_payer) { 101 require(msg.value == 0, "Invalid fee"); 102 require(_period == 0, "Invalid period"); 103 104 return new EmergencyProposal( 105 msg.sender, 106 _impl, 107 mnregistry_proxy, 108 _period, 109 _fee_payer 110 ); 111 } 112 113 // Parent has external method, unfortunately. 114 //return super.createUpgradeProposal(_impl, _period, _fee_payer); 115 116 require(msg.value == FEE_UPGRADE_V1, "Invalid fee"); 117 require(_period >= PERIOD_UPGRADE_MIN, "Period min"); 118 require(_period <= PERIOD_UPGRADE_MAX, "Period max"); 119 120 proposal = new UpgradeProposalV1( 121 msg.sender, 122 _impl, 123 mnregistry_proxy, 124 _period, 125 _fee_payer 126 ); 127 128 proposal.setFee.value(msg.value)(); 129 } 130 }