Commit Graph

142 Commits

Author SHA1 Message Date
Arnau B
6e7f860d61 Add forged txs in batch endpoints response 2020-12-23 11:26:23 +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
Arnau B
bc5fa92898 Add bootCoord to coord table, get coord by forgerAddr 2020-12-23 11:03:21 +01:00
Arnau B
a7394cdb2a Fix API nonces 2020-12-22 16:36:51 +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
Arnau B
8083e4fec3 Fix format of the MTP for exit endpoint 2020-12-16 20:09:17 +01:00
Arnau B
226c49f28f Fix inconsistency between api doc and code: hermezEthereumAddress => hezEthereumAddress 2020-12-16 12:29:46 +01:00
Eduard S
a7351992cd Make coordinator more responsive
- API:
	- Replace `emergencyModeStaringTime` by `emercengyModeStartingBlock`
- Synchronizer:
	- Track emergency mode starting block
- cli/node
	- Add working coordinator config
- coordinator:
	- Retry handler for synchronizer stats in case of error (instead of
	  waiting for the next block to try again)
	- On init, trigger an initial call to the handler for synced block
	  before waiting for the synchronizer, to force the coordinator to start
	  its logic even if there's no new block right after the node has been
	  started (very useful for running in testnet where the frequency of
	  blocks is variable)
	- Merge Msg for synced block and updated vars into one: `MsgSyncBlock`.
2020-12-15 15:15:25 +01:00
Eduard S
d1ced80e62 Update API with new buckets synchronization 2020-12-10 18:00:17 +01:00
Eduard S
20b8d0561f Update synchronizer and DB with last contracts updates
- API
	- When updating network info, handle cases where no batches exists and
	  where no forgers exists
- cli/node
	- Update `cfg.buidler.toml` config file to a working version
- common
	- Add new smart contract structs and extend some existing ones to
	  reflect updates regarding events from the smart contracts
- SQL
	- Add new tables and extend existing ones to reflect updates regarding
	  events from the smart contracts
- db/historydb
	- Add functions to insert new smart contract events data
	- Fix unclosed rows that led to inconsistent sql driver state (replace
	  NamedQuery by NamedExec).  This fixes the error:
	  `pq: unexpected Parse response 'C'`
- db/l2db
	- Close rows after usage
- eth
	- In Rollup event, introduce a new UpdateBucketsParameter when there's a
	  SafeMode event, with `SafeMode = true`
- synchronizer
	- synchronize new events
	- avoid calling `auction.CanForge` before the genesisBlock to avoid
	  getting a revert.
2020-12-10 17:45:17 +01:00
Eduard S
a05cecca80 Merge pull request #339 from hermeznetwork/feature/missing-deposit-name
Update missing LoadAmount to DepositAmount
2020-12-10 12:15:38 +01:00
a_bennassar
dbb2e957a5 Merge pull request #340 from hermeznetwork/jleebee-patch-1
Update swagger.yml
2020-12-10 11:01:54 +01:00
jleebee
2d85a4d6b9 Update swagger.yml 2020-12-09 19:22:55 +01:00
arnaucube
9d0b278d50 Update missing LoadAmount to DepositAmount
Related to 445f26ec9f
2020-12-09 18:34:01 +01:00
Eduard S
d5c753030a Merge pull request #338 from hermeznetwork/feature/api-amounts
Add amount success and load amount success
2020-12-09 17:20:21 +01:00
Arnau B
e1d34e3796 Add amount success and load amount success 2020-12-09 16:39:18 +01:00
Arnau B
039c7b29da Fix time sensitive test 2020-12-09 14:12:10 +01:00
Arnau B
a50ddbe4e0 Fix hez addr format for exits 2020-12-09 14:04:15 +01:00
Arnau B
87501276ce Fix errors when fromItem is not provided 2020-12-09 13:59:10 +01:00
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
Arnau B
3e3eb3ffe6 Update API mock server URL for swagger UI 2020-12-03 17:47:16 +01:00
laisolizq
18031343ec Update ethclient 2020-12-03 14:19:38 +01:00
Eduard S
ced42634da Wrap all errors with tracerr 2020-11-30 12:58:36 +01:00
Arnau B
5991752e30 Improve swagger doc 2020-11-27 10:45:21 +01:00
Eduard S
8f1cf2f145 Update coordinator, call all api update functions
- Common:
	- Rename Block.EthBlockNum to Block.Num to avoid unneeded repetition
- API:
	- Add UpdateNetworkInfoBlock to update just block information, to be
	  used when the node is not yet synchronized
- Node:
	- Call API.UpdateMetrics and UpdateRecommendedFee in a loop, with
	  configurable time intervals
- Synchronizer:
	- When mapping events by TxHash, use an array to support the possibility
	  of multiple calls of the same function happening in the same
	  transaction (for example, a smart contract in a single transaction
	  could call withdraw with delay twice, which would generate 2 withdraw
	  events, and 2 deposit events).
	- In Stats, keep entire LastBlock instead of just the blockNum
	- In Stats, add lastL1BatchBlock
	- Test Stats and SCVars
- Coordinator:
	- Enable writing the BatchInfo in every step of the pipeline to disk
	  (with JSON text files) for debugging purposes.
	- Move the Pipeline functionality from the Coordinator to its own struct
	  (Pipeline)
	- Implement shouldL1lL2Batch
	- In TxManager, implement logic to perform several attempts when doing
	  ethereum node RPC calls before considering the error. (Both for calls
	  to forgeBatch and transaction receipt)
	- In TxManager, reorganize the flow and note the specific points in
	  which actions are made when err != nil
- HistoryDB:
	- Implement GetLastL1BatchBlockNum: returns the blockNum of the latest
	  forged l1Batch, to help the coordinator decide when to forge an
	  L1Batch.
- EthereumClient and test.Client:
	- Update EthBlockByNumber to return the last block when the passed
	  number is -1.
2020-11-26 18:06:30 +01:00
a_bennassar
fd4e7ac315 Merge pull request #295 from hermeznetwork/feature/integration17
Redo coordinator structure, connect API to node
2020-11-24 19:07:35 +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
Arnau B
86029ca7de Improve swagger doc 2020-11-24 11:39:29 +01:00
Arnau B
ce1218e28a Integrate til into api 2020-11-17 17:50:07 +01:00
laisolizq
b3b23473b6 Add til api test first commit 2020-11-17 11:24:19 +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
ToniRamirezM
6919b561a5 Swagger Review
Swagger Review
2020-11-11 09:33:31 +01:00
laisolizq
43e9bee9db API state endpoint test 2020-11-10 13:47:18 +01:00
laisolizq
9edf9d2168 API State RecommendedFee 2020-11-09 17:57:23 +01:00
a_bennassar
a1b9720e77 Merge pull request #270 from hermeznetwork/feature/api-state-metrics
API State Metrics
2020-11-09 16:54:25 +01:00
ToniRamirezM
55a78fbd72 API State Metrics 2020-11-09 16:50:15 +01:00
Eduard S
8190755d49 Merge pull request #268 from hermeznetwork/feature/wrapped-in-struct
Refactor api pagination
2020-11-09 15:32:28 +01:00
laisolizq
cc6446e019 API add get state 2020-11-09 13:01:28 +01:00
Arnau B
d2e9196fba Refactor api pagination 2020-11-09 12:58:09 +01:00
Eduard S
220fd992c5 Merge pull request #263 from hermeznetwork/feature/wrapped-in-struct
Put api DBs into struct
2020-11-06 15:05:53 +01:00
Arnau B
1112ded933 Put api DBs into struct 2020-11-06 12:00:56 +01:00
laisolizq
22f0a45118 ItemID to uint64 & check timestamp 2020-11-06 10:40:57 +01:00
ToniRamirezM
b840ceb57a Account API 2020-11-06 09:30:32 +01:00
a_bennassar
1a9c96a720 Merge pull request #251 from hermeznetwork/feature/api-slots
API add slots endpoints
2020-11-05 16:04:43 +01:00
laisolizq
5012b82914 API add slots endpoints 2020-11-05 15:59:27 +01:00