Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SNAP the default sync mode for named networks #6530

Merged
merged 6 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

/**
Expand Down
14 changes: 13 additions & 1 deletion besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading