Skip to content

Commit

Permalink
Revert "[PAN-2798] Enable pruning by default for fast sync (#135)" (#164
Browse files Browse the repository at this point in the history
)

This reverts commit 7e2497b.

Signed-off-by: Joshua Fernandes <joshua.fernandes@consensys.net>
  • Loading branch information
joshuafernandes authored Nov 6, 2019
1 parent 4549a95 commit 761cfb3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 47 deletions.
13 changes: 5 additions & 8 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,10 @@ void setBannedNodeIds(final List<String> values) {

@Option(
names = {"--pruning-enabled"},
hidden = true,
description =
"Enable pruning of world state of blocks older than the retention period (default: true if fast sync is enabled, false otherwise)")
private Boolean pruningOverride;
"Enable pruning of world state of blocks older than the retention period (default: ${DEFAULT-VALUE})")
private final Boolean isPruningEnabled = false;

@Option(
names = {"--pruning-blocks-retained"},
Expand Down Expand Up @@ -1011,7 +1012,7 @@ private void issueOptionWarnings() {
logger,
commandLine,
"--pruning-enabled",
!isPruningEnabled(),
!isPruningEnabled,
asList("--pruning-block-confirmations", "--pruning-blocks-retained"));
}

Expand Down Expand Up @@ -1087,7 +1088,7 @@ public BesuControllerBuilder<?> getControllerBuilder() {
.clock(Clock.systemUTC())
.isRevertReasonEnabled(isRevertReasonEnabled)
.storageProvider(keyStorageProvider(keyValueStorageName))
.isPruningEnabled(isPruningEnabled())
.isPruningEnabled(isPruningEnabled)
.pruningConfiguration(buildPruningConfiguration())
.genesisConfigOverrides(genesisConfigOverrides)
.targetGasLimit(targetGasLimit == null ? Optional.empty() : Optional.of(targetGasLimit))
Expand Down Expand Up @@ -1374,10 +1375,6 @@ private PruningConfiguration buildPruningConfiguration() {
return new PruningConfiguration(pruningBlockConfirmations, pruningBlocksRetained);
}

private boolean isPruningEnabled() {
return Optional.ofNullable(pruningOverride).orElse(syncMode == SyncMode.FAST);
}

// Blockchain synchronisation from peers.
private void synchronize(
final BesuController<?> controller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ public BesuControllerBuilder<C> isRevertReasonEnabled(final boolean isRevertReas
return this;
}

public BesuControllerBuilder<C> isPruningEnabled(final boolean isPruningEnabled) {
this.isPruningEnabled = isPruningEnabled;
public BesuControllerBuilder<C> isPruningEnabled(final boolean pruningEnabled) {
this.isPruningEnabled = pruningEnabled;
return this;
}

Expand Down
35 changes: 1 addition & 34 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2327,29 +2327,7 @@ public void miningParametersAreCaptured() throws Exception {
}

@Test
public void pruningIsEnabledIfSyncModeIsFast() {
parseCommand("--sync-mode", "FAST");

verify(mockControllerBuilder).isPruningEnabled(true);
verify(mockControllerBuilder).build();

assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}

@Test
public void pruningIsDisabledIfSyncModeIsFull() {
parseCommand("--sync-mode", "FULL");

verify(mockControllerBuilder).isPruningEnabled(false);
verify(mockControllerBuilder).build();

assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}

@Test
public void pruningEnabledExplicitly() {
public void pruningIsEnabledWhenSpecified() throws Exception {
parseCommand("--pruning-enabled");

verify(mockControllerBuilder).isPruningEnabled(true);
Expand All @@ -2359,17 +2337,6 @@ public void pruningEnabledExplicitly() {
assertThat(commandErrorOutput.toString()).isEmpty();
}

@Test
public void pruningDisabledExplicitly() {
parseCommand("--pruning-enabled=false");

verify(mockControllerBuilder).isPruningEnabled(false);
verify(mockControllerBuilder).build();

assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}

@Test
public void pruningOptionsRequiresServiceToBeEnabled() {

Expand Down
3 changes: 0 additions & 3 deletions besu/src/test/resources/everything_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ miner-coinbase="0x0000000000000000000000000000000000000002"
miner-extra-data="0x444F4E27542050414E4943202120484F444C2C20484F444C2C20484F444C2021"
min-gas-price=1

# Pruning
pruning-enabled=true

# Permissioning
permissions-nodes-config-file-enabled=false
permissions-nodes-config-file="./permissions_config.toml"
Expand Down

0 comments on commit 761cfb3

Please sign in to comment.