-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Conversation
Conflicts: libp2p/NodeTable.cpp
unsigned ts; | ||
NodeIPEndpoint source; | ||
NodeIPEndpoint destination; | ||
uint32_t ts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not always initialized.
Are there tests for ipv6? |
@chriseth simple IPv6 goes in after this is working, where simple means that only IPv4 or IPv6 is supposed (not both at once). It's supported by encapsulation but because the listener doesn't support IPv6 such nodes are simply not added to the table. IPv6 was removed previously because some changes are needed:
|
… initial values for packet timestamps.
This is not interoperable with go-ethereum (this branch) because IP addresses are encoded as RLP lists.
The ping packets sent by Go look like this:
The ones sent by C++ look like this:
|
@@ -177,6 +185,9 @@ struct NodeIPEndpoint | |||
operator bool() const { return !address.is_unspecified() && udpPort > 0 && tcpPort > 0; } | |||
|
|||
bool isAllowed() const { return NodeIPEndpoint::test_allowLocal ? !address.is_unspecified() : isPublicAddress(address); } | |||
|
|||
void streamRLP(RLPStream& _s, RLPAppend _inline = StreamList) const { if (_inline == StreamList) _s.appendList(3); if (address.is_v4()) _s << address.to_v4().to_bytes(); else if (address.is_v6()) _s << address.to_v6().to_bytes(); else _s << ""; _s << udpPort << tcpPort; } | |||
void interpretRLP(RLP const& _r) { if (_r[0].size() == 0) address = bi::address(); else if (_r[0].size() == 4) address = bi::address_v4(_r[0].toArray<byte, 4>()); else address = bi::address_v6(_r[0].toArray<byte, 16>()); udpPort = _r[1].toInt<uint16_t>(); tcpPort = _r[2].toInt<uint16_t>(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistic issues aside (296 characters in a line, including a three-way braceless conditional, oh my), there seems to be some confusion about the type of input here.
size()
only works for RLP strings and returns 0 otherwise, yet toArray()
is used, which only works for lists. If IP addresses are supposed to be represented as lists maybe this should switch on itemCount()
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fjl Byte string makes sense. Is that supported by Go?
ret.push_back(n); | ||
return move(ret); | ||
} | ||
|
||
void NodeTable::ping(bi::udp::endpoint _to) const | ||
void NodeTable::ping(NodeIPEndpoint _to) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const&
?
code looks reasonable - as long as this is 100% compatible with Go, it looksgood. |
The RLP encoding of pong is missing the destination endpoint: @@ -330,8 +330,8 @@ struct Pong: RLPXDatagram<Pong>
h256 echo; ///< MCD of PingNode
uint32_t ts = 0;
- void streamRLP(RLPStream& _s) const { _s.appendList(2); _s << echo << ts; }
- void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); echo = (h256)r[0]; ts = r[1].toInt<uint32_t>(); }
+ void streamRLP(RLPStream& _s) const { _s.appendList(3); destination.streamRLP(_s); _s << echo << ts; }
+ void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); destination.interpretRLP(r[0]); echo = (h256)r[1]; ts = r[2].toInt<uint32_t>(); }
};
/** |
With the pong encoding fixed, we are interoperable once again. |
Is the sha3 distance going to be part of this PR? |
@fjl Nice catch. How'd you create a comment like that? |
I pasted the diff and put |
I tested again, the ping/pong seems to work (geth is accepting a pong sent by cpp). It looks like eth crashed after ~15seconds. The nodes exchanged blocks before the crash. Trace here: https://gist.github.com/fjl/f08e36c5d4026f37085c |
I have tested this again. The crash is no longer happening and cpp responds to findnode if it has nodes in the table. |
Conflicts: libp2p/Host.cpp libp2p/NodeTable.cpp libp2p/NodeTable.h
…ferencing shared pointer from weak ptr without verifying weak ptr).
add additional port to discovery endpoint encapsulation #1557, update ping and pong packets #1558