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
This commit is contained in:
Eduard S
2020-10-28 16:09:05 +01:00
parent 11dbf67377
commit 6e4b9b4b70
20 changed files with 671 additions and 153 deletions

View File

@@ -17,6 +17,7 @@ type ClientInterface interface {
EthereumInterface
RollupInterface
AuctionInterface
WDelayerInterface
}
//
@@ -28,6 +29,7 @@ type Client struct {
EthereumClient
AuctionClient
RollupClient
WDelayerClient
}
// TokenConfig is used to define the information about token
@@ -47,11 +49,17 @@ type AuctionConfig struct {
TokenHEZ TokenConfig
}
// WDelayerConfig is the configuration for the WDelayer smart contract interface
type WDelayerConfig struct {
Address ethCommon.Address
}
// ClientConfig is the configuration of the Client
type ClientConfig struct {
Ethereum EthereumConfig
Rollup RollupConfig
Auction AuctionConfig
WDelayer WDelayerConfig
}
// NewClient creates a new Client to interact with Ethereum and the Hermez smart contracts.
@@ -61,13 +69,18 @@ func NewClient(client *ethclient.Client, account *accounts.Account, ks *ethKeyst
if err != nil {
return nil, err
}
rollupCient, err := NewRollupClient(ethereumClient, cfg.Rollup.Address, cfg.Auction.TokenHEZ)
rollupClient, err := NewRollupClient(ethereumClient, cfg.Rollup.Address, cfg.Auction.TokenHEZ)
if err != nil {
return nil, err
}
wDelayerClient, err := NewWDelayerClient(ethereumClient, cfg.WDelayer.Address)
if err != nil {
return nil, err
}
return &Client{
EthereumClient: *ethereumClient,
AuctionClient: *auctionClient,
RollupClient: *rollupCient,
RollupClient: *rollupClient,
WDelayerClient: *wDelayerClient,
}, nil
}