Conversation
| return | ||
| err := sw.DialPeerWithAddress(netAddr, true) | ||
| if err == nil { | ||
| return // success |
There was a problem hiding this comment.
don't you think we should log success path too?
There was a problem hiding this comment.
yes it's logged within the DialPeerWithAddress function.
I wanted to avoid returning the peer because we weren't doing anything except logging it.
So I think it makes sense to let the function log it's success case, but the caller logs the error. Does that make sense or am I being silly ?
There was a problem hiding this comment.
maybe.. but I still think it's important to give user this sequence
[] .... Reconnecting to node A
[] .... Reconnected ...
p2p/switch.go
Outdated
| if err := sw.FilterConnByAddr(addr); err != nil { | ||
| return err | ||
| } | ||
| if err := sw.FilterConnByID(id); err != nil { |
There was a problem hiding this comment.
Have you tried running this with [p2p] auth_enc=false? If it is false, then id will be nil, right? So effectively, filter will not work
There was a problem hiding this comment.
Hmm crap. I think we need some extra work to make this right for AuthEnc=false. We prob dont want the id to be empty, even if it can't be verified, because we use it eg. as a key for the AddrBook. So if we want AddrBook to work with AuthEnc, we need to do something smarter.
OK thanks
| r.Switch.Logger.Info("Connected to seed", "peer", peer) | ||
| err := r.Switch.DialPeerWithAddress(seedAddr, false) | ||
| if err == nil { | ||
| return |
There was a problem hiding this comment.
same comment about logging success path
|
Very clean code ❤️ 💚 💛 but see my comments |
4be5554 to
d8d7944
Compare
if AuthEnc is true, dialed peers must have a node ID in the address and it must match the persistent pubkey from the secret handshake. Refs #1157
``` p2p/pex/pex_reactor_test.go:288:88: cannot use seed.NodeInfo().NetAddress() (type *p2p.NetAddress) as type string in array or slice literal ```
* Introduce `peerConn` containing the known fields of `peer`
* `peer` only created in `sw.addPeer` once handshake is complete and NodeInfo is checked
* Eliminates some mutable variables and makes the code flow better
* Simplifies the `newXxxPeer` funcs
* Use ID instead of PubKey where possible.
* SetPubKeyFilter -> SetIDFilter
* nodeInfo.Validate takes ID
* remove peer.PubKey()
fast_sync failed for 2nd peer. |
``` 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: panic: runtime error: invalid memory address or nil pointer dereference 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x98dd3e] 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: goroutine 3432 [running]: 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: github.com/tendermint/tendermint/p2p.newOutboundPeerConn(0xc423fd1380, 0xc420933e00, 0x1, 0x1239a60, 0 xc420128c40, 0x2, 0x42caf6, 0xc42001f300, 0xc422831d98, 0xc4227951c0, ...) 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #11/go/src/github.com/tendermint/tendermint/p2p/peer.go:123 +0x31e 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: github.com/tendermint/tendermint/p2p.(*Switch).addOutboundPeerWithConfig(0xc4200ad040, 0xc423fd1380, 0 xc420933e00, 0xc423f48801, 0x28, 0x2) 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #11/go/src/github.com/tendermint/tendermint/p2p/switch.go:455 +0x12b 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: github.com/tendermint/tendermint/p2p.(*Switch).DialPeerWithAddress(0xc4200ad040, 0xc423fd1380, 0x1, 0x 0, 0x0) 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #11/go/src/github.com/tendermint/tendermint/p2p/switch.go:371 +0xdc 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: github.com/tendermint/tendermint/p2p.(*Switch).reconnectToPeer(0xc4200ad040, 0x123e000, 0xc42007bb00) 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #11/go/src/github.com/tendermint/tendermint/p2p/switch.go:290 +0x25f 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: created by github.com/tendermint/tendermint/p2p.(*Switch).StopPeerForError 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #11/go/src/github.com/tendermint/tendermint/p2p/switch.go:256 +0x1b7 ```
Codecov Report
@@ Coverage Diff @@
## develop #1226 +/- ##
==========================================
+ Coverage 59.49% 59.69% +0.2%
==========================================
Files 121 122 +1
Lines 11046 11047 +1
==========================================
+ Hits 6572 6595 +23
+ Misses 3863 3846 -17
+ Partials 611 606 -5 |
| pc, err = newPeerConn(conn, config, true, persistent, ourNodePrivKey) | ||
| if err != nil { | ||
| if err2 := conn.Close(); err != nil { | ||
| if err2 := conn.Close(); err2 != nil { |
There was a problem hiding this comment.
is there a good paradigm/tactic we can use to avoid this kind of thing ?
There was a problem hiding this comment.
always use err? metalinter?
* CV OnStop close evidenceStore * CV OnStop print db close * CV add changelog * CV update changelog with attribution (cherry picked from commit 48335a0) Co-authored-by: Chill Validation <92176880+chillyvee@users.noreply.github.com>
peerConncontaining the known fields ofpeerpeeronly created insw.addPeeronce handshake is complete and NodeInfo is checkednewXxxPeerfuncs* SetPubKeyFilter -> SetIDFilter
* nodeInfo.Validate takes no args
* remove peer.PubKey()