Commit Graph

94 Commits

Author SHA1 Message Date
Eduard S
54562c0367 Implement CalcFeeAmount, Resolve #140 2020-10-21 12:25:15 +02:00
arnau
edb466c996 Merge pull request #208 from hermeznetwork/feature/debugapi
Extend statedb and use prefixes, add debugapi
2020-10-21 11:39:42 +02:00
arnaucube
e89f89102c Add L1 Queues system for tx generation in Trnskcio 2020-10-20 17:43:57 +02:00
Eduard S
44c70dfbcb Replace cp -r in StateDB by checkpoints, Resolve #93 2020-10-20 14:52:46 +02:00
Eduard S
88ddbbcddc Delete tmp folders from tests, Resolve #105 2020-10-20 13:13:10 +02:00
Eduard S
96ceb014bf Implement an eficient memory storage, Resolve #120 2020-10-20 13:13:05 +02:00
Eduard S
6afbda5302 Extend statedb and use prefixes, add debugapi
In statedb:
- Store all values using prefixes for keys to allow iteration
- Add methods MTGetRoot, GetAccounts

Implement debugapi, an http server with debugging endpoints:
- debugAPI.GET("sdb/batchnum", a.handleCurrentBatch)
- debugAPI.GET("sdb/mtroot", a.handleMTRoot)
- debugAPI.GET("sdb/accounts", a.handleAccounts)
- debugAPI.GET("sdb/accounts/:Idx", a.handleAccount)
2020-10-19 13:53:39 +02:00
arnaucube
a6006ebde7 Add transakcio Token Register instructions parser 2020-10-15 18:06:11 +02:00
arnaucube
17ff917a20 Add transakcio coordinator tx instruction feature
Transakcio:
- Transaction generation to fail when Transfer to an account that don't exist (not created yet)
- Add CreateAccountDepositCoordinator instruction feature
- Updated lang.go instruction type parser approach for more simplicity of code
- Remove `*testing.T` from transactions generation methods, use `log.Fatal` instead
2020-10-14 17:17:28 +02:00
arnaucube
1a2f769b5d Add TxSel Nonce sort. Fix surplus from refactors
- Add TxSel Nonce sort
- Fix surplus from refactors
- StateDB reuse computation of ToIdx across Synchronizer, TxSelector,
BatchBuilder
2020-10-14 11:38:40 +02:00
arnaucube
431df55120 Add transakcio set type define, add set load [...]
Add transakcio set type definition, add set loading, move transakcio to
package, adapt branch to last master updates (fix compile due new common
types & git conflicts).
Update tests to pass the test, pending to adapt to new Transakcio
interface.
2020-10-09 20:00:43 +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
a_bennassar
49366e3fa4 Feature/null refactor (#173)
* WIP: rebase

* Make nullable fields use pointers
2020-10-06 10:34:49 +02:00
arnaucube
3374a4754d Add StateDB compute nonces on ProcessTx L2Tx
Add StateDB compute nonces on ProcessTx L2Tx, and update StateDB for
type TypeSynchronizer, TypeTxSelector, TypeBatchBuilder
2020-10-02 11:54:58 +02:00
arnaucube
11c45cfc2f Update TxProcessor L2Tx logic for case ToIdx==0 2020-10-01 10:47:44 +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
a_bennassar
0c9a6e3f2d Merge pull request #150 from hermeznetwork/feature/historydb-sync2
Helper methods for Synchronizer and TX refactor
2020-09-23 18:22:07 +02:00
ToniRamirezM
ac677694fe Helper methods for Synchronizer and TX refactor 2020-09-23 17:05:38 +02:00
arnaucube
06703aecad Idx to 6 bytes (48 bits) 2020-09-22 18:01:14 +02:00
arnaucube
5d6f8cd3ec Add TxSelector L2Tx filtering logic 2020-09-22 13:31:48 +02:00
arnaucube
934b6120ae Add StateDB set & get Idx by EthAddr & BJJ methods 2020-09-21 22:02:20 +02:00
Eduard S
9f83fcf520 Review synchronizer, rearange some stuff, add notes and TODOs. 2020-09-21 14:33:07 +02:00
arnaucube
41715e47ba TxSel integrated with L2DB, Add L1CoordTx creation
- GetL2TxSelection & GetL1L2TxSelection integrated with dbs
- Create L1CoordinatorTx of type CreateAccountDeposit when a L2
requires it (and the AccountCreationAuth exists)
2020-09-16 12:40:56 +02:00
arnaucube
69fe471f11 Add StateTree leafs & ExtTree data ZKI calculation 2020-09-10 17:58:08 +02:00
arnaucube
aa0bde61d2 Add StateDB ZKInputs generation for L1 & L2 Txs 2020-09-09 14:40:55 +02:00
arnaucube
b1454d441c StateDB intermediate state reset when opening DB
StateDB intermediate state reset when opening DB to force getting always last
Checkpoint at last BatchNum, avoiding inconsistent intermediate state.
2020-09-07 12:19:15 +02:00
arnaucube
fdaf2c9ce2 Update log package with fields & file log
Update log package with fields & file log, and update constants in the
repository code to be MixedCase.

resolves #91, resolves #92, resolves #95
2020-09-02 10:56:48 +02:00
arnaucube
cbbcb65c8c Add lint checks: gofmt, goimports, golint
- gofmt - Gofmt checks whether code was gofmt-ed. By default this tool runs
  with -s option to check for code simplification
- goimports - Goimports does everything that gofmt does. Additionally it checks
  unused imports
- golint - Golint differs from gofmt. Gofmt reformats Go source code, whereas
  golint prints out style mistakes
    - checks the uncommented exported functions & types

Update the code to fix the lint checks.
2020-08-31 12:32:05 +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
arnaucube
9309722dfc Update StateDB to new & ExitInfo struct & BatchNum
Update StateDB to new & ExitInfo struct & BatchNum
Also a small fix at txselector & log packages
2020-08-26 18:28:53 +02:00
arnaucube
be95de18fc Add StateDB txprocessor tests using txtest generators
Add StateDB tx processor tests using tx test generators:
- update statedb/ tx processors
- add statedb tx processors tests
2020-08-25 19:28:33 +02:00
arnaucube
0d2004721c Add statedb ExitTree implementation 2020-08-25 12:09:49 +02:00
arnaucube
b4044a2ef7 Add abstraction method of processTxs to StateDB
- Update GHA lint.yml increasing timeout time to avoid GHA Lint errors
- Update common.BatchNum & common.Idx & common.Nonce usage in StateDB
- Add abstraction method of processTxs to StateDB
    - Which will be used by Synchronizer & BatchBuilder
2020-08-24 13:06:51 +02:00
arnaucube
12aa31e46b Unify StateDB MT{Create/Update}Account
Previously as the txprocessor.go methods were specific for the BatchBuilder,
the MTCreateAccount & CreateAccount and MTUpdateAccount & UpdateAccount were
also designed to be used by BatchBuilder and TxSelector depending on the
MerkleTree usage calling one kind of method or anotherone.

But now that this methods are being called directly by the StateDB (through the
methods in txprocessors.go), to allow also the methods usage from the
Synchronizer, there can not be the MT and no-MT methods separated, so this
commit unifies MTCreateAccount with CreateAccount, and MTUpdateAccount with
UpdateAccount, which internally will update the MerkleTree depending if the
specific StateDB in usage has the MerkleTree defined or not.
2020-08-20 15:53:16 +02:00
arnaucube
cfa441e1ac Migrate TxProcessors from BatchBuilder to StateDB
Migrate TxProcessors from BatchBuilder to StateDB in order to be used by
BatchBuilder & Synchronizer
2020-08-20 12:06:28 +02:00
arnaucube
aa003063f6 Update BatchBuilder & TxSelector to new StateDB 2020-08-17 13:38:48 +02:00
arnaucube
205db8e4d3 Implement StateDB Checkpoints & Resets system 2020-08-17 11:27:33 +02:00
arnaucube
a1c339c918 Add BatchQueue implementation & minor updates 2020-08-13 18:25:50 +02:00
arnaucube
60fa76b4d2 Integrate TxSelector with StateDB 2020-08-13 13:07:30 +02:00
arnau
edb8974a5a Apply fix method description typos
Co-authored-by: Eduard S. <eduard@iden3.io>
2020-08-10 16:46:15 +02:00
arnaucube
d8cb7298e0 Add StateDB & LocalStateDB 2020-08-07 10:59:30 +02:00