Commit Graph

748 Commits

Author SHA1 Message Date
Eduard S
777ca3d87e Merge pull request #646 from hermeznetwork/fix/forgerCommitment
Fix Synchronizer not setting slot.ForgerCommitment to true
2021-03-17 13:53:07 +01:00
Oleksandr Brezhniev
eb89ab84f2 Rename the variable to match the meaning 2021-03-17 14:41:06 +02:00
Oleksandr Brezhniev
36c1ba84df Fix Synchronizer not setting slot.ForgerCommitment to true until fully synced and after reorgs 2021-03-17 13:21:27 +02:00
Eduard S
80f16201a2 Merge pull request #640 from hermeznetwork/feature/BatchCheck
separated the policy to decide if we forge batch or not
2021-03-15 18:00:41 +01:00
Mikelle
cd74f1fda3 separated the policy to decide if we forge batch or not 2021-03-15 19:23:28 +03:00
arnau
6c6d1ea7b8 Merge pull request #631 from hermeznetwork/feature/serveapicli2
Allow serving API only via new cli command
2021-03-15 15:41:36 +01:00
Eduard S
d625cc9287 Allow serving API only via new cli command
- Add new command to the cli/node: `serveapi` that alows serving the API just
  by connecting to the PostgreSQL database.  The mode flag should me passed in
  order to select whether we are connecting to a synchronizer database or a
  coordinator database.  If `coord` is chosen as mode, the coordinator
  endpoints can be activated in order to allow inserting l2txs and
  authorizations into the L2DB.

Summary of the implementation details
- New SQL table with 3 columns (plus `item_id` pk).  The table only contains a
  single row with `item_id` = 1.  Columns:
    - state: historydb.StateAPI in JSON.  This is the struct that is served via
      the `/state` API endpoint.  The node will periodically update this struct
      and store it int he DB.  The api server will query it from the DB to
      serve it.
    - config: historydb.NodeConfig in JSON.  This struct contains node
      configuration parameters that the API needs to be aware of.  It's updated
      once every time the node starts.
    - constants: historydb.Constants in JSON.  This struct contains all the
      hermez network constants gathered via the ethereum client by the node.
      It's written once every time the node starts.
- The HistoryDB contains methods to get and update each one of these columns
  individually.
- The HistoryDB contains all methods that query the DB and prepare objects that
  will appear in the StateAPI endpoint.
- The configuration used in for the `serveapi` cli/node command is defined in
  `config.APIServer`, and is a subset of `node.Config` in order to allow
  reusing the same configuration file of the node if desired.
- A new object is introduced in the api: `StateAPIUpdater`, which contains all
  the necessary information to update the StateAPI in the DB periodically by
  the node.

- Moved the types `SCConsts`, `SCVariables` and `SCVariablesPtr` from
  `syncrhonizer` to `common` for convenience.
2021-03-15 15:35:20 +01:00
Eduard S
ec9b0aadce Merge pull request #617 from hermeznetwork/fix/txsel-discard-processl2txerrs
Fix TxSel discard tx when ProcessL2Tx gives err
2021-03-15 13:45:46 +01:00
arnaucube
5d8579a609 Fix TxSel discard tx when ProcessL2Tx gives err
Refactor getL1L2TxSelection, which fixes some problems for certain
combinations of txs.
2021-03-15 13:36:15 +01:00
arnau
84b84ecc17 Merge pull request #614 from hermeznetwork/feature/forger-config-options
Add the option to forge batch at the slot deadline
2021-03-15 11:29:27 +01:00
Pantani
968fcc207e Add the option to force or not a forgeBatch at the beginning of the slot 2021-03-11 23:26:17 -03:00
Eduard S
a5dcc67a08 Merge pull request #629 from hermeznetwork/feature/indivisual-token-config
Allow price update configuration to be specified per token
2021-03-10 14:11:57 +01:00
arnaubennassar
97062afc90 Allow price update configuration to be specified per token 2021-03-10 14:04:00 +01:00
Eduard S
b724348ddc Merge pull request #630 from hermeznetwork/feature/update-poseidon
Update to last Poseidon & go-merkletree versions
2021-03-10 12:18:59 +01:00
arnau
0b6911052a Merge pull request #611 from hermeznetwork/feature/sync-l1-account-creation-auth
Synchronize the AccountCreationAuths from L1CoordinatorTxs
2021-03-09 17:24:54 +01:00
arnaucube
a39d880fd4 Update to last Poseidon & go-merkletree versions
Update to last Poseidon (go-iden3-crypto) & go-merkletree versions,
update the affected test vectors, and check ZKInputs compatibility with
last version of circuits.

