Skip to content

Commit c7a7516

Browse files
h4x3rotabclaude
andcommitted
docs: update KMS documentation for Foundry migration
- Update onchain-governance.md with Foundry script commands - Update CLAUDE.md build commands (Hardhat → Foundry) - Update kms-release.yml workflow to use Foundry toolchain - Fix Manage.s.sol to use PRIVATE_KEY for broadcast Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 135a380 commit c7a7516

File tree

5 files changed

+79
-69
lines changed

5 files changed

+79
-69
lines changed

.github/workflows/kms-release.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,22 @@ jobs:
6969
subject-digest: ${{ steps.build-and-push.outputs.digest }}
7070
push-to-registry: true
7171

72-
- name: Setup Node.js
73-
uses: actions/setup-node@v4
74-
with:
75-
node-version: '18'
76-
cache: 'npm'
77-
cache-dependency-path: kms/auth-eth/package-lock.json
72+
- name: Install Foundry
73+
uses: foundry-rs/foundry-toolchain@v1
7874

79-
- name: Install dependencies and compile contracts
75+
- name: Compile contracts with Foundry
8076
run: |
8177
cd kms/auth-eth
82-
npm ci
83-
npx hardhat compile
78+
forge install
79+
forge build
8480
8581
- name: GitHub Release
8682
uses: softprops/action-gh-release@v1
8783
with:
8884
name: "KMS Release v${{ env.VERSION }}"
8985
files: |
90-
kms/auth-eth/artifacts/contracts/DstackKms.sol/DstackKms.json
91-
kms/auth-eth/artifacts/contracts/DstackApp.sol/DstackApp.json
86+
kms/auth-eth/out/DstackKms.sol/DstackKms.json
87+
kms/auth-eth/out/DstackApp.sol/DstackApp.json
9288
body: |
9389
## Docker Image Information
9490

CLAUDE.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,20 @@ cargo clippy -- -D warnings --allow unused_variables
6363

6464
```bash
6565
cd kms/auth-eth
66-
npm install
67-
npm run build # Compile TypeScript
68-
npm test # Run tests
69-
npm run test:coverage # Run tests with coverage
70-
71-
# Hardhat commands
72-
npx hardhat compile
73-
npx hardhat test
74-
npx hardhat node # Start local node
66+
npm install # Install Node.js dependencies for bootAuth server
67+
forge install # Install Foundry dependencies (submodules)
68+
69+
# Build
70+
forge build # Compile smart contracts
71+
npm run build # Build TypeScript server
72+
73+
# Test
74+
forge test --ffi # Run Foundry contract tests
75+
npm test # Run TypeScript server tests
76+
npm run test:coverage # Run TypeScript tests with coverage
77+
78+
# Local development
79+
anvil # Start local Ethereum node
7580
```
7681

7782
### Python SDK
@@ -174,8 +179,8 @@ This rule is enforced in `.cursorrules`.
174179
- Via Web UI: `http://localhost:9080` (or configured port)
175180
- Via CLI: `./vmm-cli.py` (see `docs/vmm-cli-user-guide.md`)
176181
- Requires:
177-
1. On-chain app registration (`npx hardhat kms:create-app`)
178-
2. Adding compose hash to whitelist (`npx hardhat app:add-hash`)
182+
1. On-chain app registration (see `docs/onchain-governance.md`)
183+
2. Adding compose hash to whitelist
179184
3. Deploying via VMM with App ID
180185

181186
### Accessing Deployed Apps

docs/deployment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Continue? [y/N]
355355

