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

Redesign mithril client api #1332

Merged
merged 52 commits into from
Nov 13, 2023
Merged

Commits on Nov 13, 2023

  1. Remove lib section from mithril-client-cli cargo toml

    Else the new `mithril-client` crate will conflict with it as they would
    share the same name.
    
    Note: current lib usages, and rust doc, had to be updated since this
    change the import path.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    52fe45b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    999db69 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    cba498e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    2ad48a6 View commit details
    Browse the repository at this point in the history
  5. CertificateClient can now validate Certificates

    Doing this required to address a circular dependency: The certificate
    client need to have a certificate verifier that need to have a
    certificate retriever that was implemented by the certificate client.
    To solve this a internal type, `InternalCertificateRetriever` is added
    to implement the `CertificateRetriever` trait.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    af61ea7 View commit details
    Browse the repository at this point in the history
  6. (re)Add the Client type + implement most of the ClientBuilder

    This new `Client` is just a struct that hold an Arc to each of the
    available subclients.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    1a08b4d View commit details
    Browse the repository at this point in the history
  7. Scaffold a complete mithril stake distribution integration tests

    Including: list, get (latest hash from list), verify certificate chain,
    and message validation.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    f867487 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    f29e53f View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    696094c View commit details
    Browse the repository at this point in the history
  10. Refactor AggregatorClient to pass explicit operation to its methods

    This allow to hide from the trait that the aggregator client works using
    http, making this design more robust if we change the way to communicate
    to an aggregator.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    4d37a90 View commit details
    Browse the repository at this point in the history
  11. Add snapshot client test

    + Change the snapshot client `show` method into a `get` method that return
      an option. This is in order to have the same method name on all
      clients.
    + Note: the test doesn't handle the download right now, it will be added
      later.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    83bbd35 View commit details
    Browse the repository at this point in the history
  12. Rework message computation to be able to take in dependencies

    Using a builder pattern, manually setting dependencies is optional since
    if they're missing the builder will be able to construct them by itself.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    9f7d70b View commit details
    Browse the repository at this point in the history
  13. Move Message to and from Certificate conversions in a try into impl

    and adapt existing adapters to just use the try into.
    
    This make far more simple to switch between the message and the concrete
    type, we don't need to define an adapter anymore (are the adapters
    really usefull ?).
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    fde7d2f View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    e4845f8 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    0e9a653 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    46a658c View commit details
    Browse the repository at this point in the history
  17. Split snapshot downloading responsability appart from the aggregator …

    …client
    
    It was strange that the aggregator client was handling the snapshot
    download since by design a snapshot can be downloaded using something
    else than http (ipfs, torrent, ...).
    This make easier to add new snapshot location type to the client.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    006fa94 View commit details
    Browse the repository at this point in the history
  18. Implement list for CertificateClient

    dlachaume authored and Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    87f73c9 View commit details
    Browse the repository at this point in the history
  19. Remove slog-scope from dependencies

    dlachaume authored and Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    985a87c View commit details
    Browse the repository at this point in the history
  20. Correcly handle Url::join behaviour with trailing slash

    The trailing slash is significant. Without it, the last path component is considered
    to be a “file” name to be removed.
    
    When `aggregator_url` is ending with a trailing slash (ex: https://whatever/aggregator/),
    the `Url::join` with the endpoint works fine => https://whatever/aggregator/endpoint
    
    In case there is no trailing slash in the `aggregator_url` (ex: https://whatever/aggregator),
    the `Url::join` with the endpoint remove the last part of the url => https://whatever/endpoint
    dlachaume authored and Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    adefecd View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    5baae8b View commit details
    Browse the repository at this point in the history
  22. Add basic feedback system

    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    2d75b34 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    0fb89b3 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    ed284cf View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    de325a4 View commit details
    Browse the repository at this point in the history
  26. Add complementary data in snapshot download events

    - `download_id`: a unique identifier (build using uuid::v4) to track
      individual download even with simultaneous downloads.
    - `size` to the 'progress' event: allow a completion percentage without
      the need to keep data in memory.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    743ef86 View commit details
    Browse the repository at this point in the history
  27. Use feedback system in certificate chain validation

    In order to do so the `verify_certificate_chain` method of the verifier
    could not be used since we can't known when an individual certificate is
    valid.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    2936258 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    e8ea932 View commit details
    Browse the repository at this point in the history
  29. Refactor Certificate verification so all traits are defined by the cl…

    …ient
    
    This allow to reduce the number of re-export of `mithril-common` needed
    since we can now use a `CerticateMessage` as our main certicate type
    instead of using the `mithril_common::entities::Certificate` full type.
    Meaning that we don't have to re-export crypto helpers or types anymore !
    
    To do so we define a new `CertificateVerifier` trait that only have a
    method that validate a chain and implement it with a new
    `MithrilCertificateVerifier` struct that use internally the verifier
    from `mithril-common`.
    As with the `InternalCertificateRetriever` this add some complexity to
    this specific part but the trade-off for it are worth it (as said
    before: no crypto type re-export leading to far less mithril-common
    dependency on the api level).
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    4320842 View commit details
    Browse the repository at this point in the history
  30. Remove unneeded common re-export and rework the those who are left

    Using `pub use` instead of `pub type` lead to a better rust-doc since
    the re-exported type are displayed as 'internal' type instead of alias.
    
    + Move all alias to a dedicated mod to cleanup the `lib.rs`.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    7e959cc View commit details
    Browse the repository at this point in the history
  31. Export content of the client & message submodules in the lib

    This simplify the import of those types that are likely the one that will
    be the most used by third parties.
    
    Co-authored-by: Damien Lachaume <dlachaumepalo@users.noreply.github.com>
    Alenar and Damien Lachaume committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    b50b344 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    1587b81 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    02727a7 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    40ee582 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    76597aa View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    717c97d View commit details
    Browse the repository at this point in the history
  37. Adjustements after review

    Fix typos and move `certificate().verify_chain` before
    `snapshot().download_unpack` in integration test, doc and example.
    dlachaume authored and Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    c04bd7a View commit details
    Browse the repository at this point in the history
  38. Fix rust doc url in developer docs and update missing replacements of…

    … 'mithril-client' to 'mithril-client-cli'
    dlachaume authored and Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    a82986f View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    636690e View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    0cfca39 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    7166920 View commit details
    Browse the repository at this point in the history
  42. Fix more PR review comments

     - Fix outdated `utils` module documentation.
     - Add more details on a hack comment.
     - rename `aggregator_url` to `aggregator_endpoint`.
     - rename `SnapshotDownloadComplete` mithril event to
      `SnapshotDownloadCompleted`.
     - Add a Todo on the verify chain to specify that we want
      to merge most of its code in the `mithril-common` codebase.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    0da1e2d View commit details
    Browse the repository at this point in the history
  43. Remove build-binary feature from mithril-client-cli

    Since the cli won't be used anymore to define the client library.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    dda5462 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    86d7577 View commit details
    Browse the repository at this point in the history
  45. Configuration menu
    Copy the full SHA
    1b450ab View commit details
    Browse the repository at this point in the history
  46. Fix PR review comments

    Typos in dev documentation and lib.rs
    dlachaume authored and Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    b5bdb83 View commit details
    Browse the repository at this point in the history
  47. Simplify mithril-client dependency to tokio

    Only use the features that we needs
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    89ef912 View commit details
    Browse the repository at this point in the history
  48. Update crates versions

    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    d35906f View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    53a0dc7 View commit details
    Browse the repository at this point in the history
  50. Upgrade nix flake dependencies

    By running 'nix flake update' command.
    Alenar committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    64150ca View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    3148bf4 View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    76347c5 View commit details
    Browse the repository at this point in the history