Skip to content

Commit

Permalink
Add bootnodes to the maintained peer list (hyperledger#7257)
Browse files Browse the repository at this point in the history
* Add bootnodes to the maintained peer list

Signed-off-by: Matthew Whitehead <[email protected]>

* Update unit tests

Signed-off-by: Matthew Whitehead <[email protected]>

* Add entry in changelog

Signed-off-by: Matthew Whitehead <[email protected]>

* Tweak unit test

Signed-off-by: Matthew Whitehead <[email protected]>

* Refactor to keep common steps the same for both cases

Signed-off-by: Matthew Whitehead <[email protected]>

* Add debug log, call sanitizePeers() only once

Signed-off-by: Matthew Whitehead <[email protected]>

---------

Signed-off-by: Matthew Whitehead <[email protected]>
  • Loading branch information
matthew1001 authored and daniellehrner committed Jul 16, 2024
1 parent 8c5a3c8 commit 1bf0a34
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- Added EIP-7702 [#7237](https://github.com/hyperledger/besu/pull/7237)

### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ 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));

permissionedNode.execute(allowNode(permissionedNode));
permissionedNode.verify(nodeIsAllowed(permissionedNode));

permissionedNode.verify(admin.addPeer(bootnode));
permissionedNode.verify(admin.addPeer(allowedNode));

allowedNode.verify(eth.syncingStatus(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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));

Expand All @@ -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));

Expand Down
15 changes: 14 additions & 1 deletion besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,20 @@ public Runner build() {
LOG.debug("added ethash observer: {}", stratumServer.get());
}

sanitizePeers(network, staticNodes)
final Stream<EnodeURL> 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);

Expand Down

0 comments on commit 1bf0a34

Please sign in to comment.