Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

libp2p: EIP-8 changes #46

Merged
merged 5 commits into from
Feb 17, 2016
Merged

libp2p: EIP-8 changes #46

merged 5 commits into from
Feb 17, 2016

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Jan 13, 2016

@fjl fjl force-pushed the p2p-eip8 branch 2 times, most recently from 10a5051 to fd0804d Compare January 13, 2016 01:07
@subtly
Copy link
Member

subtly commented Jan 13, 2016

Presents!

@@ -194,6 +194,15 @@ class NodeIPEndpoint
operator bool() const { return !address.is_unspecified() && udpPort > 0 && tcpPort > 0; }

bool isAllowed() const { return NodeIPEndpoint::test_allowLocal ? !address.is_unspecified() : isPublicAddress(address); }

bool operator==(const NodeIPEndpoint rhs) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NodeIPEndpoint const& _cmp. Whitespace can be removed in header (single line function).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the line breaks for better readability if the line would be longer than 100 characters.

try {
RLP rlp(rlpBytes);
switch (packetType)
auto packet = DiscoveryDatagram::interpretUDP(_from, _packet);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove DRY from this PR and submit in a future PR, or, leave DRY in and submit functional changes in a separate PR.

@subtly
Copy link
Member

subtly commented Jan 13, 2016

In the C++ codebase, especially in the networking code, we do not review PRs which mix semantic and functional changes into a PR as it's too difficult to effectively review changes.

Moreover, this class does not throw exceptions and logs have been removed. Please revert these as requested. Otherwise, please create github issues, assign them to me, and notify me – I will happily make the changes requested. In particular, I've really been meaning to refactor the nearestNodeEntries function (it was thrown together in a few days to make the PoC release).

@fjl fjl force-pushed the p2p-eip8 branch 8 times, most recently from 31c14a5 to 8d34e97 Compare January 18, 2016 15:05
@@ -98,20 +98,25 @@ bytes ReputationManager::data(Session const& _s, std::string const& _sub) const
return bytes();
}

Host::Host(std::string const& _clientVersion, NetworkPreferences const& _n, bytesConstRef _restoreNetwork):
Host::Host(std::string const& _clientVersion, KeyPair _alias, NetworkPreferences const& _n):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyPair const&?

@chriseth
Copy link
Contributor

chriseth commented Feb 3, 2016

As already discussed, please change the exceptions while interpreting the packet to direct logging (potentially using a helper function) plus returning an empty unique ptr.

@chriseth
Copy link
Contributor

@fjl ah, ok, now I get why you want to use RLP:AllowNonCanon, will have a look.

@@ -77,6 +77,9 @@ using AddressHash = std::unordered_set<h160>;
/// A vector of secrets.
using Secrets = std::vector<Secret>;

/// Amount of bytes added when encrypting with encryptECIES.
static const unsigned c_eciesOverhead = 113;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file seems a bit too generic for this protocol detail. Can we move it somewhere else?

@fjl fjl changed the title libp2p: EIP-8 changes (WIP) libp2p: EIP-8 changes Feb 12, 2016
@fjl
Copy link
Contributor Author

fjl commented Feb 12, 2016

PTAL


// These two are set for inbound packets only.
NodeID sourceid;
h256 echo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does echo mean?

@chriseth
Copy link
Contributor

Only minor things left apart from the randomness issue:
AFAIK, boost::random_device is not thread safe and futhermore, it might be possible to deplete the entropy pool with a lot of connection attempts which would degrade the security of other, more important modules.

@fjl
Copy link
Contributor Author

fjl commented Feb 16, 2016

For the padding we decided to go with rand(3), which is known to be unsafe for concurrent use, instead of using boost. It will be fixed later.

@chriseth
Copy link
Contributor

Tested on linux, works fine.

@fjl
Copy link
Contributor Author

fjl commented Feb 17, 2016

Squashed.

chriseth added a commit that referenced this pull request Feb 17, 2016
@chriseth chriseth merged commit d0507ce into ethereum:develop Feb 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants