mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Add ZKI tests Til last batches MinimumFlow0 &other
- Add ZKI tests Til last batches MinimumFlow0 - Fix zki.CurrentNumBatch - Fix StateDB BatchNum log
This commit is contained in:
@@ -117,7 +117,7 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat
|
||||
|
||||
if tp.s.Typ == statedb.TypeBatchBuilder {
|
||||
tp.zki = common.NewZKInputs(tp.config.ChainID, tp.config.MaxTx, tp.config.MaxL1Tx,
|
||||
tp.config.MaxFeeTx, tp.config.NLevels, tp.s.CurrentBatch().BigInt())
|
||||
tp.config.MaxFeeTx, tp.config.NLevels, (tp.s.CurrentBatch() + 1).BigInt())
|
||||
tp.zki.OldLastIdx = tp.s.CurrentIdx().BigInt()
|
||||
tp.zki.OldStateRoot = tp.s.MT.Root().BigInt()
|
||||
tp.zki.Metadata.NewLastIdxRaw = tp.s.CurrentIdx()
|
||||
|
||||
@@ -223,19 +223,19 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
}
|
||||
tp := NewTxProcessor(sdb, config)
|
||||
|
||||
log.Debug("block:0 batch:0, only L1CoordinatorTxs")
|
||||
log.Debug("block:0 batch:1, only L1CoordinatorTxs")
|
||||
_, err = tp.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "0", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
log.Debug("block:0 batch:1")
|
||||
log.Debug("block:0 batch:2")
|
||||
l1UserTxs := []common.L1Tx{}
|
||||
l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs)
|
||||
_, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "0", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
log.Debug("block:0 batch:2")
|
||||
log.Debug("block:0 batch:3")
|
||||
l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[2].Batch.ForgeL1TxsNum])
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[2].L2Txs)
|
||||
_, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs)
|
||||
@@ -243,7 +243,7 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
checkBalance(t, tc, sdb, "A", 0, "500")
|
||||
assert.Equal(t, "13644148972047617726265275926674266298636745191961029124811988256139761111521", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
log.Debug("block:0 batch:3")
|
||||
log.Debug("block:0 batch:4")
|
||||
l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[3].Batch.ForgeL1TxsNum])
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[3].L2Txs)
|
||||
_, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, l2Txs)
|
||||
@@ -252,7 +252,7 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
checkBalance(t, tc, sdb, "A", 1, "500")
|
||||
assert.Equal(t, "12433441613247342495680642890662773367605896324555599297255745922589338651261", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
log.Debug("block:0 batch:4")
|
||||
log.Debug("block:0 batch:5")
|
||||
l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[4].Batch.ForgeL1TxsNum])
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[4].L2Txs)
|
||||
_, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[4].L1CoordinatorTxs, l2Txs)
|
||||
@@ -261,7 +261,7 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
checkBalance(t, tc, sdb, "A", 1, "500")
|
||||
assert.Equal(t, "12433441613247342495680642890662773367605896324555599297255745922589338651261", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
log.Debug("block:0 batch:5")
|
||||
log.Debug("block:0 batch:6")
|
||||
l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[5].Batch.ForgeL1TxsNum])
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[5].L2Txs)
|
||||
_, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[5].L1CoordinatorTxs, l2Txs)
|
||||
@@ -272,7 +272,7 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
assert.Equal(t, "4191361650490017591061467288209836928064232431729236465872209988325272262963", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
coordIdxs := []common.Idx{261, 262}
|
||||
log.Debug("block:0 batch:6")
|
||||
log.Debug("block:0 batch:7")
|
||||
l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[6].Batch.ForgeL1TxsNum])
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[6].L2Txs)
|
||||
_, err = tp.ProcessTxs(coordIdxs, l1UserTxs, blocks[0].Rollup.Batches[6].L1CoordinatorTxs, l2Txs)
|
||||
@@ -287,7 +287,7 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
checkBalance(t, tc, sdb, "D", 0, "800")
|
||||
assert.Equal(t, "7614010373759339299470010949167613050707822522530721724565424494781010548240", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
log.Debug("block:0 batch:7")
|
||||
log.Debug("block:0 batch:8")
|
||||
l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[7].Batch.ForgeL1TxsNum])
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[7].L2Txs)
|
||||
_, err = tp.ProcessTxs(coordIdxs, l1UserTxs, blocks[0].Rollup.Batches[7].L1CoordinatorTxs, l2Txs)
|
||||
@@ -303,7 +303,8 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
checkBalance(t, tc, sdb, "D", 0, "800")
|
||||
assert.Equal(t, "21231789250434471575486264439945776732824482207853465397552873521865656677689", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
log.Debug("block:1 batch:0")
|
||||
coordIdxs = []common.Idx{262}
|
||||
log.Debug("block:1 batch:1")
|
||||
l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[1].Rollup.Batches[0].Batch.ForgeL1TxsNum])
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[0].L2Txs)
|
||||
_, err = tp.ProcessTxs(coordIdxs, l1UserTxs, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs)
|
||||
@@ -319,7 +320,8 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
checkBalance(t, tc, sdb, "D", 0, "470")
|
||||
assert.Equal(t, "11289313644810782435120113035387729451095637380468777086895109386127538554246", tp.s.MT.Root().BigInt().String())
|
||||
|
||||
log.Debug("block:1 batch:1")
|
||||
coordIdxs = []common.Idx{}
|
||||
log.Debug("block:1 batch:2")
|
||||
l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[1].Rollup.Batches[1].Batch.ForgeL1TxsNum])
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[1].L2Txs)
|
||||
_, err = tp.ProcessTxs(coordIdxs, l1UserTxs, blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
|
||||
@@ -332,8 +334,8 @@ func TestProcessTxsBalances(t *testing.T) {
|
||||
|
||||
_, err = tp.ProcessTxs(coordIdxs, []common.L1Tx{}, []common.L1Tx{}, poolL2Txs)
|
||||
require.NoError(t, err)
|
||||
checkBalance(t, tc, sdb, "Coord", 0, "105")
|
||||
checkBalance(t, tc, sdb, "Coord", 1, "40")
|
||||
checkBalance(t, tc, sdb, "Coord", 0, "75")
|
||||
checkBalance(t, tc, sdb, "Coord", 1, "30")
|
||||
checkBalance(t, tc, sdb, "A", 0, "510")
|
||||
checkBalance(t, tc, sdb, "A", 1, "170")
|
||||
checkBalance(t, tc, sdb, "B", 0, "480")
|
||||
@@ -384,13 +386,13 @@ func TestProcessTxsSynchronizer(t *testing.T) {
|
||||
|
||||
// Process the 1st batch, which contains the L1CoordinatorTxs necessary
|
||||
// to create the Coordinator accounts to receive the fees
|
||||
log.Debug("block:0 batch:0, only L1CoordinatorTxs")
|
||||
log.Debug("block:0 batch:1, only L1CoordinatorTxs")
|
||||
ptOut, err := tp.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 4, len(ptOut.CreatedAccounts))
|
||||
assert.Equal(t, 0, len(ptOut.CollectedFees))
|
||||
|
||||
log.Debug("block:0 batch:1")
|
||||
log.Debug("block:0 batch:2")
|
||||
l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs)
|
||||
ptOut, err = tp.ProcessTxs(coordIdxs, blocks[0].Rollup.L1UserTxs,
|
||||
blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
|
||||
@@ -406,7 +408,7 @@ func TestProcessTxsSynchronizer(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "50", acc.Balance.String())
|
||||
|
||||
log.Debug("block:0 batch:2")
|
||||
log.Debug("block:0 batch:3")
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[2].L2Txs)
|
||||
ptOut, err = tp.ProcessTxs(coordIdxs, nil, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs)
|
||||
require.NoError(t, err)
|
||||
@@ -421,7 +423,7 @@ func TestProcessTxsSynchronizer(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "35", acc.Balance.String())
|
||||
|
||||
log.Debug("block:1 batch:0")
|
||||
log.Debug("block:1 batch:1")
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[0].L2Txs)
|
||||
// before processing expect l2Txs[0:2].Nonce==0
|
||||
assert.Equal(t, common.Nonce(0), l2Txs[0].Nonce)
|
||||
@@ -447,7 +449,7 @@ func TestProcessTxsSynchronizer(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "57", acc.Balance.String())
|
||||
|
||||
log.Debug("block:1 batch:1")
|
||||
log.Debug("block:1 batch:2")
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[1].L2Txs)
|
||||
ptOut, err = tp.ProcessTxs(coordIdxs, blocks[1].Rollup.L1UserTxs,
|
||||
blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
|
||||
@@ -506,13 +508,13 @@ func TestProcessTxsBatchBuilder(t *testing.T) {
|
||||
|
||||
// Process the 1st batch, which contains the L1CoordinatorTxs necessary
|
||||
// to create the Coordinator accounts to receive the fees
|
||||
log.Debug("block:0 batch:0, only L1CoordinatorTxs")
|
||||
log.Debug("block:0 batch:1, only L1CoordinatorTxs")
|
||||
ptOut, err := tp.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil)
|
||||
require.NoError(t, err)
|
||||
// expect 0 at CreatedAccount, as is only computed when StateDB.Type==TypeSynchronizer
|
||||
assert.Equal(t, 0, len(ptOut.CreatedAccounts))
|
||||
|
||||
log.Debug("block:0 batch:1")
|
||||
log.Debug("block:0 batch:2")
|
||||
l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs)
|
||||
ptOut, err = tp.ProcessTxs(coordIdxs, blocks[0].Rollup.L1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
|
||||
require.NoError(t, err)
|
||||
@@ -522,7 +524,7 @@ func TestProcessTxsBatchBuilder(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "50", acc.Balance.String())
|
||||
|
||||
log.Debug("block:0 batch:2")
|
||||
log.Debug("block:0 batch:3")
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[2].L2Txs)
|
||||
ptOut, err = tp.ProcessTxs(coordIdxs, nil, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs)
|
||||
require.NoError(t, err)
|
||||
@@ -532,7 +534,7 @@ func TestProcessTxsBatchBuilder(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "35", acc.Balance.String())
|
||||
|
||||
log.Debug("block:1 batch:0")
|
||||
log.Debug("block:1 batch:1")
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[0].L2Txs)
|
||||
_, err = tp.ProcessTxs(coordIdxs, nil, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs)
|
||||
require.NoError(t, err)
|
||||
@@ -540,7 +542,7 @@ func TestProcessTxsBatchBuilder(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "57", acc.Balance.String())
|
||||
|
||||
log.Debug("block:1 batch:1")
|
||||
log.Debug("block:1 batch:2")
|
||||
l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[1].L2Txs)
|
||||
_, err = tp.ProcessTxs(coordIdxs, blocks[1].Rollup.L1UserTxs, blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
|
||||
require.NoError(t, err)
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user