Commit Graph

672 Commits

Author SHA1 Message Date
arnaucube
6a01c0ac14 Update ZKInputs test vectors with float40 & other
- Add AmountF new parameter to ZKInputs
- Update ZKInputs test vectors with float40 checked with circom circuits
- Small fix at eth/rollup.go with lenL1L2TxsBytes with new length of
Float40
2021-02-12 16:40:36 +01:00
arnaucube
63151a285c Migrate all packages to use Float40
Migrate all packages to use Float40 & Add more test vectors at common
2021-02-12 14:27:07 +01:00
arnaucube
52d4197330 Add Float40 methods
This commit adds Float40 related methods, and keeps the Float16 version
which will be deleted in a near future once the Float40 migration is
ready.
2021-02-12 14:27:07 +01:00
arnau
ea63cba62a Merge pull request #538 from hermeznetwork/fix/txselTransferToBJJ
Fix txselector TransferToBJJ behaviour
2021-02-12 12:02:13 +01:00
Eduard S
c7e6267189 Fix txselector TransferToBJJ behaviour 2021-02-11 18:19:29 +01:00
Eduard S
2a77dac9c1 Merge pull request #536 from hermeznetwork/feature/sql-semaphore
Add semaphore for API queries to SQL
2021-02-10 13:47:27 +01:00
Arnau B
ac1fd9acf7 Add semaphore for API queries to SQL 2021-02-10 13:36:17 +01:00
arnau
1bf29636db Merge pull request #537 from hermeznetwork/fix/l2dbreorg
Fix l2db reorg of forging l2txs
2021-02-10 13:02:21 +01:00
Eduard S
2bf3b843ed Fix l2db reorg of forging l2txs 2021-02-09 17:13:29 +01:00
arnau
277a1bc321 Merge pull request #535 from hermeznetwork/fix/sync
Fix synchronizer, add verifier index config param
2021-02-08 17:52:26 +01:00
Eduard S
3181c8738c Fix synchronizer, add verifier index config param
- eth
    - In EventsByBlock calls ignore blockNum if blockHash != nil.  This fixes
      the issue where a blockNumber and blockHash was being passed, which the
      eth events query function doesn't allow, causing the synchronizer to fail
      at every iteration.
- Node/Config
    - Add Coordinator.Debug.RollupVerifierIndex to force choosing a particular
      verifier by index in the Rollup smart contract.
2021-02-08 17:45:33 +01:00
arnau
62df063ccf Merge pull request #534 from hermeznetwork/fix/statedb2
Pass StateDB constructor parameters as Config type
2021-02-08 13:53:43 +01:00
Eduard S
48a538faa3 Pass StateDB constructor parameters as Config type
- KVDB/StateDB
        - Pass config parameters in a Config type instead of using many
          arguments in constructor.
	- Add new parameter `NoLast` which disables having an opened DB with a
	  checkpoint to the last batchNum for thread-safe reads.  Last will be
	  disabled in the StateDB used by the TxSelector and BatchBuilder.
	- Add new parameter `NoGapsCheck` which skips checking gaps in the list
	  of checkpoints and returning errors if there are gaps.  Gaps check
	  will be disabled in the StateDB used by the TxSelector and
	  BatchBuilder, because we expect to have gaps when there are multiple
	  coordinators forging (slots not forged by our coordinator will leave
	  gaps).
2021-02-08 13:46:24 +01:00
arnau
10a34c8801 Merge pull request #532 from hermeznetwork/fix/statedb1
Fix eth events query and sync inconsistent state
2021-02-08 13:21:24 +01:00
Eduard S
6260dfedad Fix eth events query and sync inconsistent state
- kvdb
	- Fix path in Last when doing `setNew`
	- Only close if db != nil, and after closing, always set db to nil
		- This will avoid a panic in the case where the db is closed but
		  there's an error soon after, and a future call tries to close
		  again.  This is because pebble.Close() will panic if the db is
		  already closed.
	- Avoid calling pebble methods when a the Storage interface already
	  implements that method (like Close).
- statedb
	- In test, avoid calling KVDB method if the same method is available for
	  the StateDB (like MakeCheckpoint, CurrentBatch).
- eth
	- In *EventByBlock methods, take blockHash as input argument and use it
	  when querying the event logs.  Previously the blockHash was only taken
	  from the logs results *only if* there was any log.  This caused the
	  following issue: if there was no logs, it was not possible to know if
	  the result was from the expected block or an uncle block!  By querying
	  logs by blockHash we make sure that even if there are no logs, they
	  are from the right block.
	  	- Note that now the function can either be called with a
		  blockNum or blockHash, but not both at the same time.
