Set EffectiveAmount and EffectiveLoadAmount of forged L1UserTxs

This commit is contained in:
Eduard S
2020-11-30 15:51:31 +01:00
parent a8c9b7a604
commit 665e0829ec
6 changed files with 155 additions and 9 deletions

View File

@@ -690,6 +690,36 @@ func (tc *Context) FillBlocksL1UserTxsBatchNum(blocks []common.BlockData) {
}
}
// FillBlocksForgedL1UserTxs fills the L1UserTxs of a batch with the L1UserTxs
// that are forged in that batch. It always sets `EffectiveAmount` = `Amount`
// and `EffectiveLoadAmount` = `LoadAmount`.
func (tc *Context) FillBlocksForgedL1UserTxs(blocks []common.BlockData) error {
for i := range blocks {
block := &blocks[i]
for j := range block.Rollup.Batches {
batch := &block.Rollup.Batches[j]
if batch.L1Batch {
batchNum := batch.Batch.BatchNum
queue := tc.Queues[int(*batch.Batch.ForgeL1TxsNum)]
batch.L1UserTxs = make([]common.L1Tx, len(queue))
for k := range queue {
tx := &batch.L1UserTxs[k]
*tx = queue[k].L1Tx
tx.EffectiveAmount = tx.Amount
tx.EffectiveLoadAmount = tx.LoadAmount
tx.BatchNum = &batchNum
_tx, err := common.NewL1Tx(tx)
if err != nil {
return tracerr.Wrap(err)
}
*tx = *_tx
}
}
}
}
return nil
}
// 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.Batch.EthBlockNum