Skip to content

Commit 19192c6

Browse files
committed
wip
1 parent 1324177 commit 19192c6

File tree

4 files changed

+56
-10
lines changed

4 files changed

+56
-10
lines changed

kms/auth-eth/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ forge test --ffi --match-path "test/DstackKms.t.sol"
7373

7474
-**DstackApp.t.sol**: 11/11 tests PASS - Core app functionality
7575
-**DstackKms.t.sol**: 16/16 tests PASS - Core KMS functionality
76-
- ⚠️ **UpgradesWithPlugin.t.sol**: OpenZeppelin validation issues (comprehensive plugin-based upgrade testing)
76+
- **UpgradesWithPlugin.t.sol**: 7/9 tests PASS (2 failing due to OpenZeppelin validation on expected-revert tests)
7777

78-
**Total: 27/27 core functionality tests PASSING**
78+
**Total: 34/36 tests PASSING (27 core + 7 upgrade tests)**
7979

8080
## Important Notes
8181

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.22;
3+
4+
import "../DstackApp.sol";
5+
6+
/**
7+
* @custom:oz-upgrades-from contracts/DstackApp.sol:DstackApp
8+
*/
9+
contract DstackAppV2 is DstackApp {
10+
// Minimal V2 contract that can be upgraded from DstackApp
11+
// Inherits all functionality from DstackApp
12+
13+
/// @custom:oz-upgrades-unsafe-allow constructor
14+
constructor() {
15+
_disableInitializers();
16+
}
17+
18+
// Optional: Add a version identifier for testing
19+
function version() public pure returns (string memory) {
20+
return "2.0.0";
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.22;
3+
4+
import "../DstackKms.sol";
5+
6+
/**
7+
* @custom:oz-upgrades-from contracts/DstackKms.sol:DstackKms
8+
*/
9+
contract DstackKmsV2 is DstackKms {
10+
// Minimal V2 contract that can be upgraded from DstackKms
11+
// Inherits all functionality from DstackKms
12+
13+
/// @custom:oz-upgrades-unsafe-allow constructor
14+
constructor() {
15+
_disableInitializers();
16+
}
17+
18+
// Optional: Add a version identifier for testing
19+
function version() public pure returns (string memory) {
20+
return "2.0.0";
21+
}
22+
}

kms/auth-eth/test/UpgradesWithPlugin.t.sol

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import "openzeppelin-foundry-upgrades/Upgrades.sol";
66
import "../contracts/DstackKms.sol";
77
import "../contracts/DstackApp.sol";
88
import "../contracts/IAppAuth.sol";
9+
import "../contracts/test-utils/DstackKmsV2.sol";
10+
import "../contracts/test-utils/DstackAppV2.sol";
911

1012
contract UpgradesWithPluginTest is Test {
1113
address public owner;
@@ -73,7 +75,7 @@ contract UpgradesWithPluginTest is Test {
7375
kms.addKmsAggregatedMr(mrAggregated);
7476

7577
// Upgrade to new implementation using plugin
76-
Upgrades.upgradeProxy(kmsProxy, "DstackKms.sol", "");
78+
Upgrades.upgradeProxy(kmsProxy, "DstackKmsV2.sol", "");
7779

7880
// Verify state is preserved after upgrade
7981
assertEq(kms.owner(), owner);
@@ -102,7 +104,7 @@ contract UpgradesWithPluginTest is Test {
102104
app.setAllowAnyDevice(true);
103105

104106
// Upgrade to new implementation using plugin
105-
Upgrades.upgradeProxy(appProxy, "DstackApp.sol", "");
107+
Upgrades.upgradeProxy(appProxy, "DstackAppV2.sol", "");
106108

107109
// Verify state is preserved after upgrade
108110
assertEq(app.owner(), owner);
@@ -131,7 +133,7 @@ contract UpgradesWithPluginTest is Test {
131133
("upgraded-gateway-id")
132134
);
133135

134-
Upgrades.upgradeProxy(kmsProxy, "DstackKms.sol", initData);
136+
Upgrades.upgradeProxy(kmsProxy, "DstackKmsV2.sol", initData);
135137

136138
// Verify the initialization happened during upgrade
137139
assertEq(kms.gatewayAppId(), "upgraded-gateway-id");
@@ -156,7 +158,7 @@ contract UpgradesWithPluginTest is Test {
156158
// - Proxy upgrade safety
157159

158160
// This should work fine since DstackKms is upgrade-safe
159-
Upgrades.upgradeProxy(kmsProxy, "DstackKms.sol", "");
161+
Upgrades.upgradeProxy(kmsProxy, "DstackKmsV2.sol", "");
160162

161163
vm.stopPrank();
162164
}
@@ -177,7 +179,7 @@ contract UpgradesWithPluginTest is Test {
177179

178180
// Try to upgrade - should fail due to our custom _authorizeUpgrade logic
179181
vm.expectRevert("Upgrades are permanently disabled");
180-
Upgrades.upgradeProxy(appProxy, "DstackApp.sol", "");
182+
Upgrades.upgradeProxy(appProxy, "DstackAppV2.sol", "");
181183

182184
vm.stopPrank();
183185
}
@@ -197,7 +199,7 @@ contract UpgradesWithPluginTest is Test {
197199
// Try to upgrade as non-owner
198200
vm.startPrank(user);
199201
vm.expectRevert();
200-
Upgrades.upgradeProxy(kmsProxy, "DstackKms.sol", "");
202+
Upgrades.upgradeProxy(kmsProxy, "DstackKmsV2.sol", "");
201203
vm.stopPrank();
202204
}
203205

@@ -235,8 +237,8 @@ contract UpgradesWithPluginTest is Test {
235237
kms.setGatewayAppId("complex-test-gateway");
236238

237239
// Upgrade both contracts
238-
Upgrades.upgradeProxy(kmsProxy, "DstackKms.sol", "");
239-
Upgrades.upgradeProxy(appId, "DstackApp.sol", "");
240+
Upgrades.upgradeProxy(kmsProxy, "DstackKmsV2.sol", "");
241+
Upgrades.upgradeProxy(appId, "DstackAppV2.sol", "");
240242

241243
// Verify everything still works after upgrades
242244
assertTrue(kms.allowedOsImages(osImageHash));

0 commit comments

Comments
 (0)