- sync
	- If there's an error during call to Sync call resetState, which
	  internally resets the stateDB to avoid stale checkpoints (and a
	  corresponding invalid increase in the StateDB batchNum).
	- During a Sync, after very batch processed, make sure that the StateDB
	  currentBatch corresponds to the batchNum in the smart contract
	  log/event.
2021-02-05 16:06:17 +01:00
Eduard S
56d05ce57a Merge pull request #530 from hermeznetwork/feature/exitfee0
Update ZKInputs to incl Accumulated Fees of val 0
2021-02-05 10:52:12 +01:00
arnaucube
e55ce04bbd Update ZKInputs to incl Accumulated Fees of val 0
Fixes the case where there is a PoolTxs of type Exit with fee 0 for a
TokenID. Before this commit the Coordinator was not sending the
accumulated fee (which has value 0) to the Coordinator account for that
TokenID, with this commit the Coordinator always sends the accumulated
fee even when the value is 0 to match the hermez circom circuits
behaviour.

Also added a test to check the values and that also sends the proof to a
real proof server to check that can generate a valid proof.
2021-02-05 10:44:50 +01:00
arnau
d62800b69a Merge pull request #526 from hermeznetwork/feature/robuststatedb2
Add Last db view in kvdb and statedb
2021-02-04 18:15:00 +01:00
Eduard S
6590c47a9a Add Last db view in kvdb and statedb
Last db view is an opened pebble db which always contains a checkpoint from the
last batch.  Methods to access this last batch are thread safe so that views of
the last checkpoint can be made anywhere and with a consistent view of the
state.
2021-02-04 18:02:53 +01:00
a_bennassar
ca7fa8ae2e Merge pull request #523 from hermeznetwork/feature/pooll2tx-info
Add PoolL2Tx.Info about the status of the tx
2021-02-03 13:58:29 +01:00
arnaucube
a8f6891aea Add PoolL2Tx.Info about the status of the tx
PoolL2Tx.Info contains information about the status & State of the
transaction. As for example, if the Tx has not been selected in the last
batch due not enough Balance at the Sender account, this reason would
appear at this parameter.
This will help the client (wallet, batchexplorer, etc) to reason why a
L2Tx is not selected in the forged batches.
2021-02-03 13:03:30 +01:00
Eduard S
0d34126a42 Merge pull request #524 from hermeznetwork/feature/swapProofB
Swap proof b vector
2021-02-03 12:34:36 +01:00
invocamanman
20efa9cfc5 swap proof b vector 2021-02-03 12:18:50 +01:00
arnau
7ce60f0200 Merge pull request #521 from hermeznetwork/feature/robuststatedb
Improve stateDB reliability
2021-02-03 11:03:28 +01:00
Eduard S
845fea42d3 Update go-merkletree dependency 2021-02-01 17:40:50 +01:00
Eduard S
8517e6afa0 Improve stateDB reliability
- Close StateDB when stopping the node
- Lock the StateDB when doing checkpoints to avoid multiple instances of
  oppening the pebble DB at the same time.
2021-02-01 16:59:12 +01:00
Eduard S
510d5c548c Merge pull request #520 from hermeznetwork/feature/txid-keccak256
Update TxID to use eth Keccak256
2021-02-01 16:33:37 +01:00
Alberto Elias
cea3af4291 Merge pull request #518 from hermeznetwork/fix/api-recommended-fee
Fix api resopnse format for recommended fee
2021-02-01 15:04:15 +00:00
arnaucube
c1cd37913f Update TxID to use eth Keccak256
- Update TxID to use eth Keccak256
- Added more tests to L2Tx TxID calculation to check compatibility with
js version from https://github.com/hermeznetwork/hermezjs/pull/57
2021-02-01 16:01:55 +01:00
Arnau B
dd1657847e Fix api resopnse format for recommended fee 2021-02-01 13:40:24 +01:00
arnau
f0886b3d2a Merge pull request #517 from hermeznetwork/feature/priceserrwarn
Update README
2021-02-01 12:28:36 +01:00
Eduard S
49610330c4 Update README 2021-02-01 12:24:24 +01:00
arnau
7559991f7f Merge pull request #516 from hermeznetwork/feature/priceserrwarn
Use Warn instead of Error on get prices error
2021-02-01 12:03:02 +01:00
arnau
c396820129 Merge pull request #515 from hermeznetwork/feature/updatecontracts
Update contracts and get verifiersLen from SC
2021-02-01 11:35:34 +01:00
Eduard S
e73499628c Use Warn instead of Error on get prices error 2021-02-01 11:19:10 +01:00
Eduard S
90fe98d15c Update contracts and get verifiersLen from SC 2021-01-29 17:46:14 +01:00
arnau
8cc23b9fb2 Merge pull request #513 from hermeznetwork/test/idx
Fix incorrect initial CurrentIdx in kvdb
2021-01-29 13:27:03 +01:00
Eduard S
bc831af6a8 Merge pull request #504 from hermeznetwork/feature/txsel-checkenoughbalance
Check enough funds on sender at TxSelector and don't include the tx in the selection
2021-01-29 13:17:48 +01:00
arnaucube
bffc0d08ae Check enough funds on sender on TxProc &TxSel
- TxSelector
	- Add check enough funds on sender at TxSelector and don't
