Skip to content

Commit

Permalink
Updating confusing --bonsai-maximum-back-layers-to-load option to --b…
Browse files Browse the repository at this point in the history
…onsai-historical-block-limit + remove deprecated snapshots config (#5337)

* Changing bonsai-max-back-layers-to-load to --bonsai-historical-block-limit

Signed-off-by: Matt Nelson <monels11@gmail.com>

* remove a couple other places where snapshot option was configured

Signed-off-by: garyschulte <garyschulte@gmail.com>

* Update besu/src/main/java/org/hyperledger/besu/cli/options/stable/DataStorageOptions.java

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Matt Nelson <85905982+non-fungible-nelson@users.noreply.github.com>

---------

Signed-off-by: Matt Nelson <monels11@gmail.com>
Signed-off-by: Matt Nelson <85905982+non-fungible-nelson@users.noreply.github.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
3 people authored Apr 18, 2023
1 parent 5e77b78 commit 560c548
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 40 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Offload LogBloom cache generation to computation executor, to avoid interfere with other scheduled tasks [#4530](https://github.com/hyperledger/besu/pull/4530)
- Reference tests are upgraded to use v12.1 of the ethereum tests [#5343](https://github.com/hyperledger/besu/pull/5343)
- Add new sepolia bootnodes, which should improve peering in the testnet. [#5352](https://github.com/hyperledger/besu/pull/5352)
- Renamed --bonsai-maximum-back-layers-to-load option to --bonsai-historical-block-limit for clarity. Removed --Xbonsai-use-snapshots option as it is no longer functional [#5337](https://github.com/hyperledger/besu/pull/5337)

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.hyperledger.besu.cli.options.stable;

import static org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration.DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD;
import static org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration.DEFAULT_BONSAI_USE_SNAPSHOTS;

import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
Expand All @@ -35,9 +34,7 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
private static final String DATA_STORAGE_FORMAT = "--data-storage-format";

private static final String BONSAI_STORAGE_FORMAT_MAX_LAYERS_TO_LOAD =
"--bonsai-maximum-back-layers-to-load";

private static final String BONSAI_STORAGE_FORMAT_USE_SNAPSHOTS = "--Xbonsai-use-snapshots";
"--bonsai-historical-block-limit";

// Use Bonsai DB
@Option(
Expand All @@ -48,22 +45,13 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
private final DataStorageFormat dataStorageFormat = DataStorageFormat.FOREST;

@Option(
names = {BONSAI_STORAGE_FORMAT_MAX_LAYERS_TO_LOAD},
names = {BONSAI_STORAGE_FORMAT_MAX_LAYERS_TO_LOAD, "--bonsai-maximum-back-layers-to-load"},
paramLabel = "<LONG>",
description =
"Limit of back layers that can be loaded with BONSAI (default: ${DEFAULT-VALUE}).",
"Limit of historical layers that can be loaded with BONSAI (default: ${DEFAULT-VALUE}).",
arity = "1")
private final Long bonsaiMaxLayersToLoad = DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD;

@Option(
names = {BONSAI_STORAGE_FORMAT_USE_SNAPSHOTS},
paramLabel = "<BOOLEAN>",
hidden = true,
description =
"Use database snapshots for mutable worldstates with BONSAI (default: ${DEFAULT-VALUE}).",
arity = "1")
private final Boolean bonsaiUseSnapshots = DEFAULT_BONSAI_USE_SNAPSHOTS;

/**
* Create data storage options.
*
Expand All @@ -78,7 +66,6 @@ public DataStorageConfiguration toDomainObject() {
return ImmutableDataStorageConfiguration.builder()
.dataStorageFormat(dataStorageFormat)
.bonsaiMaxLayersToLoad(bonsaiMaxLayersToLoad)
.useBonsaiSnapshots(bonsaiUseSnapshots)
.build();
}

Expand All @@ -88,9 +75,7 @@ public List<String> getCLIOptions() {
DATA_STORAGE_FORMAT,
dataStorageFormat.toString(),
BONSAI_STORAGE_FORMAT_MAX_LAYERS_TO_LOAD,
bonsaiMaxLayersToLoad.toString(),
BONSAI_STORAGE_FORMAT_USE_SNAPSHOTS,
bonsaiUseSnapshots.toString());
bonsaiMaxLayersToLoad.toString());
}

/**
Expand Down
14 changes: 1 addition & 13 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ public void privacyOnchainGroupsEnabledCannotBeUsedWithPrivacyFlexibleGroupsEnab

@Test
public void parsesValidBonsaiTrieLimitBackLayersOption() {
parseCommand("--data-storage-format", "BONSAI", "--bonsai-maximum-back-layers-to-load", "11");
parseCommand("--data-storage-format", "BONSAI", "--bonsai-historical-block-limit", "11");
verify(mockControllerBuilder)
.dataStorageConfiguration(dataStorageConfigurationArgumentCaptor.capture());

Expand All @@ -1881,18 +1881,6 @@ public void parsesValidBonsaiTrieLimitBackLayersOption() {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void parsesInvalidBonsaiTrieLimitBackLayersOption() {

parseCommand("--data-storage-format", "BONSAI", "--bonsai-maximum-back-layers-to-load", "ten");

Mockito.verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
"Invalid value for option '--bonsai-maximum-back-layers-to-load': 'ten' is not a long");
}

@Test
public void launcherDefaultOptionValue() {
final TestBesuCommand besuCommand = parseCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ public void shouldDisablePruningIfBonsaiIsEnabled() {
ImmutableDataStorageConfiguration.builder()
.dataStorageFormat(DataStorageFormat.BONSAI)
.bonsaiMaxLayersToLoad(DataStorageConfiguration.DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD)
.useBonsaiSnapshots(DataStorageConfiguration.DEFAULT_BONSAI_USE_SNAPSHOTS)
.build());
besuControllerBuilder.build();

Expand All @@ -197,7 +196,6 @@ public void shouldUsePruningIfForestIsEnabled() {
ImmutableDataStorageConfiguration.builder()
.dataStorageFormat(DataStorageFormat.FOREST)
.bonsaiMaxLayersToLoad(DataStorageConfiguration.DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD)
.useBonsaiSnapshots(DataStorageConfiguration.DEFAULT_BONSAI_USE_SNAPSHOTS)
.build());
besuControllerBuilder.build();

Expand Down
3 changes: 1 addition & 2 deletions besu/src/test/resources/everything_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ ethstats-cacert-file="./root.cert"

# Data storage
data-storage-format="BONSAI"
bonsai-maximum-back-layers-to-load=512
Xbonsai-use-snapshots=true
bonsai-historical-block-limit=512

# feature flags
Xsecp256k1-native-enabled=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@
public interface DataStorageConfiguration {

long DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD = 512;
boolean DEFAULT_BONSAI_USE_SNAPSHOTS = false;

DataStorageConfiguration DEFAULT_CONFIG =
ImmutableDataStorageConfiguration.builder()
.dataStorageFormat(DataStorageFormat.FOREST)
.bonsaiMaxLayersToLoad(DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD)
.useBonsaiSnapshots(DEFAULT_BONSAI_USE_SNAPSHOTS)
.build();

DataStorageFormat getDataStorageFormat();

Long getBonsaiMaxLayersToLoad();

Boolean useBonsaiSnapshots();
}

0 comments on commit 560c548

Please sign in to comment.