Skip to content

Conversation

@nugaon
Copy link
Member

@nugaon nugaon commented Aug 19, 2025

This SWIP describes a more efficient way to synchronise content between peers in the same neighbourhood by syncing each chunk only once.
It removed the maxPOdelta exception for syncing bins from peers below storage depth. Accordingly, bee should not allow shallow receipts on pushing chunks. That should be tackled in a different PR.

Forwarding chunks to the closest address on the network is also required since chunks will be pulled from its closest full nodes.

This is the implementation of SWIP 25 for details check the proposal.

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

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

@nugaon nugaon marked this pull request as ready for review September 8, 2025 16:38
@nugaon nugaon changed the title feat(swip25): uniqueness depth and pull syncing feat(swip25): pull syncing optimalization Sep 8, 2025
@martinconic martinconic requested a review from janos September 10, 2025 14:25
@martinconic martinconic changed the title feat(swip25): pull syncing optimalization feat(swip25): pull syncing optimization Sep 10, 2025
}
p.logger.Debug("radius decrease", "old_radius", prevRadius, "new_radius", newRadius)
}
changed := newRadius != prevRadius
Copy link
Contributor

Choose a reason for hiding this comment

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

can you rename please this to something like radiusChanged or rChanged. It would be easier to figure out in the code what is this boolean all about.

Copy link
Member Author

Choose a reason for hiding this comment

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

it is related to that the parameters for the pulling have changed that partially includes the radius change but also when a new peer is conencted to the node and that is a neighbor or a neighbor node is disconnected.

if err != nil {
// cannot go further in the binary representation, override leaf
if t.V != nil && !bytes.Equal(t.K, key) {
panic(errShouldNeverHappen)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want panics or should we use errors? Same bellow

Copy link
Member Author

Choose a reason for hiding this comment

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

the tree must be used with the prerequisites defined in the errShouldNeverHappen. If there is an error, no recovery should or can happen on these special cases indicating a significant bug in the logic. in such case, it seems better to panic.

// TreeNode is a leaf compacted binary tree
// representing the address space of the neighborhood
type TreeNode[T any] struct {
K []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there cases were we would need concurrency suport via a mutex?

Copy link
Member Author

Choose a reason for hiding this comment

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

there is no concurrent use of TreeNode at the moment so it does not require any concurrency handling for now

func (t *peerTreeNode) BinAssignment() (peers []*peerTreeNodeValue) {
if t.isLeaf() {
bl := uint8(len(t.V.SyncBins))
for i := t.L; i < bl; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if t.L > bl ?

syncPeer.syncBins = make([]bool, p.bins)
}
if po >= newRadius {
_ = bt.Put(addr.Bytes(), &peerTreeNodeValue{SyncBins: syncPeer.syncBins})
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we do not have also here changed = true ?

Copy link
Member Author

Choose a reason for hiding this comment

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

because at this point the pullsync parameters may have not changed to reinit syncings but you want to build up the tree with the neighbor peers in case there was a change in the neighborhood peerset eventually.

@bcsorvasi bcsorvasi added this to the v2.7.0 milestone Oct 7, 2025
@bcsorvasi bcsorvasi added bug Something isn't working and removed bug Something isn't working labels Oct 7, 2025
@bcsorvasi bcsorvasi assigned janos and unassigned janos Oct 7, 2025
@bcsorvasi bcsorvasi modified the milestones: v2.7.0, 1.13.0 Oct 10, 2025
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.

4 participants