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.
This commit is contained in:
Eduard S
2020-12-09 15:22:32 +01:00
parent a7e4e8ff6c
commit 20b8d0561f
16 changed files with 543 additions and 198 deletions

View File

@@ -1,6 +1,7 @@
package db
import (
"database/sql"
"fmt"
"math/big"
"reflect"
@@ -168,8 +169,14 @@ func SlicePtrsToSlice(slice interface{}) interface{} {
// Rollback an sql transaction, and log the error if it's not nil
func Rollback(txn *sqlx.Tx) {
err := txn.Rollback()
if err != nil {
if err := txn.Rollback(); err != nil {
log.Errorw("Rollback", "err", err)
}
}
// RowsClose close the rows of an sql query, and log the errir if it's not nil
func RowsClose(rows *sql.Rows) {
if err := rows.Close(); err != nil {
log.Errorw("rows.Close", "err", err)
}
}