config

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

README

Configuration

This is an example of the env variable equivalations and the toml file:

[API]
Address = HEZNODE_API_ADDRESS
Explorer = HEZNODE_API_EXPLORER
UpdateMetricsInterval = HEZNODE_API_UPDATEMETRICSINTERVAL
UpdateRecommendedFeeInterval = HEZNODE_API_UPDATERECOMMENDEDFEEINTERVAL
MaxSQLConnections = HEZNODE_API_MAXSQLCONNECTIONS
SQLConnectionTimeout = HEZNODE_API_SQLCONNECTIONTIMEOUT

[Debug]
APIAddress = HEZNODE_DEBUG_APIADDRESS
MeddlerLogs = HEZNODE_DEBUG_MEDDLERLOGS
GinDebugMode = HEZNODE_DEBUG_GINDEBUGMODE

[StateDB]
Path = HEZNODE_STATEDB_PATH
Keep = HEZNODE_STATEDB_KEEP

[PostgreSQL]
PortWrite     = HEZNODE_POSTGRESQL_PORTWRITE
HostWrite     = HEZNODE_POSTGRESQL_HOSTWRITE
UserWrite     = HEZNODE_POSTGRESQL_USERWRITE
PasswordWrite = HEZNODE_POSTGRESQL_PASSWORDWRITE
NameWrite     = HEZNODE_POSTGRESQL_NAMEWRITE
PortRead     = HEZNODE_POSTGRESQL_PORTREAD
HostRead     = HEZNODE_POSTGRESQL_HOSTREAD
UserRead     = HEZNODE_POSTGRESQL_USERREAD
PasswordRead = HEZNODE_POSTGRESQL_PASSWORDREAD
NameRead     = HEZNODE_POSTGRESQL_NAMEREAD

[Web3]
URL = HEZNODE_WEB3_URL

[Synchronizer]
SyncLoopInterval = HEZNODE_SYNCHRONIZER_SYNCLOOPINTERVAL
StatsUpdateBlockNumDiffThreshold = HEZNODE_SYNCHRONIZER_STATSUPDATEBLOCKSNUMDIFFTHRESHOLD
StatsUpdateFrequencyDivider = HEZNODE_SYNCHRONIZER_STATSUPDATEFREQUENCYDIVIDER

[SmartContracts]
Rollup   = HEZNODE_SMARTCONTRACTS_ROLLUP

[Coordinator]
ForgerAddress = HEZNODE_COORDINATOR_FORGERADDRESS
MinimumForgeAddressBalance = HEZNODE_COORDINATOR_MINIMUMFORGEADDRESSBALANCE
ConfirmBlocks = HEZNODE_COORDINATOR_CONFIRMBLOCKS
L1BatchTimeoutPerc = HEZNODE_COORDINATOR_L1BATCHTIMEOUTPERC
StartSlotBlocksDelay = HEZNODE_COORDINATOR_STARTSLOTBLOCKSDELAY
ScheduleBatchBlocksAheadCheck = HEZNODE_COORDINATOR_SCHEDULEBATCHBLOCKSAHEADCHECK
SendBatchBlocksMarginCheck = HEZNODE_COORDINATOR_SENDBATCHBLOCKSMARGINCHECK
ProofServerPollInterval = HEZNODE_COORDINATOR_PROOFSERVERPOLLINTERVAL
ForgeRetryInterval = HEZNODE_COORDINATOR_FORGERETRYINTERVAL
SyncRetryInterval = HEZNODE_COORDINATOR_SYNCRETRYINTERVAL
ForgeDelay = HEZNODE_COORDINATOR_FORGEDELAY
ForgeNoTxsDelay = HEZNODE_COORDINATOR_FORGENOTXSDELAY
PurgeByExtDelInterval = HEZNODE_COORDINATOR_PURGEBYEXTDELINTERVAL
MustForgeAtSlotDeadline = HEZNODE_COORDINATOR_MUSTFORGEATSLOTDEADLINE
IgnoreSlotCommitment = HEZNODE_COORDINATOR_IGNORESLOTCOMMITMENT

[Coordinator.FeeAccount]
Address = HEZNODE_FEEACCOUNT_ADDRESS
BJJ = HEZNODE_FEEACCOUNT_BJJ


[Coordinator.L2DB]
SafetyPeriod = HEZNODE_L2DB_SAFETYPERIOD
MaxTxs       = HEZNODE_L2DB_MAXTXS
MinFeeUSD    = HEZNODE_L2DB_MINFEEUSD
MaxFeeUSD    = HEZNODE_L2DB_MAXFEEUSD
TTL          = HEZNODE_L2DB_TTL
PurgeBatchDelay = HEZNODE_L2DB_PURGEBATCHDELAY
InvalidateBatchDelay = HEZNODE_L2DB_INVALIDATEBATCHDELAY
PurgeBlockDelay = HEZNODE_L2DB_PURGEBLOCKDELAY
InvalidateBlockDelay = HEZNODE_L2DB_INVALIDATEBLOCKDELAY

[Coordinator.TxSelector]
Path = HEZNODE_TXSELECTOR_PATH

[Coordinator.BatchBuilder]
Path = HEZNODE_BATCHBUILDER_PATH

[Coordinator.ServerProofs]
URLs = HEZNODE_SERVERPROOF_URLS

[Coordinator.Circuit]
MaxTx = HEZNODE_CIRCUIT_MAXTX
NLevels = HEZNODE_CIRCUIT_NLEVELS

