Share retrieval and reconstruction
Share retrieval turns a block header's data-availability header (DAH) into verified block data. It serves samples, rows, namespaces, ranges, or a complete extended data square (EDS) by combining local access, peer exchange, proof checks, and erasure-code recovery. This page describes the share layer within block data and connects to core client, header sync, and data availability sampling.
Data model
Share roots
The DAH is the trusted root for the share data in one block. It contains row roots and column roots for the EDS, so a share can be checked against either axis. The share layer uses the block height with these roots to identify the target square and to reject data that belongs to another square.
An EDS is the erasure-coded square used for both serving and recovery. Its original data square (ODS) occupies the first half of each axis. The remaining half carries recovery data. Empty data has a fixed empty EDS path and does not require network retrieval.
References: share/…/getter.go• L29-83 share/…/accessor.go• L17-41 share/…/shrex.go• L208-252 share/…/testing.go• L35-38 share/…/testing.go• L606-622
Access primitives
The shwap.Accessor is the common read view over an EDS. It exposes the square size and roots together with the data forms that higher layers need: one sample, one axis half, one row namespace result, a share range, or a row-major reader for the ODS. A caller can mark a context to prevent a streamed operation from adding rows to a shared accessor cache.
The shwap.Getter is the common retrieval contract above storage and network sources. Callers can request a sample set, a row, namespace data, a range, or the full EDS without choosing the source. Each result is expected to be checked against the DAH before it is used. Accessors also reject reads after their lifetime ends, so a forced close cannot expose a half-valid read view.
References: share/…/accessor.go• L13-38 share/…/accessor.go• L17-55 share/…/close_once.go• L20-107 share/…/getter.go• L29-83
Availability
Availability checks
The share.Availability contract answers whether a header's committed shares can be obtained from the network. It is a subjective check: the result describes what this node can retrieve at the time of the check, not a new consensus fact. A real failure returns share.ErrNotAvailable, while an old header outside the configured window is a deliberate skip.
Light availability samples selected coordinates and records which samples succeeded. Full availability retrieves enough data to reconstruct the complete EDS. Both modes use the same getter contract, so data availability sampling can coordinate them without knowing their retrieval method.
References: share/availability.go• L10-19 share/…/availability.go• L32-35 share/…/availability.go• L76-89 share/…/availability.go• L27-30 share/…/availability.go• L57-69
Storage windows
The availability window separates recent data from archival data. Recent requests use peers and storage that serve the active window. Older requests use archival peers or archival storage when the node supports them. A non-archival full node can skip work outside its window, while an archival node can retain or serve older data according to its storage policy described in storage and retention.
This boundary is shared by availability checks and retrieval sessions. It prevents a request for old data from silently using the recent-data path and lets peer management keep full-node and archival-node sources distinct.
References: share/…/availability.go• L62-69 share/…/availability.go• L98-119 share/…/shrex.go• L388-397
Retrieval architecture
Source cascade
The CascadeGetter presents one retrieval surface over several sources. It tries sources in order and returns the first verified result. A source can decline an operation when it does not support it. A bad-data error stops the cascade because another source cannot make a provably invalid square valid.
Node roles select different source orders. A bridge can try its local store first and then use the network when pruning removed the requested data. This gives local data the lowest cost while keeping a network recovery path.
The request flow has one stable shape across all source types.
sequenceDiagram
participant C as Caller
participant G as Cascade getter
participant L as Local store
participant P as Share Exchange peer
participant V as Root and proof checks
C->>G: Request data for header and coordinates
G->>L: Try local source
alt Local result
L-->>G: EDS container
else Local miss or unsupported
G->>P: Request SHWAP container
P-->>G: Encoded container
end
G->>V: Verify against DAH or row roots
V-->>G: Verified result or error
G-->>C: Data or failure
References: share/…/cascade.go• L30-42 share/…/cascade.go• L148-218 nodebuilder/…/p2p_constructors.go• L32-64 nodebuilder/…/share.go• L154-236
Request forms
The retrieval API uses the smallest result that matches the caller's need. The main forms are:
| Request | Result | Main use |
|---|---|---|
| Sample coordinates | Share plus an NMT proof | DAS and single-share reads |
| Row index | One row half | EDS recovery and row reads |
| Namespace | Namespaced shares by row plus proofs | Blob and namespace reads |
| ODS range | Contiguous shares plus boundary proofs | Range and blob retrieval |
| Block height | Complete EDS | Full availability and full data access |
Every network result carries enough information for the receiver to validate its identity and its inclusion. A sample also has a fixed-size share and a proof interval bound to the requested coordinates. A batch sample result stays positionally aligned with the requested coordinates; a failed position remains empty while the operation reports an error, so callers can use successful samples without losing their request indexes.
The wire IDs for these requests have fixed encodings and square-bound checks. Their decoders must agree with their binary constructors and must consume exactly one ID, so malformed or trailing request bytes cannot change the operation selected by the server. Fuzzed server requests also check that every accepted request produces a response that the client can decode and verify against the fixture roots.
References: share/…/getter.go• L33-83 share/…/sample.go• L23-33 share/…/sample.go• L137-164 share/…/sample_test.go• L40-108 share/…/row_namespace_data.go• L25-29 share/…/range_namespace_data.go• L19-43 share/…/shrex.go• L97-157 share/…/shrex_test.go• L315-354 share/…/containers_fuzz_test.go• L22-37 share/…/containers_fuzz_test.go• L138-209 share/…/ids_fuzz_test.go• L138-225 share/…/server_fuzz_test.go• L121-228 nodebuilder/…/share.go• L33-75
Proof and range data
Namespace data
Namespace data is the set of shares in one namespace, grouped by row. The row roots in the DAH identify which rows may contain the namespace. Each returned row contains either the matching shares with an inclusion proof or an absence proof when the namespace is not present in that row.
The root bounds include both end namespaces, so a namespace at a row boundary can belong to more than one candidate row. The share layer rejects malformed root metadata before it uses those bounds. The result keeps row order and can be verified against the DAH before a caller interprets the share payload. Namespace responses load and encode one row at a time, which keeps memory tied to row width rather than the number of candidate rows. Streamed rows do not populate the shared proof cache. Fuzzed namespace data is accepted only when it reproduces the honest shares for the selected namespace.
References: share/…/namespace_data.go• L16-20 share/…/namespace_data.go• L40-55 share/…/row_namespace_data.go• L20-23 share/…/row_namespace_data.go• L104-154 share/…/namespace_data_id.go• L141-159 share/…/row_stream.go• L12-70 share/…/proofs_cache.go• L236-305 share/…/proofs_cache_stream_test.go• L45-70 share/…/nd.go• L15-52 share/root.go• L59-99 share/…/proof_nodes_test.go• L15-56 share/…/namespace_fuzz_test.go• L132-173
Range proofs
A range request addresses ODS shares with a half-open interval: start is included and end is excluded. The range may cross row boundaries. The response contains the shares in row order and proofs only where a partial row needs extra information; complete rows can be checked from their shares and the row root.
The range data model uses inclusive coordinates for the first and last share after the half-open request has been mapped to the ODS. Its boundary proofs connect partial rows to their roots, while complete rows are rebuilt from their shares. The proofs must cover the exact edge-row bounds: a first partial row reaches the ODS row edge, and a last partial row starts at column zero. A partial single-row range also requires a proof. These checks prevent a peer from shifting shares into or out of the requested range while keeping the share count unchanged. The public range result adds the row-root proofs needed to connect the NMT proofs to the block DAH. Its Verify operation checks both the returned share bytes and the final data root. This makes a range useful as a self-contained verified result for clients.
Range IDs validate their bounds against the ODS size before a response starts. A streamed range reads only the rows touched by the interval and checks that all returned rows belong to one namespace. Range proof decoding applies the same bound on proof nodes as sample and namespace results. This keeps a valid range compact while rejecting an oversized proof before it can expand in memory. Fuzzed range responses must verify for the exact requested interval and must reproduce those ODS shares; shifted or extended intervals do not make the same response valid.
References: share/…/range_namespace_data_id.go• L19-21 share/…/range_namespace_data_id.go• L65-98 share/…/range_namespace_data_id.go• L176-207 share/…/row_stream.go• L21-70 share/…/range_namespace_data.go• L45-140 share/…/range_namespace_data.go• L143-289 share/…/range_namespace_data.go• L298-348 share/…/range_namespace_data.go• L462-495 share/…/range_namespace_data_bounds_test.go• L11-87 share/…/range_namespace_data_shift_test.go• L15-73 share/…/proof_nodes_test.go• L43-56 share/…/namespace_fuzz_test.go• L176-217 nodebuilder/…/get_range_result.go• L21-28 nodebuilder/…/get_range_result.go• L96-123
IPLD tree retrieval
The IPLD path stores row and column commitments as binary namespaced Merkle tree (NMT) nodes. Each node has a CID derived from its namespaced hash, and inner nodes link to their two child nodes. A block service fetches these nodes from local storage or peers. Leaf retrieval follows the tree to a requested position, while namespace retrieval follows only branches whose namespace bounds can contain the target and collects the other branches as proof material.
This path is useful when the caller needs selected leaves rather than a complete square. It also supplies the input for quadrant recovery, where many leaves are fetched in parallel and placed into their square positions.
When share data is added to the IPLD service, the same square and commitment model is used to create the row and column tree data that retrieval later follows. This keeps stored leaves, reconstructed squares, and their committed roots on one verification path.
Local EDS access uses a bounded cache for extended row and column shares plus the NMT proof nodes built from them. Later sample and namespace reads can reuse a cached axis after its proof tree is built. A one-off sample does not build and retain a whole axis when that work costs more than the read. When ODS shares are assembled from parity row halves, the cache uses the full extended row as the accumulator before selecting the data half, so repeated reads preserve the same ODS sequence. Range and full-EDS streaming bypass the cache, so large responses do not retain all streamed rows or pin the whole ODS in memory. The cache evicts older axes when its per-axis memory budget is full.
References: share/…/add.go• L18-49 share/…/nmt.go• L26-64 share/…/nmt.go• L66-108 share/…/nmt.go• L131-160 share/…/blockserv.go• L11-29 share/…/get.go• L45-75 share/…/get.go• L78-158 share/…/namespace_data.go• L187-335 share/…/proofs.go• L13-35 share/…/proofs_cache.go• L28-39 share/…/proofs_cache.go• L128-212 share/…/proofs_cache.go• L266-305 share/…/proofs_cache_test.go• L35-129 share/…/proofs_cache_stream_test.go• L17-70
Peer protocols
SHWAP containers
SHWAP defines the typed data containers and IDs exchanged by the share layer. An ID binds a request to a block height and, when needed, a row, coordinate, namespace, or range. The receiver uses the ID to match the response to the request before it verifies the data.
The container types preserve the proof or recovery information that belongs with each result. The receiver validates the request ID, decodes the container, and checks it against the supplied DAH or row roots before returning it to the getter. Sample validation also rejects a malformed share size and binds the proof interval to the requested coordinate. ID fuzzing checks binary round trips, exact read lengths, validation, and coordinate bounds across all request forms.
The complete-EDS ID is height-only because the block height identifies the data square. Its response is an accessor stream with a fixed copy-buffer budget, so resource accounting does not grow with the square size or require the full EDS in memory. Namespace and range IDs use row streams that build the next response only after the previous row is consumed.
References: share/…/eds_id.go• L13-24 share/…/eds_id.go• L91-114 share/…/row_id.go• L18-23 share/…/sample_id.go• L53-57 share/…/sample.go• L137-164 share/…/sample_test.go• L81-108 share/…/namespace_data_id.go• L17-38 share/…/namespace_data_id.go• L141-159 share/…/range_namespace_data_id.go• L19-43 share/…/range_namespace_data_id.go• L176-207 share/…/row_stream.go• L21-70 share/…/ids_fuzz_test.go• L16-225
Share Exchange
Share Exchange, or shrex, is the direct request/response protocol for typed SHWAP containers. Its request types cover complete EDS data, samples, rows, namespace data, and ranges. The server reads the matching data from its EDS accessor and streams a response; the client selects a peer, performs the request, and verifies the result.
Peer selection prefers peers that announced the requested data hash. Header validation turns those announcements into trusted pools. If a notification created a pool with an untrusted height, validation replaces it with the matching header's height before storage-window cleanup uses it. Discovery supplies fallback full or archival peers when a hash-specific pool has no usable peer. The manager samples two active peers and prefers the one with the better observed throughput; an unmeasured peer gets an early request so the manager can measure it. A successful request updates the score only after response verification. Timeouts, overload, and not-found results place a peer on cooldown, while invalid response data triggers the invalid-peer action. Cooldown state is kept consistent with pool membership, so a removed peer cannot return when a stale expiry fires. Peer-pool metrics expose active and cooldown populations through this same state.
Peer-pool cleanup also takes a synchronized snapshot of all entries before it removes an unvalidated data-hash pool. This keeps concurrent peer additions from racing with cleanup and ensures the peers associated with a rejected hash are the ones considered for blacklist action. The manager bounds its rejected-hash cache and limits the number of unvalidated hash pools that one peer can create. Validation or cleanup releases those per-peer slots. An archival manager without hash announcements uses discovered peers without retaining a pool for every requested block.
Discovery keeps its peer set within a soft limit. If concurrent additions temporarily move the set above that limit, the next discovery pass skips the unsigned deficit calculation instead of starting an oversized search.
The client bounds stream opening and ties in-flight reads and writes to the caller's context. A stalled peer therefore releases the request budget quickly, and cancellation resets the stream instead of waiting for a stream deadline. The client distinguishes not-found, invalid response, internal server, and resource-exhausted outcomes so the getter can retry a missing or overloaded source without treating a failed server stream as valid EOF. The server reserves response memory before it reads data, applies service and peer limits, and marks a response read failure with a stream error after an OK status. An ODS-only file serves the first half of the square and reports second-half row requests as not found, so the client can try another peer. The getter retries with other peers until the request context ends. It uses the full-node manager for recent data and the archival manager for data outside the availability window. Discovery uses separate full and archival topics; archival discovery has a smaller peer limit, and only full and bridge nodes advertise as full nodes. Pubsub validation rejects malformed notifications before they reach peer-pool logic; accepted notices have a non-zero height, a valid non-empty data hash, and the exact announced values.
References: share/…/doc.go• L1-15 share/…/request.go• L13-52 share/…/server.go• L123-169 share/…/server.go• L172-280 share/…/client.go• L54-176 share/…/error.go• L9-27 share/…/exchange_test.go• L75-115 share/…/exchange_test.go• L117-164 share/…/exchange_test.go• L206-240 share/…/manager.go• L223-319 share/…/manager.go• L464-565 share/…/manager.go• L595-642 share/…/pool.go• L53-80 share/…/pool.go• L165-223 share/…/timedqueue.go• L11-79 share/…/metrics.go• L141-169 share/…/score.go• L18-117 share/…/shrex.go• L97-157 share/…/shrex.go• L388-492 share/…/shrex_test.go• L540-607 share/…/manager_test.go• L32-66 share/…/manager_test.go• L582-707 share/…/manager_test.go• L822-898 share/…/pubsub_fuzz_test.go• L17-65 share/…/discovery.go• L268-339 share/…/discovery_limit_test.go• L28-45 share/…/options.go• L10-20 nodebuilder/…/p2p_constructors.go• L41-151
Protocol selection
The node can combine local access with Share Exchange through the same getter API. The cascade keeps this choice outside callers. A network source can be disabled or unavailable without changing the sample, row, namespace, range, or EDS API when another source can satisfy the request.
Recent and archival requests use separate peer pools in the direct exchange path. This separation aligns peer choice with the storage window and avoids sending an old-data request to a peer that only retains recent data. Full and bridge nodes advertise on the full-node discovery topic, while light nodes only discover full nodes. Archival discovery is limited to a smaller peer set because archival peers are a subset of the network.
References: nodebuilder/…/p2p_constructors.go• L21-64 nodebuilder/…/p2p_constructors.go• L102-157 share/…/shrex.go• L388-397
EDS reconstruction
Quadrant retrieval
Complete EDS retrieval does not need to transfer every EDS cell. The retriever chooses quadrants from the row and column roots, requests one quadrant at a time, and places the received leaves into a partially filled square. It starts another quadrant after a timeout so a slow or unavailable source does not block the whole request.
The row and column views overlap at the same cells. The retriever accepts the first write for a position and ignores duplicate work from the other axis. Once enough cells are present, it asks the erasure-code layer to repair the missing cells against the trusted row and column roots.
flowchart LR
H[DAH row and column roots] --> Q[Choose row and column quadrants]
Q --> I[Fetch NMT leaves in parallel]
I --> S[Fill partial EDS]
S --> R{Enough cells?}
R -- No --> Q
R -- Yes --> E[Repair with erasure coding]
E --> V[Verified complete EDS]
References: share/…/retriever.go• L33-60 share/…/retriever.go• L127-167 share/…/retriever.go• L177-197 share/…/retriever.go• L224-331 share/…/retriever_quadrant.go• L49-87
Row reconstruction
A row request can carry one half of a row because the other half can be recovered with the share codec. The receiver expands the half, computes the row commitment, and compares it with the DAH row root. This keeps row exchange smaller while preserving a full-row result for EDS repair.
The direct Share Exchange EDS path streams ODS shares and rebuilds the EDS after reading them. The path returns the same complete-square abstraction to callers. The share-to-EDS path uses a reusable construction resource and preserves the same row roots, column roots, and DAH hash during concurrent reconstruction.
References: share/…/row.go• L30-34 share/…/row.go• L80-105 share/…/row.go• L130-177 share/…/shrex.go• L208-252 share/…/rsmt2d.go• L181-197 share/…/rsmt2d_pool_test.go• L19-84
Byzantine data
Verification failure has a different meaning from a missing peer or a timeout. A missing result can trigger another source or another peer. A proof or root mismatch shows that the received data does not match the committed square, so the retrieval path stops and can retain proof context for diagnosis and peer action.
The full retriever reports this condition as a byzantine error after it closes the retrieval session. The cascade also stops on the same class of error instead of hiding it behind a later source failure.
References: share/…/share_proof.go• L20-51 share/…/share_proof.go• L54-95 share/…/retriever.go• L76-100 share/…/cascade.go• L194-212
Serving paths
Accessor-backed serving
A serving node exposes its stored EDS through an accessor rather than exposing storage layout. The request ID selects the reader: a sample reader returns one proof-bearing sample, a row reader returns a row half, a namespace reader returns row results, a range reader returns a bounded stream, and an EDS reader returns ODS shares.
The server validates the request and prepares the first response row before it sends success. It then reserves the memory needed by the response path and sends a status followed by the selected data. Complete EDS data remains a streamed ODS response, so it uses a fixed stream buffer instead of requiring the whole square in memory. Accessors used by concurrent readers can be closed once, and later calls fail instead of reaching released storage. ODS-only storage reports recovery-half rows as unavailable rather than reconstructing them in the serving path. The server request fuzz path checks this contract across all registered request types and confirms that an honest response passes the matching client-side verification.
The request registry gives each SHWAP request type the same contract for validation, response creation, and response-size accounting. Protocol limits reject excessive streams before the handler runs. Service limits then bound aggregate streams and memory for the SHREX service and for each peer. These limits scale with available memory at global and service scopes, while each request type keeps its own stream ceiling.
References: share/…/request.go• L13-52 share/…/server.go• L122-275 share/…/limits.go• L7-17 share/…/limits.go• L135-157 share/…/namespace_data_id.go• L141-159 share/…/range_namespace_data_id.go• L176-207 share/…/row_stream.go• L30-53 share/…/close_once.go• L25-107 share/…/exchange_test.go• L75-115 share/…/server_fuzz_test.go• L121-228
Reader streams
The EDS reader presents the ODS as a row-major byte stream. It reads shares from the accessor on demand and keeps partial share bytes between calls. This lets protocol code stream a large square without requiring a separate serialized EDS object in memory.
The import reader accepts a stream that ends on a share boundary and fills the unused tail with tail-padding shares. A stream that ends in the middle of a share fails because the input cannot be parsed into complete shares. The EDS response also limits consumption to the expected ODS size, so extra bytes do not become part of the reconstructed square. In the SHREX path, the response first reads and counts the ODS bytes, then closes the network stream before it rebuilds the EDS and checks its data hash. The result is accepted only when that hash matches the expected DAH. Fuzzed accepted streams must reproduce the committed square exactly, including the allowed tail-padding case. Namespace and range row streams use the same distinction between a real row error and clean end of stream, so a missing row cannot look like a valid completed response.
References: share/…/share_reader.go• L12-24 share/…/share_reader.go• L36-81 share/…/read.go• L15-93 share/…/row_stream.go• L21-70 share/…/row_stream_test.go• L13-57 share/…/eds_response.go• L15-63 share/…/eds_response_test.go• L18-80 share/…/read_fuzz_test.go• L19-47
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to EDS width, ODS layout, or erasure-code settings must stay aligned across coordinate IDs, response sizes, row-half reconstruction, and EDS import.
- Changes to SHWAP IDs must update both request decoding and response registration. A mismatch can make valid data look like an unknown or wrong container.
- Changes to proof encoding must preserve the link from sample or namespace proofs to row roots and from row roots to the DAH.
- Changes to proof-node limits must stay aligned across sample, namespace, and range deserialization. The limit must remain no larger than the proof a supported row tree can produce.
- Changes to the availability window must keep light and full availability, archival peer choice, storage retention, and getter source selection on the same boundary.
- Changes to getter order or supported operations must preserve the cascade rule that skips unsupported sources but stops on verified bad data.
- Changes to batch sample retrieval must preserve positional alignment between requested coordinates and returned samples, including empty entries on partial failure.
- Changes to peer selection, pool membership, or transfer scoring must keep verified-success scoring, failure cooldowns, stale-expiry handling, and the fallback from hash-specific peers to discovered peers aligned.
- Changes to peer-pool cleanup must keep pool locking and peer snapshots aligned so concurrent additions are not read through an unsafe list and invalid-hash cleanup still identifies the right peers.
- Changes to the rejected data-hash cache or archival manager setup must preserve bounded cache growth and must not create uncollectable per-request pools when hash announcements are unavailable.
- Changes to unvalidated pool limits or pool height assignment must keep peer-created state bounded and ensure cleanup uses the trusted header height rather than an announced height.
- Changes to discovery limits, role tags, or advertisement rules must keep full and archival peer managers connected to the matching getter paths.
- Changes to pubsub notification fields must keep decode checks, non-empty data-hash validation, empty-EDS exclusion, and peer-manager input in the same contract.
- Changes to stream open or cancellation handling must preserve prompt release of a stalled peer and must not turn caller cancellation into a peer penalty.
- Changes to streamed response sizes must update resource reservations and limits. A zero or stale size can reject valid requests or allow an unsafe memory load.
- Changes to SHREX request registration must keep protocol IDs, response readers, response-size accounting, stream limits, and outbound stream admission aligned for every request type.
- Changes to EDS streaming or its response-size contract must preserve the fixed-buffer model. The resource manager must account for the stream path rather than the full square payload.
- Changes to proof caching must preserve row and column axis identity, proof-root consistency, the bounded cache budget, and the uncached full-EDS reader path. Streamed namespace and range responses must continue to avoid retaining all rows in the cache.
- Changes to parity-half handling must preserve the full extended row while assembling ODS shares, so the accumulator does not lose its parity context or change repeated results.
- Changes to range index semantics must keep the half-open
[from, to)contract consistent across public APIs, range IDs, coordinate conversion, proof generation, and proof verification. - Changes to empty-EDS handling must preserve the local short circuit for samples and full EDS requests and the rule that empty data is not announced as a retrievable network object.
- Changes to ODS stream framing or EOF handling must preserve row-major share alignment. Share-boundary EOF can use tail padding, but mid-share EOF must remain an error before EDS verification.
- Changes to namespace root bounds must keep boundary inclusion and malformed-root rejection consistent between candidate-row selection and proof retrieval.
- Changes to accessor lifetime handling must keep close operations idempotent and prevent reads from reaching released storage.
- Changes to row streaming must keep the first-row validation before success status and must distinguish a row error from clean end of stream.
- Changes to EDS construction resources must preserve root equality under concurrent reconstruction.
- Changes to SHREX stream errors must keep resource exhaustion, not-found, invalid response, and post-OK server failures distinguishable to retry logic.
- Changes to SHWAP container decoding must preserve the invariant that any container that verifies against roots reproduces the committed sample, row, or namespace data.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A peer returns a container with an ID that does not match the requested height or operation | The result is rejected before it reaches the caller. | SHWAP IDs are validated during request and container decoding. |
| An ID has truncated, trailing, or out-of-bounds wire data | The request is rejected instead of selecting the wrong square or operation. | ID readers round-trip only fixed-size encodings and validate square bounds. |
| A sample has the wrong share size or its proof opens a different requested coordinate | The sample is rejected instead of exposing malformed or substituted share data. | Sample verification checks the fixed share size and proof interval before checking the DAH root. |
| A sample, row, namespace result, or range proof does not match the DAH | The source is treated as bad data rather than as a normal cache miss. | NMT and row-root verification runs before the getter returns the result. |
| A batch sample request has one failed coordinate | The operation returns an error but keeps successful samples at their original positions. | The getter preserves the result length and leaves the failed position empty. |
| A proof contains more nodes than a supported row tree can produce | Decoding is rejected before padded proof data can cause excessive memory use. | Sample, namespace, and range protobuf conversion checks the maximum proof-node count. |
A requested range has negative indexes or from >= to | No range request is sent. | The public module and cascade validate the half-open range. |
| A namespace is outside the namespace bounds committed by the roots | The request cannot produce valid namespace data. | Root bounds are checked before tree traversal or peer requests. |
| A row root is too short or has invalid namespace bounds | Candidate-row selection fails instead of using unsafe root data. | Root-bound parsing validates the minimum and maximum namespace fields. |
| A peer does not have the requested height | The direct request returns not found and the getter tries another peer or source. | Separate full and archival peer pools plus cooldown handling provide fallback. |
| A peer is chosen from a pool with no measured throughput | The first choice may not reflect the fastest source. | The pool gives unmeasured peers an exploration request and then ranks peers with shared throughput scores. |
| A peer returns an invalid response and its success is counted before verification | A bad peer can gain preference by serving corrupt data quickly. | The getter reports transfer statistics only after the response passes verification. |
| A removed peer has a pending cooldown expiry | A stale timer could restore a peer that no longer belongs to the pool. | Pool membership removal clears queued cooldown state and expiry updates are serialized with pool state. |
| Pool cleanup reads the peer list while peer announcements update it | Cleanup can race with peer insertion or apply invalid-hash action to an inconsistent peer set. | Manager cleanup uses a pool-locked snapshot before it processes the rejected pool's peers. |
| A peer announces too many distinct unvalidated data hashes | The manager could retain untrusted pools until cleanup. | Per-peer unvalidated-pool limits reject excess pool creation and release slots when pools validate or expire. |
| A peer announces a valid hash with a false height | Cleanup can retain the pool past the real storage window. | Header validation overwrites the pool height with the trusted header height. |
| Concurrent discovery workers add more peers than the soft limit | An unsigned peer deficit can wrap and start an oversized discovery pass. | Discovery checks whether the set is already at or above the limit before subtracting the current size. |
| A pubsub notification has an invalid hash, an empty-EDS hash, or height zero | The peer manager does not use the notice to create or validate a data pool. | The topic validator decodes the message and checks height and data-hash validity before callback. |
| Too many distinct axes are requested over time | Older cached axes are evicted and later reads rebuild their shares and proofs. | Separate row and column LRU caches use a bounded per-axis memory budget. |
| A one-off sample misses the proof cache | The read could waste memory by building a full axis for one share. | The accessor serves the sample from the inner source without retaining the axis. |
| A parity half is used while assembling ODS shares | The accumulator can lose its extended-row context and return the wrong share sequence. | The cache retains the full row while selecting its data half. |
| Too few shares arrive for EDS repair | Full retrieval remains incomplete and requests more quadrants or returns failure on cancellation. | Quadrant retrieval waits for enough cells before repair and checks both root axes. |
| An ODS stream ends in the middle of a share | The EDS import fails instead of treating incomplete bytes as valid data. | ReadShares accepts EOF only when the input is share-aligned. |
| A streamed ODS does not rebuild to the expected data hash | The received square is rejected as corrupted or mismatched data. | ReadAccessor and the SHREX EDS response recompute the EDS hash against the DAH. |
| Stream opening stalls or the caller cancels an active request | The request can consume its whole timeout or leave a read blocked. | The client bounds stream opening and resets the stream when the request context ends. |
| An outbound SHREX stream has no explicit outbound allowance | Every outbound request can be rejected as resource exhausted even when local demand is valid. | Each registered SHREX protocol sets an explicit unlimited outbound value; host and peer scopes remain the backstop. |
| SHREX stream or memory limits are exhausted | The request is reset or reported as resource exhausted. | Protocol scope rejects stream bursts early. Service scope reserves response memory and bounds aggregate and per-peer use. |
| A serving accessor is closed while a new read starts | The read returns a closed-accessor error instead of using released storage. | The close-once wrapper makes close idempotent and checks lifetime before each accessor operation. |
| A namespace or range row fails after the response starts | The response fails instead of ending as a valid truncated stream. | Row streams load the next row as needed and preserve non-EOF errors. |
| A range response crosses namespaces | The response is rejected as inconsistent data. | Range streaming checks the namespace of each returned row. |
| EDS reconstruction runs concurrently with an unsafe construction resource | Roots or reconstructed data can differ from the committed square. | The shared construction resource is initialized once and tested against reference roots under concurrency. |
| A server fails while writing a response after sending OK | The client could mistake a truncated payload for a valid response. | The server resets the stream with an internal error code rather than ending with clean EOF. |
| A fuzzed SHWAP container decodes and appears to verify against the wrong coordinates or namespace | Incorrect data could be accepted as a valid sample, row, or namespace result. | Fuzz checks require verified containers to equal the fixture's committed data at the chosen coordinates. |
Key files
| File | Why to read it |
|---|---|
| share/…/getter.go | Defines the source-independent retrieval operations. |
| share/…/accessor.go | Defines the common view used to read EDS data from storage. |
| share/…/sample.go | Shows the verified sample data model and coordinate checks. |
| share/…/sample_test.go | Shows the guarantees for sample proof binding and malformed data rejection. |
| share/…/row.go | Shows row halves and row reconstruction. |
| share/…/row_stream.go | Shows bounded, one-row-at-a-time namespace and range streaming. |
| share/…/row_namespace_data.go | Shows namespace inclusion and absence proofs plus proof-size limits. |
| share/…/range_namespace_data.go | Defines range data, coordinate conversion, and its boundary-proof model. |
| share/…/range_namespace_data_id.go | Shows range validation and row-scoped response construction. |
| share/…/namespace_data_id.go | Shows namespace candidate-row selection and streamed response construction. |
| share/…/cascade.go | Shows how local and network getters compose and how errors affect fallback. |
| share/…/availability.go | Shows sampling-based availability checks. |
| share/…/availability.go | Shows complete EDS recovery as an availability check. |
| share/…/accessor.go | Defines the accessor and streaming contracts for EDS storage. |
| share/…/close_once.go | Defines safe accessor shutdown for concurrent readers. |
| share/…/read.go | Shows row-major ODS import, share-boundary handling, and EDS hash verification. |
| share/…/read_fuzz_test.go | Confirms that accepted EDS streams reproduce the committed square. |
| share/…/rsmt2d.go | Illustrates how an EDS supplies samples, rows, ranges, and streams. |
| share/…/proofs_cache.go | Shows bounded reuse of axis shares and proof nodes without changing range or full-EDS streaming. |
| share/…/proofs_cache_test.go | Shows the cache bound, parity-half share assembly, and the distinction between proof-cache hits and one-off sample reads. |
| share/…/proofs_cache_stream_test.go | Shows that streamed namespace and range responses do not retain rows in the proof cache. |
| share/…/retriever.go | Defines quadrant retrieval and full-square reconstruction. |
| share/…/nmt.go | Defines NMT node shape and the CID mapping used by IPLD retrieval. |
| share/…/add.go | Shows how share data becomes a committed EDS and IPLD tree data. |
| share/…/get.go | Shows leaf retrieval from the IPLD NMT tree. |
| share/…/namespace_data.go | Shows namespace-bounded traversal and proof collection. |
| share/…/eds_id.go | Shows height-based EDS identity and fixed-buffer response streaming. |
| share/…/ids_fuzz_test.go | Checks SHWAP ID wire round trips, validation, and square bounds. |
| share/…/namespace_fuzz_test.go | Checks namespace, range, and JSON row data against committed shares. |
| share/…/shrex.go | Shows direct peer retrieval, positional partial samples, archival routing, peer scoring, and verification. |
| share/…/eds_response.go | Shows deferred EDS reconstruction and hash verification after an ODS stream ends. |
| share/…/client.go | Shows bounded stream setup, context cancellation, status handling, and response reads. |
| share/…/request.go | Defines the common request contract and the SHWAP request registry used by the server. |
| share/…/error.go | Defines the distinction between server, invalid-response, and resource-exhaustion outcomes. |
| share/…/limits.go | Shows the two-tier stream and memory limits for SHREX service and protocol scopes. |
| share/…/server_fuzz_test.go | Checks request decoding, validation, memory sizing, serving, and client verification together. |
| share/…/exchange_test.go | Shows fallback for ODS-only storage, prompt cancellation, and post-OK server read failures. |
| share/…/manager.go | Shows hash-specific peer validation, trusted-height cleanup, discovery fallback, synchronized cleanup, cooldowns, and blacklist actions. |
| share/…/manager_test.go | Shows concurrent cleanup, bounded rejected-hash and unvalidated-pool state, trusted pool heights, and archival discovery behavior. |
| share/…/pool.go | Shows sampled peer selection, pool membership, synchronized snapshots, and cooldown state. |
| share/…/timedqueue.go | Shows timed cooldown expiry and removal handling. |
| share/…/metrics.go | Shows peer-pool and validation metrics for active and cooldown states. |
| share/…/score.go | Shows throughput scoring across peer pools. |
| share/…/pubsub_fuzz_test.go | Checks that only valid, non-empty EDS notifications reach peer logic. |
| share/…/discovery.go | Shows bounded peer discovery, connection handling, and peer-set updates. |
| share/…/discovery_limit_test.go | Shows discovery behavior at the soft peer limit. |
| share/…/server.go | Shows request validation, response streaming, memory reservation, and post-OK stream errors. |
| share/…/containers_fuzz_test.go | Shows that decoded sample, row, and namespace containers must match their committed EDS data. |
| nodebuilder/…/p2p_constructors.go | Shows full and archival discovery, node-role advertisement, and peer-manager wiring. |
| nodebuilder/…/share.go | Shows the public share retrieval and availability surface. |
| nodebuilder/…/get_range_result.go | Shows how range data becomes a client-verifiable result. |