hermez-node

module
v1.3.1-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2021 License: AGPL-3.0

README

hermez-node Go Report Card Test Status Lint Status GoDoc

Go implementation of the Hermez node.

Developing

To contribute to this codebase you must follow the branch model and development flow.

Go version

The hermez-node has been tested with go version 1.14

Build

Build the binary and check the current version:

$ make
$ ./bin/heznode version
Run

First you must edit the default/template config file into cmd/heznode/cfg.buidler.toml, there are more information about the config file into cmd/heznode/README.md

After setting the config, you can build and run the Hermez Node as a synchronizer:

$ make run-node

Or build and run as a coordinator, and also passing the config file from other location:

$ MODE=sync CONFIG=cmd/heznode/cfg.buidler.toml make run-node

To check the useful make commands:

$ make help
Unit testing

Running the unit tests requires a connection to a PostgreSQL database. You can run PostgreSQL with docker easily this way:

$ make run-database-container

Afterward, run the tests:

$ make test

There is an extra temporary option that allows you to run the API server using the Go tests. It will be removed once the API can be properly initialized with data from the synchronizer. To use this, run:

$ make test-api-server

It is also possible to run the tests with an existing PostgreSQL server, e.g.

$ PGHOST=someserver PGUSER=hermez2 PGPASSWORD=secret make test
Lint

All Pull Requests need to pass the configured linter.

To run the linter locally, first, install golangci-lint.
Afterward, you can check the lints with this command:

$ make gocilint

Usage

Node

See cmd/heznode/README.md

Proof Server

The node in mode coordinator requires a proof server (a server capable of calculating proofs from the zkInputs). There is a mock proof server CLI at test/proofserver/cmd for testing purposes.

Usage of test/proofserver/cmd:

USAGE:
    go run ./test/proofserver/cmd OPTIONS

OPTIONS:
  -a string
        listen address (default "localhost:3000")
  -d duration
        proving time duration (default 2s)

Also, the Makefile commands can be used to run and stop the proof server in the background:

$ make run-proof-mock
$ make stop-proof-mock
/tmp as tmpfs

For every processed batch, the node builds a temporary exit tree in a key-value DB stored in /tmp. It is highly recommended that /tmp is mounted as a RAM file system in production to avoid unnecessary reads a writes to disk. This can be done by mounting /tmp as tmpfs; for example, by having this line in /etc/fstab:

tmpfs			/tmp		tmpfs		defaults,noatime,mode=1777	0 0

Directories

Path Synopsis
api
Package api implements the public interface of the hermez-node using a HTTP REST API.
Package api implements the public interface of the hermez-node using a HTTP REST API.
apitypes
Package apitypes is used to map the common types used across the node with the format expected by the API.
Package apitypes is used to map the common types used across the node with the format expected by the API.
stateapiupdater
Package stateapiupdater is responsible for generating and storing the object response of the GET /state endpoint exposed through the api package.
Package stateapiupdater is responsible for generating and storing the object response of the GET /state endpoint exposed through the api package.
cmd
Package common float40.go provides methods to work with Hermez custom half float precision, 40 bits, codification internally called Float40 has been adopted to encode large integers.
Package common float40.go provides methods to work with Hermez custom half float precision, 40 bits, codification internally called Float40 has been adopted to encode large integers.
Package coordinator handles all the logic related to forging batches as a coordinator in the hermez network.
Package coordinator handles all the logic related to forging batches as a coordinator in the hermez network.
db
Package db have some common utilities shared by db/l2db and db/historydb, the most relevant ones are: - SQL connection utilities - Managing the SQL schema: this is done using migration files placed under db/migrations.
Package db have some common utilities shared by db/l2db and db/historydb, the most relevant ones are: - SQL connection utilities - Managing the SQL schema: this is done using migration files placed under db/migrations.
historydb
Package historydb is responsible for storing and retrieving the historic data of the Hermez network.
Package historydb is responsible for storing and retrieving the historic data of the Hermez network.
kvdb
Package kvdb provides a key-value database with Checkpoints & Resets system
Package kvdb provides a key-value database with Checkpoints & Resets system
l2db
Package l2db is responsible for storing and retrieving the data received by the coordinator through the api.
Package l2db is responsible for storing and retrieving the data received by the coordinator through the api.
eth
health
Package node does the initialization of all the required objects to either run as a synchronizer or as a coordinator.
Package node does the initialization of all the required objects to either run as a synchronizer or as a coordinator.
Package synchronizer synchronizes the hermez network state by querying events emitted by the three smart contracts: `Hermez.sol` (referred as Rollup here), `HermezAuctionProtocol.sol` (referred as Auction here) and `WithdrawalDelayer.sol` (referred as WDelayer here).
Package synchronizer synchronizes the hermez network state by querying events emitted by the three smart contracts: `Hermez.sol` (referred as Rollup here), `HermezAuctionProtocol.sol` (referred as Auction here) and `WithdrawalDelayer.sol` (referred as WDelayer here).
til
txsets
Package txsets contains Til sets of transactions & Transactions generation that are used at tests of other packages of hermez-node
Package txsets contains Til sets of transactions & Transactions generation that are used at tests of other packages of hermez-node
Package txprocessor is the module that takes the transactions from the input and processes them, updating the Balances and Nonces of the Accounts in the StateDB.
Package txprocessor is the module that takes the transactions from the input and processes them, updating the Balances and Nonces of the Accounts in the StateDB.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL