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.
This commit is contained in:
Eduard S
2020-11-10 11:27:50 +01:00
parent 8cc165f562
commit e731b79e96
16 changed files with 228 additions and 132 deletions

View File

@@ -1,6 +1,7 @@
package common
import (
"math/big"
"time"
ethCommon "github.com/ethereum/go-ethereum/common"
@@ -51,15 +52,30 @@ func NewAuctionData() AuctionData {
}
}
// WDelayerTransfer represents a transfer (either deposit or withdrawal) in the
// WDelayer smart contract
type WDelayerTransfer struct {
Owner ethCommon.Address
Token ethCommon.Address
Amount *big.Int
// TxHash ethCommon.Hash // hash of the transaction in which the wdelayer transfer happened
}
// WDelayerData contains information returned by the WDelayer smart contract
type WDelayerData struct {
Vars *WDelayerVariables
Vars *WDelayerVariables
Deposits []WDelayerTransfer
DepositsByTxHash map[ethCommon.Hash]*WDelayerTransfer
Withdrawals []WDelayerTransfer
}
// NewWDelayerData creates an empty WDelayerData.
func NewWDelayerData() WDelayerData {
return WDelayerData{
Vars: nil,
Vars: nil,
Deposits: make([]WDelayerTransfer, 0),
DepositsByTxHash: make(map[ethCommon.Hash]*WDelayerTransfer),
Withdrawals: make([]WDelayerTransfer, 0),
}
}