Commit Graph

147 Commits

Author SHA1 Message Date
arnaucube
7af6371f1d ZKInputs update:
- Add ZKInputs parser to JSON
- Update ProcessTxs to last go-merkletree version changes
- Add StateDB test to generate ZKInputs to check inside a circom circuit
- Small fix at Til CoordinatorTx.LoadAmount=0
2020-11-04 16:40:55 +01:00
Eduard S
6e4b9b4b70 Update Synchronizer (node) implementation
- node:
    - Extend config to add initial variables of the smart contracts used as
      defaults before they are changed via events.
    - In stopped channels, set size 1 so that panics are not witheld until the
      node stops completely.
- common:
    - In Smart Contract variables, comment:
      - `WDelayerVariables.HermezRollupAddress` because it's not needed.
      - `RollupVariables.Buckets` because there are no events for it, and for
        now it's not used.
- historydb:
    - Add functions to get and set smart contract variables.
- db:
    - Add `Rollback` function in `utils.go` to reduce boilerplate in sql
      transaction rollbacks in defers in db functions.
    - Update `rollup_vars` and `auction_vars` (renamed from `consensus_vars`)
      table, and add `wdelayer_vars` table.
- synchronizer:
    - Synchronize WDelayer
    - Handle SC variables properly
- test/ethclient:
    - Add essential implementation of WDelayer
2020-11-04 15:12:51 +01:00
Eduard S
e6fb0a03de Reorganize smart contract types, udate eth tests, etc.
- Move smart contract constants and structs for variables to
  common/{ethrollup.go, ethauction.go, ethwdelayer.go}:
    - This removes repeated code of the structs for variables
    - Allows reusing the constants and variables from all modules without
      import cycles
- Remove unused common/scvars.go
- In common.BlockData, split data from each smart contract into a sepparate
  field (Rollup, Auction, WDelayer).  This affects the structures that til uses
  as output, and HistoryDB in the AddBlockSCData.
- In Synchronizer:
    - Pass starting block of each smart contract as config, instead of
      incorrectly using the genesis block found in the acution constant (which
      has a very different meaning)
    - Use variable structs from common instead of an internal copy
    - Synchronize more stuff (resolve some TODOs)
    - Fix some issues found after initial testing with ganache
- In eth:
    - In auction.go: Add method to get constants
    - Update README to use ganache instead of buidlerevm as local blockchain
      for testing
    - Update env variables and test vectors to pass the tests with the
      deployment in the ganache testnet.
    - Use ethereum keys derived from paths (hdwallet) in testing to avoid
      hardcoding private keys and generate the same keys from a mnemonic used
      in the ganache tesnet.
2020-11-04 12:06:28 +01:00
Eduard S
fe23361037 Update fee tables 2020-11-03 11:26:23 +01:00
arnaucube
2338b6b90b ProcessTxs fees collct update & tests, and other:
- Update StateDB ProcessTxs fees collection
- Update ProcessTxs tests to last StateDB & Til changes
- Til Blockchain L2Txs remove Nonce generation, update tests accordingly
- Update Til Set to test fees
2020-10-28 17:21:12 +01:00
Eduard S
558de2737e Test L2Txs, ExitTree in synchronizer 2020-10-27 17:59:18 +01:00
arnaucube
1203ab3865 TxSelector include L1CoordinatorTxs in selections 2020-10-27 17:25:41 +01:00
arnaucube
8f24aa93c9 Add ProcessTxs send fees to Coordinator accounts 2020-10-27 10:28:32 +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
7c8f380637 Add apitypes to avoid parsing from/to DB 2020-10-26 12:41:55 +01:00
Arnau B
ede6c33a18 Impl account creation auth endpoints 2020-10-23 13:05:20 +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
Arnau B
f77ea04c2e Calulate total collected batch fee and fix merkleproof api format 2020-10-22 12:59:15 +02:00
arnaucube
34de6412cf Update Til with small fixes [...]
Update Til with small fixes:
- L2Tx TxID & Type correctness done after Idxs setted
- Added PoolL2Tx signature for Exit type

