diff --git a/CHANGELOG.md b/CHANGELOG.md index 07cdf586349..4eb0b5166d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Update Docker base image to Ubuntu 24.04 [#7251](https://github.com/hyperledger/besu/pull/7251) - Add LUKSO as predefined network name [#7223](https://github.com/hyperledger/besu/pull/7223) - Refactored how code, initcode, and max stack size are configured in forks. [#7245](https://github.com/hyperledger/besu/pull/7245) +- Nodes in a permissioned chain maintain (and retry) connections to bootnodes [#7257](https://github.com/hyperledger/besu/pull/7257) ### Bug fixes - Validation errors ignored in accounts-allowlist and empty list [#7138](https://github.com/hyperledger/besu/issues/7138) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java index 903919c800c..f1ed4e14902 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java @@ -38,9 +38,10 @@ public void setUp() { permissionedCluster.start(bootnode, forbiddenNode, allowedNode, permissionedNode); // updating permissioning smart contract with allowed nodes - + permissionedNode.verify(nodeIsForbidden(bootnode)); permissionedNode.execute(allowNode(bootnode)); permissionedNode.verify(nodeIsAllowed(bootnode)); + permissionedNode.verify(admin.hasPeer(bootnode)); permissionedNode.execute(allowNode(allowedNode)); permissionedNode.verify(nodeIsAllowed(allowedNode)); @@ -48,7 +49,6 @@ public void setUp() { permissionedNode.execute(allowNode(permissionedNode)); permissionedNode.verify(nodeIsAllowed(permissionedNode)); - permissionedNode.verify(admin.addPeer(bootnode)); permissionedNode.verify(admin.addPeer(allowedNode)); allowedNode.verify(eth.syncingStatus(false)); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java index efb88178d6d..1f2cc682c69 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java @@ -62,7 +62,7 @@ public void permissionedNodeShouldPeerOnlyWithAllowedNodes() { @Test public void permissionedNodeShouldDisconnectFromNodeNotPermittedAnymore() { - permissionedNode.verify(admin.addPeer(bootnode)); + permissionedNode.verify(admin.hasPeer(bootnode)); permissionedNode.verify(admin.addPeer(allowedNode)); permissionedNode.verify(net.awaitPeerCount(2)); @@ -74,7 +74,7 @@ public void permissionedNodeShouldDisconnectFromNodeNotPermittedAnymore() { @Test public void permissionedNodeShouldConnectToNewlyPermittedNode() { - permissionedNode.verify(admin.addPeer(bootnode)); + permissionedNode.verify(admin.hasPeer(bootnode)); permissionedNode.verify(admin.addPeer(allowedNode)); permissionedNode.verify(net.awaitPeerCount(2)); @@ -89,7 +89,7 @@ public void permissionedNodeShouldConnectToNewlyPermittedNode() { @Test public void permissioningUpdatesPropagateThroughNetwork() { - permissionedNode.verify(admin.addPeer(bootnode)); + permissionedNode.verify(admin.hasPeer(bootnode)); permissionedNode.verify(admin.addPeer(allowedNode)); permissionedNode.verify(net.awaitPeerCount(2)); diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index 1f9c48cccc5..e9f9ef6268c 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -790,7 +790,20 @@ public Runner build() { LOG.debug("added ethash observer: {}", stratumServer.get()); } - sanitizePeers(network, staticNodes) + final Stream maintainedPeers; + if (besuController.getGenesisConfigOptions().isPoa()) { + // In a permissioned chain Besu should maintain connections to both static nodes and + // bootnodes, which includes retries periodically + maintainedPeers = + sanitizePeers( + network, + Stream.concat(staticNodes.stream(), bootnodes.stream()).collect(Collectors.toList())); + LOG.debug("Added bootnodes to the maintained peer list"); + } else { + // In a public chain only maintain connections to static nodes + maintainedPeers = sanitizePeers(network, staticNodes); + } + maintainedPeers .map(DefaultPeer::fromEnodeURL) .forEach(peerNetwork::addMaintainedConnectionPeer);