You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.0 KiB

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