[Coordinator.EthClient]
CheckLoopInterval = HEZNODE_ETHCLIENT_CHECKLOOPINTERVAL
Attempts = HEZNODE_ETHCLIENT_ATTEMPTS
AttemptsDelay = HEZNODE_ETHCLIENT_ATTEMPTSDELAY
TxResendTimeout = HEZNODE_ETHCLIENT_TXRESENDTIMEOUT
NoReuseNonce = HEZNODE_ETHCLIENT_NOREUSENONCE
MaxGasPrice = HEZNODE_ETHCLIENT_MAXGASPRICE
MinGasPrice = HEZNODE_ETHCLIENT_MINGASPRICE
GasPriceIncPerc = HEZNODE_ETHCLIENT_GASPRICEINCPERC

[Coordinator.EthClient.Keystore]
Path = HEZNODE_KEYSTORE_PATH
Password = HEZNODE_KEYSTORE_PASSWORD

[Coordinator.EthClient.ForgeBatchGasCost]
Fixed = HEZNODE_FORGEBATCHGASCOST_FIXED
L1UserTx = HEZNODE_FORGEBATCHGASCOST_L1USERTX
L1CoordTx = HEZNODE_FORGEBATCHGASCOST_L1COORDTX
L2Tx = HEZNODE_FORGEBATCHGASCOST_L2TX

[Coordinator.API]
Coordinator = HEZNODE_COORDINATORAPI_COORDINATOR

[Coordinator.Debug]
BatchPath = HEZNODE_COORDINATORDEBUG_BATCHPATH
LightScrypt = HEZNODE_COORDINATORDEBUG_LIGHTSCRYPT

[Coordinator.Etherscan]
URL = HEZNODE_ETHERSCAN_URL
APIKey = HEZNODE_ETHERSCAN_APIKEY

[RecommendedFeePolicy]
PolicyType = HEZNODE_RECOMMENDEDFEEPOLICY_POLICYTYPE
StaticValue = HEZNODE_RECOMMENDEDFEEPOLICY_STATICVALUE

Table:

