Skip to content

Commit

Permalink
Express seen_ttl in consensus params (#8140)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Mar 26, 2024
1 parent 7ec16bc commit 9ce484a
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import static com.google.common.base.Preconditions.checkNotNull;

import java.time.Duration;
import java.util.OptionalInt;
import java.util.function.Consumer;
import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException;
Expand All @@ -25,6 +26,7 @@
import tech.pegasys.teku.networking.p2p.network.config.NetworkConfig;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.config.NetworkingSpecConfig;
import tech.pegasys.teku.spec.config.SpecConfig;

public class P2PConfig {

Expand Down Expand Up @@ -182,14 +184,21 @@ public P2PConfig build() {
isGossipScoringEnabled
? GossipConfigurator.scoringEnabled(spec)
: GossipConfigurator.NOOP;
final SpecConfig specConfig = spec.getGenesisSpecConfig();
final Eth2Context eth2Context =
Eth2Context.builder()
.activeValidatorCount(spec.getGenesisSpecConfig().getMinGenesisActiveValidatorCount())
.activeValidatorCount(specConfig.getMinGenesisActiveValidatorCount())
.gossipEncoding(gossipEncoding)
.build();
networkConfig.gossipConfig(c -> gossipConfigurator.configure(c, eth2Context));

NetworkConfig networkConfig = this.networkConfig.build();
networkConfig.gossipConfig(
builder -> {
gossipConfigurator.configure(builder, eth2Context);
builder.seenTTL(
Duration.ofSeconds(
(long) specConfig.getSecondsPerSlot() * specConfig.getSlotsPerEpoch() * 2));
});

final NetworkConfig networkConfig = this.networkConfig.build();
discoveryConfig.listenUdpPortDefault(networkConfig.getListenPort());
discoveryConfig.advertisedUdpPortDefault(OptionalInt.of(networkConfig.getAdvertisedPort()));

Expand Down

0 comments on commit 9ce484a

Please sign in to comment.