Skip to content

enclave: attest floor-rejected bid prices - #46

Open
josephmilla wants to merge 4 commits into
mainfrom
attest-floor-rejected-bid-prices
Open

josephmilla wants to merge 4 commits into
mainfrom
attest-floor-rejected-bid-prices

Conversation

@josephmilla

Copy link
Copy Markdown
Contributor

Context

  • Encrypted floor-rejected bids previously lost their trusted prices before downstream analytics could record them.
  • The signed attestation now carries only each rejected bid ID and adjusted price, while retaining legacy response IDs.
  • Duplicate bid IDs and payloads beyond four rejected bids or 1024 encoded bytes fail closed before attestation.
  • Deploy this producer change before enabling the matching consumer that reads floor_rejected_bids from attestation user data.

Testing

  • mise run test: covers adjusted encrypted prices, legacy IDs, duplicate rejection, and attestation limits.
  • mise run lint: reports no issues across the changed core, enclave, and API packages.
  • git diff --check origin/main...HEAD: no whitespace errors in the committed diff.
  • Enclave deployment: required before consumers can observe nonzero encrypted rejection prices.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the enclave attestation user data to include trusted, post-adjustment prices for bids rejected by floor enforcement, so downstream analytics can recover these values even when bids were encrypted.

Changes:

  • Add floor_rejected_bids to attestation user data (ID + adjusted price only).
  • Plumb adjusted floor-rejected bids from core auction results through enclave proof generation into the attestation, with pre-attestation hard limits (max 4 bids; max 1024 encoded bytes).
  • Fail early on duplicate bid IDs in enclave auction processing, and add/extend tests covering the new attestation behavior and limit enforcement.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
enclaveapi/types.go Introduces AttestedFloorRejectedBid and adds floor_rejected_bids to attestation user data.
enclaveapi/types_test.go Adds JSON marshaling tests ensuring floor_rejected_bids is omitted when empty and includes only ID/price fields.
enclave/proofs.go Threads floor-rejected bids into attestation, with size/count limits checked before calling NSM attestation.
enclave/proofs_test.go Adds tests verifying limit failures happen before calling Attest, and updates call sites for new signatures.
enclave/auction.go Rejects duplicate bid IDs up front; passes core floor-rejected bids into proof generation.
enclave/auction_test.go Adds tests for duplicate ID rejection and for attesting adjusted decrypted floor-rejected prices without leaking other bid fields.
core/types.go Extends AuctionResult to include full post-adjustment FloorRejectedBids alongside IDs.
core/floorenforcement.go Refactors floor enforcement to expose rejected bids internally via partitionBidsByFloor.
core/auction.go Uses floor partitioning to return both FloorRejectedBidIDs and FloorRejectedBids in the result.
core/auction_test.go Adds coverage ensuring floor-rejected bids reflect adjusted values and that inputs aren’t mutated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

nickpell added a commit that referenced this pull request Oct 13, 2026
…, fix doc comments, drop the TCP healthcheck (#103)

## Summary

- **Auction failure logging (`enclave/server.go`):** the server logged
`INFO: Auction processed successfully with TEE attestation data` after
every `ProcessAuction` call, including the two cases where
`ProcessAuction` returns `Success: false` without logging anything (a
negative `bid_floor`, an invalid deal list). The success line is now
logged only when the response succeeded; otherwise the server logs
`ERROR: Auction failed: <message>`. The response sent to the host is
unchanged.
- **`TestProcessAuction_BidFloorZero`:** the test claimed "all bids pass
(no floor enforcement)" but checked only the attested bid hash count,
which includes floor-rejected bids, so it could not fail if a zero floor
rejected a bid. It now also asserts `response.FloorRejected` is empty.
- **Doc comments (`core/types.go`):** `AuctionResult.RunnerUp` is nil
when fewer than two bidders have an eligible bid, because ranking keeps
only each bidder's highest bid (two eligible bids from one bidder still
give no runner-up); the comment said "less than 2 valid bids". The
`ExcludedBid` comment listed floor rejections, which are reported in
`FloorRejected` instead; it now lists the exclusion reasons the enclave
uses.
- **Enclave image (`enclave/Dockerfile`):** removes `EXPOSE 5000` and
the `HEALTHCHECK` that pinged `127.0.0.1:5000` with `nc`. The server
listens only on vsock, so the probe could never pass, and the image is
used only as `nitro-cli build-enclave` input, where Docker health checks
never run. `nmap-ncat` stays installed. The image config changes, so the
EIF PCRs may change (the server change alters the binary in any case);
`update-pcrs` records the new values after merge.

## Notes for reviewers

- The `ExcludedBid` comment dates from #4, which moved floor rejections
out of `ExcludedBid` into a separate list in the same change; the
comment kept the old wording.
- Open #44, #46 and #102 touch `enclave/auction_test.go`,
`core/types.go` and `enclave/Dockerfile` on other lines. A trial merge
of each with this branch produces no conflicts beyond those each already
has with `main`.

## Pre-merge checklist

- [x] Build passes (`go build ./...`, `go vet ./...`; Docker Build green
on this branch; a local build of the image shows `Healthcheck` and
`ExposedPorts` null with `nc` still present)
- [x] Lint passes (`golangci-lint run`: 0 issues)
- [x] Tests pass (`go test -count=1 ./...`; with a zero floor made to
reject a bid, the new `FloorRejected` assertion fails while the existing
bid hash count check still passes)
- [x] Diff contains no unintended changes

## Post-deploy/apply verification

- [ ] The next EIF build on `main` after merge is green
- [ ] `update-pcrs` commits the new PCR measurements for the merge
commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants