-
Notifications
You must be signed in to change notification settings - Fork 379
Description
Automatic Legacy Feed Fallback
Background
Bee supports two feed formats: legacy and new.
| Format | Contents of Single Owner Chunk | Fetch Steps | Notes |
|---|---|---|---|
| Legacy | 8-byte timestamp (uint64, big endian) + reference (32 bytes unencrypted / 64 bytes encrypted) | Fetch SOC → Read reference → Fetch payload | Indirect fetch; adds latency |
| New | Payload stored directly in the SOC | Fetch payload | Eliminates lookup; faster |
Why the change
The new feed format improves performance by removing the intermediate lookup step. By being able to fetch the payload directly, we get rid of a lookup roundtrip and achieve better latency.
In performance-critical scenarios, such as live streaming (where one feed update corresponds to one multimedia segment), the new feed format provides a significant performance boost.
Previous Feed Resolution Logic (Bee 2.6.x and maybe prior)
Older Bee versions tried to automatically detect the feed type based on the payload size:
- 40 bytes (8 + 32)
- 72 bytes (8 + 64)
If the payload matched one of these sizes, Bee assumed a legacy feed, skipped the first 8 bytes (timestamp), and treated the rest as a reference.
This heuristic fails for payloads that coincidentally match these sizes. For example, chat messages that are exactly 40 or 72 bytes, would be misinterpreted as legacy references, leading to fetch errors.
Related issue:
Deterministic Feed Resolution (Bee 2.7.0)
Bee 2.7.0 removes the size-based heuristic. The new feed format is now the default.
To resolve a feed as legacy, end users must explicitly add (and there is no other way):
?swarm-feed-legacy-resolve=true
Related issues:
- Make Swarm-Feed-Legacy-Resolve query param instead of header #5156
- Support Swarm-Feed-Legacy-Resolve query param in
GET /bzz/<hash>/endpoint #5157
Feature Request for Feed Manifests in /bzz/ Endpoint
While the new behavior of Bee 2.7.0 is a step in the right direction (using the new format works without edge cases), we need a graceful fallback mechanism when the legacy lookup is known to be necessary for a correct response.
| Bee Version | Feed Mode | Example URL | Result |
|---|---|---|---|
| 2.6.x | Size-based heuristic | http://localhost:1633/bzz/2fdac7bd34a7e27e46e3fd2b6c67f13e3f04231ef92226b8d64a5f693ec80cae/ |
HTTP 200 OK |
| 2.7.0 | New (default) | http://localhost:1633/bzz/2fdac7bd34a7e27e46e3fd2b6c67f13e3f04231ef92226b8d64a5f693ec80cae/ |
{"code": 404,"message": "address not found or incorrect"} |
http://localhost:1633/bzz/2fdac7bd34a7e27e46e3fd2b6c67f13e3f04231ef92226b8d64a5f693ec80cae/?swarm-feed-legacy-resolve=true |
HTTP 200 OK for root document, subpaths fail |
Proposed Solution
- Attempt to resolve feed manifests using the new feed format (status quo).
- If the result is HTTP 404, automatically retry with
?swarm-feed-legacy-resolve=true. - If the retry still returns 404, return the error to the client.
- Otherwise, return the successfully fetched content (HTTP 200).