[PeerDAS] Expose compute_cells (cells without proofs) through the C ABI and constantine-go - #626
Conversation
compute_cells already existed as a Nim-only API. Consensus clients on the PeerDAS hot path receive cell proofs from the execution layer (engine_getBlobsV2 / BlobsBundleV2) and only need the erasure-extended cells: one size-4096 IFFT + one size-4096 FFT (~1.5 ms/blob) instead of the 128 FK20 MSMs of compute_cells_and_kzg_proofs (~80-140 ms/blob), a ~50x difference. Align its signature with the other PeerDAS exports (ptr UncheckedArray[Cell] + FFI nil-pointer validation of ctx and cells) and export it as ctt_eth_kzg_compute_cells, declared in ethereum_eip7594_peerdas.h. As with the sibling exports, the blob parameter is passed by reference and must be non-NULL from C. Matches the compute_cells function of the consensus spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/fulu/polynomial-commitments-sampling.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cells-only Go binding over ctt_eth_kzg_compute_cells, mirroring ComputeCellsAndKzgProofs, with a test over the consensus-spec-tests compute_cells vectors. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe EIP-7594 cells-only computation API now supports FFI-compatible output buffers, exposes a C declaration, and adds a Go binding with test-vector validation. Nim benchmarks and tests pass unchecked cell buffers while preserving existing assertions and recovery logic. ChangesEIP-7594 compute-cells API
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant TestComputeCells
participant EthKzgContext
participant CApi
participant NimComputeCells
TestComputeCells->>EthKzgContext: ComputeCells(blob)
EthKzgContext->>CApi: ctt_eth_kzg_compute_cells(ctx, cells, blob)
CApi->>NimComputeCells: forward output buffer and blob
NimComputeCells-->>CApi: return status and populated cells
CApi-->>EthKzgContext: return status
EthKzgContext-->>TestComputeCells: cells or error
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| func compute_cells*( | ||
| ctx: ptr EthereumKZGContext, | ||
| cells: var array[CELLS_PER_EXT_BLOB, Cell], | ||
| blob: Blob): cttEthKzgStatus = | ||
| cells: ptr UncheckedArray[Cell], | ||
| blob: Blob): cttEthKzgStatus {.libPrefix: prefix_eth_kzg, raises: [].} = |
There was a problem hiding this comment.
Public Nim API signature breaks
When an existing Nim consumer calls compute_cells(ctx, cells, blob) with a fixed array[CELLS_PER_EXT_BLOB, Cell], the new pointer-only signature rejects the argument, causing downstream compilation to fail. Retain a typed compatibility overload or separate the C export wrapper from the existing Nim API.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Greptile SummaryAdds cells-only PeerDAS computation across the existing implementation and language bindings.
Confidence Score: 4/5The PR is not yet safe to merge because the previously reported public Nim API compatibility break remains unfixed. The current public Files Needing Attention: constantine/eth_eip7594_peerdas.nim Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Go/C client
participant ABI as ctt_eth_kzg_compute_cells
participant KZG as Constantine PeerDAS
Client->>ABI: context, 128-cell output buffer, blob
ABI->>KZG: compute_cells
KZG->>KZG: deserialize and extend blob
KZG-->>ABI: 128 cells and status
ABI-->>Client: cells or error
Reviews (2): Last reviewed commit: "[PeerDAS] constantine-go: add EthKzgCont..." | Re-trigger Greptile |
Rename RESULTS_DRAFT.md to RESULTS.md, drop the draft banner, link the upstream cells-only PR (mratsim/constantine#626), and cross-link the report and README. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
SGTM, will create a separate issue to expose the same in Rust as well as this is go only. Seems like there are unrelated CI stuff to fix though. Will have a look |
|
Hopefully CI is unblocked by #627 |
|
The go tests are done first and are passing. The issue left seems to be a regression in an unreleased Nim v2.2.x that affects unit tests but not integration tests or building the static library so merging. Regression tracked in #628. |
On the PeerDAS/Fulu block proposal hot path, consensus clients receive cell proofs from the execution layer for free (
BlobsBundleV2/engine_getBlobsV2) and only need the erasure-extended cells.I'm assessing Constantine for Prysm's KZG operations (OffchainLabs/prysm#16850); in our benchmarks of constantine-go against c-kzg-4844 Constantine wins every measured operation, but this API gap is currently the main blocker to adoption: Prysm calls a cells-only
ComputeCellsatbeacon-chain/blockchain/kzg/validation.go(proof verification path), andbeacon-chain/core/peerdas/reconstruction.go(data-column reconstruction)c-kzg-4844, go-eth-kzg and rust-eth-kzg all expose the equivalent entry point, matching the consensus-spec function
compute_cells. With this change, migrating to constantine from other kzg libraries would be much easier.Summary by CodeRabbit
New Features
Tests