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); ethPeers.setBestChainComparator(mergeBestPeerComparator);
mergeContext.observeNewIsPostMergeState(mergeBestPeerComparator); mergeContext.observeNewIsPostMergeState(mergeBestPeerComparator);
if (mergePeerFilter.isPresent()) { Optional<MergePeerFilter> filterToUse = Optional.of(new MergePeerFilter());
mergeContext.observeNewIsPostMergeState(mergePeerFilter.get()); if (mergePeerFilter.isPresent()) {
mergeContext.addNewForkchoiceMessageListener(mergePeerFilter.get()); filterToUse = mergePeerFilter;
} }
mergeContext.observeNewIsPostMergeState(filterToUse.get());
mergeContext.addNewForkchoiceMessageListener(filterToUse.get());
EthProtocolManager ethProtocolManager = EthProtocolManager ethProtocolManager =
super.createEthProtocolManager( super.createEthProtocolManager(
@ -121,7 +123,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
ethMessages, ethMessages,
scheduler, scheduler,
peerValidators, peerValidators,
mergePeerFilter); filterToUse);
return ethProtocolManager; return ethProtocolManager;
} }

@ -376,11 +376,9 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
networkId, networkId,
status.genesisHash()); status.genesisHash());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
} else if (mergePeerFilter.isPresent()) { } else if (mergePeerFilter.isPresent()
final boolean disconnected = mergePeerFilter.get().disconnectIfPoW(status, peer); && mergePeerFilter.get().disconnectIfPoW(status, peer)) {
if (disconnected) {
handleDisconnect(peer.getConnection(), DisconnectReason.SUBPROTOCOL_TRIGGERED, false); handleDisconnect(peer.getConnection(), DisconnectReason.SUBPROTOCOL_TRIGGERED, false);
}
} else { } else {
LOG.debug("Received status message from {}: {}", peer, status); LOG.debug("Received status message from {}: {}", peer, status);
peer.registerStatusReceived( peer.registerStatusReceived(

Loading…
Cancel
Save