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

Default to fast sync for named networks #384

Merged
merged 13 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from 12 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
7 changes: 5 additions & 2 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ void setBannedNodeIds(final List<String> values) {
names = {"--sync-mode"},
paramLabel = MANDATORY_MODE_FORMAT_HELP,
description =
"Synchronization mode, possible values are ${COMPLETION-CANDIDATES} (default: ${DEFAULT-VALUE})")
private final SyncMode syncMode = DEFAULT_SYNC_MODE;
"Synchronization mode, possible values are ${COMPLETION-CANDIDATES} (default: FAST if a --network is supplied and privacy isn't enabled. FULL otherwise.)")
private SyncMode syncMode = null;

@Option(
names = {"--fast-sync-min-peers"},
Expand Down Expand Up @@ -1338,6 +1338,9 @@ private void issueOptionWarnings() {
}

private BesuCommand configure() throws Exception {
syncMode =
Optional.ofNullable(syncMode)
.orElse(genesisFile == null && !isPrivacyEnabled ? SyncMode.FAST : SyncMode.FULL);
ethNetworkConfig = updateNetworkConfig(getNetwork());
jsonRpcConfiguration = jsonRpcConfiguration();
graphQLConfiguration = graphQLConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.hyperledger.besu.cli;

import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.p2p.config.RlpxConfiguration;
import org.hyperledger.besu.nat.NatMethod;

Expand Down Expand Up @@ -52,7 +51,6 @@ public interface DefaultCommandValues {
String PERMISSIONING_CONFIG_LOCATION = "permissions_config.toml";
String MANDATORY_HOST_FORMAT_HELP = "<HOST>";
String MANDATORY_PORT_FORMAT_HELP = "<PORT>";
SyncMode DEFAULT_SYNC_MODE = SyncMode.FULL;
NatMethod DEFAULT_NAT_METHOD = NatMethod.AUTO;
int FAST_SYNC_MIN_PEER_COUNT = 5;
int DEFAULT_MAX_PEERS = 25;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public BesuController<C> build() {
metricsSystem);
final EthContext ethContext = new EthContext(ethPeers, ethMessages, scheduler);
final SyncState syncState = new SyncState(blockchain, ethPeers);
final boolean fastSyncEnabled = syncConfig.getSyncMode().equals(SyncMode.FAST);
final boolean fastSyncEnabled = SyncMode.FAST.equals(syncConfig.getSyncMode());

final Optional<EIP1559> eip1559;
final GenesisConfigOptions genesisConfigOptions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void callingBesuCommandWithoutOptionsMustSyncWithDefaultValues() throws E
verify(mockControllerBuilder).build();

assertThat(storageProviderArgumentCaptor.getValue()).isNotNull();
assertThat(syncConfigurationCaptor.getValue().getSyncMode()).isEqualTo(SyncMode.FULL);
assertThat(syncConfigurationCaptor.getValue().getSyncMode()).isEqualTo(SyncMode.FAST);
assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.empty());
assertThat(miningArg.getValue().getMinTransactionGasPrice()).isEqualTo(Wei.of(1000));
Expand Down Expand Up @@ -739,7 +739,7 @@ public void noOverrideDefaultValuesIfKeyIsNotPresentInConfigFile() throws IOExce
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());

final SynchronizerConfiguration syncConfig = syncConfigurationCaptor.getValue();
assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.FULL);
assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.FAST);
assertThat(syncConfig.getFastSyncMinimumPeerCount()).isEqualTo(5);

assertThat(commandErrorOutput.toString()).isEmpty();
Expand Down