Commit Graph

485 Commits

Author SHA1 Message Date
arnaucube
cf199fd832 Fix ZKI NTx for MaxTx
On the Circuits uses the name `nTx` (and on the tests `maxTx`), but
Contracts `maxTx`. On Go we had both variables, but really only used
one, now at Go we use `MaxTx` to refer to the maximum number of
transactions.
2020-12-28 11:26:47 +01:00
arnau
cbcd387f98 Merge pull request #423 from hermeznetwork/feature/integration27
Delete old checkpoints in stateDB automatically & Don't log errors when context done
2020-12-28 11:15:00 +01:00
Eduard S
a0c8ace38d Add missing tracerr.Wrap 2020-12-24 13:39:27 +01:00
Eduard S
2205fcadbc Delete old checkpoints in stateDB automatically
Introduce a constructor parameter for the StateDB called `keep`, which tells
how many checkpoints to keep.  When doing a new checkpoint, if the number of
existing checkpoints exeeds `keep`, the oldest ones will be deleted.
2020-12-24 13:35:47 +01:00
Eduard S
1b55296006 Merge pull request #420 from hermeznetwork/feature/txsel-accauths
TxSel return of AccCreatAuths from the selection
2020-12-24 11:07:02 +01:00
Eduard S
6a2b9474e3 Merge pull request #416 from hermeznetwork/feature/update-accountcreationauth
Update AccountCreationAuth & fix auth.HashToSign
2020-12-24 10:50:18 +01:00
arnaucube
8615a462ab Update AccountCreationAuth & fix auth.HashToSign
- Fix AccountCreationAuth.HashToSign (was using `[]byte("0x...")`, which
uses the bytes of the string. Now uses the bytearray of the compressed
BJJ public key (compatible with js implementation))
- Update AccountCreationAuth to last specification (add to hash
parameters ChainID & HermezAddress)
- Add missing test to AccountCreationAuth
2020-12-24 10:41:35 +01:00
arnaucube
6413011294 TxSel return of AccCreatAuths from the selection
Add return of AccountCreationAuths at the TxSelector, which is an array
of bytearrays with the signatures of the AccountCreationAuthorization of
the accounts of the users created by the Coordinator with
L1CoordinatorTxs of those accounts that does not exist yet but there is
a transactions to them and the authorization of account creation exists.
2020-12-24 10:34:41 +01:00
arnau
e787651ba3 Merge pull request #414 from hermeznetwork/feature/syncforgercommitment
Sync ForgerCommitment and use it in coord
2020-12-24 10:31:58 +01:00
Eduard S
35d598f564 Don't log errors when context done 2020-12-23 17:33:41 +01:00
Eduard S
8267d007c9 Sync ForgerCommitment and use it in coord
Previously the coordinator was erroneously using Slot.BatchesLen to determine
when anyone can forge.  The correct behaviour is implmenented with the boolean
flag `ForgerCommitment`, that is set to true only when there's a batch before
the deadline within a slot.

