Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cardano transaction sets & proof in client cli #1501

Merged
merged 20 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
29c93b0
Scaffold cardano transaction in client cli
Alenar Feb 12, 2024
997eaa0
Implement cardano transaction commitment list
Alenar Feb 12, 2024
548d046
Wrap transaction sets commands in a 'sets' subcommand
Alenar Feb 12, 2024
603f095
Factorize client builder init from parameters
Alenar Feb 12, 2024
825a956
Fix missing required key in tx message in openapi
Alenar Feb 12, 2024
53c43e6
Implement cardano transaction sets show
Alenar Feb 12, 2024
0e6a0cd
Enhance get_proofs from client lib to accept more arg types
Alenar Feb 12, 2024
3b91b27
Implement cardano transaction certify in cli
Alenar Feb 12, 2024
8d6bfb6
Fix tx retrieval by prover service not using same order as the signab…
Alenar Feb 13, 2024
bf7e111
Highlight `CardanoTransactionCommands` as unstable in clap doc for cl…
Alenar Feb 13, 2024
a365e87
Remove direct dependency to `mithril-common` in client-cli
Alenar Feb 13, 2024
f7a3ddd
Update client-cli page in docsite
Alenar Feb 13, 2024
0922668
Add support for new commands for the client in e2e runner
Alenar Feb 13, 2024
b2f6bd0
Fix parallel exec of tests in common pallas_observer
Alenar Feb 13, 2024
59b4901
refactor: split mithril specific devnet scripts
jpraynaud Feb 13, 2024
24bed4c
feat: add Mithril payment script in 'devnet'
jpraynaud Feb 13, 2024
60622f4
feat: verify Cardano transactions with client in e2e test
jpraynaud Feb 13, 2024
2fc3e12
Fix index of cardano tx table that was tagged as unique
Alenar Feb 13, 2024
d3e8ecf
Only run client cardano tx checks if the tx signind is enabled
Alenar Feb 13, 2024
d393ddc
Upgrade crates, devnet, and openapi versions
Alenar Feb 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 48 additions & 7 deletions docs/website/root/manual/developer-docs/nodes/mithril-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ Display the help menu:
You should see:

```bash
This program shows, downloads, and verifies certified blockchain artifacts.
This program shows, downloads and verifies certified blockchain artifacts.

Usage: mithril-client-cli [OPTIONS] <COMMAND>
Usage: mithril-client [OPTIONS] <COMMAND>

Commands:
snapshot Snapshot commands
mithril-stake-distribution Mithril stake distribution management (alias: msd)
help Print this message or the help for the given subcommand(s)
snapshot Snapshot management
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)

Options:
--run-mode <RUN_MODE>
Expand All @@ -136,17 +137,18 @@ Options:
--config-directory <CONFIG_DIRECTORY>
Directory where configuration file is located [default: ./config]
--aggregator-endpoint <AGGREGATOR_ENDPOINT>
Override configuration Aggregator endpoint URL
Override configuration Aggregator endpoint URL [env: AGGREGATOR_ENDPOINT=]
--log-format-json
Enable JSON output for logs displayed according to verbosity level
--log-output <LOG_OUTPUT>
Redirect the logs to a file
--unstable
Enable unstable commands (such as Cardano Transactions)
-h, --help
Print help
-V, --version
Print version


```

Run in release mode with the default configuration:
Expand Down Expand Up @@ -246,6 +248,15 @@ 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 sets
mithril_client --unstable cardano-transaction sets list

