arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/README.md
README.mdRaw
  1# hermez-node [![Go Report Card](https://goreportcard.com/badge/github.com/hermeznetwork/hermez-node)](https://goreportcard.com/report/github.com/hermeznetwork/hermez-node) [![Test Status](https://github.com/hermeznetwork/hermez-node/workflows/Test/badge.svg)](https://github.com/hermeznetwork/hermez-node/actions?query=workflow%3ATest) [![Lint Status](https://github.com/hermeznetwork/hermez-node/workflows/Lint/badge.svg)](https://github.com/hermeznetwork/hermez-node/actions?query=workflow%3ALint) [![GoDoc](https://godoc.org/github.com/hermeznetwork/hermez-node?status.svg)](https://godoc.org/github.com/hermeznetwork/hermez-node)
  2
  3Go implementation of the Hermez node.
  4
  5## Developing
  6
  7### Go version
  8
  9The `hermez-node` has been tested with go version 1.14
 10
 11### Build
 12
 13Build the binary and check the current version:
 14
 15```shell
 16$ make build
 17$ bin/node version
 18```
 19
 20### Run
 21
 22First you must edit the default/template config file into [cli/node/cfg.buidler.toml](cli/node/cfg.buidler.toml), 
 23there are more information about the config file into [cli/node/README.md](cli/node/README.md)
 24
 25After setting the config, you can build and run the Hermez Node as a synchronizer:
 26
 27```shell
 28$ make run
 29```
 30
 31Or build and run as a coordinator, and also passing the config file from other location:
 32
 33```shell
 34$ MODE=sync CONFIG=cli/node/cfg.buidler.toml make run
 35```
 36
 37To check the useful make commands:
 38
 39```shell
 40$ make help
 41```
 42
 43### Unit testing
 44
 45Running the unit tests requires a connection to a PostgreSQL database.  You can
 46run PostgreSQL with docker easily this way (where `yourpasswordhere` should
 47be your password):
 48
 49```shell
 50$ POSTGRES_PASS="yourpasswordhere" make run-database-container
 51```
 52
 53Afterward, run the tests with the password as env var:
 54
 55```shell
 56$ POSTGRES_PASS="yourpasswordhere" make test
 57```
 58
 59NOTE: `-p 1` forces execution of package test in serial. Otherwise, they may be
 60executed in parallel, and the test may find unexpected entries in the SQL database
 61because it's shared among all tests.
 62
 63There is an extra temporary option that allows you to run the API server using the 
 64Go tests. It will be removed once the API can be properly initialized with data 
 65from the synchronizer. To use this, run:
 66
 67```shell
 68$ POSTGRES_PASS="yourpasswordhere" make test-api-server
 69```
 70
 71### Lint
 72
 73All Pull Requests need to pass the configured linter.
 74
 75To run the linter locally, first, install [golangci-lint](https://golangci-lint.run).  
 76Afterward, you can check the lints with this command:
 77
 78```shell
 79$ make gocilint
 80```
 81
 82## Usage
 83
 84### Node
 85
 86See [cli/node/README.md](cli/node/README.md)
 87
 88### Proof Server
 89
 90The node in mode coordinator requires a proof server (a server capable of 
 91calculating proofs from the zkInputs). There is a mock proof server CLI 
 92at `test/proofserver/cli` for testing purposes.
 93
 94Usage of `test/proofserver/cli`:
 95
 96```shell
 97USAGE:
 98    go run ./test/proofserver/cli OPTIONS
 99
100OPTIONS:
101  -a string
102        listen address (default "localhost:3000")
103  -d duration
104        proving time duration (default 2s)
105```
106
107Also, the Makefile commands can be used to run and stop the proof server 
108in the background:
109
110```shell
111$ make run-proof-mock
112$ make stop-proof-mock
113```
114
115### `/tmp` as tmpfs
116
117For every processed batch, the node builds a temporary exit tree in a key-value
118DB stored in `/tmp`.  It is highly recommended that `/tmp` is mounted as a RAM
119file system in production to avoid unnecessary reads a writes to disk.  This
120can be done by mounting `/tmp` as tmpfs; for example, by having this line in
121`/etc/fstab`:
122```
123tmpfs			/tmp		tmpfs		defaults,noatime,mode=1777	0 0
124```