mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
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:
@@ -372,7 +372,7 @@ func GenBids(nBids int, blocks []common.Block, coords []common.Coordinator) []co
|
||||
|
||||
// GenExitTree generates an exitTree (as an array of Exits)
|
||||
//nolint:gomnd
|
||||
func GenExitTree(n int, batches []common.Batch, accounts []common.Account) []common.ExitInfo {
|
||||
func GenExitTree(n int, batches []common.Batch, accounts []common.Account, blocks []common.Block) []common.ExitInfo {
|
||||
exitTree := make([]common.ExitInfo, n)
|
||||
for i := 0; i < n; i++ {
|
||||
exitTree[i] = common.ExitInfo{
|
||||
@@ -397,17 +397,14 @@ func GenExitTree(n int, batches []common.Batch, accounts []common.Account) []com
|
||||
Balance: big.NewInt(int64(i) * 1000),
|
||||
}
|
||||
if i%2 == 0 {
|
||||
instant := new(int64)
|
||||
*instant = int64(batches[(i+1)%len(batches)].BatchNum)
|
||||
exitTree[i].InstantWithdrawn = instant
|
||||
instant := int64(blocks[i%len(blocks)].EthBlockNum)
|
||||
exitTree[i].InstantWithdrawn = &instant
|
||||
} else if i%3 == 0 {
|
||||
delayedReq := new(int64)
|
||||
*delayedReq = int64(batches[(i+1)%len(batches)].BatchNum)
|
||||
exitTree[i].DelayedWithdrawRequest = delayedReq
|
||||
delayedReq := int64(blocks[i%len(blocks)].EthBlockNum)
|
||||
exitTree[i].DelayedWithdrawRequest = &delayedReq
|
||||
if i%9 == 0 {
|
||||
delayed := new(int64)
|
||||
*delayed = int64(batches[(i+2)%len(batches)].BatchNum)
|
||||
exitTree[i].DelayedWithdrawn = delayed
|
||||
delayed := int64(blocks[i%len(blocks)].EthBlockNum)
|
||||
exitTree[i].DelayedWithdrawn = &delayed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user