Section Parameter Name Env name Required/Optional Default value Description
API Address HEZNODE_API_ADDRESS Optional "0.0.0.0:9086" Url and port where the API will listen
API Explorer HEZNODE_API_EXPLORER Optional true Enables the Explorer API endpoints
API UpdateMetricsInterval HEZNODE_API_UPDATEMETRICSINTERVAL Optional "10s" Interval between updates of the API metrics
API UpdateRecommendedFeeInterval HEZNODE_API_UPDATERECOMMENDEDFEEINTERVAL Optional "10s" Interval between updates of the recommended fees
API MaxSQLConnections HEZNODE_API_MAXSQLCONNECTIONS Optional 100 Maximum concurrent connections allowed between API and SQL
API SQLConnectionTimeout HEZNODE_API_SQLCONNECTIONTIMEOUT Optional "2s" Maximum amount of time that an API request can wait to establish a SQL connection
Debug APIAddress HEZNODE_DEBUG_APIADDRESS Optional "0.0.0.0:12345" If it is set, the debug api will listen in this address and port
Debug MeddlerLogs HEZNODE_DEBUG_MEDDLERLOGS Optional true Enables meddler debug mode, where unused columns and struct fields will be logged
Debug GinDebugMode HEZNODE_DEBUG_GINDEBUGMODE Optional false Sets the web framework Gin-Gonic to run in debug mode
StateDB Path HEZNODE_STATEDB_PATH Optional "/var/hermez/statedb" Path where the synchronizer StateDB is stored
StateDB Keep HEZNODE_STATEDB_KEEP Optional 256 Number of checkpoints to keep
PostgreSQL PortWrite HEZNODE_POSTGRESQL_PORTWRITE Required 5432 Port of the PostgreSQL write server
PostgreSQL HostWrite HEZNODE_POSTGRESQL_HOSTWRITE Required "localhost" Host of the PostgreSQL write server
PostgreSQL UserWrite HEZNODE_POSTGRESQL_USERWRITE Required "hermez" User of the PostgreSQL write server
PostgreSQL PasswordWrite HEZNODE_POSTGRESQL_PASSWORDWRITE Required "yourpasswordhere" Password of the PostgreSQL write server
PostgreSQL NameWrite HEZNODE_POSTGRESQL_NAMEWRITE Required "hermez" Name of the PostgreSQL write server database
PostgreSQL PortRead HEZNODE_POSTGRESQL_PORTREAD Optional 5432 Port of the PostgreSQL read server. If it is not set, the hermez node will use the postgresql write server configuration
PostgreSQL HostRead HEZNODE_POSTGRESQL_HOSTREAD Optional "localhost" Host of the PostgreSQL read server. If it is not set, the hermez node will use the postgresql write server configuration
PostgreSQL UserRead HEZNODE_POSTGRESQL_USERREAD Optional "hermez" User of the PostgreSQL read server. If it is not set, the hermez node will use the postgresql write server configuration
PostgreSQL PasswordRead HEZNODE_POSTGRESQL_PASSWORDREAD Optional "yourpasswordhere" Password of the PostgreSQL read server. If it is not set, the hermez node will use the postgresql write server configuration
PostgreSQL NameRead HEZNODE_POSTGRESQL_NAMEREAD Optional "hermez" Name of the PostgreSQL read server database. If it is not set, the hermez node will use the postgresql write server configuration
Web3 URL HEZNODE_WEB3_URL Required "http://localhost:8545" Url of the web3 ethereum-node RPC server. Only geth is officially supported
Synchronizer SyncLoopInterval HEZNODE_SYNCHRONIZER_SYNCLOOPINTERVAL Optional "1s" Interval between attempts to synchronize a new block from an ethereum node
Synchronizer StatsUpdateBlockNumDiffThreshold HEZNODE_SYNCHRONIZER_STATSUPDATEBLOCKSNUMDIFFTHRESHOLD Optional 100 Threshold of a number of Ethereum blocks left to synchronize, such that if there are more blocks to sync than the defined value synchronizer can aggressively skip calling UpdateEth to save network bandwidth and time. After reaching the threshold UpdateEth is called on each block. This value only affects the reported % of synchronization of blocks and batches, nothing else.
Synchronizer StatsUpdateFrequencyDivider HEZNODE_SYNCHRONIZER_STATSUPDATEFREQUENCYDIVIDER Optional 100 While having more blocks to sync than updateEthBlockNumThreshold, UpdateEth will be called once in a defined number of blocks. This value only affects the reported % of synchronization of blocks and batches, nothing else
SmartContracts Rollup HEZNODE_SMARTCONTRACTS_ROLLUP Required "0xA68D85dF56E733A06443306A095646317B5Fa633" Smart contract address of the rollup Hermez.sol
Coordinator ForgerAddress HEZNODE_COORDINATOR_FORGERADDRESS Required "0x05c23b938a85ab26A36E6314a0D02080E9ca6BeD" Ethereum address that the coordinator is using to forge batches
Coordinator MinimumForgeAddressBalance HEZNODE_COORDINATOR_MINIMUMFORGEADDRESSBALANCE Optional "0" Minimum balance the forger address needs to start the coordinator in wei. If It is set to 0, the coordinator will not check the balance
Coordinator ConfirmBlocks HEZNODE_COORDINATOR_CONFIRMBLOCKS Optional 5 Number of confirmation blocks to be sure that the tx has been mined correctly
Coordinator L1BatchTimeoutPerc HEZNODE_COORDINATOR_L1BATCHTIMEOUTPERC Optional 0.00001 Portion of the range before the L1Batch timeout that will trigger a schedule to forge an L1Batch
Coordinator StartSlotBlocksDelay HEZNODE_COORDINATOR_STARTSLOTBLOCKSDELAY Optional 0 Number of delay blocks to wait before starting the pipeline when a slot in which the coordinator can forge is reached
Coordinator ScheduleBatchBlocksAheadCheck HEZNODE_COORDINATOR_SCHEDULEBATCHBLOCKSAHEADCHECK Optional 0 Number of blocks ahead used to decide when to stop scheduling new batches
Coordinator SendBatchBlocksMarginCheck HEZNODE_COORDINATOR_SENDBATCHBLOCKSMARGINCHECK Optional 0 Number of marging blocks used to decide when to stop sending batches to the smart contract
Coordinator ProofServerPollInterval HEZNODE_COORDINATOR_PROOFSERVERPOLLINTERVAL Optional "1s" Interval between calls to the ProofServer to check the status
Coordinator ForgeRetryInterval HEZNODE_COORDINATOR_FORGERETRYINTERVAL Optional "10s" Interval between forge retries after an error
Coordinator SyncRetryInterval HEZNODE_COORDINATOR_SYNCRETRYINTERVAL Optional "1s" Interval between calls to the main handler of a synced block after an error
Coordinator ForgeDelay HEZNODE_COORDINATOR_FORGEDELAY Optional "600s" Delay after which a batch is forged if the slot is already committed. If It is set to "0s", the coordinator will continuously forge at the maximum rate
Coordinator ForgeNoTxsDelay HEZNODE_COORDINATOR_FORGENOTXSDELAY Optional "86400s" Delay after a forged batch if there are no txs to forge. If It is set to 0s, the coordinator will continuously forge even if the batches are empty
Coordinator PurgeByExtDelInterval HEZNODE_COORDINATOR_PURGEBYEXTDELINTERVAL Optional "1m" Interval between calls to the PurgeByExternalDelete function of the l2db which deletes pending txs externally marked by the column external_delete
Coordinator MustForgeAtSlotDeadline HEZNODE_COORDINATOR_MUSTFORGEATSLOTDEADLINE Optional true Enables the coordinator to forge in slots if the empty slots reach the slot deadline.
Coordinator IgnoreSlotCommitment HEZNODE_COORDINATOR_IGNORESLOTCOMMITMENT Optional true It will make the coordinator forge at most one batch per slot, only if there are included txs in that batch, or pending l1UserTxs in the smart contract. Setting this parameter overrides ForgeDelay, ForgeNoTxsDelay, MustForgeAtSlotDeadline and IgnoreSlotCommitment.
Coordinator ForgeOncePerSlotIfTxs HEZNODE_COORDINATOR_FORGEONCEPERSLOTIFTXS Optional false This parameter will make the coordinator forge at most one batch per slot, only if there are included txs in that batch, or pending l1UserTxs in the smart contract. Setting this parameter overrides ForgeDelay, ForgeNoTxsDelay, MustForgeAtSlotDeadline and IgnoreSlotCommitment.
Coordinator.FeeAccount Address HEZNODE_FEEACCOUNT_ADDRESS Required "0x56232B1c5B10038125Bc7345664B4AFD745bcF8E" Ethereum address of the account that will receive the fees
Coordinator.FeeAccount BJJ HEZNODE_FEEACCOUNT_BJJ Required "0x130c5c7f294792559f469220274f3d3b2dca6e89f4c5ec88d3a08bf73262171b" BJJ is the baby jub jub public key of the account that will receive the fees
Coordinator.L2DB SafetyPeriod HEZNODE_L2DB_SAFETYPERIOD Optional 10 Number of batches after which non-pending L2Txs are deleted from the pool
Coordinator.L2DB MaxTxs HEZNODE_L2DB_MAXTXS Optional 1000000 Maximum number of pending L2Txs that can be stored in the pool
Coordinator.L2DB MinFeeUSD HEZNODE_L2DB_MINFEEUSD Optional 0.10 Minimum fee in USD that a tx must pay in order to be accepted into the pool
Coordinator.L2DB MaxFeeUSD HEZNODE_L2DB_MAXFEEUSD Optional 10.0 Maximum fee in USD that a tx must pay in order to be accepted into the pool
Coordinator.L2DB TTL HEZNODE_L2DB_TTL Optional "24h" Time To Live for L2Txs in the pool. L2Txs older than TTL will be deleted.
Coordinator.L2DB PurgeBatchDelay HEZNODE_L2DB_PURGEBATCHDELAY Optional 10 Delay between batches to purge outdated transactions. Outdated L2Txs are those that have been forged or marked as invalid for longer than the SafetyPeriod and pending L2Txs that have been in the pool for longer than TTL once there are MaxTxs
Coordinator.L2DB InvalidateBatchDelay HEZNODE_L2DB_INVALIDATEBATCHDELAY Optional 20 Delay between batches to mark invalid transactions due to nonce lower than the account nonce
Coordinator.L2DB PurgeBlockDelay HEZNODE_L2DB_PURGEBLOCKDELAY Optional 10 Delay between blocks to purge outdated transactions. Outdated L2Txs are those that have been forged or marked as invalid for longer than the SafetyPeriod and pending L2Txs that have been in the pool for longer than TTL once there are MaxTxs.
Coordinator.L2DB InvalidateBlockDelay HEZNODE_L2DB_INVALIDATEBLOCKDELAY Optional 20 Delay between blocks to mark invalid transactions due to nonce lower than the account nonce
Coordinator.TxSelector Path HEZNODE_TXSELECTOR_PATH Optional "/var/hermez/txselector" Path where the TxSelector StateDB is stored
Coordinator.BatchBuilder Path HEZNODE_BATCHBUILDER_PATH Optional "/var/hermez/batchbuilder" Path where the BatchBuilder StateDB is stored
Coordinator.ServerProofs URLs HEZNODE_SERVERPROOF_URLS (comma separator ",") Required ["http://localhost:3000"] Server proof API URL
Coordinator.Circuit MaxTx HEZNODE_CIRCUIT_MAXTX Required 2048 Maximum number of txs supported by the circuit
Coordinator.Circuit NLevels HEZNODE_CIRCUIT_NLEVELS Required 32 Maximum number of merkle tree levels supported by the circuit
Coordinator.EthClient CheckLoopInterval HEZNODE_ETHCLIENT_CHECKLOOPINTERVAL Optional "500ms" Interval between receipt checks of ethereum transactions in the TxManager
Coordinator.EthClient Attempts HEZNODE_ETHCLIENT_ATTEMPTS Optional 4 Number of attempts to do an eth client RPC call before giving up
Coordinator.EthClient AttemptsDelay HEZNODE_ETHCLIENT_ATTEMPTSDELAY Optional "500ms" Delay between attempts do do an eth client RPC call
Coordinator.EthClient TxResendTimeout HEZNODE_ETHCLIENT_TXRESENDTIMEOUT Optional "2m" Timeout after which a non-mined ethereum transaction will be resent (reusing the nonce) with a newly calculated gas price
Coordinator.EthClient NoReuseNonce HEZNODE_ETHCLIENT_NOREUSENONCE Optional false Disables reusing nonces of pending transactions for new replacement transactions
Coordinator.EthClient MaxGasPrice HEZNODE_ETHCLIENT_MAXGASPRICE Optional 500 Maximum gas price allowed for ethereum transactions in gwei
Coordinator.EthClient MinGasPrice HEZNODE_ETHCLIENT_MINGASPRICE Optional 5 Minimum gas price allowed for ethereum transactions in gwei
Coordinator.EthClient GasPriceIncPerc HEZNODE_ETHCLIENT_GASPRICEINCPERC Optional 5 Percentage increased of gas price set in an ethereum transaction from the suggested gas price by the ethereum node
Coordinator.EthClient.Keystore Path HEZNODE_KEYSTORE_PATH Optional "/var/hermez/ethkeystore" Path where the keystore is stored
Coordinator.EthClient.Keystore Password HEZNODE_KEYSTORE_PASSWORD Required "yourpasswordhere" Password used to decrypt the keys in the keystore
Coordinator.EthClient.ForgeBatchGasCost Fixed HEZNODE_FORGEBATCHGASCOST_FIXED Optional 900000 Gas needed to forge an empty batch
Coordinator.EthClient.ForgeBatchGasCost L1UserTx HEZNODE_FORGEBATCHGASCOST_L1USERTX Optional 15000 Gas needed per L1 tx
Coordinator.EthClient.ForgeBatchGasCost L1CoordTx HEZNODE_FORGEBATCHGASCOST_L1COORDTX Optional 7000 Gas needed for a coordinator L1 tx
Coordinator.EthClient.ForgeBatchGasCost L2Tx HEZNODE_FORGEBATCHGASCOST_L2TX Optional 600 Gas needed for an L2 tx
Coordinator.API Coordinator HEZNODE_COORDINATORAPI_COORDINATOR Optional true Enables coordinator API endpoints
Coordinator.Debug BatchPath HEZNODE_COORDINATORDEBUG_BATCHPATH Optional "" If this parameter is set, specifies the path where batchInfo is stored in JSON in every step/update of the pipeline
Coordinator.Debug LightScrypt HEZNODE_COORDINATORDEBUG_LIGHTSCRYPT Optional false If lightScrypt is set, uses light parameters for the ethereum keystore encryption algorithm
Coordinator.Debug RollupVerifierIndex Optional nil RollupVerifierIndex is the index of the verifier to use in the Rollup smart contract. The verifier chosen by index must match with the Circuit parameters. Only for debug purposes. It can't be used as env variable
Coordinator.Etherscan URL HEZNODE_ETHERSCAN_URL Optional "" If this parameter is set, specifies the etherscan endpoint to get the gas estimations for that momment
Coordinator.Etherscan APIKey HEZNODE_ETHERSCAN_APIKEY Optional "" This parameter allow access to etherscan services
RecommendedFeePolicy PolicyType HEZNODE_RECOMMENDEDFEEPOLICY_POLICYTYPE Optional "Static" Selects the mode. "Static" or "AvgLastHour"
RecommendedFeePolicy StaticValue HEZNODE_RECOMMENDEDFEEPOLICY_STATICVALUE Optional 0.10 If PolicyType is "static" defines the recommended fee value