Delete Slot.BatchesLen, and the synchronization code of this value from the
Synchronizer, as this is not needed
2020-12-23 17:06:20 +01:00
Eduard S
cd6eb44c16 Merge pull request #413 from hermeznetwork/feature/parametrize-chainid
Parametrize ChainID
2020-12-23 16:35:39 +01:00
Eduard S
086dc85104 Get ChainID from ethereum node 2020-12-23 16:26:56 +01:00
arnaucube
150597c282 Parametrize ChainID 2020-12-23 15:23:48 +01:00
Eduard S
adc044001f Merge pull request #412 from hermeznetwork/fix/sdb-nonce
Fix StateDB & Til Nonce increment
2020-12-23 12:47:40 +01:00
arnaucube
eea44b3990 Fix StateDB & Til Nonce increment 2020-12-23 12:32:41 +01:00
Eduard S
fb48ca4e58 Merge pull request #411 from hermeznetwork/feature/forged-txs-in-batchesapi
Add forged txs in batch endpoints response
2020-12-23 12:07:45 +01:00
Eduard S
4793a20727 Merge pull request #408 from hermeznetwork/feature/txsel-update-processinglogic
TxSelector update txs processing logic
2020-12-23 11:48:06 +01:00
arnaucube
982a423bf3 TxSelector update txs processing logic 2020-12-23 11:36:41 +01:00
Arnau B
6e7f860d61 Add forged txs in batch endpoints response 2020-12-23 11:26:23 +01:00
arnau
3cf615a769 Merge pull request #406 from hermeznetwork/feature/implforgebatchargs
Implement Pipeline.prepareForgeBatchArgs()
2020-12-23 11:22:28 +01:00
Eduard S
8d5b375625 Merge pull request #407 from hermeznetwork/fix/api-coordinator
Add bootCoord to coord table, get coord by forgerAddr
2020-12-23 11:10:23 +01:00
arnaucube
2583d35adf Update ZKInputs for empty batches
- Add TestZKInputsEmpty circom test vectors
- Fix ZKInputsHash OldLastIdx bytearray
2020-12-23 11:09:43 +01:00
Arnau B
bc5fa92898 Add bootCoord to coord table, get coord by forgerAddr 2020-12-23 11:03:21 +01:00
Eduard S
cd1a193dcd Merge pull request #405 from hermeznetwork/fix/api-nonce
Fix API nonces
2020-12-22 17:43:24 +01:00
Eduard S
a50bda3f59 Update packr dependency
Update packr to 2.8.1 which fixes this issue:
https://github.com/gobuffalo/packr/issues/261 which I encountered while running
a test with `-race`
2020-12-22 17:27:38 +01:00
Eduard S
6a990376b4 Implement Pipeline.prepareForgeBatchArgs()
- Implement Pipeline.prepareForgeBatchArgs()
- Add a minimal stress test for the coordinator (that also runs the
  synchronizer)
- Update txprocessor.ProcessTxs() to return valid results for batches without
  transactions
  	- Add the boilerplate for the corresponding test, leaving as TODO the
	  zkInput values
- Update prover client to use the same point format as proof server (projective)
- Update interface of TxSelector.GetCoordIdxs to also return the authorizations
  to create accounts that go with the l1CoordinatorTxs.
2020-12-22 17:27:34 +01:00
arnau
c61c4f3376 Merge pull request #402 from hermeznetwork/feature/testpurger
Test purger, fix some nonces
2020-12-22 17:15:16 +01:00
Arnau B
a7394cdb2a Fix API nonces 2020-12-22 16:36:51 +01:00
Eduard S
a8ac35059a Test purger, fix some nonces
- Test all the purger functions
- Fix nonces set by til (previously til started with nonce 1 for pool l2txs,
  but the correct implementation is to start with nonce 0)
- Rename L2DB.CheckNonces to L2DB.invalidateOldNoncesQuery
- Rename L2DB.checkNoncesQuery to L2DB.InvalidateOldNonces

Related https://github.com/hermeznetwork/hermez-node/issues/392 (Fix checkNoncesQuery)
Resolve https://github.com/hermeznetwork/hermez-node/issues/396
2020-12-22 12:00:12 +01:00
a_bennassar
8a2df8de0d Merge pull request #390 from hermeznetwork/feature/bjj-comp
Feature/bjj comp
2020-12-22 11:44:19 +01:00
arnaucube
4b10549822 mv of babyjub.PublicKey to babyjub.PublicKeyComp
Update usage of `*babyjub.PublicKey` to `babyjub.PublicKeyComp`
- when the key is not defined, internally is used `babyjub.EmptyBJJComp`, which is a `[32]byte` of zeroes of type `babyjub.PublicKeyComp`
- the API continues returning `nil` when the key is not defined
2020-12-22 11:29:47 +01:00
a_bennassar
0401ff6180 Merge pull request #385 from hermeznetwork/feature/integratepriceupdater
Update and integrate price updater
2020-12-21 09:56:07 +01:00
arnau
b9943182b8 Merge pull request #383 from hermeznetwork/feature/initvars
Use init SC vars and start block from events
2020-12-18 20:26:41 +01:00
Eduard S
92e34fb683 Merge pull request #387 from hermeznetwork/feature/fix-get-best-bid-coord
Fix historyDB GetBestBidCoordinator
2020-12-18 17:53:34 +01:00
laisolizq
bc29222341 Fix historyDB GetBestBidCoordinator 2020-12-18 17:47:41 +01:00
Eduard S
56fffdcee5 Update and integrate price updater
PriceUpdater:
    - Pass context so that it can be canceled during an update loop
    - Define APITypes to make it explicit which API we are using
2020-12-18 17:19:53 +01:00
Eduard S
b1a8384f27 Run go-instrument-errors to wrap errors 2020-12-18 13:39:42 +01:00
Eduard S
b59f790c04 Use init SC vars and start block from events
Previously the Synchronizer required the initial variables of the smart
contracts to be passed as a configuration parameter (that the node took from
the configuration file).  The same applied to the blockNumber.

The last update of the smart contracts introduced events for each smart
contract constructor (initializer), which allows querying the initial variables
as well as the initial block number for each smart contract.

Now the synchronizer uses this information, and thus the initial variables and
the starting block numbers have been removed from the configuration.
2020-12-18 13:39:06 +01:00
laisolizq
0bde608a1b Merge pull request #380 from hermeznetwork/feature/upgradecontracts
Upgrade contracts and parse init events
2020-12-18 11:28:40 +01:00
Eduard S
ac400bad77 Upgrade contracts and parse init events 2020-12-18 11:19:02 +01:00
Eduard S
d649dd3395 Merge pull request #379 from hermeznetwork/feature/upd-effamounts
Effective amounts add missing check
2020-12-17 18:18:21 +01:00
arnaucube
0bcf57603c Effective amounts add missing checks 2020-12-17 17:51:23 +01:00
Eduard S
cae69acecb Merge pull request #373 from hermeznetwork/feature/txsel-coordidx
TxSelector add CoordIdxDB, SelectionConfig, abstract filtering
2020-12-17 17:02:51 +01:00
arnaucube
004f852b44 TxSelector add CoordIdxDB, SelectionConfig, abstract filtering
TxTypeToEthAddr & TxTypeToBJJ

- TxSelector
	- Add SelectionConfig for each batch
	- Add CoordIdxDB key-value where the CoordinatorIdxs are stored
	- Separated method for filtering TxTypeToEthAddr & TxTypeToBJJ
2020-12-17 16:46:23 +01:00
a_bennassar
6ac033bdd6 Merge pull request #372 from hermeznetwork/feature/fixtxsorder
Fix order of L1UserTxs
2020-12-17 15:54:05 +01:00
Eduard S
8a59296cb8 Fix order of L1UserTxs
When the synchronizer queries the unforged L1UserTxs, sort them by position

Swap the order of calls setL1UserTxEffectiveAmounts and addBatch in
AddBlockSCData because otherwise, for reasons I dont understand, the item_id of
the txs doesn't follow the position of the txs.
2020-12-17 15:48:01 +01:00
arnau
8838bd62f9 Merge pull request #371 from hermeznetwork/feature/fixpanic1
Fix panic caused by nil batchInfo.ServerProof
2020-12-17 15:12:03 +01:00
Eduard S
7f0d2dfd43 Fix panic caused by nil batchInfo.ServerProof 2020-12-17 13:50:04 +01:00
Eduard S
a3d0765644 Merge pull request #370 from hermeznetwork/fix/pipeline-call
Fix coordinator pipeline forgeBatch call
2020-12-17 13:20:29 +01:00