Skip to content

Add Want-Repr-Digest / Repr-Digest support to ledger-chunk endpoints#7651

Merged
eddyashton merged 19 commits intomainfrom
copilot/close-feature-request-7650
Feb 10, 2026
Merged

Add Want-Repr-Digest / Repr-Digest support to ledger-chunk endpoints#7651
eddyashton merged 19 commits intomainfrom
copilot/close-feature-request-7650

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

  • Implement Want-Repr-Digest / Repr-Digest in fill_range_response_from_file
  • Add snapshot endpoint test (test_snapshot_repr_digest)
  • Apply brace style suggestion
  • Apply doc suggestion for example header
  • Update parse_want_repr_digest comment to reflect best-effort/ignore behavior
  • Add gcount() >= range_end check, return 500 on short read
  • Return 200 OK (not 206) for GET without Range header; add Range+Digest test cases
  • Clarify unsupported algorithms are ignored in doc/changelog/tests
  • Default to sha-256 when no supported algorithm matches (RFC 9530 Appendix C.2)
  • Return 500 on HEAD path when file read fails with Want-Repr-Digest
  • Move parse_want_repr_digest() to src/http/http_digest.h with unit tests
  • Move http_digest.h include to top of test file

Closes #7650


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 9, 2026 14:57
…loses #7650)

Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for sha-256, sha-384, and sha-512 algorithms Add Want-Repr-Digest / Repr-Digest support to ledger-chunk endpoints Feb 9, 2026
Copilot AI requested a review from achamayou February 9, 2026 15:02
@eddyashton
Copy link
Member

@achamayou - Is there a reason this is /ledger-chunk specific, or could we move it inside fill_range_response_from_file to get the same behaviour for /snapshot requests?

@achamayou
Copy link
Member

@achamayou - Is there a reason this is /ledger-chunk specific, or could we move it inside fill_range_response_from_file to get the same behaviour for /snapshot requests?

No specific reason, but it's a bit of a questionable coupling, because that behaviour is specifically not affect by the Range? So it seems like a bit of functionality we want for both snapshot and ledger endpoints perhaps (probably more for the latter, where there is a clear use case).

@achamayou
Copy link
Member

@copilot could you try to integrate with the fill_range_response_from_file() function, because that already finds, opens, and reads from the file. To compute the repr-digest, you may need to read a longer range, because it's always the digest of the whole file, as opposed to just the range being selected, but in case when the range is the whole file, it's a single read.

And in case where it's a subset, you should be able to use the update_hash() to read what comes before the range, update the digest, what's in range and needs to be set in the body, update the digest, and after the range and update the digest with that too.

That avoids duplicate reads, and means the snapshot endpoint download benefits from the same feature. It will needs it own test as well of course.

Copy link
Contributor Author

Copilot AI commented Feb 9, 2026

@achamayou Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 7a1a94cb-7287-485d-9d12-d9b5670984ef

Sorry for the inconvenience!

@achamayou
Copy link
Member

@copilot can you try again please?

Copilot AI and others added 2 commits February 9, 2026 16:19
…e; add snapshot test

Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 9, 2026

@copilot can you try again please?

Moved the Want-Repr-Digest/Repr-Digest handling into fill_range_response_from_file() in d57c8e3 so both /snapshot/{snapshot_name} and /ledger-chunk/{chunk_name} endpoints benefit automatically. When a digest is requested, the full file is read once and the range is extracted from it — avoiding duplicate reads. Split the old compute_repr_digest into parse_want_repr_digest() (header parsing) and format_repr_digest() (hash + formatting). Added test_snapshot_repr_digest for snapshot endpoint coverage, and updated docs/changelog to mention both endpoints.

@achamayou achamayou marked this pull request as ready for review February 9, 2026 16:50
@achamayou achamayou requested a review from a team as a code owner February 9, 2026 16:50
Copilot AI review requested due to automatic review settings February 9, 2026 16:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds RFC 9530 representation digest negotiation to snapshot and ledger-chunk download endpoints so clients can verify downloaded content (and avoid re-downloads) via Want-Repr-Digest / Repr-Digest.

Changes:

  • Introduces want-repr-digest / repr-digest header constants and implements digest computation + selection logic in file-serving handlers.
  • Updates file-serving responses to include Repr-Digest for GET/HEAD when requested (digest covers full file even with Range).
  • Adds E2E tests for snapshots and ledger chunks, plus public documentation and changelog entry.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
include/ccf/http_consts.h Adds header name constants for Want-Repr-Digest / Repr-Digest.
src/node/rpc/file_serving_handlers.h Parses Want-Repr-Digest, computes digest, and injects Repr-Digest header for file-serving endpoints.
tests/e2e_operations.py Adds E2E coverage for Repr-Digest behavior on snapshot and ledger-chunk endpoints.
doc/operations/ledger_snapshot.rst Documents new request/response header behavior and supported algorithms.
CHANGELOG.md Records feature addition in the changelog.

Copy link
Contributor Author

Copilot AI commented Feb 9, 2026

@achamayou Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 0a0734ff-7018-4280-ab51-7af288002a15

Sorry for the inconvenience!

Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
@achamayou achamayou added the run-long-test Run Long Test job label Feb 10, 2026
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
Copilot AI requested a review from eddyashton February 10, 2026 14:20
@eddyashton eddyashton merged commit b63d230 into main Feb 10, 2026
16 of 17 checks passed
@eddyashton eddyashton deleted the copilot/close-feature-request-7650 branch February 10, 2026 16:17
Copilot AI added a commit that referenced this pull request Feb 10, 2026
- Resolve merge conflicts with Want-Repr-Digest (#7651) changes
- Fix ETag check to handle both HTTP 200 OK (no Range) and
  206 Partial Content (with Range) from fill_range_response_from_file()
- Merge CHANGELOG, docs, and header constant additions

Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-long-test Run Long Test job

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Want-Repr-Digest and Repr-Digest to HEAD/GET /node/ledger-chunk/{chunk_name}

3 participants