356356
**Before pressing 'y'**, add the compose hash to your auth server whitelist:
357357
- For auth-simple: Add to `composeHashes` array in `auth-config.json`
358-
- For auth-eth: Use `app:add-hash` (see [On-Chain Governance](./onchain-governance.md#register-gateway-app))
358+
- For auth-eth: Use Foundry scripts (see [On-Chain Governance](./onchain-governance.md#register-gateway-app))
359359

360360
Then return to the first terminal and press 'y' to deploy.
361361

docs/onchain-governance.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,38 @@ On-chain governance adds:
1313

1414
- Production dstack deployment with KMS and Gateway as CVMs (see [Deployment Guide](./deployment.md))
1515
- Ethereum wallet with funds on Sepolia testnet (or your target network)
16-
- Node.js and npm installed
17-
- Alchemy API key (for Sepolia) - get one at https://www.alchemy.com/
16+
- [Foundry](https://book.getfoundry.sh/getting-started/installation) installed
17+
- Node.js and npm installed (for the bootAuth server)
1818

1919
## Deploy DstackKms Contract
2020

2121
```bash
2222
cd dstack/kms/auth-eth
23-
npm install
24-
npx hardhat compile
25-
PRIVATE_KEY=<your-key> ALCHEMY_API_KEY=<your-key> npx hardhat kms:deploy --with-app-impl --network sepolia
23+
npm install # Install Node.js dependencies
24+
forge install # Install Foundry dependencies
25+
26+
# Deploy contracts (deploys both DstackApp implementation and DstackKms proxy)
27+
PRIVATE_KEY=<your-key> forge script script/Deploy.s.sol:DeployScript \
28+
--broadcast --rpc-url https://eth-sepolia.g.alchemy.com/v2/<your-alchemy-key>
2629
```
2730

28-
The command will prompt for confirmation. Sample output:
31+
Sample output:
2932

3033
```
31-
✅ DstackApp implementation deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
32-
DstackKms Proxy deployed to: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
33-
Implementation deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
34+
Deploying with account: 0x...
35+
DstackApp implementation deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
36+
DstackKms implementation deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
37+
DstackKms proxy deployed to: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
3438
```
3539

3640
Note the proxy address (e.g., `0x9fE4...`).
3741

3842
Set environment variables for subsequent commands:
3943

4044
```bash
41-
export KMS_CONTRACT_ADDRESS="<DstackKms-proxy-address>"
45+
export KMS_CONTRACT_ADDR="<DstackKms-proxy-address>"
4246
export PRIVATE_KEY="<your-private-key>"
43-
export ALCHEMY_API_KEY="<your-alchemy-key>"
47+
export RPC_URL="https://eth-sepolia.g.alchemy.com/v2/<your-alchemy-key>"
4448
```
4549

4650
## Configure KMS for On-Chain Auth
@@ -52,42 +56,45 @@ KMS_CONTRACT_ADDR=<your-dstack-kms-contract-address>
5256
ETH_RPC_URL=<ethereum-rpc-endpoint>
5357
```
5458

55-
Note: The auth-api uses `KMS_CONTRACT_ADDR`, while Hardhat tasks use `KMS_CONTRACT_ADDRESS`.
56-
5759
The auth-api validates boot requests against the smart contract. See [Deployment Guide](./deployment.md#2-deploy-kms-as-cvm) for complete setup instructions.
5860

5961
## Whitelist OS Image
6062

6163
```bash
62-
npx hardhat kms:add-image --network sepolia 0x<os-image-hash>
64+
OS_IMAGE_HASH=0x<os-image-hash> \
65+
forge script script/Manage.s.sol:AddOsImage --broadcast --rpc-url $RPC_URL
6366
```
6467

65-
Output: `Image added successfully`
68+
Output: `Added OS image hash: 0x...`
6669

6770
The `os_image_hash` is in the `digest.txt` file from the guest OS image build (see [Building Guest Images](./deployment.md#building-guest-images)).
6871

6972
## Register Gateway App
7073

7174
```bash
72-
npx hardhat kms:create-app --network sepolia --allow-any-device
75+
# Create a new app with allowAnyDevice=true
76+
ALLOW_ANY_DEVICE=true \
77+
forge script script/Manage.s.sol:DeployApp --broadcast --rpc-url $RPC_URL
7378
```
7479

7580
Sample output:
7681

7782
```
78-
✅ App deployed and registered successfully!
79-
Proxy Address (App Id): 0x75537828f2ce51be7289709686A69CbFDbB714F1
83+
Deployed new app at: 0x75537828f2ce51be7289709686A69CbFDbB714F1
84+
Owner: 0x...
85+
Allow any device: true
8086
```
8187

82-
Note the App ID (Proxy Address) from the output.
88+
Note the App ID (deployed app address) from the output.
8389

8490
Set it as the gateway app:
8591

8692
```bash
87-
npx hardhat kms:set-gateway --network sepolia <app-id>
93+
GATEWAY_APP_ID=<app-id> \
94+
forge script script/Manage.s.sol:SetGatewayAppId --broadcast --rpc-url $RPC_URL
8895
```
8996

90-
Output: `Gateway App ID set successfully`
97+
Output: `Set gateway app ID: <app-id>`
9198

9299
Add the gateway's compose hash to the whitelist. To compute the compose hash:
93100

@@ -98,10 +105,11 @@ sha256sum /path/to/gateway-compose.json | awk '{print "0x"$1}'
98105
Then add it:
99106

100107
```bash
101-
npx hardhat app:add-hash --network sepolia --app-id <app-id> <compose-hash>
108+
APP_CONTRACT_ADDR=<app-id> COMPOSE_HASH=<compose-hash> \
109+
forge script script/Manage.s.sol:AddComposeHash --broadcast --rpc-url $RPC_URL
102110
```
103111

104-
Output: `Compose hash added successfully`
112+
Output: `Added compose hash: 0x...`
105113

106114
## Register Apps On-Chain
107115

@@ -110,7 +118,8 @@ For each app you want to deploy:
110118
### Create App
111119

112120
```bash
113-
npx hardhat kms:create-app --network sepolia --allow-any-device
121+
ALLOW_ANY_DEVICE=true \
122+
forge script script/Manage.s.sol:DeployApp --broadcast --rpc-url $RPC_URL
114123
```
115124

116125
Note the App ID from the output.
@@ -126,7 +135,8 @@ sha256sum /path/to/your-app-compose.json | awk '{print "0x"$1}'
126135
Then add it:
127136

128137
```bash
129-
npx hardhat app:add-hash --network sepolia --app-id <app-id> <compose-hash>
138+
APP_CONTRACT_ADDR=<app-id> COMPOSE_HASH=<compose-hash> \
139+
forge script script/Manage.s.sol:AddComposeHash --broadcast --rpc-url $RPC_URL
130140
```
131141

132142
### Deploy via VMM

0 commit comments

Comments
 (0)