Skip to content

feat(pushsync): remember first hop results per neighborhood - #5710

Draft
gacevicljubisa wants to merge 18 commits into
fix/pushsync-out-of-depth-chunk-lossfrom
feat/pushsync-first-hop-memory-mainnet
Draft

gacevicljubisa wants to merge 18 commits into
fix/pushsync-out-of-depth-chunk-lossfrom
feat/pushsync-first-hop-memory-mainnet

Conversation

@gacevicljubisa

@gacevicljubisa gacevicljubisa commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have added or updated fuzz targets for any code handling untrusted input.
  • I have filled out the description and linked the related issues.

Description

This PR is stacked on #5390. The base branch is fix/pushsync-out-of-depth-chunk-loss, so the diff shows only the changes below. It has two changes.

1. Pushsync origin: first-hop memory (pkg/pushsync/hopmemory.go, pkg/pushsync/pushsync.go)

With #5390 the origin retries a chunk when it gets a shallow receipt. Each shallow receipt is paid. For the next chunk of the same neighborhood, the origin often selects the same first hop and pays for the same shallow receipt again.

The origin now keeps, per neighborhood (the chunk addresses that share the first radius bits), the last result of each first hop:

  • A first hop that gave a valid receipt is preferred for the next chunks of that neighborhood.
  • A first hop that gave a shallow receipt is paused for that neighborhood for 1 minute. The pause doubles with each shallow receipt in a row, up to 30 minutes.
  • At most once per 30 seconds per neighborhood, the origin sends one chunk to a peer that is closer to the chunk than the peers with a valid record, so that a better first hop can be found.
  • When all peers that are left for a chunk are paused, the origin sends through the peer whose pause ends first. An origin that is inside the neighborhood stores the chunk itself.
  • Records without a new result are removed after 30 minutes (valid) or 60 minutes (shallow), in all neighborhoods. All records are removed when the storage radius changes.

Only the origin changes. Forwarders and the protocol do not change. The memory is not stored on disk. The new metric first_hop_total counts the results by the reason the first hop was selected.

2. Retrieval: the closest reachable peer, without the health mark (pkg/retrieval/retrieval.go)

closestPeer asked a healthy peer first, at any distance from the chunk. A healthy peer that is far from the chunk was asked before a closer peer that was not marked healthy. The request then used its attempts on far peers and the chunk was not retrieved.

closestPeer now selects the closest reachable peer and does not use the health mark. When no reachable peer is left, it selects the closest connected peer. It applies to the origin and to forwarders.

Known limitations

  • A push reads the storage radius once, when it starts. A push that started before a radius change can remove the records of the new radius when it selects its next peer. The memory is then empty for a short time; no chunk is lost.
  • Retrieval does not retrieve a chunk that only unreachable nodes hold. This is the same on master.

Motivation and Context

Measurement Without the change With the change
Mainnet uploads, shallow receipts per 100 chunks 23–65 1–6
Simulator, 4,500 nodes, storage radius 10, shallow receipts per 100 chunks 31.2 2.2
Simulator, 1,000 nodes, 24,609 chunks, chunks not retrieved by the first request 14,949 0
  • Mainnet, change 1: in the 100 MB uploads with the memory, every chunk synced and the upload cost was 0.069–0.080 BZZ, against 0.104 BZZ without the memory.
  • Mainnet, change 2: the download node retrieved a 100 MB file in one request in three runs. An earlier version of the change, which kept the health mark as the decision between peers of the same proximity order, gave the same number of requests to peers, download time and cost, within the difference between runs.
  • Test network, both changes on all 20 nodes: 24 files of 4 MB uploaded and downloaded, every chunk synced and every download matched its SHA-256, also after the records expired. All nodes there have the same storage radius, so this network gives no shallow receipts and shows no saving.
  • Simulator, change 2: the retrieval row uses health marks that every node sees the same, so the absolute numbers do not apply to mainnet. With the change only at the origin, 5,500 to 15,000 of the 24,609 chunks were still not retrieved, so the forwarder part is necessary. It cannot be measured on mainnet, because the forwarders of other operators cannot be changed.
  • The simulator is on the branch pushsim. It is not part of this PR.

Related Issue (Optional)

Depends on #5390.

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.

@gacevicljubisa
gacevicljubisa force-pushed the feat/pushsync-first-hop-memory-mainnet branch from ff06964 to b3e76f3 Compare November 19, 2026 07:19
@gacevicljubisa
gacevicljubisa marked this pull request as ready for review November 19, 2026 13:07
@gacevicljubisa
gacevicljubisa requested review from acud and janos November 19, 2026 13:08
@gacevicljubisa
gacevicljubisa marked this pull request as draft November 20, 2026 19:42

This branch has not been deployed

No deployments
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.

1 participant