1 unstable release

0.1.0 May 25, 2022

#1212 in Procedural macros

Custom license

14KB
314 lines

many-rs

ci coverage license

A collection of applications and libraries for the MANY protocol.

Features

  • A ledger client/server
  • A key-value store client/server
  • An application blockchain interface (ABCI)
  • A http proxy
  • A 4-nodes end-to-end Docker demo
  • MANY module interfaces
  • MANY common types
  • MANY message and transport layers
  • MANY client and server
  • Hardware Security Module
  • CLI developer's tools

Requirements

Build

  1. Install build dependencies
    # Ubuntu/Debian
    $ sudo apt update && sudo apt install build-essential clang libssl-dev libsofthsm2 libudev-dev 
        libusb-1.0-0-dev bsdextrautils
    
    # macOS
    $ brew update
    $ brew install git bazelisk
    
  2. Build
    $ git clone https://github.com/liftedinit/many-rs.git
    $ cd many-rs
    $ bazel build //...
    
  3. Tests
    # Unit/integration tests
    $ bazel test //...
    
    # E2E integration tests
    $ bazel test --config=all-features //tests/e2e/kvstore:bats-e2e-kvstore
    $ bazel test --config=all-features //tests/e2e/ledger:bats-e2e-ledger
    $ bazel test --balance_testing --migration_testing --config=remote-cache //tests/e2e/ledger:bats-e2e-ledger-tokens
    
    # Resiliency integration tests (Linux only - requires Docker)
    $ bazel test //tests/resiliency/kvstore:bats-resiliency-kvstore 
    $ bazel test --config=bats-resiliency-ledger //tests/resiliency/ledger:bats-resiliency-ledger
    

Usage example

Below are some examples of how to use the different CLI.

Ledger cluster

# Create a 4-nodes Ledger cluster. Requires local Docker. Linux only
$ bazel run //:start-ledger-cluster

# Create a 4-nodes Ledger cluster in the background
$ bazel run //:start-ledger-cluster-detached

# Stop the ledger cluster
$ bazel run //:stop-ledger-cluster 

Balance

# Query the local ledger cluster
$ bazel run //src/ledger -- --pem $(pwd)/keys/id1.pem balance
  1000000000 MFX (mqbfbahksdwaqeenayy2gxke32hgb7aq4ao4wt745lsfs6wiaaaaqnz)

Send tokens

# Send tokens from id1.pem to id2.pem
$ bazel run //src/ledger -- --pem $(pwd)/keys/id1.pem send mahukzwuwgt3porn6q4vq4xu3mwy5gyskhouryzbscq7wb2iow 10000 MFX
2023-03-13T19:07:20.120255Z  INFO ledger: Async token: a560d5409a18ae493ce457bb4008da0afc3d383c2a505979a963c26398f51fc9
  Waiting for async response
null

# Check the balance of the new ID
$ bazel run //src/ledger -- --pem $(pwd)/keys/id2.pem balance
       10000 MFX (mqbfbahksdwaqeenayy2gxke32hgb7aq4ao4wt745lsfs6wiaaaaqnz)

Print the MANY ID of a key file

$ bazel run //src/many -- id $(pwd)/keys/id1.pem
maffbahksdwaqeenayy2gxke32hgb7aq4ao4wt745lsfs6wijp

Retrieve the status of a running MANY server

$ bazel run //src/many -- message --server https://alberto.app/api 'status' '{}'
{_
    0: 1,
    1: "AbciModule(many-ledger)",
    2: h'a5010103270481022006215820e5cd546d5292af5d9f0ffd54b57ff555c51b91a249b9cf544010a3c01cfa75a2',
    3: 10000_1(h'01378dd9916915fb276116ff4bc13c04a4e413f663e04b710199c46021'),
    4: [0, 1, 2, 4, 6, 8, 9, 1002_1],
    5: "0.1.0",
    7: 300_1,
}

Developers

Contributing

Read our Contributing Guidelines

Crates

Here's a list of crates published by this repository and their purposes. You can visit their crates entries (linked below) for more information.

Published to crates.io

  • many(crates, docs) – Contains the CLI tool to contact and diagnose MANY servers.
  • many-client(crates, docs) – Types and methods to talk to the MANY network.
  • many-client-macros(crates, docs) – many-client procedural macro
  • many-cli-helpers(crate, docs)) – Common CLI flags
  • many-error(crates, docs) – Error and Reason types, as defined by the specification.
  • many-identity(crates, docs) – Types for managing an identity, its address and traits related to signing/verification of messages.
  • many-identity-dsa(crates, docs) – Digital Signature identity, verifiers and utility functions. This crate has features for all supported algorithms (e.g. ed25519).
  • many-identity-hsm(crates, docs) – Hardware Security Module based identity, verifiers and utility functions.
  • many-identity-webauthn(crates, docs) – Verifiers for WebAuthn signed envelopes. This uses our custom WebAuthn format, which is not fully compliant with the WebAuthn standard. See the Lifted WebAuthn Auth Paper.
  • many-macros(crates, docs) – Contains macros to help with server and module declaration and implementations.
  • many-migration(crates, docs) – Storage/Transaction migration framework.
  • many-mock(crates, docs) – Utility types for creating mocked MANY servers.
  • many-modules(crates, docs) – All modules declared in the specification.
  • many-protocol(crates, docs) – Types exclusively associated with the protocol. This does not include types that are related to attributes or modules.
  • many-server(crates, docs) – Types and methods to create a MANY network server and neighborhood.
  • many-types(crates, docs) – General types related to CBOR encoding, or to the specification.

Using Bazel

Remote cache

# Use BuildBuddy remote cache
$ bazel build --config=remote-cache //...

Code formatting

# Check code formatting
$ bazel build --config=rustfmt-check //...

# Apply format changes using
$ bazel run @rules_rust//:rustfmt

Lint

# Clippy
$ bazel build --config=clippy //...

Generating new keys

ECDSA

$ ssh-keygen -a 100 -q -P "" -m pkcs8 -t ecdsa -f key_name.pem

Ed25519

# Requires openssl@3 on macOS
$ openssl genpkey -algorithm Ed25519 -out key_name.pem

References

  • Concise Binary Object Representation (CBOR): RFC 8949
  • CBOR Object Signing and Encryption (COSE): RFC 8152
  • Platform-independent API to cryptographic tokens: PKCS #11
  • Blockchain application platform: Tendermint
  • Persistent key-value store: RocksDB
  • Concise Binary Object Representation (CBOR): RFC 8949
  • CBOR Object Signing and Encryption (COSE): RFC 8152
  • Platform-independent API to cryptographic tokens: PKCS #11

Tools

Dependencies

~1.3–1.7MB
~41K SLoC