Update to last Poseidon version (which includes the changes of the
reference implementation from
26ddaa91db)

Compatible with update at circomlib
(cf853c1cc9)
2021-03-09 14:43:08 +01:00
Pantani
efb23950db Synchronize the AccountCreationAuths from L1CoordinatorTxs 2021-03-08 14:41:19 -03:00
Eduard S
06b271fc47 Merge pull request #620 from hermeznetwork/feature/priceupdater-by-SC-addr
Add coingecko client to price updater
2021-03-08 16:42:07 +01:00
arnaubennassar
ac66ede917 Add coingecko client to price updater 2021-03-08 16:34:49 +01:00
Eduard S
7305a8d7f1 Merge pull request #615 from hermeznetwork/fix/l2txs-all-tonull
API doesnt accept pool txs without to
2021-03-08 15:24:35 +01:00
arnaubennassar
81690039da API doesnt accept pool txs without to 2021-03-08 15:16:49 +01:00
Eduard S
661da0d53e Merge pull request #619 from hermeznetwork/fix/floor-float40-helper
Fix NewFloat40Floor helper method
2021-03-08 15:16:45 +01:00
arnau
d0ace0773d Merge pull request #616 from hermeznetwork/fix/typos-and-lint
fix some code typos
2021-03-08 14:35:30 +01:00
arnaucube
4fd757a03c Fix NewFloat40Floor helper method 2021-03-08 14:32:05 +01:00
arnau
1778b08043 Merge pull request #618 from hermeznetwork/fix/poolL2-signature
Fix tx signature when toEthAddr starts with 0x0
2021-03-05 17:26:56 +01:00
arnaubennassar
dcd40f1943 Fix tx signature when toEthAddr starts with 0x0 2021-03-05 17:21:14 +01:00
Danilo Pantani
7833cb11de fix some code and comment typos 2021-03-04 18:26:00 -03:00
Danilo Pantani
d361abb8cd Add the config option to forge batch when the coordinator we are not the auction winner and reach the slot deadline 2021-03-04 13:55:06 -03:00
Eduard S
9e96bc89f0 Merge pull request #613 from hermeznetwork/fix/zkinputs-ISExitRoot-L1CoordTxs
Fix ZKInputs.ISExitRoot for case of L1CoordTxs
2021-03-04 16:44:43 +01:00
arnaucube
7bc83d7f70 Fix ZKInputs.ISExitRoot for case of L1CoordTxs
For the cases when there are Exit L1UserTxs and also there are
L1CoordinatorTxs, the ISExitRoot should have the expected value (!=0)
for the L1CoordinatorTxs slots.
2021-03-04 14:57:08 +01:00
Eduard S
6bf8584a82 Merge pull request #612 from hermeznetwork/fix/txselector-unselectedtx-nonce
Fix TxSel for unselected tx update internal Nonce
2021-03-04 14:14:00 +01:00
arnaucube
18e9e437da Fix TxSel for unselected tx update internal Nonce
Fix TxSelector for unselected tx update internal Nonce.
Also updated TxSelector config parameter.
2021-03-04 14:09:13 +01:00
Eduard S
e4343a73ad Merge pull request #610 from hermeznetwork/feature/float40-floor
Add NewFloor40Floor helper method
2021-03-03 12:07:50 +01:00
arnau
59558e5a4b Merge pull request #609 from hermeznetwork/feature/wipestatedb
Wipe StateDB in cli command wipesql
2021-03-03 12:02:21 +01:00
arnaucube
dfd49164f4 Add NewFloor40Floor helper method
Also added tracerr.Wrap(...) to missing places.
2021-03-03 11:58:17 +01:00
Eduard S
1050da350a Wipe StateDB in cli command wipesql
Also, in the cli commands `wipesql` and `discard`, always rebuild the current
checkpoint of the stateDBs to make sure it's in a consistent non-corrupted
state and do a reset afterwards.  These commands will allow reverting the
StateDB to a valid and consistent state in case a crash leaves the StateDB in a
corrupted state.
2021-03-03 11:33:22 +01:00
Eduard S
e460a7e58b Merge pull request #608 from hermeznetwork/feature/txprocessor-doc
Extend TxProcessor documentation and explanation
2021-03-02 14:19:49 +01:00
arnaucube
97fdbfe037 Extend TxProcessor documentation and explanation 2021-03-02 14:13:45 +01:00
arnau
2e2d5a3c29 Merge pull request #607 from hermeznetwork/feature/updateconfig
Update example config with working values
2021-03-02 12:08:36 +01:00
Eduard S
f762fbdc4d Update example config with working values
The `ForgeBatchGasCost` parameters work for the current version of the smart
contracts.
2021-03-02 12:00:18 +01:00
Eduard S
4390fd8346 Merge pull request #603 from hermeznetwork/feature/update-linter-lll
Add lll to linter checks
2021-03-01 18:07:09 +01:00
arnaucube
93b7866d3e Add lll to linter checks
Updated:
	batchbuilder
	common
	coordinator
	db/statedb
	eth
	log
	node
	priceupdater
	prover
	synchronizer
	test/*
	txprocessor
	txselector

Pending (once
https://github.com/hermeznetwork/hermez-node/tree/feature/serveapicli is
merged to master):
	Update golangci-lint version to v1.37.1
	api
	apitypes
	cli
	config
	db/historydb
	db/l2db
2021-03-01 18:02:10 +01:00
a_bennassar
059a3556fb Merge pull request #604 from hermeznetwork/fix/meddler
Don't select extra columns in SQL, fix metrics query
2021-03-01 17:18:53 +01:00
Eduard S
8b88e1fbd0 Don't select extra columns in SQL, fix metrics query
In the metrics query, the estimatedTimeToForgeL1 was probably not being read
from the SQL query because it contained upper case letters, and in PostgreSQL
when identifiers are not double quoted they are case insensitive:
https://stackoverflow.com/a/20880247
2021-03-01 16:31:26 +01:00
arnau
1de0b08bac Merge pull request #593 from hermeznetwork/fix/addgaspriceresend
When resending an eth tx, always increase gas price
2021-03-01 15:05:36 +01:00
arnau
73c3a91746 Merge pull request #602 from hermeznetwork/fix/forgebatch
Fix unforged L1UserTxs query in forgeBatch
2021-03-01 14:47:18 +01:00
Eduard S
74769da5ba Fix unforged L1UserTxs query in forgeBatch
Previously the code was only querying the unforged L1UserTxs of a particular
queue, but this was incorrect because there are always two non-forged queues:
the frozen one and the open one.

Replace it by a query to all the unforged L1UserTxs via a new HistoryDB method.
2021-03-01 13:02:06 +01:00
Eduard S
65b007d59c When resending an eth tx, always increase gas price
Incrementing the gas price unconditionally avoids sending the exact same
transaction, which geth will reject because that transaction already exists in
the pool
2021-03-01 12:06:25 +01:00
arnau
6e4bd56c1a Merge pull request #595 from hermeznetwork/fix/print-balance
fix forge address balance printing removing the int64 casting
2021-03-01 11:44:45 +01:00
Eduard S
39b7882ef2 Merge pull request #594 from hermeznetwork/fix/post-tx-no-usd
Avoid SQL error when checking value of token without usd on tx insert
2021-03-01 10:34:35 +01:00