2
2
3
3
pragma solidity ^ 0.8.9 ;
4
4
5
+ import { TConsensus } from "../udvts/Types.sol " ;
6
+
5
7
interface IMaintenance {
6
8
/**
7
9
* @dev Error thrown when attempting to schedule an already scheduled event.
@@ -61,9 +63,9 @@ interface IMaintenance {
61
63
}
62
64
63
65
/// @dev Emitted when a maintenance is scheduled.
64
- event MaintenanceScheduled (address indexed consensusAddr , Schedule);
66
+ event MaintenanceScheduled (TConsensus indexed consensusAddr , Schedule);
65
67
/// @dev Emitted when a schedule of maintenance is cancelled.
66
- event MaintenanceScheduleCancelled (address indexed consensusAddr );
68
+ event MaintenanceScheduleCancelled (TConsensus indexed consensusAddr );
67
69
/// @dev Emitted when the maintenance config is updated.
68
70
event MaintenanceConfigUpdated (
69
71
uint256 minMaintenanceDurationInBlock ,
@@ -75,52 +77,76 @@ interface IMaintenance {
75
77
);
76
78
77
79
/**
78
- * @dev Returns whether the validator `_consensusAddr` maintained at the block number `_block`.
80
+ * @dev Returns whether the validator `consensusAddr` maintained at the block number `_block`.
81
+ */
82
+ function checkMaintained (TConsensus consensusAddr , uint256 _block ) external view returns (bool );
83
+
84
+ /**
85
+ * @dev Returns whether the validator whose id `validatorId` maintained at the block number `_block`.
79
86
*/
80
- function checkMaintained (address _consensusAddr , uint256 _block ) external view returns (bool );
87
+ function checkMaintainedById (address validatorId , uint256 _block ) external view returns (bool );
81
88
82
89
/**
83
- * @dev Returns whether the validator `_consensusAddr ` maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks.
90
+ * @dev Returns whether the validator `consensusAddr ` maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks.
84
91
*/
85
92
function checkMaintainedInBlockRange (
86
- address _consensusAddr ,
93
+ TConsensus consensusAddr ,
87
94
uint256 _fromBlock ,
88
95
uint256 _toBlock
89
96
) external view returns (bool );
90
97
91
98
/**
92
- * @dev Returns the bool array indicating the validators maintained at block number `_block ` or not.
99
+ * @dev Returns the bool array indicating the validators maintained at block number `k ` or not.
93
100
*/
94
- function checkManyMaintained (address [] calldata _addrList , uint256 _block ) external view returns (bool [] memory );
101
+ function checkManyMaintained (
102
+ TConsensus[] calldata consensusAddrList ,
103
+ uint256 atBlock
104
+ ) external view returns (bool [] memory );
105
+
106
+ function checkManyMaintainedById (
107
+ address [] calldata candidateIdList ,
108
+ uint256 atBlock
109
+ ) external view returns (bool [] memory );
95
110
96
111
/**
97
112
* @dev Returns a bool array indicating the validators maintained in the inclusive range [`_fromBlock`, `_toBlock`] of blocks or not.
98
113
*/
99
114
function checkManyMaintainedInBlockRange (
100
- address [] calldata _addrList ,
115
+ TConsensus [] calldata _consensusAddrList ,
101
116
uint256 _fromBlock ,
102
117
uint256 _toBlock
103
118
) external view returns (bool [] memory );
104
119
120
+ function checkManyMaintainedInBlockRangeById (
121
+ address [] calldata idList ,
122
+ uint256 fromBlock ,
123
+ uint256 toBlock
124
+ ) external view returns (bool [] memory );
125
+
105
126
/**
106
- * @dev Returns whether the validator `_consensusAddr ` has scheduled .
127
+ * @dev Returns whether the validator `consensusAddr ` has finished cooldown .
107
128
*/
108
- function checkScheduled ( address _consensusAddr ) external view returns (bool );
129
+ function checkCooldownEnded (TConsensus consensusAddr ) external view returns (bool );
109
130
110
131
/**
111
- * @dev Returns whether the validator `_consensusAddr`
132
+ * @dev Returns whether the validator `consensusAddr` has schedule.
112
133
*/
113
- function checkCooldownEnded ( address _consensusAddr ) external view returns (bool );
134
+ function checkScheduled (TConsensus consensusAddr ) external view returns (bool );
114
135
115
136
/**
116
- * @dev Returns the detailed schedule of the validator `_consensusAddr `.
137
+ * @dev Returns the detailed schedule of the validator `consensusAddr `.
117
138
*/
118
- function getSchedule (address _consensusAddr ) external view returns (Schedule memory );
139
+ function getSchedule (TConsensus consensusAddr ) external view returns (Schedule memory );
119
140
120
141
/**
121
142
* @dev Returns the total of current schedules.
122
143
*/
123
- function totalSchedule () external view returns (uint256 _count );
144
+ function totalSchedule () external view returns (uint256 count );
145
+
146
+ /**
147
+ * @dev Returns the cooldown to maintain in seconds.
148
+ */
149
+ function cooldownSecsToMaintain () external view returns (uint256 );
124
150
125
151
/**
126
152
* @dev Sets the duration restriction, start time restriction, and max allowed for maintenance.
@@ -134,12 +160,12 @@ interface IMaintenance {
134
160
*
135
161
*/
136
162
function setMaintenanceConfig (
137
- uint256 _minMaintenanceDurationInBlock ,
138
- uint256 _maxMaintenanceDurationInBlock ,
139
- uint256 _minOffsetToStartSchedule ,
140
- uint256 _maxOffsetToStartSchedule ,
141
- uint256 _maxSchedules ,
142
- uint256 _cooldownSecsToMaintain
163
+ uint256 minMaintenanceDurationInBlock_ ,
164
+ uint256 maxMaintenanceDurationInBlock_ ,
165
+ uint256 minOffsetToStartSchedule_ ,
166
+ uint256 maxOffsetToStartSchedule_ ,
167
+ uint256 maxSchedules_ ,
168
+ uint256 cooldownSecsToMaintain_
143
169
) external ;
144
170
145
171
/**
@@ -168,12 +194,12 @@ interface IMaintenance {
168
194
function maxSchedule () external view returns (uint256 );
169
195
170
196
/**
171
- * @dev Schedules for maintenance from `_startedAtBlock ` to `_startedAtBlock `.
197
+ * @dev Schedules for maintenance from `startedAtBlock ` to `endedAtBlock `.
172
198
*
173
199
* Requirements:
174
- * - The candidate `_consensusAddr ` is the block producer.
175
- * - The method caller is candidate admin of the candidate `_consensusAddr `.
176
- * - The candidate `_consensusAddr ` has no schedule yet or the previous is done.
200
+ * - The candidate `consensusAddr ` is the block producer.
201
+ * - The method caller is candidate admin of the candidate `consensusAddr `.
202
+ * - The candidate `consensusAddr ` has no schedule yet or the previous is done.
177
203
* - The total number of schedules is not larger than `maxSchedules()`.
178
204
* - The start block must be at least `minOffsetToStartSchedule()` and at most `maxOffsetToStartSchedule()` blocks from the current block.
179
205
* - The end block is larger than the start block.
@@ -184,17 +210,17 @@ interface IMaintenance {
184
210
* Emits the event `MaintenanceScheduled`.
185
211
*
186
212
*/
187
- function schedule (address _consensusAddr , uint256 _startedAtBlock , uint256 _endedAtBlock ) external ;
213
+ function schedule (TConsensus consensusAddr , uint256 startedAtBlock , uint256 endedAtBlock ) external ;
188
214
189
215
/**
190
- * @dev Cancel the schedule of maintenance for the `_consensusAddr `.
216
+ * @dev Cancel the schedule of maintenance for the `consensusAddr `.
191
217
*
192
218
* Requirements:
193
- * - The candidate `_consensusAddr ` is the block producer.
194
- * - The method caller is candidate admin of the candidate `_consensusAddr `.
195
- * - A schedule for the `_consensusAddr ` must be existent and not executed yet.
219
+ * - The candidate `consensusAddr ` is the block producer.
220
+ * - The method caller is candidate admin of the candidate `consensusAddr `.
221
+ * - A schedule for the `consensusAddr ` must be existent and not executed yet.
196
222
*
197
223
* Emits the event `MaintenanceScheduleCancelled`.
198
224
*/
199
- function cancelSchedule (address _consensusAddr ) external ;
225
+ function cancelSchedule (TConsensus consensusAddr ) external ;
200
226
}
0 commit comments