From 7cbfd4b81292c0d551729986b150db795d4d0a25 Mon Sep 17 00:00:00 2001 From: David Ryan Date: Thu, 3 Oct 2024 12:34:27 +1000 Subject: [PATCH] WIP. More spotlessApply --- .../services/chainstorage/StorageService.java | 6 +++-- .../teku/storage/archive/DataArchive.java | 18 +++++++------- .../archive/fsarchive/FileSystemArchive.java | 1 - .../archive/nooparchive/NoopDataArchive.java | 24 ++++++++++++++----- .../storage/server/StorageConfiguration.java | 6 +++-- .../cli/options/BeaconNodeDataOptions.java | 14 +++++------ 6 files changed, 41 insertions(+), 28 deletions(-) diff --git a/services/chainstorage/src/main/java/tech/pegasys/teku/services/chainstorage/StorageService.java b/services/chainstorage/src/main/java/tech/pegasys/teku/services/chainstorage/StorageService.java index 237d3e5f18a..b25be38923f 100644 --- a/services/chainstorage/src/main/java/tech/pegasys/teku/services/chainstorage/StorageService.java +++ b/services/chainstorage/src/main/java/tech/pegasys/teku/services/chainstorage/StorageService.java @@ -148,8 +148,10 @@ protected SafeFuture doStart() { } } - final DataArchive dataArchive = config.getBlobsArchivePath() - .map( path->(DataArchive) new FileSystemArchive(Path.of(path))) + final DataArchive dataArchive = + config + .getBlobsArchivePath() + .map(path -> (DataArchive) new FileSystemArchive(Path.of(path))) .orElse(new NoopDataArchive()); if (config.getSpec().isMilestoneSupported(SpecMilestone.DENEB)) { diff --git a/storage/src/main/java/tech/pegasys/teku/storage/archive/DataArchive.java b/storage/src/main/java/tech/pegasys/teku/storage/archive/DataArchive.java index 651fc938562..fe863473ff1 100644 --- a/storage/src/main/java/tech/pegasys/teku/storage/archive/DataArchive.java +++ b/storage/src/main/java/tech/pegasys/teku/storage/archive/DataArchive.java @@ -13,9 +13,8 @@ package tech.pegasys.teku.storage.archive; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; - import java.io.IOException; +import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; /** * Interface for a data archive which stores non-current BlobSidecars and could be extended later to @@ -25,12 +24,11 @@ */ public interface DataArchive { - /** - * Returns the archive writer capable of storing BlobSidecars. - * - * @return a closeable DataArchiveWriter for writing BlobSidecars - * @throws IOException - */ - DataArchiveWriter getBlobSidecarWriter() throws IOException; - + /** + * Returns the archive writer capable of storing BlobSidecars. + * + * @return a closeable DataArchiveWriter for writing BlobSidecars + * @throws IOException + */ + DataArchiveWriter getBlobSidecarWriter() throws IOException; } diff --git a/storage/src/main/java/tech/pegasys/teku/storage/archive/fsarchive/FileSystemArchive.java b/storage/src/main/java/tech/pegasys/teku/storage/archive/fsarchive/FileSystemArchive.java index 2efbcdd635f..cf6011ff593 100644 --- a/storage/src/main/java/tech/pegasys/teku/storage/archive/fsarchive/FileSystemArchive.java +++ b/storage/src/main/java/tech/pegasys/teku/storage/archive/fsarchive/FileSystemArchive.java @@ -27,7 +27,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.SlotAndBlockRoot; import tech.pegasys.teku.storage.archive.DataArchive; import tech.pegasys.teku.storage.archive.DataArchiveWriter; -import tech.pegasys.teku.storage.archive.DataArchiveWriterFactory; /** * A file system based implementations of the DataArchive. Writes to a directory using the diff --git a/storage/src/main/java/tech/pegasys/teku/storage/archive/nooparchive/NoopDataArchive.java b/storage/src/main/java/tech/pegasys/teku/storage/archive/nooparchive/NoopDataArchive.java index d4ec0c4dfe0..9a5d660cc79 100644 --- a/storage/src/main/java/tech/pegasys/teku/storage/archive/nooparchive/NoopDataArchive.java +++ b/storage/src/main/java/tech/pegasys/teku/storage/archive/nooparchive/NoopDataArchive.java @@ -1,16 +1,28 @@ +/* + * Copyright Consensys Software Inc., 2024 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + package tech.pegasys.teku.storage.archive.nooparchive; +import java.io.IOException; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; import tech.pegasys.teku.storage.archive.DataArchive; import tech.pegasys.teku.storage.archive.DataArchiveNoopWriter; import tech.pegasys.teku.storage.archive.DataArchiveWriter; -import java.io.IOException; - public class NoopDataArchive implements DataArchive { - @Override - public DataArchiveWriter getBlobSidecarWriter() throws IOException { - return DataArchiveNoopWriter.NOOP_BLOBSIDECAR_STORE; - } + @Override + public DataArchiveWriter getBlobSidecarWriter() throws IOException { + return DataArchiveNoopWriter.NOOP_BLOBSIDECAR_STORE; + } } diff --git a/storage/src/main/java/tech/pegasys/teku/storage/server/StorageConfiguration.java b/storage/src/main/java/tech/pegasys/teku/storage/server/StorageConfiguration.java index a00e0344a65..f912425119b 100644 --- a/storage/src/main/java/tech/pegasys/teku/storage/server/StorageConfiguration.java +++ b/storage/src/main/java/tech/pegasys/teku/storage/server/StorageConfiguration.java @@ -152,7 +152,9 @@ public int getBlobsPruningLimit() { return blobsPruningLimit; } - public Optional getBlobsArchivePath() { return Optional.ofNullable(blobsArchivePath); } + public Optional getBlobsArchivePath() { + return Optional.ofNullable(blobsArchivePath); + } public long getRetainedSlots() { return retainedSlots; @@ -286,7 +288,7 @@ public Builder blobsArchivePath(final String blobsArchivePath) { File file = Path.of(blobsArchivePath).toFile(); if (!file.exists()) { throw new InvalidConfigurationException( - String.format("blobsArchivePath does not exist: '%s'", blobsArchivePath)); + String.format("blobsArchivePath does not exist: '%s'", blobsArchivePath)); } } this.blobsArchivePath = blobsArchivePath; diff --git a/teku/src/main/java/tech/pegasys/teku/cli/options/BeaconNodeDataOptions.java b/teku/src/main/java/tech/pegasys/teku/cli/options/BeaconNodeDataOptions.java index 859f19c9a7b..1feeaaaa254 100644 --- a/teku/src/main/java/tech/pegasys/teku/cli/options/BeaconNodeDataOptions.java +++ b/teku/src/main/java/tech/pegasys/teku/cli/options/BeaconNodeDataOptions.java @@ -171,13 +171,13 @@ public class BeaconNodeDataOptions extends ValidatorClientDataOptions { private int blobsPruningLimit = StorageConfiguration.DEFAULT_BLOBS_PRUNING_LIMIT; @CommandLine.Option( - names = {"--Xdata-storage-archive-path"}, - hidden = true, - paramLabel = "", - description = "Path to write pruned blobs", - fallbackValue = "true", - showDefaultValue = Visibility.ALWAYS, - arity = "0..1") + names = {"--Xdata-storage-archive-path"}, + hidden = true, + paramLabel = "", + description = "Path to write pruned blobs", + fallbackValue = "true", + showDefaultValue = Visibility.ALWAYS, + arity = "0..1") private String blobsArchivePath = null; @Option(