@@ -20,8 +20,6 @@ import {
20
20
abstract contract Governance is IGovernance , State , ERC1967Upgrade {
21
21
using BytesParsing for bytes ;
22
22
23
- error UnsupportedGovernanceAction ();
24
-
25
23
uint16 constant GOVERNANCE_CHAIN = 1 ;
26
24
bytes32 constant GOVERNANCE_EMITTER =
27
25
0x0000000000000000000000000000000000000000000000000000000000000004 ;
@@ -42,32 +40,23 @@ abstract contract Governance is IGovernance, State, ERC1967Upgrade {
42
40
// unless the target chain is 0 (which means all chains).
43
41
uint16 targetChain;
44
42
(targetChain, offset) = vaa.payload.asUint16Unchecked (offset);
45
-
46
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
47
43
require (targetChain == 0 || targetChain == _chainId, "invalid target chain " );
48
44
49
45
uint16 foreignChain;
50
46
(foreignChain, offset) = vaa.payload.asUint16Unchecked (offset);
51
-
52
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
53
47
require (foreignChain != 0 && foreignChain != _chainId, "invalid chain " );
54
48
55
49
mapping (uint16 => bytes32 ) storage registeredEmitters = getRegisteredEmitters ();
56
50
57
51
// For now, ensure that we cannot register the same foreign chain again.
58
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
59
52
require (registeredEmitters[foreignChain] == 0 , "chain already registered " );
60
53
61
54
bytes32 foreignAddress;
62
55
(foreignAddress, offset) = vaa.payload.asBytes32Unchecked (offset);
63
-
64
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
65
56
require (foreignAddress != 0 , "emitter cannot be zero address " );
66
57
67
58
uint32 cctpDomain;
68
59
(cctpDomain, offset) = vaa.payload.asUint32Unchecked (offset);
69
-
70
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
71
60
require (cctpDomain != _localCctpDomain, "domain == localDomain() " );
72
61
73
62
_checkLength (vaa.payload, offset);
@@ -102,14 +91,10 @@ abstract contract Governance is IGovernance, State, ERC1967Upgrade {
102
91
// contract upgrades should only be relevant for this contract's chain ID
103
92
uint16 targetChain;
104
93
(targetChain, offset) = vaa.payload.asUint16Unchecked (offset);
105
-
106
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
107
94
require (targetChain == _chainId, "invalid target chain " );
108
95
109
96
bytes32 encodedImplementation;
110
97
(encodedImplementation, offset) = vaa.payload.asBytes32Unchecked (offset);
111
-
112
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
113
98
require (bytes12 (encodedImplementation) == 0 , "invalid address " );
114
99
115
100
_checkLength (vaa.payload, offset);
@@ -125,7 +110,6 @@ abstract contract Governance is IGovernance, State, ERC1967Upgrade {
125
110
abi.encodeWithSignature ("circleIntegrationImplementation() " )
126
111
);
127
112
128
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
129
113
require (queried.length == 32 , "invalid implementation " );
130
114
require (
131
115
abi.decode (queried, (bytes32 )) == keccak256 ("circleIntegrationImplementation() " ),
@@ -141,8 +125,6 @@ abstract contract Governance is IGovernance, State, ERC1967Upgrade {
141
125
// call initialize function of the new implementation
142
126
(bool success , bytes memory reason ) =
143
127
newImplementation.delegatecall (abi.encodeWithSignature ("initialize() " ));
144
-
145
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
146
128
require (success, string (reason));
147
129
148
130
emit ContractUpgraded (currentImplementation, newImplementation);
@@ -180,41 +162,33 @@ abstract contract Governance is IGovernance, State, ERC1967Upgrade {
180
162
uint8 action
181
163
) private view returns (IWormhole.VM memory vaa , uint256 offset ) {
182
164
// Make sure the blockchain has not forked.
183
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
184
165
require (block .chainid == _evmChain, "invalid evm chain " );
185
166
186
167
// verify the governance message
187
168
bool valid;
188
169
string memory reason;
189
170
(vaa, valid, reason) = _wormhole.parseAndVerifyVM (encodedVaa);
190
-
191
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
192
171
require (valid, reason);
193
172
194
173
// Confirm that the governance message was sent from the governance contract.
195
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
196
174
require (vaa.emitterChainId == GOVERNANCE_CHAIN, "invalid governance chain " );
197
175
require (vaa.emitterAddress == GOVERNANCE_EMITTER, "invalid governance contract " );
198
176
199
177
// Confirm that this governance action has not been consumed already.
200
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
201
178
require (! consumedVaas[vaa.hash], "governance action already consumed " );
202
179
203
180
bytes32 govModule;
204
181
(govModule, offset) = vaa.payload.asBytes32Unchecked (offset);
205
182
206
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
207
183
require (govModule == GOVERNANCE_MODULE, "invalid governance module " );
208
184
209
185
uint8 govAction;
210
186
(govAction, offset) = vaa.payload.asUint8Unchecked (offset);
211
187
212
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
213
188
require (govAction == action, "invalid governance action " );
214
189
}
215
190
216
191
function _checkLength (bytes memory encoded , uint256 expected ) private pure {
217
- // NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
218
192
require (encoded.length == expected, "invalid governance payload length " );
219
193
}
220
194
0 commit comments