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### Unit testing
12
13Running the unit tests requires a connection to a PostgreSQL database.  You can
14start PostgreSQL with docker easily this way (where `yourpasswordhere` should
15be your password):
16
17```
18POSTGRES_PASS=yourpasswordhere; sudo docker run --rm --name hermez-db-test -p 5432:5432 -e POSTGRES_DB=hermez -e POSTGRES_USER=hermez -e POSTGRES_PASSWORD="$POSTGRES_PASS" -d postgres
19```
20
21Afterwards, run the tests with the password as env var:
22
23```
24POSTGRES_PASS=yourpasswordhere go test -p 1 ./...
25```
26
27NOTE: `-p 1` forces execution of package test in serial.  Otherwise they may be
28executed in paralel and the test may find unexpected entries in the SQL databse
29because it's shared among all tests.
30
31There is an extra temporary option that allows you to run the API server using
32the Go tests. This will be removed once the API can be properly initialized,
33with data from the synchronizer and so on. To use this, run:
34
35```
36FAKE_SERVER=yes POSTGRES_PASS=yourpasswordhere go test -timeout 0  ./api -p 1 -count 1 -v`
37```
38
39### Lint
40
41All Pull Requests need to pass the configured linter.
42
43To run the linter locally, first install [golangci-lint](https://golangci-lint.run).  Afterwards you can check the lints with this command:
44
45```
46golangci-lint run --timeout=5m -E whitespace -E gosec -E gci -E misspell -E gomnd -E gofmt -E goimports -E golint --exclude-use-default=false --max-same-issues 0
47```
48
49## Usage
50
51### Node
52
53See [cli/node/README.md](cli/node/README.md)
54
55### Proof Server
56
57The node in mode coordinator requires a proof server (a server that is capable
58of calculating proofs from the zkInputs). For testing purposes there is a mock
59proof server cli at `test/proofserver/cli`.
60
61Usage of `test/proofserver/cli`:
62
63```
64USAGE:
65    go run ./test/proofserver/cli OPTIONS
66
67OPTIONS:
68  -a string
69        listen address (default "localhost:3000")
70  -d duration
71        proving time duration (default 2s)
72```
73
74### `/tmp` as tmpfs
75
76For every processed batch, the node builds a temporary exit tree in a key-value
77DB stored in `/tmp`.  It is highly recommended that `/tmp` is mounted as a RAM
78file system in production to avoid unecessary reads an writes to disk.  This
79can be done by mounting `/tmp` as tmpfs; for example, by having this line in
80`/etc/fstab`:
81```
82tmpfs			/tmp		tmpfs		defaults,noatime,mode=1777	0 0
83```