Default to fast sync for named networks (#384)

We consider the named network condition to be satisfied when --network 
is explicitly used OR when it isn't supplied but neither are 
--genesis-file nor --privacy-enabled

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
pull/1045/head
Ratan Rai Sur 5 years ago committed by GitHub
parent 091ab9725e
commit c570c05a02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
  2. 7
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  3. 2
      besu/src/main/java/org/hyperledger/besu/cli/DefaultCommandValues.java
  4. 2
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  5. 4
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java

@ -85,6 +85,9 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
params.add("DEV");
}
params.add("--sync-mode");
params.add("FULL");
params.add("--discovery-enabled");
params.add(Boolean.toString(node.isDiscoveryEnabled()));

@ -368,8 +368,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
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"},
@ -1338,6 +1338,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
private BesuCommand configure() throws Exception {
syncMode =
Optional.ofNullable(syncMode)
.orElse(genesisFile == null && !isPrivacyEnabled ? SyncMode.FAST : SyncMode.FULL);
ethNetworkConfig = updateNetworkConfig(getNetwork());
jsonRpcConfiguration = jsonRpcConfiguration();
graphQLConfiguration = graphQLConfiguration();

@ -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;
@ -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;

@ -250,7 +250,7 @@ public abstract class BesuControllerBuilder<C> {
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 =

@ -192,7 +192,7 @@ public class BesuCommandTest extends CommandTestAbstract {
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));
@ -739,7 +739,7 @@ public class BesuCommandTest extends CommandTestAbstract {
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();

Loading…
Cancel
Save