Skip to content

Commit 7bf5bfb

Browse files
committed
feat(DstackKms): restore backward-compatible 5-param deployAndRegisterApp
Keep the old 5-param deployAndRegisterApp(address,bool,bool,bytes32,bytes32) overload that defaults requireTcbUpToDate=false, so existing SDK callers (e.g. phala-cloud SDKs using viem) continue to work without changes. Fix ethers v6 ambiguous overload resolution by using explicit function signatures in kms:create-app task and upgrade tests.
1 parent 9664344 commit 7bf5bfb

File tree

8 files changed

+105
-14
lines changed

8 files changed

+105
-14
lines changed

kms/auth-eth/contracts/DstackKms.sol

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ contract DstackKms is
148148
bool allowAnyDevice,
149149
bytes32 initialDeviceId,
150150
bytes32 initialComposeHash
151-
) external returns (address appId) {
151+
) public returns (address appId) {
152152
require(appImplementation != address(0), "DstackApp implementation not set");
153153
require(initialOwner != address(0), "Invalid owner address");
154154

@@ -167,6 +167,24 @@ contract DstackKms is
167167
emit AppDeployedViaFactory(appId, msg.sender);
168168
}
169169

170+
// Backward compatible factory method for old SDK callers (pre TCB flag)
171+
function deployAndRegisterApp(
172+
address initialOwner,
173+
bool disableUpgrades,
174+
bool allowAnyDevice,
175+
bytes32 initialDeviceId,
176+
bytes32 initialComposeHash
177+
) external returns (address appId) {
178+
return deployAndRegisterApp(
179+
initialOwner,
180+
disableUpgrades,
181+
false,
182+
allowAnyDevice,
183+
initialDeviceId,
184+
initialComposeHash
185+
);
186+
}
187+
170188
// Function to register an aggregated MR measurement
171189
function addKmsAggregatedMr(bytes32 mrAggregated) external onlyOwner {
172190
kmsAllowedAggregatedMrs[mrAggregated] = true;

kms/auth-eth/hardhat.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ task("kms:create-app", "Create DstackApp via KMS factory method (single transact
353353
console.log("Initial compose hash:", composeHash === "0x0000000000000000000000000000000000000000000000000000000000000000" ? "none" : composeHash);
354354
console.log("Using factory method for single-transaction deployment...");
355355

356-
// Single transaction deployment via factory
357-
const tx = await kmsContract.deployAndRegisterApp(
356+
// Single transaction deployment via factory (explicit signature to disambiguate overloads)
357+
const tx = await kmsContract["deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)"](
358358
deployerAddress, // deployer owns the contract
359359
false, // disableUpgrades
360360
taskArgs.requireTcbUpToDate,

kms/auth-eth/test/DstackApp.upgrade.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe("DstackApp upgrade", function () {
176176
const composeHash = ethers.encodeBytes32String("factory-hash");
177177

178178
// Deploy app with requireTcbUpToDate = true via factory
179-
const tx = await kms.deployAndRegisterApp(
179+
const tx = await kms["deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)"](
180180
owner.address,
181181
false, // disableUpgrades
182182
true, // requireTcbUpToDate
@@ -255,7 +255,7 @@ describe("DstackApp upgrade", function () {
255255

256256
const composeHash = ethers.encodeBytes32String("no-tcb-hash");
257257

258-
const tx = await kms.deployAndRegisterApp(
258+
const tx = await kms["deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)"](
259259
owner.address,
260260
false, // disableUpgrades
261261
false, // requireTcbUpToDate = false

kms/auth-eth/typechain-types/contracts/DstackKms.ts

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export interface DstackKmsInterface extends Interface {
8484
| "addOsImageHash"
8585
| "allowedOsImages"
8686
| "appImplementation"
87-
| "deployAndRegisterApp"
87+
| "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)"
88+
| "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)"
8889
| "gatewayAppId"
8990
| "initialize"
9091
| "isAppAllowed"
@@ -153,7 +154,11 @@ export interface DstackKmsInterface extends Interface {
153154
values?: undefined
154155
): string;
155156
encodeFunctionData(
156-
functionFragment: "deployAndRegisterApp",
157+
functionFragment: "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)",
158+
values: [AddressLike, boolean, boolean, BytesLike, BytesLike]
159+
): string;
160+
encodeFunctionData(
161+
functionFragment: "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)",
157162
values: [AddressLike, boolean, boolean, boolean, BytesLike, BytesLike]
158163
): string;
159164
encodeFunctionData(
@@ -268,7 +273,11 @@ export interface DstackKmsInterface extends Interface {
268273
data: BytesLike
269274
): Result;
270275
decodeFunctionResult(
271-
functionFragment: "deployAndRegisterApp",
276+
functionFragment: "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)",
277+
data: BytesLike
278+
): Result;
279+
decodeFunctionResult(
280+
functionFragment: "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)",
272281
data: BytesLike
273282
): Result;
274283
decodeFunctionResult(
@@ -590,7 +599,19 @@ export interface DstackKms extends BaseContract {
590599

591600
appImplementation: TypedContractMethod<[], [string], "view">;
592601

593-
deployAndRegisterApp: TypedContractMethod<
602+
"deployAndRegisterApp(address,bool,bool,bytes32,bytes32)": TypedContractMethod<
603+
[
604+
initialOwner: AddressLike,
605+
disableUpgrades: boolean,
606+
allowAnyDevice: boolean,
607+
initialDeviceId: BytesLike,
608+
initialComposeHash: BytesLike
609+
],
610+
[string],
611+
"nonpayable"
612+
>;
613+
614+
"deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)": TypedContractMethod<
594615
[
595616
initialOwner: AddressLike,
596617
disableUpgrades: boolean,
@@ -739,7 +760,20 @@ export interface DstackKms extends BaseContract {
739760
nameOrSignature: "appImplementation"
740761
): TypedContractMethod<[], [string], "view">;
741762
getFunction(
742-
nameOrSignature: "deployAndRegisterApp"
763+
nameOrSignature: "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)"
764+
): TypedContractMethod<
765+
[
766+
initialOwner: AddressLike,
767+
disableUpgrades: boolean,
768+
allowAnyDevice: boolean,
769+
initialDeviceId: BytesLike,
770+
initialComposeHash: BytesLike
771+
],
772+
[string],
773+
"nonpayable"
774+
>;
775+
getFunction(
776+
nameOrSignature: "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)"
743777
): TypedContractMethod<
744778
[
745779
initialOwner: AddressLike,

kms/auth-eth/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy__factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const _abi = [
8989
] as const;
9090

9191
const _bytecode =
92-
"0x608060405260405161040938038061040983398101604081905261002291610267565b61002c8282610033565b5050610351565b61003c82610092565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561008657610081828261010e565b505050565b61008e610185565b5050565b806001600160a01b03163b6000036100cd57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161012b9190610335565b600060405180830381855af49150503d8060008114610166576040519150601f19603f3d011682016040523d82523d6000602084013e61016b565b606091505b50909250905061017c8583836101a6565b95945050505050565b34156101a45760405163b398979f60e01b815260040160405180910390fd5b565b6060826101bb576101b682610205565b6101fe565b81511580156101d257506001600160a01b0384163b155b156101fb57604051639996b31560e01b81526001600160a01b03851660048201526024016100c4565b50805b9392505050565b80511561021457805160208201fd5b60405163d6bda27560e01b815260040160405180910390fd5b634e487b7160e01b600052604160045260246000fd5b60005b8381101561025e578181015183820152602001610246565b50506000910152565b6000806040838503121561027a57600080fd5b82516001600160a01b038116811461029157600080fd5b60208401519092506001600160401b03808211156102ae57600080fd5b818501915085601f8301126102c257600080fd5b8151818111156102d4576102d461022d565b604051601f8201601f19908116603f011681019083821181831017156102fc576102fc61022d565b8160405282815288602084870101111561031557600080fd5b610326836020830160208801610243565b80955050505050509250929050565b60008251610347818460208701610243565b9190910192915050565b60aa8061035f6000396000f3fe6080604052600a600c565b005b60186014601a565b6051565b565b6000604c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b3660008037600080366000845af43d6000803e808015606f573d6000f35b3d6000fdfea264697066735822122060aeada43c964f1fbb27c2d9cbef9ca57ecc24f36b6aed0059d5371ade8a972f64736f6c63430008160033";
92+
"0x608060405260405161040a38038061040a83398101604081905261002291610268565b61002c8282610033565b5050610352565b61003c82610092565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561008657610081828261010e565b505050565b61008e610185565b5050565b806001600160a01b03163b6000036100cd57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161012b9190610336565b600060405180830381855af49150503d8060008114610166576040519150601f19603f3d011682016040523d82523d6000602084013e61016b565b606091505b50909250905061017c8583836101a6565b95945050505050565b34156101a45760405163b398979f60e01b815260040160405180910390fd5b565b6060826101bb576101b682610205565b6101fe565b81511580156101d257506001600160a01b0384163b155b156101fb57604051639996b31560e01b81526001600160a01b03851660048201526024016100c4565b50805b9392505050565b8051156102155780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b634e487b7160e01b600052604160045260246000fd5b60005b8381101561025f578181015183820152602001610247565b50506000910152565b6000806040838503121561027b57600080fd5b82516001600160a01b038116811461029257600080fd5b60208401519092506001600160401b03808211156102af57600080fd5b818501915085601f8301126102c357600080fd5b8151818111156102d5576102d561022e565b604051601f8201601f19908116603f011681019083821181831017156102fd576102fd61022e565b8160405282815288602084870101111561031657600080fd5b610327836020830160208801610244565b80955050505050509250929050565b60008251610348818460208701610244565b9190910192915050565b60aa806103606000396000f3fe6080604052600a600c565b005b60186014601a565b6051565b565b6000604c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b3660008037600080366000845af43d6000803e808015606f573d6000f35b3d6000fdfea26469706673582212201d1e675cd71e57bb3f08113f3040612bee9b14a06a3515aeb6fc806b55a6323764736f6c63430008160033";
9393

9494
type ERC1967ProxyConstructorParams =
9595
| [signer?: Signer]

kms/auth-eth/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils__factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const _abi = [
5656
] as const;
5757

5858
const _bytecode =
59-
"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209baa0f683dcc124e324ea3c0ab526cc62e34d6c5576b9108a0aa3731af9601ad64736f6c63430008160033";
59+
"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220e274eaccba5882a0af048d39959ca6e8cdf4933e54498c57fc57a9f23851c56b64736f6c63430008160033";
6060

6161
type ERC1967UtilsConstructorParams =
6262
| [signer?: Signer]

kms/auth-eth/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const _abi = [
2929
] as const;
3030

3131
const _bytecode =
32-
"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f0a467a10c04721c0fddc955e88d253117cad803d69d1e92bde08fd95759797764736f6c63430008160033";
32+
"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212205965a49a4005a86ed954ab6e57bfedc675ff3c6b372d5d68bd315532662a642c64736f6c63430008160033";
3333

3434
type AddressConstructorParams =
3535
| [signer?: Signer]

kms/auth-eth/typechain-types/factories/contracts/DstackKms__factory.ts

Lines changed: 40 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)