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.

93 lines
3.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
  1. # node cli
  2. This is the main cli for the node
  3. ## Usage
  4. ```
  5. NAME:
  6. hermez-node - A new cli application
  7. USAGE:
  8. node [global options] command [command options] [arguments...]
  9. VERSION:
  10. 0.1.0-alpha
  11. COMMANDS:
  12. importkey Import ethereum private key
  13. genbjj Generate a new BabyJubJub key
  14. wipesql Wipe the SQL DB (HistoryDB and L2DB), leaving the DB in a clean state
  15. run Run the hermez-node in the indicated mode
  16. help, h Shows a list of commands or help for one command
  17. GLOBAL OPTIONS:
  18. --mode MODE Set node MODE (can be "sync" or "coord")
  19. --cfg FILE Node configuration FILE
  20. --help, -h show help (default: false)
  21. --version, -v print the version (default: false)
  22. ```
  23. The node has two main modes of running:
  24. - `sync`: Synchronizer mode. In this mode the node will only synchronize the
  25. state of the hermez smart contracts, mainly processing the transactions in
  26. the batches.
  27. - `coord`: Coordinator mode. In this mode, apart from doing all the
  28. synchronization work, the node will also act as a coordinator, accepting L2
  29. transactions in the pool, and trying to forge batches when the proper
  30. conditions arise.
  31. ## Configuration
  32. The node requires a single configuration file to run.
  33. You can find a testing working configuration example at
  34. [cfg.buidler.toml](./cfg.buidler.toml)
  35. To read the documentation of each configuration parameter, please check the
  36. `type Node` and `type Coordinator` at
  37. [config/config.go](../../config/config.go). All the sections that are prefixed
  38. with `Coordinator` are only used in coord mode, and don't need to be defined
  39. when running the coordinator in sync mode
  40. ### Notes
  41. - The private key corresponding to the parameter `Coordinator.ForgerAddress` needs to be imported in the ethereum keystore
  42. - The private key corresponding to the parameter `Coordinator.FeeAccount.Address` needs to be imported in the ethereum keystore
  43. - The public key corresponding to the parameter `Coordinator.FeeAccount.BJJ` can be generated with the command `genbjj`
  44. - There are two sets of debug parameters (`Debug` for all modes, and
  45. `Coordinator.Debug` for `coord` mode). Some of these parameters may not be
  46. suitable for production.
  47. - The parameter `Coordinator.Debug.BatchPath`, when set, causes the coordinator
  48. to store dumps of a lot of information related to batches in json files.
  49. This files can be around 2MB big. If this parameter is set, be careful to
  50. monitor the size of the folder to avoid running out of space.
  51. - The node requires a PostgreSQL database. The parameters of the server and
  52. database must be set in the `PostgreSQL` section.
  53. ## Usage Examples
  54. Run the node in mode synchronizer:
  55. ```
  56. go run . --mode sync --cfg cfg.buidler.toml run
  57. ```
  58. Run the node in mode coordinator:
  59. ```
  60. go run . --mode coord --cfg cfg.buidler.toml run
  61. ```
  62. Import an ethereum private key into the keystore:
  63. ```
  64. go run . --mode coord --cfg cfg.buidler.toml importkey --privatekey 0x618b35096c477aab18b11a752be619f0023a539bb02dd6c813477a6211916cde
  65. ```
  66. Generate a new BabyJubJub key pair:
  67. ```
  68. go run . --mode coord --cfg cfg.buidler.toml genbjj
  69. ```
  70. Wipe the entier SQL database (this will destroy all synchronized and pool data):
  71. ```
  72. go run . --mode coord --cfg cfg.buidler.toml wipesql
  73. ```