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