@@ -63,17 +63,17 @@ contract XanV1 is
63
63
error ImplementationNotDelayed (address expected , address actual );
64
64
65
65
error UpgradeNotScheduled (address impl );
66
- error UpgradeAlreadyScheduled (ScheduledUpgrade scheduledImpl );
67
- error UpgradeCancellationInvalid (ScheduledUpgrade scheduledImpl );
66
+ error UpgradeAlreadyScheduled (address impl , uint48 endTime );
67
+ error UpgradeCancellationInvalid (address impl , uint48 endTime );
68
68
error UpgradeIsNotAllowedToBeScheduledTwice (address impl );
69
69
70
70
error MinLockedSupplyNotReached ();
71
71
error QuorumNowhereReached ();
72
72
error QuorumNotReached (address impl );
73
73
error QuorumReached (address impl );
74
74
75
- error DelayPeriodNotStarted (ScheduledUpgrade scheduledImpl );
76
- error DelayPeriodNotEnded (ScheduledUpgrade scheduledImpl );
75
+ error DelayPeriodNotStarted (uint48 endTime );
76
+ error DelayPeriodNotEnded (uint48 endTime );
77
77
78
78
error UnauthorizedCaller (address caller );
79
79
@@ -184,13 +184,14 @@ contract XanV1 is
184
184
}
185
185
186
186
/// @inheritdoc IXanV1
187
+ // TODO! remove input arg
187
188
function scheduleVoterBodyUpgrade (address proposedImpl ) external override {
188
189
Voting.Data storage votingData = _getVotingData ();
189
190
190
191
// Check that no other upgrade has been scheduled yet.
191
192
{
192
- if (votingData.scheduledUpgrade.endTime != 0 && votingData.scheduledUpgrade.impl != address (0 )) {
193
- revert UpgradeAlreadyScheduled (votingData.scheduledUpgrade );
193
+ if (votingData.scheduledEndTime != 0 && votingData.scheduledImpl != address (0 )) {
194
+ revert UpgradeAlreadyScheduled (votingData.scheduledImpl, votingData.scheduledEndTime );
194
195
}
195
196
}
196
197
@@ -205,37 +206,36 @@ contract XanV1 is
205
206
// Check if the council has proposed an upgrade and, if so, cancel.
206
207
{
207
208
Council.Data storage councilData = _getCouncilData ();
208
- if (councilData.scheduledUpgrade.endTime != 0 && councilData.scheduledUpgrade.impl != address (0 )) {
209
+ if (councilData.scheduledEndTime != 0 && councilData.scheduledImpl != address (0 )) {
209
210
_cancelCouncilUpgrade ();
210
211
211
212
emit CouncilUpgradeVetoed (); // TODO! Revisit event args
212
213
}
213
214
}
214
215
215
216
// Schedule the upgrade and emit the associated event.
216
- votingData.scheduledUpgrade =
217
- ScheduledUpgrade ({impl: proposedImpl, endTime: Time.timestamp () + Parameters.DELAY_DURATION}) ;
217
+ votingData.scheduledImpl = proposedImpl;
218
+ votingData.scheduledEndTime = Time.timestamp () + Parameters.DELAY_DURATION;
218
219
219
- emit VoterBodyUpgradeScheduled (votingData.scheduledUpgrade );
220
+ emit VoterBodyUpgradeScheduled (votingData.scheduledImpl, votingData.scheduledEndTime );
220
221
}
221
222
222
223
/// @inheritdoc IXanV1
223
224
function cancelVoterBodyUpgrade () external override {
224
225
Voting.Data storage data = _getVotingData ();
225
226
226
- ScheduledUpgrade memory scheduledUpgrade = data.scheduledUpgrade;
227
-
228
- _checkDelayCriterion (scheduledUpgrade);
227
+ _checkDelayCriterion (data.scheduledEndTime);
229
228
230
229
// Check that the quorum for the new implementation is reached.
231
- if (_isQuorumReached (scheduledUpgrade.impl ) && scheduledUpgrade.impl == data.ranking[0 ]) {
232
- revert UpgradeCancellationInvalid (scheduledUpgrade );
230
+ if (_isQuorumReached (data.scheduledImpl ) && data.scheduledImpl == data.ranking[0 ]) {
231
+ revert UpgradeCancellationInvalid (data.scheduledImpl, data.scheduledEndTime );
233
232
}
234
233
235
- emit VoterBodyUpgradeCancelled (data.scheduledUpgrade );
234
+ emit VoterBodyUpgradeCancelled (data.scheduledImpl, data.scheduledEndTime );
236
235
237
236
// Reset the scheduled upgrade
238
- data.scheduledUpgrade = ScheduledUpgrade ({impl: address (0 ), endTime: 0 });
237
+ data.scheduledImpl = address (0 );
238
+ data.scheduledEndTime = 0 ;
239
239
}
240
240
241
241
/// @notice @inheritdoc IXanV1
@@ -252,14 +252,14 @@ contract XanV1 is
252
252
253
253
Council.Data storage data = _getCouncilData ();
254
254
255
- if (data.scheduledUpgrade.impl == proposedImpl) {
255
+ if (data.scheduledImpl == proposedImpl) {
256
256
revert ImplementationAlreadyProposed (proposedImpl);
257
257
}
258
258
259
- data.scheduledUpgrade =
260
- ScheduledUpgrade ({impl: proposedImpl, endTime: Time.timestamp () + Parameters.DELAY_DURATION}) ;
259
+ data.scheduledImpl = proposedImpl;
260
+ data.scheduledEndTime = Time.timestamp () + Parameters.DELAY_DURATION;
261
261
262
- emit CouncilUpgradeScheduled (data.scheduledUpgrade );
262
+ emit CouncilUpgradeScheduled (data.scheduledImpl, data.scheduledEndTime );
263
263
}
264
264
265
265
/// @notice @inheritdoc IXanV1
@@ -324,13 +324,17 @@ contract XanV1 is
324
324
}
325
325
326
326
/// @inheritdoc IXanV1
327
- function scheduledVoterBodyUpgrade () public view override returns (ScheduledUpgrade memory scheduledUpgrade ) {
328
- scheduledUpgrade = _getVotingData ().scheduledUpgrade;
327
+ function scheduledVoterBodyUpgrade () public view override returns (address impl , uint48 endTime ) {
328
+ Voting.Data storage data = _getVotingData ();
329
+ impl = data.scheduledImpl;
330
+ endTime = data.scheduledEndTime;
329
331
}
330
332
331
333
/// @inheritdoc IXanV1
332
- function scheduledCouncilUpgrade () public view override returns (ScheduledUpgrade memory scheduledUpgrade ) {
333
- scheduledUpgrade = _getCouncilData ().scheduledUpgrade;
334
+ function scheduledCouncilUpgrade () public view override returns (address impl , uint48 endTime ) {
335
+ Council.Data storage data = _getCouncilData ();
336
+ impl = data.scheduledImpl;
337
+ endTime = data.scheduledEndTime;
334
338
}
335
339
336
340
/// @inheritdoc IXanV1
@@ -385,7 +389,10 @@ contract XanV1 is
385
389
386
390
/// @notice Cancels the scheduled upgrade by the council by resetting it to 0.
387
391
function _cancelCouncilUpgrade () internal {
388
- _getCouncilData ().scheduledUpgrade = ScheduledUpgrade ({impl: address (0 ), endTime: 0 });
392
+ Council.Data storage data = _getCouncilData ();
393
+
394
+ data.scheduledImpl = address (0 );
395
+ data.scheduledEndTime = 0 ;
389
396
}
390
397
391
398
/// @notice Authorizes an upgrade.
@@ -396,13 +403,12 @@ contract XanV1 is
396
403
}
397
404
398
405
Voting.Data storage votingData = _getVotingData ();
399
- address bestRankedVoterBodyImpl = votingData.ranking[ 0 ] ;
406
+ Council.Data storage councilData = _getCouncilData () ;
400
407
401
- ScheduledUpgrade memory voterBodyUpgrade = votingData.scheduledUpgrade;
402
- ScheduledUpgrade memory councilUpgrade = scheduledCouncilUpgrade ();
408
+ address bestRankedVoterBodyImpl = votingData.ranking[0 ];
403
409
404
- bool isScheduledByVoterBody = (newImpl == voterBodyUpgrade.impl );
405
- bool isScheduledByCouncil = (newImpl == councilUpgrade.impl );
410
+ bool isScheduledByVoterBody = (newImpl == votingData.scheduledImpl );
411
+ bool isScheduledByCouncil = (newImpl == councilData.scheduledImpl );
406
412
407
413
// NOTE: councilUpgrade.impl and voterBodyUpgrade.impl can still be address(0);
408
414
@@ -412,17 +418,17 @@ contract XanV1 is
412
418
}
413
419
414
420
if (isScheduledByVoterBody) {
415
- _checkDelayCriterion (voterBodyUpgrade );
421
+ _checkDelayCriterion (votingData.scheduledEndTime );
416
422
_checkVoterBodyUpgradeCriteria ({
417
- impl: voterBodyUpgrade.impl ,
423
+ impl: votingData.scheduledImpl ,
418
424
bestRankedVoterBodyImpl: bestRankedVoterBodyImpl
419
425
});
420
426
421
427
return ;
422
428
}
423
429
424
430
if (isScheduledByCouncil) {
425
- _checkDelayCriterion (councilUpgrade );
431
+ _checkDelayCriterion (councilData.scheduledEndTime );
426
432
_checkCouncilUpgradeCriteria ({bestRankedVoterBodyImpl: bestRankedVoterBodyImpl});
427
433
428
434
return ;
@@ -486,14 +492,14 @@ contract XanV1 is
486
492
}
487
493
488
494
/// @notice Checks if the delay period for a scheduled upgrade has ended and reverts with errors if not.
489
- /// @param scheduledUpgrade The end time to check.
490
- function _checkDelayCriterion (ScheduledUpgrade memory scheduledUpgrade ) internal view {
491
- if (scheduledUpgrade. endTime == 0 ) {
492
- revert DelayPeriodNotStarted (scheduledUpgrade );
495
+ /// @param endTime The end time of the delay period to check.
496
+ function _checkDelayCriterion (uint48 endTime ) internal view {
497
+ if (endTime == 0 ) {
498
+ revert DelayPeriodNotStarted (endTime );
493
499
}
494
500
495
- if (Time.timestamp () < scheduledUpgrade. endTime) {
496
- revert DelayPeriodNotEnded (scheduledUpgrade );
501
+ if (Time.timestamp () < endTime) {
502
+ revert DelayPeriodNotEnded (endTime );
497
503
}
498
504
}
499
505
0 commit comments