This repository is dedicated to developing the Linera protocol. For an overview of how the Linera protocol functions refer to the whitepaper.
The Linera protocol repository is broken down into the following crates and subdirectories: (from low-level to high-level in the dependency graph)
-
linera-base
Base definitions, including cryptography. -
linera-views
A library mapping complex data structures onto a key-value store. The corresponding procedural macros are implemented inlinera-view-derive
. -
linera-execution
Persistent data and the corresponding logics for runtime and execution of smart contracts / applications. -
linera-chain
Persistent data and the corresponding logics for chains of blocks, certificates, and cross-chain messaging. -
linera-storage
Defines the storage abstractions for the protocol on top oflinera-chain
. -
linera-core
The core Linera protocol, including client and server logic, node synchronization, etc. -
linera-rpc
Defines the data-type for RPC messages (currently all client<->proxy<->chain<->chain interactions), and track the corresponding data schemas. -
linera-service
Executable for clients (aka CLI wallets), proxy (aka validator frontend) and servers. -
linera-sdk
The library to develop Linera applications written in Rust for the Wasm virtual machine. -
examples
Examples of Linera applications written in Rust.
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 ../..