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

Revert "[PAN-2798] Enable pruning by default for fast sync (#135)" #164

Merged
merged 1 commit into from
Nov 6, 2019
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
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