Skip to content

Commit 88e1e20

Browse files
6612: Remove deprecated sync modes and related helper methods
Signed-off-by: Matilda-Clerke <matilda.shay.clerke@gmail.com>
1 parent 3f00bad commit 88e1e20

File tree

7 files changed

+14
-36
lines changed

7 files changed

+14
-36
lines changed

besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,11 +1566,11 @@ private void validateConsensusSyncCompatibilityOptions() {
15661566
|| genesisConfigOptionsSupplier.get().isQbft())
15671567
&& !unstableSynchronizerOptions.isSnapSyncBftEnabled()) {
15681568
final String errorSuffix = "can't be used with BFT networks";
1569-
if (SyncMode.CHECKPOINT.equals(syncMode) || SyncMode.X_CHECKPOINT.equals(syncMode)) {
1569+
if (SyncMode.CHECKPOINT.equals(syncMode)) {
15701570
throw new ParameterException(
15711571
commandLine, String.format("%s %s", "Checkpoint sync", errorSuffix));
15721572
}
1573-
if (syncMode == SyncMode.SNAP || syncMode == SyncMode.X_SNAP) {
1573+
if (syncMode == SyncMode.SNAP) {
15741574
throw new ParameterException(commandLine, String.format("%s %s", "Snap sync", errorSuffix));
15751575
}
15761576
}
@@ -1753,7 +1753,7 @@ && isOptionSet(commandLine, "--sync-min-peers")) {
17531753
CommandLineUtils.failIfOptionDoesntMeetRequirement(
17541754
commandLine,
17551755
"--Xcheckpoint-post-merge-enabled can only be used with CHECKPOINT sync-mode",
1756-
SyncMode.isCheckpointSync(getDefaultSyncModeIfNotSet()),
1756+
getDefaultSyncModeIfNotSet() == SyncMode.CHECKPOINT,
17571757
singletonList("--Xcheckpoint-post-merge-enabled"));
17581758

17591759
CommandLineUtils.failIfOptionDoesntMeetRequirement(
@@ -2043,10 +2043,10 @@ private PrivacyParameters privacyParameters() {
20432043
if (syncMode == SyncMode.FAST) {
20442044
throw new ParameterException(commandLine, String.format("%s %s", "Fast sync", errorSuffix));
20452045
}
2046-
if (syncMode == SyncMode.SNAP || syncMode == SyncMode.X_SNAP) {
2046+
if (syncMode == SyncMode.SNAP) {
20472047
throw new ParameterException(commandLine, String.format("%s %s", "Snap sync", errorSuffix));
20482048
}
2049-
if (syncMode == SyncMode.CHECKPOINT || syncMode == SyncMode.X_CHECKPOINT) {
2049+
if (syncMode == SyncMode.CHECKPOINT) {
20502050
throw new ParameterException(
20512051
commandLine, String.format("%s %s", "Checkpoint sync", errorSuffix));
20522052
}

besu/src/main/java/org/hyperledger/besu/controller/BesuController.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
*/
1515
package org.hyperledger.besu.controller;
1616

17-
import static org.hyperledger.besu.ethereum.eth.sync.SyncMode.isCheckpointSync;
18-
1917
import org.hyperledger.besu.cli.config.EthNetworkConfig;
2018
import org.hyperledger.besu.config.GenesisConfigFile;
2119
import org.hyperledger.besu.config.GenesisConfigOptions;
@@ -361,7 +359,7 @@ public BesuControllerBuilder fromGenesisFile(
361359
// wrap with TransitionBesuControllerBuilder if we have a terminal total difficulty:
362360
if (configOptions.getTerminalTotalDifficulty().isPresent()) {
363361
// Enable start with vanilla MergeBesuControllerBuilder for PoS checkpoint block
364-
if (isCheckpointSync(syncMode) && isCheckpointPoSBlock(configOptions)) {
362+
if (syncMode == SyncMode.CHECKPOINT && isCheckpointPoSBlock(configOptions)) {
365363
return new MergeBesuControllerBuilder().genesisConfigFile(genesisConfigFile);
366364
} else {
367365
// TODO this should be changed to vanilla MergeBesuControllerBuilder and the Transition*

besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,7 @@ public BesuController build() {
708708

709709
ethPeers.setTrailingPeerRequirementsSupplier(synchronizer::calculateTrailingPeerRequirements);
710710

711-
if (SyncMode.isSnapSync(syncConfig.getSyncMode())
712-
|| SyncMode.isCheckpointSync(syncConfig.getSyncMode())) {
711+
if (syncConfig.getSyncMode() == SyncMode.SNAP || syncConfig.getSyncMode() == SyncMode.CHECKPOINT) {
713712
synchronizer.subscribeInSync((b) -> ethPeers.snapServerPeersNeeded(!b));
714713
ethPeers.snapServerPeersNeeded(true);
715714
} else {
@@ -1157,7 +1156,7 @@ protected List<PeerValidator> createPeerValidators(final ProtocolSchedule protoc
11571156

11581157
final CheckpointConfigOptions checkpointConfigOptions =
11591158
genesisConfigOptions.getCheckpointOptions();
1160-
if (SyncMode.isCheckpointSync(syncConfig.getSyncMode()) && checkpointConfigOptions.isValid()) {
1159+
if (syncConfig.getSyncMode() == SyncMode.CHECKPOINT && checkpointConfigOptions.isValid()) {
11611160
validators.add(
11621161
new CheckpointBlocksPeerValidator(
11631162
protocolSchedule,

besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ public void syncMode_invalid() {
11071107
assertThat(commandOutput.toString(UTF_8)).isEmpty();
11081108
assertThat(commandErrorOutput.toString(UTF_8))
11091109
.contains(
1110-
"Invalid value for option '--sync-mode': expected one of [FULL, FAST, SNAP, CHECKPOINT, X_SNAP, X_CHECKPOINT] (case-insensitive) but was 'bogus'");
1110+
"Invalid value for option '--sync-mode': expected one of [FULL, FAST, SNAP, CHECKPOINT] (case-insensitive) but was 'bogus'");
11111111
}
11121112

11131113
@Test

ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ private void ethPeerStatusExchanged(final EthPeer peer) {
525525

526526
peer.chainState().updateHeightEstimate(peerHeadBlockHeader.getNumber());
527527
CompletableFuture<Void> isServingSnapFuture;
528-
if (SyncMode.isCheckpointSync(syncMode) || SyncMode.isSnapSync(syncMode)) {
528+
if (syncMode == SyncMode.SNAP || syncMode == SyncMode.CHECKPOINT) {
529529
// even if we have finished the snap sync, we still want to know if the peer is a snap
530530
// server
531531
isServingSnapFuture =

ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public DefaultSynchronizer(
9999
this::calculateTrailingPeerRequirements,
100100
metricsSystem);
101101

102-
if (SyncMode.isSnapSync(syncConfig.getSyncMode())
103-
|| SyncMode.isCheckpointSync(syncConfig.getSyncMode())) {
102+
if (syncConfig.getSyncMode() == SyncMode.SNAP || syncConfig.getSyncMode() == SyncMode.CHECKPOINT) {
104103
SnapServerChecker.createAndSetSnapServerChecker(ethContext, metricsSystem);
105104
}
106105

@@ -145,7 +144,7 @@ public DefaultSynchronizer(
145144
worldStateStorageCoordinator,
146145
syncState,
147146
clock);
148-
} else if (SyncMode.isCheckpointSync(syncConfig.getSyncMode())) {
147+
} else if (syncConfig.getSyncMode() == SyncMode.CHECKPOINT) {
149148
this.fastSyncFactory =
150149
() ->
151150
CheckpointDownloaderFactory.createCheckpointDownloader(

ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncMode.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,17 @@ public enum SyncMode {
2727
// Perform snapsync
2828
SNAP,
2929
// Perform snapsync but starting from a checkpoint instead of starting from genesis
30-
CHECKPOINT,
31-
// Deprecated and will be removed in 24.4.0 (X_SNAP and X_CHECKPOINT)
32-
X_SNAP,
33-
X_CHECKPOINT;
30+
CHECKPOINT;
3431

3532
public String normalize() {
36-
if (this.toString().startsWith("X_")) {
37-
// removes X_ at the beginning
38-
return StringUtils.capitalize(this.toString().substring(2).toLowerCase(Locale.ROOT));
39-
}
40-
4133
return StringUtils.capitalize(this.toString().toLowerCase(Locale.ROOT));
4234
}
4335

4436
public static boolean isFullSync(final SyncMode syncMode) {
4537
return !EnumSet.of(
4638
SyncMode.FAST,
4739
SyncMode.SNAP,
48-
SyncMode.X_SNAP,
49-
SyncMode.CHECKPOINT,
50-
SyncMode.X_CHECKPOINT)
40+
SyncMode.CHECKPOINT)
5141
.contains(syncMode);
5242
}
53-
54-
public static boolean isCheckpointSync(final SyncMode syncMode) {
55-
return X_CHECKPOINT.equals(syncMode) || CHECKPOINT.equals(syncMode);
56-
}
57-
58-
public static boolean isSnapSync(final SyncMode syncMode) {
59-
return X_SNAP.equals(syncMode) || SNAP.equals(syncMode);
60-
}
6143
}

0 commit comments

Comments
 (0)