# 8- Show detailed information about a Cardano transaction sets
mithril_client --unstable cardano-transaction sets show $CARDANO_TRANSACTION_SETS_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
```

### Local image
Expand Down Expand Up @@ -283,6 +294,15 @@ Here are the subcommands available:
| **help** | Prints this message or the help for the given subcommand(s)|
| **list** | Lists available Mithril stake distributions|

### Cardano transactions

| Subcommand | Performed action |
|------------|------------------|
| **certify** | Certifies that given list of transactions hashes are included in the Cardano transactions set|
| **help** | Prints this message or the help for the given subcommand(s)|
| **sets list** | Lists available Cardano transactions sets|
| **sets show** | Shows information about a Cardano transaction sets|

## Configuration parameters

The configuration parameters can be set in either of the following ways:
Expand All @@ -296,6 +316,7 @@ Here is a list of the available parameters:
| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
|-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:|
| `verbose` | `--verbose` | `-v` | `VERBOSE` | Verbosity level | - | Parsed from the number of occurrences: `-v` for `Warning`, `-vv` for `Info`, `-vvv` for `Debug` and `-vvvv` for `Trace` | :heavy_check_mark: |
| `unstable` | `--unstable` | - | - | Enable unstable commands | - | - | - |
| `run_mode` | `--run-mode` | - | `RUN_MODE` | Runtime mode | `dev` | - | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
| `aggregator_endpoint` | `--aggregator-endpoint` | - | `AGGREGATOR_ENDPOINT` | Aggregator node endpoint | - | `https://aggregator.pre-release-preview.api.mithril.network/aggregator` | :heavy_check_mark: |
Expand Down Expand Up @@ -336,3 +357,23 @@ 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 --unstable sets show` command:

| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
|-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:|
| `hash` | `--hash` | - | `HASH` | Cardano transaction sets hash or `latest` for the latest Cardano transaction sets | - | - | :heavy_check_mark: |
| `json` | `--json` | - | - | Enable JSON output for command results | - | - | - |

`cardano-transaction --unstable sets list` command:

| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
|-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:|
| `json` | `--json` | - | - | Enable JSON output for command results | - | - | - |

`cardano-transaction --unstable download` command:

| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
|-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:|
| `transactions_hashes` | `--transactions_hashes` | - | `TRANSACTIONS_HASHES` | Cardano transactions hashes separated by commas | - | - | :heavy_check_mark: |
| `json` | `--json` | - | - | Enable JSON output for progress logs | - | - | - |
2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.4.36"
version = "0.4.37"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
15 changes: 15 additions & 0 deletions mithril-aggregator/src/database/cardano_transaction_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ create table cardano_tx (
);

create unique index cardano_tx_immutable_file_number_index on cardano_tx(immutable_file_number);
"#,
),
// Migration 2
// Fix the `cardano_tx` table index on immutable_file number, incorrectly marked as unique.
SqlMigration::new(
2,
r#"
-- remove all data from the cardano tx table since a lot of transactions where missing for each
-- block and we rely on their insert order.
delete from cardano_tx;

drop index cardano_tx_immutable_file_number_index;
create index cardano_tx_immutable_file_number_index on cardano_tx(immutable_file_number);

vacuum;
"#,
),
]
Expand Down
21 changes: 6 additions & 15 deletions mithril-aggregator/src/database/provider/cardano_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ impl<'client> Provider<'client> for CardanoTransactionProvider<'client> {
let aliases = SourceAlias::new(&[("{:cardano_tx:}", "cardano_tx")]);
let projection = Self::Entity::get_projection().expand(aliases);

format!(
"select {projection} from cardano_tx where {condition} order by transaction_hash desc"
)
format!("select {projection} from cardano_tx where {condition} order by rowid")
}
}

Expand Down Expand Up @@ -205,7 +203,7 @@ impl CardanoTransactionRepository {
Self { connection }
}

/// Return all the [CardanoTransactionRecord]s in the database.
/// Return all the [CardanoTransactionRecord]s in the database using chronological order.
pub async fn get_all_transactions(&self) -> StdResult<Vec<CardanoTransactionRecord>> {
let provider = CardanoTransactionProvider::new(&self.connection);
let filters = WhereCondition::default();
Expand All @@ -214,7 +212,8 @@ impl CardanoTransactionRepository {
Ok(transactions.collect())
}

/// Return all the [CardanoTransactionRecord]s in the database up to the given beacon.
/// Return all the [CardanoTransactionRecord]s in the database up to the given beacon using
/// chronological order.
pub async fn get_transactions_up_to(
&self,
beacon: &Beacon,
Expand Down Expand Up @@ -551,22 +550,15 @@ mod tests {
.await
.unwrap();

assert_eq!(
cardano_transactions[0..=14]
.iter()
.cloned()
.rev()
.collect::<Vec<_>>(),
transaction_result
);
assert_eq!(cardano_transactions[0..=14].to_vec(), transaction_result);

let transaction_result = repository
.get_up_to(&Beacon::new("".to_string(), 1, 300))
.await
.unwrap();

assert_eq!(
cardano_transactions.into_iter().rev().collect::<Vec<_>>(),
cardano_transactions.into_iter().collect::<Vec<_>>(),
transaction_result
);

Expand Down Expand Up @@ -603,7 +595,6 @@ mod tests {
let transactions_result = repository.get_all_transactions().await.unwrap();
let transactions_expected: Vec<CardanoTransactionRecord> = cardano_transactions
.iter()
.rev()
.map(|tx| tx.clone().into())
.collect();

Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/src/services/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub trait ProverService: Sync + Send {
#[cfg_attr(test, automock)]
#[async_trait]
pub trait TransactionsRetriever: Sync + Send {
/// Get transactions up to given beacon
/// Get transactions up to given beacon using chronological order
async fn get_up_to(&self, beacon: &Beacon) -> StdResult<Vec<CardanoTransaction>>;
}

Expand Down
10 changes: 3 additions & 7 deletions mithril-client-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-client-cli"
version = "0.5.19"
version = "0.6.0"
description = "A Mithril Client"
authors = { workspace = true }
edition = { workspace = true }
Expand Down Expand Up @@ -32,8 +32,7 @@ fs2 = "0.4.3"
futures = "0.3.28"
human_bytes = { version = "0.4.3", features = ["fast"] }
indicatif = { version = "0.17.7", features = ["tokio"] }
mithril-client = { path = "../mithril-client", features = ["fs"] }
mithril-common = { path = "../mithril-common", features = ["full"] }
mithril-client = { path = "../mithril-client", features = ["fs", "unstable"] }
openssl = { version = "0.10.63", features = ["vendored"], optional = true }
openssl-probe = { version = "0.1.5", optional = true }
serde = { version = "1.0.196", features = ["derive"] }
Expand All @@ -49,9 +48,6 @@ slog-term = "2.9.0"
thiserror = "1.0.56"
tokio = { version = "1.35.1", features = ["full"] }

[dev-dependencies]
mithril-common = { path = "../mithril-common", features = ["test_http_server"] }

[features]
portable = ["mithril-common/portable"]
portable = ["mithril-client/portable"]
bundle_openssl = ["dep:openssl", "dep:openssl-probe"]
Loading
Loading