truchain

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2019 License: Apache-2.0

README

TruChain

CircleCI codecov

TruChain is an application-specific blockchain built with Cosmos SDK. It powers trustory.io.

Installation

  1. Install Go by following the official docs.

Go version must be 1.13.

  1. Now let's install truchain.
mkdir -p github.com/TruStory
cd TruStory
git clone https://github.com/TruStory/truchain.git
cd truchain && git checkout master

Getting Started

Download dependencies
make download
Install
make install

This creates:

truchaind: TruStory blockchain daemon

truchaincli: TruStory blockchain client. Used for creating keys and lightweight interaction with the chain and underlying Tendermint node.

Run a single node

TruChain currently needs a registrar account to sign new user registration messages.

# Add a new key named registrar
make registrar

# Initialize configuration files and genesis file
make init

# Start the chain
make start

Run a local 4-node testnet

A 4-node local testnet can be created with Docker Compose.

NOTE: You will not be able to register accounts because each node won't have a registrar key setup. This restriction will go away after client-side signing.

# Build daemon for linux so it can run inside a Docker container
make build-linux

# Create 4-nodes with their own genesis files and configuration
make localnet-start

The config.toml files generated by the above command isn't exactly right due to bugs in Tendermint. Go to each config file in build/nodeN/truchaind/config/config.toml and replace these:

laddr = "tcp://0.0.0.0:26657"
addr_book_strict = false
# stop and restart
make localnet-stop && make localnet-start

# Tail logs
docker-compose logs -f

Run a full node on another machine

TruChain can be run as a full node, syncing it's state with another node. First follow the instructions above to install and setup a single node.

# Initialize another chain with a new moniker but same chain-id
truchaind init <moniker-2> --chain-id betanet-1 --home ~/.devnet

# Copy the genesis file from the first node
scp ubuntu@devnet:/home/ubuntu/.truchaind/config/genesis.json ~/.devnet/config/

# Get the node id of the first node
truchaincli status

# Add first node to `persistent_peers` in config.toml
sed -i -e 's/persistent_peers.*/persistent_peers = "3ebaf6ae8000af5e233ce2d3158776f7245e5ae0@ec2-54-183-49-244.us-west-1.compute.amazonaws.com:26656"/' ~/.devnet/config/config.toml

# Optional: Add verbose logging
sed -i -e 's/log_level.*/log_level = "main:info,state:info,*:error,app:info,account:info,trubank2:info,claim:info,community:info,truslashing:info,trustaking:info"/' ~/.devnet/config/config.toml

# Start the second node
truchaind start --home ~/.devnet

If the first node has many blocks, it could take several minutes for the first sync to complete. Now you will have two nodes running in lockstep!

Testing

# Run linter
make check

# Run tests
make test

API Documentation

# Generate a website with documentation
make doc

Upgrades

To migrate between different genesis schemas, use the python script in contrib/migration.

python 2-stories-to-claims.py \
    --exported-genesis exported-genesis.json \
    --chain-id betanet-1 > genesis.json 

Directories

Path Synopsis
cmd
x

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL