-
Notifications
You must be signed in to change notification settings - Fork 20.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cademlia and p2p peer pool (please dont merge) #253
Conversation
Conflicts: p2p/server.go
- SuggestPeer lookup convenience method from backend to server - now takes (host, pubkey) arguments - earlier suggest peer -> AddPeer which now calls the peer selector - delete peer_util (save, restore functionality belongs to peer selector) - peerRecord implements peerInfo (a record entry object for peer info) - introduce lastActive timestamping via the protocol pingpong loop - instead of connect channel, peer simply takes 2 functions (addPeer, getPeers) this is inline with blockPool etc - protocol.PeerList now many phases (server gives active peers including own address, selector proximity peers, and protocol filters for recipient peer and does encoding) - fix and simplify peer_selector
Conflicts: p2p/protocol.go p2p/protocol_test.go
…te file - maybe should be in a different package...
- peerInfo interface has Disconnect(Reason) func only - peerSelector.AddPeer returns boolean only (for acceptance); all connection is managed by the server - peerSelector.GetPeers returns peer objects remove cademlia implementation into a different file
- get rid of dialLoop entirely - get rid of peerConnect channel in favour of simple function call - server handles the peerSelector hook for prospective outbound peers - no need for NoDial anymore really - changed how peer is initialised
- changed peer initialisation (now peer can be just a record) - peer.Addr (always listening address) - peer.Hash() memoized hash of the address (pubkey from dialaddr or listenaddr) - LastActive updates with channel - ActiveAddresses convenience filter method returns addresses of all connected peers
- connectFunc on server, by default it calles srv.connect(peer, conn) - srv.connect(peer, conn) is the init code from peer - this still provides a nice hook for testing - adapt server and peer tests
…on peer - keep missing, mismatch and invalid pubkey errors to errPubkeyInvalid -> DiscInvalidIdentity - introduce errBlacklistedPeer, errSelfConnection, errConnectedPeer, errRejectedPeer -> DiscUselessPeer - peer.pubkeyHook -> peer.verifyPeerHook - peer.verifyPeerHook called on peer by protocol after handshake info set - peer.Pubkey looks into identity.Pubkey too (redundant though)
- after handshake when nodeID is known - part of verifyPeerHook - peerSelector.AddPeer now returns error
- parameter are Cademlia public fields - compulsory Hash, verifiable HashBits, Hash, RowLength, adjustable MaxAge, PurgeInterval, ProxSize - they default to package level constants and vars - row initialisation - adjustProx, updateProx to 'update depth' - proper global locking thanks to Prox - map from entries to peerInfo for GetPeers - call disconnect on the worst peer expunged when inserting - locking for purge - extract self.Distance <- self.DistanceTo (made public method) - call disconnect when purging
- distance -> proximity - proximity bin properly implemented - fix update and adjust prox functions - rename fields and methods - comments
We had a long conversation and arrived at this. This is probably not going to be implemented, let's remember it for the future. The idea is that we maintain a protocol-specific rating of peers in peer pools. We already The What needs to be solved (which is also a general open question in the ethereum project) is type Peer interface {
Addr() net.Addr
Pubkey() []byte
LastActive() time.Time
}
type PeerPool interface {
// AddPeer adds knowledge about a peer to the pool.
// The pool should check whether this peer is
// good and return an error if it considers
// the peer unsuitable.
AddPeer(Peer) error
// GoodPeers fills the peers slice with suggestions
// of peers that should be connected to, in order
// of their goodness.
// It returns the number of peers written.
GoodPeers(peers []Peer) (n int)
}
type Protocol struct {
Name string
// ...and the other fields
// PeerPool is the peer selection algorithm for
// the protocol. It may be nil if the protocol
// does not prefer a particular algorithm.
PeerPool
} |
Cademlia on wiki https://github.com/ethereum/wiki/wiki/Cademlia-Peer-Selection |
…dation tiny fix M2 duplicate sign a block
* add web3 extension for dccs * Update internal/web3ext/web3ext.go * Update internal/web3ext/web3ext.go
fix hex-based inputs in TestUnMarshalHexOrDecimal64
…otone-update-mar-14 Update Ecotone mainnet activation to Mar 14 00:00:01 UTC
initial untested commit for review @fjl
further architecture design coming in a comment