liftedinit / many-rs

Rust libraries for the Many Protocol
Apache License 2.0
5 stars 11 forks source link
cli decentralized distributed library many-protocol web2 web3

many-rs

ci coverage license

A collection of applications and libraries for the MANY protocol.

Features

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 --config=all-features //...
    
    # 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=all-features //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

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

Tools