applies merge filtering to peers after 2 finalized (#4124)

* applies merge filtering to peers after 2 finalized
* fixes logical error in handling status messages

Signed-off-by: Justin Florentine <justin+github@florentine.us>
pull/4210/head
Justin Florentine 2 years ago committed by GitHub
parent 7c29709fe3
commit e1c8eb7fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
  2. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java

@ -104,11 +104,13 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
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(
@ -121,7 +123,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
ethMessages,
scheduler,
peerValidators,
mergePeerFilter);
filterToUse);
return ethProtocolManager;
}

@ -376,11 +376,9 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
networkId,
status.genesisHash());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
} else if (mergePeerFilter.isPresent()) {
final boolean disconnected = mergePeerFilter.get().disconnectIfPoW(status, peer);
if (disconnected) {
} 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(

Loading…
Cancel
Save