Skip to content

Commit 9276b83

Browse files
authored
Merge pull request #156 from Dstack-TEE/fix-phala-cloud-integration
fix deploy scripts
2 parents 4ca0d4a + 57e5a17 commit 9276b83

File tree

15 files changed

+151
-108
lines changed

15 files changed

+151
-108
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ else
1515
# Please uncomment and set values for the following variables:
1616
1717
# The URL of the dstack-vmm RPC service
18-
# VMM_=unix:../../../build/vmm.sock
18+
# VMM_RPC=unix:../../../build/vmm.sock
1919
2020
# Cloudflare API token for DNS challenge
2121
# CF_API_TOKEN=your_cloudflare_api_token
@@ -72,7 +72,7 @@ required_env_vars=(
7272
"WG_ADDR"
7373
"GATEWAY_APP_ID"
7474
"MY_URL"
75-
"BOOTNODE_URL"
75+
# "BOOTNODE_URL"
7676
)
7777

7878
# Validate required environment variables
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ if [[ ! "$SUBNET_INDEX" =~ ^[0-9]+$ ]] || [ "$SUBNET_INDEX" -lt 0 ] || [ "$SUBNE
5353
exit 1
5454
fi
5555

56+
SYNC_ENABLED=$([ -z "$BOOTNODE_URL" ] && echo "false" || echo "true")
5657
# The IP address of this dstack-gateway node
5758
IP="10.4.0.$((SUBNET_INDEX + 1))/16"
5859
# Reserving 5 bits(32 IPs) for server use
@@ -63,6 +64,7 @@ CLIENT_RANGE="10.4.$((SUBNET_INDEX * 16)).0/20"
6364
echo "IP: $IP"
6465
echo "RESERVED_NET: $RESERVED_NET"
6566
echo "CLIENT_RANGE: $CLIENT_RANGE"
67+
echo "SYNC_ENABLED: $SYNC_ENABLED"
6668

6769
# Create gateway.toml configuration
6870
cat >$CONFIG_PATH <<EOF
@@ -86,7 +88,7 @@ rpc_domain = "gateway.$SRV_DOMAIN"
8688
run_in_dstack = true
8789
8890
[core.sync]
89-
enabled = true
91+
enabled = $SYNC_ENABLED
9092
interval = "30s"
9193
my_url = "$MY_URL"
9294
bootnode = "$BOOTNODE_URL"

kms/auth-eth/src/ethereum.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ export class EthereumBackend {
5454
gatewayAppId,
5555
}
5656
}
57+
58+
async getGatewayAppId(): Promise<string> {
59+
return await this.kmsAuth.gatewayAppId();
60+
}
5761
}

kms/auth-eth/src/server.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ export async function build(): Promise<FastifyInstance> {
4646
const provider = new ethers.JsonRpcProvider(rpcUrl);
4747
server.decorate('ethereum', new EthereumBackend(provider, kmsContractAddr));
4848

49+
server.get('/', async (request, reply) => {
50+
return {
51+
status: 'ok',
52+
kmsContractAddr: kmsContractAddr,
53+
gatewayAppId: await server.ethereum.getGatewayAppId(),
54+
};
55+
});
56+
4957
// Define routes
5058
server.post<{
5159
Body: BootInfo;
@@ -61,6 +69,7 @@ export async function build(): Promise<FastifyInstance> {
6169
try {
6270
return await server.ethereum.checkBoot(request.body, false);
6371
} catch (error) {
72+
console.error(error);
6473
reply.code(200).send({
6574
isAllowed: false,
6675
gatewayAppId: '',
@@ -83,6 +92,7 @@ export async function build(): Promise<FastifyInstance> {
8392
try {
8493
return await server.ethereum.checkBoot(request.body, true);
8594
} catch (error) {
95+
console.error(error);
8696
reply.code(200).send({
8797
isAllowed: false,
8898
gatewayAppId: '',

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

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export interface KmsAuthInterface extends Interface {
8686
| "appAllowedImages"
8787
| "appAllowedSystemMrs"
8888
| "apps"
89+
| "gatewayAppId"
8990
| "initialize"
9091
| "isAppAllowed"
9192
| "isKmsAllowed"
@@ -102,11 +103,10 @@ export interface KmsAuthInterface extends Interface {
102103
| "removeKmsAggregatedMr"
103104
| "removeKmsDevice"
104105
| "renounceOwnership"
106+
| "setGatewayAppId"
105107
| "setKmsEventlog"
106108
| "setKmsInfo"
107109
| "setKmsQuote"
108-
| "setTproxyAppId"
109-
| "tproxyAppId"
110110
| "transferOwnership"
111111
| "upgradeToAndCall"
112112
): FunctionFragment;
@@ -118,14 +118,14 @@ export interface KmsAuthInterface extends Interface {
118118
| "AppRegistered"
119119
| "AppSystemMrAdded"
120120
| "AppSystemMrRemoved"
121+
| "GatewayAppIdSet"
121122
| "Initialized"
122123
| "KmsAggregatedMrAdded"
123124
| "KmsAggregatedMrRemoved"
124125
| "KmsDeviceAdded"
125126
| "KmsDeviceRemoved"
126127
| "KmsInfoSet"
127128
| "OwnershipTransferred"
128-
| "TproxyAppIdSet"
129129
| "Upgraded"
130130
): EventFragment;
131131

@@ -158,6 +158,10 @@ export interface KmsAuthInterface extends Interface {
158158
values: [BytesLike]
159159
): string;
160160
encodeFunctionData(functionFragment: "apps", values: [AddressLike]): string;
161+
encodeFunctionData(
162+
functionFragment: "gatewayAppId",
163+
values?: undefined
164+
): string;
161165
encodeFunctionData(
162166
functionFragment: "initialize",
163167
values: [AddressLike]
@@ -213,6 +217,10 @@ export interface KmsAuthInterface extends Interface {
213217
functionFragment: "renounceOwnership",
214218
values?: undefined
215219
): string;
220+
encodeFunctionData(
221+
functionFragment: "setGatewayAppId",
222+
values: [string]
223+
): string;
216224
encodeFunctionData(
217225
functionFragment: "setKmsEventlog",
218226
values: [BytesLike]
@@ -225,14 +233,6 @@ export interface KmsAuthInterface extends Interface {
225233
functionFragment: "setKmsQuote",
226234
values: [BytesLike]
227235
): string;
228-
encodeFunctionData(
229-
functionFragment: "setTproxyAppId",
230-
values: [string]
231-
): string;
232-
encodeFunctionData(
233-
functionFragment: "tproxyAppId",
234-
values?: undefined
235-
): string;
236236
encodeFunctionData(
237237
functionFragment: "transferOwnership",
238238
values: [AddressLike]
@@ -271,6 +271,10 @@ export interface KmsAuthInterface extends Interface {
271271
data: BytesLike
272272
): Result;
273273
decodeFunctionResult(functionFragment: "apps", data: BytesLike): Result;
274+
decodeFunctionResult(
275+
functionFragment: "gatewayAppId",
276+
data: BytesLike
277+
): Result;
274278
decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result;
275279
decodeFunctionResult(
276280
functionFragment: "isAppAllowed",
@@ -324,20 +328,16 @@ export interface KmsAuthInterface extends Interface {
324328
data: BytesLike
325329
): Result;
326330
decodeFunctionResult(
327-
functionFragment: "setKmsEventlog",
328-
data: BytesLike
329-
): Result;
330-
decodeFunctionResult(functionFragment: "setKmsInfo", data: BytesLike): Result;
331-
decodeFunctionResult(
332-
functionFragment: "setKmsQuote",
331+
functionFragment: "setGatewayAppId",
333332
data: BytesLike
334333
): Result;
335334
decodeFunctionResult(
336-
functionFragment: "setTproxyAppId",
335+
functionFragment: "setKmsEventlog",
337336
data: BytesLike
338337
): Result;
338+
decodeFunctionResult(functionFragment: "setKmsInfo", data: BytesLike): Result;
339339
decodeFunctionResult(
340-
functionFragment: "tproxyAppId",
340+
functionFragment: "setKmsQuote",
341341
data: BytesLike
342342
): Result;
343343
decodeFunctionResult(
@@ -410,6 +410,18 @@ export namespace AppSystemMrRemovedEvent {
410410
export type LogDescription = TypedLogDescription<Event>;
411411
}
412412

413+
export namespace GatewayAppIdSetEvent {
414+
export type InputTuple = [gatewayAppId: string];
415+
export type OutputTuple = [gatewayAppId: string];
416+
export interface OutputObject {
417+
gatewayAppId: string;
418+
}
419+
export type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
420+
export type Filter = TypedDeferredTopicFilter<Event>;
421+
export type Log = TypedEventLog<Event>;
422+
export type LogDescription = TypedLogDescription<Event>;
423+
}
424+
413425
export namespace InitializedEvent {
414426
export type InputTuple = [version: BigNumberish];
415427
export type OutputTuple = [version: bigint];
@@ -495,18 +507,6 @@ export namespace OwnershipTransferredEvent {
495507
export type LogDescription = TypedLogDescription<Event>;
496508
}
497509

498-
export namespace TproxyAppIdSetEvent {
499-
export type InputTuple = [tproxyAppId: string];
500-
export type OutputTuple = [tproxyAppId: string];
501-
export interface OutputObject {
502-
tproxyAppId: string;
503-
}
504-
export type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
505-
export type Filter = TypedDeferredTopicFilter<Event>;
506-
export type Log = TypedEventLog<Event>;
507-
export type LogDescription = TypedLogDescription<Event>;
508-
}
509-
510510
export namespace UpgradedEvent {
511511
export type InputTuple = [implementation: AddressLike];
512512
export type OutputTuple = [implementation: string];
@@ -602,6 +602,8 @@ export interface KmsAuth extends BaseContract {
602602
"view"
603603
>;
604604

605+
gatewayAppId: TypedContractMethod<[], [string], "view">;
606+
605607
initialize: TypedContractMethod<
606608
[initialOwner: AddressLike],
607609
[void],
@@ -685,6 +687,8 @@ export interface KmsAuth extends BaseContract {
685687

686688
renounceOwnership: TypedContractMethod<[], [void], "nonpayable">;
687689

690+
setGatewayAppId: TypedContractMethod<[appId: string], [void], "nonpayable">;
691+
688692
setKmsEventlog: TypedContractMethod<
689693
[eventlog: BytesLike],
690694
[void],
@@ -699,10 +703,6 @@ export interface KmsAuth extends BaseContract {
699703

700704
setKmsQuote: TypedContractMethod<[quote: BytesLike], [void], "nonpayable">;
701705

702-
setTproxyAppId: TypedContractMethod<[appId: string], [void], "nonpayable">;
703-
704-
tproxyAppId: TypedContractMethod<[], [string], "view">;
705-
706706
transferOwnership: TypedContractMethod<
707707
[newOwner: AddressLike],
708708
[void],
@@ -747,6 +747,9 @@ export interface KmsAuth extends BaseContract {
747747
[[boolean, string] & { isRegistered: boolean; controller: string }],
748748
"view"
749749
>;
750+
getFunction(
751+
nameOrSignature: "gatewayAppId"
752+
): TypedContractMethod<[], [string], "view">;
750753
getFunction(
751754
nameOrSignature: "initialize"
752755
): TypedContractMethod<[initialOwner: AddressLike], [void], "nonpayable">;
@@ -814,6 +817,9 @@ export interface KmsAuth extends BaseContract {
814817
getFunction(
815818
nameOrSignature: "renounceOwnership"
816819
): TypedContractMethod<[], [void], "nonpayable">;
820+
getFunction(
821+
nameOrSignature: "setGatewayAppId"
822+
): TypedContractMethod<[appId: string], [void], "nonpayable">;
817823
getFunction(
818824
nameOrSignature: "setKmsEventlog"
819825
): TypedContractMethod<[eventlog: BytesLike], [void], "nonpayable">;
@@ -823,12 +829,6 @@ export interface KmsAuth extends BaseContract {
823829
getFunction(
824830
nameOrSignature: "setKmsQuote"
825831
): TypedContractMethod<[quote: BytesLike], [void], "nonpayable">;
826-
getFunction(
827-
nameOrSignature: "setTproxyAppId"
828-
): TypedContractMethod<[appId: string], [void], "nonpayable">;
829-
getFunction(
830-
nameOrSignature: "tproxyAppId"
831-
): TypedContractMethod<[], [string], "view">;
832832
getFunction(
833833
nameOrSignature: "transferOwnership"
834834
): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">;
@@ -875,6 +875,13 @@ export interface KmsAuth extends BaseContract {
875875
AppSystemMrRemovedEvent.OutputTuple,
876876
AppSystemMrRemovedEvent.OutputObject
877877
>;
878+
getEvent(
879+
key: "GatewayAppIdSet"
880+
): TypedContractEvent<
881+
GatewayAppIdSetEvent.InputTuple,
882+
GatewayAppIdSetEvent.OutputTuple,
883+
GatewayAppIdSetEvent.OutputObject
884+
>;
878885
getEvent(
879886
key: "Initialized"
880887
): TypedContractEvent<
@@ -924,13 +931,6 @@ export interface KmsAuth extends BaseContract {
924931
OwnershipTransferredEvent.OutputTuple,
925932
OwnershipTransferredEvent.OutputObject
926933
>;
927-
getEvent(
928-
key: "TproxyAppIdSet"
929-
): TypedContractEvent<
930-
TproxyAppIdSetEvent.InputTuple,
931-
TproxyAppIdSetEvent.OutputTuple,
932-
TproxyAppIdSetEvent.OutputObject
933-
>;
934934
getEvent(
935935
key: "Upgraded"
936936
): TypedContractEvent<
@@ -995,6 +995,17 @@ export interface KmsAuth extends BaseContract {
995995
AppSystemMrRemovedEvent.OutputObject
996996
>;
997997

998+
"GatewayAppIdSet(string)": TypedContractEvent<
999+
GatewayAppIdSetEvent.InputTuple,
1000+
GatewayAppIdSetEvent.OutputTuple,
1001+
GatewayAppIdSetEvent.OutputObject
1002+
>;
1003+
GatewayAppIdSet: TypedContractEvent<
1004+
GatewayAppIdSetEvent.InputTuple,
1005+
GatewayAppIdSetEvent.OutputTuple,
1006+
GatewayAppIdSetEvent.OutputObject
1007+
>;
1008+
9981009
"Initialized(uint64)": TypedContractEvent<
9991010
InitializedEvent.InputTuple,
10001011
InitializedEvent.OutputTuple,
@@ -1072,17 +1083,6 @@ export interface KmsAuth extends BaseContract {
10721083
OwnershipTransferredEvent.OutputObject
10731084
>;
10741085

1075-
"TproxyAppIdSet(string)": TypedContractEvent<
1076-
TproxyAppIdSetEvent.InputTuple,
1077-
TproxyAppIdSetEvent.OutputTuple,
1078-
TproxyAppIdSetEvent.OutputObject
1079-
>;
1080-
TproxyAppIdSet: TypedContractEvent<
1081-
TproxyAppIdSetEvent.InputTuple,
1082-
TproxyAppIdSetEvent.OutputTuple,
1083-
TproxyAppIdSetEvent.OutputObject
1084-
>;
1085-
10861086
"Upgraded(address)": TypedContractEvent<
10871087
UpgradedEvent.InputTuple,
10881088
UpgradedEvent.OutputTuple,

0 commit comments

Comments
 (0)