Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ env:
REGISTRY: ghcr.io
IMAGE_NAME: tinycloudlabs/tinycloud-node
# Production dstack OS the tinycloud-node CVM must run (the Phala KMS only releases app keys to this image).
PHALA_OS_IMAGE: dstack-0.5.12
PHALA_OS_IMAGE_HASH: 8db40cb23008d6213668b5816702d100b37b859a8a5bfd18d938ae3a1b3715bd
# TC-3554: Phala's KMS move put its CVMs on dstack 0.5.15 (prod and dev classes); 0.5.12 would be a downgrade.
# Hash from Phala /os-images (name dstack-0.5.15). The node CVM itself runs dstack-dev-0.5.15 (allowlist).
PHALA_OS_IMAGE: dstack-0.5.15
PHALA_OS_IMAGE_HASH: 4597735f1a38ad8ec9f781356b88737fc052062deb7c9aaa4be89bf1b35643ca

jobs:
rollback-audit:
Expand Down Expand Up @@ -595,7 +597,7 @@ jobs:

# Fail closed before any production change unless the CVM runs the pinned production OS, or the one pinned dev OS
# in scripts/ci/phala-dev-os-allowlist.txt after a fresh integrity check (scripts/ci/phala-os-guard.sh).
# To fix it, set the OS by hand: `phala api -X PATCH /cvms/<id>/os-image -F os_image_name=dstack-0.5.12`.
# To fix it, set the OS by hand: `phala api -X PATCH /cvms/<id>/os-image -F os_image_name=dstack-0.5.15`.
- name: Require a permitted OS image on the CVM
env:
PHALA_CLOUD_API_KEY: ${{ secrets.PHALA_CLOUD_API_KEY }}
Expand Down Expand Up @@ -765,10 +767,11 @@ jobs:
# cap (raw d95bfb70…), the TC-1274 + TC-1317 + TC-1482 + c_index + TC-1840 + TC-1843 Vector config and the
# optional TC-1482 NODE_STATS_READ_TOKEN env line, the TC-950 pool of 10 and the TC-1777 named-keys gate
# env lines + deletion-ledger volume, the TC-2346 operation-retry warning codes, the TC-2917
# storage-headroom event in the Vector config and the TC-1491 artifact read limit env line
# (raw d6af7a70…; 5419a6fb… before TC-1491, d703d69b… before TC-2917, 298ea356… before TC-2346,
# storage-headroom event in the Vector config, the TC-1491 artifact read limit env line and the TC-3554
# key-recovery sidecar + DstackKmsEpoch epoch-0 pins (raw 8e602959…; 417719648a0c… / d6af7a70… before
# TC-3554, 5419a6fb… before TC-1491, d703d69b… before TC-2917, 298ea356… before TC-2346,
# 192dfb7e… before TC-1777), its single node digest normalized to 64 zeros.
n0_template_hash = '417719648a0c0daac6f0de186bdcda2c992a3fc8504fbf509c9b26a1dec9c5da'
n0_template_hash = '70c71aa0acb7ebe157a1c1fac3e30fb3536b7cc21ba51d4013f905599c22ea4f'
node_pin = re.compile(rb'(?m)^ image: ghcr\.io/tinycloudlabs/tinycloud-node@sha256:([0-9a-f]{64})$')
def n0_template(raw):
pins = list(node_pin.finditer(raw))
Expand Down Expand Up @@ -1205,8 +1208,10 @@ jobs:
# The CLI/SDK can include request details in errors. Never forward
# those responses into Actions logs, even when deployment fails.
# A failing CLI/update can still have restarted the CVM.
# No --image/--no-dev-os: the CVM keeps its OS class (TC-3554: it runs
# dstack-dev-0.5.15); the guards before and after check the OS.
echo "cvm_mutation_attempted=true" >> "$GITHUB_OUTPUT"
if ! phala deploy --cvm-id tinycloud-node -c docker-compose.dstack-postgres.yaml -e .phala-prod.env --no-public-logs --no-public-sysinfo --no-dev-os --image "${PHALA_OS_IMAGE}" --wait >/dev/null 2>&1; then
if ! phala deploy --cvm-id tinycloud-node -c docker-compose.dstack-postgres.yaml -e .phala-prod.env --no-public-logs --no-public-sysinfo --wait >/dev/null 2>&1; then
echo "::error::Phala deployment failed; inspect the private control plane"
exit 1
fi
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@
Values are sealed like the webhook secret (v2, bound to the subscription row and column) and are never returned or logged; create and list return `headerNames` only. Change headers by deleting and re-registering. One migration, `m20261117_000000_hook_subscription_headers`, adds `header_names_json`, `encrypted_headers` and `encrypted_headers_format` (`NOT NULL DEFAULT 0`) to `hook_subscription`. Existing subscriptions have no headers and deliver unchanged. Details: TC-3123.
- SQL write events (SSE and webhook bodies) carry `rowId`, the SQLite rowid of the row a statement inserted, when that statement is a single-table INSERT that inserted exactly one row. A woken agent can then read the row (for example the Home feed's `feed_responses.sequence`) without scanning. Updates, deletes, multi-row inserts, upserts that updated, ignored inserts, `WITHOUT ROWID` tables and DuckDB writes omit it. The body stays ids-only. Details: TC-3123.

## [1.26.14] - 2026-11-20

Restores the node after Phala moved its CVM to KMS `dstack-pha-prod2` (TC-3554). The node keeps its root and identity (`did:key:z6MkjHi79SMX4doJyo2w7jDTM6Fa7iX6EVZWXNbJ6RzBm3Wi`); no data is re-encrypted.

### Upgrade notes

- **No database migration.**
- **Before the first boot, with the node stopped,** `renewal_identity` must read the original renewer `did:key:z6MkgWpiYdQV8pAr3dtHLdQsoZR3wF5wsS7fpkzAuX6q1PZj` at the epoch its live renewal leases carry. A boot on the moved root that reached startup would have replaced the DID and bumped the epoch, orphaning every existing lease; if one did, the reviewed, pinned reset puts the row back. (On 2026-11-20 the row still held the original DID, so the 04:42Z boots had not written it.)
- The CVM runs `dstack-dev-0.5.15`; the deploy guard now allows it and the deploy no longer asks Phala for an OS image.
- **No rollback below 1.26.14 on this compose.** An older binary does not know `TINYCLOUD_KEYS__TYPE: DstackKmsEpoch` and refuses to start; without the epoch-0 fetch it could only derive keys from the moved root, which is a different identity.

### Changes

- Keys: `DstackKmsEpoch` fetches a historical KMS root epoch inside the TEE, through Phala's `dstack-key-recovery` sidecar on a unix socket, and verifies it before the database connects: the KMS signature chain under a pinned root public key, the root and app epochs, and the expected node DID. Any mismatch stops the boot; there is no fallback to the current root. A `DstackKmsEpoch` identity refuses `backup`. Spec: `docs/tc-3554-kms-epoch-fetch.md`. Details: TC-3554.
- Production compose: the `key-recovery` sidecar (digest-pinned, no ports, socket shared only with the node, logging off) and the epoch-0 pins as literals. Details: TC-3554.
- Deploys: production OS pin `dstack-0.5.15`, `dstack-dev-0.5.15` on the dev allowlist, and the reviewed N0 compose hash updated for the new compose. Details: TC-3554.

## [1.26.13] - 2026-11-20

Ships the changes merged since 1.26.12 (#653, #442, #557, #646, #655, #650, #652, #665, #664, #624, #610, #599 and the production compose change for SQL databases up to 320 MiB), detailed under [Unreleased] above.
Expand Down
6 changes: 5 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 49 additions & 1 deletion docker-compose.dstack-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,27 @@ services:
mode: non-blocking
max-buffer-size: 4m
cache-disabled: "true"
depends_on:
- key-recovery
ports:
- "8000:8000"
volumes:
- /var/run/dstack.sock:/var/run/dstack.sock
- deletion-ledger:/var/lib/tinycloud/ledger
- key-recovery:/run/key-recovery
environment:
TINYCLOUD_KEYS_TYPE: Dstack
# TC-3554: the node keeps its pre-move root and identity. Phala's move to
# KMS prod2 left that root at root epoch 0, so the node fetches it through
# the key-recovery sidecar below and verifies it against these pins before
# the database connects (docs/tc-3554-kms-epoch-fetch.md). Every pin is a
# literal so the compose hash attests it.
TINYCLOUD_KEYS__TYPE: DstackKmsEpoch
TINYCLOUD_KEYS__LEGACY__KEY_RECOVERY_SOCKET: /run/key-recovery/kr.sock
TINYCLOUD_KEYS__LEGACY__ROOT_EPOCH: "0"
TINYCLOUD_KEYS__LEGACY__KMS_ROOT_PUBKEY: 0334c76e0c3f52ec64cbf9bbf5c910c272330166fd656c0a86bb330963e46910e1
TINYCLOUD_KEYS__LEGACY__APP_ID: 350d124c81d53a57e8899e9f85a904918e663b61
TINYCLOUD_KEYS__LEGACY__EXPECTED_DID: did:key:z6MkjHi79SMX4doJyo2w7jDTM6Fa7iX6EVZWXNbJ6RzBm3Wi
TINYCLOUD_KEYS__EXPECTED_NODE_DID: did:key:z6MkjHi79SMX4doJyo2w7jDTM6Fa7iX6EVZWXNbJ6RzBm3Wi
TINYCLOUD_STORAGE_DATABASE: "${DATABASE_URL}"
TINYCLOUD_STORAGE_BLOCKS_TYPE: S3
TINYCLOUD_STORAGE_BLOCKS_BUCKET: "${S3_BUCKET}"
Expand Down Expand Up @@ -106,6 +120,39 @@ services:
ROCKET_ADDRESS: "0.0.0.0"
ROCKET_MAX_BLOCKING: "1024"

# TC-3554: Phala's dstack-key-recovery (0.6.5, cosign-verified digest) fetches
# the epoch-0 key from the KMS and serves it on a unix socket. No ports and no
# TCP listener; the socket lives on a volume only this service and tinycloud
# mount. Runs as uid 0 (TDX device, host-shared files) with primary gid 1000,
# so its 0660 socket is group-owned by the node's tinycloud group. From
# host-shared it sees only .appkeys.json and .sys-config.json (launch ticket,
# vm_config), never the decrypted env. Its `key` answers are not logged
# anywhere (serve mode prints only the listen line; logging off). Removed once
# the node keeps its root sealed under the current root.
key-recovery:
image: ghcr.io/dstack-tee/dstack-key-recovery@sha256:26803eb7eb34f69f367d7ebc0b4abc31f35caad5e58213de77a91dddcd2d0b6b
restart: unless-stopped
user: "0:1000"
command: ["serve", "--no-addr", "--socket", "/run/key-recovery/kr.sock"]
# The quote goes through the host's vsock QGS; Docker's default seccomp
# profile blocks AF_VSOCK.
security_opt:
- seccomp=unconfined
environment:
DSTACK_CCEL_FILE: /ccel.bin
volumes:
- key-recovery:/run/key-recovery
- /dstack/.host-shared/.appkeys.json:/dstack/.host-shared/.appkeys.json:ro
- /dstack/.host-shared/.sys-config.json:/dstack/.host-shared/.sys-config.json:ro
- /run/log/dstack:/run/log/dstack:ro
- /sys/firmware/acpi/tables/data/CCEL:/ccel.bin:ro
- /etc/tdx-attest.conf:/etc/tdx-attest.conf:ro
devices:
- /dev/tdx_guest:/dev/tdx_guest
- /dev/vsock:/dev/vsock
logging:
driver: none

dstack-ingress:
image: ghcr.io/tinycloudlabs/tinycloud-node-ingress@sha256:63c1c44e2ded5b73a5f174807b91ca677826974df0f9ab3045f6ec87865a5744
ports:
Expand Down Expand Up @@ -193,6 +240,7 @@ services:
volumes:
cert-data:
deletion-ledger:
key-recovery:

networks:
logship:
Expand Down
25 changes: 15 additions & 10 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ The `deploy-phala` job in `docker.yml` refuses to deploy, and fails after a
deploy, unless the `tinycloud-node` CVM reports one of:

- the production image: `.os.is_dev == false` with the name and hash pinned in
`PHALA_OS_IMAGE` / `PHALA_OS_IMAGE_HASH` (`dstack-0.5.12`); or
`PHALA_OS_IMAGE` / `PHALA_OS_IMAGE_HASH` (`dstack-0.5.15`); or
- a dev image whose `.os.os_image_hash` is listed in
`scripts/ci/phala-dev-os-allowlist.txt` (today only `dstack-dev-0.5.12`), and
`scripts/ci/phala-dev-os-allowlist.txt` (`dstack-dev-0.5.12`, and
`dstack-dev-0.5.15`, which the node CVM runs since the TC-3554 KMS move), and
that passes a fresh check in the same job: `download.dstack.org` serves
`mr_<hash>.tar.gz`, and `sha256sum sha256sum.txt` of the extracted archive
equals `<hash>`, and every file it lists matches (`sha256sum -c`).
Expand All @@ -77,11 +78,11 @@ CI never changes the OS. If the check fails, set it by hand, then re-run:

```sh
phala cvms get tinycloud-node --json | jq .os
phala api -X PATCH /cvms/<id>/os-image -F os_image_name=dstack-0.5.12
phala api -X PATCH /cvms/<id>/os-image -F os_image_name=dstack-0.5.15
```

`phala deploy --image/--no-dev-os` is ignored for an existing CVM; the PATCH is
what changes the OS.
The deploy does not pass `--image`/`--no-dev-os` (they are ignored for an
existing CVM anyway); the PATCH is what changes the OS.

## Operator steps before a node deploy

Expand Down Expand Up @@ -662,8 +663,9 @@ Before any CVM mutation the workflow requires:

- the main compose, with its one node digest replaced by 64 zeros, to hash
to the reviewed N0 template
**`417719648a0c0daac6f0de186bdcda2c992a3fc8504fbf509c9b26a1dec9c5da`**
(raw `d6af7a704ba532a2f9fce5166f4c7f05125e31f33e5cabf885b35efac61aa8b9` normalized). Before the TC-1491 `TINYCLOUD_STORAGE__SQL__MAX_ARTIFACT_READ_BYTES` env line the template was `90841a34e6ea5b581374f50abe70e580496e6814bc83f61f20fd4c9e090e5d51`
**`70c71aa0acb7ebe157a1c1fac3e30fb3536b7cc21ba51d4013f905599c22ea4f`**
(raw `8e6029591516134f3706a170fe402e81f816216475eeac01072aa6facbc415a9` normalized). Before the TC-3554 key-recovery sidecar and `DstackKmsEpoch` epoch-0 pins the template was `417719648a0c0daac6f0de186bdcda2c992a3fc8504fbf509c9b26a1dec9c5da`
(raw `d6af7a704ba532a2f9fce5166f4c7f05125e31f33e5cabf885b35efac61aa8b9` normalized); before the TC-1491 `TINYCLOUD_STORAGE__SQL__MAX_ARTIFACT_READ_BYTES` env line the template was `90841a34e6ea5b581374f50abe70e580496e6814bc83f61f20fd4c9e090e5d51`
(raw `5419a6fbb73efe8b4430e4ab76d5e2970b2c9204525854e23f59dbdc01f4e250` normalized; before the TC-2917 `node_storage_headroom` event (the node's disk headroom line shipped as an individual event) in the Vector config the template was `9d0cd8a2…`, raw `d703d69b…`; before the TC-2346 `db_operation_retried` and `db_operation_retry_skipped_slow` warning codes in the Vector config the template was `c9bcbea9…`, raw `298ea356…`; before the TC-1777 named-keys gate env lines (`TINYCLOUD_ENCRYPTION_NETWORK__NAMED_KEYS_V1`, `…__DELETION_LEDGER_PATH`) and the `deletion-ledger` volume the template was `8df7e0f2…`, raw `192dfb7e407fa591d4f0232b95e43a41a85dd18add1d4976e70ebdbff5ddebca`; before the TC-1843 per-minute caps on 4xx and 5xx request events and on the 5xx diagnostic, and the `errors_dropped` event (the dropped count), in the Vector config the template was `7c3456dc…`, raw `d0e72bde…`; before the TC-1840 `db_failure_5xx` event (the node's 5xx diagnostic line shipped as an individual event) in the Vector config the template was `c91e5b7a…`, raw `99013c40…`; before the TC-950 pool of 10 (`TINYCLOUD_DATABASE__MAX_CONNECTIONS` 15 to 10) the template was `79469f97…`, raw `32a002ef…`; before the three `current_kv_c_index_*` warning codes in the Vector config (TC-1274 `current_kv` C-index migration) the template was `87b5d12a…`, raw `d1fcd665…`; before the optional TC-1482 `NODE_STATS_READ_TOKEN` env line and the TC-1482 route in the Vector config the template was `7fabba70…`, raw `1228d81927fc0a3fbba85745103e77b3112606f5d314d15974d400b222409350`: the 1.21.0 compose
`d95bfb707871c1d626c4a8f2b8d32d354103edbb5077847c6a21fe5f7f6cfa50`, template
`51f8e9e9…`, with only the embedded Vector config regenerated for TC-1274's,
Expand Down Expand Up @@ -812,9 +814,12 @@ gh workflow run docker.yml -R TinyCloudLabs/tinycloud-node --ref main \

The served/OCI identity remains **1.20.6-dstack / e18578ff9162986ddd813259c60f73866e3e60d1**.
With the template lock on main this redeploys exactly main's raw compose
`d6af7a704ba532a2f9fce5166f4c7f05125e31f33e5cabf885b35efac61aa8b9`
(the 1.21.0 compose `d95bfb70…` with the TC-1274, TC-1317, TC-1482, `current_kv_c_index_*`, `db_failure_5xx`, the 4xx and 5xx caps, `errors_dropped`, TC-2346 `db_operation_retried` / `db_operation_retry_skipped_slow` and TC-2917 `node_storage_headroom` Vector config, the optional TC-1482 `NODE_STATS_READ_TOKEN` env line, the TC-950 pool of 10, the TC-1777 `NAMED_KEYS_V1` gate env lines with the `deletion-ledger` volume, and the TC-1491 artifact read limit env line), whatever digest
main's template currently pins. It is not a rollback of a
`8e6029591516134f3706a170fe402e81f816216475eeac01072aa6facbc415a9`
(the 1.21.0 compose `d95bfb70…` with the TC-1274, TC-1317, TC-1482, `current_kv_c_index_*`, `db_failure_5xx`, the 4xx and 5xx caps, `errors_dropped`, TC-2346 `db_operation_retried` / `db_operation_retry_skipped_slow` and TC-2917 `node_storage_headroom` Vector config, the optional TC-1482 `NODE_STATS_READ_TOKEN` env line, the TC-950 pool of 10, the TC-1777 `NAMED_KEYS_V1` gate env lines with the `deletion-ledger` volume, the TC-1491 artifact read limit env line, and the TC-3554 key-recovery sidecar with `TINYCLOUD_KEYS__TYPE: DstackKmsEpoch`), whatever digest
main's template currently pins. **Since TC-3554 only an image of 1.26.14 or
later boots on this compose:** an older binary does not know
`DstackKmsEpoch` and refuses to start, so this command and any rollback below
1.26.14 fail closed rather than serve under the moved KMS root. It is not a rollback of a
later release across a schema migration. Current pre-N0 tag/pinned
equivalents are separately hash-checked; arbitrary same-image config
substitutions fail before mutation.
Expand Down
Loading
Loading