Common:
- Add common.TxID Marshalers test
2020-10-22 12:22:08 +02:00
Arnau B
006bbf3321 Implement tx pool endpoints 2020-10-21 16:34:54 +02:00
arnau
6a8b454368 Merge pull request #211 from hermeznetwork/feature/update-general
Feature/update general
2020-10-21 13:06:09 +02:00
Eduard S
54562c0367 Implement CalcFeeAmount, Resolve #140 2020-10-21 12:25:15 +02:00
Eduard S
a2bda1890d Simplify eth code 2020-10-21 11:56:55 +02:00
arnaucube
e89f89102c Add L1 Queues system for tx generation in Trnskcio 2020-10-20 17:43:57 +02:00
arnaucube
d7a1ba19b9 Fix PoolL2Tx.RqTxCompressedData 2020-10-14 18:30:58 +02:00
Eduard S
250f1aa119 Merge pull request #194 from hermeznetwork/feature/txsel-noncesorting0
Add TxSel Nonce sort. Fix surplus from refactors
2020-10-14 11:45:46 +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
arnau
c145147e6e Merge pull request #179 from hermeznetwork/feature/api-exits
Impl exit edpoint and refactor pagination
2020-10-14 11:16:03 +02:00
Arnau B
fe7d38843e Impls exit endpoints and change pagination to cursor 2020-10-14 10:06:28 +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
arnaucube
bdbbde47bf Fix PR #187
(#187 PR was done before another PR (#186) was merged into master, and
when 187 was merged to master, was not compiling due changes from #186
not applied yet to #187)
2020-10-09 12:36:02 +02:00
arnau
f142e23c45 Merge pull request #187 from hermeznetwork/feature/ethclient15-sc
Update ethclient rollup iteration 2
2020-10-09 12:17:06 +02:00
Arnau B
5097939b12 Avoid using pointers in common 2020-10-08 16:42:16 +02:00
laisolizq
1c54beca5a Update ethclient rollup iteration 2 2020-10-08 13:18:34 +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
laisolizq
202b98b3e6 Update ethclient contracts & rollup iteration 1 2020-10-06 12:15:16 +02:00
arnau
15a122a6a0 Merge pull request #178 from hermeznetwork/feature/codec-funcs
Add L1CoordTx & L2Tx byte parsers functions
2020-10-06 11:12:58 +02:00
a_bennassar
49366e3fa4 Feature/null refactor (#173)
* WIP: rebase

* Make nullable fields use pointers
2020-10-06 10:34:49 +02:00
laisolizq
aef6da38af Add codec functions 2020-10-05 17:00:10 +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
a_bennassar
c0336f485f Merge pull request #148 from hermeznetwork/feature/txsel-l2logic
Add TxSelector L2Tx filtering logic
2020-09-22 15:40:40 +02:00
Eduard S
b86d21902b Merge pull request #142 from hermeznetwork/feature/api-boilerplate
Add GET histroy-transactions endpoint
2020-09-22 15:39:13 +02:00
arnaucube
5d6f8cd3ec Add TxSelector L2Tx filtering logic 2020-09-22 13:31:48 +02:00
Arnau B
85fe885265 Add GET histroy-transactions endpoint 2020-09-22 13:21:28 +02:00
arnaucube
934b6120ae Add StateDB set & get Idx by EthAddr & BJJ methods 2020-09-21 22:02:20 +02:00
Eduard S
05b273cc00 Merge pull request #128 from hermeznetwork/feature/l1txbytes
Update common.L1Tx parsers, add test checks
2020-09-21 15:40:49 +02:00
arnaucube
3013fbacb6 Change endianness to BigEndian :(
Change endianness to BigEndian (ಥ﹏ಥ), spec has been updated to achieve
compatibility with js & smart contracts & circuits implementations.
2020-09-21 15:10:01 +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