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.

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