lachesis

package
v0.0.0-...-168a2c3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: MIT Imports: 14 Imported by: 0

README

PoS-Lachesis node

Package assembles functionality of network node and consensus into solid Lachesis-node.

Executables

cli/ - contains cli (only for fakenet now):

  • build: go build -o lachesis .;
  • for help use: ./lachesis -h;
  • run single node: ./lachesis start;
transfer example
  • Check the balance to ensure the node have something to transfer
./lachesis balance

outputs balance of the node.

balance of 0x70210aeeb6f7550d1a3f0e6e1bd41fc9b7c6122b5176ed7d7fe93847dac856cf == 1000000000
  • Transfer some amount to another node using transfer command
./lachesis transfer --amount=10000 --receiver=0xf2610eb8185d8120e0e71f0d5f1fc74e3b187646a6a0aee169ca242a6b599fc0

returns hex of the outgoing transaction

0xab92d4dff02c4dc9f52c298a6cef1e7b73c46215c2bb621d6decfe57c1c0af4b
  • Check the transaction status using info command and previous hex of the transfer
./lachesis info 0xab92d4dff02c4dc9f52c298a6cef1e7b73c46215c2bb621d6decfe57c1c0af4b

outputs transaction information and it's status

transfer 10000 from 0x70210aeeb6f7550d1a3f0e6e1bd41fc9b7c6122b5176ed7d7fe93847dac856cf to 0xf2610eb8185d8120e0e71f0d5f1fc74e3b187646a6a0aee169ca242a6b599fc0 confirmed
  • As soon as transaction status changed to confirmed this will result in the balance change of both nodes
./lachesis balance --peer 0xf2610eb8185d8120e0e71f0d5f1fc74e3b187646a6a0aee169ca242a6b599fc0

outputs the balance of the peer we've sent the money. Note that while transaction status is unconfirmed there won't be any changes in balance

balance of 0xf2610eb8185d8120e0e71f0d5f1fc74e3b187646a6a0aee169ca242a6b599fc0 == 10000

Docker

docker/ - contains scripts to try lachesis fakenet with Docker:

for common purpose:
  • build node docker image "pos-lachesis": make build;
  • run network of N nodes: n=N ./start.sh;
  • drop network: ./stop.sh;
for testing network failures:
  • build node docker image "pos-lachesis-blockade": make build blockade;
  • install blockade and add it to "$PATH": pip install blockade;
  • make blockade.yaml config: n=N ./blockade.sh;
  • test lachesis network with blockade commands;

Sentry

If you want to use Sentry, please use this link for setup your own copy.

Don't forget include --dsn key to ./docker/start.sh

Example: --dsn="http://64f6a4a7aaba4aa0a12fedd4d8f7aa61@localhost:9000/1"

where: --dsn="http://<sentry public key>@<sentry host>:<port>/<project id>"

tips

If you have an error about Sentry connection, check next steps:

  • docker-compose.yml should include SENTRY_SECRET_KEY which you should generate using link above.
environment:
  SENTRY_SECRET_KEY: !!!SECRET_KEY!!!
  • Try to use custom network for docker-compose.yml:
networks:
  custom_network:
    driver: bridge
    name: lachesis // The name should be the same as for `pos-lachesis` and as for Sentry containers
  • Don't forget add this network for each service:

Example:

worker:
  <<: *defaults
  command: run worker
  networks:
    custom_network:
  • If you have empty Client DSN links, add next line to config.yml:
system.url-prefix: http://<sentry host>:<port>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Net      *Net
	AppPort  int
	CtrlPort int
	Node     posnode.Config
}

Config of lachesis node. TODO: move ports to Net?

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns lachesis default config.

type Lachesis

type Lachesis struct {
	logger.Instance
	// contains filtered or unexported fields
}

Lachesis is a lachesis node implementation.

func New

func New(db *badger.DB, host string, key *common.PrivateKey, conf *Config, opts ...grpc.DialOption) *Lachesis

New makes lachesis node. It does not start any process.

func (*Lachesis) AddPeers

func (l *Lachesis) AddPeers(hosts ...string)

AddPeers suggests hosts for network discovery.

func (*Lachesis) AppListenAddr

func (l *Lachesis) AppListenAddr() string

AppListenAddr returns listen address for application connections.

func (*Lachesis) CtrlListenAddr

func (l *Lachesis) CtrlListenAddr() string

CtrlListenAddr returns listen address for control connections.

func (*Lachesis) Start

func (l *Lachesis) Start()

Start inits and starts whole lachesis node.

func (*Lachesis) Stop

func (l *Lachesis) Stop()

Stop stops whole lachesis node.

type Net

type Net struct {
	Name    string
	Genesis map[hash.Peer]uint64
}

Net describes lachesis net.

func FakeNet

func FakeNet(n int) (*Net, []*common.PrivateKey)

FakeNet generates fake net with n-nodes genesis.

func MainNet

func MainNet() *Net

MainNet returns builtin genesis keys of mainnet.

func TestNet

func TestNet() *Net

TestNet returns builtin genesis keys of testnet.

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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