Skip to content
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

eth66 #2365

Merged
merged 84 commits into from
Aug 25, 2021
Merged

eth66 #2365

merged 84 commits into from
Aug 25, 2021

Conversation

RatanRSur
Copy link
Contributor

@RatanRSur RatanRSur commented Jun 2, 2021

PR description

https://eips.ethereum.org/EIPS/eip-2481

Review suggestion: hide whitespace changes

Fixed Issue(s)

fixes #2210

Changelog

@RatanRSur RatanRSur force-pushed the eth66 branch 2 times, most recently from 33ca7f2 to b87e7b0 Compare June 28, 2021 16:13
RatanRSur added 28 commits July 1, 2021 11:26
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Comment on lines 54 to 68
private static final List<Integer> eth63Messages =
Stream.concat(
eth62Messages.stream(),
Stream.of(
EthPV63.GET_NODE_DATA, EthPV63.NODE_DATA, EthPV63.GET_RECEIPTS, EthPV63.RECEIPTS))
.collect(toUnmodifiableList());

static {
eth63Messages.addAll(
Arrays.asList(
EthPV63.GET_NODE_DATA, EthPV63.NODE_DATA, EthPV63.GET_RECEIPTS, EthPV63.RECEIPTS));
}
private static final List<Integer> eth65Messages =
Stream.concat(
eth62Messages.stream(),
Stream.of(
EthPV65.NEW_POOLED_TRANSACTION_HASHES,
EthPV65.GET_POOLED_TRANSACTIONS,
EthPV65.POOLED_TRANSACTIONS))
.collect(toUnmodifiableList());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cosmetic

Comment on lines +64 to +72
private final Set<Hash> knownBlocks =
Collections.newSetFromMap(
Collections.synchronizedMap(
new LinkedHashMap<>(16, 0.75f, true) {
@Override
protected boolean removeEldestEntry(final Map.Entry<Hash, Boolean> eldest) {
return size() > maxTrackedSeenBlocks;
}
}));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cosmetic, moved from constructor

Comment on lines -61 to -69
@Test
public void shouldRespondToNodeDataRequests() throws Exception {
when(worldStateArchive.getNodeData(HASH1)).thenReturn(Optional.of(VALUE1));
when(worldStateArchive.getNodeData(HASH2)).thenReturn(Optional.of(VALUE2));
ethMessages.dispatch(new EthMessage(ethPeer, GetNodeDataMessage.create(asList(HASH1, HASH2))));

verify(ethPeer).send(NodeDataMessage.create(asList(VALUE1, VALUE2)));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ethMessages is no longer responsible for sending. Also, this behavior is already covered by EthProtocolManagerTest

@RatanRSur RatanRSur marked this pull request as ready for review August 19, 2021 19:28
Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

Looks good, I have a few questions to clarify my understanding and some minor nitpicky stuff

}

static Map.Entry<BigInteger, MessageData> unwrapRequestId(final MessageData messageData) {
final RLPInput messageDataRLP = RLP.input(messageData.getData());
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to handle MalformedRLPInputException here or would it get appropriately handled further up the call stack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, will fix

Copy link
Contributor

Choose a reason for hiding this comment

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

did you determine we do not need to handle this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.ifPresentOrElse(
responseStream -> responseStream.processMessage(requestIdAndEthMessage.getValue()),
// disconnect on incorrect requestIds
() -> peer.disconnect(DisconnectMessage.DisconnectReason.BREACH_OF_PROTOCOL));
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this happen in practice? We have a response, but no open stream to receive the response, so we disconnect the target peer? This seems likely to occur on our side rather than it being the fault of the remote ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should have all the request ids for the outstanding requests we sent so if we receive a request id we're not tracking, that means the remote is breaching protocol somehow.

Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this our response to a request rather than a response to our request? Seems to me if we have formulated a response but can't find the request id, that is a problem on our end and we shouldn't disconnect from the peer. thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
@RatanRSur RatanRSur requested a review from garyschulte August 24, 2021 14:57
Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

🚢 🥳

@RatanRSur RatanRSur enabled auto-merge (squash) August 25, 2021 17:06
@RatanRSur RatanRSur merged commit f888983 into hyperledger:main Aug 25, 2021
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
https://eips.ethereum.org/EIPS/eip-2481

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement eth/66
2 participants