Skip to content

fix(celestia-node-fiber): report original payload size in BlobEvent#3281

Merged
julienrbrt merged 1 commit intoevstack:julien/fiberfrom
walldiss:feat/fibre-adapter-datasize-fix
Apr 23, 2026
Merged

fix(celestia-node-fiber): report original payload size in BlobEvent#3281
julienrbrt merged 1 commit intoevstack:julien/fiberfrom
walldiss:feat/fibre-adapter-datasize-fix

Conversation

@walldiss
Copy link
Copy Markdown

Summary

Follow-up to #3280 (landed a few seconds before this fix was pushed). Corrects the `BlobEvent.DataSize` reported by the adapter's Listen path.

The bug

`listen.go` set `BlobEvent.DataSize` to `b.DataLen()`. For a share-version-2 Fibre blob, `DataLen()` is always the fixed on-chain share layout — `fibre_blob_version (4 bytes) + commitment (32 bytes)` — not the original payload length.

The 10-blob showcase on julien/fiber asserts `DataSize > 0` because of this, but ev-node's `fibermock` contract is `DataSize = len(data)` (original payload length). Any downstream consumer using `DataSize` to pre-allocate buffers, filter by size, or report progress would be silently misled.

Why Download-to-resolve

The v2 share genuinely doesn't carry the original size, and `x/fibre` v8 exposes no query that maps `commitment → PaymentPromise.BlobSize`. Events don't carry size either (`EventPayForFibre` has signer/namespace/commitment/validator_count — no size). So the only accurate path is to Download the blob and measure. Listen now does that per v2 event before forwarding.

Cost: one FSP round-trip per v2 BlobEvent. For the showcase (10 × ~40 bytes) this is noise. For 128 MiB blobs it's non-trivial — we can add an opt-out config switch if that becomes material. Correctness wins for now.

Changes

  • `listen.go` — `forwardFibreBlobs` and `fibreBlobToEvent` become methods on `*Adapter` so they can reach `a.fibre.Download`. `fibreBlobToEvent` issues a Download, reads `len(res.Data)` for `DataSize`. Doc on `Listen` explains the tradeoff.
  • `adapter_test.go` — `TestListen_FiltersFibreOnlyAndEmitsEvent` stubs `fakeFibre.Download` with a deterministic payload and asserts `DataSize == len(payload)`.
  • `testing/showcase_test.go` — restored the strict `DataSize == len(expected[key])` assertion for all 10 blobs.

Test plan

  • `go build -tags fibre ./...`
  • `go vet -tags fibre ./...`
  • `go test -count=1 ./...` — 7 adapter unit tests pass (no tag needed)
  • `go test -tags fibre -count=1 ./...` — 7 unit + 1 showcase (10 blobs, each with exact `data_size` match) — all pass in ~10s

Sample output after the fix

```
upload[00] size=37 → listen[01] data_size=37
upload[01] size=38 → listen[02] data_size=38
...
upload[09] size=46 → listen[10] data_size=46
```

(On julien/fiber pre-fix: all 10 reported `data_size=36`.)

🤖 Generated with Claude Code

listen.go previously set BlobEvent.DataSize to b.DataLen(), which for
a share-version-2 Fibre blob is always the fixed share-data layout
(fibre_blob_version + commitment = 36 bytes) — not the original
payload length. That diverges from ev-node's fibermock contract and
misleads any consumer that uses DataSize to allocate buffers or
report progress.

The v2 share genuinely doesn't carry the original size, and x/fibre
v8 has no chain query to derive it from the commitment. The only
accurate path is to Download the blob and measure. Listen now does
exactly that before forwarding each event. The cost is one FSP
round-trip per v2 blob; can be made opt-out later if it hurts
throughput-sensitive use cases.

Tests:
- Showcase restores the strict DataSize == len(payload) assertion
  across all 10 blobs.
- Unit test TestListen_FiltersFibreOnlyAndEmitsEvent now stubs
  fakeFibre.Download to return a deterministic payload and asserts
  DataSize matches its length.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7637791-edfc-4719-a04a-9b899dc1430f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@julienrbrt julienrbrt merged commit 90a18b1 into evstack:julien/fiber Apr 23, 2026
16 of 24 checks passed
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