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
.
# For debug builds:
cargo build && cd target/debug
# For release builds:
# cargo build --release && cd target/release
# Clean up data files
rm -rf *.json *.txt *.db
# 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
# 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.
./linera --wallet wallet.json 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 &
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
done
# Command line prefix for client calls
CLIENT=(./linera --storage rocksdb:linera.db --wallet wallet.json --max-pending-messages 10000)
${CLIENT[@]} query-validators
# Give some time for server startup
sleep 1
# 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 ../..