diff --git a/.github/workflows/test-client.yml b/.github/workflows/test-client.yml index 7f50697198c..af6930145f2 100644 --- a/.github/workflows/test-client.yml +++ b/.github/workflows/test-client.yml @@ -87,7 +87,7 @@ jobs: aria2c -o aggregator_capabilities.json $AGGREGATOR_ENDPOINT CTX_CAPABILITY=$(jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])' aggregator_capabilities.json) echo "ctx_enabled=$CTX_CAPABILITY" >> $GITHUB_OUTPUT - + - name: Checkout binary uses: dawidd6/action-download-artifact@v3 with: @@ -108,17 +108,25 @@ jobs: working-directory: ./bin run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} --version - - name: Snapshot / list and get last digest + - name: Cardano-db / list and get last digest shell: bash working-directory: ./bin run: | - ./mithril-client ${{ steps.prepare.outputs.debug_level }} snapshot list - echo "SNAPSHOT_DIGEST=$(./mithril-client snapshot list --json | jq -r '.[0].digest')" >> $GITHUB_ENV + ./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-db snapshot list + echo "CDB_SNAPSHOT_DIGEST=$(./mithril-client cardano-db snapshot list --json | jq -r '.[0].digest')" >> $GITHUB_ENV + + - name: Cardano-db / download & restore latest + shell: bash + working-directory: ./bin + run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-db download $CDB_SNAPSHOT_DIGEST - - name: Snapshot / download & restore latest + - name: Cardano-db / check old 'snapshot' commands availability shell: bash working-directory: ./bin - run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} snapshot download $SNAPSHOT_DIGEST + run: | + ./mithril-client ${{ steps.prepare.outputs.debug_level }} snapshot list --help + ./mithril-client ${{ steps.prepare.outputs.debug_level }} snapshot show --help + ./mithril-client ${{ steps.prepare.outputs.debug_level }} snapshot download --help - name: Mithril Stake Distribution / list and get last hash shell: bash @@ -132,19 +140,19 @@ jobs: working-directory: ./bin run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} mithril-stake-distribution download $MITHRIL_STAKE_DISTRIBUTION_HASH - - name: Cardano transaction / list and get last commitment + - name: Cardano transaction / list and get last snapshot if: steps.aggregator_capability_unix.outputs.ctx_enabled == 'true' || steps.aggregator_capability_windows.outputs.ctx_enabled == 'true' shell: bash working-directory: ./bin run: | - ./mithril-client ${{ steps.prepare.outputs.debug_level }} --unstable cardano-transaction commitment list - echo "CTX_COMMITMENT_HASH=$(./mithril-client --unstable cardano-transaction commitment list --json | jq -r '.[0].hash')" >> $GITHUB_ENV + ./mithril-client ${{ steps.prepare.outputs.debug_level }} --unstable cardano-transaction snapshot list + echo "CTX_SNAPSHOT_HASH=$(./mithril-client --unstable cardano-transaction snapshot list --json | jq -r '.[0].hash')" >> $GITHUB_ENV - - name: Cardano transaction / show commitment + - name: Cardano transaction / show snapshot if: steps.aggregator_capability_unix.outputs.ctx_enabled == 'true' || steps.aggregator_capability_windows.outputs.ctx_enabled == 'true' shell: bash working-directory: ./bin - run: ./mithril-client --unstable cardano-transaction commitment show $CTX_COMMITMENT_HASH + run: ./mithril-client --unstable cardano-transaction snapshot show $CTX_SNAPSHOT_HASH - name: Cardano transaction certify if: steps.aggregator_capability_unix.outputs.ctx_enabled == 'true' || steps.aggregator_capability_windows.outputs.ctx_enabled == 'true' @@ -190,15 +198,22 @@ jobs: shell: bash run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} --version - - name: Snapshot / list and get last digest + - name: Cardano-db / list and get last digest shell: bash run: | - ${{ steps.command.outputs.mithril_client }} snapshot list - echo "SNAPSHOT_DIGEST=$(${{ steps.command.outputs.mithril_client }} snapshot list --json | jq -r '.[0].digest')" >> $GITHUB_ENV + ${{ steps.command.outputs.mithril_client }} cardano-db snapshot list + echo "CDB_SNAPSHOT_DIGEST=$(${{ steps.command.outputs.mithril_client }} cardano-db snapshot list --json | jq -r '.[0].digest')" >> $GITHUB_ENV - - name: Snapshot / download & restore latest + - name: Cardano-db / download & restore latest shell: bash - run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} snapshot download $SNAPSHOT_DIGEST --download-dir /app + run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} cardano-db download $CDB_SNAPSHOT_DIGEST --download-dir /app + + - name: Cardano-db / check old 'snapshot' commands availability + shell: bash + run: | + ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} snapshot list --help + ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} snapshot show --help + ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} snapshot download --help - name: Mithril Stake Distribution / list and get last hash shell: bash @@ -210,18 +225,18 @@ jobs: shell: bash run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} mithril-stake-distribution download $MITHRIL_STAKE_DISTRIBUTION_HASH --download-dir /app - - name: Cardano transaction / list and get last commitment + - name: Cardano transaction / list and get last snapshot if: steps.aggregator_capability.outputs.ctx_enabled == 'true' shell: bash run: | - ${{ steps.command.outputs.mithril_client }} --unstable cardano-transaction commitment list - echo "CTX_COMMITMENT_HASH=$(${{ steps.command.outputs.mithril_client }} --unstable cardano-transaction commitment list --json | jq -r '.[0].hash')" >> $GITHUB_ENV + ${{ steps.command.outputs.mithril_client }} --unstable cardano-transaction snapshot list + echo "CTX_SNAPSHOT_HASH=$(${{ steps.command.outputs.mithril_client }} --unstable cardano-transaction snapshot list --json | jq -r '.[0].hash')" >> $GITHUB_ENV - - name: Cardano transaction / show commitment + - name: Cardano transaction / show snapshot if: steps.aggregator_capability.outputs.ctx_enabled == 'true' shell: bash - run: ${{ steps.command.outputs.mithril_client }} --unstable cardano-transaction commitment show $CTX_COMMITMENT_HASH - + run: ${{ steps.command.outputs.mithril_client }} --unstable cardano-transaction snapshot show $CTX_SNAPSHOT_HASH + - name: Cardano transaction certify if: steps.aggregator_capability.outputs.ctx_enabled == 'true' shell: bash diff --git a/Cargo.lock b/Cargo.lock index 925b88e83e4..4174dbd54f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3331,7 +3331,7 @@ dependencies = [ [[package]] name = "mithril-aggregator" -version = "0.4.42" +version = "0.4.43" dependencies = [ "anyhow", "async-trait", @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "mithril-aggregator-fake" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "axum", @@ -3396,7 +3396,7 @@ dependencies = [ [[package]] name = "mithril-build-script" -version = "0.1.1" +version = "0.1.2" dependencies = [ "semver", "serde_yaml", @@ -3404,7 +3404,7 @@ dependencies = [ [[package]] name = "mithril-client" -version = "0.6.5" +version = "0.6.6" dependencies = [ "anyhow", "async-recursion", @@ -3437,7 +3437,7 @@ dependencies = [ [[package]] name = "mithril-client-cli" -version = "0.7.2" +version = "0.7.3" dependencies = [ "anyhow", "async-trait", @@ -3467,7 +3467,7 @@ dependencies = [ [[package]] name = "mithril-client-wasm" -version = "0.2.1" +version = "0.2.2" dependencies = [ "async-trait", "futures", @@ -3483,7 +3483,7 @@ dependencies = [ [[package]] name = "mithril-common" -version = "0.3.10" +version = "0.3.11" dependencies = [ "anyhow", "async-trait", @@ -3555,7 +3555,7 @@ dependencies = [ [[package]] name = "mithril-end-to-end" -version = "0.4.2" +version = "0.4.3" dependencies = [ "anyhow", "async-recursion", diff --git a/docs/website/root/glossary.md b/docs/website/root/glossary.md index 1f5256bcd68..819132024e1 100644 --- a/docs/website/root/glossary.md +++ b/docs/website/root/glossary.md @@ -28,7 +28,7 @@ A Cardano key pair is an asymmetric key pair used to identify a [stake pool oper A Cardano transaction proof is a cryptographic proof that a sub-set of Cardano transactions is included in the Cardano transactions set. It is generated upon request from a [Mithril client](#mithril-client) and is signed by a [certificate](#certificate). -A Cardano transactions set commitment represents, in a succinct way, the Cardano transactions set that was signed by Mithril at a given [Beacon](#beacon). +A Cardano transactions set snapshot represents, in a succinct way, the Cardano transactions set that was signed by Mithril at a given [Beacon](#beacon). ## Certificate diff --git a/docs/website/root/manual/developer-docs/nodes/mithril-client-library-wasm.md b/docs/website/root/manual/developer-docs/nodes/mithril-client-library-wasm.md index 230c3c24155..6265e1d314f 100644 --- a/docs/website/root/manual/developer-docs/nodes/mithril-client-library-wasm.md +++ b/docs/website/root/manual/developer-docs/nodes/mithril-client-library-wasm.md @@ -14,7 +14,7 @@ Mithril client library WASM can be used by Javascript developers to use the Mith It is responsible for handling the different types of data certified by Mithril, and available through a Mithril aggregator: - [**Snapshot**](../../../glossary.md#snapshot): list and get. - [**Mithril stake distribution**](../../../glossary.md#stake-distribution): list and get. -- [**Cardano transaction**](../../../glossary.md#cardano-transaction): list & get commitments, get proofs +- [**Cardano transaction**](../../../glossary.md#cardano-transaction): list & get snapshots, get proofs - [**Certificate**](../../../glossary.md#certificate): list, get, and chain validation. ::: diff --git a/docs/website/root/manual/developer-docs/nodes/mithril-client.md b/docs/website/root/manual/developer-docs/nodes/mithril-client.md index af08c0ff1fe..adb8596a4f7 100644 --- a/docs/website/root/manual/developer-docs/nodes/mithril-client.md +++ b/docs/website/root/manual/developer-docs/nodes/mithril-client.md @@ -126,7 +126,8 @@ This program shows, downloads and verifies certified blockchain artifacts. Usage: mithril-client [OPTIONS] Commands: - snapshot Snapshot management + snapshot Deprecated, use `cardano-db` instead + cardano-db Cardano db management (alias: cdb) mithril-stake-distribution Mithril Stake Distribution management (alias: msd) cardano-transaction [unstable] Cardano transactions management (alias: ctx) help Print this message or the help of the given subcommand(s) @@ -150,7 +151,6 @@ Options: Print help -V, --version Print version - ``` Run in release mode with the default configuration: @@ -237,14 +237,14 @@ Now you can use the `mithril_client` functions: # 1- Help mithril_client help -# 2- List snapshots -mithril_client snapshot list +# 2- List cardano db snapshots +mithril_client cardano-db snapshot list -# 3- Show detailed information about a snapshot -mithril_client snapshot show $SNAPSHOT_DIGEST +# 3- Show detailed information about a cardano db snapshot +mithril_client cardano-db snapshot show $CARDANO_DB_DIGEST -# 4- Download the given snapshot and verify the certificate -mithril_client snapshot download $SNAPSHOT_DIGEST +# 4- Download the given cardano db and verify the certificate +mithril_client cardano-db download $CARDANO_DB_DIGEST # 5- List Mithril stake distributions mithril_client mithril-stake-distribution list @@ -252,11 +252,11 @@ mithril_client mithril-stake-distribution list # 6- Download and verify the given Mithril stake distribution mithril_client mithril-stake-distribution download $MITHRIL_STAKE_DISTRIBUTION_ARTIFACT_HASH -# 7- List Cardano transaction commitments -mithril_client --unstable cardano-transaction commitment list +# 7- List Cardano transaction snapshots +mithril_client --unstable cardano-transaction snapshot list -# 8- Show detailed information about a Cardano transaction commitment -mithril_client --unstable cardano-transaction commitment show $CARDANO_TRANSACTION_COMMITMENT_HASH +# 8- Show detailed information about a Cardano transaction snapshot +mithril_client --unstable cardano-transaction snapshot show $CARDANO_TRANSACTION_SNAPSHOT_HASH # 9- Certify that given list of transactions hashes are included in the Cardano transactions set mithril_client --unstable cardano-transaction certify $TRANSACTION_HASH_1,$TRANSACTION_HASH_2 @@ -280,14 +280,28 @@ make docker-run Here are the subcommands available: +### Cardano DB (previously: Snapshot) + +| Subcommand | Performed action | +|------------|------------------| +| **download** | Downloads and restores a cardano-db snapshot| +| **help** | Prints this message or the help for the given subcommand(s)| +| **snapshot list** | Lists available cardano-db snapshots| +| **snapshot show** | Shows information about a cardano-db snapshot| + ### Snapshot +:::warning +The `snapshot` commands are now **deprecated** and has been superseded by the `cardano-db` commands. +The `snapshot` commands will be removed in the near future. +::: + | Subcommand | Performed action | |------------|------------------| -| **download** | Downloads and restores a snapshot| +| **download** | Downloads and restores a cardano-db snapshot| | **help** | Prints this message or the help for the given subcommand(s)| -| **list** | Lists available snapshots| -| **show** | Shows information about a snapshot| +| **list** | Lists available cardano-db snapshots| +| **show** | Shows information about a cardano-db snapshot| ### Mithril stake distribution @@ -302,8 +316,8 @@ Here are the subcommands available: | Subcommand | Performed action | |------------|------------------| | **certify** | Certifies that given list of transactions hashes are included in the Cardano transactions set| -| **commitment list** | Lists available Cardano transactions commitments| -| **commitment show** | Shows information about a Cardano transactions commitment| +| **snapshot list** | Lists available Cardano transactions snapshots| +| **snapshot show** | Shows information about a Cardano transactions snapshot| | **help** | Prints this message or the help for the given subcommand(s)| ## Configuration parameters @@ -328,25 +342,25 @@ Here is a list of the available parameters: | `log_format_json` | `--log-format-json` | - | - | Enable JSON output for logs | - | - | - | | `log_output` | `--log-output` | `-o` | - | Redirect the logs to a file | - | `./mithril-client.log` | - | -`snapshot show` command: +`cardano-db snapshot show` or `snapshot show` command: | Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory | |-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:| -| `digest` | `--digest` | - | `DIGEST` | Snapshot digest or `latest` for the latest digest | - | - | :heavy_check_mark: | +| `digest` | `--digest` | - | `DIGEST` | Cardano DB digest or `latest` for the latest digest | - | - | :heavy_check_mark: | | `json` | `--json` | - | - | Enable JSON output for command results | - | - | - | -`snapshot list` command: +`cardano-db snapshot list` or `snapshot list` command: | Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory | |-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:| | `json` | `--json` | - | - | Enable JSON output for command results | - | - | - | -`snapshot download` command: +`cardano-db download` or `snapshot download` command: | Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory | |-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:| -| `digest` | `--digest` | - | `DIGEST` | Snapshot digest or `latest` for the latest digest | - | - | :heavy_check_mark: | -| `download_dir` | `--download-dir` | - | - | Directory where the snapshot will be downloaded | . | - | - | +| `digest` | `--digest` | - | `DIGEST` | Cardano DB digest or `latest` for the latest digest | - | - | :heavy_check_mark: | +| `download_dir` | `--download-dir` | - | - | Directory where the Cardano DB will be downloaded | . | - | - | | `json` | `--json` | - | - | Enable JSON output for progress logs | - | - | - | `mithril-stake-distribution list` command: @@ -362,14 +376,14 @@ Here is a list of the available parameters: | `artifact_hash` | `--artifact-hash` | - | - | Hash of the Mithril stake distribution artifact or `latest` for the latest artifact | - | - | :heavy_check_mark: | | `download_dir` | `--download-dir` | - | - | Directory where the Mithril stake distribution will be downloaded | . | - | - | -`cardano-transaction commitment show` command: +`cardano-transaction snapshot show` command: | Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory | |-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:| -| `hash` | `--hash` | - | `HASH` | Cardano transaction commitment hash or `latest` for the latest Cardano transaction commitment | - | - | :heavy_check_mark: | +| `hash` | `--hash` | - | `HASH` | Cardano transaction snapshot hash or `latest` for the latest Cardano transaction snapshot | - | - | :heavy_check_mark: | | `json` | `--json` | - | - | Enable JSON output for command results | - | - | - | -`cardano-transaction commitment list` command: +`cardano-transaction snapshot list` command: | Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory | |-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:| diff --git a/internal/mithril-build-script/Cargo.toml b/internal/mithril-build-script/Cargo.toml index f614abe1767..d12ebebce8a 100644 --- a/internal/mithril-build-script/Cargo.toml +++ b/internal/mithril-build-script/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-build-script" -version = "0.1.1" +version = "0.1.2" description = "A toolbox for Mithril crates build scripts" authors = { workspace = true } edition = { workspace = true } diff --git a/internal/mithril-build-script/src/fake_aggregator.rs b/internal/mithril-build-script/src/fake_aggregator.rs index 5620c19b7b4..a1f1bfe0d9b 100644 --- a/internal/mithril-build-script/src/fake_aggregator.rs +++ b/internal/mithril-build-script/src/fake_aggregator.rs @@ -22,8 +22,8 @@ pub struct FakeAggregatorData { msds_list: FileContent, individual_msds: BTreeMap, - ctx_commitments_list: FileContent, - individual_ctx_commitments: BTreeMap, + ctx_snapshots_list: FileContent, + individual_ctx_snapshots: BTreeMap, ctx_proofs: BTreeMap, } @@ -58,8 +58,8 @@ impl FakeAggregatorData { "certificates.json" => { data.certificates_list = file_content; } - "ctx-commitments.json" => { - data.ctx_commitments_list = file_content; + "ctx-snapshots.json" => { + data.ctx_snapshots_list = file_content; } _ if filename.starts_with("mithril-stake-distribution-") => { data.individual_msds.insert( @@ -75,9 +75,9 @@ impl FakeAggregatorData { data.individual_certificates .insert(extract_artifact_id(&filename, "certificate-"), file_content); } - _ if filename.starts_with("ctx-commitment-") => { - data.individual_ctx_commitments.insert( - extract_artifact_id(&filename, "ctx-commitment-"), + _ if filename.starts_with("ctx-snapshot-") => { + data.individual_ctx_snapshots.insert( + extract_artifact_id(&filename, "ctx-snapshot-"), file_content, ); } @@ -109,8 +109,8 @@ impl FakeAggregatorData { BTreeSet::from_iter(self.individual_certificates.keys().cloned()), ), generate_ids_array( - "ctx_commitment_hashes", - BTreeSet::from_iter(self.individual_ctx_commitments.keys().cloned()), + "ctx_snapshot_hashes", + BTreeSet::from_iter(self.individual_ctx_snapshots.keys().cloned()), ), generate_ids_array( "proof_transaction_hashes", @@ -144,11 +144,11 @@ impl FakeAggregatorData { generate_artifact_getter("certificates", self.individual_certificates), generate_list_getter("certificate_list", self.certificates_list), generate_ids_array( - "ctx_commitment_hashes", - BTreeSet::from_iter(self.individual_ctx_commitments.keys().cloned()), + "ctx_snapshot_hashes", + BTreeSet::from_iter(self.individual_ctx_snapshots.keys().cloned()), ), - generate_artifact_getter("ctx_commitments", self.individual_ctx_commitments), - generate_list_getter("ctx_commitments_list", self.ctx_commitments_list), + generate_artifact_getter("ctx_snapshots", self.individual_ctx_snapshots), + generate_list_getter("ctx_snapshots_list", self.ctx_snapshots_list), generate_ids_array( "proof_transaction_hashes", BTreeSet::from_iter(self.ctx_proofs.keys().cloned()), diff --git a/mithril-aggregator/Cargo.toml b/mithril-aggregator/Cargo.toml index 2f684350a98..e7135de36bb 100644 --- a/mithril-aggregator/Cargo.toml +++ b/mithril-aggregator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator" -version = "0.4.42" +version = "0.4.43" description = "A Mithril Aggregator server" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-aggregator/src/artifact_builder/cardano_transactions.rs b/mithril-aggregator/src/artifact_builder/cardano_transactions.rs index 19c265bd43b..b65a6658801 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_transactions.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_transactions.rs @@ -4,8 +4,7 @@ use super::ArtifactBuilder; use anyhow::{anyhow, Context}; use mithril_common::{ entities::{ - Beacon, CardanoTransactionsCommitment, Certificate, ProtocolMessagePartKey, - SignedEntityType, + Beacon, CardanoTransactionsSnapshot, Certificate, ProtocolMessagePartKey, SignedEntityType, }, StdResult, }; @@ -21,12 +20,12 @@ impl CardanoTransactionsArtifactBuilder { } #[async_trait] -impl ArtifactBuilder for CardanoTransactionsArtifactBuilder { +impl ArtifactBuilder for CardanoTransactionsArtifactBuilder { async fn compute_artifact( &self, beacon: Beacon, certificate: &Certificate, - ) -> StdResult { + ) -> StdResult { let merkle_root = certificate .protocol_message .get_message_part(&ProtocolMessagePartKey::CardanoTransactionsMerkleRoot) @@ -40,7 +39,7 @@ impl ArtifactBuilder for CardanoTransacti ) })?; - Ok(CardanoTransactionsCommitment::new( + Ok(CardanoTransactionsSnapshot::new( merkle_root.to_string(), beacon, )) @@ -75,7 +74,7 @@ mod tests { .await .unwrap(); let artifact_expected = - CardanoTransactionsCommitment::new("merkleroot".to_string(), certificate.beacon); + CardanoTransactionsSnapshot::new("merkleroot".to_string(), certificate.beacon); assert_eq!(artifact_expected, artifact); } diff --git a/mithril-aggregator/src/database/provider/signed_entity.rs b/mithril-aggregator/src/database/provider/signed_entity.rs index 735b89e5c39..30cd6690a19 100644 --- a/mithril-aggregator/src/database/provider/signed_entity.rs +++ b/mithril-aggregator/src/database/provider/signed_entity.rs @@ -11,7 +11,7 @@ use mithril_common::{ Beacon, Epoch, SignedEntity, SignedEntityType, SignedEntityTypeDiscriminants, Snapshot, }, messages::{ - CardanoTransactionCommitmentListItemMessage, CardanoTransactionCommitmentMessage, + CardanoTransactionSnapshotListItemMessage, CardanoTransactionSnapshotMessage, MithrilStakeDistributionListItemMessage, MithrilStakeDistributionMessage, SignerWithStakeMessagePart, SnapshotListItemMessage, SnapshotMessage, }, @@ -140,7 +140,7 @@ impl TryFrom for MithrilStakeDistributionListItemMessage { } } -impl TryFrom for CardanoTransactionCommitmentMessage { +impl TryFrom for CardanoTransactionSnapshotMessage { type Error = StdError; fn try_from(value: SignedEntityRecord) -> Result { @@ -151,7 +151,7 @@ impl TryFrom for CardanoTransactionCommitmentMessage { hash: String, } let artifact = serde_json::from_str::(&value.artifact)?; - let cardano_transaction_message = CardanoTransactionCommitmentMessage { + let cardano_transaction_message = CardanoTransactionSnapshotMessage { merkle_root: artifact.merkle_root, beacon: artifact.beacon, hash: artifact.hash, @@ -163,7 +163,7 @@ impl TryFrom for CardanoTransactionCommitmentMessage { } } -impl TryFrom for CardanoTransactionCommitmentListItemMessage { +impl TryFrom for CardanoTransactionSnapshotListItemMessage { type Error = StdError; fn try_from(value: SignedEntityRecord) -> Result { @@ -174,7 +174,7 @@ impl TryFrom for CardanoTransactionCommitmentListItemMessage hash: String, } let artifact = serde_json::from_str::(&value.artifact)?; - let message = CardanoTransactionCommitmentListItemMessage { + let message = CardanoTransactionSnapshotListItemMessage { merkle_root: artifact.merkle_root, beacon: artifact.beacon, hash: artifact.hash, diff --git a/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_transaction.rs b/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_transaction.rs index 6ae53211026..6069ef47e61 100644 --- a/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_transaction.rs +++ b/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_transaction.rs @@ -123,7 +123,7 @@ pub mod tests { async fn test_cardano_transactions_get_ok() { let signed_entity_records = create_signed_entities( SignedEntityType::CardanoTransactions(Beacon::default()), - fake_data::cardano_transactions_commitment(5), + fake_data::cardano_transactions_snapshot(5), ); let message = ToCardanoTransactionListMessageAdapter::adapt(signed_entity_records); let mut mock_http_message_service = MockMessageService::new(); @@ -186,7 +186,7 @@ pub mod tests { async fn test_cardano_transaction_get_ok() { let signed_entity = create_signed_entities( SignedEntityType::CardanoTransactions(Beacon::default()), - fake_data::cardano_transactions_commitment(1), + fake_data::cardano_transactions_snapshot(1), ) .first() .unwrap() diff --git a/mithril-aggregator/src/http_server/routes/proof_routes.rs b/mithril-aggregator/src/http_server/routes/proof_routes.rs index 409ce0fa298..5357528bd36 100644 --- a/mithril-aggregator/src/http_server/routes/proof_routes.rs +++ b/mithril-aggregator/src/http_server/routes/proof_routes.rs @@ -67,7 +67,7 @@ mod handlers { match unwrap_to_internal_server_error!( signed_entity_service - .get_last_cardano_transaction_commitment() + .get_last_cardano_transaction_snapshot() .await, "proof_cardano_transaction::error" ) { @@ -109,7 +109,7 @@ mod tests { use anyhow::anyhow; use mithril_common::entities::{ - CardanoTransactionsCommitment, CardanoTransactionsSetProof, SignedEntity, + CardanoTransactionsSetProof, CardanoTransactionsSnapshot, SignedEntity, }; use serde_json::Value::Null; use warp::{http::Method, test::request}; @@ -140,8 +140,8 @@ mod tests { let mut dependency_manager = builder.build_dependency_container().await.unwrap(); let mut mock_signed_entity_service = MockSignedEntityService::new(); mock_signed_entity_service - .expect_get_last_cardano_transaction_commitment() - .returning(|| Ok(Some(SignedEntity::::dummy()))); + .expect_get_last_cardano_transaction_snapshot() + .returning(|| Ok(Some(SignedEntity::::dummy()))); dependency_manager.signed_entity_service = Arc::new(mock_signed_entity_service); let mut mock_prover_service = MockProverService::new(); @@ -205,7 +205,7 @@ mod tests { let mut dependency_manager = builder.build_dependency_container().await.unwrap(); let mut mock_signed_entity_service = MockSignedEntityService::new(); mock_signed_entity_service - .expect_get_last_cardano_transaction_commitment() + .expect_get_last_cardano_transaction_snapshot() .returning(|| Err(anyhow!("Error"))); dependency_manager.signed_entity_service = Arc::new(mock_signed_entity_service); diff --git a/mithril-aggregator/src/message_adapters/to_cardano_transaction_list_message.rs b/mithril-aggregator/src/message_adapters/to_cardano_transaction_list_message.rs index f4e2f3e98e1..c8db36ffc85 100644 --- a/mithril-aggregator/src/message_adapters/to_cardano_transaction_list_message.rs +++ b/mithril-aggregator/src/message_adapters/to_cardano_transaction_list_message.rs @@ -1,25 +1,25 @@ -use mithril_common::entities::{CardanoTransactionsCommitment, SignedEntity}; +use mithril_common::entities::{CardanoTransactionsSnapshot, SignedEntity}; use mithril_common::messages::{ - CardanoTransactionCommitmentListItemMessage, CardanoTransactionCommitmentListMessage, + CardanoTransactionSnapshotListItemMessage, CardanoTransactionSnapshotListMessage, ToMessageAdapter, }; -/// Adapter to convert a list of [CardanoTransaction] to [CardanoTransactionCommitmentListMessage] instances +/// Adapter to convert a list of [CardanoTransaction] to [CardanoTransactionSnapshotListMessage] instances pub struct ToCardanoTransactionListMessageAdapter; impl ToMessageAdapter< - Vec>, - CardanoTransactionCommitmentListMessage, + Vec>, + CardanoTransactionSnapshotListMessage, > for ToCardanoTransactionListMessageAdapter { /// Method to trigger the conversion fn adapt( - snapshots: Vec>, - ) -> CardanoTransactionCommitmentListMessage { + snapshots: Vec>, + ) -> CardanoTransactionSnapshotListMessage { snapshots .into_iter() - .map(|entity| CardanoTransactionCommitmentListItemMessage { + .map(|entity| CardanoTransactionSnapshotListItemMessage { merkle_root: entity.artifact.merkle_root.clone(), beacon: entity.artifact.beacon.clone(), hash: entity.artifact.hash, @@ -36,9 +36,9 @@ mod tests { #[test] fn adapt_ok() { - let signed_entity = SignedEntity::::dummy(); + let signed_entity = SignedEntity::::dummy(); let mithril_stake_distribution_list_message_expected = - vec![CardanoTransactionCommitmentListItemMessage { + vec![CardanoTransactionSnapshotListItemMessage { merkle_root: signed_entity.artifact.merkle_root.clone(), beacon: signed_entity.artifact.beacon.clone(), hash: signed_entity.artifact.hash.clone(), diff --git a/mithril-aggregator/src/message_adapters/to_cardano_transaction_message.rs b/mithril-aggregator/src/message_adapters/to_cardano_transaction_message.rs index 7e0685dffa3..3e32301babb 100644 --- a/mithril-aggregator/src/message_adapters/to_cardano_transaction_message.rs +++ b/mithril-aggregator/src/message_adapters/to_cardano_transaction_message.rs @@ -1,20 +1,15 @@ -use mithril_common::entities::{CardanoTransactionsCommitment, SignedEntity}; -use mithril_common::messages::{CardanoTransactionCommitmentMessage, ToMessageAdapter}; +use mithril_common::entities::{CardanoTransactionsSnapshot, SignedEntity}; +use mithril_common::messages::{CardanoTransactionSnapshotMessage, ToMessageAdapter}; -/// Adapter to convert [CardanoTransaction] to [CardanoTransactionCommitmentMessage] instances +/// Adapter to convert [CardanoTransaction] to [CardanoTransactionSnapshotMessage] instances pub struct ToCardanoTransactionMessageAdapter; -impl - ToMessageAdapter< - SignedEntity, - CardanoTransactionCommitmentMessage, - > for ToCardanoTransactionMessageAdapter +impl ToMessageAdapter, CardanoTransactionSnapshotMessage> + for ToCardanoTransactionMessageAdapter { /// Method to trigger the conversion - fn adapt( - from: SignedEntity, - ) -> CardanoTransactionCommitmentMessage { - CardanoTransactionCommitmentMessage { + fn adapt(from: SignedEntity) -> CardanoTransactionSnapshotMessage { + CardanoTransactionSnapshotMessage { merkle_root: from.artifact.merkle_root.clone(), beacon: from.artifact.beacon, hash: from.artifact.hash, @@ -30,8 +25,8 @@ mod tests { #[test] fn adapt_ok() { - let signed_entity = SignedEntity::::dummy(); - let cardano_stake_distribution_message_expected = CardanoTransactionCommitmentMessage { + let signed_entity = SignedEntity::::dummy(); + let cardano_stake_distribution_message_expected = CardanoTransactionSnapshotMessage { merkle_root: signed_entity.artifact.merkle_root.clone(), beacon: signed_entity.artifact.beacon.clone(), hash: signed_entity.artifact.hash.clone(), diff --git a/mithril-aggregator/src/services/message.rs b/mithril-aggregator/src/services/message.rs index f9c2150fa10..d88ddad6eb6 100644 --- a/mithril-aggregator/src/services/message.rs +++ b/mithril-aggregator/src/services/message.rs @@ -8,7 +8,7 @@ use thiserror::Error; use mithril_common::{ entities::SignedEntityTypeDiscriminants, messages::{ - CardanoTransactionCommitmentListMessage, CardanoTransactionCommitmentMessage, + CardanoTransactionSnapshotListMessage, CardanoTransactionSnapshotMessage, CertificateListMessage, CertificateMessage, MithrilStakeDistributionListMessage, MithrilStakeDistributionMessage, SnapshotListMessage, SnapshotMessage, }, @@ -67,13 +67,13 @@ pub trait MessageService: Sync + Send { async fn get_cardano_transaction_message( &self, signed_entity_id: &str, - ) -> StdResult>; + ) -> StdResult>; /// Return the list of the last Cardano transactions set message async fn get_cardano_transaction_list_message( &self, limit: usize, - ) -> StdResult; + ) -> StdResult; } /// Implementation of the [MessageService] @@ -165,7 +165,7 @@ impl MessageService for MithrilMessageService { async fn get_cardano_transaction_message( &self, signed_entity_id: &str, - ) -> StdResult> { + ) -> StdResult> { let signed_entity = self .signed_entity_storer .get_signed_entity(signed_entity_id) @@ -177,7 +177,7 @@ impl MessageService for MithrilMessageService { async fn get_cardano_transaction_list_message( &self, limit: usize, - ) -> StdResult { + ) -> StdResult { let signed_entity_type_id = SignedEntityTypeDiscriminants::CardanoTransactions; let entities = self .signed_entity_storer @@ -194,7 +194,7 @@ mod tests { use mithril_common::{ entities::{ - Beacon, CardanoTransactionsCommitment, MithrilStakeDistribution, SignedEntity, + Beacon, CardanoTransactionsSnapshot, MithrilStakeDistribution, SignedEntity, SignedEntityType, Snapshot, }, messages::ToMessageAdapter, @@ -440,7 +440,7 @@ mod tests { #[tokio::test] async fn get_cardano_transaction() { - let entity = SignedEntity::::dummy(); + let entity = SignedEntity::::dummy(); let record = SignedEntityRecord { signed_entity_id: entity.signed_entity_id.clone(), signed_entity_type: SignedEntityType::CardanoTransactions( @@ -490,7 +490,7 @@ mod tests { #[tokio::test] async fn get_cardano_transaction_list_message() { - let entity = SignedEntity::::dummy(); + let entity = SignedEntity::::dummy(); let records = vec![SignedEntityRecord { signed_entity_id: entity.signed_entity_id.clone(), signed_entity_type: SignedEntityType::CardanoTransactions( diff --git a/mithril-aggregator/src/services/signed_entity.rs b/mithril-aggregator/src/services/signed_entity.rs index bf7b416d483..0975e7a4469 100644 --- a/mithril-aggregator/src/services/signed_entity.rs +++ b/mithril-aggregator/src/services/signed_entity.rs @@ -1,6 +1,6 @@ //! ## SignedEntityService //! -//! This service is responsible of dealing with [SignedEntity] type. +//! This service is responsible for dealing with [SignedEntity] type. //! It creates [Artifact] that can be accessed by clients. use anyhow::Context; use async_trait::async_trait; @@ -10,7 +10,7 @@ use std::sync::Arc; use mithril_common::{ entities::{ - Beacon, CardanoTransactionsCommitment, Certificate, Epoch, MithrilStakeDistribution, + Beacon, CardanoTransactionsSnapshot, Certificate, Epoch, MithrilStakeDistribution, SignedEntity, SignedEntityType, SignedEntityTypeDiscriminants, Snapshot, }, signable_builder::Artifact, @@ -49,10 +49,10 @@ pub trait SignedEntityService: Send + Sync { total: usize, ) -> StdResult>>; - /// Return the last signed Cardano Transaction Commitment. - async fn get_last_cardano_transaction_commitment( + /// Return the last signed Cardano Transaction Snapshot. + async fn get_last_cardano_transaction_snapshot( &self, - ) -> StdResult>>; + ) -> StdResult>>; /// Return a signed snapshot async fn get_signed_snapshot_by_id( @@ -74,7 +74,7 @@ pub struct MithrilSignedEntityService { Arc>, cardano_immutable_files_full_artifact_builder: Arc>, cardano_transactions_artifact_builder: - Arc>, + Arc>, } impl MithrilSignedEntityService { @@ -86,7 +86,7 @@ impl MithrilSignedEntityService { >, cardano_immutable_files_full_artifact_builder: Arc>, cardano_transactions_artifact_builder: Arc< - dyn ArtifactBuilder, + dyn ArtifactBuilder, >, ) -> Self { Self { @@ -239,9 +239,9 @@ impl SignedEntityService for MithrilSignedEntityService { Ok(signed_entities) } - async fn get_last_cardano_transaction_commitment( + async fn get_last_cardano_transaction_snapshot( &self, - ) -> StdResult>> { + ) -> StdResult>> { let mut signed_entities_records = self .get_last_signed_entities(1, &SignedEntityTypeDiscriminants::CardanoTransactions) .await?; @@ -296,7 +296,7 @@ impl SignedEntityService for MithrilSignedEntityService { #[cfg(test)] mod tests { use mithril_common::{ - entities::{CardanoTransactionsCommitment, Epoch}, + entities::{CardanoTransactionsSnapshot, Epoch}, signable_builder, test_utils::fake_data, }; @@ -334,7 +334,7 @@ mod tests { MockArtifactBuilder, mock_cardano_immutable_files_full_artifact_builder: MockArtifactBuilder, mock_cardano_transactions_artifact_builder: - MockArtifactBuilder, + MockArtifactBuilder, } impl MockDependencyInjector { @@ -351,7 +351,7 @@ mod tests { >::new(), mock_cardano_transactions_artifact_builder: MockArtifactBuilder::< Beacon, - CardanoTransactionsCommitment, + CardanoTransactionsSnapshot, >::new(), } } @@ -436,18 +436,18 @@ mod tests { } #[tokio::test] - async fn build_cardano_transactions_commitment_artifact_when_given_cardano_transactions_type() { + async fn build_cardano_transactions_snapshot_artifact_when_given_cardano_transactions_type() { let mut mock_container = MockDependencyInjector::new(); let expected = - CardanoTransactionsCommitment::new("merkle_root".to_string(), Beacon::default()); + CardanoTransactionsSnapshot::new("merkle_root".to_string(), Beacon::default()); mock_container .mock_cardano_transactions_artifact_builder .expect_compute_artifact() .times(1) .returning(|_, _| { - Ok(CardanoTransactionsCommitment::new( + Ok(CardanoTransactionsSnapshot::new( "merkle_root".to_string(), Beacon::default(), )) @@ -469,7 +469,7 @@ mod tests { async fn should_store_the_artifact_when_creating_artifact_for_cardano_transactions() { generic_test_that_the_artifact_is_stored( SignedEntityType::CardanoTransactions(Beacon::default()), - CardanoTransactionsCommitment::new("merkle_root".to_string(), Beacon::default()), + CardanoTransactionsSnapshot::new("merkle_root".to_string(), Beacon::default()), &|mock_injector| &mut mock_injector.mock_cardano_transactions_artifact_builder, ) .await; diff --git a/mithril-client-cli/Cargo.toml b/mithril-client-cli/Cargo.toml index 373624f84e6..bd597d57dcf 100644 --- a/mithril-client-cli/Cargo.toml +++ b/mithril-client-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-client-cli" -version = "0.7.2" +version = "0.7.3" description = "A Mithril Client" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client-cli/src/commands/snapshot/download.rs b/mithril-client-cli/src/commands/cardano_db/download.rs similarity index 76% rename from mithril-client-cli/src/commands/snapshot/download.rs rename to mithril-client-cli/src/commands/cardano_db/download.rs index 495a66b7dcf..04102e4f6c3 100644 --- a/mithril-client-cli/src/commands/snapshot/download.rs +++ b/mithril-client-cli/src/commands/cardano_db/download.rs @@ -14,27 +14,27 @@ use crate::{ commands::client_builder, configuration::ConfigParameters, utils::{ - ExpanderUtils, IndicatifFeedbackReceiver, ProgressOutputType, ProgressPrinter, - SnapshotUnpacker, SnapshotUtils, + CardanoDbUnpacker, CardanoDbUtils, ExpanderUtils, IndicatifFeedbackReceiver, + ProgressOutputType, ProgressPrinter, }, }; use mithril_client::{ common::ProtocolMessage, Client, MessageBuilder, MithrilCertificate, MithrilResult, Snapshot, }; -/// Clap command to download the snapshot and verify the certificate. +/// Clap command to download a Cardano db and verify its associated certificate. #[derive(Parser, Debug, Clone)] -pub struct SnapshotDownloadCommand { +pub struct CardanoDbDownloadCommand { /// Enable JSON output. #[clap(long)] json: bool, - /// Digest of the snapshot to download. Use the `list` command to get that information. + /// Digest of the cardano db to download. Use the `list` command to get that information. /// - /// If `latest` is specified as digest, the command will return the latest snapshot. + /// If `latest` is specified as digest, the command will return the latest cardano db. digest: String, - /// Directory where the snapshot will be downloaded. By default, a + /// Directory where the cardano db will be downloaded. By default, a /// subdirectory will be created in this directory to extract and verify the /// certificate. #[clap(long)] @@ -45,10 +45,9 @@ pub struct SnapshotDownloadCommand { genesis_verification_key: Option, } -impl SnapshotDownloadCommand { +impl CardanoDbDownloadCommand { /// Command execution pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { - debug!("Snapshot service: download."); let config = config_builder.add_source(self.clone()).build()?; let params = ConfigParameters::new(config.try_deserialize::>()?); let download_dir: &String = ¶ms.require("download_dir")?; @@ -67,64 +66,64 @@ impl SnapshotDownloadCommand { .build()?; let get_list_of_artifact_ids = || async { - let snapshots = client.snapshot().list().await.with_context(|| { - "Can not get the list of artifacts while retrieving the latest snapshot digest" + let cardano_dbs = client.snapshot().list().await.with_context(|| { + "Can not get the list of artifacts while retrieving the latest cardano db digest" })?; - Ok(snapshots + Ok(cardano_dbs .iter() - .map(|snapshot| snapshot.digest.to_owned()) + .map(|cardano_db| cardano_db.digest.to_owned()) .collect::>()) }; - let snapshot_message = client + let cardano_db_message = client .snapshot() .get( &ExpanderUtils::expand_eventual_id_alias(&self.digest, get_list_of_artifact_ids()) .await?, ) .await? - .with_context(|| format!("Can not get the snapshot for digest: '{}'", self.digest))?; + .with_context(|| format!("Can not get the cardano db for digest: '{}'", self.digest))?; - Self::check_local_disk_info(1, &progress_printer, &db_dir, &snapshot_message)?; + Self::check_local_disk_info(1, &progress_printer, &db_dir, &cardano_db_message)?; let certificate = Self::fetch_certificate_and_verifying_chain( 2, &progress_printer, &client, - &snapshot_message.certificate_hash, + &cardano_db_message.certificate_hash, ) .await?; - Self::download_and_unpack_snapshot( + Self::download_and_unpack_cardano_db( 3, &progress_printer, &client, - &snapshot_message, + &cardano_db_message, &db_dir, ) .await .with_context(|| { format!( - "Can not get download and unpack snapshot for digest: '{}'", + "Can not get download and unpack cardano db for digest: '{}'", self.digest ) })?; let message = - Self::compute_snapshot_message(4, &progress_printer, &certificate, &db_dir).await?; + Self::compute_cardano_db_message(4, &progress_printer, &certificate, &db_dir).await?; - Self::verify_snapshot_signature( + Self::verify_cardano_db_signature( 5, &progress_printer, &certificate, &message, - &snapshot_message, + &cardano_db_message, &db_dir, ) .await?; - Self::log_download_information(&db_dir, &snapshot_message, self.json)?; + Self::log_download_information(&db_dir, &cardano_db_message, self.json)?; Ok(()) } @@ -133,16 +132,16 @@ impl SnapshotDownloadCommand { step_number: u16, progress_printer: &ProgressPrinter, db_dir: &PathBuf, - snapshot: &Snapshot, + cardano_db: &Snapshot, ) -> MithrilResult<()> { progress_printer.report_step(step_number, "Checking local disk info…")?; - if let Err(e) = SnapshotUnpacker::check_prerequisites( + if let Err(e) = CardanoDbUnpacker::check_prerequisites( db_dir, - snapshot.size, - snapshot.compression_algorithm.unwrap_or_default(), + cardano_db.size, + cardano_db.compression_algorithm.unwrap_or_default(), ) { progress_printer - .report_step(step_number, &SnapshotUtils::check_disk_space_error(e)?)?; + .report_step(step_number, &CardanoDbUtils::check_disk_space_error(e)?)?; } std::fs::create_dir_all(db_dir).with_context(|| { @@ -179,20 +178,23 @@ impl SnapshotDownloadCommand { Ok(certificate) } - async fn download_and_unpack_snapshot( + async fn download_and_unpack_cardano_db( step_number: u16, progress_printer: &ProgressPrinter, client: &Client, - snapshot: &Snapshot, + cardano_db: &Snapshot, db_dir: &Path, ) -> MithrilResult<()> { - progress_printer.report_step(step_number, "Downloading and unpacking the snapshot…")?; - client.snapshot().download_unpack(snapshot, db_dir).await?; + progress_printer.report_step(step_number, "Downloading and unpacking the cardano db")?; + client + .snapshot() + .download_unpack(cardano_db, db_dir) + .await?; - // The snapshot download does not fail if the statistic call fails. + // The cardano db download does not fail if the statistic call fails. // It would be nice to implement tests to verify the behavior of `add_statistics` - if let Err(e) = client.snapshot().add_statistics(snapshot).await { - warn!("Could not increment snapshot download statistics: {e:?}"); + if let Err(e) = client.snapshot().add_statistics(cardano_db).await { + warn!("Could not increment cardano db download statistics: {e:?}"); } // Append 'clean' file to speedup node bootstrap @@ -206,21 +208,21 @@ impl SnapshotDownloadCommand { Ok(()) } - async fn compute_snapshot_message( + async fn compute_cardano_db_message( step_number: u16, progress_printer: &ProgressPrinter, certificate: &MithrilCertificate, db_dir: &Path, ) -> MithrilResult { - progress_printer.report_step(step_number, "Computing the snapshot message")?; - let message = SnapshotUtils::wait_spinner( + progress_printer.report_step(step_number, "Computing the cardano db message")?; + let message = CardanoDbUtils::wait_spinner( progress_printer, MessageBuilder::new().compute_snapshot_message(certificate, db_dir), ) .await .with_context(|| { format!( - "Can not compute the snapshot message from the directory: '{:?}'", + "Can not compute the cardano db message from the directory: '{:?}'", db_dir ) })?; @@ -228,15 +230,15 @@ impl SnapshotDownloadCommand { Ok(message) } - async fn verify_snapshot_signature( + async fn verify_cardano_db_signature( step_number: u16, progress_printer: &ProgressPrinter, certificate: &MithrilCertificate, message: &ProtocolMessage, - snapshot: &Snapshot, + cardano_db: &Snapshot, db_dir: &Path, ) -> MithrilResult<()> { - progress_printer.report_step(step_number, "Verifying the snapshot signature…")?; + progress_printer.report_step(step_number, "Verifying the cardano db signature…")?; if !certificate.match_message(message) { debug!("Digest verification failed, removing unpacked files & directory."); @@ -245,8 +247,8 @@ impl SnapshotDownloadCommand { } return Err(anyhow!( - "Certificate verification failed (snapshot digest = '{}').", - snapshot.digest.clone() + "Certificate verification failed (cardano db digest = '{}').", + cardano_db.digest.clone() )); } @@ -255,7 +257,7 @@ impl SnapshotDownloadCommand { fn log_download_information( db_dir: &Path, - snapshot: &Snapshot, + cardano_db: &Snapshot, json_output: bool, ) -> MithrilResult<()> { let canonicalized_filepath = &db_dir.canonicalize().with_context(|| { @@ -272,12 +274,12 @@ impl SnapshotDownloadCommand { canonicalized_filepath.display() ); } else { - let cardano_node_version = snapshot + let cardano_node_version = cardano_db .cardano_node_version .clone() .unwrap_or("latest".to_string()); println!( - r###"Snapshot '{}' has been unpacked and successfully checked against Mithril multi-signature contained in the certificate. + r###"Cardano db '{}' has been unpacked and successfully checked against Mithril multi-signature contained in the certificate. Files in the directory '{}' can be used to run a Cardano node with version >= {}. @@ -286,11 +288,11 @@ impl SnapshotDownloadCommand { docker run -v cardano-node-ipc:/ipc -v cardano-node-data:/data --mount type=bind,source="{}",target=/data/db/ -e NETWORK={} ghcr.io/intersectmbo/cardano-node:{} "###, - snapshot.digest, + cardano_db.digest, db_dir.display(), cardano_node_version, canonicalized_filepath.display(), - snapshot.beacon.network, + cardano_db.beacon.network, cardano_node_version ); } @@ -299,7 +301,7 @@ impl SnapshotDownloadCommand { } } -impl Source for SnapshotDownloadCommand { +impl Source for CardanoDbDownloadCommand { fn clone_into_box(&self) -> Box { Box::new(self.clone()) } @@ -368,7 +370,7 @@ mod tests { } #[tokio::test] - async fn verify_snapshot_signature_should_remove_db_dir_if_messages_mismatch() { + async fn verify_cardano_db_signature_should_remove_db_dir_if_messages_mismatch() { let progress_printer = ProgressPrinter::new(ProgressOutputType::Tty, 1); let certificate = dummy_certificate(); let mut message = ProtocolMessage::new(); @@ -377,18 +379,18 @@ mod tests { ProtocolMessagePartKey::NextAggregateVerificationKey, "avk".to_string(), ); - let snapshot = Snapshot::dummy(); + let cardano_db = Snapshot::dummy(); let db_dir = TempDir::create( "client-cli", - "verify_snapshot_signature_should_remove_db_dir_if_messages_mismatch", + "verify_cardano_db_signature_should_remove_db_dir_if_messages_mismatch", ); - let result = SnapshotDownloadCommand::verify_snapshot_signature( + let result = CardanoDbDownloadCommand::verify_cardano_db_signature( 1, &progress_printer, &certificate, &message, - &snapshot, + &cardano_db, &db_dir, ) .await; diff --git a/mithril-client-cli/src/commands/snapshot/list.rs b/mithril-client-cli/src/commands/cardano_db/list.rs similarity index 94% rename from mithril-client-cli/src/commands/snapshot/list.rs rename to mithril-client-cli/src/commands/cardano_db/list.rs index 1aa62d711e6..01334475c1c 100644 --- a/mithril-client-cli/src/commands/snapshot/list.rs +++ b/mithril-client-cli/src/commands/cardano_db/list.rs @@ -6,15 +6,15 @@ use std::collections::HashMap; use crate::{commands::client_builder_with_fallback_genesis_key, configuration::ConfigParameters}; use mithril_client::MithrilResult; -/// Clap command to list existing snapshots +/// Clap command to list existing cardano dbs #[derive(Parser, Debug, Clone)] -pub struct SnapshotListCommand { +pub struct CardanoDbListCommand { /// Enable JSON output. #[clap(long)] json: bool, } -impl SnapshotListCommand { +impl CardanoDbListCommand { /// Main command execution pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { let config = config_builder.build()?; diff --git a/mithril-client-cli/src/commands/cardano_db/mod.rs b/mithril-client-cli/src/commands/cardano_db/mod.rs new file mode 100644 index 00000000000..a1bfd377422 --- /dev/null +++ b/mithril-client-cli/src/commands/cardano_db/mod.rs @@ -0,0 +1,91 @@ +//! Commands for the cardano db artifact +mod download; +mod list; +mod show; + +pub use download::*; +pub use list::*; +pub use show::*; + +use clap::Subcommand; +use config::{builder::DefaultState, ConfigBuilder}; +use mithril_client::MithrilResult; + +/// Cardano db management (alias: cdb) +#[derive(Subcommand, Debug, Clone)] +pub enum CardanoDbCommands { + /// Cardano db snapshot commands + #[clap(subcommand)] + Snapshot(CardanoDbSnapshotCommands), + + /// Download a Cardano db snapshot and verify its associated certificate + #[clap(arg_required_else_help = true)] + Download(CardanoDbDownloadCommand), +} + +/// Cardano db snapshots +#[derive(Subcommand, Debug, Clone)] +pub enum CardanoDbSnapshotCommands { + /// List available cardano db snapshots + #[clap(arg_required_else_help = false)] + List(CardanoDbListCommand), + + /// Show detailed information about a cardano db snapshot + #[clap(arg_required_else_help = true)] + Show(CardanoDbShowCommand), +} + +impl CardanoDbCommands { + /// Execute cardano db command + pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { + match self { + Self::Download(cmd) => cmd.execute(config_builder).await, + Self::Snapshot(cmd) => cmd.execute(config_builder).await, + } + } +} + +impl CardanoDbSnapshotCommands { + /// Execute Cardano db snapshot command + pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { + match self { + Self::List(cmd) => cmd.execute(config_builder).await, + Self::Show(cmd) => cmd.execute(config_builder).await, + } + } +} + +/// Legacy snapshot commands, deprecated in favor of [CardanoDbCommands]. +pub mod deprecated { + use super::*; + + /// Cardano db snapshot management + #[derive(Subcommand, Debug, Clone)] + pub enum SnapshotCommands { + /// List available Cardano db snapshots + #[clap(arg_required_else_help = false)] + List(CardanoDbListCommand), + + /// Show detailed information about a Cardano db snapshot + #[clap(arg_required_else_help = true)] + Show(CardanoDbShowCommand), + + /// Download a Cardano db snapshot and verify its associated certificate + #[clap(arg_required_else_help = true)] + Download(CardanoDbDownloadCommand), + } + + impl SnapshotCommands { + /// Execute snapshot command + pub async fn execute( + &self, + config_builder: ConfigBuilder, + ) -> MithrilResult<()> { + match self { + Self::List(cmd) => cmd.execute(config_builder).await, + Self::Download(cmd) => cmd.execute(config_builder).await, + Self::Show(cmd) => cmd.execute(config_builder).await, + } + } + } +} diff --git a/mithril-client-cli/src/commands/snapshot/show.rs b/mithril-client-cli/src/commands/cardano_db/show.rs similarity index 61% rename from mithril-client-cli/src/commands/snapshot/show.rs rename to mithril-client-cli/src/commands/cardano_db/show.rs index c6902bf104c..f75ed198e1e 100644 --- a/mithril-client-cli/src/commands/snapshot/show.rs +++ b/mithril-client-cli/src/commands/cardano_db/show.rs @@ -10,64 +10,67 @@ use crate::{ }; use mithril_client::MithrilResult; -/// Clap command to show a given snapshot +/// Clap command to show a given cardano db #[derive(Parser, Debug, Clone)] -pub struct SnapshotShowCommand { +pub struct CardanoDbShowCommand { /// Enable JSON output. #[clap(long)] json: bool, - /// Snapshot digest. + /// Cardano DB digest. /// - /// If `latest` is specified as digest, the command will return the latest snapshot. + /// If `latest` is specified as digest, the command will return the latest cardano db. digest: String, } -impl SnapshotShowCommand { - /// Snapshot Show command +impl CardanoDbShowCommand { + /// Cardano DB Show command pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { let config = config_builder.build()?; let params = ConfigParameters::new(config.try_deserialize::>()?); let client = client_builder_with_fallback_genesis_key(¶ms)?.build()?; let get_list_of_artifact_ids = || async { - let snapshots = client.snapshot().list().await.with_context(|| { - "Can not get the list of artifacts while retrieving the latest snapshot digest" + let cardano_dbs = client.snapshot().list().await.with_context(|| { + "Can not get the list of artifacts while retrieving the latest cardano db digest" })?; - Ok(snapshots + Ok(cardano_dbs .iter() - .map(|snapshot| snapshot.digest.to_owned()) + .map(|cardano_db| cardano_db.digest.to_owned()) .collect::>()) }; - let snapshot_message = client + let cardano_db_message = client .snapshot() .get( &ExpanderUtils::expand_eventual_id_alias(&self.digest, get_list_of_artifact_ids()) .await?, ) .await? - .ok_or_else(|| anyhow!("Snapshot not found for digest: '{}'", &self.digest))?; + .ok_or_else(|| anyhow!("Cardano DB not found for digest: '{}'", &self.digest))?; if self.json { - println!("{}", serde_json::to_string(&snapshot_message)?); + println!("{}", serde_json::to_string(&cardano_db_message)?); } else { - let snapshot_table = vec![ + let cardano_db_table = vec![ vec![ "Epoch".cell(), - format!("{}", &snapshot_message.beacon.epoch).cell(), + format!("{}", &cardano_db_message.beacon.epoch).cell(), ], vec![ "Immutable File Number".cell(), - format!("{}", &snapshot_message.beacon.immutable_file_number).cell(), + format!("{}", &cardano_db_message.beacon.immutable_file_number).cell(), + ], + vec!["Network".cell(), cardano_db_message.beacon.network.cell()], + vec!["Digest".cell(), cardano_db_message.digest.cell()], + vec![ + "Size".cell(), + format!("{}", &cardano_db_message.size).cell(), ], - vec!["Network".cell(), snapshot_message.beacon.network.cell()], - vec!["Digest".cell(), snapshot_message.digest.cell()], - vec!["Size".cell(), format!("{}", &snapshot_message.size).cell()], vec![ "Cardano node version".cell(), - snapshot_message + cardano_db_message .cardano_node_version .as_ref() .unwrap_or(&"NA".to_string()) @@ -76,24 +79,24 @@ impl SnapshotShowCommand { ], vec![ "Location".cell(), - snapshot_message.locations.join(",").cell(), + cardano_db_message.locations.join(",").cell(), ], vec![ "Created".cell(), - snapshot_message.created_at.to_string().cell(), + cardano_db_message.created_at.to_string().cell(), ], vec![ "Compression Algorithm".cell(), format!( "{}", - &snapshot_message.compression_algorithm.unwrap_or_default() + &cardano_db_message.compression_algorithm.unwrap_or_default() ) .cell(), ], ] .table(); - print_stdout(snapshot_table)? + print_stdout(cardano_db_table)? } Ok(()) diff --git a/mithril-client-cli/src/commands/cardano_transaction/mod.rs b/mithril-client-cli/src/commands/cardano_transaction/mod.rs index b7d81018fa4..69f558e2664 100644 --- a/mithril-client-cli/src/commands/cardano_transaction/mod.rs +++ b/mithril-client-cli/src/commands/cardano_transaction/mod.rs @@ -1,11 +1,11 @@ -//! Commands for the Cardano Transaction Commitment artifact & Cardano Transactions Proof +//! Commands for the Cardano Transaction Snapshot artifact & Cardano Transactions Proof mod certify; -mod commitment_list; -mod commitment_show; +mod snapshot_list; +mod snapshot_show; pub use certify::*; -pub use commitment_list::*; -pub use commitment_show::*; +pub use snapshot_list::*; +pub use snapshot_show::*; use clap::Subcommand; use config::builder::DefaultState; @@ -16,9 +16,9 @@ use mithril_client::MithrilResult; #[derive(Subcommand, Debug, Clone)] #[command(about = "[unstable] Cardano transactions management (alias: ctx)")] pub enum CardanoTransactionCommands { - /// Cardano transaction commitment commands + /// Cardano transaction snapshot commands #[clap(subcommand)] - Commitment(CardanoTransactionCommitmentCommands), + Snapshot(CardanoTransactionSnapshotCommands), /// Certify that a given list of transaction hashes are included in the Cardano transactions set #[clap(arg_required_else_help = false)] @@ -27,28 +27,28 @@ pub enum CardanoTransactionCommands { /// Cardano transactions set #[derive(Subcommand, Debug, Clone)] -pub enum CardanoTransactionCommitmentCommands { +pub enum CardanoTransactionSnapshotCommands { /// List Cardano transaction sets #[clap(arg_required_else_help = false)] - List(CardanoTransactionCommitmentListCommand), + List(CardanoTransactionSnapshotListCommand), /// Show Cardano transaction sets #[clap(arg_required_else_help = false)] - Show(CardanoTransactionsCommitmentShowCommand), + Show(CardanoTransactionsSnapshotShowCommand), } impl CardanoTransactionCommands { /// Execute Cardano transaction command pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { match self { - Self::Commitment(cmd) => cmd.execute(config_builder).await, + Self::Snapshot(cmd) => cmd.execute(config_builder).await, Self::Certify(cmd) => cmd.execute(config_builder).await, } } } -impl CardanoTransactionCommitmentCommands { - /// Execute Cardano transaction commitment command +impl CardanoTransactionSnapshotCommands { + /// Execute Cardano transaction snapshot command pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { match self { Self::List(cmd) => cmd.execute(config_builder).await, diff --git a/mithril-client-cli/src/commands/cardano_transaction/commitment_list.rs b/mithril-client-cli/src/commands/cardano_transaction/snapshot_list.rs similarity index 89% rename from mithril-client-cli/src/commands/cardano_transaction/commitment_list.rs rename to mithril-client-cli/src/commands/cardano_transaction/snapshot_list.rs index d1dff3dcd56..996a9ba0d27 100644 --- a/mithril-client-cli/src/commands/cardano_transaction/commitment_list.rs +++ b/mithril-client-cli/src/commands/cardano_transaction/snapshot_list.rs @@ -8,21 +8,21 @@ use crate::commands::client_builder_with_fallback_genesis_key; use crate::configuration::ConfigParameters; use mithril_client::MithrilResult; -/// Cardano transaction commitment list command +/// Cardano transaction snapshot list command #[derive(Parser, Debug, Clone)] -pub struct CardanoTransactionCommitmentListCommand { +pub struct CardanoTransactionSnapshotListCommand { /// Enable JSON output. #[clap(long)] json: bool, } -impl CardanoTransactionCommitmentListCommand { +impl CardanoTransactionSnapshotListCommand { /// Main command execution pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { let config = config_builder.build()?; let params = ConfigParameters::new(config.try_deserialize::>()?); let client = client_builder_with_fallback_genesis_key(¶ms)?.build()?; - let lines = client.cardano_transaction().list_commitments().await?; + let lines = client.cardano_transaction().list_snapshots().await?; if self.json { println!("{}", serde_json::to_string(&lines)?); diff --git a/mithril-client-cli/src/commands/cardano_transaction/commitment_show.rs b/mithril-client-cli/src/commands/cardano_transaction/snapshot_show.rs similarity index 84% rename from mithril-client-cli/src/commands/cardano_transaction/commitment_show.rs rename to mithril-client-cli/src/commands/cardano_transaction/snapshot_show.rs index 2da3db6b670..9a68e7f8ecd 100644 --- a/mithril-client-cli/src/commands/cardano_transaction/commitment_show.rs +++ b/mithril-client-cli/src/commands/cardano_transaction/snapshot_show.rs @@ -10,30 +10,30 @@ use crate::{ }; use mithril_client::MithrilResult; -/// Clap command to show a given Cardano transaction commitment +/// Clap command to show a given Cardano transaction snapshot #[derive(Parser, Debug, Clone)] -pub struct CardanoTransactionsCommitmentShowCommand { +pub struct CardanoTransactionsSnapshotShowCommand { /// Enable JSON output. #[clap(long)] json: bool, - /// Cardano transaction commitment hash. + /// Cardano transaction snapshot hash. /// /// If `latest` is specified as hash, the command will return the latest Cardano transaction - /// commitment. + /// snapshot. hash: String, } -impl CardanoTransactionsCommitmentShowCommand { - /// Cardano transaction commitment Show command +impl CardanoTransactionsSnapshotShowCommand { + /// Cardano transaction snapshot Show command pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { let config = config_builder.build()?; let params = ConfigParameters::new(config.try_deserialize::>()?); let client = client_builder_with_fallback_genesis_key(¶ms)?.build()?; let get_list_of_artifact_ids = || async { - let transactions_sets = client.cardano_transaction().list_commitments().await.with_context(|| { - "Can not get the list of artifacts while retrieving the latest Cardano transaction commitment hash" + let transactions_sets = client.cardano_transaction().list_snapshots().await.with_context(|| { + "Can not get the list of artifacts while retrieving the latest Cardano transaction snapshot hash" })?; Ok(transactions_sets @@ -44,14 +44,14 @@ impl CardanoTransactionsCommitmentShowCommand { let tx_sets = client .cardano_transaction() - .get_commitment( + .get_snapshot( &ExpanderUtils::expand_eventual_id_alias(&self.hash, get_list_of_artifact_ids()) .await?, ) .await? .ok_or_else(|| { anyhow!( - "Cardano transaction commitment not found for hash: '{}'", + "Cardano transaction snapshot not found for hash: '{}'", &self.hash ) })?; diff --git a/mithril-client-cli/src/commands/mod.rs b/mithril-client-cli/src/commands/mod.rs index 3bc309ee131..ad7364dfae2 100644 --- a/mithril-client-cli/src/commands/mod.rs +++ b/mithril-client-cli/src/commands/mod.rs @@ -3,9 +3,9 @@ //! //! +pub mod cardano_db; pub mod cardano_transaction; pub mod mithril_stake_distribution; -pub mod snapshot; use mithril_client::{ClientBuilder, MithrilResult}; use slog_scope::logger; diff --git a/mithril-client-cli/src/commands/snapshot/mod.rs b/mithril-client-cli/src/commands/snapshot/mod.rs deleted file mode 100644 index 0bb8a3f8315..00000000000 --- a/mithril-client-cli/src/commands/snapshot/mod.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! Commands for the snapshot artifact -mod download; -mod list; -mod show; - -pub use download::*; -pub use list::*; -pub use show::*; - -use clap::Subcommand; -use config::{builder::DefaultState, ConfigBuilder}; -use mithril_client::MithrilResult; - -/// Snapshot management -#[derive(Subcommand, Debug, Clone)] -pub enum SnapshotCommands { - /// List available snapshots - #[clap(arg_required_else_help = false)] - List(SnapshotListCommand), - - /// Show detailed informations about a snapshot - #[clap(arg_required_else_help = true)] - Show(SnapshotShowCommand), - - /// Download the snapshot and verify the certificate - #[clap(arg_required_else_help = true)] - Download(SnapshotDownloadCommand), -} - -impl SnapshotCommands { - /// Execute snapshot command - pub async fn execute(&self, config_builder: ConfigBuilder) -> MithrilResult<()> { - match self { - Self::List(cmd) => cmd.execute(config_builder).await, - Self::Download(cmd) => cmd.execute(config_builder).await, - Self::Show(cmd) => cmd.execute(config_builder).await, - } - } -} diff --git a/mithril-client-cli/src/lib.rs b/mithril-client-cli/src/lib.rs index 877997e4ea0..91f818b85ba 100644 --- a/mithril-client-cli/src/lib.rs +++ b/mithril-client-cli/src/lib.rs @@ -2,7 +2,7 @@ //! A command line interface that uses the [Mithril Client Library](https://mithril.network/doc/manual/developer-docs/nodes/mithril-client-library) //! to manipulate Mithril certified types from a Mithril Aggregator: -//! * Snapshots: List, Show, download and verify +//! * Cardano DB: List, Show, download and verify //! * Mithril Stake Distribution: List, download and verify // //! You can find more information on how it works reading the [documentation website](https://mithril.network/doc/mithril/mithril-network/client). diff --git a/mithril-client-cli/src/main.rs b/mithril-client-cli/src/main.rs index 43a036f3afd..f776b5b9316 100644 --- a/mithril-client-cli/src/main.rs +++ b/mithril-client-cli/src/main.rs @@ -15,8 +15,9 @@ use mithril_client::MithrilResult; use mithril_doc::{Documenter, GenerateDocCommands, StructDoc}; use mithril_client_cli::commands::{ + cardano_db::{deprecated::SnapshotCommands, CardanoDbCommands}, cardano_transaction::CardanoTransactionCommands, - mithril_stake_distribution::MithrilStakeDistributionCommands, snapshot::SnapshotCommands, + mithril_stake_distribution::MithrilStakeDistributionCommands, }; enum LogOutputType { @@ -77,7 +78,7 @@ pub struct Args { #[example = "`./mithril-client.log`"] log_output: Option, - /// Enable unstable commands (Such as Cardano Transactions) + /// Enable unstable commands (such as Cardano Transactions) #[clap(long)] unstable: bool, } @@ -162,9 +163,14 @@ impl Source for Args { #[derive(Subcommand, Debug, Clone)] enum ArtifactCommands { + /// Deprecated, use `cardano-db` instead #[clap(subcommand)] + #[deprecated(since = "0.7.3", note = "use `CardanoDb` commands instead")] Snapshot(SnapshotCommands), + #[clap(subcommand, alias("cdb"))] + CardanoDb(CardanoDbCommands), + #[clap(subcommand, alias("msd"))] MithrilStakeDistribution(MithrilStakeDistributionCommands), @@ -182,7 +188,12 @@ impl ArtifactCommands { config_builder: ConfigBuilder, ) -> MithrilResult<()> { match self { - Self::Snapshot(cmd) => cmd.execute(config_builder).await, + #[allow(deprecated)] + Self::Snapshot(cmd) => { + eprintln!("`snapshot` command is deprecated, use `cardano-db` instead"); + cmd.execute(config_builder).await + } + Self::CardanoDb(cmd) => cmd.execute(config_builder).await, Self::MithrilStakeDistribution(cmd) => cmd.execute(config_builder).await, Self::CardanoTransaction(ctx) => { if !unstable_enabled { @@ -221,13 +232,9 @@ mod tests { #[tokio::test] async fn fail_if_cardano_tx_command_is_used_without_unstable_flag() { - let args = Args::try_parse_from([ - "mithril-client", - "cardano-transaction", - "commitment", - "list", - ]) - .unwrap(); + let args = + Args::try_parse_from(["mithril-client", "cardano-transaction", "snapshot", "list"]) + .unwrap(); args.execute() .await diff --git a/mithril-client-cli/src/utils/snapshot.rs b/mithril-client-cli/src/utils/cardano_db.rs similarity index 71% rename from mithril-client-cli/src/utils/snapshot.rs rename to mithril-client-cli/src/utils/cardano_db.rs index 7cf8aabf24d..5c25853e349 100644 --- a/mithril-client-cli/src/utils/snapshot.rs +++ b/mithril-client-cli/src/utils/cardano_db.rs @@ -3,20 +3,20 @@ use futures::Future; use indicatif::{MultiProgress, ProgressBar}; use std::time::Duration; -use super::SnapshotUnpackerError; +use super::CardanoDbUnpackerError; use mithril_client::{MithrilError, MithrilResult}; -/// Utility functions for to the Snapshot commands -pub struct SnapshotUtils; +/// Utility functions for to the CardanoDb commands +pub struct CardanoDbUtils; -impl SnapshotUtils { +impl CardanoDbUtils { /// Handle the error return by `check_prerequisites` pub fn check_disk_space_error(error: MithrilError) -> MithrilResult { - if let Some(SnapshotUnpackerError::NotEnoughSpace { + if let Some(CardanoDbUnpackerError::NotEnoughSpace { left_space: _, pathdir: _, archive_size: _, - }) = error.downcast_ref::() + }) = error.downcast_ref::() { Ok(format!("Warning: {}", error)) } else { @@ -51,14 +51,14 @@ mod test { #[test] fn check_disk_space_error_should_return_warning_message_if_error_is_not_enough_space() { - let not_enough_space_error = SnapshotUnpackerError::NotEnoughSpace { + let not_enough_space_error = CardanoDbUnpackerError::NotEnoughSpace { left_space: 1_f64, pathdir: PathBuf::new(), archive_size: 2_f64, }; let expected = format!("Warning: {}", not_enough_space_error); - let result = SnapshotUtils::check_disk_space_error(anyhow!(not_enough_space_error)) + let result = CardanoDbUtils::check_disk_space_error(anyhow!(not_enough_space_error)) .expect("check_disk_space_error should not error"); assert!(result.contains(&expected)); @@ -66,15 +66,15 @@ mod test { #[test] fn check_disk_space_error_should_return_error_if_error_is_not_error_not_enough_space() { - let error = SnapshotUnpackerError::UnpackDirectoryAlreadyExists(PathBuf::new()); + let error = CardanoDbUnpackerError::UnpackDirectoryAlreadyExists(PathBuf::new()); - let error = SnapshotUtils::check_disk_space_error(anyhow!(error)) + let error = CardanoDbUtils::check_disk_space_error(anyhow!(error)) .expect_err("check_disk_space_error should fail"); assert!( matches!( - error.downcast_ref::(), - Some(SnapshotUnpackerError::UnpackDirectoryAlreadyExists(_)) + error.downcast_ref::(), + Some(CardanoDbUnpackerError::UnpackDirectoryAlreadyExists(_)) ), "Unexpected error: {:?}", error diff --git a/mithril-client-cli/src/utils/feedback_receiver.rs b/mithril-client-cli/src/utils/feedback_receiver.rs index 992220deede..760c0592a85 100644 --- a/mithril-client-cli/src/utils/feedback_receiver.rs +++ b/mithril-client-cli/src/utils/feedback_receiver.rs @@ -7,7 +7,7 @@ use super::{DownloadProgressReporter, ProgressOutputType}; use mithril_client::feedback::{FeedbackReceiver, MithrilEvent}; -/// Custom [FeedbackReceiver] for Snapshot to handle events sent +/// Custom [FeedbackReceiver] for Cardano DB to handle events sent /// by the `mithril-client` library pub struct IndicatifFeedbackReceiver { download_progress_reporter: RwLock>, @@ -61,7 +61,7 @@ impl FeedbackReceiver for IndicatifFeedbackReceiver { MithrilEvent::SnapshotDownloadCompleted { download_id: _ } => { let mut download_progress_reporter = self.download_progress_reporter.write().await; if let Some(progress_reporter) = download_progress_reporter.as_ref() { - progress_reporter.finish("Snapshot download completed"); + progress_reporter.finish("Cardano DB download completed"); } *download_progress_reporter = None; } diff --git a/mithril-client-cli/src/utils/mod.rs b/mithril-client-cli/src/utils/mod.rs index 969fa60d471..83405403f1b 100644 --- a/mithril-client-cli/src/utils/mod.rs +++ b/mithril-client-cli/src/utils/mod.rs @@ -1,14 +1,14 @@ //! Utilities module //! This module contains tools needed for the commands layer. +mod cardano_db; mod expander; mod feedback_receiver; mod progress_reporter; -mod snapshot; mod unpacker; +pub use cardano_db::*; pub use expander::*; pub use feedback_receiver::*; pub use progress_reporter::*; -pub use snapshot::*; pub use unpacker::*; diff --git a/mithril-client-cli/src/utils/unpacker.rs b/mithril-client-cli/src/utils/unpacker.rs index a75c407c99a..cb002bf95e6 100644 --- a/mithril-client-cli/src/utils/unpacker.rs +++ b/mithril-client-cli/src/utils/unpacker.rs @@ -9,11 +9,11 @@ use mithril_client::{common::CompressionAlgorithm, MithrilError, MithrilResult}; /// Check and unpack a downloaded archive in a given directory. #[derive(Default)] -pub struct SnapshotUnpacker; +pub struct CardanoDbUnpacker; -/// Errors tied with the SnapshotUnpacker. +/// Errors tied with the CardanoDbUnpacker. #[derive(Debug, Error)] -pub enum SnapshotUnpackerError { +pub enum CardanoDbUnpackerError { /// Not enough space on the disk. There should be at least the ratio given for the /// used algorithm (see [CompressionAlgorithm::free_space_snapshot_ratio]) times /// the size of the archive to download to ensure it could be unpacked safely. @@ -25,11 +25,11 @@ pub enum SnapshotUnpackerError { /// Specified location pathdir: PathBuf, - /// Packed snapshot size + /// Packed cardano db size archive_size: f64, }, - /// The directory where the files from snapshot are expanded already exists. + /// The directory where the files from cardano db are expanded already exists. /// An error is raised because it lets the user a chance to preserve a /// previous work. #[error("Unpack directory '{0}' already exists, please move or delete it.")] @@ -40,9 +40,9 @@ pub enum SnapshotUnpackerError { UnpackDirectoryIsNotWritable(PathBuf, #[source] MithrilError), } -impl SnapshotUnpacker { +impl CardanoDbUnpacker { /// Check all prerequisites are met before starting to download and unpack - /// big snapshot archive. + /// big cardano db archive. pub fn check_prerequisites( pathdir: &Path, size: u64, @@ -50,18 +50,18 @@ impl SnapshotUnpacker { ) -> MithrilResult<()> { if pathdir.exists() { return Err( - SnapshotUnpackerError::UnpackDirectoryAlreadyExists(pathdir.to_owned()).into(), + CardanoDbUnpackerError::UnpackDirectoryAlreadyExists(pathdir.to_owned()).into(), ); } create_dir_all(pathdir).map_err(|e| { - SnapshotUnpackerError::UnpackDirectoryIsNotWritable(pathdir.to_owned(), e.into()) + CardanoDbUnpackerError::UnpackDirectoryIsNotWritable(pathdir.to_owned(), e.into()) })?; let free_space = fs2::available_space(pathdir)? as f64; // `remove_dir` doesn't remove intermediate directories that could have been created by `create_dir_all` remove_dir(pathdir)?; if free_space < compression_algorithm.free_space_snapshot_ratio() * size as f64 { - return Err(SnapshotUnpackerError::NotEnoughSpace { + return Err(CardanoDbUnpackerError::NotEnoughSpace { left_space: free_space, pathdir: pathdir.to_owned(), archive_size: size as f64, @@ -86,7 +86,7 @@ mod test { fn should_return_ok() { let pathdir = create_temporary_empty_directory("return_ok").join("target_directory"); - SnapshotUnpacker::check_prerequisites(&pathdir, 12, CompressionAlgorithm::default()) + CardanoDbUnpacker::check_prerequisites(&pathdir, 12, CompressionAlgorithm::default()) .expect("check_prerequisites should not fail"); } @@ -95,13 +95,13 @@ mod test { let pathdir = create_temporary_empty_directory("existing_directory"); let error = - SnapshotUnpacker::check_prerequisites(&pathdir, 12, CompressionAlgorithm::default()) + CardanoDbUnpacker::check_prerequisites(&pathdir, 12, CompressionAlgorithm::default()) .expect_err("check_prerequisites should fail"); assert!( matches!( - error.downcast_ref::(), - Some(SnapshotUnpackerError::UnpackDirectoryAlreadyExists(_)) + error.downcast_ref::(), + Some(CardanoDbUnpackerError::UnpackDirectoryAlreadyExists(_)) ), "Unexpected error: {:?}", error @@ -122,13 +122,13 @@ mod test { let targetdir = pathdir.join("target_directory"); let error = - SnapshotUnpacker::check_prerequisites(&targetdir, 12, CompressionAlgorithm::default()) + CardanoDbUnpacker::check_prerequisites(&targetdir, 12, CompressionAlgorithm::default()) .expect_err("check_prerequisites should fail"); assert!( matches!( - error.downcast_ref::(), - Some(SnapshotUnpackerError::UnpackDirectoryIsNotWritable(_, _)) + error.downcast_ref::(), + Some(CardanoDbUnpackerError::UnpackDirectoryIsNotWritable(_, _)) ), "Unexpected error: {:?}", error @@ -141,7 +141,7 @@ mod test { create_temporary_empty_directory("enough_available_space").join("target_directory"); let archive_size = u64::MAX; - let error = SnapshotUnpacker::check_prerequisites( + let error = CardanoDbUnpacker::check_prerequisites( &pathdir, archive_size, CompressionAlgorithm::default(), @@ -150,8 +150,8 @@ mod test { assert!( matches!( - error.downcast_ref::(), - Some(SnapshotUnpackerError::NotEnoughSpace { + error.downcast_ref::(), + Some(CardanoDbUnpackerError::NotEnoughSpace { left_space: _, pathdir: _, archive_size: _ diff --git a/mithril-client-wasm/Cargo.toml b/mithril-client-wasm/Cargo.toml index db47d1db866..5c9289958ed 100644 --- a/mithril-client-wasm/Cargo.toml +++ b/mithril-client-wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-client-wasm" -version = "0.2.1" +version = "0.2.2" description = "Mithril client WASM" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client-wasm/README.md b/mithril-client-wasm/README.md index a8a2d24b118..fcb8687beda 100644 --- a/mithril-client-wasm/README.md +++ b/mithril-client-wasm/README.md @@ -7,7 +7,7 @@ * The different types of available data certified by Mithril are: * Snapshot: list and get. * Mithril stake distribution: list and get. - * Cardano transactions: list & get commitments, get proofs + * Cardano transactions: list & get snapshots, get proofs * Certificate: list, get, and chain validation. ## Installation diff --git a/mithril-client-wasm/src/client_wasm.rs b/mithril-client-wasm/src/client_wasm.rs index b41971b87ac..a40f2d9f59c 100644 --- a/mithril-client-wasm/src/client_wasm.rs +++ b/mithril-client-wasm/src/client_wasm.rs @@ -220,30 +220,30 @@ impl MithrilUnstableClient { } } - /// Call the client for the list of available Cardano transactions commitments + /// Call the client for the list of available Cardano transactions snapshots #[wasm_bindgen] - pub async fn list_cardano_transactions_commitments(&self) -> WasmResult { + pub async fn list_cardano_transactions_snapshots(&self) -> WasmResult { let result = self .client .cardano_transaction() - .list_commitments() + .list_snapshots() .await .map_err(|err| format!("{err:?}"))?; Ok(serde_wasm_bindgen::to_value(&result)?) } - /// Call the client to get a Cardano transactions commitment from a hash + /// Call the client to get a Cardano transactions snapshot from a hash #[wasm_bindgen] - pub async fn get_cardano_transactions_commitment(&self, hash: &str) -> WasmResult { + pub async fn get_cardano_transactions_snapshot(&self, hash: &str) -> WasmResult { let result = self .client .cardano_transaction() - .get_commitment(hash) + .get_snapshot(hash) .await .map_err(|err| format!("{err:?}"))? .ok_or(JsValue::from_str(&format!( - "No cardano transactions commitment found for hash: '{hash}'" + "No cardano transactions snapshot found for hash: '{hash}'" )))?; Ok(serde_wasm_bindgen::to_value(&result)?) @@ -301,7 +301,7 @@ mod tests { use wasm_bindgen_test::*; use mithril_client::{ - common::ProtocolMessage, CardanoTransactionCommitment, MithrilCertificateListItem, + common::ProtocolMessage, CardanoTransactionSnapshot, MithrilCertificateListItem, MithrilStakeDistribution, MithrilStakeDistributionListItem, Snapshot, SnapshotListItem, }; @@ -493,13 +493,13 @@ mod tests { } #[wasm_bindgen_test] - async fn list_cardano_transactions_commitments_should_return_value_convertible_in_rust_type() { + async fn list_cardano_transactions_snapshots_should_return_value_convertible_in_rust_type() { let cardano_tx_sets_js_value = get_mithril_client() .unstable - .list_cardano_transactions_commitments() + .list_cardano_transactions_snapshots() .await - .expect("list_cardano_transactions_commitments should not fail"); - let cardano_tx_sets = serde_wasm_bindgen::from_value::>( + .expect("list_cardano_transactions_snapshots should not fail"); + let cardano_tx_sets = serde_wasm_bindgen::from_value::>( cardano_tx_sets_js_value, ) .expect("conversion should not fail"); @@ -507,31 +507,31 @@ mod tests { assert_eq!( cardano_tx_sets.len(), // Aggregator return up to 20 items for a list route - test_data::ctx_commitment_hashes().len().min(20) + test_data::ctx_snapshot_hashes().len().min(20) ); } #[wasm_bindgen_test] - async fn get_cardano_transactions_commitment_should_return_value_convertible_in_rust_type() { + async fn get_cardano_transactions_snapshot_should_return_value_convertible_in_rust_type() { let cardano_tx_set_js_value = get_mithril_client() .unstable - .get_cardano_transactions_commitment(test_data::ctx_commitment_hashes()[0]) + .get_cardano_transactions_snapshot(test_data::ctx_snapshot_hashes()[0]) .await - .expect("get_cardano_transactions_commitment should not fail"); + .expect("get_cardano_transactions_snapshot should not fail"); let cardano_tx_set = - serde_wasm_bindgen::from_value::(cardano_tx_set_js_value) + serde_wasm_bindgen::from_value::(cardano_tx_set_js_value) .expect("conversion should not fail"); - assert_eq!(cardano_tx_set.hash, test_data::ctx_commitment_hashes()[0]); + assert_eq!(cardano_tx_set.hash, test_data::ctx_snapshot_hashes()[0]); } #[wasm_bindgen_test] - async fn get_cardano_transactions_commitment_should_fail_with_unknown_digest() { + async fn get_cardano_transactions_snapshot_should_fail_with_unknown_digest() { get_mithril_client() .unstable - .get_cardano_transactions_commitment("whatever") + .get_cardano_transactions_snapshot("whatever") .await - .expect_err("get_cardano_transactions_commitment should fail"); + .expect_err("get_cardano_transactions_snapshot should fail"); } #[wasm_bindgen_test] diff --git a/mithril-client-wasm/www-test/index.js b/mithril-client-wasm/www-test/index.js index c35ac854da2..3eb8736e29c 100644 --- a/mithril-client-wasm/www-test/index.js +++ b/mithril-client-wasm/www-test/index.js @@ -1,5 +1,5 @@ import initMithrilClient, { - MithrilClient, + MithrilClient } from "@mithril-dev/mithril-client-wasm"; async function run_test(test_name, test_number, fun) { @@ -132,18 +132,18 @@ await run_test("verify_message_match_certificate", test_number, async () => { }); if (aggregator_capabilities.includes("CardanoTransactions")) { - const transactions_hashes_to_certify = process.env.TRANSACTIONS_HASHES_TO_CERTIFY?.split(',') ?? []; + const transactions_hashes_to_certify = process.env.TRANSACTIONS_HASHES_TO_CERTIFY?.split(",") ?? []; let ctx_sets; test_number++; - await run_test("list_cardano_transactions_commitments", test_number, async () => { - ctx_sets = await client.unstable.list_cardano_transactions_commitments(); + await run_test("list_cardano_transactions_snapshots", test_number, async () => { + ctx_sets = await client.unstable.list_cardano_transactions_snapshots(); console.log("cardano_transactions_sets", ctx_sets); }); test_number++; - await run_test("get_cardano_transactions_commitment", test_number, async () => { - const ctx_set = await client.unstable.get_cardano_transactions_commitment(ctx_sets[0].hash); + await run_test("get_cardano_transactions_snapshot", test_number, async () => { + const ctx_set = await client.unstable.get_cardano_transactions_snapshot(ctx_sets[0].hash); console.log("cardano_transaction_set", ctx_set); }); diff --git a/mithril-client-wasm/www-test/package-lock.json b/mithril-client-wasm/www-test/package-lock.json index 022a590f1d5..703bbc9707f 100644 --- a/mithril-client-wasm/www-test/package-lock.json +++ b/mithril-client-wasm/www-test/package-lock.json @@ -20,7 +20,7 @@ }, "../pkg": { "name": "mithril-client-wasm", - "version": "0.1.8", + "version": "0.2.1", "license": "Apache-2.0" }, "node_modules/@discoveryjs/json-ext": { diff --git a/mithril-client-wasm/www/package-lock.json b/mithril-client-wasm/www/package-lock.json index 9849a3807b9..39ce5a83c0c 100644 --- a/mithril-client-wasm/www/package-lock.json +++ b/mithril-client-wasm/www/package-lock.json @@ -1,12 +1,12 @@ { "name": "www", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "www", - "version": "0.1.0", + "version": "0.1.1", "dependencies": { "@mithril-dev/mithril-client-wasm": "file:../pkg" }, @@ -19,7 +19,7 @@ }, "../pkg": { "name": "mithril-client-wasm", - "version": "0.1.8", + "version": "0.2.1", "license": "Apache-2.0" }, "node_modules/@discoveryjs/json-ext": { diff --git a/mithril-client/Cargo.toml b/mithril-client/Cargo.toml index cfe96ba9eab..cb8c93fb01e 100644 --- a/mithril-client/Cargo.toml +++ b/mithril-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-client" -version = "0.6.5" +version = "0.6.6" description = "Mithril client library" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client/src/aggregator_client.rs b/mithril-client/src/aggregator_client.rs index f070fcf2c41..01ce9b30a49 100644 --- a/mithril-client/src/aggregator_client.rs +++ b/mithril-client/src/aggregator_client.rs @@ -82,16 +82,16 @@ pub enum AggregatorRequest { transactions_hashes: Vec, }, - /// Get a specific [Cardano transaction commitment][crate::CardanoTransactionCommitment] + /// Get a specific [Cardano transaction snapshot][crate::CardanoTransactionSnapshot] #[cfg(feature = "unstable")] - GetCardanoTransactionCommitment { - /// Hash of the Cardano transaction commitment to retrieve + GetCardanoTransactionSnapshot { + /// Hash of the Cardano transaction snapshot to retrieve hash: String, }, - /// Lists the aggregator [Cardano transaction commitment][crate::CardanoTransactionCommitment] + /// Lists the aggregator [Cardano transaction snapshot][crate::CardanoTransactionSnapshot] #[cfg(feature = "unstable")] - ListCardanoTransactionCommitments, + ListCardanoTransactionSnapshots, } impl AggregatorRequest { @@ -123,11 +123,11 @@ impl AggregatorRequest { transactions_hashes.join(",") ), #[cfg(feature = "unstable")] - AggregatorRequest::GetCardanoTransactionCommitment { hash } => { + AggregatorRequest::GetCardanoTransactionSnapshot { hash } => { format!("artifact/cardano-transaction/{hash}") } #[cfg(feature = "unstable")] - AggregatorRequest::ListCardanoTransactionCommitments => { + AggregatorRequest::ListCardanoTransactionSnapshots => { "artifact/cardano-transactions".to_string() } } @@ -470,7 +470,7 @@ mod tests { assert_eq!( "artifact/cardano-transaction/abc".to_string(), - AggregatorRequest::GetCardanoTransactionCommitment { + AggregatorRequest::GetCardanoTransactionSnapshot { hash: "abc".to_string() } .route() @@ -478,7 +478,7 @@ mod tests { assert_eq!( "artifact/cardano-transactions".to_string(), - AggregatorRequest::ListCardanoTransactionCommitments.route() + AggregatorRequest::ListCardanoTransactionSnapshots.route() ); } } diff --git a/mithril-client/src/cardano_transaction_client.rs b/mithril-client/src/cardano_transaction_client.rs index 9519a156637..8f7bd86baec 100644 --- a/mithril-client/src/cardano_transaction_client.rs +++ b/mithril-client/src/cardano_transaction_client.rs @@ -3,10 +3,10 @@ //! In order to do so it defines a [CardanoTransactionClient] which exposes the following features: //! - [get_proofs][CardanoTransactionClient::get_proofs]: get a [cryptographic proof][CardanoTransactionsProofs] //! that the transactions with given hash are included in the global Cardano transactions set. -//! - [get][CardanoTransactionClient::get_commitment]: get a [Cardano transaction commitment][CardanoTransactionCommitment] +//! - [get][CardanoTransactionClient::get_snapshot]: get a [Cardano transaction snapshot][CardanoTransactionSnapshot] //! data from its hash. -//! - [list][CardanoTransactionClient::list_commitments]: get the list of the latest available Cardano transaction -//! commitments. +//! - [list][CardanoTransactionClient::list_snapshots]: get the list of the latest available Cardano transaction +//! snapshot. //! //! **Important:** Verifying a proof **only** means that its cryptography is valid, in order to certify that a Cardano //! transactions subset is valid, the associated proof must be tied to a valid Mithril certificate (see the example below). @@ -40,35 +40,35 @@ //! # } //! ``` //! -//! # Get a Cardano transaction commitment +//! # Get a Cardano transaction snapshot //! -//! To get a Cardano transaction commitment using the [ClientBuilder][crate::client::ClientBuilder]. +//! To get a Cardano transaction snapshot using the [ClientBuilder][crate::client::ClientBuilder]. //! //! ```no_run //! # async fn run() -> mithril_client::MithrilResult<()> { //! use mithril_client::ClientBuilder; //! //! let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?; -//! let cardano_transaction_commitment = client.cardano_transaction().get_commitment("CARDANO_TRANSACTION_COMMITMENT_HASH").await?.unwrap(); +//! let cardano_transaction_snapshot = client.cardano_transaction().get_snapshot("CARDANO_TRANSACTION_SNAPSHOT_HASH").await?.unwrap(); //! -//! println!("Cardano transaction commitment hash={}, epoch={}", cardano_transaction_commitment.hash, cardano_transaction_commitment.beacon.epoch); +//! println!("Cardano transaction snapshot hash={}, epoch={}", cardano_transaction_snapshot.hash, cardano_transaction_snapshot.beacon.epoch); //! # Ok(()) //! # } //! ``` //! -//! # List available Cardano transaction commitments +//! # List available Cardano transaction snapshots //! -//! To list latest available Cardano transaction commitments using the [ClientBuilder][crate::client::ClientBuilder]. +//! To list latest available Cardano transaction snapshots using the [ClientBuilder][crate::client::ClientBuilder]. //! //! ```no_run //! # async fn run() -> mithril_client::MithrilResult<()> { //! use mithril_client::ClientBuilder; //! //! let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?; -//! let cardano_transaction_commitments = client.cardano_transaction().list_commitments().await?; +//! let cardano_transaction_snapshots = client.cardano_transaction().list_snapshots().await?; //! -//! for cardano_transaction_commitment in cardano_transaction_commitments { -//! println!("Cardano transaction commitment hash={}, epoch={}", cardano_transaction_commitment.hash, cardano_transaction_commitment.beacon.epoch); +//! for cardano_transaction_snapshot in cardano_transaction_snapshots { +//! println!("Cardano transaction snapshot hash={}, epoch={}", cardano_transaction_snapshot.hash, cardano_transaction_snapshot.beacon.epoch); //! } //! # Ok(()) //! # } @@ -76,7 +76,7 @@ use crate::aggregator_client::{AggregatorClient, AggregatorClientError, AggregatorRequest}; use crate::{ - CardanoTransactionCommitment, CardanoTransactionCommitmentListItem, CardanoTransactionsProofs, + CardanoTransactionSnapshot, CardanoTransactionSnapshotListItem, CardanoTransactionsProofs, MithrilResult, }; use anyhow::Context; @@ -117,40 +117,38 @@ impl CardanoTransactionClient { } } - /// Fetch a list of signed Cardano transaction commitments. - pub async fn list_commitments( - &self, - ) -> MithrilResult> { + /// Fetch a list of signed Cardano transaction snapshots. + pub async fn list_snapshots(&self) -> MithrilResult> { let response = self .aggregator_client - .get_content(AggregatorRequest::ListCardanoTransactionCommitments) + .get_content(AggregatorRequest::ListCardanoTransactionSnapshots) .await .with_context(|| "CardanoTransactionClient Client can not get the artifact list")?; - let items = serde_json::from_str::>(&response) + let items = serde_json::from_str::>(&response) .with_context(|| "CardanoTransactionClient Client can not deserialize artifact list")?; Ok(items) } - /// Get the given Cardano transaction commitment data. If it cannot be found, a None is returned. - pub async fn get_commitment( + /// Get the given Cardano transaction snapshot data. If it cannot be found, a None is returned. + pub async fn get_snapshot( &self, hash: &str, - ) -> MithrilResult> { + ) -> MithrilResult> { match self .aggregator_client - .get_content(AggregatorRequest::GetCardanoTransactionCommitment { + .get_content(AggregatorRequest::GetCardanoTransactionSnapshot { hash: hash.to_string(), }) .await { Ok(content) => { - let cardano_transaction_commitment: CardanoTransactionCommitment = + let cardano_transaction_snapshot: CardanoTransactionSnapshot = serde_json::from_str(&content).with_context(|| { "CardanoTransactionClient Client can not deserialize artifact" })?; - Ok(Some(cardano_transaction_commitment)) + Ok(Some(cardano_transaction_snapshot)) } Err(AggregatorClientError::RemoteServerLogical(_)) => Ok(None), Err(e) => Err(e.into()), @@ -163,8 +161,8 @@ mod tests { use crate::aggregator_client::{AggregatorClientError, MockAggregatorHTTPClient}; use crate::common::Beacon; use crate::{ - CardanoTransactionCommitment, CardanoTransactionCommitmentListItem, - CardanoTransactionsProofs, CardanoTransactionsSetProof, + CardanoTransactionSnapshot, CardanoTransactionSnapshotListItem, CardanoTransactionsProofs, + CardanoTransactionsSetProof, }; use anyhow::anyhow; use chrono::{DateTime, Utc}; @@ -172,9 +170,9 @@ mod tests { use super::*; - fn fake_messages() -> Vec { + fn fake_messages() -> Vec { vec![ - CardanoTransactionCommitmentListItem { + CardanoTransactionSnapshotListItem { merkle_root: "mk-123".to_string(), beacon: Beacon::new("network".to_string(), 1, 1), hash: "hash-123".to_string(), @@ -183,7 +181,7 @@ mod tests { .unwrap() .with_timezone(&Utc), }, - CardanoTransactionCommitmentListItem { + CardanoTransactionSnapshotListItem { merkle_root: "mk-456".to_string(), beacon: Beacon::new("network".to_string(), 1, 2), hash: "hash-456".to_string(), @@ -196,14 +194,14 @@ mod tests { } #[tokio::test] - async fn get_cardano_transactions_commitment_list() { + async fn get_cardano_transactions_snapshot_list() { let message = fake_messages(); let mut http_client = MockAggregatorHTTPClient::new(); http_client .expect_get_content() .return_once(move |_| Ok(serde_json::to_string(&message).unwrap())); let client = CardanoTransactionClient::new(Arc::new(http_client)); - let items = client.list_commitments().await.unwrap(); + let items = client.list_snapshots().await.unwrap(); assert_eq!(2, items.len()); assert_eq!("hash-123".to_string(), items[0].hash); @@ -211,9 +209,9 @@ mod tests { } #[tokio::test] - async fn get_cardano_transactions_commitment() { + async fn get_cardano_transactions_snapshot() { let mut http_client = MockAggregatorHTTPClient::new(); - let message = CardanoTransactionCommitment { + let message = CardanoTransactionSnapshot { merkle_root: "mk-123".to_string(), beacon: Beacon::new("network".to_string(), 1, 1), hash: "hash-123".to_string(), @@ -227,13 +225,13 @@ mod tests { .expect_get_content() .return_once(move |_| Ok(serde_json::to_string(&message).unwrap())); let client = CardanoTransactionClient::new(Arc::new(http_client)); - let cardano_transaction_commitment = client - .get_commitment("hash") + let cardano_transaction_snapshot = client + .get_snapshot("hash") .await .unwrap() - .expect("This test returns a cardano transaction commitment"); + .expect("This test returns a cardano transaction snapshot"); - assert_eq!(expected, cardano_transaction_commitment); + assert_eq!(expected, cardano_transaction_snapshot); } #[tokio::test] diff --git a/mithril-client/src/lib.rs b/mithril-client/src/lib.rs index 1c982741a02..cc96a047c5a 100644 --- a/mithril-client/src/lib.rs +++ b/mithril-client/src/lib.rs @@ -8,7 +8,7 @@ //! //! - [Snapshot][snapshot_client] list, get, download tarball and record statistics. //! - [Mithril stake distribution][mithril_stake_distribution_client] list and get. -//! - [Cardano transactions proofs][cardano_transaction_client] list & get commitment, get proofs +//! - [Cardano transactions][cardano_transaction_client] list & get snapshot, get proofs //! _(available using crate feature_ **unstable**_)_. //! - [Certificates][certificate_client] list, get, and chain validation. //! diff --git a/mithril-client/src/type_alias.rs b/mithril-client/src/type_alias.rs index 61037a4243c..abbbc1b01f5 100644 --- a/mithril-client/src/type_alias.rs +++ b/mithril-client/src/type_alias.rs @@ -45,13 +45,13 @@ cfg_unstable! { pub use mithril_common::messages::VerifyCardanoTransactionsProofsError; - /// A commitment that Mithril have certified Cardano transactions up to a given [point of time][common::Beacon]. + /// A snapshot that allow to know up to which [point of time][common::Beacon] Mithril have certified Cardano transactions. /// - pub use mithril_common::messages::CardanoTransactionCommitmentMessage as CardanoTransactionCommitment; + pub use mithril_common::messages::CardanoTransactionSnapshotMessage as CardanoTransactionSnapshot; - /// List item of a Cardano transaction commitment. + /// List item of a Cardano transaction snapshot. /// - pub use mithril_common::messages::CardanoTransactionCommitmentListItemMessage as CardanoTransactionCommitmentListItem; + pub use mithril_common::messages::CardanoTransactionSnapshotListItemMessage as CardanoTransactionSnapshotListItem; } /// `mithril-common` re-exports diff --git a/mithril-common/Cargo.toml b/mithril-common/Cargo.toml index 38f5a4b1ccb..abf1658992c 100644 --- a/mithril-common/Cargo.toml +++ b/mithril-common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-common" -version = "0.3.10" +version = "0.3.11" description = "Common types, interfaces, and utilities for Mithril nodes." authors = { workspace = true } edition = { workspace = true } @@ -92,7 +92,7 @@ slog-term = "2.9.0" tokio = { version = "1.35.1", features = ["macros", "time"] } [build-dependencies] -mithril-build-script = { path = "../internal/mithril-build-script", version = "=0.1.1" } +mithril-build-script = { path = "../internal/mithril-build-script", version = "=0.1.2" } [features] default = [] diff --git a/mithril-common/src/entities/cardano_transactions_commitment.rs b/mithril-common/src/entities/cardano_transactions_snapshot.rs similarity index 63% rename from mithril-common/src/entities/cardano_transactions_commitment.rs rename to mithril-common/src/entities/cardano_transactions_snapshot.rs index 307264e5bd9..f97febd6fdf 100644 --- a/mithril-common/src/entities/cardano_transactions_commitment.rs +++ b/mithril-common/src/entities/cardano_transactions_snapshot.rs @@ -4,9 +4,9 @@ use sha2::{Digest, Sha256}; use super::Beacon; -/// Commitment of a set of Cardano transactions +/// Snapshot of a set of Cardano transactions #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] -pub struct CardanoTransactionsCommitment { +pub struct CardanoTransactionsSnapshot { /// Hash of the Cardano transactions set pub hash: String, @@ -17,19 +17,19 @@ pub struct CardanoTransactionsCommitment { pub beacon: Beacon, } -impl CardanoTransactionsCommitment { - /// Creates a new [CardanoTransactionsCommitment] +impl CardanoTransactionsSnapshot { + /// Creates a new [CardanoTransactionsSnapshot] pub fn new(merkle_root: String, beacon: Beacon) -> Self { - let mut cardano_transactions_commitment = Self { + let mut cardano_transactions_snapshot = Self { merkle_root, beacon, hash: "".to_string(), }; - cardano_transactions_commitment.hash = cardano_transactions_commitment.compute_hash(); - cardano_transactions_commitment + cardano_transactions_snapshot.hash = cardano_transactions_snapshot.compute_hash(); + cardano_transactions_snapshot } - /// Cardano transactions commitment hash computation + /// Cardano transactions snapshot hash computation fn compute_hash(&self) -> String { let mut hasher = Sha256::new(); hasher.update(self.merkle_root.clone().as_bytes()); @@ -40,7 +40,7 @@ impl CardanoTransactionsCommitment { } #[typetag::serde] -impl Artifact for CardanoTransactionsCommitment { +impl Artifact for CardanoTransactionsSnapshot { fn get_id(&self) -> String { self.hash.clone() } @@ -51,18 +51,18 @@ mod tests { use super::*; #[test] - fn test_cardano_transactuions_commitment_compute_hash() { + fn test_cardano_transactions_snapshot_compute_hash() { let hash_expected = "66a1d7aa3995e9a0dce15fae3f6b91640824ecd1f81991df5ce4ddff62b34df4"; assert_eq!( hash_expected, - CardanoTransactionsCommitment::new("mk-root-123".to_string(), Beacon::default()) + CardanoTransactionsSnapshot::new("mk-root-123".to_string(), Beacon::default()) .compute_hash() ); assert_ne!( hash_expected, - CardanoTransactionsCommitment::new("mk-root-456".to_string(), Beacon::default()) + CardanoTransactionsSnapshot::new("mk-root-456".to_string(), Beacon::default()) .compute_hash() ); } diff --git a/mithril-common/src/entities/mod.rs b/mithril-common/src/entities/mod.rs index b5ae12d2ae5..5b6f0cb4295 100644 --- a/mithril-common/src/entities/mod.rs +++ b/mithril-common/src/entities/mod.rs @@ -3,8 +3,8 @@ mod beacon; mod cardano_network; mod cardano_transaction; -mod cardano_transactions_commitment; mod cardano_transactions_set_proof; +mod cardano_transactions_snapshot; mod certificate; mod certificate_metadata; mod certificate_pending; @@ -24,8 +24,8 @@ mod type_alias; pub use beacon::{Beacon, BeaconComparison, BeaconComparisonError}; pub use cardano_network::CardanoNetwork; pub use cardano_transaction::{BlockNumber, CardanoTransaction, TransactionHash}; -pub use cardano_transactions_commitment::CardanoTransactionsCommitment; pub use cardano_transactions_set_proof::CardanoTransactionsSetProof; +pub use cardano_transactions_snapshot::CardanoTransactionsSnapshot; pub use certificate::{Certificate, CertificateSignature}; pub use certificate_metadata::{CertificateMetadata, StakeDistributionParty}; pub use certificate_pending::CertificatePending; diff --git a/mithril-common/src/entities/signed_entity.rs b/mithril-common/src/entities/signed_entity.rs index 12842a4eeb6..a96d825af2e 100644 --- a/mithril-common/src/entities/signed_entity.rs +++ b/mithril-common/src/entities/signed_entity.rs @@ -1,6 +1,6 @@ #[cfg(any(test, feature = "test_tools"))] use super::{Beacon, Epoch}; -use super::{CardanoTransactionsCommitment, MithrilStakeDistribution, SignedEntityType, Snapshot}; +use super::{CardanoTransactionsSnapshot, MithrilStakeDistribution, SignedEntityType, Snapshot}; use crate::signable_builder::Artifact; #[cfg(any(test, feature = "test_tools"))] use crate::test_utils::fake_data; @@ -62,15 +62,15 @@ impl SignedEntity { } } -impl SignedEntity { +impl SignedEntity { cfg_test_tools! { - /// Create a dummy [SignedEntity] for [CardanoTransactionsCommitment] entity + /// Create a dummy [SignedEntity] for [CardanoTransactionsSnapshot] entity pub fn dummy() -> Self { SignedEntity { signed_entity_id: "snapshot-id-123".to_string(), signed_entity_type: SignedEntityType::CardanoTransactions(Beacon::default()), certificate_id: "certificate-hash-123".to_string(), - artifact: CardanoTransactionsCommitment::new("mkroot123".to_string(), Beacon::default()), + artifact: CardanoTransactionsSnapshot::new("mkroot123".to_string(), Beacon::default()), created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z") .unwrap() .with_timezone(&Utc), diff --git a/mithril-common/src/messages/cardano_transaction_commitment.rs b/mithril-common/src/messages/cardano_transaction_snapshot.rs similarity index 75% rename from mithril-common/src/messages/cardano_transaction_commitment.rs rename to mithril-common/src/messages/cardano_transaction_snapshot.rs index dee92b8ac8b..48e8ff3a869 100644 --- a/mithril-common/src/messages/cardano_transaction_commitment.rs +++ b/mithril-common/src/messages/cardano_transaction_snapshot.rs @@ -6,16 +6,16 @@ use crate::entities::Beacon; #[cfg(any(test, feature = "test_tools"))] use crate::test_utils::fake_data; -/// Message structure of a Cardano Transactions commitment +/// Message structure of a Cardano Transactions snapshot #[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] -pub struct CardanoTransactionCommitmentMessage { - /// Merkle root of the Cardano transactions commitment +pub struct CardanoTransactionSnapshotMessage { + /// Merkle root of the Cardano transactions snapshot pub merkle_root: String, - /// Beacon of the Cardano transactions commitment + /// Beacon of the Cardano transactions snapshot pub beacon: Beacon, - /// Hash of the Cardano Transactions commitment + /// Hash of the Cardano Transactions snapshot pub hash: String, /// Hash of the associated certificate @@ -25,7 +25,7 @@ pub struct CardanoTransactionCommitmentMessage { pub created_at: DateTime, } -impl CardanoTransactionCommitmentMessage { +impl CardanoTransactionSnapshotMessage { cfg_test_tools! { /// Return a dummy test entity (test-only). pub fn dummy() -> Self { @@ -46,8 +46,8 @@ impl CardanoTransactionCommitmentMessage { mod tests { use super::*; - fn golden_message() -> CardanoTransactionCommitmentMessage { - CardanoTransactionCommitmentMessage { + fn golden_message() -> CardanoTransactionSnapshotMessage { + CardanoTransactionSnapshotMessage { merkle_root: "mkroot-123".to_string(), beacon: fake_data::beacon(), hash: "hash-123".to_string(), @@ -72,8 +72,8 @@ mod tests { "certificate_hash": "certificate-hash-123", "created_at": "2023-01-19T13:43:05.618857482Z" }"#; - let message: CardanoTransactionCommitmentMessage = serde_json::from_str(json).expect( - "This JSON is expected to be succesfully parsed into a CardanoTransactionCommitmentMessage instance.", + let message: CardanoTransactionSnapshotMessage = serde_json::from_str(json).expect( + "This JSON is expected to be successfully parsed into a CardanoTransactionSnapshotMessage instance.", ); assert_eq!(golden_message(), message); diff --git a/mithril-common/src/messages/cardano_transaction_commitment_list.rs b/mithril-common/src/messages/cardano_transaction_snapshot_list.rs similarity index 69% rename from mithril-common/src/messages/cardano_transaction_commitment_list.rs rename to mithril-common/src/messages/cardano_transaction_snapshot_list.rs index 9d9c273e486..a137c749c8d 100644 --- a/mithril-common/src/messages/cardano_transaction_commitment_list.rs +++ b/mithril-common/src/messages/cardano_transaction_snapshot_list.rs @@ -5,19 +5,19 @@ use crate::entities::Beacon; #[cfg(any(test, feature = "test_tools"))] use crate::test_utils::fake_data; -/// Message structure of a Cardano Transactions Commitments list -pub type CardanoTransactionCommitmentListMessage = Vec; +/// Message structure of a Cardano Transactions Snapshots list +pub type CardanoTransactionSnapshotListMessage = Vec; -/// Message structure of a Cardano Transactions Commitment list item +/// Message structure of a Cardano Transactions Snapshot list item #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] -pub struct CardanoTransactionCommitmentListItemMessage { - /// Merkle root of the Cardano transactions commitment +pub struct CardanoTransactionSnapshotListItemMessage { + /// Merkle root of the Cardano transactions snapshot pub merkle_root: String, - /// Beacon of the Cardano transactions commitment + /// Beacon of the Cardano transactions snapshot pub beacon: Beacon, - /// Hash of the Cardano Transactions commitment + /// Hash of the Cardano Transactions snapshot pub hash: String, /// Hash of the associated certificate @@ -27,7 +27,7 @@ pub struct CardanoTransactionCommitmentListItemMessage { pub created_at: DateTime, } -impl CardanoTransactionCommitmentListItemMessage { +impl CardanoTransactionSnapshotListItemMessage { cfg_test_tools! { /// Return a dummy test entity (test-only). pub fn dummy() -> Self { @@ -50,8 +50,8 @@ mod tests { use super::*; - fn golden_message() -> CardanoTransactionCommitmentListMessage { - vec![CardanoTransactionCommitmentListItemMessage { + fn golden_message() -> CardanoTransactionSnapshotListMessage { + vec![CardanoTransactionSnapshotListItemMessage { merkle_root: "mkroot-123".to_string(), beacon: fake_data::beacon(), hash: "hash-123".to_string(), @@ -71,15 +71,15 @@ mod tests { "network": "testnet", "epoch": 10, "immutable_file_number": 100 - }, + }, "hash": "hash-123", "certificate_hash": "certificate-hash-123", "created_at": "2023-01-19T13:43:05.618857482Z" }]"#; println!("message: {:?}", golden_message()); - let message: CardanoTransactionCommitmentListMessage = serde_json::from_str(json).expect( - "This JSON is expected to be succesfully parsed into a CardanoTransactionCommitmentListMessage instance.", + let message: CardanoTransactionSnapshotListMessage = serde_json::from_str(json).expect( + "This JSON is expected to be successfully parsed into a CardanoTransactionSnapshotListMessage instance.", ); assert_eq!(golden_message(), message); } diff --git a/mithril-common/src/messages/mod.rs b/mithril-common/src/messages/mod.rs index 7d0d1d9b81c..e60dde98ba8 100644 --- a/mithril-common/src/messages/mod.rs +++ b/mithril-common/src/messages/mod.rs @@ -1,7 +1,7 @@ //! Messages module //! This module aims at providing shared structures for API communications. -mod cardano_transaction_commitment; -mod cardano_transaction_commitment_list; +mod cardano_transaction_snapshot; +mod cardano_transaction_snapshot_list; mod cardano_transactions_proof; mod certificate; mod certificate_list; @@ -17,9 +17,9 @@ mod snapshot; mod snapshot_download; mod snapshot_list; -pub use cardano_transaction_commitment::CardanoTransactionCommitmentMessage; -pub use cardano_transaction_commitment_list::{ - CardanoTransactionCommitmentListItemMessage, CardanoTransactionCommitmentListMessage, +pub use cardano_transaction_snapshot::CardanoTransactionSnapshotMessage; +pub use cardano_transaction_snapshot_list::{ + CardanoTransactionSnapshotListItemMessage, CardanoTransactionSnapshotListMessage, }; pub use cardano_transactions_proof::{ CardanoTransactionsProofsMessage, VerifiedCardanoTransactions, diff --git a/mithril-common/src/test_utils/fake_data.rs b/mithril-common/src/test_utils/fake_data.rs index b12989e82bd..d72dbbbe3f8 100644 --- a/mithril-common/src/test_utils/fake_data.rs +++ b/mithril-common/src/test_utils/fake_data.rs @@ -220,10 +220,10 @@ pub fn mithril_stake_distributions(total: u64) -> Vec Vec { +pub fn cardano_transactions_snapshot(total: u64) -> Vec { (1..total + 1) .map(|idx| { - entities::CardanoTransactionsCommitment::new( + entities::CardanoTransactionsSnapshot::new( format!("merkleroot-{idx}"), entities::Beacon { immutable_file_number: idx, diff --git a/mithril-test-lab/mithril-aggregator-fake/Cargo.toml b/mithril-test-lab/mithril-aggregator-fake/Cargo.toml index 22c253036e3..d1c414ef021 100644 --- a/mithril-test-lab/mithril-aggregator-fake/Cargo.toml +++ b/mithril-test-lab/mithril-aggregator-fake/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator-fake" -version = "0.2.1" +version = "0.2.2" description = "Mithril Fake Aggregator for client testing" authors = { workspace = true } documentation = { workspace = true } diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-18f2e46d9b07a8cfff2fd6138675a19931e06c949c9e3592c5f278314f535cd8.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-18f2e46d9b07a8cfff2fd6138675a19931e06c949c9e3592c5f278314f535cd8.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-18f2e46d9b07a8cfff2fd6138675a19931e06c949c9e3592c5f278314f535cd8.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-18f2e46d9b07a8cfff2fd6138675a19931e06c949c9e3592c5f278314f535cd8.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-36a2c7b10af4eea225119c866c6d3931c1b8095d885f080af11d5ee91d687deb.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-36a2c7b10af4eea225119c866c6d3931c1b8095d885f080af11d5ee91d687deb.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-36a2c7b10af4eea225119c866c6d3931c1b8095d885f080af11d5ee91d687deb.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-36a2c7b10af4eea225119c866c6d3931c1b8095d885f080af11d5ee91d687deb.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-5843d93ebc19e446f0c707c637fac0bf3ca272d9c0102a5a45fcd8a61e1d3c06.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-5843d93ebc19e446f0c707c637fac0bf3ca272d9c0102a5a45fcd8a61e1d3c06.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-5843d93ebc19e446f0c707c637fac0bf3ca272d9c0102a5a45fcd8a61e1d3c06.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-5843d93ebc19e446f0c707c637fac0bf3ca272d9c0102a5a45fcd8a61e1d3c06.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-6142130a94d5693b9b23e091e86d2fcc594c2267ded4629d368e9584d82927b2.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-6142130a94d5693b9b23e091e86d2fcc594c2267ded4629d368e9584d82927b2.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-6142130a94d5693b9b23e091e86d2fcc594c2267ded4629d368e9584d82927b2.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-6142130a94d5693b9b23e091e86d2fcc594c2267ded4629d368e9584d82927b2.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-68124a275155807ea2de2f6ef5d3ffc55f6f9c2c301b043e49170df68c303501.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-68124a275155807ea2de2f6ef5d3ffc55f6f9c2c301b043e49170df68c303501.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-68124a275155807ea2de2f6ef5d3ffc55f6f9c2c301b043e49170df68c303501.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-68124a275155807ea2de2f6ef5d3ffc55f6f9c2c301b043e49170df68c303501.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-687f75b22c6e3ffab6d5db1fde91ecbd3c986aeb7eeb2cb98420a82762b3747e.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-687f75b22c6e3ffab6d5db1fde91ecbd3c986aeb7eeb2cb98420a82762b3747e.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-687f75b22c6e3ffab6d5db1fde91ecbd3c986aeb7eeb2cb98420a82762b3747e.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-687f75b22c6e3ffab6d5db1fde91ecbd3c986aeb7eeb2cb98420a82762b3747e.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-8e96a66ef4ff38885c20417d4ba5b0cfccf8cd09ac75ae1e67011ec983502d8e.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-8e96a66ef4ff38885c20417d4ba5b0cfccf8cd09ac75ae1e67011ec983502d8e.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-8e96a66ef4ff38885c20417d4ba5b0cfccf8cd09ac75ae1e67011ec983502d8e.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-8e96a66ef4ff38885c20417d4ba5b0cfccf8cd09ac75ae1e67011ec983502d8e.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-9056cfe649ca6c5e8871cde4c1f5def00c1945b20824cfd5bcd03ec69a45ef42.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-9056cfe649ca6c5e8871cde4c1f5def00c1945b20824cfd5bcd03ec69a45ef42.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-9056cfe649ca6c5e8871cde4c1f5def00c1945b20824cfd5bcd03ec69a45ef42.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-9056cfe649ca6c5e8871cde4c1f5def00c1945b20824cfd5bcd03ec69a45ef42.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-943b405a3e002db2c442415f2a9c7cc6c27349a2b6298b7ad9cc44d4cec0960b.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-943b405a3e002db2c442415f2a9c7cc6c27349a2b6298b7ad9cc44d4cec0960b.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-943b405a3e002db2c442415f2a9c7cc6c27349a2b6298b7ad9cc44d4cec0960b.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-943b405a3e002db2c442415f2a9c7cc6c27349a2b6298b7ad9cc44d4cec0960b.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-96219db543351b8d2e6e716af5bc566b1625c54493f71f56f18f179e4aa25b20.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-96219db543351b8d2e6e716af5bc566b1625c54493f71f56f18f179e4aa25b20.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-96219db543351b8d2e6e716af5bc566b1625c54493f71f56f18f179e4aa25b20.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-96219db543351b8d2e6e716af5bc566b1625c54493f71f56f18f179e4aa25b20.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-98aca9b1a36a973bbb24d278c281e5091e68a57fa39de0533c7bc7f3d23197a0.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-98aca9b1a36a973bbb24d278c281e5091e68a57fa39de0533c7bc7f3d23197a0.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-98aca9b1a36a973bbb24d278c281e5091e68a57fa39de0533c7bc7f3d23197a0.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-98aca9b1a36a973bbb24d278c281e5091e68a57fa39de0533c7bc7f3d23197a0.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-be8b2148240dacdf9b0380cc98d45246cfd2ce2b0b974f4464f4d7a0b638976f.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-be8b2148240dacdf9b0380cc98d45246cfd2ce2b0b974f4464f4d7a0b638976f.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-be8b2148240dacdf9b0380cc98d45246cfd2ce2b0b974f4464f4d7a0b638976f.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-be8b2148240dacdf9b0380cc98d45246cfd2ce2b0b974f4464f4d7a0b638976f.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-caad1e2f6f5790100595aa6e5965d9322c9b00cb12b6d9344980d2f66c513c3e.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-caad1e2f6f5790100595aa6e5965d9322c9b00cb12b6d9344980d2f66c513c3e.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-caad1e2f6f5790100595aa6e5965d9322c9b00cb12b6d9344980d2f66c513c3e.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-caad1e2f6f5790100595aa6e5965d9322c9b00cb12b6d9344980d2f66c513c3e.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-cfea8e49f8fafbcc51a8a8c8223b5a3c51e2c37392e8757373ae37fe1013147d.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-cfea8e49f8fafbcc51a8a8c8223b5a3c51e2c37392e8757373ae37fe1013147d.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-cfea8e49f8fafbcc51a8a8c8223b5a3c51e2c37392e8757373ae37fe1013147d.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-cfea8e49f8fafbcc51a8a8c8223b5a3c51e2c37392e8757373ae37fe1013147d.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-d46093bf991f34e6b34c31bb8ffcc9573cbad04dc210bd04a133939e8656096a.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-d46093bf991f34e6b34c31bb8ffcc9573cbad04dc210bd04a133939e8656096a.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-d46093bf991f34e6b34c31bb8ffcc9573cbad04dc210bd04a133939e8656096a.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-d46093bf991f34e6b34c31bb8ffcc9573cbad04dc210bd04a133939e8656096a.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-e3ebb3f0d9dc28fb834d4089853fe2ca24c1398711d1fcb3a6f55ef4762a4977.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-e3ebb3f0d9dc28fb834d4089853fe2ca24c1398711d1fcb3a6f55ef4762a4977.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-e3ebb3f0d9dc28fb834d4089853fe2ca24c1398711d1fcb3a6f55ef4762a4977.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-e3ebb3f0d9dc28fb834d4089853fe2ca24c1398711d1fcb3a6f55ef4762a4977.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-f91a4c7b7fb60453efab4f0a674df04b6a094a02856d4209c6be6842fd5ac657.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-f91a4c7b7fb60453efab4f0a674df04b6a094a02856d4209c6be6842fd5ac657.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-f91a4c7b7fb60453efab4f0a674df04b6a094a02856d4209c6be6842fd5ac657.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-f91a4c7b7fb60453efab4f0a674df04b6a094a02856d4209c6be6842fd5ac657.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-f9bc2f3b27a7f6714957adb2a4bd1b161800047a44eaae4973bed065be09f04e.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-f9bc2f3b27a7f6714957adb2a4bd1b161800047a44eaae4973bed065be09f04e.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-f9bc2f3b27a7f6714957adb2a4bd1b161800047a44eaae4973bed065be09f04e.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-f9bc2f3b27a7f6714957adb2a4bd1b161800047a44eaae4973bed065be09f04e.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-f9c2105c6f497a0ebb9646d1a1d9b0ec6ed16e03faa484874292e672f43b317d.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-f9c2105c6f497a0ebb9646d1a1d9b0ec6ed16e03faa484874292e672f43b317d.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-f9c2105c6f497a0ebb9646d1a1d9b0ec6ed16e03faa484874292e672f43b317d.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-f9c2105c6f497a0ebb9646d1a1d9b0ec6ed16e03faa484874292e672f43b317d.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-fbc6991bdcc8d11c54d8fcb8e632354b3988655caac669193c4528cc95fb8ede.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-fbc6991bdcc8d11c54d8fcb8e632354b3988655caac669193c4528cc95fb8ede.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitment-fbc6991bdcc8d11c54d8fcb8e632354b3988655caac669193c4528cc95fb8ede.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshot-fbc6991bdcc8d11c54d8fcb8e632354b3988655caac669193c4528cc95fb8ede.json diff --git a/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitments.json b/mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshots.json similarity index 100% rename from mithril-test-lab/mithril-aggregator-fake/default_data/ctx-commitments.json rename to mithril-test-lab/mithril-aggregator-fake/default_data/ctx-snapshots.json diff --git a/mithril-test-lab/mithril-aggregator-fake/scripts/import.sh b/mithril-test-lab/mithril-aggregator-fake/scripts/import.sh index 33b652cc554..752ae6f7069 100755 --- a/mithril-test-lab/mithril-aggregator-fake/scripts/import.sh +++ b/mithril-test-lab/mithril-aggregator-fake/scripts/import.sh @@ -184,8 +184,8 @@ download_artifacts "$BASE_URL/artifact/snapshot" "snapshot" "digest" true download_data "$BASE_URL/artifact/mithril-stake-distributions" "mithril-stake-distributions" download_artifacts "$BASE_URL/artifact/mithril-stake-distribution" "mithril-stake-distribution" "hash" true -download_data "$BASE_URL/artifact/cardano-transactions" "ctx-commitments" -download_artifacts "$BASE_URL/artifact/cardano-transaction" "ctx-commitment" "hash" +download_data "$BASE_URL/artifact/cardano-transactions" "ctx-snapshots" +download_artifacts "$BASE_URL/artifact/cardano-transaction" "ctx-snapshot" "hash" if [ -n "$CARDANO_TRANSACTIONS_HASHES" ]; then download_ctx_proof $CARDANO_TRANSACTIONS_HASHES diff --git a/mithril-test-lab/mithril-aggregator-fake/src/application.rs b/mithril-test-lab/mithril-aggregator-fake/src/application.rs index 495479bf9a1..3fe10482be5 100644 --- a/mithril-test-lab/mithril-aggregator-fake/src/application.rs +++ b/mithril-test-lab/mithril-aggregator-fake/src/application.rs @@ -403,7 +403,7 @@ mod tests { } #[tokio::test] - async fn get_ctx() { + async fn get_ctx_snapshot() { const PORT: u16 = 3011; let task = tokio::spawn(async move { // Yield back to Tokio's scheduler to ensure the web server is ready before going @@ -411,7 +411,7 @@ mod tests { yield_now().await; let path = "/artifact/cardano-transaction/{hash}"; - let hash = default_values::ctx_commitment_hashes()[0]; + let hash = default_values::ctx_snapshot_hashes()[0]; let url = BASE_URL.replace("PORT", &PORT.to_string()); let response = reqwest::get(&format!("{url}{}", path.replace("{hash}", hash))) .await @@ -435,7 +435,7 @@ mod tests { } #[tokio::test] - async fn get_no_ctx() { + async fn get_no_ctx_snapshot() { const PORT: u16 = 3012; let task = tokio::spawn(async move { // Yield back to Tokio's scheduler to ensure the web server is ready before going diff --git a/mithril-test-lab/mithril-aggregator-fake/src/handlers.rs b/mithril-test-lab/mithril-aggregator-fake/src/handlers.rs index 6b1c695de01..b1e75b03b76 100644 --- a/mithril-test-lab/mithril-aggregator-fake/src/handlers.rs +++ b/mithril-test-lab/mithril-aggregator-fake/src/handlers.rs @@ -27,8 +27,8 @@ pub async fn aggregator_router() -> Router { .route("/artifact/mithril-stake-distributions", get(msds)) .route("/artifact/mithril-stake-distribution/:digest", get(msd)) .route("/artifact/snapshot/:digest", get(snapshot)) - .route("/artifact/cardano-transactions", get(ctx_commitments)) - .route("/artifact/cardano-transaction/:hash", get(ctx_commitment)) + .route("/artifact/cardano-transactions", get(ctx_snapshots)) + .route("/artifact/cardano-transaction/:hash", get(ctx_snapshot)) .route("/proof/cardano-transaction", get(ctx_proof)) .route("/certificates", get(certificates)) .route("/certificate/:hash", get(certificate)) @@ -127,25 +127,25 @@ pub async fn certificate( } /// HTTP: return the list of certificates -pub async fn ctx_commitments(State(state): State) -> Result { +pub async fn ctx_snapshots(State(state): State) -> Result { let app_state = state.read().await; - let certificates = app_state.get_ctx_commitments().await?; + let certificates = app_state.get_ctx_snapshots().await?; Ok(certificates) } -/// HTTP: return a cardano transaction commitment identified by its hash. -pub async fn ctx_commitment( +/// HTTP: return a cardano transaction snapshot identified by its hash. +pub async fn ctx_snapshot( Path(key): Path, State(state): State, ) -> Result, AppError> { let app_state = state.read().await; app_state - .get_ctx_commitment(&key) + .get_ctx_snapshot(&key) .await? .map(|s| s.into_response()) - .ok_or_else(|| AppError::NotFound(format!("ctx commitment hash={key}"))) + .ok_or_else(|| AppError::NotFound(format!("ctx snapshot hash={key}"))) } #[derive(serde::Deserialize, Default)] @@ -274,24 +274,24 @@ mod tests { } #[tokio::test] - async fn invalid_ctx_commitment_hash() { + async fn invalid_ctx_snapshot_hash() { let state: State = State(AppState::default().into()); let hash = Path("whatever".to_string()); - let error = ctx_commitment(hash, state).await.expect_err( - "The handler was expected to fail since the ctx commitment's hash does not exist.", + let error = ctx_snapshot(hash, state).await.expect_err( + "The handler was expected to fail since the ctx snapshot's hash does not exist.", ); assert!(matches!(error, AppError::NotFound(_))); } #[tokio::test] - async fn existing_ctx_commitment_hash() { + async fn existing_ctx_snapshot_hash() { let state: State = State(AppState::default().into()); - let hash = Path(default_values::ctx_commitment_hashes()[0].to_string()); + let hash = Path(default_values::ctx_snapshot_hashes()[0].to_string()); - let response = ctx_commitment(hash, state).await.expect( - "The handler was expected to succeed since the ctx commitment's hash does exist.", + let response = ctx_snapshot(hash, state).await.expect( + "The handler was expected to succeed since the ctx snapshot's hash does exist.", ); assert_eq!(StatusCode::OK, response.status()); diff --git a/mithril-test-lab/mithril-aggregator-fake/src/shared_state.rs b/mithril-test-lab/mithril-aggregator-fake/src/shared_state.rs index 0175aa50eac..55b8bf0c114 100644 --- a/mithril-test-lab/mithril-aggregator-fake/src/shared_state.rs +++ b/mithril-test-lab/mithril-aggregator-fake/src/shared_state.rs @@ -19,8 +19,8 @@ pub struct AppState { snapshots: BTreeMap, msd_list: String, msds: BTreeMap, - ctx_commitment_list: String, - ctx_commitments: BTreeMap, + ctx_snapshot_list: String, + ctx_snapshots: BTreeMap, ctx_proofs: BTreeMap, } @@ -44,8 +44,8 @@ impl Default for AppState { snapshots: default_values::snapshots(), msd_list: default_values::msd_list().to_owned(), msds: default_values::msds(), - ctx_commitment_list: default_values::ctx_commitments_list().to_owned(), - ctx_commitments: default_values::ctx_commitments(), + ctx_snapshot_list: default_values::ctx_snapshots_list().to_owned(), + ctx_snapshots: default_values::ctx_snapshots(), ctx_proofs: default_values::ctx_proofs(), } } @@ -61,7 +61,7 @@ impl AppState { reader.read_certificate_chain(&certificate_list, &mut certificates)?; let (snapshot_list, snapshots) = reader.read_files("snapshot", "digest")?; let (msd_list, msds) = reader.read_files("mithril-stake-distribution", "hash")?; - let (ctx_commitment_list, ctx_commitments) = reader.read_files("ctx-commitment", "hash")?; + let (ctx_snapshot_list, ctx_snapshots) = reader.read_files("ctx-snapshot", "hash")?; let (_, ctx_proofs) = reader.read_files("ctx-proof", "transaction_hash")?; let instance = Self { @@ -72,8 +72,8 @@ impl AppState { snapshots, msd_list, msds, - ctx_commitment_list, - ctx_commitments, + ctx_snapshot_list, + ctx_snapshots, ctx_proofs, }; @@ -115,14 +115,14 @@ impl AppState { Ok(self.certificates.get(key).cloned()) } - /// return the list of Cardano transactions commitments in the same order as they were read - pub async fn get_ctx_commitments(&self) -> StdResult { - Ok(self.ctx_commitment_list.clone()) + /// return the list of Cardano transactions snapshots in the same order as they were read + pub async fn get_ctx_snapshots(&self) -> StdResult { + Ok(self.ctx_snapshot_list.clone()) } - /// return the Cardano transactions commitment identified by the given key if any. - pub async fn get_ctx_commitment(&self, key: &str) -> StdResult> { - Ok(self.ctx_commitments.get(key).cloned()) + /// return the Cardano transactions snapshot identified by the given key if any. + pub async fn get_ctx_snapshot(&self, key: &str) -> StdResult> { + Ok(self.ctx_snapshots.get(key).cloned()) } /// return the Cardano transactions proofs from Cardano transaction hashes. diff --git a/mithril-test-lab/mithril-end-to-end/Cargo.toml b/mithril-test-lab/mithril-end-to-end/Cargo.toml index 9b63be5a283..21e2b050d5d 100644 --- a/mithril-test-lab/mithril-end-to-end/Cargo.toml +++ b/mithril-test-lab/mithril-end-to-end/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-end-to-end" -version = "0.4.2" +version = "0.4.3" authors = { workspace = true } edition = { workspace = true } documentation = { workspace = true } diff --git a/mithril-test-lab/mithril-end-to-end/src/assertions/check.rs b/mithril-test-lab/mithril-end-to-end/src/assertions/check.rs index 90f5e05b512..e509099e884 100644 --- a/mithril-test-lab/mithril-end-to-end/src/assertions/check.rs +++ b/mithril-test-lab/mithril-end-to-end/src/assertions/check.rs @@ -6,7 +6,7 @@ use anyhow::{anyhow, Context}; use mithril_common::{ entities::{Epoch, TransactionHash}, messages::{ - CardanoTransactionCommitmentListMessage, CardanoTransactionCommitmentMessage, + CardanoTransactionSnapshotListMessage, CardanoTransactionSnapshotMessage, CertificateMessage, MithrilStakeDistributionListMessage, MithrilStakeDistributionMessage, SnapshotMessage, }, @@ -170,7 +170,7 @@ pub async fn assert_node_producing_cardano_transactions( match reqwest::get(url.clone()).await { Ok(response) => match response.status() { StatusCode::OK => match response - .json::() + .json::() .await .as_deref() { @@ -211,7 +211,7 @@ pub async fn assert_signer_is_signing_cardano_transactions( match attempt!(10, Duration::from_millis(1000), { match reqwest::get(url.clone()).await { Ok(response) => match response.status() { - StatusCode::OK => match response.json::().await { + StatusCode::OK => match response.json::().await { Ok(artifact) => match artifact.beacon.epoch { epoch if epoch >= expected_epoch_min => Ok(Some(artifact)), epoch => Err(anyhow!( diff --git a/mithril-test-lab/mithril-end-to-end/src/mithril/client.rs b/mithril-test-lab/mithril-end-to-end/src/mithril/client.rs index 5d13cae2ac6..bb3d44a54eb 100644 --- a/mithril-test-lab/mithril-end-to-end/src/mithril/client.rs +++ b/mithril-test-lab/mithril-end-to-end/src/mithril/client.rs @@ -68,16 +68,16 @@ impl MithrilStakeDistributionCommand { #[derive(Debug)] pub enum CardanoTransactionCommand { - ListCommitment, - ShowCommitment { hash: String }, + ListSnapshot, + ShowSnapshot { hash: String }, Certify { tx_hashes: Vec }, } impl CardanoTransactionCommand { fn name(&self) -> String { match self { - CardanoTransactionCommand::ListCommitment => "list-commitment".to_string(), - CardanoTransactionCommand::ShowCommitment { hash } => format!("show-commitment-{hash}"), + CardanoTransactionCommand::ListSnapshot => "list-snapshot".to_string(), + CardanoTransactionCommand::ShowSnapshot { hash } => format!("show-snapshot-{hash}"), CardanoTransactionCommand::Certify { tx_hashes } if tx_hashes.len() > 1 => { // Only output first & last hash to avoid too long filenames format!("certify-{}..{}", tx_hashes[0], tx_hashes.last().unwrap()) @@ -90,11 +90,11 @@ impl CardanoTransactionCommand { fn cli_arg(&self) -> Vec { match self { - CardanoTransactionCommand::ListCommitment => { - vec!["commitment".to_string(), "list".to_string()] + CardanoTransactionCommand::ListSnapshot => { + vec!["snapshot".to_string(), "list".to_string()] } - CardanoTransactionCommand::ShowCommitment { hash } => { - vec!["commitment".to_string(), "show".to_string(), hash.clone()] + CardanoTransactionCommand::ShowSnapshot { hash } => { + vec!["snapshot".to_string(), "show".to_string(), hash.clone()] } CardanoTransactionCommand::Certify { tx_hashes } => { vec!["certify".to_string(), tx_hashes.join(",")] diff --git a/openapi.yaml b/openapi.yaml index acb396c391d..fbd7f0a559a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4,7 +4,7 @@ info: # `mithril-common/src/lib.rs` file. If you plan to update it # here to reflect changes in the API, please also update the constant in the # Rust file. - version: 0.1.18 + version: 0.1.19 title: Mithril Aggregator Server description: | The REST API provided by a Mithril Aggregator Node in a Mithril network. @@ -291,20 +291,20 @@ paths: /artifact/cardano-transactions: get: - summary: Get most recent Cardano transactions set commitments + summary: Get most recent Cardano transactions set snapshots description: | - Returns the list of the most recent Cardano transactions set commitments + Returns the list of the most recent Cardano transactions set snapshots responses: "200": - description: Cardano transactions set commitments found + description: Cardano transactions set snapshots found content: application/json: schema: - $ref: "#/components/schemas/CardanoTransactionCommitmentListMessage" + $ref: "#/components/schemas/CardanoTransactionSnapshotListMessage" "412": description: API version mismatch default: - description: Cardano transactions set commitments retrieval error + description: Cardano transactions set snapshots retrieval error content: application/json: schema: @@ -312,13 +312,13 @@ paths: /artifact/cardano-transaction/{hash}: get: - summary: Get Cardano transactions set commitment information + summary: Get Cardano transactions set snapshot information description: | - Returns the information of a Cardano transactions set commitment + Returns the information of a Cardano transactions set snapshot parameters: - name: hash in: path - description: Hash of the Cardano transactions set commitment to retrieve + description: Hash of the Cardano transactions set snapshot to retrieve required: true schema: type: string @@ -326,17 +326,17 @@ paths: example: "6da2b104ed68481ef829d72d72c2f6a20142916d17985e01774b14ed49f0fea1" responses: "200": - description: Cardano transactions set commitment found + description: Cardano transactions set snapshot found content: application/json: schema: - $ref: "#/components/schemas/CardanoTransactionCommitmentMessage" + $ref: "#/components/schemas/CardanoTransactionSnapshotMessage" "404": - description: Cardano transactions set commitment not found + description: Cardano transactions set snapshot not found "412": description: API version mismatch default: - description: Cardano transactions set commitment retrieval error + description: Cardano transactions set snapshot retrieval error content: application/json: schema: @@ -566,13 +566,13 @@ components: - CardanoStakeDistribution - CardanoImmutableFilesFull - CardanoTransactions - example: + example: { "open_api_version": "0.1.17", "documentation_url": "https://mithril.network", "capabilities": { - "signed_entity_types": ["MithrilStakeDistribution", "CardanoImmutableFilesFull", "CardanoTransactions"] + "signed_entity_types": [ "MithrilStakeDistribution", "CardanoImmutableFilesFull", "CardanoTransactions" ] } } @@ -596,8 +596,8 @@ components: $ref: "#/components/schemas/ProtocolParameters" next_protocol: $ref: "#/components/schemas/ProtocolParameters" - example: - { + example: + { "epoch": 329, "protocol": { "k": 857, "m": 6172, "phi_f": 0.2 }, "next_protocol": { "k": 2422, "m": 20973, "phi_f": 0.2 } @@ -682,7 +682,7 @@ components: type: array items: $ref: "#/components/schemas/Signer" - example: + example: { "beacon": { @@ -710,7 +710,7 @@ components: "kes_period": 456 } ], - "next_signers": + "next_signers": [ { "party_id": "3456789000", @@ -925,8 +925,8 @@ components: RegisterSingleSignatureMessage: description: | - This message holds a Signer Single Signature with the - list of won indexes in the lottery. + This message holds a Signer Single Signature with the + list of won indexes in the lottery. type: object additionalProperties: false required: @@ -955,7 +955,7 @@ components: "entity_type": { "MithrilStakeDistribution": 246 }, "party_id": "1234567890", "signature": "7b2c36322c3130352c3232322c31302c3131302c33312c37312c39372c22766b223a5b3136342c2c31393137352c313834", - "indexes": [25, 35] + "indexes": [ 25, 35 ] } ProtocolMessageParts: @@ -990,7 +990,7 @@ components: $ref: "#/components/schemas/ProtocolMessageParts" example: { - "message_parts": + "message_parts": { "snapshot_digest": "6367ee65d0d1272e6e70736a1ea2cae34015874517f6328364f6b73930966732", "next_aggregate_verification_key": "b132362c3232352c36392c31373133352c31323235392c3235332c3233342c34226d745f636f6d6d69746d656e74223a7b22726f6f74223a5b33382c3382c3138322c3231322c2c363" @@ -1521,10 +1521,10 @@ components: $ref: "#/components/schemas/ProtocolParameters" example: { - "epoch": 123, - "hash": "6367ee65d0d1272e6e70736a1ea2cae34015874517f6328364f6b73930966732", - "certificate_hash": "7905e83ab5d7bc082c1bbc3033bfd19c539078830d19080d1f241c70aa532572", - "signers": + "epoch": 123, + "hash": "6367ee65d0d1272e6e70736a1ea2cae34015874517f6328364f6b73930966732", + "certificate_hash": "7905e83ab5d7bc082c1bbc3033bfd19c539078830d19080d1f241c70aa532572", + "signers": [ { "party_id": "1234567890", @@ -1543,12 +1543,12 @@ components: "stake": 2345 } ], - "created_at": "2022-06-14T10:52:31Z", - "protocol_parameters": { "k": 5, "m": 100, "phi_f": 0.65 } + "created_at": "2022-06-14T10:52:31Z", + "protocol_parameters": { "k": 5, "m": 100, "phi_f": 0.65 } } - CardanoTransactionCommitmentListMessage: - description: CardanoTransactionCommitmentListMessage represents a list of Cardano transactions set commitments + CardanoTransactionSnapshotListMessage: + description: CardanoTransactionSnapshotListMessage represents a list of Cardano transactions set snapshots type: array items: type: object @@ -1584,16 +1584,16 @@ components: "certificate_hash": "7905e83ab5d7bc082c1bbc3033bfd19c539078830d19080d1f241c70aa532572", "merkle_root": "33bfd17bc082ab5dd1fc0788241c70aa5325241c70aa532530d190809c5391bbc307905e8372", "beacon": - { - "network": "mainnet", - "epoch": 329, - "immutable_file_number": 7060000 - }, + { + "network": "mainnet", + "epoch": 329, + "immutable_file_number": 7060000 + }, "created_at": "2022-06-14T10:52:31Z" } - CardanoTransactionCommitmentMessage: - description: This message represents a Cardano transactions set commitment. + CardanoTransactionSnapshotMessage: + description: This message represents a Cardano transactions set snapshot. type: object additionalProperties: false required: @@ -1627,11 +1627,11 @@ components: "certificate_hash": "7905e83ab5d7bc082c1bbc3033bfd19c539078830d19080d1f241c70aa532572", "merkle_root": "33bfd17bc082ab5dd1fc0788241c70aa5325241c70aa532530d190809c5391bbc307905e8372", "beacon": - { - "network": "mainnet", - "epoch": 329, - "immutable_file_number": 7060000 - }, + { + "network": "mainnet", + "epoch": 329, + "immutable_file_number": 7060000 + }, "created_at": "2022-06-14T10:52:31Z" } @@ -1676,11 +1676,11 @@ components: example: { "certificate_hash": "7905e83ab5d7bc082c1bbc3033bfd19c539078830d19080d1f241c70aa532572", - "certified_transactions": [{ - "transactions_hashes": ["6367ee65d0d1272e6e70736a1ea2cae34015874517f6328364f6b73930966732", "5d0d1272e6e70736a1ea2cae34015876367ee64517f6328364f6b73930966732"], + "certified_transactions": [ { + "transactions_hashes": [ "6367ee65d0d1272e6e70736a1ea2cae34015874517f6328364f6b73930966732", "5d0d1272e6e70736a1ea2cae34015876367ee64517f6328364f6b73930966732" ], "proof": "5b73136372c38302c37342c3136362c313535b5b323136362c313535b5b3232352c3230332c3235352c313030262c38322c39382c32c39332c3138342c313532352c3230332c3235352c313030262c33136362c313535b5b3232352c3230332c3235352c313030262c38322c39382c32c39332c3138342c31358322c39382c32c39332c3138342c3135362c3136362c32312c3131312c3232312c36332c3137372c3232332c3232332c31392c3537" - }], - "non_certified_transactions": ["732d0d1272e6e70736367ee6f6328364f6b739309666a1ea2cae34015874517"], + } ], + "non_certified_transactions": [ "732d0d1272e6e70736367ee6f6328364f6b739309666a1ea2cae34015874517" ], } Error: