Commit Graph

31 Commits

Author SHA1 Message Date
Arnau B
445f26ec9f Rename load amount to deposit amount 2020-12-04 16:13:41 +01:00
Eduard S
897d7d5319 Merge pull request #326 from hermeznetwork/feature/effective-amount-update
Feature/effective amount update
2020-12-04 12:33:30 +01:00
Arnau B
5fd258ee07 Use flags for effective amounts in SQL schema 2020-12-04 12:17:09 +01:00
laisolizq
75c6d8f14e Updates API to new changes 2020-12-04 11:22:12 +01:00
Eduard S
329d2796c6 Update some eth types, update eth dependencies to new changes 2020-12-03 18:05:33 +01:00
arnaucube
dde9250429 Update Common & StateDB & ZKInputs to last protocol version
- Add InvalidData flag to L1Tx
- Add BytesDataAvailability to L1Tx
- Update ZKInputs & HashGlobalInputs to last spec of the protocol
(massive migrations)
- TxProcessor check correctness of L1Txs

Compatible with hermeznetwork/commonjs v0.0.4
(c345239bba)
2020-11-30 11:26:15 +01:00
Eduard S
3b99953007 Redo coordinator structure, connect API to node
- API:
	- Modify the constructor so that hardcoded rollup constants don't need
	  to be passed (introduce a `Config` and use `configAPI` internally)
- Common:
	- Update rollup constants with proper *big.Int when required
	- Add BidCoordinator and Slot structs used by the HistoryDB and
	  Synchronizer.
	- Add helper methods to AuctionConstants
	- AuctionVariables: Add column `DefaultSlotSetBidSlotNum` (in the SQL
	  table: `default_slot_set_bid_slot_num`), which indicates at which
	  slotNum does the `DefaultSlotSetBid` specified starts applying.
- Config:
	- Move coordinator exclusive configuration from the node config to the
	  coordinator config
- Coordinator:
	- Reorganize the code towards having the goroutines started and stopped
	  from the coordinator itself instead of the node.
	- Remove all stop and stopped channels, and use context.Context and
	  sync.WaitGroup instead.
	- Remove BatchInfo setters and assing variables directly
	- In ServerProof and ServerProofPool use context instead stop channel.
	- Use message passing to notify the coordinator about sync updates and
	  reorgs
	- Introduce the Pipeline, which can be started and stopped by the
	  Coordinator
	- Introduce the TxManager, which manages ethereum transactions (the
	  TxManager is also in charge of making the forge call to the rollup
	  smart contract).  The TxManager keeps ethereum transactions and:
	  	1. Waits for the transaction to be accepted
		2. Waits for the transaction to be confirmed for N blocks
	- In forge logic, first prepare a batch and then wait for an available
	  server proof to have all work ready once the proof server is ready.
	- Remove the `isForgeSequence` method which was querying the smart
	  contract, and instead use notifications sent by the Synchronizer to
	  figure out if it's forging time.
	- Update test (which is a minimal test to manually see if the
	  coordinator starts)
- HistoryDB:
	- Add method to get the number of batches in a slot (used to detect when
	  a slot has passed the bid winner forging deadline)
	- Add method to get the best bid and associated coordinator of a slot
	  (used to detect the forgerAddress that can forge the slot)
- General:
	- Rename some instances of `currentBlock` to `lastBlock` to be more
	  clear.
- Node:
	- Connect the API to the node and call the methods to update cached
	  state when the sync advances blocks.
	- Call methods to update Coordinator state when the sync advances blocks
	  and finds reorgs.
- Synchronizer:
	- Add Auction field in the Stats, which contain the current slot with
	  info about highest bidder and other related info required to know who
	  can forge in the current block.
	- Better organization of cached state:
		- On Sync, update the internal cached state
		- On Init or Reorg, load the state from HistoryDB into the
		  internal cached state.
2020-11-24 18:59:30 +01:00
Eduard S
738fa0ac30 Update SQL types, improve SQL *big.Int
- In SQL Tables, set rollup_vars.forge_l1_timeout to BIGINT (instead of BYTEA)
- In "bigint" encoding/decoding used with meddler, store the *big.Int as raw
  bytes, instead of base64 to be more space efficient
2020-11-18 13:26:46 +01:00
Arnau B
ce1218e28a Integrate til into api 2020-11-17 17:50:07 +01:00
Eduard S
e731b79e96 Fix exit table, set delayed_withdrawn in exits
- In exit table, `instant_withdrawn`, `delayed_withdraw_request`, and
  `delayed_withdrawn` were referencing batch_num.  But these actions happen
  outside a batch, so they should reference a block_num.
- Process delayed withdrawns:
    - In Synchronizer, first match a Rollup delayed withdrawn request, with the
      WDelayer deposit (via TxHash), and store the owner and token associated
      with the delayed withdrawn.
    - In HistoryDB: store the owner and token of a delayed withdrawal request
      in the exit_tree, and set delayed_withdrawn when the withdraw is done in
      the WDelayer.
- Update dependency of sqlx to master
    - Last release of sqlx is from 2018 October, and it doesn't support
      `NamedQuery` with a slice of structs, which is used in this commit.
2020-11-13 16:53:16 +01:00
arnau
8cc165f562 Merge pull request #275 from hermeznetwork/feature/api-db-tests-til
Feature/api db tests til
2020-11-11 15:54:41 +01:00
Arnau B
bed25d424a Use til for batches and blocks at historydb 2020-11-11 14:00:19 +01:00
laisolizq
43e9bee9db API state endpoint test 2020-11-10 13:47:18 +01:00
arnau
fd9b247120 Merge pull request #261 from hermeznetwork/feature/til-extra
Move logic to extend til blocks to til
2020-11-06 11:46:49 +01:00
ToniRamirezM
b840ceb57a Account API 2020-11-06 09:30:32 +01:00
Eduard S
5ebf46e045 Move logic to extend til blocks to til
Previously, the synchronizer test was extending the output from til to
precalculate many fields to compare it with the synchronizer and BD output.
Since this is useful outside of the syncrhonizer testing: move this
functionality to til via a function that extends the output
(til.Context.FillBlocksExtra).

Also, add new functionality: calculate fee idxs dynamically by setting a user
name, and calculate collected fees.
2020-11-05 18:09:12 +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
fe23361037 Update fee tables 2020-11-03 11:26:23 +01:00
Arnau B
cbeca0f76e Insert ETH as HistoryDB token 2020-11-02 12:09:09 +01:00
laisolizq
aa6cb6f818 API add bids endpoint 2020-10-28 18:11:52 +01:00
Arnau B
a329d894d2 Refactor api txs 2020-10-28 12:16:35 +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
ToniRamirezM
f314498a26 Coordinators methods for API 2020-10-22 13:29:38 +02:00
laisolizq
043710112d Add get tokens endpoint 2020-10-19 10:14:18 +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
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
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