Skip to content

Commit

Permalink
applies merge filtering to peers after 2 finalized (#4124)
Browse files Browse the repository at this point in the history
* applies merge filtering to peers after 2 finalized
* fixes logical error in handling status messages

Signed-off-by: Justin Florentine <justin+github@florentine.us>
  • Loading branch information
jflo authored Aug 2, 2022
1 parent 7c29709 commit e1c8eb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ protected EthProtocolManager createEthProtocolManager(
ethPeers.setBestChainComparator(mergeBestPeerComparator);
mergeContext.observeNewIsPostMergeState(mergeBestPeerComparator);

if (mergePeerFilter.isPresent()) {
Optional<MergePeerFilter> filterToUse = Optional.of(new MergePeerFilter());

mergeContext.observeNewIsPostMergeState(mergePeerFilter.get());
mergeContext.addNewForkchoiceMessageListener(mergePeerFilter.get());
if (mergePeerFilter.isPresent()) {
filterToUse = mergePeerFilter;
}
mergeContext.observeNewIsPostMergeState(filterToUse.get());
mergeContext.addNewForkchoiceMessageListener(filterToUse.get());

EthProtocolManager ethProtocolManager =
super.createEthProtocolManager(
Expand All @@ -121,7 +123,7 @@ protected EthProtocolManager createEthProtocolManager(
ethMessages,
scheduler,
peerValidators,
mergePeerFilter);
filterToUse);

return ethProtocolManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,9 @@ private void handleStatusMessage(final EthPeer peer, final MessageData data) {
networkId,
status.genesisHash());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
} else if (mergePeerFilter.isPresent()) {
final boolean disconnected = mergePeerFilter.get().disconnectIfPoW(status, peer);
if (disconnected) {
handleDisconnect(peer.getConnection(), DisconnectReason.SUBPROTOCOL_TRIGGERED, false);
}
} else if (mergePeerFilter.isPresent()
&& mergePeerFilter.get().disconnectIfPoW(status, peer)) {
handleDisconnect(peer.getConnection(), DisconnectReason.SUBPROTOCOL_TRIGGERED, false);
} else {
LOG.debug("Received status message from {}: {}", peer, status);
peer.registerStatusReceived(
Expand Down

0 comments on commit e1c8eb7

Please sign in to comment.