test(test-utils): regenerate attestation fixtures with a retained signer key - #4104
Conversation
|
PR title type suggestion: This PR modifies source code files in addition to test files and fixtures, so the type prefix should probably be Suggested title: |
There was a problem hiding this comment.
Pull request overview
This PR refreshes the Dstack/TDX attestation fixtures and adjusts the sandbox testing/build plumbing so CI can exercise the full “Verified → store attestation” path end-to-end (including signing submit_participant_info with the fixture node key), while keeping production attestation verification strict by default.
Changes:
- Regenerates
test-utilsattestation assets (quote/collateral/tcb_info/app-compose, keys) and updatesVALID_ATTESTATION_TIMESTAMP. - Introduces an opt-in
allow-pre-launch-scriptattestation feature and wires it through to a dedicated sandbox WASM feature (sandbox-test-attestation) used only by fixture-verifying tests. - Updates localnet rust-launcher scripts/READMEs to support injecting an in-guest prelaunch hook for exporting the in-enclave signer key during fixture collection, and un-ignores the Verified-path sandbox tests accordingly.
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| localnet/tee/scripts/rust-launcher/single-node.sh | Adds PRELAUNCH_SCRIPT env var passthrough for fixture collection. |
| localnet/tee/scripts/rust-launcher/single-node-readme.md | Documents PRELAUNCH_SCRIPT usage for single-node localnet runs. |
| localnet/tee/scripts/rust-launcher/README.md | Adds detailed fixture-collection guidance and an example export hook. |
| deployment/cvm-deployment/deploy-launcher.sh | Threads an optional --prelaunch-script into app-compose generation. |
| crates/test-utils/src/attestation.rs | Updates fixture timestamp and switches fixture secret key loading to include_str!. |
| crates/test-utils/assets/tcb_info.json | Updates fixture TCB info (incl. app-compose and measurements). |
| crates/test-utils/assets/README.md | Documents that the fixture is test-only (contains pre-launch script + secret key). |
| crates/test-utils/assets/quote.json | Updates the serialized quote fixture. |
| crates/test-utils/assets/near_p2p_public_key.pub | Updates the fixture P2P public key. |
| crates/test-utils/assets/near_account_secret_key | Adds the fixture NEAR signer secret key for sandbox tests. |
| crates/test-utils/assets/near_account_public_key.pub | Updates the fixture NEAR signer public key. |
| crates/test-utils/assets/mpc_image_digest.txt | Updates the fixture MPC image digest. |
| crates/test-utils/assets/launcher_image_compose.yaml | Updates pinned launcher image + default image digest. |
| crates/test-utils/assets/create-assets.sh | Fixes collateral extraction to hex-encode DER/signature fields. |
| crates/test-utils/assets/collateral.json | Updates collateral fixture (now includes pck_certificate_chain). |
| crates/test-utils/assets/app_compose.json | Updates app-compose fixture (now includes pre_launch_script). |
| crates/tee-verifier/tests/verify_quote.rs | Updates expected report fields to match the regenerated fixture. |
| crates/mpc-attestation/Cargo.toml | Forwards attestation/allow-pre-launch-script as a feature. |
| crates/contract/tests/sandbox/utils/contract_build.rs | Adds a dedicated build artifact for sandbox-test-attestation. |
| crates/contract/tests/sandbox/tee_verifier.rs | Un-ignores Verified-path tests and uses the fixture-accepting sandbox WASM. |
| crates/contract/tests/sandbox/common.rs | Extends sandbox setup builder to select the attestation-relaxed sandbox WASM. |
| crates/contract/Cargo.toml | Adds sandbox-test-attestation feature (test-only attestation relaxation). |
| crates/attestation/src/attestation.rs | Refactors script-field validation and gates pre_launch_script by feature. |
| crates/attestation/Cargo.toml | Adds allow-pre-launch-script feature and wires it into test-utils. |
| crates/attestation/assets/tcb_info.json | Updates the attestation crate’s deserialization fixture in sync with test-utils. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Script executed inside the CVM before docker compose up, and the only way to | ||
| # run anything of your own in there. Needed when collecting test assets, to | ||
| # export the node's in-enclave signer key; the dev image has no sshd, and the | ||
| # guest agent serves only node info and container logs. See | ||
| # ../../../../localnet/tee/scripts/rust-launcher/README.md for a working script. | ||
| export PRELAUNCH_SCRIPT=/path/to/prelaunch.sh |
There was a problem hiding this comment.
Simplified to README.md in this directory. For the record the old path did resolve (four levels up from localnet/tee/scripts/rust-launcher/ is the repo root), it was just a needlessly long way to point at a sibling file.
| jq -r 'def tohex: | ||
| if type == "array" then | ||
| reduce .[] as $b (""; . + ("0123456789abcdef" | .[(($b / 16) | floor):(($b / 16) | floor) + 1]) | ||
| + ("0123456789abcdef" | .[($b % 16):($b % 16) + 1])) | ||
| else . end; | ||
| .tee_participant_info.Dstack.collateral | ||
| | .root_ca_crl |= tohex | ||
| | .pck_crl |= tohex | ||
| | .tcb_info_signature |= tohex | ||
| | .qe_identity_signature |= tohex' "$INPUT_FILE" > "$OUTPUT_DIR/collateral.json" |
There was a problem hiding this comment.
Good catch, and newly introduced — the previous fixture had no pck_certificate_chain at all. Extraction now strips the trailing NUL from all four PEM fields, and the borsh arg fixture is regenerated. Side effect worth knowing: with the NUL gone the blob's last byte is the PEM newline, which tripped editorconfig-checker, so .editorconfig no longer asserts that file's final byte either way.
Pull request overviewRegenerates the TDX attestation fixtures from a fresh localnet CVM, this time retaining the node's in-enclave NEAR signer key so sandbox tests can sign Changes:
Reviewed changesPer-file summary
I verified the feature plumbing does not reach production: FindingsBlocking (must fix before merge):
Non-blocking (nits, follow-ups, suggestions):
|
fdac57e to
213a577
Compare
|
Addressed the review, and rebased onto the updated #4085. Blocking items:
Nits taken: unconditional regeneration reminder (the committed key is normally present but stale, which the old existence check could never catch), the borsh/report-value refresh step added to the canonical runbook, vestigial Not taken, deliberately: splitting Also confirmed the fixture key's provenance rather than asserting it: Locally: |
213a577 to
79463d1
Compare
|
This PR includes source code changes and dependency updates beyond test files, so the type should probably be Suggested title: |
79463d1 to
64beae3
Compare
|
This PR is marked merged, but nothing from it landed on What happened: its base was The work continues in #4109 (fixtures, targeting |
Closes #3787