Commit Graph

38 Commits

Author SHA1 Message Date
Eduard S
558de2737e Test L2Txs, ExitTree in synchronizer 2020-10-27 17:59:18 +01:00
laisolizq
bc34f3456b API Update tokens endpoint 2020-10-27 13:23:01 +01:00
a_bennassar
b320069e75 Merge pull request #229 from hermeznetwork/feature/api-getstate
Add struct get state endpoint
2020-10-27 12:30:40 +01:00
laisolizq
82ee7c6aa7 Add struct get state endpoint 2020-10-27 12:27:04 +01:00
Eduard S
b5222303c2 Update Synchroinzer and tests
- Test L1UserTxs in Synchronizer
- Test Batches in Synchronizer
- Add last_idx in `TABLE batch` in HistoryDB
- Minor updates in til to satisfy blockchain constraints
2020-10-26 16:22:40 +01:00
Arnau B
28c0164525 Impl api get batch(es) 2020-10-26 12:42:05 +01:00
Arnau B
7c8f380637 Add apitypes to avoid parsing from/to DB 2020-10-26 12:41:55 +01:00
Eduard S
4dbfedee49 In til, process L1UserTxs when defined, not in batch 2020-10-22 16:13:57 +02:00
Eduard S
827e917fa0 Update missing parts, improve til, and more
- Node
	- Updated configuration to initialize the interface to all the smart
	  contracts
- Common
	- Moved BlockData and BatchData types to common so that they can be
	  shared among: historydb, til and synchronizer
	- Remove hash.go (it was never used)
	- Remove slot.go (it was never used)
	- Remove smartcontractparams.go (it was never used, and appropriate
	  structs are defined in `eth/`)
	- Comment state / status method until requirements of this method are
	  properly defined, and move it to Synchronizer
- Synchronizer
	- Simplify `Sync` routine to only sync one block per call, and return
	  useful information.
	- Use BlockData and BatchData from common
	- Check that events belong to the expected block hash
	- In L1Batch, query L1UserTxs from HistoryDB
	- Fill ERC20 token information
	- Test AddTokens with test.Client
- HistryDB
	- Use BlockData and BatchData from common
	- Add `GetAllTokens` method
	- Uncomment and update GetL1UserTxs (with corresponding tests)
- Til
	- Rename all instances of RegisterToken to AddToken (to follow the smart
	  contract implementation naming)
	- Use BlockData and BatchData from common
		- Move testL1CoordinatorTxs and testL2Txs to a separate struct
		  from BatchData in Context
	- Start Context with BatchNum = 1 (which the protocol defines to be the
	  first batchNum)
	- In every Batch, set StateRoot and ExitRoot to a non-nil big.Int
	  (zero).
	- In all L1Txs, if LoadAmount is not used, set it to 0; if Amount is not
	  used, set it to 0; so that no *big.Int is nil.
	- In L1UserTx, don't set BatchNum, because when L1UserTxs are created
	  and obtained by the synchronizer, the BatchNum is not known yet (it's
	  a synchronizer job to set it)
	- In L1UserTxs, set `UserOrigin` and set `ToForgeL1TxsNum`.
2020-10-22 15:20:51 +02:00
Eduard S
24bca9e3b0 Merge pull request #216 from hermeznetwork/feature/batch-total-fee
Calulate total collected batch fee and fix merkleproof api format
2020-10-22 14:28:49 +02:00
ToniRamirezM
f314498a26 Coordinators methods for API 2020-10-22 13:29:38 +02:00
Arnau B
f77ea04c2e Calulate total collected batch fee and fix merkleproof api format 2020-10-22 12:59:15 +02:00
Arnau B
006bbf3321 Implement tx pool endpoints 2020-10-21 16:34:54 +02:00
laisolizq
043710112d Add get tokens endpoint 2020-10-19 10:14:18 +02:00
laisolizq
63a4f3c8b6 Add get token endpoint 2020-10-15 14:25:04 +02:00
Arnau B
fe7d38843e Impls exit endpoints and change pagination to cursor 2020-10-14 10:06:28 +02:00
Arnau B
5097939b12 Avoid using pointers in common 2020-10-08 16:42:16 +02:00
Eduard S
b14495cfcc Replace all []*Foo by []Foo in sql db return values
- Implement SlicePtrsToSlice and use it in all `meddler.QueryAll` sql db functions to always return []Foo instead of []*Foo
2020-10-07 17:03:39 +02:00
Eduard S
0277210c39 Extend ethclient test, implement new TxID spec
- Implement new TxID spec that distinguishes L1UserTx and L1CoordinatorTx
- Replace some type []*Foo by []Foo
- Fix HistoryDB & L2DB bug: in case of error, a rollback was applied and the returned error was nil
- Reorder inserts in historydb.NewHistoryDB() to follow foreign key dependencies
- Add initial synchronizer test with test.Client (for now, only tested l1UserTxs, blocks, addToken)
- Update L1UserTx event in test.Client
2020-10-07 16:41:51 +02:00
Eduard S
1a85f15d27 Fix conflicts and update dependencies of ethclient 2020-10-06 18:16:59 +02:00
a_bennassar
49366e3fa4 Feature/null refactor (#173)
* WIP: rebase

* Make nullable fields use pointers
2020-10-06 10:34:49 +02:00
Arnau B
f653ff8a73 Connect price updater to historydb 2020-10-02 10:13:48 +02:00
arnaucube
9bb4a4ec1b Add TxID calculation & New{Layer}Tx Type
Add TxID calculation & New{Layer}Tx Type

New{Layer}Tx methods that compute the `TxID` & `TxType` values from the
transaction values:
- NewL1Tx
- NewL2Tx
- NewPoolL2Tx

Add TxID Scanner & Valuer for database/sql

HistoryDB & L2DB & API packages tests will need to be addapted to the
TestTransaction generation once is done.
2020-09-30 15:37:13 +02:00
a_bennassar
c6f70f3177 Feature/merge history l2 tables (#156)
* WIP rebase

* Combine both SQL DBs

* API and DB refactor
2020-09-29 18:27:07 +02:00
ToniRamirezM
ac677694fe Helper methods for Synchronizer and TX refactor 2020-09-23 17:05:38 +02:00
Arnau B
85fe885265 Add GET histroy-transactions endpoint 2020-09-22 13:21:28 +02:00
Eduard S
35a558f6c9 Merge pull request #135 from hermeznetwork/feature/synchronizer-sc
Smart Contracts Data Synchronization
2020-09-21 14:40:10 +02:00
Eduard S
9f83fcf520 Review synchronizer, rearange some stuff, add notes and TODOs. 2020-09-21 14:33:07 +02:00
Eduard S
d3f6da22ed Fix sync integration with StateDB & HistoryDB 2020-09-18 12:10:39 +02:00
Arnau B
94e1f11a98 Implement L2DB 2020-09-18 10:17:51 +02:00
a_bennassar
8a21cd1b5c Add HistoryDB SQL triggers (#125) 2020-09-17 11:57:42 +02:00
Eduard S
56604ecc69 Use int64 for blockNum (like it's sroted in DB) 2020-09-07 18:09:27 +02:00
arnaucube
fd1e9c25ee Add linter checks to GHA & Fix code to pass lints
Add linter checks to GHA & Fix code to pass lints.
The linters added are:
- whitespace: Tool for detection of leading and trailing whitespace
- gosec: Inspects source code for security problems
- gci: Gci control golang package import order and make it always deterministic
- misspell: Finds commonly misspelled English words in comments
- gomnd: An analyzer to detect magic numbers

The file utils/utils.go is excluded from the checks of gomnd, as uses magic numbers through the code
2020-08-28 09:58:39 +02:00
Arnau B
3e7173b1da Impl historyDB methods for sync main loop 2020-08-26 14:31:24 +02:00
Arnau B
c108739c24 Add usefull methods for reorg 2020-08-25 14:15:12 +02:00
Arnau B
1cbf54acc7 Add sync interface 2020-08-25 14:14:51 +02:00
a_bennassar
cb1b820256 Update SQL schemas 2020-08-17 16:16:17 +02:00
a_bennassar
428dcd7590 create sql tables (#40)
Co-authored-by: Eduard S <eduard@iden3.io>
2020-08-11 16:25:55 +02:00