Giter Club home page Giter Club logo

linera-protocol's Introduction

License Build Status for Rust Build Status for Documentation Build Status for DynamoDB

Linera

This repository is dedicated to developing the Linera protocol. For an overview of how the Linera protocol functions refer to the whitepaper.

Repository Structure

The Linera protocol repository is broken down into the following crates and subdirectories: (from low-level to high-level in the dependency graph)

  1. linera-base Base definitions, including cryptography.

  2. linera-views A library mapping complex data structures onto a key-value store. The corresponding procedural macros are implemented in linera-view-derive.

  3. linera-execution Persistent data and the corresponding logics for runtime and execution of smart contracts / applications.

  4. linera-chain Persistent data and the corresponding logics for chains of blocks, certificates, and cross-chain messaging.

  5. linera-storage Defines the storage abstractions for the protocol on top of linera-chain.

  6. linera-core The core Linera protocol, including client and server logic, node synchronization, etc.

  7. linera-rpc Defines the data-type for RPC messages (currently all client<->proxy<->chain<->chain interactions), and track the corresponding data schemas.

  8. linera-service Executable for clients (aka CLI wallets), proxy (aka validator frontend) and servers.

  9. linera-sdk The library to develop Linera applications written in Rust for the Wasm virtual machine.

  10. examples Examples of Linera applications written in Rust.

Quickstart with the Linera service CLI

The following script can be run with cargo test.

storage="ROCKSDB"

if [ $# -eq 1 ]
then
    if [ "$1" == 'DYNAMODB' ]
    then
        storage="DYNAMODB"
    fi
    if [ "$1" == 'SCYLLADB' ]
    then
        storage="SCYLLADB"
    fi
fi

# For debug builds:
if [ "$storage" = "ROCKSDB" ]
then
    cargo build && cd target/debug
elif [ "$storage" = "DYNAMODB" ]
then
    cargo build --features aws && cd target/debug
elif [ "$storage" = "SCYLLADB" ]
then
    cargo build --features scylladb && cd target/debug
fi

# For release builds:
# cargo build --release && cd target/release

# Clean up data files
rm -rf *.json *.txt *.db
rm -rf linera.db
if [ "$storage" = "ROCKSDB" ]
then
    rm -rf server_?_?.db
elif [ "$storage" = "DYNAMODB" ]
then
    ./linera-db delete_all --storage dynamodb:table:localstack
elif [ "$storage" = "SCYLLADB" ]
then
    ./linera-db delete_all --storage scylladb:
fi




# Make sure to clean up child processes on exit.
trap 'kill $(jobs -p)' EXIT

# Create configuration files for 4 validators with 4 shards each.
# * Private server states are stored in `server*.json`.
# * `committee.json` is the public description of the Linera committee.
./linera-server generate --validators ../../configuration/local/validator_{1,2,3,4}.toml --committee committee.json

# Command line prefix for client calls
CLIENT=(./linera --storage rocksdb:linera.db --wallet wallet.json --max-pending-messages 10000)

# Create configuration files for 10 user chains.
# * Private chain states are stored in one local wallet `wallet.json`.
# * `genesis.json` will contain the initial balances of chains as well as the initial committee.
${CLIENT[@]} create-genesis-config 10 --genesis genesis.json --initial-funding 10 --committee committee.json

# Start servers and create initial chains in DB
for I in 1 2 3 4
do
    ./linera-proxy server_"$I".json &
    if [ "$storage" = "ROCKSDB" ]
    then
        for J in $(seq 0 3)
        do
            ./linera-server initialize --storage rocksdb:server_"$I"_"$J".db --genesis genesis.json
        done
        for J in $(seq 0 3)
        do
            ./linera-server run --storage rocksdb:server_"$I"_"$J".db --server server_"$I".json --shard "$J" --genesis genesis.json &
        done
    elif [ "$storage" = "DYNAMODB" ]
    then
        ./linera-server initialize --storage dynamodb:server-"$I":localstack --genesis genesis.json
        for J in $(seq 0 3)
        do
            ./linera-server run --storage dynamodb:server-"$I":localstack --server server_"$I".json --shard "$J" --genesis genesis.json &
        done
    elif [ "$storage" = "SCYLLADB" ]
    then
        ./linera-server initialize --storage scylladb:table_server_"$I" --genesis genesis.json
        for J in $(seq 0 3)
        do
            ./linera-server run --storage scylladb:table_server_"$I" --server server_"$I".json --shard "$J" --genesis genesis.json &
        done
    fi
done

${CLIENT[@]} query-validators

# Give some time for server startup
sleep 5

# Query balance for first and last user chain, root chains 0 and 9
CHAIN1="e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65"
CHAIN2="256e1dbc00482ddd619c293cc0df94d366afe7980022bb22d99e33036fd465dd"
${CLIENT[@]} query-balance "$CHAIN1"
${CLIENT[@]} query-balance "$CHAIN2"

# Transfer 10 units then 5 back
${CLIENT[@]} transfer 10 --from "$CHAIN1" --to "$CHAIN2"
${CLIENT[@]} transfer 5 --from "$CHAIN2" --to "$CHAIN1"

# Query balances again
${CLIENT[@]} query-balance "$CHAIN1"
${CLIENT[@]} query-balance "$CHAIN2"

cd ../..

linera-protocol's People

Contributors

jvff avatar ma2bd avatar afck avatar christos-h avatar mathieudutsik avatar andresilva91 avatar maxtori avatar firedpeanut avatar harnen avatar laurentmazare avatar ashu26jha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.