Add thin CGo zstd wrapper for packfile compression - #650
Conversation
5e66034 to
c188fb0
Compare
There was a problem hiding this comment.
Pull request overview
Adds an internal CGO-based zstd wrapper (backed by system libzstd) to support upcoming packfile compression work, along with CI/Docker changes to ensure an appropriate libzstd is available.
Changes:
- Introduces
cmd/stellar-rpc/internal/zstdwith reusable compressor/decompressor contexts plus convenienceEncode/Decodehelpers. - Adds unit tests covering roundtrips, corruption handling, buffer reuse/aliasing, checksum behavior, and close semantics.
- Updates build infrastructure (Docker + GitHub composite action) to provide libzstd >= 1.5.7 and
pkg-config.
Reviewed changes
Copilot reviewed 82 out of 85 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| cmd/stellar-rpc/internal/zstd/zstd.go | New thin CGO wrapper over system libzstd with reusable contexts and options. |
| cmd/stellar-rpc/internal/zstd/zstd_test.go | New test suite exercising correctness and safety contracts. |
| cmd/stellar-rpc/docker/Dockerfile | Moves builder image to Debian trixie; installs libzstd-dev + pkg-config. |
| .github/actions/setup-go/action.yml | Installs libzstd (1.5.7) in CI before setting up Go. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
96dc9cc to
7f93516
Compare
f920751 to
9ec5045
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 12 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c0128cd to
d2e7954
Compare
Shaptic
left a comment
There was a problem hiding this comment.
LGTM pending one CI comment
| @@ -0,0 +1,253 @@ | |||
| // Package zstd provides compression and decompression using system libzstd | |||
There was a problem hiding this comment.
can these files be moved form under cmd/stellar-rpc/internal to something like a top level?
under pkg/zstd ?
atleast for the time being till such time that the new rpc binary is being designed
once all is done, we can converge on what the final step looks like.
if you put it under cmd/stellar-rpc/internal, I cannot use it from under full-history/ (which is where I am doing the current backfill implementation)
3ae1e8f to
f3163f4
Compare
f3163f4 to
707c97f
Compare
Second in a series of PRs checking in the packfile implementation for full history RPC v2. This PR adds a thin CGo wrapper around system libzstd (>= 1.5.7) for compression and decompression. - Compressor: reusable context with configurable content checksums - Decompressor: reusable context with buffer reuse - Convenience Encode/Decode functions for one-off use Also updates build infrastructure to provide libzstd >= 1.5.7: - Dockerfile: switch build stage from bookworm to trixie (Debian 13) which ships libzstd 1.5.7 in its default repos - CI: build libzstd 1.5.7 from source in the setup-go action (Linux), or install via brew (macOS) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
707c97f to
8b35b5a
Compare
Summary
Second in a series of PRs checking in the packfile implementation for full history RPC v2. See #633 for the design doc and #649 for the first PR (FOR encoding + offset index).
This PR adds a thin CGo wrapper around system libzstd (>= 1.5.7) for compression and decompression, and updates build infrastructure to provide the required library version.
Why a custom wrapper instead of existing Go bindings? (see
zstd.gopackage doc for details)Why 1.5.7? Benchmarked on representative production data (28KB blocks of 128 events):
Linking strategy:
#cgo linux LDFLAGS: -l:libzstd.a— the binary carries libzstd 1.5.7 baked in, no runtime dependency. This applies to Docker builds, CI, and the Jenkins .deb package pipeline (which uses our Dockerfile).Build infrastructure changes:
golang:1.25-bookwormtogolang:1.25-trixie(Debian 13 ships libzstd 1.5.7 in default repos), addlibzstd-devandpkg-configsetup-goaction on Linux (with SHA256 verification); install via brew on macOSTest plan
🤖 Generated with Claude Code