Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

proxbin evaluation in kademlia.Each* is incorrect #1042

Closed
nolash opened this issue Dec 3, 2018 · 0 comments · Fixed by ethereum/go-ethereum#18239
Closed

proxbin evaluation in kademlia.Each* is incorrect #1042

nolash opened this issue Dec 3, 2018 · 0 comments · Fixed by ethereum/go-ethereum#18239
Assignees
Labels

Comments

@nolash
Copy link
Contributor

nolash commented Dec 3, 2018

func (k *Kademlia) eachConn(base []byte, o int, f func(*Peer, int, bool) bool) {
        if len(base) == 0 {
                base = k.base
        }
        depth := depthForPot(k.conns, k.MinProxBinSize, k.base)
        k.conns.EachNeighbour(base, pof, func(val pot.Val, po int) bool {
                if po > o {
                        return true
                }
                return f(val.(*Peer), po, po >= depth)
        })
}

where in f func(*Peer, int, bool) the second parameter is po and the third isProxBin.

The depth is a property in relation to k.base - the base address of the kademlia.

However, the po compared to this depth to determine whether or not the Peer is in the proxbin (nearest neighbour) of the base of the kademlia is effectively the po between the passed base and the peer.

If the po of passed base in relation to Peer is higher than depth, the Peer can be erroneously be returned as a nearest neighbor.

Additionally, this raises the question of which assumptions have been made for the behavior of this function by the code that uses it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants