mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Process withdrawals in HistoryDB, test withdrawals and vars in sync
This commit is contained in:
@@ -663,9 +663,33 @@ type ConfigExtra struct {
|
||||
CoordUser string
|
||||
}
|
||||
|
||||
// FillBlocksL1UserTxsBatchNum fills the BatchNum of forged L1UserTxs:
|
||||
// - blocks[].Rollup.L1UserTxs[].BatchNum
|
||||
func (tc *Context) FillBlocksL1UserTxsBatchNum(blocks []common.BlockData) {
|
||||
for i := range blocks {
|
||||
block := &blocks[i]
|
||||
for j := range block.Rollup.Batches {
|
||||
batch := &block.Rollup.Batches[j]
|
||||
if batch.L1Batch {
|
||||
// Set BatchNum for forged L1UserTxs to til blocks
|
||||
bn := batch.Batch.BatchNum
|
||||
for k := range blocks {
|
||||
block := &blocks[k]
|
||||
for l := range block.Rollup.L1UserTxs {
|
||||
tx := &block.Rollup.L1UserTxs[l]
|
||||
if *tx.ToForgeL1TxsNum == tc.extra.openToForge {
|
||||
tx.BatchNum = &bn
|
||||
}
|
||||
}
|
||||
}
|
||||
tc.extra.openToForge++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FillBlocksExtra fills extra fields not generated by til in each block, so
|
||||
// that the blockData is closer to what the HistoryDB stores. The filled fields are:
|
||||
// - blocks[].Rollup.L1UserTxs[].BatchNum
|
||||
// - blocks[].Rollup.Batch.EthBlockNum
|
||||
// - blocks[].Rollup.Batch.ForgerAddr
|
||||
// - blocks[].Rollup.Batch.ForgeL1TxsNum
|
||||
@@ -686,21 +710,6 @@ func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra)
|
||||
block := &blocks[i]
|
||||
for j := range block.Rollup.Batches {
|
||||
batch := &block.Rollup.Batches[j]
|
||||
if batch.L1Batch {
|
||||
// Set BatchNum for forged L1UserTxs to til blocks
|
||||
bn := batch.Batch.BatchNum
|
||||
for k := range blocks {
|
||||
block := &blocks[k]
|
||||
for l := range block.Rollup.L1UserTxs {
|
||||
tx := &block.Rollup.L1UserTxs[l]
|
||||
if *tx.ToForgeL1TxsNum == tc.extra.openToForge {
|
||||
tx.BatchNum = &bn
|
||||
}
|
||||
}
|
||||
}
|
||||
tc.extra.openToForge++
|
||||
}
|
||||
|
||||
batch.Batch.EthBlockNum = block.Block.EthBlockNum
|
||||
// til doesn't fill the batch forger addr
|
||||
batch.Batch.ForgerAddr = cfg.BootCoordAddr
|
||||
@@ -802,6 +811,7 @@ func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra)
|
||||
batch.ExitTree =
|
||||
append(batch.ExitTree,
|
||||
common.ExitInfo{
|
||||
BatchNum: batch.Batch.BatchNum,
|
||||
AccountIdx: tx.FromIdx,
|
||||
Balance: tx.Amount,
|
||||
})
|
||||
@@ -812,6 +822,7 @@ func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra)
|
||||
tx := &batch.L2Txs[k]
|
||||
if tx.Type == common.TxTypeExit {
|
||||
batch.ExitTree = append(batch.ExitTree, common.ExitInfo{
|
||||
BatchNum: batch.Batch.BatchNum,
|
||||
AccountIdx: tx.FromIdx,
|
||||
Balance: tx.Amount,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user