Skip to content

feat(pushsync): forward chunk after storing - #5081

Closed
acha-bill wants to merge 14 commits into
masterfrom
fix/pushsync
Closed

feat(pushsync): forward chunk after storing#5081
acha-bill wants to merge 14 commits into
masterfrom
fix/pushsync

Conversation

@acha-bill

@acha-bill acha-bill commented Apr 23, 2025

Copy link
Copy Markdown
Contributor

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 filled out the description and linked the related issues.

Description

Currently, we return from pushsync as soon as node lands in a neighborhood and is stored by the first node which is not necessarily the closest to the chunk. One effect of this is that gsoc does not work reliably with pushsync as the listening node does not receive the chunk.

In this PR, the in-neighborhood node will forward the chunk to its closest peer after storing it.
Also, a node will multiplex only if the node is not in AOR to prevent circular pushes. So it's 1 extra push from before.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

fixes #5067

Screenshots (if appropriate):

Comment thread pkg/pushsync/pushsync.go
// act as the multiplexer and push the chunk in parallel to multiple peers
if swarm.Proximity(peer.Bytes(), ch.Address().Bytes()) >= rad {
if swarm.Proximity(peer.Bytes(), ch.Address().Bytes()) >= rad &&
swarm.Proximity(ps.address.Bytes(), ch.Address().Bytes()) < rad {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change in logic should be formally validated, either by a regression unit test or an integration test.

I would suggest that the research team evaluates this logic change as well as the change #5037 that allegedly caused the issue.

From the technical point of view, regression test is missing, but it is just as important to have an approval from the research.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enhanced test

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zelig @significance your input about these changes please

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acha-bill we discussed this a little in research sync, could you give us a little extra commentary on what's going on here and amend the comment please dude? just so we are sure we're all on the same page

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amended the descr

Comment thread pkg/pushsync/pushsync_test.go

@nugaon nugaon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a test case may be needed where peers pass the chunk to node with addr 71 and that is in connection with node 70 and in the same neighborhood. node 71 should forward the chunk to node 70 since that is the closest to the chunk address.

Comment thread pkg/pushsync/pushsync_test.go Outdated
Comment thread pkg/pushsync/pushsync_test.go Outdated
Comment thread pkg/pushsync/pushsync_test.go Outdated
@acha-bill acha-bill changed the title fix: cascading pushsync requests feat(pushsync): forward chunk after storing Jul 28, 2025
@acha-bill
acha-bill marked this pull request as ready for review July 28, 2025 15:52
@acha-bill

Copy link
Copy Markdown
Contributor Author

a test case may be needed where peers pass the chunk to node with addr 71 and that is in connection with node 70 and in the same neighborhood. node 71 should forward the chunk to node 70 since that is the closest to the chunk address.

It was already tested in the other PR.
I've brought those changes here now.

@nugaon
nugaon self-requested a review July 30, 2025 12:22

@nugaon nugaon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

closestPeer := swarm.MustParseHexAddress("70")
closestPeer1 := swarm.MustParseHexAddress("72")

psClosestPeer, closestPeerStorer, closestAccounting := createPushSyncNode(t, closestPeer, defaultPrices, nil, nil, defaultSigner(chunk), mock.WithClosestPeerErr(topology.ErrWantSelf))

@nugaon nugaon Jul 30, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ErrWantSelf mocking is strange, it should work without that by setting neighbor peers that may return this error.

recorder1 := streamtest.New(streamtest.WithProtocols(psClosestPeer.Protocol()), streamtest.WithBaseAddr(pivotPeer))

// pivot connects to closestpeer and closestpeer1 but should only forward once to closestpeer after storing
// closestpeer should not forward the chunk to closestpeer1 as it is already the closest peer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyway it cannot, because it does not have peers defined.

Comment thread pkg/pushsync/pushsync.go
return
}

ps.logger.Debug("chunk sent", "chunk_address", ch.Address().String(), "peer_address", peer)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be handy on manual test, also shallow receipt logs should be checked.

@gacevicljubisa
gacevicljubisa requested review from sbackend123 and removed request for istae August 14, 2025 12:26
@martinconic

Copy link
Copy Markdown
Contributor

LGTM , but needs more testing

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.

Out of control request cascading in pushsync in-neighborhood phase

9 participants