Skip to content

Commit

Permalink
fix a handful of tests
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte committed Jul 14, 2023
1 parent 33fb8ff commit 1a6cced
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,7 @@ public BesuController build() {

Optional<Pruner> maybePruner = Optional.empty();
if (isPruningEnabled) {
if (!storageProvider.isWorldStateIterable()) {
LOG.warn(
"Cannot enable pruning with current database version. Disabling. Resync to get the latest database version or disable pruning explicitly on the command line to remove this warning.");
} else if (dataStorageConfiguration.getDataStorageFormat().equals(DataStorageFormat.BONSAI)) {
if (dataStorageConfiguration.getDataStorageFormat().equals(DataStorageFormat.BONSAI)) {
LOG.warn(
"Cannot enable pruning with Bonsai data storage format. Disabling. Change the data storage format or disable pruning explicitly on the command line to remove this warning.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ public void setup() {
when(storageProvider.createWorldStateStorage(DataStorageFormat.FOREST))
.thenReturn(worldStateStorage);
when(storageProvider.createWorldStatePreimageStorage()).thenReturn(worldStatePreimageStorage);
when(storageProvider.isWorldStateIterable()).thenReturn(true);

when(worldStateStorage.isWorldStateAvailable(any(), any())).thenReturn(true);
when(worldStatePreimageStorage.updater())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@ BlockchainStorage createBlockchainStorage(
KeyValueStorage getStorageBySegmentIdentifier(SegmentIdentifier segment);

SegmentedKeyValueStorage getStorageBySegmentIdentifiers(List<SegmentIdentifier> segment);

boolean isWorldStateIterable();
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,16 @@ public class KeyValueStorageProvider implements StorageProvider {
protected final Function<List<SegmentIdentifier>, SegmentedKeyValueStorage>
segmentedStorageCreator;
private final KeyValueStorage worldStatePreimageStorage;
private final boolean isWorldStateIterable;
protected final Map<List<SegmentIdentifier>, SegmentedKeyValueStorage> storageInstances =
new HashMap<>();
private final ObservableMetricsSystem metricsSystem;

public KeyValueStorageProvider(
final Function<List<SegmentIdentifier>, SegmentedKeyValueStorage> segmentedStorageCreator,
final KeyValueStorage worldStatePreimageStorage,
final boolean segmentIsolationSupported,
final ObservableMetricsSystem metricsSystem) {
this.segmentedStorageCreator = segmentedStorageCreator;
this.worldStatePreimageStorage = worldStatePreimageStorage;
this.isWorldStateIterable = segmentIsolationSupported;
this.metricsSystem = metricsSystem;
}

Expand Down Expand Up @@ -106,11 +103,6 @@ public SegmentedKeyValueStorage getStorageBySegmentIdentifiers(
return segmentedStorageCreator.apply(segments);
}

@Override
public boolean isWorldStateIterable() {
return isWorldStateIterable;
}

@Override
public void close() throws IOException {
storageInstances.entrySet().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import org.hyperledger.besu.plugin.services.storage.KeyValueStorageFactory;
import org.hyperledger.besu.services.kvstore.LimitedInMemoryKeyValueStorage;

import java.util.List;

public class KeyValueStorageProviderBuilder {

private static final long DEFAULT_WORLD_STATE_PRE_IMAGE_CACHE_SIZE = 5_000L;
Expand Down Expand Up @@ -60,14 +58,9 @@ public KeyValueStorageProvider build() {
final KeyValueStorage worldStatePreImageStorage =
new LimitedInMemoryKeyValueStorage(DEFAULT_WORLD_STATE_PRE_IMAGE_CACHE_SIZE);

// this tickles init needed for isSegmentIsolationSupported
storageFactory.create(
List.of(KeyValueSegmentIdentifier.BLOCKCHAIN), commonConfiguration, metricsSystem);

return new KeyValueStorageProvider(
segments -> storageFactory.create(segments, commonConfiguration, metricsSystem),
worldStatePreImageStorage,
storageFactory.isSegmentIsolationSupported(),
(ObservableMetricsSystem) metricsSystem);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public InMemoryKeyValueStorageProvider() {
super(
segmentIdentifiers -> new SegmentedInMemoryKeyValueStorage(),
new InMemoryKeyValueStorage(),
SEGMENT_ISOLATION_SUPPORTED,
new NoOpMetricsSystem());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public boolean isSegmentIsolationSupported() {

@Override
public boolean isSnapshotIsolationSupported() {
return publicFactory.isSegmentIsolationSupported();
return publicFactory.isSnapshotIsolationSupported();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public SegmentedKeyValueStorage create(
case 1, 2 -> {
if (segmentedStorage == null) {
final List<SegmentIdentifier> segmentsForVersion =
segments.stream()
configuredSegments.stream()
.filter(segmentId -> segmentId.includeInDatabaseVersion(databaseVersion))
.collect(Collectors.toList());
if (isForestStorageFormat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ public abstract class RocksDBColumnarKeyValueStorage implements SegmentedKeyValu
* Instantiates a new Rocks db columnar key value storage.
*
* @param configuration the configuration
* @param segments the segments
* @param defaultSegments the segments
* @param ignorableSegments the ignorable segments
* @param metricsSystem the metrics system
* @param rocksDBMetricsFactory the rocks db metrics factory
* @throws StorageException the storage exception
*/
public RocksDBColumnarKeyValueStorage(
final RocksDBConfiguration configuration,
final List<SegmentIdentifier> segments,
final List<SegmentIdentifier> defaultSegments,
final List<SegmentIdentifier> ignorableSegments,
final MetricsSystem metricsSystem,
final RocksDBMetricsFactory rocksDBMetricsFactory)
Expand All @@ -136,7 +136,7 @@ public RocksDBColumnarKeyValueStorage(

try {
final ColumnFamilyOptions columnFamilyOptions = new ColumnFamilyOptions();
trimmedSegments = new ArrayList<>(segments);
trimmedSegments = new ArrayList<>(defaultSegments);
final List<byte[]> existingColumnFamilies =
RocksDB.listColumnFamilies(new Options(), configuration.getDatabaseDir().toString());
// Only ignore if not existed currently
Expand Down Expand Up @@ -216,7 +216,7 @@ void initColumnHandles() throws RocksDBException {
.filter(
ch -> {
try {
return ch.getName() == segment.getId();
return Arrays.equals(ch.getName(), segment.getId());
} catch (RocksDBException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 1a6cced

Please sign in to comment.