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

Ensemble/895/mithril client snapshot commands #951

Merged
merged 9 commits into from Jun 1, 2023

Conversation

ghubertpalo
Copy link
Collaborator

@ghubertpalo ghubertpalo commented May 31, 2023

Content

This PR includes snapshot commands to the Mithril client.

Pre-submit checklist

  • Branch
    • Tests are provided
    • Crates versions are updated
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • No clippy warnings in the CI
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • Update documentation website
    • Add dev blog post (yes but not in this ticket)

Comments

This PR also includes some refactoring in the common crate.

Issue(s)

Closes #895

@github-actions
Copy link

github-actions bot commented May 31, 2023

Test Results

    3 files  ±  0    30 suites  ±0   5m 28s ⏱️ -19s
574 tests  - 22  574 ✔️  - 22  0 💤 ±0  0 ±0 
606 runs   - 66  606 ✔️  - 66  0 💤 ±0  0 ±0 

Results for commit fbece38. ± Comparison against base commit b2124a3.

This pull request removes 33 and adds 11 tests. Note that renamed tests count towards both.
aggregator::tests ‑ discard_current_api_version_one_version
aggregator::tests ‑ discard_current_api_version_two_version
aggregator::tests ‑ discard_current_api_version_zero_version
aggregator::tests ‑ get_certificate_details_ko_404
aggregator::tests ‑ get_certificate_details_ko_500
aggregator::tests ‑ get_certificate_details_ko_unreachable
aggregator::tests ‑ get_certificate_details_ok
aggregator::tests ‑ get_download_snapshot_ko_500
aggregator::tests ‑ get_download_snapshot_ko_unreachable
aggregator::tests ‑ get_download_snapshot_ok
…
aggregator_client::certificate_client::tests ‑ test_show_ko
aggregator_client::certificate_client::tests ‑ test_show_ok_none
aggregator_client::certificate_client::tests ‑ test_show_ok_some
services::snapshot::tests ‑ test_download_snapshot_dir_already_exists
services::snapshot::tests ‑ test_download_snapshot_invalid_digest
services::snapshot::tests ‑ test_download_snapshot_ok
services::snapshot::tests ‑ test_list_snapshots
services::snapshot::tests ‑ test_list_snapshots_err
services::snapshot::tests ‑ test_show_snapshot
services::snapshot::tests ‑ test_show_snapshot_err
…

♻️ This comment has been updated with latest results.

Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I left few comments below

Arc::new(CertificateClient::new(http_client)),
Arc::new(MithrilCertificateVerifier::new(slog_scope::logger())),
Arc::new(CardanoImmutableDigester::new(
Path::new(""),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment or to do here to explain with the path is empty?

Arc::new(CertificateClient::new(http_client)),
Arc::new(MithrilCertificateVerifier::new(slog_scope::logger())),
Arc::new(CardanoImmutableDigester::new(
Path::new(""),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above


/// Convert Snapshot to SnapshotFieldItems routine
fn convert_to_field_items(snapshot: &Snapshot) -> Vec<SnapshotFieldItem> {
let mut field_items = vec![
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a SnapshotFieldItem with the Cardano network and use the snapshot.beacon.network to retrieve the value

@@ -21,10 +21,6 @@ pub struct Config {
/// for the purpose of tabular display
#[derive(Table, Debug, Clone, PartialEq, Eq, PartialOrd, Serialize)]
pub struct SnapshotListItem {
/// Cardano network
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have kept this information of the Cardano network and use the snapshot.beacon.network to retrieve the value

mithril-client/src/main.rs Show resolved Hide resolved
mithril-client/src/main.rs Outdated Show resolved Hide resolved
/// CLI command list
#[derive(Subcommand, Debug, Clone)]
enum Commands {
enum SnapshotCommands {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be declared in the snapshot command sub-module? WDYT?

/// List available snapshots
#[clap(arg_required_else_help = false)]
List(ListCommand),
List(SnapshotListCommand),

/// Show detailed informations about a snapshot
#[clap(arg_required_else_help = false)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this instead?

Suggested change
#[clap(arg_required_else_help = false)]
#[clap(arg_required_else_help = true)]

Copy link
Member

@jpraynaud jpraynaud Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this runtime module?

let from_vec = Vec::from_hex(from).map_err(|e| format!("can't parse from hex: {e}"))?;
serde_json::from_slice(from_vec.as_slice()).map_err(|e| format!("can't deserialize: {e}"))
let from_vec = Vec::from_hex(from).map_err(|e| {
format!("Key decode hex: can not turn hexadecimal '{from}' into bytes, error: {e}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The from could be very lengthy and hard to read error message. Maybe using the std::any::type_name::<T>() as below could give a good hint of where the problem occurs?

Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghubertpalo ghubertpalo force-pushed the ensemble/895/mithril_client_snapshot_commands branch from 2428f22 to 671c082 Compare June 1, 2023 10:22
@ghubertpalo ghubertpalo force-pushed the ensemble/895/mithril_client_snapshot_commands branch 2 times, most recently from 14060f8 to 1cb7bdb Compare June 1, 2023 12:32
@ghubertpalo ghubertpalo temporarily deployed to testing-preview June 1, 2023 12:39 — with GitHub Actions Inactive
@ghubertpalo ghubertpalo force-pushed the ensemble/895/mithril_client_snapshot_commands branch from 1cb7bdb to fbece38 Compare June 1, 2023 13:00
@ghubertpalo ghubertpalo temporarily deployed to testing-preview June 1, 2023 13:07 — with GitHub Actions Inactive
@ghubertpalo ghubertpalo merged commit 27d5783 into main Jun 1, 2023
24 checks passed
@ghubertpalo ghubertpalo deleted the ensemble/895/mithril_client_snapshot_commands branch June 1, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create the sub-command for Cardano Immutable Files Full in client
3 participants