-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create file system based BlobSidecar data archive (#8674)
Add the option --Xdata-storage-blobs-archive-path to allow pruned BlobSidecars to be written to disk. Each block/slot has all associated BlobSidecars written to disk in a filename of the block root hash and written out in JSON format.
- Loading branch information
1 parent
b50adc4
commit 5be6509
Showing
20 changed files
with
738 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
storage/src/main/java/tech/pegasys/teku/storage/archive/DataArchive.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; | ||
|
||
/** | ||
* Interface for a data archive which stores prunable BlobSidecars outside the data availability | ||
* window and could be extended later to include other data types. It is expected that the | ||
* DataArchive is on disk or externally stored with slow write and recovery times. Initial interface | ||
* is write only, but may be expanded to include read operations later. | ||
*/ | ||
public interface DataArchive { | ||
|
||
/** | ||
* Returns the archive writer capable of storing BlobSidecars. | ||
* | ||
* @return a closeable DataArchiveWriter for writing BlobSidecars | ||
* @throws IOException throw exception if it fails to get a writer. | ||
*/ | ||
DataArchiveWriter<List<BlobSidecar>> getBlobSidecarWriter() throws IOException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
storage/src/main/java/tech/pegasys/teku/storage/archive/fsarchive/BlobSidecarJsonWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.fsarchive; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition.listOf; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import tech.pegasys.teku.infrastructure.json.JsonUtil; | ||
import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; | ||
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; | ||
|
||
public class BlobSidecarJsonWriter { | ||
|
||
public void writeSlotBlobSidecars(final OutputStream out, final List<BlobSidecar> blobSidecars) | ||
throws IOException { | ||
Objects.requireNonNull(out); | ||
Objects.requireNonNull(blobSidecars); | ||
|
||
// Technically not possible as pruner prunes sidecars and not slots. | ||
if (blobSidecars.isEmpty()) { | ||
out.write("[]".getBytes(UTF_8)); | ||
return; | ||
} | ||
|
||
final SerializableTypeDefinition<List<BlobSidecar>> type = | ||
listOf(blobSidecars.getFirst().getSchema().getJsonTypeDefinition()); | ||
JsonUtil.serializeToBytes(blobSidecars, type, out); | ||
} | ||
} |
Oops, something went wrong.