Skip to content

Commit

Permalink
pinned sync with cli
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Feb 25, 2025
1 parent 7136d5e commit 168c22f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@

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

import java.util.Optional;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.networking.eth2.P2PConfig;

import java.util.Optional;

public class SyncConfig {

public static final boolean DEFAULT_MULTI_PEER_SYNC_ENABLED = true;
Expand All @@ -45,7 +44,7 @@ public class SyncConfig {
private final int forwardSyncMaxPendingBatches;
private final int forwardSyncMaxBlocksPerMinute;
private final int forwardSyncMaxBlobSidecarsPerMinute;
private final Optional<UInt64> pinnedSyncSlot;
private final Optional<UInt64> pinnedSyncSlot;

private SyncConfig(
final boolean isEnabled,
Expand Down Expand Up @@ -110,9 +109,9 @@ public int getForwardSyncMaxBlobSidecarsPerMinute() {
return forwardSyncMaxBlobSidecarsPerMinute;
}

public Optional<UInt64> getPinnedSyncSlot() {
return pinnedSyncSlot;
}
public Optional<UInt64> getPinnedSyncSlot() {
return pinnedSyncSlot;
}

public static class Builder {
private Boolean isEnabled;
Expand Down Expand Up @@ -141,7 +140,7 @@ public SyncConfig build() {
forwardSyncMaxPendingBatches,
forwardSyncMaxBlocksPerMinute,
forwardSyncMaxBlobSidecarsPerMinute,
pinnedSyncSlot);
pinnedSyncSlot);
}

private void initMissingDefaults() {
Expand Down Expand Up @@ -188,7 +187,8 @@ public Builder forwardSyncMaxPendingBatches(final Integer forwardSyncMaxPendingB
}

public Builder pinnedSyncSlot(final Long pinnedSyncSlot) {
Optional.ofNullable(pinnedSyncSlot).ifPresent(slot -> this.pinnedSyncSlot = Optional.of(UInt64.valueOf(slot)));
Optional.ofNullable(pinnedSyncSlot)
.ifPresent(slot -> this.pinnedSyncSlot = Optional.of(UInt64.valueOf(slot)));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ public class MultipeerCommonAncestorFinder {
}

public static MultipeerCommonAncestorFinder create(
final RecentChainData recentChainData, final EventThread eventThread,
final Optional<UInt64> pinnedSlot, final Spec spec) {
final RecentChainData recentChainData,
final EventThread eventThread,
final Optional<UInt64> pinnedSlot,
final Spec spec) {
return new MultipeerCommonAncestorFinder(
recentChainData,
new CommonAncestor(recentChainData, pinnedSlot),
eventThread,
spec);
recentChainData, new CommonAncestor(recentChainData, pinnedSlot), eventThread, spec);
}

public SafeFuture<UInt64> findCommonAncestor(final TargetChain targetChain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package tech.pegasys.teku.beacon.sync.forward.multipeer;

import java.util.Optional;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import tech.pegasys.teku.beacon.sync.events.SyncingStatus;
import tech.pegasys.teku.beacon.sync.forward.ForwardSyncService;
Expand Down Expand Up @@ -42,8 +43,6 @@
import tech.pegasys.teku.statetransition.util.PendingPool;
import tech.pegasys.teku.storage.client.RecentChainData;

import java.util.Optional;

public class MultipeerSyncService extends Service implements ForwardSyncService {
private final SyncStallDetector syncStallDetector;
private final EventThread eventThread;
Expand Down Expand Up @@ -102,7 +101,8 @@ public static MultipeerSyncService create(
eventThread, blobSidecarManager, new PeerScoringConflictResolutionStrategy()),
batchSize,
maxPendingBatches,
MultipeerCommonAncestorFinder.create(recentChainData, eventThread, pinnedCommonAncestorSlot, spec),
MultipeerCommonAncestorFinder.create(
recentChainData, eventThread, pinnedCommonAncestorSlot, spec),
timeProvider);
final SyncController syncController =
new SyncController(
Expand Down
14 changes: 7 additions & 7 deletions teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ The network interface(s) on which the node listens for P2P communication.
private boolean multiPeerSyncEnabled = SyncConfig.DEFAULT_MULTI_PEER_SYNC_ENABLED;

@Option(
names = {"--Xp2p-multipeer-sync-pinned-slot"},
paramLabel = "<NUMBER>",
showDefaultValue = Visibility.ALWAYS,
description = "Pin the sync to a specific slot",
hidden = true,
arity = "1")
names = {"--Xp2p-multipeer-sync-pinned-slot"},
paramLabel = "<NUMBER>",
showDefaultValue = Visibility.ALWAYS,
description = "Pin the sync to a specific slot",
hidden = true,
arity = "1")
private Long pinnedSyncSlot;

@Option(
Expand Down Expand Up @@ -524,7 +524,7 @@ public void configure(final TekuConfiguration.Builder builder) {
.forwardSyncMaxBlobSidecarsPerMinute(forwardSyncBlobSidecarsRateLimit)
.forwardSyncBatchSize(forwardSyncBatchSize)
.forwardSyncMaxPendingBatches(forwardSyncMaxPendingBatches)
.pinnedSyncSlot(pinnedSyncSlot));
.pinnedSyncSlot(pinnedSyncSlot));

if (subscribeAllSubnetsEnabled) {
builder
Expand Down

0 comments on commit 168c22f

Please sign in to comment.