From 56459c6c639b72706e1b490f8c22c71a4e2dd27b Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 17 Oct 2019 11:19:24 +0300 Subject: [PATCH 1/2] network: remove port check from handleVersionCmd() It's bogus and no other node implementation has anything like that. It fires up for no good reason in the case when some other node connects to us and it obviously doesn't use its listening port for it. --- pkg/network/server.go | 3 --- pkg/network/server_test.go | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/pkg/network/server.go b/pkg/network/server.go index 039c8a01d..7f04e9d9a 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -252,9 +252,6 @@ func (s *Server) handleVersionCmd(p Peer, version *payload.Version) error { if s.id == version.Nonce { return errIdenticalID } - if p.NetAddr().Port != int(version.Port) { - return fmt.Errorf("port mismatch: connected to %d and peer sends %d", p.NetAddr().Port, version.Port) - } return p.SendVersionAck(NewMessage(s.Net, CMDVerack, nil)) } diff --git a/pkg/network/server_test.go b/pkg/network/server_test.go index 7d96b7989..b24205460 100644 --- a/pkg/network/server_test.go +++ b/pkg/network/server_test.go @@ -67,15 +67,9 @@ func TestServerNotSendsVerack(t *testing.T) { p.netaddr = *na s.register <- p - // Port should mismatch - version := payload.NewVersion(1337, 2000, "/NEO-GO/", 0, true) - err := s.handleVersionCmd(p, version) - assert.NotNil(t, err) - assert.Contains(t, err.Error(), "port mismatch") - // identical id's - version = payload.NewVersion(1, 3000, "/NEO-GO/", 0, true) - err = s.handleVersionCmd(p, version) + version := payload.NewVersion(1, 3000, "/NEO-GO/", 0, true) + err := s.handleVersionCmd(p, version) assert.NotNil(t, err) assert.Equal(t, errIdenticalID, err) } From 3f6104ef4da5cb7624d1d7ce8b13289bd8f895d4 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 17 Oct 2019 11:28:58 +0300 Subject: [PATCH 2/2] network: ignore consensus messages It's a temporary stub until proper encoding/decoding is implemented. It's useful for testnet/mainnet connections because without it consensus message receival leads to peer disconnection. --- pkg/network/message.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/network/message.go b/pkg/network/message.go index 187c7c9d9..b66aeaf78 100644 --- a/pkg/network/message.go +++ b/pkg/network/message.go @@ -184,6 +184,9 @@ func (m *Message) decodePayload(br *io.BinReader) error { p = &payload.AddressList{} case CMDBlock: p = &core.Block{} + case CMDConsensus: + // Stubbed out for now, see #431. + return nil case CMDGetBlocks: fallthrough case CMDGetHeaders: