Skip to content

Commit

Permalink
normalize DataStorageConfiguration plugin and storage interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte committed Oct 24, 2024
1 parent 5e01e01 commit 757b592
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public DataStoreConfigurationImpl(final DataStorageConfiguration dataStorageConf
}

@Override
public DataStorageFormat getDatabaseFormat() {
public DataStorageFormat getDataStorageFormat() {
return dataStorageConfiguration.getDataStorageFormat();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
*/
package org.hyperledger.besu.ethereum.worldstate;

import org.hyperledger.besu.plugin.Unstable;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;

import org.immutables.value.Value;

@Value.Immutable
@Value.Enclosing
public interface DataStorageConfiguration {
public interface DataStorageConfiguration
extends org.hyperledger.besu.plugin.services.storage.DataStorageConfiguration {

long DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD = 512;
boolean DEFAULT_BONSAI_LIMIT_TRIE_LOGS_ENABLED = true;
Expand Down Expand Up @@ -56,15 +58,13 @@ public interface DataStorageConfiguration {
.unstable(Unstable.DEFAULT)
.build();

DataStorageFormat getDataStorageFormat();

Long getBonsaiMaxLayersToLoad();

@Value.Default
@Override
default boolean getHashPreImageStorageEnabled() {
return DEFAULT_HASH_PREIMAGE_STORAGE_ENABLED;
}
;

@Value.Default
default boolean getBonsaiLimitTrieLogsEnabled() {
Expand All @@ -77,6 +77,7 @@ default int getBonsaiTrieLogPruningWindowSize() {
}

@Value.Default
@Override
default boolean getReceiptCompactionEnabled() {
return DEFAULT_RECEIPT_COMPACTION_ENABLED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public Wei getMinGasPrice() {
getDataStorageConfiguration() {
return new org.hyperledger.besu.plugin.services.storage.DataStorageConfiguration() {
@Override
public DataStorageFormat getDatabaseFormat() {
public DataStorageFormat getDataStorageFormat() {
return DataStorageFormat.BONSAI;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
public abstract class AbstractWorldUpdater<W extends WorldView, A extends Account>
implements WorldUpdater {

/** The worldview associated with this updater. */
protected final W world;

private final EvmConfiguration evmConfiguration;

/** The Updated accounts. */
Expand Down
2 changes: 1 addition & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files
knownHash = '1RyHu/1awWJrbvx2sEeXdGO1tGq1RuAfsZmONrD2K7M='
knownHash = 'qXX4LwLi4ibYNDrXEUEFfNWCvUpcibJyeBBeltWo99k='
}
check.dependsOn('checkAPIChanges')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface DataStorageConfiguration {
* @return Database format.
*/
@Unstable
DataStorageFormat getDatabaseFormat();
DataStorageFormat getDataStorageFormat();

/**
* Whether receipt compaction is enabled. When enabled this reduces the storage needed for
Expand All @@ -40,6 +40,8 @@ public interface DataStorageConfiguration {
/**
* Indicates whether to persist hash preimages to storage. When enabled this option will persist
* Account and Hash preimages to storage upon their writing.
*
* @return whether preimage persistent storage is enabled
*/
@Unstable
boolean getHashPreImageStorageEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private DatabaseMetadata readDatabaseMetadata(final BesuConfiguration commonConf
if (!metadata
.getVersionedStorageFormat()
.getFormat()
.equals(commonConfiguration.getDataStorageConfiguration().getDatabaseFormat())) {
.equals(commonConfiguration.getDataStorageConfiguration().getDataStorageFormat())) {
handleFormatMismatch(commonConfiguration, dataDir, metadata);
}

Expand Down Expand Up @@ -278,7 +278,7 @@ private static void handleFormatMismatch(
+ "Please check your config.",
dataDir,
existingMetadata.getVersionedStorageFormat().getFormat().name(),
commonConfiguration.getDataStorageConfiguration().getDatabaseFormat());
commonConfiguration.getDataStorageConfiguration().getDataStorageFormat());

throw new StorageException(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public enum BaseVersionedStorageFormat implements VersionedStorageFormat {
*/
public static BaseVersionedStorageFormat defaultForNewDB(
final DataStorageConfiguration configuration) {
return switch (configuration.getDatabaseFormat()) {
return switch (configuration.getDataStorageFormat()) {
case FOREST -> FOREST_WITH_RECEIPT_COMPACTION;
case BONSAI -> BONSAI_WITH_RECEIPT_COMPACTION;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public enum PrivacyVersionedStorageFormat implements VersionedStorageFormat {
*/
public static VersionedStorageFormat defaultForNewDB(
final DataStorageConfiguration configuration) {
return switch (configuration.getDatabaseFormat()) {
return switch (configuration.getDataStorageFormat()) {
case FOREST -> FOREST_WITH_RECEIPT_COMPACTION;
case BONSAI -> BONSAI_WITH_RECEIPT_COMPACTION;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private static void mockCommonConfiguration(final Path tempDataDir) {
when(commonConfiguration.getStoragePath()).thenReturn(tempDataDir);
when(commonConfiguration.getDataPath()).thenReturn(tempDataDir);
DataStorageConfiguration dataStorageConfiguration = mock(DataStorageConfiguration.class);
when(dataStorageConfiguration.getDatabaseFormat()).thenReturn(DataStorageFormat.BONSAI);
when(dataStorageConfiguration.getDataStorageFormat()).thenReturn(DataStorageFormat.BONSAI);
lenient()
.when(commonConfiguration.getDataStorageConfiguration())
.thenReturn(dataStorageConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private void mockCommonConfiguration(
final DataStorageFormat dataStorageFormat) {
when(commonConfiguration.getStoragePath()).thenReturn(tempDatabaseDir);
when(commonConfiguration.getDataPath()).thenReturn(tempDataDir);
when(dataStorageConfiguration.getDatabaseFormat()).thenReturn(dataStorageFormat);
when(dataStorageConfiguration.getDataStorageFormat()).thenReturn(dataStorageFormat);
lenient()
.when(commonConfiguration.getDataStorageConfiguration())
.thenReturn(dataStorageConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private void mockCommonConfiguration(
final Path tempDataDir, final Path tempDatabaseDir, final DataStorageFormat format) {
when(commonConfiguration.getStoragePath()).thenReturn(tempDatabaseDir);
when(commonConfiguration.getDataPath()).thenReturn(tempDataDir);
lenient().when(dataStorageConfiguration.getDatabaseFormat()).thenReturn(format);
lenient().when(dataStorageConfiguration.getDataStorageFormat()).thenReturn(format);
lenient()
.when(commonConfiguration.getDataStorageConfiguration())
.thenReturn(dataStorageConfiguration);
Expand Down

0 comments on commit 757b592

Please sign in to comment.