mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
@@ -328,7 +328,8 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat
|
|||||||
if i < int(tp.config.MaxTx)-1 {
|
if i < int(tp.config.MaxTx)-1 {
|
||||||
tp.zki.ISOutIdx[i] = tp.s.CurrentIdx().BigInt()
|
tp.zki.ISOutIdx[i] = tp.s.CurrentIdx().BigInt()
|
||||||
tp.zki.ISStateRoot[i] = tp.s.MT.Root().BigInt()
|
tp.zki.ISStateRoot[i] = tp.s.MT.Root().BigInt()
|
||||||
tp.zki.ISAccFeeOut[i] = formatAccumulatedFees(collectedFees, tp.zki.FeePlanTokens, coordIdxs)
|
tp.zki.ISAccFeeOut[i] = formatAccumulatedFees(collectedFees,
|
||||||
|
tp.zki.FeePlanTokens, coordIdxs)
|
||||||
tp.zki.ISExitRoot[i] = exitTree.Root().BigInt()
|
tp.zki.ISExitRoot[i] = exitTree.Root().BigInt()
|
||||||
}
|
}
|
||||||
if i >= tp.i {
|
if i >= tp.i {
|
||||||
@@ -396,6 +397,7 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat
|
|||||||
// once all txs processed (exitTree root frozen), for each Exit,
|
// once all txs processed (exitTree root frozen), for each Exit,
|
||||||
// generate common.ExitInfo data
|
// generate common.ExitInfo data
|
||||||
var exitInfos []common.ExitInfo
|
var exitInfos []common.ExitInfo
|
||||||
|
exitInfosByIdx := make(map[common.Idx]*common.ExitInfo)
|
||||||
for i := 0; i < nTx; i++ {
|
for i := 0; i < nTx; i++ {
|
||||||
if !exits[i].exit {
|
if !exits[i].exit {
|
||||||
continue
|
continue
|
||||||
@@ -415,7 +417,12 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat
|
|||||||
MerkleProof: p,
|
MerkleProof: p,
|
||||||
Balance: exitAccount.Balance,
|
Balance: exitAccount.Balance,
|
||||||
}
|
}
|
||||||
exitInfos = append(exitInfos, ei)
|
if prevExit, ok := exitInfosByIdx[exitIdx]; !ok {
|
||||||
|
exitInfos = append(exitInfos, ei)
|
||||||
|
exitInfosByIdx[exitIdx] = &exitInfos[len(exitInfos)-1]
|
||||||
|
} else {
|
||||||
|
*prevExit = ei
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if tp.s.Typ == statedb.TypeSynchronizer {
|
if tp.s.Typ == statedb.TypeSynchronizer {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package txprocessor
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
@@ -463,7 +462,7 @@ func TestProcessTxsSynchronizer(t *testing.T) {
|
|||||||
blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
|
blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, 2, len(ptOut.ExitInfos)) // 2, as previous batch was without L1UserTxs, and has pending the 'ForceExit(1) A: 5'
|
assert.Equal(t, 1, len(ptOut.ExitInfos)) // 1, as previous batch was without L1UserTxs, and has pending the 'ForceExit(1) A: 5', and the 2 exit transactions get grouped under 1 ExitInfo
|
||||||
assert.Equal(t, 1, len(ptOut.CreatedAccounts))
|
assert.Equal(t, 1, len(ptOut.CreatedAccounts))
|
||||||
assert.Equal(t, 4, len(ptOut.CollectedFees))
|
assert.Equal(t, 4, len(ptOut.CollectedFees))
|
||||||
assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(0)].String())
|
assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(0)].String())
|
||||||
@@ -842,10 +841,8 @@ func TestTwoExits(t *testing.T) {
|
|||||||
ptOuts := []*ProcessTxOutput{}
|
ptOuts := []*ProcessTxOutput{}
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
for _, batch := range block.Rollup.Batches {
|
for _, batch := range block.Rollup.Batches {
|
||||||
// fmt.Printf("Batch %v\n%#v\n", batch.Batch.BatchNum, batch.L1UserTxs)
|
|
||||||
ptOut, err := tp.ProcessTxs(nil, batch.L1UserTxs, nil, nil)
|
ptOut, err := tp.ProcessTxs(nil, batch.L1UserTxs, nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
fmt.Printf("Exits (batch %v)\n%#v\n", batch.Batch.BatchNum, ptOut.ExitInfos)
|
|
||||||
ptOuts = append(ptOuts, ptOut)
|
ptOuts = append(ptOuts, ptOut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user