Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ca7c13b
swarm/pss: forwarding function refactoring (#18353)
gluk256 Dec 21, 2018
064e72f
swarm/network: Revised depth calculation with tests
nolash Dec 12, 2018
a1db6ca
swarm/network: WIP remove redundant "full" function
nolash Dec 12, 2018
be6ded9
swarm/network: WIP peerpot refactor
nolash Dec 14, 2018
d3885dd
swarm/network: Make test methods submethod of peerpot and embed kad
nolash Dec 14, 2018
bd70cc7
swarm/network: Remove commented out code
nolash Dec 14, 2018
c332482
swarm/network: Rename health test functions
nolash Dec 14, 2018
2370532
swarm/network: Too many n's
nolash Dec 14, 2018
bdbbb83
swarm/network: Change hive Healthy func to accept addresses
nolash Dec 17, 2018
55bdd3d
swarm/network: Add Healthy proxy method for api in hive
nolash Dec 17, 2018
1f2edfb
swarm/network: Skip failing test out of scope for PR
nolash Dec 17, 2018
ff3dabf
swarm/network: Skip all tests dependent on SuggestPeers
nolash Dec 17, 2018
b7d9e51
swarm/network: Remove commented code and useless kad Pof member
nolash Dec 17, 2018
e28a789
swarm/network: Remove more unused code, add counter on depth test errors
nolash Dec 17, 2018
c735ad3
swarm/network: WIP Create Healthy assertion tests
nolash Dec 17, 2018
306640b
swarm/network: Roll back health related methods receiver change
nolash Dec 17, 2018
8f59376
swarm/network: Hardwire network minproxbinsize in swarm sim
nolash Dec 17, 2018
d309a8d
swarm/network: Rework Health test to strict
nolash Dec 17, 2018
e6da789
swarm/network: Skip discovery tests (dependent on SuggestPeer)
nolash Dec 17, 2018
e60cc34
swarm/network: Remove useless minProxBinSize in stream
nolash Dec 18, 2018
e0b9f40
swarm/network: Remove unnecessary testing.T param to assert health
nolash Dec 19, 2018
ec2d5e3
swarm/network: Implement t.Helper() in checkHealth
nolash Dec 19, 2018
a7531d3
swarm/network: Rename check back to assert now that we have helper magic
nolash Dec 19, 2018
ce8de34
swarm/network: Revert WaitTillHealthy change (deferred to nxt PR)
nolash Dec 20, 2018
22096cc
swarm/network: Kademlia tests GotNN => ConnectNN
nolash Dec 20, 2018
43de85e
swarm/network: Renames and comments
nolash Dec 20, 2018
bd3ad21
swarm/network: Add comments
nolash Dec 21, 2018
f1b143b
swarm/network: Make minproxbinsize constant throughout simulation
nolash Dec 20, 2018
2c35a8f
swarm/network: Add evaluation of potential conncetions in health testing
nolash Dec 18, 2018
200bfdf
swarm/network: Add comment to new connectedPotential function
nolash Dec 18, 2018
de57c00
swarm/network: Rename Got to Connect
nolash Dec 18, 2018
eba2613
swarm/network: Finish basic test cases for potent
nolash Dec 19, 2018
a627947
swarm/network: Cherrypick saturation, potency test adds from wrong br…
nolash Dec 19, 2018
b5cb505
swarm/network: Use assert and t helper on all health tests
nolash Dec 19, 2018
72dae51
swarm/network: Cleanup after rebase on upstream cosmetic changes
nolash Dec 20, 2018
d0d6a41
swarm/network: Add evaluation of potential conncetions in health testing
nolash Dec 18, 2018
c1129ff
swarm/network: Remove reachable, maxpeers + add simple peer verify in…
nolash Dec 20, 2018
d9f81ee
swarm/network: WIP rebase on upstream cosmetics
nolash Dec 20, 2018
7f353d5
swarm/network: Last rebase fix after cosmetics
nolash Dec 20, 2018
5810e65
swarm/network: Add Connected/Known test lost after rebasing
nolash Dec 20, 2018
6c75f1b
swarm/network: WIP connection driver related components from kad to hive
nolash Dec 21, 2018
5ce60da
swarm/network: Factor out peers table, decompose suggest peer parts
nolash Dec 21, 2018
592bb4d
swarm/network: Correct upper iteration abstraction for callable peers
nolash Dec 21, 2018
2f83537
swarm/network: Add topmost aggregator for peer suggestion
nolash Dec 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion p2p/simulations/adapters/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type NodeConfig struct {
Services []string

// function to sanction or prevent suggesting a peer
Reachable func(id enode.ID) bool
// Reachable func(id enode.ID) bool

Port uint16
}
Expand Down
18 changes: 9 additions & 9 deletions p2p/simulations/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ func (net *Network) NewNodeWithConfig(conf *adapters.NodeConfig) (*Node, error)
net.lock.Lock()
defer net.lock.Unlock()

if conf.Reachable == nil {
conf.Reachable = func(otherID enode.ID) bool {
_, err := net.InitConn(conf.ID, otherID)
if err != nil && bytes.Compare(conf.ID.Bytes(), otherID.Bytes()) < 0 {
return false
}
return true
}
}
// if conf.Reachable == nil {
// conf.Reachable = func(otherID enode.ID) bool {
// _, err := net.InitConn(conf.ID, otherID)
// if err != nil && bytes.Compare(conf.ID.Bytes(), otherID.Bytes()) < 0 {
// return false
// }
// return true
// }
// }

// check the node doesn't already exist
if node := net.getNode(conf.ID); node != nil {
Expand Down
39 changes: 32 additions & 7 deletions swarm/network/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,58 @@ import (
"context"
"fmt"
"sync"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/swarm/pot"
)

// discovery bzz extension for requesting and relaying node address records

// encapsulates connectivity information related to discovery mechanics
type connectivity struct {
seenAt time.Time
retries int
depth uint8
}

// encapsulates peer information exchange related to discovery mechanics
type exchange struct {
sentPeers bool // whether we already sent peer closer to this address
peers map[string]bool // tracks node records sent to the peer
}

// Peer wraps BzzPeer and embeds Kademlia overlay connectivity driver
type Peer struct {
*BzzPeer
kad *Kademlia
sentPeers bool // whether we already sent peer closer to this address
mtx sync.RWMutex //
peers map[string]bool // tracks node records sent to the peer
depth uint8 // the proximity order advertised by remote as depth of saturation
*connectivity
*exchange
kad *Kademlia
mtx sync.RWMutex
up bool
}

// NewPeer constructs a discovery peer
func NewPeer(p *BzzPeer, kad *Kademlia) *Peer {
d := &Peer{
exchange: &exchange{
peers: make(map[string]bool),
},
kad: kad,
BzzPeer: p,
peers: make(map[string]bool),
}
// record remote as seen so we never send a peer its own record
d.seen(p.BzzAddr)
return d
}

// Label is a short tag for the entry for debug
// TODO: move this to common utility function
func Label(d pot.BytesAddress) string {
//return fmt.Sprintf("%s (%d)", common.Bytes2Hex(d.Address())[:4]) //, d.retries)
return fmt.Sprintf("%s", common.Bytes2Hex(d.Address())[:4])
}

// HandleMsg is the message handler that delegates incoming messages
func (d *Peer) HandleMsg(ctx context.Context, msg interface{}) error {
switch msg := msg.(type) {
Expand All @@ -64,6 +88,7 @@ func (d *Peer) HandleMsg(ctx context.Context, msg interface{}) error {
}

// NotifyDepth sends a message to all connections if depth of saturation is changed
// TODO rename depth to unambiguous term and make sure cast properly from source throughout (ideally not cast)
func NotifyDepth(depth uint8, kad *Kademlia) {
f := func(val *Peer, po int, _ bool) bool {
val.NotifyDepth(depth)
Expand Down Expand Up @@ -161,7 +186,7 @@ func (d *Peer) handleSubPeersMsg(msg *subPeersMsg) error {
d.setDepth(msg.Depth)
var peers []*BzzAddr
d.kad.EachConn(d.Over(), 255, func(p *Peer, po int, isproxbin bool) bool {
if pob, _ := pof(d, d.kad.BaseAddr(), 0); pob > po {
if pob, _ := Pof(d, d.kad.BaseAddr(), 0); pob > po {
return false
}
if !d.seen(p.BzzAddr) {
Expand Down
Loading