hyperledger / aries-vcx

aries-vcx is set of crates to work with DIDs, DID Documents, DIDComm, Verifiable Credentials and Hyperledger Aries.
https://didcomm.org
Apache License 2.0
125 stars 83 forks source link

Turn aries-vcx into consumable crate #196

Closed Patrik-Stas closed 2 years ago

Patrik-Stas commented 4 years ago

The problem

Currently there's no good way to consume aries-vcx from other Rust code.

Solution 1 - Aries-vcx as consumable crate

vcx_crate_architecture

Here I am proposing structuring aries-vcx into 4 layers. But that doesn't mean we should have them all exposed from the crate.

Steps to take:

  1. Rename api to api_c. Then api_c module to be more "pure", as currently it does more than handling FFI calls, more specifically it:

    • Some function are reading data from settings.rs, passing it down to further called functions (see vcx_schema_prepare_for_endorser for example).
    • Spawning work on threadpool.
    1. Create api_handle module. This will contain basically the logic and state shared across threads - currently in src/*rs files which take u32 object "handles" as input/output.

    2. Create api_comfort module. This should have similar API as api_handle however input/outputs should be typed with Rust structures. This layer will contain logic gluing together multiple structures / operations on top of them (for example updateState()). This layer should not have any state of its own.

    3. Create api_direct which would include:

      • Aries state machines
      • agency client
      • other operations (pool, wallet, ledger operations)

Pros:

Patrik-Stas commented 3 years ago

Updated architecture

vcx_crate_architecture_110621_2

This splits Rust portion of AriesVCX repo in 3 layers, 4 crates.

  1. C-Bindings crate
    • Rust project depending on the main AriesVCX crate, providing C ABI interface and memory management (providing references to in-memory vcx objects via u32 handles)
  2. AriesVCX crate
    • This is the definition "what AriesVCX" is. This will be our main artifact, directly consumable as crate in 3rd party Rust projects. This is layer where we glue up runtime dependencies (libindy), agency (downloading and updating agency-stored messages), networking (what client to use for network comm, dealing with SSL) and use AriesFSM Crate to deal with Aries protocols.
  3. AriesFSM Crate
    • Essentially codification of Aries RFCs, should be with almost no dependencies. It should be very simple, only reflect Aries protocol state machines, message types, transitions and transition inputs. Given the simplicity, this crate should be compilable to WASM and should serve as cornerstone of differently opinionated Aries implementations.
Patrik-Stas commented 3 years ago

Generally implemented, but before we close we should:

Patrik-Stas commented 3 years ago

Updated architecture diagram

ariesvcx_architecture_now_180821

Patrik-Stas commented 2 years ago

aries-vcx can now be considered consumable stateless aries crate which can simultaneously manage multiple wallets and multiple pool connections.

ariesvcx_architecture_now_150922