Merge branch 'main' into feature/worldstate-refactor

pull/6209/head
Karim TAAM 10 months ago committed by GitHub
commit 78f64f2d99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 23
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java
  3. 24
      ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java
  4. 8
      ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryTestHelper.java

@ -87,6 +87,7 @@ https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/23.10.3-hotfix/besu-
### Bug fixes ### Bug fixes
- Fix Docker image name clash between Besu and evmtool [#6194](https://github.com/hyperledger/besu/pull/6194) - Fix Docker image name clash between Besu and evmtool [#6194](https://github.com/hyperledger/besu/pull/6194)
- Fix `logIndex` in `eth_getTransactionReceipt` JSON RPC method [#6206](https://github.com/hyperledger/besu/pull/6206) - Fix `logIndex` in `eth_getTransactionReceipt` JSON RPC method [#6206](https://github.com/hyperledger/besu/pull/6206)
- Fix the way an advertised host configured with `--p2p-host` is treated when communicating with the originator of a PING packet [#6225](https://github.com/hyperledger/besu/pull/6225)
### Download Links ### Download Links
https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/23.10.3/besu-23.10.3.zip / sha256 da7ef8a6ceb88d3e327cacddcdb32218d1750b464c14165a74068f6dc6e0871a https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/23.10.3/besu-23.10.3.zip / sha256 da7ef8a6ceb88d3e327cacddcdb32218d1750b464c14165a74068f6dc6e0871a

@ -282,8 +282,29 @@ public abstract class PeerDiscoveryAgent {
.flatMap(Endpoint::getTcpPort) .flatMap(Endpoint::getTcpPort)
.orElse(udpPort); .orElse(udpPort);
// If the host is present in the P2P PING packet itself, use that as the endpoint. If the P2P
// PING packet specifies 127.0.0.1 (the default if a custom value is not specified with
// --p2p-host or via a suitable --nat-method) we ignore it in favour of the UDP source address.
// The likelihood is that the UDP source will be 127.0.0.1 anyway, but this reduces the chance
// of an unexpected change in behaviour as a result of
// https://github.com/hyperledger/besu/issues/6224 being fixed.
final String host =
packet
.getPacketData(PingPacketData.class)
.flatMap(PingPacketData::getFrom)
.map(Endpoint::getHost)
.filter(abc -> !abc.equals("127.0.0.1"))
.stream()
.peek(
h ->
LOG.trace(
"Using \"From\" endpoint {} specified in ping packet. Ignoring UDP source host {}",
h,
sourceEndpoint.getHost()))
.findFirst()
.orElseGet(sourceEndpoint::getHost);
// Notify the peer controller. // Notify the peer controller.
final String host = sourceEndpoint.getHost();
final DiscoveryPeer peer = final DiscoveryPeer peer =
DiscoveryPeer.fromEnode( DiscoveryPeer.fromEnode(
EnodeURLImpl.builder() EnodeURLImpl.builder()

@ -244,6 +244,30 @@ public class PeerDiscoveryAgentTest {
} }
} }
@Test
public void endpointHonoursCustomAdvertisedAddressInPingPacket() {
// Start a peer with the default advertised host
final MockPeerDiscoveryAgent agent1 = helper.startDiscoveryAgent();
// Start another peer with its advertised host set to a custom value
final MockPeerDiscoveryAgent agent2 = helper.startDiscoveryAgent("192.168.0.1");
// Send a PING so we can exchange messages
Packet packet = helper.createPingPacket(agent2, agent1);
helper.sendMessageBetweenAgents(agent2, agent1, packet);
// Agent 1's peers should have endpoints that match the custom advertised value...
agent1
.streamDiscoveredPeers()
.forEach(peer -> assertThat(peer.getEndpoint().getHost()).isEqualTo("192.168.0.1"));
// ...but agent 2's peers should have endpoints that match the default
agent2
.streamDiscoveredPeers()
.forEach(peer -> assertThat(peer.getEndpoint().getHost()).isEqualTo("127.0.0.1"));
}
@Test @Test
public void shouldEvictPeerWhenPermissionsRevoked() { public void shouldEvictPeerWhenPermissionsRevoked() {
final PeerPermissionsDenylist denylist = PeerPermissionsDenylist.create(); final PeerPermissionsDenylist denylist = PeerPermissionsDenylist.create();

@ -165,6 +165,14 @@ public class PeerDiscoveryTestHelper {
return startDiscoveryAgent(agentBuilder); return startDiscoveryAgent(agentBuilder);
} }
public MockPeerDiscoveryAgent startDiscoveryAgent(
final String advertisedHost, final DiscoveryPeer... bootstrapPeers) {
final AgentBuilder agentBuilder =
agentBuilder().bootstrapPeers(bootstrapPeers).advertisedHost(advertisedHost);
return startDiscoveryAgent(agentBuilder);
}
/** /**
* Start a single discovery agent with the provided bootstrap peers. * Start a single discovery agent with the provided bootstrap peers.
* *

Loading…
Cancel
Save