Documentation

Index

Constants

View Source
const DefaultValues = `` /* 2341-byte string literal not displayed */

DefaultValues is the default fonfigurations for the hermez node

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServer

type APIServer struct {
	// NodeAPI specifies the configuration parameters of the API
	API struct {
		// Address where the API will listen if set
		Address string `validate:"required" env:"HEZNODE_API_ADDRESS"`
		// Explorer enables the Explorer API endpoints
		Explorer bool `env:"HEZNODE_API_EXPLORER"`
		// Maximum concurrent connections allowed between API and SQL
		MaxSQLConnections int `validate:"required,gte=1" env:"HEZNODE_API_MAXSQLCONNECTIONS"`
		// SQLConnectionTimeout is the maximum amount of time that an API request
		// can wait to establish a SQL connection
		SQLConnectionTimeout Duration `env:"HEZNODE_API_SQLCONNECTIONTIMEOUT"`
	} `validate:"required"`
	PostgreSQL  PostgreSQL `validate:"required"`
	Coordinator struct {
		API struct {
			// Coordinator enables the coordinator API endpoints
			Coordinator bool `env:"HEZNODE_COORDINATORAPI_COORDINATOR"`
		} `validate:"required"`
		L2DB struct {
			// MaxTxs is the maximum number of pending L2Txs that can be
			// stored in the pool.  Once this number of pending L2Txs is
			// reached, inserts to the pool will be denied until some of
			// the pending txs are forged.
			MaxTxs uint32 `validate:"required" env:"HEZNODE_L2DB_MAXTXS"`
			// MinFeeUSD is the minimum fee in USD that a tx must pay in
			// order to be accepted into the pool.  Txs with lower than
			// minimum fee will be rejected at the API level.
			MinFeeUSD float64 `validate:"gte=0" env:"HEZNODE_L2DB_MINFEEUSD"`
			// MaxFeeUSD is the maximum fee in USD that a tx must pay in
			// order to be accepted into the pool.  Txs with greater than
			// maximum fee will be rejected at the API level.
			MaxFeeUSD float64 `validate:"required,gte=0" env:"HEZNODE_L2DB_MAXFEEUSD"`
		} `validate:"required"`
	}
	Debug NodeDebug `validate:"required"`
}

