@@ -115,11 +115,11 @@ contract XanV1 is
115
115
function castVote (address proposedImpl ) external override {
116
116
address voter = msg .sender ;
117
117
118
- Voting.Data storage $ = _getVotingData ();
119
- Voting.Ballot storage ballot = $ .ballots[proposedImpl];
118
+ Voting.Data storage data = _getVotingData ();
119
+ Voting.Ballot storage ballot = data .ballots[proposedImpl];
120
120
121
121
if (! ballot.exists) {
122
- $ .assignWorstRank (proposedImpl);
122
+ data .assignWorstRank (proposedImpl);
123
123
}
124
124
125
125
// Cache the old votum of the voter.
@@ -147,7 +147,7 @@ contract XanV1 is
147
147
ballot.totalVotes += delta;
148
148
149
149
// Bubble the proposed implementation up in the ranking.
150
- $ .bubbleUp (proposedImpl);
150
+ data .bubbleUp (proposedImpl);
151
151
152
152
emit VoteCast ({voter: voter, implementation: proposedImpl, value: delta});
153
153
}
@@ -156,8 +156,8 @@ contract XanV1 is
156
156
function revokeVote (address proposedImpl ) external override {
157
157
address voter = msg .sender ;
158
158
159
- Voting.Data storage $ = _getVotingData ();
160
- Voting.Ballot storage ballot = $ .ballots[proposedImpl];
159
+ Voting.Data storage data = _getVotingData ();
160
+ Voting.Ballot storage ballot = data .ballots[proposedImpl];
161
161
162
162
// Cache the old votum of the voter.
163
163
uint256 oldVotum = ballot.vota[voter];
@@ -174,7 +174,7 @@ contract XanV1 is
174
174
ballot.totalVotes -= oldVotum;
175
175
176
176
// Bubble the proposed implementation down in the ranking.
177
- $ .bubbleDown (proposedImpl);
177
+ data .bubbleDown (proposedImpl);
178
178
179
179
emit VoteRevoked ({voter: voter, implementation: proposedImpl, value: oldVotum});
180
180
}
@@ -184,24 +184,24 @@ contract XanV1 is
184
184
// Check that all upgrade criteria are met before starting the delay.
185
185
_checkVoterBodyUpgradeCriteria (proposedImpl);
186
186
187
- Voting.Data storage $ = _getVotingData ();
187
+ Voting.Data storage data = _getVotingData ();
188
188
189
189
uint48 currentTime = Time.timestamp ();
190
190
191
191
// Check that the delay period hasn't been started yet by
192
192
// ensuring that no end time and implementation has been set.
193
- if ($ .delayEndTime != 0 && $ .delayedUpgradeImpl != address (0 )) {
194
- revert DelayPeriodAlreadyStarted ($ .delayedUpgradeImpl);
193
+ if (data .delayEndTime != 0 && data .delayedUpgradeImpl != address (0 )) {
194
+ revert DelayPeriodAlreadyStarted (data .delayedUpgradeImpl);
195
195
}
196
196
197
197
// Set the end time and emit the associated event.
198
- $ .delayEndTime = currentTime + Parameters.DELAY_DURATION;
199
- $ .delayedUpgradeImpl = proposedImpl;
198
+ data .delayEndTime = currentTime + Parameters.DELAY_DURATION;
199
+ data .delayedUpgradeImpl = proposedImpl;
200
200
201
201
emit VoterBodyUpgradeDelayStarted ({
202
202
implementation: proposedImpl,
203
203
startTime: currentTime,
204
- endTime: $ .delayEndTime
204
+ endTime: data .delayEndTime
205
205
});
206
206
}
207
207
@@ -383,18 +383,29 @@ contract XanV1 is
383
383
revert ImplementationZero ();
384
384
}
385
385
386
- // TODO optimize fetching? Data is also used in Criteria checks // No, happens only once.
387
- address councilProposedImpl = _getCouncilData ().proposedImpl ;
386
+ Council. Data storage council = _getCouncilData ();
387
+ Voting.Data storage voting = _getVotingData () ;
388
388
389
- // TODO! What if the voter body votes for the same impl as the council?
389
+ // TODO REFACTOR
390
+ if (newImpl != council.proposedImpl) {
391
+ _checkVoterBodyDelayCriterion (newImpl);
392
+ _checkVoterBodyUpgradeCriteria (newImpl);
393
+ return ;
394
+ }
390
395
391
- if (newImpl == councilProposedImpl) {
392
- _checkCouncilDelayCriterion ( /*TODO! //councilProposedImpl*/ );
396
+ // TODO! rename delayedUpgradeImpl to scheduled impl!!!
397
+ if (newImpl != voting.delayedUpgradeImpl) {
398
+ _checkCouncilDelayCriterion ();
399
+ _checkCouncilUpgradeCriteria (newImpl);
400
+ return ;
401
+ }
393
402
394
- _checkCouncilUpgradeCriteria (councilProposedImpl);
403
+ // The same implementation has been proposed by both
404
+ if (council.delayEndTime < voting.delayEndTime) {
405
+ _checkCouncilDelayCriterion ();
406
+ _checkCouncilUpgradeCriteria (newImpl);
395
407
} else {
396
408
_checkVoterBodyDelayCriterion (newImpl);
397
-
398
409
_checkVoterBodyUpgradeCriteria (newImpl);
399
410
}
400
411
}
0 commit comments