-
Notifications
You must be signed in to change notification settings - Fork 52
Feat: implement artifact builder for CardanoDatabase
#2159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dlachaume
merged 14 commits into
main
from
dlachaume/2151/implement-artifact-builder-cardano-database
Dec 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
74c6e61
refactor: move `CompressionAlgorithm` in a dedicated module
dlachaume 4bddc11
feat: add `CardanoDatabase` entity
dlachaume 92ac8ca
test: add support for ledger and volatile files management in `DummyI…
dlachaume 6cb0be1
feat: implement artifact builder for `CardanoDatabase` signed entity …
dlachaume c16d697
feat: integrate `CardanoDatabase` artifact builder into the aggregato…
dlachaume 41f2c6b
refactor: simplify and enhance database size computation and improve …
dlachaume 6b27c8b
refactor: use a more appropriate type to declare an artifact location
dlachaume 1cd900e
refactor: rename `CardanoDatabase` to `CardanoDatabaseSnapshot` and d…
dlachaume 92d63e3
refactor: update `ArtifactLocation` enum to use an internally tagged …
dlachaume f9d5379
refactor: use specific types for each `ArtifactsLocations` field
dlachaume c0587d0
refactor: streamline `compute_uncompressed_database_size`
dlachaume 3d0a0c1
refactor: update `DummyImmutablesDbBuilder` to simplify its usage
dlachaume 0beef31
refactor: secure and simplify `/ledger` and `/volatile` directories h…
dlachaume d27a9a6
chore: upgrade crate versions
dlachaume File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,83 @@ | ||
| use semver::Version; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| use crate::{ | ||
| entities::{CardanoDbBeacon, CompressionAlgorithm}, | ||
| signable_builder::Artifact, | ||
| }; | ||
|
|
||
| /// Cardano database incremental. | ||
| #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct CardanoDatabase { | ||
| /// Merkle root of the Cardano database. | ||
dlachaume marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub merkle_root: String, | ||
|
|
||
| /// Mithril beacon on the Cardano chain. | ||
| pub beacon: CardanoDbBeacon, | ||
|
|
||
| /// Size of the uncompressed Cardano database (including the ledger and volatile) in Bytes. | ||
dlachaume marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub total_db_size_uncompressed: u64, | ||
|
|
||
| /// Locations of the Cardano database artifacts. | ||
| pub locations: ArtifactsLocations, | ||
|
|
||
| /// Compression algorithm of the Cardano database archives | ||
dlachaume marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub compression_algorithm: CompressionAlgorithm, | ||
|
|
||
| /// Version of the Cardano node used to create the archives. | ||
dlachaume marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub cardano_node_version: String, | ||
| } | ||
|
|
||
| impl CardanoDatabase { | ||
| /// [CardanoDatabase] factory | ||
| pub fn new( | ||
| merkle_root: String, | ||
| beacon: CardanoDbBeacon, | ||
| total_db_size_uncompressed: u64, | ||
| locations: ArtifactsLocations, | ||
| compression_algorithm: CompressionAlgorithm, | ||
| cardano_node_version: &Version, | ||
| ) -> Self { | ||
| let cardano_node_version = format!("{cardano_node_version}"); | ||
|
|
||
| Self { | ||
| merkle_root, | ||
| beacon, | ||
| locations, | ||
| total_db_size_uncompressed, | ||
| compression_algorithm, | ||
| cardano_node_version, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum ArtifactLocationType { | ||
| Aggregator, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct ArtifactLocationEntry { | ||
| #[serde(rename = "type")] | ||
| pub location_type: ArtifactLocationType, | ||
| pub uri: String, | ||
| } | ||
|
|
||
| /// Locations of the Cardano database related files. | ||
| #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct ArtifactsLocations { | ||
| /// Locations of the file containing the digests of the immutable files. | ||
| pub digests: Vec<ArtifactLocationEntry>, | ||
| /// Locations of the immutable files. | ||
| pub immutables: Vec<ArtifactLocationEntry>, | ||
| /// Locations of the ancillary files (ledger and volatile). | ||
| pub ancillary: Vec<ArtifactLocationEntry>, | ||
| } | ||
|
|
||
| #[typetag::serde] | ||
| impl Artifact for CardanoDatabase { | ||
| fn get_id(&self) -> String { | ||
| self.merkle_root.clone() | ||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.