APIServer is the api server configuration parameters

func LoadAPIServer

func LoadAPIServer(path string, coordinator bool) (*APIServer, error)

LoadAPIServer loads the APIServer configuration from path.

type Coordinator

type Coordinator struct {
	// ForgerAddress is the address under which this coordinator is forging
	ForgerAddress ethCommon.Address `validate:"required" env:"HEZNODE_COORDINATOR_FORGERADDRESS"`
	// MinimumForgeAddressBalance is the minimum balance the forger address
	// needs to start the coordinator in wei. Of set to 0, the coordinator
	// will not check the balance before starting.
	MinimumForgeAddressBalance *big.Int `env:"HEZNODE_COORDINATOR_MINIMUMFORGEADDRESSBALANCE"`
	// FeeAccount is the Hermez account that the coordinator uses to receive fees
	FeeAccount struct {
		// Address is the ethereum address of the account to receive fees
		Address ethCommon.Address `validate:"required" env:"HEZNODE_FEEACCOUNT_ADDRESS"`
		// BJJ is the baby jub jub public key of the account to receive fees
		BJJ babyjub.PublicKeyComp `validate:"required" env:"HEZNODE_FEEACCOUNT_BJJ"`
	} `validate:"required"`
	// ConfirmBlocks is the number of confirmation blocks to wait for sent
	// ethereum transactions before forgetting about them
	ConfirmBlocks int64 `validate:"required,gte=0" env:"HEZNODE_COORDINATOR_CONFIRMBLOCKS"`
	// L1BatchTimeoutPerc is the portion of the range before the L1Batch
	// timeout that will trigger a schedule to forge an L1Batch
	L1BatchTimeoutPerc float64 `validate:"required,lte=1.0,gte=0.0" env:"HEZNODE_COORDINATOR_L1BATCHTIMEOUTPERC"`
	// StartSlotBlocksDelay is the number of blocks of delay to wait before
	// starting the pipeline when we reach a slot in which we can forge.
	StartSlotBlocksDelay int64 `validate:"gte=0" env:"HEZNODE_COORDINATOR_STARTSLOTBLOCKSDELAY"`
	// ScheduleBatchBlocksAheadCheck is the number of blocks ahead in which
	// the forger address is checked to be allowed to forge (apart from
	// checking the next block), used to decide when to stop scheduling new
	// batches (by stopping the pipeline).
	// For example, if we are at block 10 and ScheduleBatchBlocksAheadCheck
	// is 5, even though at block 11 we canForge, the pipeline will be
	// stopped if we can't forge at block 15.
	// This value should be the expected number of blocks it takes between
	// scheduling a batch and having it mined.
	ScheduleBatchBlocksAheadCheck int64 `validate:"gte=0" env:"HEZNODE_COORDINATOR_SCHEDULEBATCHBLOCKSAHEADCHECK"`
	// SendBatchBlocksMarginCheck is the number of margin blocks ahead in
	// which the coordinator is also checked to be allowed to forge, apart
	// from the next block; used to decide when to stop sending batches to
	// the smart contract.
	// For example, if we are at block 10 and SendBatchBlocksMarginCheck is
	// 5, even though at block 11 we canForge, the batch will be discarded
	// if we can't forge at block 15.
	SendBatchBlocksMarginCheck int64 `validate:"gte=0" env:"HEZNODE_COORDINATOR_SENDBATCHBLOCKSMARGINCHECK"`
	// ProofServerPollInterval is the waiting interval between polling the
	// ProofServer while waiting for a particular status
	ProofServerPollInterval Duration `validate:"required" env:"HEZNODE_COORDINATOR_PROOFSERVERPOLLINTERVAL"`
	// ForgeRetryInterval is the waiting interval between calls forge a
	// batch after an error
	ForgeRetryInterval Duration `validate:"required" env:"HEZNODE_COORDINATOR_FORGERETRYINTERVAL"`
	// ForgeDelay is the delay after which a batch is forged if the slot is
	// already committed.  If set to 0s, the coordinator will continuously
	// forge at the maximum rate.
	ForgeDelay Duration `validate:"-" env:"HEZNODE_COORDINATOR_FORGEDELAY"`
	// ForgeNoTxsDelay is the delay after which a batch is forged even if
	// there are no txs to forge if the slot is already committed.  If set
	// to 0s, the coordinator will continuously forge even if the batches
	// are empty.
	ForgeNoTxsDelay Duration `validate:"-" env:"HEZNODE_COORDINATOR_FORGENOTXSDELAY"`
	// MustForgeAtSlotDeadline enables the coordinator to forge slots if
	// the empty slots reach the slot deadline.
	MustForgeAtSlotDeadline bool `env:"HEZNODE_COORDINATOR_MUSTFORGEATSLOTDEADLINE"`
	// IgnoreSlotCommitment disables forcing the coordinator to forge a
	// slot immediately when the slot is not committed. If set to false,
	// the coordinator will immediately forge a batch at the beginning of a
	// slot if it's the slot winner.
	IgnoreSlotCommitment bool `env:"HEZNODE_COORDINATOR_IGNORESLOTCOMMITMENT"`
	// ForgeOncePerSlotIfTxs will make the coordinator forge at most one
	// batch per slot, only if there are included txs in that batch, or
	// pending l1UserTxs in the smart contract.  Setting this parameter
	// overrides `ForgeDelay`, `ForgeNoTxsDelay`, `MustForgeAtSlotDeadline`
	// and `IgnoreSlotCommitment`.
	ForgeOncePerSlotIfTxs bool `env:"HEZNODE_COORDINATOR_FORGEONCEPERSLOTIFTXS"`
	// SyncRetryInterval is the waiting interval between calls to the main
	// handler of a synced block after an error
	SyncRetryInterval Duration `validate:"required" env:"HEZNODE_COORDINATOR_SYNCRETRYINTERVAL"`
	// PurgeByExtDelInterval is the waiting interval between calls
	// to the PurgeByExternalDelete function of the l2db which deletes
	// pending txs externally marked by the column `external_delete`
	PurgeByExtDelInterval Duration `validate:"required" env:"HEZNODE_COORDINATOR_PURGEBYEXTDELINTERVAL"`
	// L2DB is the DB that holds the pool of L2Txs
	L2DB struct {
		// SafetyPeriod is the number of batches after which
		// non-pending L2Txs are deleted from the pool
		SafetyPeriod common.BatchNum `validate:"required" env:"HEZNODE_L2DB_SAFETYPERIOD"`
		// MaxTxs is the maximum number of pending L2Txs that can be
		// stored in the pool.  Once this number of pending L2Txs is
		// reached, inserts to the pool will be denied until some of
		// the pending txs are forged.
		MaxTxs uint32 `validate:"required" env:"HEZNODE_L2DB_MAXTXS"`
		// MinFeeUSD is the minimum fee in USD that a tx must pay in
		// order to be accepted into the pool.  Txs with lower than
		// minimum fee will be rejected at the API level.
		MinFeeUSD float64 `validate:"gte=0" env:"HEZNODE_L2DB_MINFEEUSD"`
		// MaxFeeUSD is the maximum fee in USD that a tx must pay in
		// order to be accepted into the pool.  Txs with greater than
		// maximum fee will be rejected at the API level.
		MaxFeeUSD float64 `validate:"required,gte=0" env:"HEZNODE_L2DB_MAXFEEUSD"`
		// TTL is the Time To Live for L2Txs in the pool. L2Txs older
		// than TTL will be deleted.
		TTL Duration `validate:"required" env:"HEZNODE_L2DB_TTL"`
		// PurgeBatchDelay is the delay between batches to purge
		// outdated transactions. Outdated L2Txs are those that have
		// been forged or marked as invalid for longer than the
		// SafetyPeriod and pending L2Txs that have been in the pool
		// for longer than TTL once there are MaxTxs.
		PurgeBatchDelay int64 `validate:"required,gte=0" env:"HEZNODE_L2DB_PURGEBATCHDELAY"`
		// InvalidateBatchDelay is the delay between batches to mark
		// invalid transactions due to nonce lower than the account
		// nonce.
		InvalidateBatchDelay int64 `validate:"required" env:"HEZNODE_L2DB_INVALIDATEBATCHDELAY"`
		// PurgeBlockDelay is the delay between blocks to purge
		// outdated transactions. Outdated L2Txs are those that have
		// been forged or marked as invalid for longer than the
		// SafetyPeriod and pending L2Txs that have been in the pool
		// for longer than TTL once there are MaxTxs.
		PurgeBlockDelay int64 `validate:"required,gte=0" env:"HEZNODE_L2DB_PURGEBLOCKDELAY"`
		// InvalidateBlockDelay is the delay between blocks to mark
		// invalid transactions due to nonce lower than the account
		// nonce.
		InvalidateBlockDelay int64 `validate:"required,gte=0" env:"HEZNODE_L2DB_INVALIDATEBLOCKDELAY"`
	} `validate:"required"`
	TxSelector struct {
		// Path where the TxSelector StateDB is stored
		Path string `validate:"required" env:"HEZNODE_TXSELECTOR_PATH"`
	} `validate:"required"`
	BatchBuilder struct {
		// Path where the BatchBuilder StateDB is stored
		Path string `validate:"required" env:"HEZNODE_BATCHBUILDER_PATH"`
	} `validate:"required"`
	ServerProofs struct {
		URLs []string `validate:"required" env:"HEZNODE_SERVERPROOF_URLS" envSeparator:","`
	} `validate:"required"`
	Circuit struct {
		// MaxTx is the maximum number of txs supported by the circuit
		MaxTx int64 `validate:"required,gte=0" env:"HEZNODE_CIRCUIT_MAXTX"`
		// NLevels is the maximum number of merkle tree levels
		// supported by the circuit
		NLevels int64 `validate:"required,gte=0" env:"HEZNODE_CIRCUIT_NLEVELS"`
	} `validate:"required"`
	EthClient struct {
		// MaxGasPrice is the maximum gas price allowed for ethereum
		// transactions
		MaxGasPrice int64 `validate:"required" env:"HEZNODE_ETHCLIENT_MAXGASPRICE"`
		// MinGasPrice is the minimum gas price in gwei allowed for ethereum
		MinGasPrice int64 `validate:"required" env:"HEZNODE_ETHCLIENT_MINGASPRICE"`
		// GasPriceIncPerc is the percentage increase of gas price set
		// in an ethereum transaction from the suggested gas price by
		// the ethereum node
		GasPriceIncPerc int64 `validate:"gte=0" env:"HEZNODE_ETHCLIENT_GASPRICEINCPERC"`
		// CheckLoopInterval is the waiting interval between receipt
		// checks of ethereum transactions in the TxManager
		CheckLoopInterval Duration `validate:"required" env:"HEZNODE_ETHCLIENT_CHECKLOOPINTERVAL"`
		// Attempts is the number of attempts to do an eth client RPC
		// call before giving up
		Attempts int `validate:"required,gte=1" env:"HEZNODE_ETHCLIENT_ATTEMPTS"`
		// AttemptsDelay is delay between attempts do do an eth client
		// RPC call
		AttemptsDelay Duration `validate:"required" env:"HEZNODE_ETHCLIENT_ATTEMPTSDELAY"`
		// TxResendTimeout is the timeout after which a non-mined
		// ethereum transaction will be resent (reusing the nonce) with
		// a newly calculated gas price
		TxResendTimeout Duration `validate:"required" env:"HEZNODE_ETHCLIENT_TXRESENDTIMEOUT"`
		// NoReuseNonce disables reusing nonces of pending transactions for
		// new replacement transactions
		NoReuseNonce bool `env:"HEZNODE_ETHCLIENT_NOREUSENONCE"`
		// Keystore is the ethereum keystore where private keys are kept
		Keystore struct {
			// Path to the keystore
			Path string `validate:"required" env:"HEZNODE_KEYSTORE_PATH"`
			// Password used to decrypt the keys in the keystore
			Password string `validate:"required" env:"HEZNODE_KEYSTORE_PASSWORD"`
		} `validate:"required"`
		// ForgeBatchGasCost contains the cost of each action in the
		// ForgeBatch transaction.
		ForgeBatchGasCost ForgeBatchGasCost `validate:"required"`
	} `validate:"required"`
	API   CoordinatorAPI `validate:"required"`
	Debug struct {
		// BatchPath if set, specifies the path where batchInfo is stored
		// in JSON in every step/update of the pipeline
		BatchPath string `env:"HEZNODE_COORDINATORDEBUG_BATCHPATH"`
		// LightScrypt if set, uses light parameters for the ethereum
		// keystore encryption algorithm.
		LightScrypt bool `env:"HEZNODE_COORDINATORDEBUG_LIGHTSCRYPT"`
		// RollupVerifierIndex is the index of the verifier to use in
		// the Rollup smart contract.  The verifier chosen by index
		// must match with the Circuit parameters.
		RollupVerifierIndex *int
	}
	Etherscan struct {
		// URL if set, specifies the etherscan endpoint to get
		// the gas estimations for that moment.
		URL string `env:"HEZNODE_ETHERSCAN_URL"`
		// APIKey allow access to etherscan services
		APIKey string `env:"HEZNODE_ETHERSCAN_APIKEY"`
	}
}

