Implement Pipeline.prepareForgeBatchArgs()

- Implement Pipeline.prepareForgeBatchArgs()
- Add a minimal stress test for the coordinator (that also runs the
  synchronizer)
- Update txprocessor.ProcessTxs() to return valid results for batches without
  transactions
  	- Add the boilerplate for the corresponding test, leaving as TODO the
	  zkInput values
- Update prover client to use the same point format as proof server (projective)
- Update interface of TxSelector.GetCoordIdxs to also return the authorizations
  to create accounts that go with the l1CoordinatorTxs.
This commit is contained in:
Eduard S
2020-12-22 16:50:58 +01:00
parent c61c4f3376
commit 6a990376b4
10 changed files with 361 additions and 49 deletions

View File

@@ -151,15 +151,15 @@ func (txsel *TxSelector) GetCoordIdxs() (map[common.TokenID]common.Idx, error) {
// GetL2TxSelection returns the L1CoordinatorTxs and a selection of the L2Txs
// for the next batch, from the L2DB pool
func (txsel *TxSelector) GetL2TxSelection(selectionConfig *SelectionConfig,
batchNum common.BatchNum) ([]common.Idx, []common.L1Tx, []common.PoolL2Tx, error) {
coordIdxs, _, l1CoordinatorTxs, l2Txs, err := txsel.GetL1L2TxSelection(selectionConfig, batchNum,
batchNum common.BatchNum) ([]common.Idx, [][]byte, []common.L1Tx, []common.PoolL2Tx, error) {
coordIdxs, auths, _, l1CoordinatorTxs, l2Txs, err := txsel.GetL1L2TxSelection(selectionConfig, batchNum,
[]common.L1Tx{})
return coordIdxs, l1CoordinatorTxs, l2Txs, tracerr.Wrap(err)
return coordIdxs, auths, l1CoordinatorTxs, l2Txs, tracerr.Wrap(err)
}
// GetL1L2TxSelection returns the selection of L1 + L2 txs
func (txsel *TxSelector) GetL1L2TxSelection(selectionConfig *SelectionConfig,
batchNum common.BatchNum, l1Txs []common.L1Tx) ([]common.Idx, []common.L1Tx, []common.L1Tx,
batchNum common.BatchNum, l1Txs []common.L1Tx) ([]common.Idx, [][]byte, []common.L1Tx, []common.L1Tx,
[]common.PoolL2Tx, error) {
// apply l1-user-tx to localAccountDB
// create new leaves
@@ -169,7 +169,7 @@ func (txsel *TxSelector) GetL1L2TxSelection(selectionConfig *SelectionConfig,
// get existing CoordIdxs
coordIdxsMap, err := txsel.GetCoordIdxs()
if err != nil {
return nil, nil, nil, nil, tracerr.Wrap(err)
return nil, nil, nil, nil, nil, tracerr.Wrap(err)
}
var coordIdxs []common.Idx
for tokenID := range coordIdxsMap {
@@ -179,7 +179,7 @@ func (txsel *TxSelector) GetL1L2TxSelection(selectionConfig *SelectionConfig,
// get pending l2-tx from tx-pool
l2TxsRaw, err := txsel.l2db.GetPendingTxs() // (batchID)
if err != nil {
return nil, nil, nil, nil, tracerr.Wrap(err)
return nil, nil, nil, nil, nil, tracerr.Wrap(err)
}
var validTxs txs
@@ -235,14 +235,19 @@ func (txsel *TxSelector) GetL1L2TxSelection(selectionConfig *SelectionConfig,
// process the txs in the local AccountsDB
_, err = txsel.localAccountsDB.ProcessTxs(ptc, coordIdxs, l1Txs, l1CoordinatorTxs, l2Txs)
if err != nil {
return nil, nil, nil, nil, tracerr.Wrap(err)
return nil, nil, nil, nil, nil, tracerr.Wrap(err)
}
err = txsel.localAccountsDB.MakeCheckpoint()
if err != nil {
return nil, nil, nil, nil, tracerr.Wrap(err)
return nil, nil, nil, nil, nil, tracerr.Wrap(err)
}
return nil, l1Txs, l1CoordinatorTxs, l2Txs, nil
// TODO
auths := make([][]byte, len(l1CoordinatorTxs))
for i := range auths {
auths[i] = make([]byte, 65)
}
return nil, auths, l1Txs, l1CoordinatorTxs, l2Txs, nil
}
// processTxsToEthAddrBJJ process the common.PoolL2Tx in the case where

View File

@@ -133,12 +133,12 @@ func TestGetL2TxSelection(t *testing.T) {
// add the 1st batch of transactions to the TxSelector
addL2Txs(t, txsel, common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[0].L2Txs))
_, l1CoordTxs, l2Txs, err := txsel.GetL2TxSelection(selectionConfig, 0)
_, _, l1CoordTxs, l2Txs, err := txsel.GetL2TxSelection(selectionConfig, 0)
assert.NoError(t, err)
assert.Equal(t, 0, len(l2Txs))
assert.Equal(t, 0, len(l1CoordTxs))
_, _, _, _, err = txsel.GetL1L2TxSelection(selectionConfig, 0, blocks[0].Rollup.L1UserTxs)
_, _, _, _, _, err = txsel.GetL1L2TxSelection(selectionConfig, 0, blocks[0].Rollup.L1UserTxs)
assert.NoError(t, err)
// TODO once L2DB is updated to return error in case that AddTxTest