From f4e85700bf5cad147ae6930757a7944199d6e566 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Thu, 24 Oct 2024 18:25:20 +0200 Subject: [PATCH] Upgrade `jvm-libp2p` to 1.2.1 (#8783) --- CHANGELOG.md | 5 +++- gradle/versions.gradle | 2 +- .../teku/networking/eth2/P2PConfig.java | 12 ++++---- .../p2p/gossip/config/GossipConfig.java | 22 +++++++------- .../libp2p/config/LibP2PParamsFactory.java | 2 +- .../pegasys/teku/cli/options/P2POptions.java | 11 +++---- .../teku/cli/options/P2POptionsTest.java | 29 +++++-------------- 7 files changed, 39 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79bfa293d6c..372c06cc271 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,10 @@ ### Additions and Improvements - Clean up old beacon states when switching from ARCHIVE to PRUNE or MINIMAL data storage mode +- Upgrade to jvm-libp2p 1.2.1 which brings: + - message publishing over gossipsub improvements (addresses `Failed to publish * because no peers were available on the required gossip topic`) + - IDONTWANT control message usage improvements ### Bug Fixes - Fixed a block production issue for Validator Client (24.10.0 to 24.10.2 teku VC), where required headers were not provided for JSON payloads. Default SSZ block production was unaffected. - - Block production now uses json data (more like 24.8.0 did than 24.10) if the Eth-Consensus-version header is absent. + - Block production now uses json data (more like 24.8.0 did than 24.10) if the Eth-Consensus-version header is absent. diff --git a/gradle/versions.gradle b/gradle/versions.gradle index f7c4c174517..ad37563f6af 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -32,7 +32,7 @@ dependencyManagement { entry 'javalin-rendering' } - dependency 'io.libp2p:jvm-libp2p:1.2.0-RELEASE' + dependency 'io.libp2p:jvm-libp2p:1.2.1-RELEASE' dependency 'tech.pegasys:jblst:0.3.12' dependency 'io.consensys.protocols:jc-kzg-4844:2.0.0' diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/P2PConfig.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/P2PConfig.java index 619bcbfa33f..60aec96d20e 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/P2PConfig.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/P2PConfig.java @@ -14,7 +14,7 @@ package tech.pegasys.teku.networking.eth2; import static com.google.common.base.Preconditions.checkNotNull; -import static tech.pegasys.teku.networking.p2p.gossip.config.GossipConfig.DEFAULT_FLOOD_PUBLISH_ENABLED; +import static tech.pegasys.teku.networking.p2p.gossip.config.GossipConfig.DEFAULT_FLOOD_PUBLISH_MAX_MESSAGE_SIZE_THRESHOLD; import java.time.Duration; import java.util.OptionalInt; @@ -175,7 +175,8 @@ public static class Builder { private boolean batchVerifyStrictThreadLimitEnabled = DEFAULT_BATCH_VERIFY_STRICT_THREAD_LIMIT_ENABLED; private boolean allTopicsFilterEnabled = DEFAULT_PEER_ALL_TOPIC_FILTER_ENABLED; - private boolean isFloodPublishEnabled = DEFAULT_FLOOD_PUBLISH_ENABLED; + private int floodPublishMaxMessageSizeThreshold = + DEFAULT_FLOOD_PUBLISH_MAX_MESSAGE_SIZE_THRESHOLD; private Builder() {} @@ -198,7 +199,7 @@ public P2PConfig build() { builder.seenTTL( Duration.ofSeconds( (long) specConfig.getSecondsPerSlot() * specConfig.getSlotsPerEpoch() * 2)); - builder.floodPublishEnabled(isFloodPublishEnabled); + builder.floodPublishMaxMessageSizeThreshold(floodPublishMaxMessageSizeThreshold); }); final NetworkConfig networkConfig = this.networkConfig.build(); @@ -287,8 +288,9 @@ public Builder peerRequestLimit(final Integer peerRequestLimit) { return this; } - public Builder isFloodPublishEnabled(final boolean floodPublishEnabled) { - this.isFloodPublishEnabled = floodPublishEnabled; + public Builder floodPublishMaxMessageSizeThreshold( + final int floodPublishMaxMessageSizeThreshold) { + this.floodPublishMaxMessageSizeThreshold = floodPublishMaxMessageSizeThreshold; return this; } diff --git a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/gossip/config/GossipConfig.java b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/gossip/config/GossipConfig.java index 10b7099b794..ce82d57b529 100644 --- a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/gossip/config/GossipConfig.java +++ b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/gossip/config/GossipConfig.java @@ -36,7 +36,7 @@ public class GossipConfig { // After EIP-7045, attestations are valid for up to 2 full epochs, so TTL is 65 // slots 1115 * HEARTBEAT = 1115 * 0.7 / 12 = 65.125 static final Duration DEFAULT_SEEN_TTL = DEFAULT_HEARTBEAT_INTERVAL.multipliedBy(1115); - public static final Boolean DEFAULT_FLOOD_PUBLISH_ENABLED = false; + public static final int DEFAULT_FLOOD_PUBLISH_MAX_MESSAGE_SIZE_THRESHOLD = 1 << 14; // 16KiB private final int d; private final int dLow; @@ -47,7 +47,7 @@ public class GossipConfig { private final int history; private final Duration heartbeatInterval; private final Duration seenTTL; - private final boolean floodPublishEnabled; + private final int floodPublishMaxMessageSizeThreshold; private final GossipScoringConfig scoringConfig; private GossipConfig( @@ -60,7 +60,7 @@ private GossipConfig( final int history, final Duration heartbeatInterval, final Duration seenTTL, - final boolean floodPublishEnabled, + final int floodPublishMaxMessageSizeThreshold, final GossipScoringConfig scoringConfig) { this.d = d; this.dLow = dLow; @@ -71,7 +71,7 @@ private GossipConfig( this.history = history; this.heartbeatInterval = heartbeatInterval; this.seenTTL = seenTTL; - this.floodPublishEnabled = floodPublishEnabled; + this.floodPublishMaxMessageSizeThreshold = floodPublishMaxMessageSizeThreshold; this.scoringConfig = scoringConfig; } @@ -119,8 +119,8 @@ public Duration getSeenTTL() { return seenTTL; } - public boolean isFloodPublishEnabled() { - return floodPublishEnabled; + public int getFloodPublishMaxMessageSizeThreshold() { + return floodPublishMaxMessageSizeThreshold; } public GossipScoringConfig getScoringConfig() { @@ -139,7 +139,8 @@ public static class Builder { private Integer history = DEFAULT_HISTORY; private Duration heartbeatInterval = DEFAULT_HEARTBEAT_INTERVAL; private Duration seenTTL = DEFAULT_SEEN_TTL; - private boolean floodPublishEnabled = DEFAULT_FLOOD_PUBLISH_ENABLED; + private int floodPublishMaxMessageSizeThreshold = + DEFAULT_FLOOD_PUBLISH_MAX_MESSAGE_SIZE_THRESHOLD; private Builder() {} @@ -154,7 +155,7 @@ public GossipConfig build() { history, heartbeatInterval, seenTTL, - floodPublishEnabled, + floodPublishMaxMessageSizeThreshold, scoringConfigBuilder.build()); } @@ -227,8 +228,9 @@ public Builder seenTTL(final Duration seenTTL) { return this; } - public Builder floodPublishEnabled(final boolean floodPublishEnabled) { - this.floodPublishEnabled = floodPublishEnabled; + public Builder floodPublishMaxMessageSizeThreshold( + final int floodPublishMaxMessageSizeThreshold) { + this.floodPublishMaxMessageSizeThreshold = floodPublishMaxMessageSizeThreshold; return this; } diff --git a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/libp2p/config/LibP2PParamsFactory.java b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/libp2p/config/LibP2PParamsFactory.java index 42f9aeb32d6..c24629cd897 100644 --- a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/libp2p/config/LibP2PParamsFactory.java +++ b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/libp2p/config/LibP2PParamsFactory.java @@ -47,7 +47,7 @@ private static void addGossipParamsMiscValues( final GossipConfig gossipConfig, final GossipParamsBuilder builder) { builder .fanoutTTL(gossipConfig.getFanoutTTL()) - .floodPublish(gossipConfig.isFloodPublishEnabled()) + .floodPublishMaxMessageSizeThreshold(gossipConfig.getFloodPublishMaxMessageSizeThreshold()) .gossipSize(gossipConfig.getAdvertise()) .gossipHistoryLength(gossipConfig.getHistory()) .heartbeatInterval(gossipConfig.getHeartbeatInterval()) diff --git a/teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java b/teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java index 1eb119ff67a..e268b2da55e 100644 --- a/teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java +++ b/teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java @@ -370,14 +370,15 @@ The network interface(s) on which the node listens for P2P communication. // More about flood publishing // https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#flood-publishing @Option( - names = {"--Xp2p-flood-publish-enabled"}, - paramLabel = "", + names = {"--Xp2p-flood-max-message-size-threshold"}, + paramLabel = "", showDefaultValue = Visibility.ALWAYS, - description = "Enables gossip 'floodPublish' feature", + description = "Maximum size (in bytes) of a message that will be flood published", arity = "0..1", hidden = true, fallbackValue = "true") - private boolean floodPublishEnabled = GossipConfig.DEFAULT_FLOOD_PUBLISH_ENABLED; + private int floodPublishMaxMessageSizeThreshold = + GossipConfig.DEFAULT_FLOOD_PUBLISH_MAX_MESSAGE_SIZE_THRESHOLD; private OptionalInt getP2pLowerBound() { if (p2pUpperBound.isPresent() && p2pLowerBound.isPresent()) { @@ -409,7 +410,7 @@ public void configure(final TekuConfiguration.Builder builder) { .peerRateLimit(peerRateLimit) .allTopicsFilterEnabled(allTopicsFilterEnabled) .peerRequestLimit(peerRequestLimit) - .isFloodPublishEnabled(floodPublishEnabled); + .floodPublishMaxMessageSizeThreshold(floodPublishMaxMessageSizeThreshold); batchVerifyQueueCapacity.ifPresent(b::batchVerifyQueueCapacity); }) .discovery( diff --git a/teku/src/test/java/tech/pegasys/teku/cli/options/P2POptionsTest.java b/teku/src/test/java/tech/pegasys/teku/cli/options/P2POptionsTest.java index 474e4377725..be720223370 100644 --- a/teku/src/test/java/tech/pegasys/teku/cli/options/P2POptionsTest.java +++ b/teku/src/test/java/tech/pegasys/teku/cli/options/P2POptionsTest.java @@ -18,7 +18,7 @@ import static tech.pegasys.teku.infrastructure.async.AsyncRunnerFactory.DEFAULT_MAX_QUEUE_SIZE_ALL_SUBNETS; import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryConfig.DEFAULT_P2P_PEERS_LOWER_BOUND_ALL_SUBNETS; import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryConfig.DEFAULT_P2P_PEERS_UPPER_BOUND_ALL_SUBNETS; -import static tech.pegasys.teku.networking.p2p.gossip.config.GossipConfig.DEFAULT_FLOOD_PUBLISH_ENABLED; +import static tech.pegasys.teku.networking.p2p.gossip.config.GossipConfig.DEFAULT_FLOOD_PUBLISH_MAX_MESSAGE_SIZE_THRESHOLD; import static tech.pegasys.teku.networking.p2p.network.config.NetworkConfig.DEFAULT_P2P_PORT; import static tech.pegasys.teku.networking.p2p.network.config.NetworkConfig.DEFAULT_P2P_PORT_IPV6; import static tech.pegasys.teku.validator.api.ValidatorConfig.DEFAULT_EXECUTOR_MAX_QUEUE_SIZE_ALL_SUBNETS; @@ -340,31 +340,18 @@ public void allSubnetsShouldNotOverrideQueuesIfExplicitlySet() { } @Test - public void floodPublishEnabled_defaultIsSetCorrectly() { + public void floodPublishMaxMessageSizeThreshold_defaultIsSetCorrectly() { final TekuConfiguration config = getTekuConfigurationFromArguments(); - assertThat(config.network().getGossipConfig().isFloodPublishEnabled()) - .isEqualTo(DEFAULT_FLOOD_PUBLISH_ENABLED); + assertThat(config.network().getGossipConfig().getFloodPublishMaxMessageSizeThreshold()) + .isEqualTo(DEFAULT_FLOOD_PUBLISH_MAX_MESSAGE_SIZE_THRESHOLD); } @Test - public void floodPublishEnabled_shouldNotRequireAValue() { + public void floodPublishMaxMessageSizeThreshold_isSetCorrectly() { final TekuConfiguration config = - getTekuConfigurationFromArguments("--Xp2p-flood-publish-enabled"); - assertThat(config.network().getGossipConfig().isFloodPublishEnabled()).isTrue(); - } - - @Test - public void floodPublishEnabled_true() { - final TekuConfiguration config = - getTekuConfigurationFromArguments("--Xp2p-flood-publish-enabled=true"); - assertThat(config.network().getGossipConfig().isFloodPublishEnabled()).isTrue(); - } - - @Test - public void floodPublishEnabled_false() { - final TekuConfiguration config = - getTekuConfigurationFromArguments("--Xp2p-flood-publish-enabled=false"); - assertThat(config.network().getGossipConfig().isFloodPublishEnabled()).isFalse(); + getTekuConfigurationFromArguments("--Xp2p-flood-max-message-size-threshold=1000"); + assertThat(config.network().getGossipConfig().getFloodPublishMaxMessageSizeThreshold()) + .isEqualTo(1000); } @Test