Coordinator is the coordinator specific configuration.

type CoordinatorAPI

type CoordinatorAPI struct {
	// Coordinator enables the coordinator API endpoints
	Coordinator bool `env:"HEZNODE_COORDINATORAPI_COORDINATOR"`
}

CoordinatorAPI specifies the configuration parameters of the API in mode coordinator

type Duration

type Duration struct {
	time.Duration `validate:"required"`
}

Duration is a wrapper type that parses time duration from text.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) error

UnmarshalText unmarshalls time duration from text.

type ForgeBatchGasCost

type ForgeBatchGasCost struct {
	Fixed     uint64 `validate:"required" env:"HEZNODE_FORGEBATCHGASCOST_FIXED"`
	L1UserTx  uint64 `validate:"required" env:"HEZNODE_FORGEBATCHGASCOST_L1USERTX"`
	L1CoordTx uint64 `validate:"required" env:"HEZNODE_FORGEBATCHGASCOST_L1COORDTX"`
	L2Tx      uint64 `validate:"required" env:"HEZNODE_FORGEBATCHGASCOST_L2TX"`
}

ForgeBatchGasCost is the costs associated to a ForgeBatch transaction, split into different parts to be used in a formula.

type Node

type Node struct {
	StateDB struct {
		// Path where the synchronizer StateDB is stored
		Path string `validate:"required" env:"HEZNODE_STATEDB_PATH"`
		// Keep is the number of checkpoints to keep
		Keep int `validate:"required,gte=128" env:"HEZNODE_STATEDB_KEEP"`
	} `validate:"required"`
	PostgreSQL PostgreSQL `validate:"required"`
	Web3       struct {
		// URL is the URL of the web3 ethereum-node RPC server.  Only
		// geth is officially supported.
		URL string `validate:"required,url" env:"HEZNODE_WEB3_URL"`
	} `validate:"required"`
	Synchronizer struct {
		// SyncLoopInterval is the interval between attempts to
		// synchronize a new block from an ethereum node
		SyncLoopInterval Duration `validate:"required" env:"HEZNODE_SYNCHRONIZER_SYNCLOOPINTERVAL"`
		// StatsUpdateBlockNumDiffThreshold is a threshold of a number of
		// Ethereum blocks left to synchronize, such that if there are more
		// blocks to sync than the defined value synchronizer can aggressively
		// skip calling UpdateEth to save network bandwidth and time.
		// After reaching the threshold UpdateEth is called on each block.
		// This value only affects the reported % of synchronization of
		// blocks and batches, nothing else.
		StatsUpdateBlockNumDiffThreshold uint16 `validate:"required,gt=32" env:"HEZNODE_SYNCHRONIZER_STATSUPDATEBLOCKSNUMDIFFTHRESHOLD"`
		// StatsUpdateFrequencyDivider - While having more blocks to sync than
		// updateEthBlockNumThreshold, UpdateEth will be called once in a
		// defined number of blocks. This value only affects the reported % of
		// synchronization of blocks and batches, nothing else.
		StatsUpdateFrequencyDivider uint16 `validate:"required,gt=1" env:"HEZNODE_SYNCHRONIZER_STATSUPDATEFREQUENCYDIVIDER"`
	} `validate:"required"`
	SmartContracts struct {
		// Rollup is the address of the Hermez.sol smart contract
		Rollup ethCommon.Address `validate:"required" env:"HEZNODE_SMARTCONTRACTS_ROLLUP"`
	} `validate:"required"`
	// API specifies the configuration parameters of the API
	API struct {
		// Address where the API will listen if set
		Address string `env:"HEZNODE_API_ADDRESS"`
		// Explorer enables the Explorer API endpoints
		Explorer bool `env:"HEZNODE_API_EXPLORER"`
		// UpdateMetricsInterval is the interval between updates of the
		// API metrics
		UpdateMetricsInterval Duration `validate:"required" env:"HEZNODE_API_UPDATEMETRICSINTERVAL"`
		// UpdateRecommendedFeeInterval is the interval between updates of the
		// recommended fees
		UpdateRecommendedFeeInterval Duration `validate:"required" env:"HEZNODE_API_UPDATERECOMMENDEDFEEINTERVAL"`
		// Maximum concurrent connections allowed between API and SQL
		MaxSQLConnections int `validate:"required,gte=1" env:"HEZNODE_API_MAXSQLCONNECTIONS"`
		// SQLConnectionTimeout is the maximum amount of time that an API request
		// can wait to establish a SQL connection
		SQLConnectionTimeout Duration `env:"HEZNODE_API_SQLCONNECTIONTIMEOUT"`
	} `validate:"required"`
	RecommendedFeePolicy stateapiupdater.RecommendedFeePolicy `validate:"required"`
	Debug                NodeDebug                            `validate:"required"`
	Coordinator          Coordinator                          `validate:"-"`
}

