diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ede741f64c..1f5f3e0fb3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Requesting the Ethereum Node Record (ENR) to acquire the fork id from bonded peers is now enabled by default, so the following change has been made [#5628](https://github.com/hyperledger/besu/pull/5628): - `--Xfilter-on-enr-fork-id` has been removed. To disable the feature use `--filter-on-enr-fork-id=false`. - `--engine-jwt-enabled` has been removed. Use `--engine-jwt-disabled` instead. [#6491](https://github.com/hyperledger/besu/pull/6491) +- SNAP sync is now the default for named networks [#6530](https://github.com/hyperledger/besu/pull/6530) ### Deprecations - X_SNAP and X_CHECKPOINT are marked for deprecation and will be removed in 24.4.0 in favor of SNAP and CHECKPOINT [#6405](https://github.com/hyperledger/besu/pull/6405) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 201568ac8fd..656abc5b03b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -509,7 +509,7 @@ private InetAddress autoDiscoverDefaultIP() { names = {"--sync-mode"}, paramLabel = MANDATORY_MODE_FORMAT_HELP, description = - "Synchronization mode, possible values are ${COMPLETION-CANDIDATES} (default: FAST if a --network is supplied and privacy isn't enabled. FULL otherwise.)") + "Synchronization mode, possible values are ${COMPLETION-CANDIDATES} (default: SNAP if a --network is supplied and privacy isn't enabled. FULL otherwise.)") private SyncMode syncMode = null; @Option( @@ -2659,8 +2659,8 @@ private SyncMode getDefaultSyncModeIfNotSet() { .orElse( genesisFile == null && !privacyOptionGroup.isPrivacyEnabled - && Optional.ofNullable(network).map(NetworkName::canFastSync).orElse(false) - ? SyncMode.FAST + && Optional.ofNullable(network).map(NetworkName::canSnapSync).orElse(false) + ? SyncMode.SNAP : SyncMode.FULL); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java b/besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java index 6638ddfa44e..5656abc2979 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java @@ -43,17 +43,17 @@ public enum NetworkName { private final String genesisFile; private final BigInteger networkId; - private final boolean canFastSync; + private final boolean canSnapSync; private final String deprecationDate; NetworkName(final String genesisFile, final BigInteger networkId) { this(genesisFile, networkId, true); } - NetworkName(final String genesisFile, final BigInteger networkId, final boolean canFastSync) { + NetworkName(final String genesisFile, final BigInteger networkId, final boolean canSnapSync) { this.genesisFile = genesisFile; this.networkId = networkId; - this.canFastSync = canFastSync; + this.canSnapSync = canSnapSync; // no deprecations planned this.deprecationDate = null; } @@ -77,12 +77,12 @@ public BigInteger getNetworkId() { } /** - * Can fast sync boolean. + * Can SNAP sync boolean. * * @return the boolean */ - public boolean canFastSync() { - return canFastSync; + public boolean canSnapSync() { + return canSnapSync; } /** diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index 09b7c8a2cbf..63841f12a86 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -257,7 +257,7 @@ public void callingBesuCommandWithoutOptionsMustSyncWithDefaultValues() { verify(mockControllerBuilder).build(); assertThat(storageProviderArgumentCaptor.getValue()).isNotNull(); - assertThat(syncConfigurationCaptor.getValue().getSyncMode()).isEqualTo(SyncMode.FAST); + assertThat(syncConfigurationCaptor.getValue().getSyncMode()).isEqualTo(SyncMode.SNAP); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.empty()); assertThat(miningArg.getValue().getMinTransactionGasPrice()).isEqualTo(Wei.of(1000)); @@ -1149,6 +1149,18 @@ public void syncMode_full_by_default_for_dev() { assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); } + @Test + public void syncMode_snap_by_default() { + parseCommand(); + verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture()); + + final SynchronizerConfiguration syncConfig = syncConfigurationCaptor.getValue(); + assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.SNAP); + + assertThat(commandOutput.toString(UTF_8)).isEmpty(); + assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); + } + @Test public void helpShouldDisplayFastSyncOptions() { parseCommand("--help"); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java index fcba28bd61b..008ae6a89b1 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java @@ -179,7 +179,7 @@ public void noOverrideDefaultValuesIfKeyIsNotPresentInConfigFile() { verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture()); final SynchronizerConfiguration syncConfig = syncConfigurationCaptor.getValue(); - assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.FAST); + assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.SNAP); assertThat(syncConfig.getFastSyncMinimumPeerCount()).isEqualTo(5); assertThat(commandOutput.toString(UTF_8)).isEmpty();