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