@inco/lightning 0.8.0-devnet-1 → 0.8.0-devnet-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -70,6 +70,8 @@ abstract contract TEELifecycle is
|
|
|
70
70
|
// Events
|
|
71
71
|
// @notice A new MR_AGGREGATED has been approved
|
|
72
72
|
event NewTEEVersionApproved(uint256 indexed version, bytes32 indexed mrAggregated);
|
|
73
|
+
// @notice A previously approved TEE version has been removed
|
|
74
|
+
event TEEVersionRemoved(bytes32 indexed mrAggregated);
|
|
73
75
|
event NewCovalidatorAdded(address covalidatorAddress, bytes quote);
|
|
74
76
|
event BootstrapStageComplete(address indexed newEoaSigner, BootstrapResult bootstrapResult);
|
|
75
77
|
// @notice Emitted to prove that an EOA has upgraded their TDX to a new
|
|
@@ -211,6 +213,28 @@ abstract contract TEELifecycle is
|
|
|
211
213
|
emit NewTEEVersionApproved($.approvedTeeVersions.length - 1, newMrAggregated);
|
|
212
214
|
}
|
|
213
215
|
|
|
216
|
+
/**
|
|
217
|
+
* @notice Removes a previously approved TEE version from the contract state
|
|
218
|
+
* @param mrAggregated - The MR_AGGREGATED bytes of the TEE version to remove
|
|
219
|
+
*/
|
|
220
|
+
function removeApprovedTeeVersion(bytes32 mrAggregated) public onlyOwner {
|
|
221
|
+
StorageForTeeLifecycle storage $ = getTeeLifecycleStorage();
|
|
222
|
+
bool found = false;
|
|
223
|
+
for (uint256 i = 0; i < $.approvedTeeVersions.length; i++) {
|
|
224
|
+
if ($.approvedTeeVersions[i] == mrAggregated) {
|
|
225
|
+
// Shift all elements after index i to the left to preserve insertion order
|
|
226
|
+
for (uint256 j = i; j < $.approvedTeeVersions.length - 1; j++) {
|
|
227
|
+
$.approvedTeeVersions[j] = $.approvedTeeVersions[j + 1];
|
|
228
|
+
}
|
|
229
|
+
$.approvedTeeVersions.pop();
|
|
230
|
+
found = true;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
require(found, TEEVersionNotFound());
|
|
235
|
+
emit TEEVersionRemoved(mrAggregated);
|
|
236
|
+
}
|
|
237
|
+
|
|
214
238
|
function _isApprovedTeeVersion(bytes32 newMrAggregated) internal view returns (bool) {
|
|
215
239
|
StorageForTeeLifecycle storage $ = getTeeLifecycleStorage();
|
|
216
240
|
for (uint256 i = 0; i < $.approvedTeeVersions.length; i++) {
|
|
@@ -124,6 +124,61 @@ contract TEELifecycleMockTest is MockRemoteAttestation, TEELifecycle {
|
|
|
124
124
|
vm.stopPrank();
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
function testRemoveApprovedTeeVersionPreservesOrder() public {
|
|
128
|
+
bytes32 mrAggregated1 = hex"1111111111111111111111111111111111111111111111111111111111111111";
|
|
129
|
+
bytes32 mrAggregated2 = hex"2222222222222222222222222222222222222222222222222222222222222222";
|
|
130
|
+
bytes32 mrAggregated3 = hex"3333333333333333333333333333333333333333333333333333333333333333";
|
|
131
|
+
|
|
132
|
+
vm.startPrank(this.owner());
|
|
133
|
+
|
|
134
|
+
// Add three versions
|
|
135
|
+
this.approveNewTeeVersion(mrAggregated1);
|
|
136
|
+
this.approveNewTeeVersion(mrAggregated2);
|
|
137
|
+
this.approveNewTeeVersion(mrAggregated3);
|
|
138
|
+
|
|
139
|
+
// Verify all exist in order
|
|
140
|
+
assertEq(this.approvedTeeVersions(0), mrAggregated1);
|
|
141
|
+
assertEq(this.approvedTeeVersions(1), mrAggregated2);
|
|
142
|
+
assertEq(this.approvedTeeVersions(2), mrAggregated3);
|
|
143
|
+
|
|
144
|
+
// Remove the middle one (mrAggregated2)
|
|
145
|
+
this.removeApprovedTeeVersion(mrAggregated2);
|
|
146
|
+
|
|
147
|
+
// Verify insertion order is preserved: mrAggregated1 stays at 0, mrAggregated3 shifts to 1
|
|
148
|
+
assertEq(this.approvedTeeVersions(0), mrAggregated1);
|
|
149
|
+
assertEq(this.approvedTeeVersions(1), mrAggregated3);
|
|
150
|
+
|
|
151
|
+
// Verify index 2 is now out of bounds
|
|
152
|
+
vm.expectRevert(TEELifecycle.IndexOutOfBounds.selector);
|
|
153
|
+
this.approvedTeeVersions(2);
|
|
154
|
+
|
|
155
|
+
vm.stopPrank();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function testRemoveApprovedTeeVersionNotFound() public {
|
|
159
|
+
bytes32 nonExistentMrAggregated = hex"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
160
|
+
|
|
161
|
+
vm.startPrank(this.owner());
|
|
162
|
+
vm.expectRevert(TEELifecycle.TEEVersionNotFound.selector);
|
|
163
|
+
this.removeApprovedTeeVersion(nonExistentMrAggregated);
|
|
164
|
+
vm.stopPrank();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function testRemoveApprovedTeeVersionOnlyOwner() public {
|
|
168
|
+
bytes32 mrAggregated = hex"1111111111111111111111111111111111111111111111111111111111111111";
|
|
169
|
+
|
|
170
|
+
vm.startPrank(this.owner());
|
|
171
|
+
this.approveNewTeeVersion(mrAggregated);
|
|
172
|
+
vm.stopPrank();
|
|
173
|
+
|
|
174
|
+
// Try to remove as non-owner
|
|
175
|
+
address nonOwner = address(0x1234);
|
|
176
|
+
vm.startPrank(nonOwner);
|
|
177
|
+
vm.expectRevert();
|
|
178
|
+
this.removeApprovedTeeVersion(mrAggregated);
|
|
179
|
+
vm.stopPrank();
|
|
180
|
+
}
|
|
181
|
+
|
|
127
182
|
// Helper function to create a successful bootstrap result
|
|
128
183
|
function successfulBootstrapResult()
|
|
129
184
|
internal
|