Skip to content

Commit 1bf0a34

Browse files
matthew1001daniellehrner
authored andcommitted
Add bootnodes to the maintained peer list (besu-eth#7257)
* Add bootnodes to the maintained peer list Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update unit tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add entry in changelog Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Tweak unit test Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor to keep common steps the same for both cases Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add debug log, call sanitizePeers() only once Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
1 parent 8c5a3c8 commit 1bf0a34

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Update Docker base image to Ubuntu 24.04 [#7251](https://github.com/hyperledger/besu/pull/7251)
1616
- Add LUKSO as predefined network name [#7223](https://github.com/hyperledger/besu/pull/7223)
1717
- Refactored how code, initcode, and max stack size are configured in forks. [#7245](https://github.com/hyperledger/besu/pull/7245)
18+
- Nodes in a permissioned chain maintain (and retry) connections to bootnodes [#7257](https://github.com/hyperledger/besu/pull/7257)
1819
- Added EIP-7702 [#7237](https://github.com/hyperledger/besu/pull/7237)
1920

2021
### Bug fixes

acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ public void setUp() {
3838
permissionedCluster.start(bootnode, forbiddenNode, allowedNode, permissionedNode);
3939

4040
// updating permissioning smart contract with allowed nodes
41-
41+
permissionedNode.verify(nodeIsForbidden(bootnode));
4242
permissionedNode.execute(allowNode(bootnode));
4343
permissionedNode.verify(nodeIsAllowed(bootnode));
44+
permissionedNode.verify(admin.hasPeer(bootnode));
4445

4546
permissionedNode.execute(allowNode(allowedNode));
4647
permissionedNode.verify(nodeIsAllowed(allowedNode));
4748

4849
permissionedNode.execute(allowNode(permissionedNode));
4950
permissionedNode.verify(nodeIsAllowed(permissionedNode));
5051

51-
permissionedNode.verify(admin.addPeer(bootnode));
5252
permissionedNode.verify(admin.addPeer(allowedNode));
5353

5454
allowedNode.verify(eth.syncingStatus(false));

acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void permissionedNodeShouldPeerOnlyWithAllowedNodes() {
6262

6363
@Test
6464
public void permissionedNodeShouldDisconnectFromNodeNotPermittedAnymore() {
65-
permissionedNode.verify(admin.addPeer(bootnode));
65+
permissionedNode.verify(admin.hasPeer(bootnode));
6666
permissionedNode.verify(admin.addPeer(allowedNode));
6767
permissionedNode.verify(net.awaitPeerCount(2));
6868

@@ -74,7 +74,7 @@ public void permissionedNodeShouldDisconnectFromNodeNotPermittedAnymore() {
7474

7575
@Test
7676
public void permissionedNodeShouldConnectToNewlyPermittedNode() {
77-
permissionedNode.verify(admin.addPeer(bootnode));
77+
permissionedNode.verify(admin.hasPeer(bootnode));
7878
permissionedNode.verify(admin.addPeer(allowedNode));
7979
permissionedNode.verify(net.awaitPeerCount(2));
8080

@@ -89,7 +89,7 @@ public void permissionedNodeShouldConnectToNewlyPermittedNode() {
8989

9090
@Test
9191
public void permissioningUpdatesPropagateThroughNetwork() {
92-
permissionedNode.verify(admin.addPeer(bootnode));
92+
permissionedNode.verify(admin.hasPeer(bootnode));
9393
permissionedNode.verify(admin.addPeer(allowedNode));
9494
permissionedNode.verify(net.awaitPeerCount(2));
9595

besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,20 @@ public Runner build() {
790790
LOG.debug("added ethash observer: {}", stratumServer.get());
791791
}
792792

793-
sanitizePeers(network, staticNodes)
793+
final Stream<EnodeURL> maintainedPeers;
794+
if (besuController.getGenesisConfigOptions().isPoa()) {
795+
// In a permissioned chain Besu should maintain connections to both static nodes and
796+
// bootnodes, which includes retries periodically
797+
maintainedPeers =
798+
sanitizePeers(
799+
network,
800+
Stream.concat(staticNodes.stream(), bootnodes.stream()).collect(Collectors.toList()));
801+
LOG.debug("Added bootnodes to the maintained peer list");
802+
} else {
803+
// In a public chain only maintain connections to static nodes
804+
maintainedPeers = sanitizePeers(network, staticNodes);
805+
}
806+
maintainedPeers
794807
.map(DefaultPeer::fromEnodeURL)
795808
.forEach(peerNetwork::addMaintainedConnectionPeer);
796809

0 commit comments

Comments
 (0)