forked from omni-network/omni
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUpgrade.sol
64 lines (56 loc) · 2.67 KB
/
Upgrade.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity =0.8.24;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
/**
* @title Upgrade
* @notice The EVM interface to the consensus chain's x/upgrade module.
* Calls are proxied, and not executed syncronously. Their execution is left to
* the consensus chain, and they may fail.
* @dev This contract is predeployed, and requires storage slots to be set in genesis.
* Genesis storage slots must:
* - set _owner on proxy
* - set _initialized on proxy to 1, to disable the initializer
* - set _initialized on implementation to type(uint64).max, to disabled all initializers
*/
contract Upgrade is OwnableUpgradeable {
/**
* @notice Emitted when a software upgrade is planned
* @param name (MsgSoftwareUpgrade.plan.name) The name for the upgrade
* @param height (MsgSoftwareUpgrade.plan.height) The height at which the upgrade must be performed
* @param info (MsgSoftwareUpgrade.plan.info) Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to
*/
event PlanUpgrade(string name, uint64 height, string info);
/**
* @notice Emitted when the current planned (non-executed) upgrade plan should be cancelled.
*/
event CancelUpgrade();
/**
* @notice Plan specifies information about a planned upgrade and when it should occur..
* @custom:field name (MsgSoftwareUpgrade.plan.name) The name for the upgrade
* @custom:field height (MsgSoftwareUpgrade.plan.height) The height at which the upgrade must be performed
* @custom:field info (MsgSoftwareUpgrade.plan.info) Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to
*/
struct Plan {
string name;
uint64 height;
string info;
}
function initialize(address owner_) public initializer {
__Ownable_init(owner_);
}
//////////////////////////////////////////////////////////////////////////////
// Admin //
//////////////////////////////////////////////////////////////////////////////
/**
* @notice Plan a new software upgrade
*/
function planUpgrade(Plan calldata plan) external onlyOwner {
emit PlanUpgrade(plan.name, plan.height, plan.info);
}
/**
* @notice Cancels the current planned (non-executed) upgrade.
*/
function cancelUpgrade() external onlyOwner {
emit CancelUpgrade();
}
}