Node is the hermez node configuration.

func LoadNode

func LoadNode(path string, coordinator bool) (*Node, error)

LoadNode loads the Node configuration from path.

type NodeDebug

type NodeDebug struct {
	// APIAddress is the address where the debugAPI will listen if
	// set
	APIAddress string `env:"HEZNODE_DEBUG_APIADDRESS"`
	// MeddlerLogs enables meddler debug mode, where unused columns and struct
	// fields will be logged
	MeddlerLogs bool `env:"HEZNODE_DEBUG_MEDDLERLOGS"`
	// GinDebugMode sets Gin-Gonic (the web framework) to run in
	// debug mode
	GinDebugMode bool `env:"HEZNODE_DEBUG_GINDEBUGMODE"`
}

NodeDebug specifies debug configuration parameters

type PostgreSQL

type PostgreSQL struct {
	// Port of the PostgreSQL write server
	PortWrite int `validate:"required" env:"HEZNODE_POSTGRESQL_PORTWRITE"`
	// Host of the PostgreSQL write server
	HostWrite string `validate:"required" env:"HEZNODE_POSTGRESQL_HOSTWRITE"`
	// User of the PostgreSQL write server
	UserWrite string `validate:"required" env:"HEZNODE_POSTGRESQL_USERWRITE"`
	// Password of the PostgreSQL write server
	PasswordWrite string `validate:"required" env:"HEZNODE_POSTGRESQL_PASSWORDWRITE"`
	// Name of the PostgreSQL write server database
	NameWrite string `validate:"required" env:"HEZNODE_POSTGRESQL_NAMEWRITE"`
	// Port of the PostgreSQL read server
	PortRead int `env:"HEZNODE_POSTGRESQL_PORTREAD"`
	// Host of the PostgreSQL read server
	HostRead string `validate:"nefield=HostWrite" env:"HEZNODE_POSTGRESQL_HOSTREAD"`
	// User of the PostgreSQL read server
	UserRead string `env:"HEZNODE_POSTGRESQL_USERREAD"`
	// Password of the PostgreSQL read server
	PasswordRead string `env:"HEZNODE_POSTGRESQL_PASSWORDREAD"`
	// Name of the PostgreSQL read server database
	NameRead string `env:"HEZNODE_POSTGRESQL_NAMEREAD"`
}

PostgreSQL is the postgreSQL configuration parameters. It's possible to use differentiated SQL connections for read/write. If the read configuration is not provided, the write one it's going to be used for both reads and writes

Jump to

Keyboard shortcuts

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