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.

124 lines
3.5 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
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. ### Build
  7. Build the binary and check the current version:
  8. ```shell
  9. $ make build
  10. $ bin/node version
  11. ```
  12. ### Run
  13. First you must edit the default/template config file into [cli/node/cfg.buidler.toml](cli/node/cfg.buidler.toml),
  14. there are more information about the config file into [cli/node/README.md](cli/node/README.md)
  15. After setting the config, you can build and run the Hermez Node as a synchronizer:
  16. ```shell
  17. $ make run
  18. ```
  19. Or build and run as a coordinator, and also passing the config file from other location:
  20. ```shell
  21. $ MODE=sync CONFIG=cli/node/cfg.buidler.toml make run
  22. ```
  23. To check the useful make commands:
  24. ```shell
  25. $ make help
  26. ```
  27. ### Unit testing
  28. Running the unit tests requires a connection to a PostgreSQL database. You can
  29. run PostgreSQL with docker easily this way (where `yourpasswordhere` should
  30. be your password):
  31. ```shell
  32. $ POSTGRES_PASS="yourpasswordhere" make run-database-container
  33. ```
  34. Afterward, run the tests with the password as env var:
  35. ```shell
  36. $ POSTGRES_PASS="yourpasswordhere" make test
  37. ```
  38. NOTE: `-p 1` forces execution of package test in serial. Otherwise, they may be
  39. executed in parallel, and the test may find unexpected entries in the SQL database
  40. because it's shared among all tests.
  41. There is an extra temporary option that allows you to run the API server using the
  42. Go tests. It will be removed once the API can be properly initialized with data
  43. from the synchronizer. To use this, run:
  44. ```shell
  45. $ POSTGRES_PASS="yourpasswordhere" make test-api-server
  46. ```
  47. ### Lint
  48. All Pull Requests need to pass the configured linter.
  49. To run the linter locally, first, install [golangci-lint](https://golangci-lint.run).
  50. Afterward, you can check the lints with this command:
  51. ```shell
  52. $ make gocilint
  53. ```
  54. ## Usage
  55. ### Node
  56. See [cli/node/README.md](cli/node/README.md)
  57. ### Proof Server
  58. The node in mode coordinator requires a proof server (a server capable of
  59. calculating proofs from the zkInputs). There is a mock proof server CLI
  60. at `test/proofserver/cli` for testing purposes.
  61. Usage of `test/proofserver/cli`:
  62. ```shell
  63. USAGE:
  64. go run ./test/proofserver/cli OPTIONS
  65. OPTIONS:
  66. -a string
  67. listen address (default "localhost:3000")
  68. -d duration
  69. proving time duration (default 2s)
  70. ```
  71. Also, the Makefile commands can be used to run and stop the proof server
  72. in the background:
  73. ```shell
  74. $ make run-proof-mock
  75. $ make stop-proof-mock
  76. ```
  77. ### `/tmp` as tmpfs
  78. For every processed batch, the node builds a temporary exit tree in a key-value
  79. DB stored in `/tmp`. It is highly recommended that `/tmp` is mounted as a RAM
  80. file system in production to avoid unnecessary reads a writes to disk. This
  81. can be done by mounting `/tmp` as tmpfs; for example, by having this line in
  82. `/etc/fstab`:
  83. ```
  84. tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
  85. ```