include the tx in the selection
- TxProcessor
	- Add checks that the balance when substracted the
amount/amount+fee never goes below 0

fix #502
2021-01-29 13:13:17 +01:00
Eduard S
d7c56afa5c Fix incorrect initial CurrentIdx in kvdb 2021-01-29 12:41:26 +01:00
Eduard S
30973aa292 Merge pull request #507 from hermeznetwork/feature/txid-fixcollisions
Feature/txid fixcollisions
2021-01-29 11:43:10 +01:00
arnaucube
aade6220d4 Update TxID to avoid collisions on DB (fix #503) 2021-01-29 11:38:22 +01:00
arnaucube
a899f43914 Add TokenID to L2Tx
L2Tx.TokenID is not on the data obtained by the Synchronizer from the
blockchain, but is set by the TxProcessor when processing the
transactions in the StateDB.
2021-01-27 12:40:09 +01:00
Pedro Sousa Grilo
f3678e8cb8 Merge pull request #496 from hermeznetwork/feature/integration
run integration on push to master
2021-01-22 14:44:59 +00:00
Pedro grilo
1e7f903cf9 Add action to trigger tests in integration-testing 2021-01-22 11:59:37 +01:00
arnau
733ffb6399 Merge pull request #500 from hermeznetwork/fix/exitnonces1
Fix exit tree nonces
2021-01-22 10:10:32 +01:00
Eduard S
1772422803 Fix exit tree nonces
Remove increment in exit tree leaf nonce when there are multiple exits for the
same account in the same batch.

Add a test to verify the correct implementation of exit leafs caused by
multiple exits.
2021-01-21 17:06:59 +01:00
arnau
3801d0bee6 Merge pull request #498 from hermeznetwork/feature/update-txman
Update coordinator to work better under real net
2021-01-20 17:33:57 +01:00
Eduard S
70482605c4 Update coordinator to work better under real net
- cli / node
    - Update handler of SIGINT so that after 3 SIGINTs, the process terminates
      unconditionally
- coordinator
    - Store stats without pointer
    - In all functions that send a variable via channel, check for context done
      to avoid deadlock (due to no process reading from the channel, which has
      no queue) when the node is stopped.
    - Abstract `canForge` so that it can be used outside of the `Coordinator`
    - In `canForge` check the blockNumber in current and next slot.
    - Update tests due to smart contract changes in slot handling, and minimum
      bid defaults
    - TxManager
        - Add consts, vars and stats to allow evaluating `canForge`
        - Add `canForge` method (not used yet)
        - Store batch and nonces status (last success and last pending)
        - Track nonces internally instead of relying on the ethereum node (this
          is required to work with ganache when there are pending txs)
        - Handle the (common) case of the receipt not being found after the tx
          is sent.
        - Don't start the main loop until we get an initial messae fo the stats
          and vars (so that in the loop the stats and vars are set to
          synchronizer values)
- eth / ethereum client
    - Add necessary methods to create the auth object for transactions manually
      so that we can set the nonce, gas price, gas limit, etc manually
    - Update `RollupForgeBatch` to take an auth object as input (so that the
      coordinator can set parameters manually)
- synchronizer
    - In stats, add `NextSlot`
2021-01-20 17:29:02 +01:00
Eduard S
eaca2f4f21 Merge pull request #499 from hermeznetwork/feature/fixexitinfos
Feature/fixexitinfos
2021-01-20 16:46:12 +01:00