From 95708f94300a2aa624a05f32e7edff98e0edf983 Mon Sep 17 00:00:00 2001 From: Anton Nashatyrev Date: Tue, 15 Oct 2024 20:53:53 +0400 Subject: [PATCH] Resolve merge issue --- .../eth2/gossip/forks/GossipForkManager.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/forks/GossipForkManager.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/forks/GossipForkManager.java index 5ad99287e46..3220469395c 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/forks/GossipForkManager.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/forks/GossipForkManager.java @@ -29,7 +29,6 @@ import java.util.stream.Collectors; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.SpecMilestone; @@ -57,7 +56,7 @@ public class GossipForkManager { private static final Logger LOG = LogManager.getLogger(); private static final int EPOCHS_PRIOR_TO_FORK_TO_ACTIVATE = 2; private final Spec spec; - private final Bytes32 genesisValidatorsRoot; + private final RecentChainData recentChainData; private final NavigableMap forksByActivationEpoch; private final Set activeSubscriptions = new HashSet<>(); private final IntSet currentAttestationSubnets = new IntOpenHashSet(); @@ -68,13 +67,12 @@ public class GossipForkManager { private GossipForkManager( final Spec spec, - final Bytes32 genesisValidatorsRoot, - final boolean isHeadOptimistic, + final RecentChainData recentChainData, final NavigableMap forksByActivationEpoch) { this.spec = spec; - this.genesisValidatorsRoot = genesisValidatorsRoot; - this.isHeadOptimistic = isHeadOptimistic; + this.recentChainData = recentChainData; this.forksByActivationEpoch = forksByActivationEpoch; + this.isHeadOptimistic = recentChainData.isChainHeadOptimistic(); } public static GossipForkManager.Builder builder() { @@ -150,7 +148,10 @@ public synchronized void onOptimisticHeadChanged(final boolean isHeadOptimistic) activeSubscriptions.forEach(GossipForkSubscriptions::stopGossipForOptimisticSync); } else { activeSubscriptions.forEach( - subscriptions -> subscriptions.startGossip(genesisValidatorsRoot, false)); + subscriptions -> + subscriptions.startGossip( + recentChainData.getGenesisData().orElseThrow().getGenesisValidatorsRoot(), + false)); } } @@ -279,7 +280,9 @@ private boolean isActive(final GossipForkSubscriptions subscriptions) { private void startSubscriptions(final GossipForkSubscriptions subscription) { if (activeSubscriptions.add(subscription)) { - subscription.startGossip(genesisValidatorsRoot, isHeadOptimistic); + subscription.startGossip( + recentChainData.getGenesisData().orElseThrow().getGenesisValidatorsRoot(), + isHeadOptimistic); currentAttestationSubnets.forEach(subscription::subscribeToAttestationSubnetId); currentSyncCommitteeSubnets.forEach(subscription::subscribeToSyncCommitteeSubnet); } @@ -330,11 +333,7 @@ public GossipForkManager build() { checkNotNull(spec, "Must supply spec"); checkNotNull(recentChainData, "Must supply recentChainData"); checkState(!forksByActivationEpoch.isEmpty(), "Must specify at least one fork"); - return new GossipForkManager( - spec, - recentChainData.getGenesisData().orElseThrow().getGenesisValidatorsRoot(), - recentChainData.isChainHeadOptimistic(), - forksByActivationEpoch); + return new GossipForkManager(spec, recentChainData, forksByActivationEpoch); } } }