You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1287 lines
366 KiB

  1. package txprocessor
  2. import (
  3. "encoding/hex"
  4. "encoding/json"
  5. "fmt"
  6. "io/ioutil"
  7. "math/big"
  8. "os"
  9. "testing"
  10. "github.com/hermeznetwork/hermez-node/common"
  11. "github.com/hermeznetwork/hermez-node/db/statedb"
  12. "github.com/hermeznetwork/hermez-node/log"
  13. "github.com/hermeznetwork/hermez-node/test/til"
  14. "github.com/hermeznetwork/hermez-node/test/txsets"
  15. "github.com/stretchr/testify/assert"
  16. "github.com/stretchr/testify/require"
  17. )
  18. //nolint:deadcode,unused
  19. func printZKInputs(t *testing.T, zki *common.ZKInputs) {
  20. s, err := json.Marshal(zki)
  21. require.NoError(t, err)
  22. h, err := zki.HashGlobalData()
  23. require.NoError(t, err)
  24. fmt.Println("Batch", zki.CurrentNumBatch)
  25. fmt.Println("\nCopy&Paste into js circom test:\n let zkInput = JSON.parse(`" + string(s) + "`);")
  26. // fmt.Println("\nZKInputs json:\n echo '" + string(s) + "' | jq > ~/go.txt")
  27. fmt.Printf(`
  28. const output={
  29. hashGlobalInputs: "%s",
  30. };
  31. await circuit.assertOut(w, output);
  32. `, h.String())
  33. fmt.Println("")
  34. }
  35. func TestZKInputsHashTestVector0(t *testing.T) {
  36. dir, err := ioutil.TempDir("", "tmpdb")
  37. require.NoError(t, err)
  38. defer assert.Nil(t, os.RemoveAll(dir))
  39. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  40. Type: statedb.TypeBatchBuilder, NLevels: 32})
  41. require.NoError(t, err)
  42. chainID := uint16(0)
  43. users, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs := txsets.GenerateTxsZKInputsHash0(t, chainID)
  44. config := Config{
  45. NLevels: 32,
  46. MaxFeeTx: 8,
  47. MaxTx: 32,
  48. MaxL1Tx: 16,
  49. ChainID: chainID,
  50. }
  51. tp := NewTxProcessor(sdb, config)
  52. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  53. require.NoError(t, err)
  54. // check expected account keys values from tx inputs
  55. acc, err := sdb.GetAccount(common.Idx(256))
  56. require.NoError(t, err)
  57. assert.Equal(t, users[0].BJJ.Public().Compress().String(), acc.BJJ.String())
  58. assert.Equal(t, users[0].Addr.Hex(), acc.EthAddr.Hex())
  59. // check that there no exist more accounts
  60. _, err = sdb.GetAccount(common.Idx(257))
  61. require.NotNil(t, err)
  62. ptOut.ZKInputs.FeeIdxs[0] = common.Idx(256).BigInt()
  63. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  64. assert.NoError(t, err)
  65. // value from js test vector
  66. expectedToHash := "0000000000ff000000000100000000000000000000000000000000000000000000000000000000000000000023c65c0c7d6b6a35a37253f64a1629c61a2b7982add65196f1ee64108e45fffd00000000000000000000000000000000000000000000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d70000000000000000f424000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010000000003e87e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000001" //nolint:lll
  67. // checks are splitted to find the difference easier
  68. // assert.Equal(t, expectedToHash, hex.EncodeToString(toHash))
  69. assert.Equal(t, expectedToHash[:1000], hex.EncodeToString(toHash)[:1000])
  70. assert.Equal(t, expectedToHash[1000:2000], hex.EncodeToString(toHash)[1000:2000])
  71. assert.Equal(t, expectedToHash[2000:], hex.EncodeToString(toHash)[2000:])
  72. h, err := ptOut.ZKInputs.HashGlobalData()
  73. require.NoError(t, err)
  74. // value from js test vector
  75. assert.Equal(t,
  76. "2280359224837322594951095666065560814862974477042574683055716416537275902219",
  77. h.String())
  78. }
  79. func TestZKInputsHashTestVector1(t *testing.T) {
  80. dir, err := ioutil.TempDir("", "tmpdb")
  81. require.NoError(t, err)
  82. defer assert.Nil(t, os.RemoveAll(dir))
  83. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  84. Type: statedb.TypeBatchBuilder, NLevels: 32})
  85. require.NoError(t, err)
  86. chainID := uint16(0)
  87. users, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs := txsets.GenerateTxsZKInputsHash1(t, chainID)
  88. config := Config{
  89. NLevels: 32,
  90. MaxFeeTx: 8,
  91. MaxTx: 32,
  92. MaxL1Tx: 16,
  93. ChainID: chainID,
  94. }
  95. tp := NewTxProcessor(sdb, config)
  96. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  97. require.NoError(t, err)
  98. // check expected account keys values from tx inputs
  99. acc, err := sdb.GetAccount(common.Idx(256))
  100. require.NoError(t, err)
  101. assert.Equal(t, users[0].BJJ.Public().Compress().String(), acc.BJJ.String())
  102. assert.Equal(t, users[0].Addr.Hex(), acc.EthAddr.Hex())
  103. acc, err = sdb.GetAccount(common.Idx(257))
  104. require.NoError(t, err)
  105. assert.Equal(t, users[1].BJJ.Public().Compress().String(), acc.BJJ.String())
  106. assert.Equal(t, users[1].Addr.Hex(), acc.EthAddr.Hex())
  107. // check that there no exist more accounts
  108. _, err = sdb.GetAccount(common.Idx(258))
  109. require.NotNil(t, err)
  110. ptOut.ZKInputs.FeeIdxs[0] = common.Idx(257).BigInt()
  111. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  112. assert.NoError(t, err)
  113. // value from js test vector
  114. expectedToHash := "0000000000ff00000000010100000000000000000000000000000000000000000000000000000000000000002730864bb0449edae92c8cec0a74ca84348cb39ba1d17676bf0330799049ef7e00000000000000000000000000000000000000000000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d70000000000000000f424000000000000000000010000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf093985b1993d9f743f9d7d943ed56f38601cb8b196db025f79650c4007c3054d0000000000000000f4240000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010000010000000003e889000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000001" //nolint:lll
  115. // checks are splitted to find the difference easier
  116. assert.Equal(t, expectedToHash[:1000], hex.EncodeToString(toHash)[:1000])
  117. assert.Equal(t, expectedToHash[1000:2000], hex.EncodeToString(toHash)[1000:2000])
  118. assert.Equal(t, expectedToHash[2000:], hex.EncodeToString(toHash)[2000:])
  119. h, err := ptOut.ZKInputs.HashGlobalData()
  120. require.NoError(t, err)
  121. // value from js test vector
  122. assert.Equal(t,
  123. "20195347509024076860791948682074257137912369319255341203011736647711127385192",
  124. h.String())
  125. }
  126. // TestZKInputsEmpty:
  127. // tests:
  128. // - L1: empty
  129. // - L2: empty
  130. func TestZKInputsEmpty(t *testing.T) {
  131. dir, err := ioutil.TempDir("", "tmpdb")
  132. require.NoError(t, err)
  133. defer assert.Nil(t, os.RemoveAll(dir))
  134. nLevels := 16
  135. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  136. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  137. require.NoError(t, err)
  138. chainID := uint16(0)
  139. config := Config{
  140. NLevels: uint32(nLevels),
  141. MaxTx: 3,
  142. MaxL1Tx: 2,
  143. MaxFeeTx: 2,
  144. ChainID: chainID,
  145. }
  146. tp := NewTxProcessor(sdb, config)
  147. // 0. Generate a batch from the empty state with no transactions
  148. coordIdxs := []common.Idx{}
  149. l1UserTxs := []common.L1Tx{}
  150. l1CoordTxs := []common.L1Tx{}
  151. l2Txs := []common.PoolL2Tx{}
  152. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  153. require.NoError(t, err)
  154. assert.Equal(t, "0", sdb.MT.Root().BigInt().String())
  155. assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
  156. // check that there are no accounts
  157. accs, err := sdb.TestGetAccounts()
  158. require.NoError(t, err)
  159. assert.Equal(t, 0, len(accs))
  160. h, err := ptOut.ZKInputs.HashGlobalData()
  161. require.NoError(t, err)
  162. assert.Equal(t,
  163. "14868835594749398227643041454077020616740826983996922254454329672794659979378",
  164. h.String())
  165. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  166. require.NoError(t, err)
  167. assert.Equal(t, "0000000000ff0000000000ff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", hex.EncodeToString(toHash)) //nolint:lll
  168. // printZKInputs(t, ptOut.ZKInputs)
  169. s, err := json.Marshal(ptOut.ZKInputs)
  170. require.NoError(t, err)
  171. // the 'expected' data has been checked with the circom circuits
  172. expected := `{"amountF":["0","0","0"],"auxFromIdx":["0","0","0"],"auxToIdx":["0","0","0"],"ay1":["0","0","0"],"ay2":["0","0","0"],"ay3":["0","0"],"balance1":["0","0","0"],"balance2":["0","0","0"],"balance3":["0","0"],"currentNumBatch":"1","ethAddr1":["0","0","0"],"ethAddr2":["0","0","0"],"ethAddr3":["0","0"],"feeIdxs":["0","0"],"feePlanTokens":["0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["0","0","0"],"fromIdx":["0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0"],["0","0"]],"imExitRoot":["0","0"],"imFinalAccFee":["0","0"],"imInitStateRootFee":"0","imOnChain":["0","0"],"imOutIdx":["255","255"],"imStateRoot":["0","0"],"imStateRootFee":["0"],"isOld0_1":["0","0","0"],"isOld0_2":["0","0","0"],"loadAmountF":["0","0","0"],"maxNumBatch":["0","0","0"],"newAccount":["0","0","0"],"newExit":["0","0","0"],"nonce1":["0","0","0"],"nonce2":["0","0","0"],"nonce3":["0","0"],"oldKey1":["0","0","0"],"oldKey2":["0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","0","0"],"oldValue2":["0","0","0"],"onChain":["0","0","0"],"r8x":["0","0","0"],"r8y":["0","0","0"],"rqOffset":["0","0","0"],"rqToBjjAy":["0","0","0"],"rqToEthAddr":["0","0","0"],"rqTxCompressedDataV2":["0","0","0"],"s":["0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0"],"sign2":["0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0"],"toEthAddr":["0","0","0"],"toIdx":["0","0","0"],"tokenID1":["0","0","0"],"tokenID2":["0","0","0"],"tokenID3":["0","0"],"txCompressedData":["3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0"]}` //nolint:lll
  173. assert.Equal(t, expected, string(s))
  174. // 1. Generate a batch with two transactions that create one account
  175. // so that the state tree is not empty (same transactions as
  176. // TestZKInputs0)
  177. _, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs = txsets.GenerateTxsZKInputs0(t, chainID)
  178. ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  179. require.NoError(t, err)
  180. rootNonZero := sdb.MT.Root()
  181. // check that there is 1 account
  182. accs, err = sdb.TestGetAccounts()
  183. require.NoError(t, err)
  184. assert.Equal(t, 1, len(accs))
  185. h, err = ptOut.ZKInputs.HashGlobalData()
  186. require.NoError(t, err)
  187. assert.Equal(t,
  188. "268050518603676181303232762670889252107887961637122352824279203063446724220",
  189. h.String())
  190. toHash, err = ptOut.ZKInputs.ToHashGlobalData()
  191. require.NoError(t, err)
  192. assert.Equal(t, "0000000000ff00000000010000000000000000000000000000000000000000000000000000000000000000001274f3b04b971ba79471cc0c054c6f4e8e04a652d8156005e08572d48b284a4900000000000000000000000000000000000000000000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d700000000000000000028a0000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100010000000003e8000000000000000000000000000000000000000002", hex.EncodeToString(toHash)) //nolint:lll
  193. // 2. Generate a batch from a non-empty state with no transactions
  194. coordIdxs = []common.Idx{}
  195. l1UserTxs = []common.L1Tx{}
  196. l1CoordTxs = []common.L1Tx{}
  197. l2Txs = []common.PoolL2Tx{}
  198. ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  199. require.NoError(t, err)
  200. assert.Equal(t, rootNonZero, sdb.MT.Root())
  201. assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
  202. // check that there is still 1 account
  203. accs, err = sdb.TestGetAccounts()
  204. require.NoError(t, err)
  205. assert.Equal(t, 1, len(accs))
  206. // printZKInputs(t, ptOut.ZKInputs)
  207. h, err = ptOut.ZKInputs.HashGlobalData()
  208. require.NoError(t, err)
  209. assert.Equal(t,
  210. "14549773481215902770370895402511592482257052682044233219736414725386013867961",
  211. h.String())
  212. toHash, err = ptOut.ZKInputs.ToHashGlobalData()
  213. require.NoError(t, err)
  214. assert.Equal(t, "0000000001000000000001001274f3b04b971ba79471cc0c054c6f4e8e04a652d8156005e08572d48b284a491274f3b04b971ba79471cc0c054c6f4e8e04a652d8156005e08572d48b284a49000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003", hex.EncodeToString(toHash)) //nolint:lll
  215. s, err = json.Marshal(ptOut.ZKInputs)
  216. require.NoError(t, err)
  217. // the 'expected' data has been checked with the circom circuits
  218. expected = `{"amountF":["0","0","0"],"auxFromIdx":["0","0","0"],"auxToIdx":["0","0","0"],"ay1":["0","0","0"],"ay2":["0","0","0"],"ay3":["0","0"],"balance1":["0","0","0"],"balance2":["0","0","0"],"balance3":["0","0"],"currentNumBatch":"3","ethAddr1":["0","0","0"],"ethAddr2":["0","0","0"],"ethAddr3":["0","0"],"feeIdxs":["0","0"],"feePlanTokens":["0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["0","0","0"],"fromIdx":["0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0"],["0","0"]],"imExitRoot":["0","0"],"imFinalAccFee":["0","0"],"imInitStateRootFee":"8348267411286555209888146266884632338262429363093943412964280643886950926921","imOnChain":["0","0"],"imOutIdx":["256","256"],"imStateRoot":["8348267411286555209888146266884632338262429363093943412964280643886950926921","8348267411286555209888146266884632338262429363093943412964280643886950926921"],"imStateRootFee":["8348267411286555209888146266884632338262429363093943412964280643886950926921"],"isOld0_1":["0","0","0"],"isOld0_2":["0","0","0"],"loadAmountF":["0","0","0"],"maxNumBatch":["0","0","0"],"newAccount":["0","0","0"],"newExit":["0","0","0"],"nonce1":["0","0","0"],"nonce2":["0","0","0"],"nonce3":["0","0"],"oldKey1":["0","0","0"],"oldKey2":["0","0","0"],"oldLastIdx":"256","oldStateRoot":"8348267411286555209888146266884632338262429363093943412964280643886950926921","oldValue1":["0","0","0"],"oldValue2":["0","0","0"],"onChain":["0","0","0"],"r8x":["0","0","0"],"r8y":["0","0","0"],"rqOffset":["0","0","0"],"rqToBjjAy":["0","0","0"],"rqToEthAddr":["0","0","0"],"rqTxCompressedDataV2":["0","0","0"],"s":["0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0"],"sign2":["0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0"],"toEthAddr":["0","0","0"],"toIdx":["0","0","0"],"tokenID1":["0","0","0"],"tokenID2":["0","0","0"],"tokenID3":["0","0"],"txCompressedData":["3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0"]}` //nolint:lll
  219. assert.Equal(t, expected, string(s))
  220. }
  221. // TestZKInputs0:
  222. // tests:
  223. // - L1: CreateAccountDeposit
  224. // - L2: Transfer (without fees)
  225. // no Coordinator Idxs defined to receive the fees
  226. func TestZKInputs0(t *testing.T) {
  227. dir, err := ioutil.TempDir("", "tmpdb")
  228. require.NoError(t, err)
  229. defer assert.Nil(t, os.RemoveAll(dir))
  230. nLevels := 16
  231. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  232. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  233. require.NoError(t, err)
  234. chainID := uint16(0)
  235. users, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs := txsets.GenerateTxsZKInputs0(t, chainID)
  236. config := Config{
  237. NLevels: uint32(nLevels),
  238. MaxTx: 3,
  239. MaxL1Tx: 2,
  240. MaxFeeTx: 2,
  241. ChainID: chainID,
  242. }
  243. tp := NewTxProcessor(sdb, config)
  244. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  245. require.NoError(t, err)
  246. // check expected account keys values from tx inputs
  247. acc, err := sdb.GetAccount(common.Idx(256))
  248. require.NoError(t, err)
  249. assert.Equal(t, users[0].BJJ.Public().Compress().String(), acc.BJJ.String())
  250. assert.Equal(t, users[0].Addr.Hex(), acc.EthAddr.Hex())
  251. // check that there no exist more accounts
  252. _, err = sdb.GetAccount(common.Idx(257))
  253. require.NotNil(t, err)
  254. // printZKInputs(t, ptOut.ZKInputs)
  255. h, err := ptOut.ZKInputs.HashGlobalData()
  256. require.NoError(t, err)
  257. assert.Equal(t,
  258. "3929005955149551308549162130283891912726069629279688007150275375143313213942",
  259. h.String())
  260. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  261. require.NoError(t, err)
  262. assert.Equal(t, "0000000000ff00000000010000000000000000000000000000000000000000000000000000000000000000001274f3b04b971ba79471cc0c054c6f4e8e04a652d8156005e08572d48b284a4900000000000000000000000000000000000000000000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d700000000000000000028a0000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100010000000003e8000000000000000000000000000000000000000001", hex.EncodeToString(toHash)) //nolint:lll
  263. s, err := json.Marshal(ptOut.ZKInputs)
  264. require.NoError(t, err)
  265. // the 'expected' data has been checked with the circom circuits
  266. expected := `{"amountF":["0","1000","0"],"auxFromIdx":["256","0","0"],"auxToIdx":["0","0","0"],"ay1":["15238403086306505038849621710779816852318505119327426213168494964113886299863","15238403086306505038849621710779816852318505119327426213168494964113886299863","0"],"ay2":["0","15238403086306505038849621710779816852318505119327426213168494964113886299863","0"],"ay3":["0","0"],"balance1":["10400","10400","0"],"balance2":["0","9400","0"],"balance3":["0","0"],"currentNumBatch":"1","ethAddr1":["721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0"],"ethAddr2":["0","721457446580647751014191829380889690493307935711","0"],"ethAddr3":["0","0"],"feeIdxs":["0","0"],"feePlanTokens":["0","0"],"fromBjjCompressed":[["1","1","1","0","1","0","1","1","0","1","1","0","0","0","1","0","0","1","0","0","0","0","0","1","1","1","1","1","0","0","1","0","1","0","1","1","1","1","1","0","0","1","0","1","0","0","0","0","1","0","1","0","0","0","1","1","0","0","1","0","0","0","0","0","0","1","0","1","0","0","1","0","1","1","1","0","1","0","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","1","0","0","1","0","0","1","1","0","1","0","0","0","1","1","1","1","0","0","0","1","1","0","1","0","1","1","0","1","0","1","1","0","1","1","0","1","1","0","1","1","0","0","1","0","0","0","0","0","1","1","1","0","1","1","1","0","0","0","0","1","1","0","1","1","1","1","0","0","1","1","1","0","0","1","0","1","0","1","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","1","0","0","0","1","1","0","1","1","1","1","0","1","1","1","0","1","1","1","1","1","1","1","0","1","1","0","0","1","1","0","1","0","0","0","1","0","0","0","1","0","1","1","0","1","0","0","0","0","1","0","1","0","0","0","0","1","1","0","1","1","0","0","0","0","1","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","0","0"],"fromIdx":["0","256","0"],"globalChainID":"0","imAccFeeOut":[["0","0"],["0","0"]],"imExitRoot":["0","0"],"imFinalAccFee":["0","0"],"imInitStateRootFee":"8348267411286555209888146266884632338262429363093943412964280643886950926921","imOnChain":["1","0"],"imOutIdx":["256","256"],"imStateRoot":["5916166484411096386067910087740889906181628346949420436845073207929853337018","8348267411286555209888146266884632338262429363093943412964280643886950926921"],"imStateRootFee":["8348267411286555209888146266884632338262429363093943412964280643886950926921"],"isOld0_1":["1","0","0"],"isOld0_2":["0","0","0"],"loadAmountF":["10400","0","0"],"maxNumBatch":["0","0","0"],"newAccount":["1","0","0"],"newExit":["0","0","0"],"nonce1":["0","0","0"],"nonce2":["0","1","0"],"nonce3":["0","0"],"oldKey1":["0","0","0"],"oldKey2":["0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","0","0"],"oldValue2":["0","0","0"],"onChain":["1","0","0"],"r8x":["0","697669104883320562721075831863807250320343234312456080331266967258122458566","0"],"r8y":["0","10267257208224950693137009121218178526902987699350854333214357775215243475180","0"],"rqOffset":["0","0","0"],"rqToBjjAy":["0","0","0"],"rqToEthAddr":["0","0","0"],"rqTxCompressedDataV2":["0","0","0"],"s":["0","1961149612988146876975130085936547472666307783405869801085936230575020628253","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0"],"sign2":["0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0"],"toEthAddr":["0","0","0"],"toIdx":["0","256","0"],"tokenID1":["1","1","0"],"tokenID2":["0","1","0"],"tokenID3":["0","0"],"txCompressedData":["22300745198530623141535718272648364828648975","22300745198550905551139370015129906117862927","3322668559"],"txCompressedDataV2":["0","87112286010988409160888309153670650396928","0"]}` //nolint:lll
  267. assert.Equal(t, expected, string(s))
  268. }
  269. // TestZKInputs1:
  270. // tests:
  271. // - L1: CreateAccountDeposit
  272. // - L2: Transfer (with fees)
  273. func TestZKInputs1(t *testing.T) {
  274. dir, err := ioutil.TempDir("", "tmpdb")
  275. require.NoError(t, err)
  276. defer assert.Nil(t, os.RemoveAll(dir))
  277. nLevels := 16
  278. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  279. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  280. require.NoError(t, err)
  281. chainID := uint16(0)
  282. users, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs := txsets.GenerateTxsZKInputs1(t, chainID)
  283. config := Config{
  284. NLevels: uint32(nLevels),
  285. MaxTx: 3,
  286. MaxL1Tx: 2,
  287. MaxFeeTx: 2,
  288. ChainID: chainID,
  289. }
  290. tp := NewTxProcessor(sdb, config)
  291. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  292. require.NoError(t, err)
  293. // check expected account keys values from tx inputs
  294. acc, err := sdb.GetAccount(common.Idx(256))
  295. require.NoError(t, err)
  296. assert.Equal(t, users[0].BJJ.Public().Compress().String(), acc.BJJ.String())
  297. assert.Equal(t, users[0].Addr.Hex(), acc.EthAddr.Hex())
  298. assert.Equal(t, "15999899", acc.Balance.String())
  299. acc, err = sdb.GetAccount(common.Idx(257))
  300. require.NoError(t, err)
  301. assert.Equal(t, users[1].BJJ.Public().Compress().String(), acc.BJJ.String())
  302. assert.Equal(t, users[1].Addr.Hex(), acc.EthAddr.Hex())
  303. assert.Equal(t, "16000101", acc.Balance.String())
  304. // check that there no exist more accounts
  305. _, err = sdb.GetAccount(common.Idx(258))
  306. require.NotNil(t, err)
  307. // printZKInputs(t, ptOut.ZKInputs)
  308. h, err := ptOut.ZKInputs.HashGlobalData()
  309. require.NoError(t, err)
  310. assert.Equal(t,
  311. "4769975682103783301627482328403399304491751667854188770340972991469531152734",
  312. h.String())
  313. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  314. require.NoError(t, err)
  315. assert.Equal(t, "0000000000ff00000000010100000000000000000000000000000000000000000000000000000000000000000313ee32d5a5e47fd500f8e4f64c75b51ffb43c921567b59c953cd264cedf87400000000000000000000000000000000000000000000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d70000000000000000f424000000000000000000010000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf093985b1993d9f743f9d7d943ed56f38601cb8b196db025f79650c4007c3054d0000000000000000f4240000000000000000000100000000000000000000000000000000000000000000000000000100010000000003e87e01010000000000000001", hex.EncodeToString(toHash)) //nolint:lll
  316. s, err := json.Marshal(ptOut.ZKInputs)
  317. require.NoError(t, err)
  318. // the 'expected' data has been checked with the circom circuits
  319. expected := `{"amountF":["0","0","1000"],"auxFromIdx":["256","257","0"],"auxToIdx":["0","0","0"],"ay1":["15238403086306505038849621710779816852318505119327426213168494964113886299863","4172448640254579435434214421479401747968866348490029667576411173067925161293","15238403086306505038849621710779816852318505119327426213168494964113886299863"],"ay2":["0","0","15238403086306505038849621710779816852318505119327426213168494964113886299863"],"ay3":["4172448640254579435434214421479401747968866348490029667576411173067925161293","0"],"balance1":["16000000","16000000","16000000"],"balance2":["0","0","15998899"],"balance3":["16000000","0"],"currentNumBatch":"1","ethAddr1":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","721457446580647751014191829380889690493307935711"],"ethAddr2":["0","0","721457446580647751014191829380889690493307935711"],"ethAddr3":["247512291986854564435551364600938690683113101007","0"],"feeIdxs":["257","0"],"feePlanTokens":["1","0"],"fromBjjCompressed":[["1","1","1","0","1","0","1","1","0","1","1","0","0","0","1","0","0","1","0","0","0","0","0","1","1","1","1","1","0","0","1","0","1","0","1","1","1","1","1","0","0","1","0","1","0","0","0","0","1","0","1","0","0","0","1","1","0","0","1","0","0","0","0","0","0","1","0","1","0","0","1","0","1","1","1","0","1","0","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","1","0","0","1","0","0","1","1","0","1","0","0","0","1","1","1","1","0","0","0","1","1","0","1","0","1","1","0","1","0","1","1","0","1","1","0","1","1","0","1","1","0","0","1","0","0","0","0","0","1","1","1","0","1","1","1","0","0","0","0","1","1","0","1","1","1","1","0","0","1","1","1","0","0","1","0","1","0","1","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","1","0","0","0","1","1","0","1","1","1","1","0","1","1","1","0","1","1","1","1","1","1","1","0","1","1","0","0","1","1","0","1","0","0","0","1","0","0","0","1","0","1","1","0","1","0","0","0","0","1","0","1","0","0","0","0","1","1","0","1","1","0","0","0","0","1","0","0"],["1","0","1","1","0","0","1","0","1","0","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","0","0","1","1","1","1","0","1","1","1","1","1","0","1","0","0","1","0","0","0","0","0","0","1","1","0","1","1","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","0","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","0","1","1","1","1","0","1","1","0","1","0","1","0","1","0","1","1","0","1","1","1","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","1","1","1","1","0","1","0","1","1","1","0","0","1","1","1","1","1","1","1","0","0","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","0","1","1","1","1","0","0","1","0","0","1","1","0","0","1","1","0","0","0","1","1","0","1","1","0","1","0","0","0","0","1","1","0","0","1","1","1","0","0","1","0","0","1","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","0"],"fromIdx":["0","0","256"],"globalChainID":"0","imAccFeeOut":[["0","0"],["0","0"]],"imExitRoot":["0","0"],"imFinalAccFee":["101","0"],"imInitStateRootFee":"4701211614901671622906638145267049140901820673296178124795093273962348087623","imOnChain":["1","1"],"imOutIdx":["256","257"],"imStateRoot":["9864363881518933755872975814973434564014010763285201917208728592660216535879","5464828090683525701848539079562826610593498026797583519227991802661481319398"],"imStateRootFee":["1392152626108220351776484223832756350024459120043243879257905623047508719732"],"isOld0_1":["1","0","0"],"isOld0_2":["0","0","0"],"loadAmountF":["16000000","16000000","0"],"maxNumBatch":["0","0","0"],"newAccount":["1","1","0"],"newExit":["0","0","0"],"nonce1":["0","0","0"],"nonce2":["0","0","1"],"nonce3":["0","0"],"oldKey1":["0","256","0"],"oldKey2":["0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","19640802975431343835432574856056762450507078736963927763903813795922811702786","0"],"oldValue2":["0","0","0"],"onChain":["1","1","0"],"r8x":["0","0","865587427317261018969747933724484238890490037749223349749343817734915365056"],"r8y":["0","0","10097882213180588855407259454126651013708340487137819946446911422749059296357"],"rqOffset":["0","0","0"],"rqToBjjAy":["0","0","0"],"rqToEthAddr":["0","0","0"],"rqTxCompressedDataV2":["0","0","0"],"s":["0","0","158611668210751947510096164919575153990763953488269869923668683740564737855"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["16181420716631932805604732887923905079487577323947343079740042260791593140221","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0"],"sign2":["0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0"],"toEthAddr":["0","0","0"],"toIdx":["0","0","256"],"tokenID1":["1","1","1"],"tokenID2":["0","0","1"],"tokenID3":["1","0"],"txCompressedData":["22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","13269348750238205523937693788887673023086333159839203147949301032463"],"txCompressedDataV2":["0","0","51833393555617990327881616362842551895365340655766919366131581184"]}` //nolint:lll
  320. assert.Equal(t, expected, string(s))
  321. }
  322. // TestZKInputs2:
  323. // Similar to TestZKInputs1, but with bigger circuit
  324. // tests:
  325. // - L1: CreateAccountDeposit
  326. // - L2: Transfer (with fees)
  327. func TestZKInputs2(t *testing.T) {
  328. dir, err := ioutil.TempDir("", "tmpdb")
  329. require.NoError(t, err)
  330. defer assert.Nil(t, os.RemoveAll(dir))
  331. nLevels := 16
  332. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  333. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  334. require.NoError(t, err)
  335. chainID := uint16(0)
  336. users, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs := txsets.GenerateTxsZKInputs2(t, chainID)
  337. config := Config{
  338. NLevels: uint32(nLevels),
  339. MaxTx: 10,
  340. MaxL1Tx: 4,
  341. MaxFeeTx: 2,
  342. ChainID: chainID,
  343. }
  344. tp := NewTxProcessor(sdb, config)
  345. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  346. require.NoError(t, err)
  347. // check expected account keys values from tx inputs
  348. acc, err := sdb.GetAccount(common.Idx(256))
  349. require.NoError(t, err)
  350. assert.Equal(t, users[0].BJJ.Public().Compress().String(), acc.BJJ.String())
  351. assert.Equal(t, users[0].Addr.Hex(), acc.EthAddr.Hex())
  352. assert.Equal(t, "15997798", acc.Balance.String())
  353. acc, err = sdb.GetAccount(common.Idx(257))
  354. require.NoError(t, err)
  355. assert.Equal(t, users[1].BJJ.Public().Compress().String(), acc.BJJ.String())
  356. assert.Equal(t, users[1].Addr.Hex(), acc.EthAddr.Hex())
  357. assert.Equal(t, "16000202", acc.Balance.String())
  358. acc, err = sdb.GetAccount(common.Idx(258))
  359. require.NoError(t, err)
  360. assert.Equal(t, users[2].BJJ.Public().Compress().String(), acc.BJJ.String())
  361. assert.Equal(t, users[2].Addr.Hex(), acc.EthAddr.Hex())
  362. assert.Equal(t, "16001000", acc.Balance.String())
  363. acc, err = sdb.GetAccount(common.Idx(259))
  364. require.NoError(t, err)
  365. assert.Equal(t, users[3].BJJ.Public().Compress().String(), acc.BJJ.String())
  366. assert.Equal(t, users[3].Addr.Hex(), acc.EthAddr.Hex())
  367. assert.Equal(t, "16001000", acc.Balance.String())
  368. // check that there no exist more accounts
  369. _, err = sdb.GetAccount(common.Idx(260))
  370. require.NotNil(t, err)
  371. // printZKInputs(t, ptOut.ZKInputs)
  372. h, err := ptOut.ZKInputs.HashGlobalData()
  373. require.NoError(t, err)
  374. assert.Equal(t,
  375. "2680347631898543468383081668469450804381778427022985081745025651147893197868",
  376. h.String())
  377. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  378. require.NoError(t, err)
  379. assert.Equal(t, "0000000000ff00000000010300000000000000000000000000000000000000000000000000000000000000000f82896e1e624529ca3b532282c8f5e2ce183deaa220cccf648b5eced6382ccc00000000000000000000000000000000000000000000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d70000000000000000f424000000000000000000010000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf093985b1993d9f743f9d7d943ed56f38601cb8b196db025f79650c4007c3054d0000000000000000f424000000000000000000010000000000006813eb9362372eef6200f3b1dbc3f819671cba6911fe412a6f9b7532ff9263f16c4062892406e203252a952aeb62457202a0ff380000000000000000f424000000000000000000010000000000001eff47bc3a10a45d4b230b5d10e37751fe6aa7180b764f45f5aded093b1a347515c0335275e28f44d3fcfba77fbe901140e619c70000000000000000f42400000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100010200000003e87e0100010300000003e87e0000000000000000000000000000000000000000000000000000000000000000000000000000000001010000000000000001", hex.EncodeToString(toHash)) //nolint:lll
  380. s, err := json.Marshal(ptOut.ZKInputs)
  381. require.NoError(t, err)
  382. // the 'expected' data has been checked with the circom circuits
  383. expected := `{"amountF":["0","0","0","0","1000","1000","0","0","0","0"],"auxFromIdx":["256","257","258","259","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0"],"ay1":["15238403086306505038849621710779816852318505119327426213168494964113886299863","4172448640254579435434214421479401747968866348490029667576411173067925161293","8138547337953155637712635674046872799144091023272207542905444721067900862264","5184476412130556544090991668866402222418200486089222951317185404775371774407","15238403086306505038849621710779816852318505119327426213168494964113886299863","15238403086306505038849621710779816852318505119327426213168494964113886299863","0","0","0","0"],"ay2":["0","0","0","0","8138547337953155637712635674046872799144091023272207542905444721067900862264","5184476412130556544090991668866402222418200486089222951317185404775371774407","0","0","0","0"],"ay3":["4172448640254579435434214421479401747968866348490029667576411173067925161293","0"],"balance1":["16000000","16000000","16000000","16000000","16000000","15998899","0","0","0","0"],"balance2":["0","0","0","0","16000000","16000000","0","0","0","0"],"balance3":["16000000","0"],"currentNumBatch":"1","ethAddr1":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0","0","0","0"],"ethAddr2":["0","0","0","0","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","0","0","0","0"],"ethAddr3":["247512291986854564435551364600938690683113101007","0"],"feeIdxs":["257","0"],"feePlanTokens":["1","0"],"fromBjjCompressed":[["1","1","1","0","1","0","1","1","0","1","1","0","0","0","1","0","0","1","0","0","0","0","0","1","1","1","1","1","0","0","1","0","1","0","1","1","1","1","1","0","0","1","0","1","0","0","0","0","1","0","1","0","0","0","1","1","0","0","1","0","0","0","0","0","0","1","0","1","0","0","1","0","1","1","1","0","1","0","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","1","0","0","1","0","0","1","1","0","1","0","0","0","1","1","1","1","0","0","0","1","1","0","1","0","1","1","0","1","0","1","1","0","1","1","0","1","1","0","1","1","0","0","1","0","0","0","0","0","1","1","1","0","1","1","1","0","0","0","0","1","1","0","1","1","1","1","0","0","1","1","1","0","0","1","0","1","0","1","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","1","0","0","0","1","1","0","1","1","1","1","0","1","1","1","0","1","1","1","1","1","1","1","0","1","1","0","0","1","1","0","1","0","0","0","1","0","0","0","1","0","1","1","0","1","0","0","0","0","1","0","1","0","0","0","0","1","1","0","1","1","0","0","0","0","1","0","0"],["1","0","1","1","0","0","1","0","1","0","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","0","0","1","1","1","1","0","1","1","1","1","1","0","1","0","0","1","0","0","0","0","0","0","1","1","0","1","1","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","0","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","0","1","1","1","1","0","1","1","0","1","0","1","0","1","0","1","1","0","1","1","1","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","1","1","1","1","0","1","0","1","1","1","0","0","1","1","1","1","1","1","1","0","0","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","0","1","1","1","1","0","0","1","0","0","1","1","0","0","1","1","0","0","0","1","1","0","1","1","0","1","0","0","0","0","1","1","0","0","1","1","1","0","0","1","0","0","1","0","0","0","0"],["0","0","0","1","1","1","0","0","1","1","1","1","1","1","1","1","0","0","0","0","0","1","0","1","0","1","0","0","0","0","0","0","0","1","0","0","1","1","1","0","1","0","1","0","0","0","1","0","0","1","0","0","0","1","1","0","1","1","0","1","0","1","1","1","0","1","0","1","0","1","0","0","1","0","1","0","1","0","0","1","0","1","0","1","0","1","0","0","1","0","1","0","0","1","0","0","1","1","0","0","0","0","0","0","0","1","0","0","0","1","1","1","0","1","1","0","0","0","0","0","0","0","1","0","0","1","0","0","1","0","0","1","0","0","0","1","0","1","0","0","0","1","1","0","0","0","0","0","0","0","1","0","0","0","1","1","0","1","1","0","1","0","0","0","1","1","1","1","1","1","0","0","0","1","1","0","0","1","0","0","1","0","0","1","1","1","1","1","1","1","1","1","0","1","0","0","1","1","0","0","1","0","1","0","1","1","1","0","1","1","0","1","1","0","0","1","1","1","1","1","0","1","1","0","0","1","0","1","0","1","0","0","1","0","0","0","0","0","1","0","0","1","1","1","1","1","1","1","1","0","0","0","1","0","0","0"],["1","1","1","0","0","0","1","1","1","0","0","1","1","0","0","0","0","1","1","0","0","1","1","1","0","0","0","0","0","0","1","0","1","0","0","0","1","0","0","0","0","0","0","0","1","0","0","1","0","1","1","1","1","1","0","1","1","1","1","1","1","1","1","0","1","1","1","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","1","1","1","1","1","1","0","0","1","0","1","1","0","0","1","0","0","0","1","0","1","1","1","1","0","0","0","1","0","1","0","0","0","1","1","1","1","0","1","0","1","1","1","0","0","1","0","0","1","0","1","0","1","1","0","0","1","1","0","0","0","0","0","0","0","0","1","1","1","0","1","0","1","0","0","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","0","0","0","1","0","1","1","0","0","0","1","1","0","1","1","1","0","0","1","0","0","1","0","0","0","0","1","0","1","1","0","1","1","1","1","0","1","1","0","1","0","1","1","0","1","0","1","1","1","1","1","0","1","0","0","0","1","0","1","1","1","1","0","0","1","0","0","1","1","0","1","1","1","0","1","1","0","1","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","256","256","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0"],["0","0"],["0","0"],["0","0"],["101","0"],["202","0"],["202","0"],["202","0"],["202","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["202","0"],"imInitStateRootFee":"14705087142182902021865387279619603616348670534852729618730348206461589083539","imOnChain":["1","1","1","1","0","0","0","0","0"],"imOutIdx":["256","257","258","259","259","259","259","259","259"],"imStateRoot":["9864363881518933755872975814973434564014010763285201917208728592660216535879","5464828090683525701848539079562826610593498026797583519227991802661481319398","21757119152350828398458192463999984214478561077268984476451182370038048671794","820233650408376145207092987547556409298548608116495110406312712740014032930","19702284217210216414869816996626037095309251913519952996692665368821744508118","14705087142182902021865387279619603616348670534852729618730348206461589083539","14705087142182902021865387279619603616348670534852729618730348206461589083539","14705087142182902021865387279619603616348670534852729618730348206461589083539","14705087142182902021865387279619603616348670534852729618730348206461589083539"],"imStateRootFee":["7015331355213624235010964992837431121205876434761120578120125821230582869196"],"isOld0_1":["1","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["16000000","16000000","16000000","16000000","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","1","1","1","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","1","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0"],"oldKey1":["0","256","256","257","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","19640802975431343835432574856056762450507078736963927763903813795922811702786","19640802975431343835432574856056762450507078736963927763903813795922811702786","7011122728196526556362175003763228196463322346418732717978342330615268049804","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0"],"onChain":["1","1","1","1","0","0","0","0","0","0"],"r8x":["0","0","0","0","19866842755434711891463587603163698981005220536588982690510091305303742487133","7562237590013712974129550048252619257820926688209864287779119583235290095359","0","0","0","0"],"r8y":["0","0","0","0","12516632933343659347565213901850695623540287728505725401985587559578384224418","9753018860351521991289171174252511221910263127742150249304956090751586258314","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","367452715170916245887301982266240387928267340885855692824342516281499768160","1825531714675406316210058758988277481331565066389486637779648290677818056282","0","0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["8754013549394880600214720851516281765874528110684674870941000589987097751393","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9291151758418258889310802508183552818496920530352746070107986561729796276422","17734111280499127219998634548631057749549617782307447116305772550966560406740","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9291151758418258889310802508183552818496920530352746070107986561729796276422","8500123404203352732703470005331022998122216024636231599036564381054444654302","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9291151758418258889310802508183552818496920530352746070107986561729796276422","755276081112069011563151270065961196621734344759807910052861456278819469813","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["6569103230855390462319223099443032644543936241853450242177678371764000894784","14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["6569103230855390462319223099443032644543936241853450242177678371764000894784","4639068079695973420444140421529722600221567914703678021061203215475909340529","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","0","258","259","0","0","0","0"],"tokenID1":["1","1","1","1","1","1","0","0","0","0"],"tokenID2":["0","0","0","0","1","1","0","0","0","0"],"tokenID3":["1","0"],"txCompressedData":["22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","13269348750238205523937693788887673023244789484867731823136388933135","13269348750238301304908997906941320420013214541705972331925069358607","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","51833393555617990327881616362842551895365340655767482316085002496","51833393555618364472300773073989612038682516024220795709792715008","0","0","0","0"]}` //nolint:lll
  384. assert.Equal(t, expected, string(s))
  385. }
  386. // TestZKInputs3:
  387. // tests:
  388. // - L1: CreateAccountDeposit, CreateAccountDepositTransfer
  389. // - L2: Transfer (with fees)
  390. func TestZKInputs3(t *testing.T) {
  391. dir, err := ioutil.TempDir("", "tmpdb")
  392. require.NoError(t, err)
  393. defer assert.Nil(t, os.RemoveAll(dir))
  394. nLevels := 16
  395. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  396. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  397. require.NoError(t, err)
  398. chainID := uint16(0)
  399. users, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs := txsets.GenerateTxsZKInputs3(t, chainID)
  400. config := Config{
  401. NLevels: uint32(nLevels),
  402. MaxTx: 10,
  403. MaxL1Tx: 4,
  404. MaxFeeTx: 2,
  405. ChainID: chainID,
  406. }
  407. tp := NewTxProcessor(sdb, config)
  408. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  409. require.NoError(t, err)
  410. // check expected account keys values from tx inputs
  411. acc, err := sdb.GetAccount(common.Idx(256))
  412. require.NoError(t, err)
  413. assert.Equal(t, users[0].BJJ.Public().Compress().String(), acc.BJJ.String())
  414. assert.Equal(t, users[0].Addr.Hex(), acc.EthAddr.Hex())
  415. assert.Equal(t, "15997798", acc.Balance.String())
  416. acc, err = sdb.GetAccount(common.Idx(257))
  417. require.NoError(t, err)
  418. assert.Equal(t, users[1].BJJ.Public().Compress().String(), acc.BJJ.String())
  419. assert.Equal(t, users[1].Addr.Hex(), acc.EthAddr.Hex())
  420. assert.Equal(t, "16000202", acc.Balance.String())
  421. acc, err = sdb.GetAccount(common.Idx(258))
  422. require.NoError(t, err)
  423. assert.Equal(t, users[2].BJJ.Public().Compress().String(), acc.BJJ.String())
  424. assert.Equal(t, users[2].Addr.Hex(), acc.EthAddr.Hex())
  425. assert.Equal(t, "16002000", acc.Balance.String())
  426. acc, err = sdb.GetAccount(common.Idx(259))
  427. require.NoError(t, err)
  428. assert.Equal(t, users[3].BJJ.Public().Compress().String(), acc.BJJ.String())
  429. assert.Equal(t, users[3].Addr.Hex(), acc.EthAddr.Hex())
  430. assert.Equal(t, "16000000", acc.Balance.String())
  431. // check that there no exist more accounts
  432. _, err = sdb.GetAccount(common.Idx(260))
  433. require.NotNil(t, err)
  434. // printZKInputs(t, ptOut.ZKInputs)
  435. h, err := ptOut.ZKInputs.HashGlobalData()
  436. require.NoError(t, err)
  437. assert.Equal(t,
  438. "8283229913960298519648241556943670996572673393348815027814188830846761517089",
  439. h.String())
  440. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  441. require.NoError(t, err)
  442. assert.Equal(t, "0000000000ff00000000010300000000000000000000000000000000000000000000000000000000000000001b84f6f43c7047d2d2b23e266fa1c3c4e8b2e1631bfddc3e96ea6b74ee9ed13700000000000000000000000000000000000000000000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d70000000000000000f424000000000000000000010000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf093985b1993d9f743f9d7d943ed56f38601cb8b196db025f79650c4007c3054d0000000000000000f424000000000000000000010000000000006813eb9362372eef6200f3b1dbc3f819671cba6911fe412a6f9b7532ff9263f16c4062892406e203252a952aeb62457202a0ff380000000000000000f424000000000000000000010000000000001eff47bc3a10a45d4b230b5d10e37751fe6aa7180b764f45f5aded093b1a347515c0335275e28f44d3fcfba77fbe901140e619c70000000000000000f4240000000003e8000000010000000001020000000000000000000000000000000000000000000000000000000000000000010200000003e8000100010200000003e87e0100010300000003e87e0000000000000000000000000000000000000000000000000000000000000000000000000000000001010000000000000001", hex.EncodeToString(toHash)) //nolint:lll
  443. s, err := json.Marshal(ptOut.ZKInputs)
  444. require.NoError(t, err)
  445. // the 'expected' data has been checked with the circom circuits
  446. expected := `{"amountF":["0","0","0","1000","1000","1000","0","0","0","0"],"auxFromIdx":["256","257","258","259","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0"],"ay1":["15238403086306505038849621710779816852318505119327426213168494964113886299863","4172448640254579435434214421479401747968866348490029667576411173067925161293","8138547337953155637712635674046872799144091023272207542905444721067900862264","5184476412130556544090991668866402222418200486089222951317185404775371774407","15238403086306505038849621710779816852318505119327426213168494964113886299863","15238403086306505038849621710779816852318505119327426213168494964113886299863","0","0","0","0"],"ay2":["0","0","0","8138547337953155637712635674046872799144091023272207542905444721067900862264","8138547337953155637712635674046872799144091023272207542905444721067900862264","5184476412130556544090991668866402222418200486089222951317185404775371774407","0","0","0","0"],"ay3":["4172448640254579435434214421479401747968866348490029667576411173067925161293","0"],"balance1":["16000000","16000000","16000000","16000000","16000000","15998899","0","0","0","0"],"balance2":["0","0","0","16000000","16001000","15999000","0","0","0","0"],"balance3":["16000000","0"],"currentNumBatch":"1","ethAddr1":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0","0","0","0"],"ethAddr2":["0","0","0","594179275863704165266696689399235767493667371625","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","0","0","0","0"],"ethAddr3":["247512291986854564435551364600938690683113101007","0"],"feeIdxs":["257","0"],"feePlanTokens":["1","0"],"fromBjjCompressed":[["1","1","1","0","1","0","1","1","0","1","1","0","0","0","1","0","0","1","0","0","0","0","0","1","1","1","1","1","0","0","1","0","1","0","1","1","1","1","1","0","0","1","0","1","0","0","0","0","1","0","1","0","0","0","1","1","0","0","1","0","0","0","0","0","0","1","0","1","0","0","1","0","1","1","1","0","1","0","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","1","0","0","1","0","0","1","1","0","1","0","0","0","1","1","1","1","0","0","0","1","1","0","1","0","1","1","0","1","0","1","1","0","1","1","0","1","1","0","1","1","0","0","1","0","0","0","0","0","1","1","1","0","1","1","1","0","0","0","0","1","1","0","1","1","1","1","0","0","1","1","1","0","0","1","0","1","0","1","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","1","0","0","0","1","1","0","1","1","1","1","0","1","1","1","0","1","1","1","1","1","1","1","0","1","1","0","0","1","1","0","1","0","0","0","1","0","0","0","1","0","1","1","0","1","0","0","0","0","1","0","1","0","0","0","0","1","1","0","1","1","0","0","0","0","1","0","0"],["1","0","1","1","0","0","1","0","1","0","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","0","0","1","1","1","1","0","1","1","1","1","1","0","1","0","0","1","0","0","0","0","0","0","1","1","0","1","1","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","0","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","0","1","1","1","1","0","1","1","0","1","0","1","0","1","0","1","1","0","1","1","1","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","1","1","1","1","0","1","0","1","1","1","0","0","1","1","1","1","1","1","1","0","0","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","0","1","1","1","1","0","0","1","0","0","1","1","0","0","1","1","0","0","0","1","1","0","1","1","0","1","0","0","0","0","1","1","0","0","1","1","1","0","0","1","0","0","1","0","0","0","0"],["0","0","0","1","1","1","0","0","1","1","1","1","1","1","1","1","0","0","0","0","0","1","0","1","0","1","0","0","0","0","0","0","0","1","0","0","1","1","1","0","1","0","1","0","0","0","1","0","0","1","0","0","0","1","1","0","1","1","0","1","0","1","1","1","0","1","0","1","0","1","0","0","1","0","1","0","1","0","0","1","0","1","0","1","0","1","0","0","1","0","1","0","0","1","0","0","1","1","0","0","0","0","0","0","0","1","0","0","0","1","1","1","0","1","1","0","0","0","0","0","0","0","1","0","0","1","0","0","1","0","0","1","0","0","0","1","0","1","0","0","0","1","1","0","0","0","0","0","0","0","1","0","0","0","1","1","0","1","1","0","1","0","0","0","1","1","1","1","1","1","0","0","0","1","1","0","0","1","0","0","1","0","0","1","1","1","1","1","1","1","1","1","0","1","0","0","1","1","0","0","1","0","1","0","1","1","1","0","1","1","0","1","1","0","0","1","1","1","1","1","0","1","1","0","0","1","0","1","0","1","0","0","1","0","0","0","0","0","1","0","0","1","1","1","1","1","1","1","1","0","0","0","1","0","0","0"],["1","1","1","0","0","0","1","1","1","0","0","1","1","0","0","0","0","1","1","0","0","1","1","1","0","0","0","0","0","0","1","0","1","0","0","0","1","0","0","0","0","0","0","0","1","0","0","1","0","1","1","1","1","1","0","1","1","1","1","1","1","1","1","0","1","1","1","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","1","1","1","1","1","1","0","0","1","0","1","1","0","0","1","0","0","0","1","0","1","1","1","1","0","0","0","1","0","1","0","0","0","1","1","1","1","0","1","0","1","1","1","0","0","1","0","0","1","0","1","0","1","1","0","0","1","1","0","0","0","0","0","0","0","0","1","1","1","0","1","0","1","0","0","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","0","0","0","1","0","1","1","0","0","0","1","1","0","1","1","1","0","0","1","0","0","1","0","0","0","0","1","0","1","1","0","1","1","1","1","0","1","1","0","1","0","1","1","0","1","0","1","1","1","1","1","0","1","0","0","0","1","0","1","1","1","1","0","0","1","0","0","1","1","0","1","1","1","0","1","1","0","1","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","256","256","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0"],["0","0"],["0","0"],["0","0"],["101","0"],["202","0"],["202","0"],["202","0"],["202","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["202","0"],"imInitStateRootFee":"4026424569980514971696065746468190357130483308144324868789920383248035038819","imOnChain":["1","1","1","1","0","0","0","0","0"],"imOutIdx":["256","257","258","259","259","259","259","259","259"],"imStateRoot":["9864363881518933755872975814973434564014010763285201917208728592660216535879","5464828090683525701848539079562826610593498026797583519227991802661481319398","21757119152350828398458192463999984214478561077268984476451182370038048671794","6274319989607135037509455697614581234209673521766435697340076617581528324331","8229855223197541407644598707174576558155263092226693766876296040565017546333","4026424569980514971696065746468190357130483308144324868789920383248035038819","4026424569980514971696065746468190357130483308144324868789920383248035038819","4026424569980514971696065746468190357130483308144324868789920383248035038819","4026424569980514971696065746468190357130483308144324868789920383248035038819"],"imStateRootFee":["12447375138492163524709755517824739051233681924343009042369915486279129026871"],"isOld0_1":["1","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["16000000","16000000","16000000","16000000","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","1","1","1","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","1","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0"],"oldKey1":["0","256","256","257","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","19640802975431343835432574856056762450507078736963927763903813795922811702786","19640802975431343835432574856056762450507078736963927763903813795922811702786","7011122728196526556362175003763228196463322346418732717978342330615268049804","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0"],"onChain":["1","1","1","1","0","0","0","0","0","0"],"r8x":["0","0","0","0","19866842755434711891463587603163698981005220536588982690510091305303742487133","7562237590013712974129550048252619257820926688209864287779119583235290095359","0","0","0","0"],"r8y":["0","0","0","0","12516632933343659347565213901850695623540287728505725401985587559578384224418","9753018860351521991289171174252511221910263127742150249304956090751586258314","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","367452715170916245887301982266240387928267340885855692824342516281499768160","1825531714675406316210058758988277481331565066389486637779648290677818056282","0","0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["8754013549394880600214720851516281765874528110684674870941000589987097751393","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9070450449079106190728972463766836113023769072886878712846312355113394063496","8500123404203352732703470005331022998122216024636231599036564381054444654302","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9070450449079106190728972463766836113023769072886878712846312355113394063496","6616161815122071189942148458373187369126387999697893283891950095684741920550","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9070450449079106190728972463766836113023769072886878712846312355113394063496","9864363881518933755872975814973434564014010763285201917208728592660216535879","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9070450449079106190728972463766836113023769072886878712846312355113394063496","755276081112069011563151270065961196621734344759807910052861456278819469813","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["6437624657858515682347820028282144502401370623634575182982124631464308858310","14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["6437624657858515682347820028282144502401370623634575182982124631464308858310","19845465682517582670119932353544738273771586444440738393117757917681124339291","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","258","258","259","0","0","0","0"],"tokenID1":["1","1","1","1","1","1","0","0","0","0"],"tokenID2":["0","0","0","1","1","1","0","0","0","0"],"tokenID3":["1","0"],"txCompressedData":["22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","22300745198551064007464398471747499167835663","13269348750238205523937693788887673023244789484867731823136388933135","13269348750238301304908997906941320420013214541705972331925069358607","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","51833393555617990327881616362842551895365340655767482316085002496","51833393555618364472300773073989612038682516024220795709792715008","0","0","0","0"]}` //nolint:lll
  447. assert.Equal(t, expected, string(s))
  448. }
  449. // TestZKInputs4:
  450. // tests:
  451. // - L1: CreateAccountDeposit, CreateAccountDepositTransfer, DepositTransfer
  452. // - L2: Transfer
  453. func TestZKInputs4(t *testing.T) {
  454. dir, err := ioutil.TempDir("", "tmpdb")
  455. require.NoError(t, err)
  456. defer assert.Nil(t, os.RemoveAll(dir))
  457. nLevels := 16
  458. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  459. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  460. require.NoError(t, err)
  461. chainID := uint16(0)
  462. users, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs := txsets.GenerateTxsZKInputs4(t, chainID)
  463. config := Config{
  464. NLevels: uint32(nLevels),
  465. MaxTx: 10,
  466. MaxL1Tx: 5,
  467. MaxFeeTx: 2,
  468. ChainID: chainID,
  469. }
  470. tp := NewTxProcessor(sdb, config)
  471. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  472. require.NoError(t, err)
  473. // check expected account keys values from tx inputs
  474. acc, err := sdb.GetAccount(common.Idx(256))
  475. require.NoError(t, err)
  476. assert.Equal(t, users[0].BJJ.Public().Compress().String(), acc.BJJ.String())
  477. assert.Equal(t, users[0].Addr.Hex(), acc.EthAddr.Hex())
  478. assert.Equal(t, "15997798", acc.Balance.String())
  479. acc, err = sdb.GetAccount(common.Idx(257))
  480. require.NoError(t, err)
  481. assert.Equal(t, users[1].BJJ.Public().Compress().String(), acc.BJJ.String())
  482. assert.Equal(t, users[1].Addr.Hex(), acc.EthAddr.Hex())
  483. assert.Equal(t, "16000202", acc.Balance.String())
  484. acc, err = sdb.GetAccount(common.Idx(258))
  485. require.NoError(t, err)
  486. assert.Equal(t, users[2].BJJ.Public().Compress().String(), acc.BJJ.String())
  487. assert.Equal(t, users[2].Addr.Hex(), acc.EthAddr.Hex())
  488. assert.Equal(t, "32001000", acc.Balance.String())
  489. acc, err = sdb.GetAccount(common.Idx(259))
  490. require.NoError(t, err)
  491. assert.Equal(t, users[3].BJJ.Public().Compress().String(), acc.BJJ.String())
  492. assert.Equal(t, users[3].Addr.Hex(), acc.EthAddr.Hex())
  493. assert.Equal(t, "16001000", acc.Balance.String())
  494. // check that there no exist more accounts
  495. _, err = sdb.GetAccount(common.Idx(260))
  496. require.NotNil(t, err)
  497. // printZKInputs(t, ptOut.ZKInputs)
  498. h, err := ptOut.ZKInputs.HashGlobalData()
  499. require.NoError(t, err)
  500. assert.Equal(t,
  501. "6901252428240482276831660663991736752545421443183955059356516008029513034893",
  502. h.String())
  503. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  504. require.NoError(t, err)
  505. assert.Equal(t, "0000000000ff000000000103000000000000000000000000000000000000000000000000000000000000000002c040d3840f7dbadaeef65d01caf00ba5ac7b0f90a4ddf1ab1532d63df3e4de00000000000000000000000000000000000000000000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d70000000000000000f424000000000000000000010000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf093985b1993d9f743f9d7d943ed56f38601cb8b196db025f79650c4007c3054d0000000000000000f424000000000000000000010000000000006813eb9362372eef6200f3b1dbc3f819671cba6911fe412a6f9b7532ff9263f16c4062892406e203252a952aeb62457202a0ff380000000000000000f424000000000000000000010000000000001eff47bc3a10a45d4b230b5d10e37751fe6aa7180b764f45f5aded093b1a347515c0335275e28f44d3fcfba77fbe901140e619c70000000000000000f4240000000003e8000000010000000001026813eb9362372eef6200f3b1dbc3f819671cba6900000000000000000000000000000000000000000000000000000000000000000000000001020000f4240000000003e8000000010000000001030000000000000000000000000000000000000000000000000000000000000000010200000003e8000102010300000003e8000100010200000003e87e0100010300000003e87e00000000000000000000000000000000000000000000000000000000000001010000000000000001", hex.EncodeToString(toHash)) //nolint
  506. s, err := json.Marshal(ptOut.ZKInputs)
  507. require.NoError(t, err)
  508. // the 'expected' data has been checked with the circom circuits
  509. expected := `{"amountF":["0","0","0","1000","1000","1000","1000","0","0","0"],"auxFromIdx":["256","257","258","259","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0"],"ay1":["15238403086306505038849621710779816852318505119327426213168494964113886299863","4172448640254579435434214421479401747968866348490029667576411173067925161293","8138547337953155637712635674046872799144091023272207542905444721067900862264","5184476412130556544090991668866402222418200486089222951317185404775371774407","8138547337953155637712635674046872799144091023272207542905444721067900862264","15238403086306505038849621710779816852318505119327426213168494964113886299863","15238403086306505038849621710779816852318505119327426213168494964113886299863","0","0","0"],"ay2":["0","0","0","8138547337953155637712635674046872799144091023272207542905444721067900862264","5184476412130556544090991668866402222418200486089222951317185404775371774407","8138547337953155637712635674046872799144091023272207542905444721067900862264","5184476412130556544090991668866402222418200486089222951317185404775371774407","0","0","0"],"ay3":["4172448640254579435434214421479401747968866348490029667576411173067925161293","0"],"balance1":["16000000","16000000","16000000","16000000","16001000","16000000","15998899","0","0","0"],"balance2":["0","0","0","16000000","15999000","32000000","16000000","0","0","0"],"balance3":["16000000","0"],"currentNumBatch":"1","ethAddr1":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","594179275863704165266696689399235767493667371625","721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0","0","0"],"ethAddr2":["0","0","0","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","0","0","0"],"ethAddr3":["247512291986854564435551364600938690683113101007","0"],"feeIdxs":["257","0"],"feePlanTokens":["1","0"],"fromBjjCompressed":[["1","1","1","0","1","0","1","1","0","1","1","0","0","0","1","0","0","1","0","0","0","0","0","1","1","1","1","1","0","0","1","0","1","0","1","1","1","1","1","0","0","1","0","1","0","0","0","0","1","0","1","0","0","0","1","1","0","0","1","0","0","0","0","0","0","1","0","1","0","0","1","0","1","1","1","0","1","0","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","1","0","0","1","0","0","1","1","0","1","0","0","0","1","1","1","1","0","0","0","1","1","0","1","0","1","1","0","1","0","1","1","0","1","1","0","1","1","0","1","1","0","0","1","0","0","0","0","0","1","1","1","0","1","1","1","0","0","0","0","1","1","0","1","1","1","1","0","0","1","1","1","0","0","1","0","1","0","1","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","1","0","0","0","1","1","0","1","1","1","1","0","1","1","1","0","1","1","1","1","1","1","1","0","1","1","0","0","1","1","0","1","0","0","0","1","0","0","0","1","0","1","1","0","1","0","0","0","0","1","0","1","0","0","0","0","1","1","0","1","1","0","0","0","0","1","0","0"],["1","0","1","1","0","0","1","0","1","0","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","0","0","1","1","1","1","0","1","1","1","1","1","0","1","0","0","1","0","0","0","0","0","0","1","1","0","1","1","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","0","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","0","1","1","1","1","0","1","1","0","1","0","1","0","1","0","1","1","0","1","1","1","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","1","1","1","1","0","1","0","1","1","1","0","0","1","1","1","1","1","1","1","0","0","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","0","1","1","1","1","0","0","1","0","0","1","1","0","0","1","1","0","0","0","1","1","0","1","1","0","1","0","0","0","0","1","1","0","0","1","1","1","0","0","1","0","0","1","0","0","0","0"],["0","0","0","1","1","1","0","0","1","1","1","1","1","1","1","1","0","0","0","0","0","1","0","1","0","1","0","0","0","0","0","0","0","1","0","0","1","1","1","0","1","0","1","0","0","0","1","0","0","1","0","0","0","1","1","0","1","1","0","1","0","1","1","1","0","1","0","1","0","1","0","0","1","0","1","0","1","0","0","1","0","1","0","1","0","1","0","0","1","0","1","0","0","1","0","0","1","1","0","0","0","0","0","0","0","1","0","0","0","1","1","1","0","1","1","0","0","0","0","0","0","0","1","0","0","1","0","0","1","0","0","1","0","0","0","1","0","1","0","0","0","1","1","0","0","0","0","0","0","0","1","0","0","0","1","1","0","1","1","0","1","0","0","0","1","1","1","1","1","1","0","0","0","1","1","0","0","1","0","0","1","0","0","1","1","1","1","1","1","1","1","1","0","1","0","0","1","1","0","0","1","0","1","0","1","1","1","0","1","1","0","1","1","0","0","1","1","1","1","1","0","1","1","0","0","1","0","1","0","1","0","0","1","0","0","0","0","0","1","0","0","1","1","1","1","1","1","1","1","0","0","0","1","0","0","0"],["1","1","1","0","0","0","1","1","1","0","0","1","1","0","0","0","0","1","1","0","0","1","1","1","0","0","0","0","0","0","1","0","1","0","0","0","1","0","0","0","0","0","0","0","1","0","0","1","0","1","1","1","1","1","0","1","1","1","1","1","1","1","1","0","1","1","1","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","1","1","1","1","1","1","0","0","1","0","1","1","0","0","1","0","0","0","1","0","1","1","1","1","0","0","0","1","0","1","0","0","0","1","1","1","1","0","1","0","1","1","1","0","0","1","0","0","1","0","1","0","1","1","0","0","1","1","0","0","0","0","0","0","0","0","1","1","1","0","1","0","1","0","0","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","0","0","0","1","0","1","1","0","0","0","1","1","0","1","1","1","0","0","1","0","0","1","0","0","0","0","1","0","1","1","0","1","1","1","1","0","1","1","0","1","0","1","1","0","1","0","1","1","1","1","1","0","1","0","0","0","1","0","1","1","1","1","0","0","1","0","0","1","1","0","1","1","1","0","1","1","0","1","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","594179275863704165266696689399235767493667371625","176962662172908264953938498278848696642639144728","594179275863704165266696689399235767493667371625","0","0","0","0","0"],"fromIdx":["0","0","0","0","258","256","256","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0"],["0","0"],["0","0"],["0","0"],["0","0"],["101","0"],["202","0"],["202","0"],["202","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["202","0"],"imInitStateRootFee":"13892272773241364335591835912712576640929058692530643098814037520434481445725","imOnChain":["1","1","1","1","1","0","0","0","0"],"imOutIdx":["256","257","258","259","259","259","259","259","259"],"imStateRoot":["9864363881518933755872975814973434564014010763285201917208728592660216535879","5464828090683525701848539079562826610593498026797583519227991802661481319398","21757119152350828398458192463999984214478561077268984476451182370038048671794","6274319989607135037509455697614581234209673521766435697340076617581528324331","18344102211581396878821265539614030907026729777237842585270784873616453799625","3819070746999004990111308709006887432791471680307789035861043508123353014070","13892272773241364335591835912712576640929058692530643098814037520434481445725","13892272773241364335591835912712576640929058692530643098814037520434481445725","13892272773241364335591835912712576640929058692530643098814037520434481445725"],"imStateRootFee":["1244307747826519115398224755296309242962058069501177791323349491597373072606"],"isOld0_1":["1","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["16000000","16000000","16000000","16000000","16000000","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","1","1","1","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","1","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0"],"oldKey1":["0","256","256","257","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","19640802975431343835432574856056762450507078736963927763903813795922811702786","19640802975431343835432574856056762450507078736963927763903813795922811702786","7011122728196526556362175003763228196463322346418732717978342330615268049804","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0"],"onChain":["1","1","1","1","1","0","0","0","0","0"],"r8x":["0","0","0","0","0","19866842755434711891463587603163698981005220536588982690510091305303742487133","7562237590013712974129550048252619257820926688209864287779119583235290095359","0","0","0"],"r8y":["0","0","0","0","0","12516632933343659347565213901850695623540287728505725401985587559578384224418","9753018860351521991289171174252511221910263127742150249304956090751586258314","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","367452715170916245887301982266240387928267340885855692824342516281499768160","1825531714675406316210058758988277481331565066389486637779648290677818056282","0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["8754013549394880600214720851516281765874528110684674870941000589987097751393","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9070450449079106190728972463766836113023769072886878712846312355113394063496","9864363881518933755872975814973434564014010763285201917208728592660216535879","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9291151758418258889310802508183552818496920530352746070107986561729796276422","15223745864287444685328306463590755923867207909634671085921808173893239289704","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9291151758418258889310802508183552818496920530352746070107986561729796276422","6992682896545058557675125520963795864508085598511115874687950877907588708906","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9070450449079106190728972463766836113023769072886878712846312355113394063496","9864363881518933755872975814973434564014010763285201917208728592660216535879","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["18402002860215861753509241175480343879605142126939094513682057517533496743665","14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9291151758418258889310802508183552818496920530352746070107986561729796276422","755276081112069011563151270065961196621734344759807910052861456278819469813","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["332550877260143391804226799276321385601108798970480674577981058846255327585","14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["332550877260143391804226799276321385601108798970480674577981058846255327585","4639068079695973420444140421529722600221567914703678021061203215475909340529","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","258","259","258","259","0","0","0"],"tokenID1":["1","1","1","1","1","1","1","0","0","0"],"tokenID2":["0","0","0","1","1","1","1","0","0","0"],"tokenID3":["1","0"],"txCompressedData":["22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","22300745198551064007464398471747499167835663","22300745198551143235626912808705636703135247","13269348750238205523937693788887673023244789484867731823136388933135","13269348750238301304908997906941320420013214541705972331925069358607","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","51833393555617990327881616362842551895365340655767482316085002496","51833393555618364472300773073989612038682516024220795709792715008","0","0","0"]}` //nolint
  510. assert.Equal(t, expected, string(s))
  511. }
  512. // TestZKInputs5:
  513. // tests:
  514. // - L1: CreateAccountDeposit, ForceExit
  515. // - L2: Transfer, Exit
  516. func TestZKInputs5(t *testing.T) {
  517. dir, err := ioutil.TempDir("", "tmpdb")
  518. require.NoError(t, err)
  519. defer assert.Nil(t, os.RemoveAll(dir))
  520. nLevels := 16
  521. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  522. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  523. require.NoError(t, err)
  524. chainID := uint16(0)
  525. users, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs := txsets.GenerateTxsZKInputs5(t, chainID)
  526. config := Config{
  527. NLevels: uint32(nLevels),
  528. MaxTx: 10,
  529. MaxL1Tx: 5,
  530. MaxFeeTx: 2,
  531. ChainID: chainID,
  532. }
  533. tp := NewTxProcessor(sdb, config)
  534. ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs)
  535. require.NoError(t, err)
  536. assert.Equal(t,
  537. "2876714902080560437312639230274788012352898700644108410216831426783321840346",
  538. sdb.MT.Root().BigInt().String())
  539. assert.Equal(t,
  540. "13140975706661203784805217240537482476556143928013013185721039885503232354236",
  541. ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
  542. // check expected account keys values from tx inputs
  543. acc, err := sdb.GetAccount(common.Idx(256))
  544. require.NoError(t, err)
  545. assert.Equal(t, users[0].BJJ.Public().Compress().String(), acc.BJJ.String())
  546. assert.Equal(t, users[0].Addr.Hex(), acc.EthAddr.Hex())
  547. assert.Equal(t, "15997798", acc.Balance.String())
  548. acc, err = sdb.GetAccount(common.Idx(257))
  549. require.NoError(t, err)
  550. assert.Equal(t, users[1].BJJ.Public().Compress().String(), acc.BJJ.String())
  551. assert.Equal(t, users[1].Addr.Hex(), acc.EthAddr.Hex())
  552. assert.Equal(t, "16000202", acc.Balance.String())
  553. // check that there no exist more accounts
  554. _, err = sdb.GetAccount(common.Idx(258))
  555. require.NotNil(t, err)
  556. // printZKInputs(t, ptOut.ZKInputs)
  557. h, err := ptOut.ZKInputs.HashGlobalData()
  558. require.NoError(t, err)
  559. assert.Equal(t,
  560. "19086778807106099319194336332943774102228783570513930291082708026458948532486",
  561. h.String())
  562. toHash, err := ptOut.ZKInputs.ToHashGlobalData()
  563. require.NoError(t, err)
  564. assert.Equal(t, "0000000000ff0000000001010000000000000000000000000000000000000000000000000000000000000000065c29b615f1569637a020bc0ad8fce077b1303f0446018d40db0fcf7144dada1d0d87572bfc36682eb36d59e8bcc358ffdb685dcf809e10ce894346ab1e27bc7e5f4552091a69125d5dfcb7b8c2659029395bdf21b0a1688b37f77b1d1d5539ec3b826db5ac78b2513f574a04c50a7d4f8246d70000000000000000f424000000000000000000010000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf093985b1993d9f743f9d7d943ed56f38601cb8b196db025f79650c4007c3054d0000000000000000f424000000000000000000010000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf093985b1993d9f743f9d7d943ed56f38601cb8b196db025f79650c4007c3054d000000000101000000000000000003e80000000100000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000100000003e8000100010100000003e87e0100000100000003e87e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010000000000000001", hex.EncodeToString(toHash)) //nolint:lll
  565. s, err := json.Marshal(ptOut.ZKInputs)
  566. require.NoError(t, err)
  567. // the 'expected' data has been checked with the circom circuits
  568. expected := `{"amountF":["0","0","1000","1000","1000","0","0","0","0","0"],"auxFromIdx":["256","257","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0"],"ay1":["15238403086306505038849621710779816852318505119327426213168494964113886299863","4172448640254579435434214421479401747968866348490029667576411173067925161293","4172448640254579435434214421479401747968866348490029667576411173067925161293","15238403086306505038849621710779816852318505119327426213168494964113886299863","15238403086306505038849621710779816852318505119327426213168494964113886299863","0","0","0","0","0"],"ay2":["0","0","4172448640254579435434214421479401747968866348490029667576411173067925161293","4172448640254579435434214421479401747968866348490029667576411173067925161293","15238403086306505038849621710779816852318505119327426213168494964113886299863","0","0","0","0","0"],"ay3":["4172448640254579435434214421479401747968866348490029667576411173067925161293","0"],"balance1":["16000000","16000000","16000000","16000000","15998899","0","0","0","0","0"],"balance2":["0","0","0","15999000","0","0","0","0","0","0"],"balance3":["16000000","0"],"currentNumBatch":"1","ethAddr1":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","247512291986854564435551364600938690683113101007","721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0","0","0","0","0"],"ethAddr2":["0","0","247512291986854564435551364600938690683113101007","247512291986854564435551364600938690683113101007","721457446580647751014191829380889690493307935711","0","0","0","0","0"],"ethAddr3":["247512291986854564435551364600938690683113101007","0"],"feeIdxs":["257","0"],"feePlanTokens":["1","0"],"fromBjjCompressed":[["1","1","1","0","1","0","1","1","0","1","1","0","0","0","1","0","0","1","0","0","0","0","0","1","1","1","1","1","0","0","1","0","1","0","1","1","1","1","1","0","0","1","0","1","0","0","0","0","1","0","1","0","0","0","1","1","0","0","1","0","0","0","0","0","0","1","0","1","0","0","1","0","1","1","1","0","1","0","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","1","0","0","1","0","0","1","1","0","1","0","0","0","1","1","1","1","0","0","0","1","1","0","1","0","1","1","0","1","0","1","1","0","1","1","0","1","1","0","1","1","0","0","1","0","0","0","0","0","1","1","1","0","1","1","1","0","0","0","0","1","1","0","1","1","1","1","0","0","1","1","1","0","0","1","0","1","0","1","0","1","0","1","0","1","1","1","0","0","0","1","0","1","1","1","0","0","0","1","1","0","1","1","1","1","0","1","1","1","0","1","1","1","1","1","1","1","0","1","1","0","0","1","1","0","1","0","0","0","1","0","0","0","1","0","1","1","0","1","0","0","0","0","1","0","1","0","0","0","0","1","1","0","1","1","0","0","0","0","1","0","0"],["1","0","1","1","0","0","1","0","1","0","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","0","0","1","1","1","1","0","1","1","1","1","1","0","1","0","0","1","0","0","0","0","0","0","1","1","0","1","1","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","0","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","0","1","1","1","1","0","1","1","0","1","0","1","0","1","0","1","1","0","1","1","1","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","1","1","1","1","0","1","0","1","1","1","0","0","1","1","1","1","1","1","1","0","0","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","0","1","1","1","1","0","0","1","0","0","1","1","0","0","1","1","0","0","0","1","1","0","1","1","0","1","0","0","0","0","1","1","0","0","1","1","1","0","0","1","0","0","1","0","0","0","0"],["1","0","1","1","0","0","1","0","1","0","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","0","0","1","1","1","1","0","1","1","1","1","1","0","1","0","0","1","0","0","0","0","0","0","1","1","0","1","1","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","0","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","0","1","1","1","1","0","1","1","0","1","0","1","0","1","0","1","1","0","1","1","1","1","1","0","0","0","0","1","0","1","0","0","1","1","0","1","1","1","1","1","0","1","0","1","1","1","0","0","1","1","1","1","1","1","1","0","0","0","0","1","0","1","1","1","0","1","1","1","1","1","0","0","1","1","0","1","1","1","1","0","0","1","0","0","1","1","0","0","1","1","0","0","0","1","1","0","1","1","0","1","0","0","0","0","1","1","0","0","1","1","1","0","0","1","0","0","1","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","247512291986854564435551364600938690683113101007","0","0","0","0","0","0","0"],"fromIdx":["0","0","257","256","256","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0"],["0","0"],["0","0"],["101","0"],["202","0"],["202","0"],["202","0"],["202","0"],["202","0"]],"imExitRoot":["0","0","3108927039349628080560992930038448899434762097566869327880204534185427296840","3108927039349628080560992930038448899434762097566869327880204534185427296840","13140975706661203784805217240537482476556143928013013185721039885503232354236","13140975706661203784805217240537482476556143928013013185721039885503232354236","13140975706661203784805217240537482476556143928013013185721039885503232354236","13140975706661203784805217240537482476556143928013013185721039885503232354236","13140975706661203784805217240537482476556143928013013185721039885503232354236"],"imFinalAccFee":["202","0"],"imInitStateRootFee":"9503362710103278904036862070280924778607495993026847242248890901328040935233","imOnChain":["1","1","1","0","0","0","0","0","0"],"imOutIdx":["256","257","257","257","257","257","257","257","257"],"imStateRoot":["9864363881518933755872975814973434564014010763285201917208728592660216535879","5464828090683525701848539079562826610593498026797583519227991802661481319398","4247263217385784889252612914836186807163204284677141615244167232954279040123","467779177153675901236293259524865072478363349266529570205711870575795620675","9503362710103278904036862070280924778607495993026847242248890901328040935233","9503362710103278904036862070280924778607495993026847242248890901328040935233","9503362710103278904036862070280924778607495993026847242248890901328040935233","9503362710103278904036862070280924778607495993026847242248890901328040935233","9503362710103278904036862070280924778607495993026847242248890901328040935233"],"imStateRootFee":["2876714902080560437312639230274788012352898700644108410216831426783321840346"],"isOld0_1":["1","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","1","0","0","0","0","0","0","0"],"loadAmountF":["16000000","16000000","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","1","0","0","0","0","0","0","0","0"],"newExit":["0","0","1","0","1","0","0","0","0","0"],"nonce1":["0","0","0","0","1","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0"],"oldKey1":["0","256","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","257","0","0","0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","19640802975431343835432574856056762450507078736963927763903813795922811702786","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","7620927768470786630890456301883078954294110378768426042508118871542584856605","0","0","0","0","0"],"onChain":["1","1","1","0","0","0","0","0","0","0"],"r8x":["0","0","0","7336021243851963421210850522807832525035191881198148637808216019229564287638","4335347683302518885656094741838374742042049687254503611295583708168066553122","0","0","0","0","0"],"r8y":["0","0","0","7284926593819138014983750032481192319515596222912311296586652432118797806827","18317758063691754838050093763598415885567580710296138957411848263207115082035","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","2712396168101349179993946196732135488303913938789417919046886927442841762195","132650388286499743959545052846392384139435824181224950821290049782713294419","0","0","0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9864363881518933755872975814973434564014010763285201917208728592660216535879","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["11468541074937051275291586516909786916023547891151197567148968218556670588327","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["14493150842991150984762949860135854212445502260878128102773900804254374077543","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["755276081112069011563151270065961196621734344759807910052861456278819469813","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["13607374628485440413017108525076157423761820024150288665356519684305393011820","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","1","257","1","0","0","0","0","0"],"tokenID1":["1","1","1","1","1","0","0","0","0","0"],"tokenID2":["0","0","1","1","1","0","0","0","0","0"],"tokenID3":["1","0"],"txCompressedData":["22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","22300745198530702369698232609325027387237903","13269348750238205523937693788887673023165561322353467485542844982799","13269348750238301304908997906941320399572348613025773232790730171919","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","51833393555617990327881616362842551895365340655767200841108291840","51833393555618364472300773073989612038682516024148175165801365760","0","0","0","0","0"]}` //nolint:lll
  569. assert.Equal(t, expected, string(s))
  570. }
  571. // TestZKInputs6:
  572. // Tests ZKInputs generated by the batches generated by
  573. // txsets.SetBlockchainMinimumFlow0
  574. func TestZKInputs6(t *testing.T) {
  575. dir, err := ioutil.TempDir("", "tmpdb")
  576. require.NoError(t, err)
  577. defer assert.Nil(t, os.RemoveAll(dir))
  578. nLevels := 16
  579. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  580. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  581. require.NoError(t, err)
  582. chainID := uint16(0)
  583. config := Config{
  584. NLevels: uint32(nLevels),
  585. MaxTx: 11,
  586. MaxL1Tx: 5,
  587. MaxFeeTx: 4,
  588. ChainID: chainID,
  589. }
  590. tp := NewTxProcessor(sdb, config)
  591. tc := til.NewContext(chainID, common.RollupConstMaxL1UserTx)
  592. blocks, err := tc.GenerateBlocks(txsets.SetBlockchainMinimumFlow0)
  593. require.NoError(t, err)
  594. // restart nonces of TilContext, as will be set by generating directly
  595. // the PoolL2Txs for each specific batch with tc.GeneratePoolL2Txs
  596. tc.RestartNonces()
  597. log.Debug("block:0 batch:1")
  598. ptOut, err := tp.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil)
  599. require.NoError(t, err)
  600. assert.Equal(t, "0", sdb.MT.Root().BigInt().String())
  601. assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
  602. h, err := ptOut.ZKInputs.HashGlobalData()
  603. require.NoError(t, err)
  604. assert.Equal(t,
  605. "9301299094526013223591553014344438261082826223511181150957064862524512234943",
  606. h.String())
  607. s, err := json.Marshal(ptOut.ZKInputs)
  608. require.NoError(t, err)
  609. // the 'expected' data has been checked with the circom circuits
  610. expected := `{"amountF":["0","0","0","0","0","0","0","0","0","0","0"],"auxFromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["0","0","0","0","0","0","0","0","0","0","0"],"ay2":["0","0","0","0","0","0","0","0","0","0","0"],"ay3":["0","0","0","0"],"balance1":["0","0","0","0","0","0","0","0","0","0","0"],"balance2":["0","0","0","0","0","0","0","0","0","0","0"],"balance3":["0","0","0","0"],"currentNumBatch":"1","ethAddr1":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr2":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr3":["0","0","0","0"],"feeIdxs":["0","0","0","0"],"feePlanTokens":["0","0","0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["0","0","0","0"],"imInitStateRootFee":"0","imOnChain":["0","0","0","0","0","0","0","0","0","0"],"imOutIdx":["255","255","255","255","255","255","255","255","255","255"],"imStateRoot":["0","0","0","0","0","0","0","0","0","0"],"imStateRootFee":["0","0","0"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["0","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["0","0","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["0","0","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","0","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["0","0","0","0","0","0","0","0","0","0","0"],"r8x":["0","0","0","0","0","0","0","0","0","0","0"],"r8y":["0","0","0","0","0","0","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","0","0","0","0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID1":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID3":["0","0","0","0"],"txCompressedData":["3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"]}` //nolint:lll
  611. assert.Equal(t, expected, string(s))
  612. // printZKInputs(t, ptOut.ZKInputs)
  613. log.Debug("block:0 batch:2")
  614. l1UserTxs := []common.L1Tx{}
  615. l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs)
  616. ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
  617. require.NoError(t, err)
  618. assert.Equal(t, "0", sdb.MT.Root().BigInt().String())
  619. assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
  620. h, err = ptOut.ZKInputs.HashGlobalData()
  621. require.NoError(t, err)
  622. assert.Equal(t,
  623. "4184435607160937848424963697607049814276054691661035837321784742516738196426",
  624. h.String())
  625. s, err = json.Marshal(ptOut.ZKInputs)
  626. require.NoError(t, err)
  627. // the 'expected' data has been checked with the circom circuits
  628. expected = `{"amountF":["0","0","0","0","0","0","0","0","0","0","0"],"auxFromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["0","0","0","0","0","0","0","0","0","0","0"],"ay2":["0","0","0","0","0","0","0","0","0","0","0"],"ay3":["0","0","0","0"],"balance1":["0","0","0","0","0","0","0","0","0","0","0"],"balance2":["0","0","0","0","0","0","0","0","0","0","0"],"balance3":["0","0","0","0"],"currentNumBatch":"2","ethAddr1":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr2":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr3":["0","0","0","0"],"feeIdxs":["0","0","0","0"],"feePlanTokens":["0","0","0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["0","0","0","0"],"imInitStateRootFee":"0","imOnChain":["0","0","0","0","0","0","0","0","0","0"],"imOutIdx":["255","255","255","255","255","255","255","255","255","255"],"imStateRoot":["0","0","0","0","0","0","0","0","0","0"],"imStateRootFee":["0","0","0"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["0","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["0","0","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["0","0","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","0","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["0","0","0","0","0","0","0","0","0","0","0"],"r8x":["0","0","0","0","0","0","0","0","0","0","0"],"r8y":["0","0","0","0","0","0","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","0","0","0","0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID1":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID3":["0","0","0","0"],"txCompressedData":["3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"]}` //nolint:lll
  629. assert.Equal(t, expected, string(s))
  630. // printZKInputs(t, ptOut.ZKInputs)
  631. log.Debug("block:0 batch:3")
  632. l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[2].Batch.ForgeL1TxsNum])
  633. l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[2].L2Txs)
  634. ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs)
  635. require.NoError(t, err)
  636. assert.Equal(t,
  637. "10303926118213025243660668481827257778714122989909761705455084995854999537039",
  638. sdb.MT.Root().BigInt().String())
  639. h, err = ptOut.ZKInputs.HashGlobalData()
  640. require.NoError(t, err)
  641. assert.Equal(t,
  642. "9999662659875498841976333618236375723684936083895886788503429391557693098936",
  643. h.String())
  644. s, err = json.Marshal(ptOut.ZKInputs)
  645. require.NoError(t, err)
  646. // the 'expected' data has been checked with the circom circuits
  647. expected = `{"amountF":["0","0","0","0","0","0","0","0","0","0","0"],"auxFromIdx":["256","257","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["14382649545529405976710664157356364657039027681269256663271478725131562622080","20534271334408079873799448508761237599936782740731511933526664305820108254173","0","0","0","0","0","0","0","0","0"],"ay2":["0","0","0","0","0","0","0","0","0","0","0"],"ay3":["0","0","0","0"],"balance1":["500","0","0","0","0","0","0","0","0","0","0"],"balance2":["0","0","0","0","0","0","0","0","0","0","0"],"balance3":["0","0","0","0"],"currentNumBatch":"3","ethAddr1":["721457446580647751014191829380889690493307935711","594179275863704165266696689399235767493667371625","0","0","0","0","0","0","0","0","0"],"ethAddr2":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr3":["0","0","0","0"],"feeIdxs":["0","0","0","0"],"feePlanTokens":["0","0","0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","1","0","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","1","1","1","1","0","0","1","0","1","0","1","1","1","0","1","0","1","1","1","1","0","0","1","0","0","0","0","1","1","0","1","1","0","1","1","1","0","1","0","0","0","1","0","1","0","0","1","0","1","1","1","1","1","1","0","0","1","1","0","1","0","1","1","1","1","1","1","0","0","1","1","1","1","1","1","0","0","0","0","1","1","1","1","0","0","1","0","1","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","0","0","1","0","0","0","0","0","1","1","1","1","1","1","1","1","0","1","1","0","1","0","1","0","1","0","0","1","1","1","0","0","0","1","1","0","0","0","1","0","1","1","0","1","0","1","0","1","1","1","0","0","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","0","0","1","1","0","0","0","1","1","0","0","1","0","0","1","1","0","0","1","0","0","0","1","0","1","0","1","0","0","1","0","0","0","1","1","0","0","1","1","1","1","1","1","1","0","0","0"],["1","0","1","1","1","0","1","1","1","1","0","1","0","1","1","1","0","1","1","1","1","0","1","0","1","0","0","0","1","0","1","1","1","0","0","0","1","0","1","1","1","1","1","0","0","0","0","1","1","1","1","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","1","1","1","1","0","1","1","1","0","0","0","0","0","0","0","0","0","1","0","0","1","0","0","1","0","1","0","1","1","1","0","1","0","0","1","0","1","1","0","1","1","1","0","0","0","1","1","1","1","0","0","0","1","0","0","0","1","1","0","1","1","0","1","1","1","1","0","0","1","0","1","0","1","0","1","0","0","0","0","1","0","0","1","0","1","0","0","0","1","1","1","1","1","1","1","0","1","1","1","1","1","0","0","0","1","0","1","0","0","0","1","1","0","1","0","0","1","0","1","0","0","1","0","0","0","1","1","0","1","1","0","1","1","0","1","0","1","0","1","1","1","0","1","1","1","1","0","1","0","1","1","0","1","0","1","0","1","0","1","1","1","0","1","0","1","0","0","0","1","1","1","1","1","1","1","0","1","0","0","1","1","0","1","0","1","1","0","1","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","594179275863704165266696689399235767493667371625","0","0","0","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["0","0","0","0"],"imInitStateRootFee":"10303926118213025243660668481827257778714122989909761705455084995854999537039","imOnChain":["1","1","0","0","0","0","0","0","0","0"],"imOutIdx":["256","257","257","257","257","257","257","257","257","257"],"imStateRoot":["13718432332053174787133381314507031682723671867032236085753048202902611396851","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039"],"imStateRootFee":["10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039","10303926118213025243660668481827257778714122989909761705455084995854999537039"],"isOld0_1":["1","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["500","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","1","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["0","256","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"255","oldStateRoot":"0","oldValue1":["0","2583248008987306529500243289625143461497330890528286426538504628325593550223","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["1","1","0","0","0","0","0","0","0","0","0"],"r8x":["0","0","0","0","0","0","0","0","0","0","0"],"r8y":["0","0","0","0","0","0","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","0","0","0","0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID1":["0","1","0","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID3":["0","0","0","0"],"txCompressedData":["3322668559","22300745198530623141535718272648364828648975","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"]}` //nolint:lll
  648. assert.Equal(t, expected, string(s))
  649. // printZKInputs(t, ptOut.ZKInputs)
  650. log.Debug("block:0 batch:4")
  651. l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[3].Batch.ForgeL1TxsNum])
  652. l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[3].L2Txs)
  653. ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, l2Txs)
  654. require.NoError(t, err)
  655. assert.Equal(t,
  656. "8530501758307821623834726627056947648600328521261384179220598288701741436285",
  657. sdb.MT.Root().BigInt().String())
  658. h, err = ptOut.ZKInputs.HashGlobalData()
  659. require.NoError(t, err)
  660. assert.Equal(t,
  661. "21745783755001552009352131063359021173230283198838080672999642521405741778972",
  662. h.String())
  663. s, err = json.Marshal(ptOut.ZKInputs)
  664. require.NoError(t, err)
  665. // the 'expected' data has been checked with the circom circuits
  666. expected = `{"amountF":["0","0","0","0","0","0","0","0","0","0","0"],"auxFromIdx":["258","0","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["14382649545529405976710664157356364657039027681269256663271478725131562622080","0","0","0","0","0","0","0","0","0","0"],"ay2":["0","0","0","0","0","0","0","0","0","0","0"],"ay3":["0","0","0","0"],"balance1":["500","0","0","0","0","0","0","0","0","0","0"],"balance2":["0","0","0","0","0","0","0","0","0","0","0"],"balance3":["0","0","0","0"],"currentNumBatch":"4","ethAddr1":["721457446580647751014191829380889690493307935711","0","0","0","0","0","0","0","0","0","0"],"ethAddr2":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr3":["0","0","0","0"],"feeIdxs":["0","0","0","0"],"feePlanTokens":["0","0","0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","1","0","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","1","1","1","1","0","0","1","0","1","0","1","1","1","0","1","0","1","1","1","1","0","0","1","0","0","0","0","1","1","0","1","1","0","1","1","1","0","1","0","0","0","1","0","1","0","0","1","0","1","1","1","1","1","1","0","0","1","1","0","1","0","1","1","1","1","1","1","0","0","1","1","1","1","1","1","0","0","0","0","1","1","1","1","0","0","1","0","1","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","0","0","1","0","0","0","0","0","1","1","1","1","1","1","1","1","0","1","1","0","1","0","1","0","1","0","0","1","1","1","0","0","0","1","1","0","0","0","1","0","1","1","0","1","0","1","0","1","1","1","0","0","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","0","0","1","1","0","0","0","1","1","0","0","1","0","0","1","1","0","0","1","0","0","0","1","0","1","0","1","0","0","1","0","0","0","1","1","0","0","1","1","1","1","1","1","1","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","0","0","0","0","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["0","0","0","0"],"imInitStateRootFee":"8530501758307821623834726627056947648600328521261384179220598288701741436285","imOnChain":["1","0","0","0","0","0","0","0","0","0"],"imOutIdx":["258","258","258","258","258","258","258","258","258","258"],"imStateRoot":["8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285"],"imStateRootFee":["8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["500","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","0","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["256","0","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"257","oldStateRoot":"10303926118213025243660668481827257778714122989909761705455084995854999537039","oldValue1":["2583248008987306529500243289625143461497330890528286426538504628325593550223","0","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["1","0","0","0","0","0","0","0","0","0","0"],"r8x":["0","0","0","0","0","0","0","0","0","0","0"],"r8y":["0","0","0","0","0","0","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","0","0","0","0","0","0"],"siblings1":[["6925334635958825334942359093560850539634901248387497427591330889995136411874","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID1":["1","0","0","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID3":["0","0","0","0"],"txCompressedData":["22300745198530623141535718272648364828648975","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"]}` //nolint:lll
  667. assert.Equal(t, expected, string(s))
  668. // printZKInputs(t, ptOut.ZKInputs)
  669. log.Debug("block:0 batch:5")
  670. l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[4].Batch.ForgeL1TxsNum])
  671. l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[4].L2Txs)
  672. ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[4].L1CoordinatorTxs, l2Txs)
  673. require.NoError(t, err)
  674. assert.Equal(t,
  675. "8530501758307821623834726627056947648600328521261384179220598288701741436285",
  676. sdb.MT.Root().BigInt().String())
  677. h, err = ptOut.ZKInputs.HashGlobalData()
  678. require.NoError(t, err)
  679. assert.Equal(t,
  680. "439746443468813644034435169428358686324589417835281704573071179725530484327",
  681. h.String())
  682. s, err = json.Marshal(ptOut.ZKInputs)
  683. require.NoError(t, err)
  684. // the 'expected' data has been checked with the circom circuits
  685. expected = `{"amountF":["0","0","0","0","0","0","0","0","0","0","0"],"auxFromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["0","0","0","0","0","0","0","0","0","0","0"],"ay2":["0","0","0","0","0","0","0","0","0","0","0"],"ay3":["0","0","0","0"],"balance1":["0","0","0","0","0","0","0","0","0","0","0"],"balance2":["0","0","0","0","0","0","0","0","0","0","0"],"balance3":["0","0","0","0"],"currentNumBatch":"5","ethAddr1":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr2":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr3":["0","0","0","0"],"feeIdxs":["0","0","0","0"],"feePlanTokens":["0","0","0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["0","0","0","0"],"imInitStateRootFee":"8530501758307821623834726627056947648600328521261384179220598288701741436285","imOnChain":["0","0","0","0","0","0","0","0","0","0"],"imOutIdx":["258","258","258","258","258","258","258","258","258","258"],"imStateRoot":["8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285"],"imStateRootFee":["8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285","8530501758307821623834726627056947648600328521261384179220598288701741436285"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["0","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["0","0","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["0","0","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"258","oldStateRoot":"8530501758307821623834726627056947648600328521261384179220598288701741436285","oldValue1":["0","0","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["0","0","0","0","0","0","0","0","0","0","0"],"r8x":["0","0","0","0","0","0","0","0","0","0","0"],"r8y":["0","0","0","0","0","0","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","0","0","0","0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID1":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID3":["0","0","0","0"],"txCompressedData":["3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"]}` //nolint:lll
  686. assert.Equal(t, expected, string(s))
  687. // printZKInputs(t, ptOut.ZKInputs)
  688. log.Debug("block:0 batch:6")
  689. l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[5].Batch.ForgeL1TxsNum])
  690. l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[5].L2Txs)
  691. ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[5].L1CoordinatorTxs, l2Txs)
  692. require.NoError(t, err)
  693. assert.Equal(t,
  694. "9061858435528794221929846392270405504056106238451760714188625065949729889651",
  695. sdb.MT.Root().BigInt().String())
  696. h, err = ptOut.ZKInputs.HashGlobalData()
  697. require.NoError(t, err)
  698. assert.Equal(t,
  699. "1131640502554085111799984404500621124536653482253378744415001039320871470273",
  700. h.String())
  701. s, err = json.Marshal(ptOut.ZKInputs)
  702. require.NoError(t, err)
  703. // the 'expected' data has been checked with the circom circuits
  704. expected = `{"amountF":["100","0","0","0","0","0","0","0","0","0","0"],"auxFromIdx":["259","0","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["21759653464180282217133439550283093276794317614482080451288933258136700169296","0","0","0","0","0","0","0","0","0","0"],"ay2":["14382649545529405976710664157356364657039027681269256663271478725131562622080","0","0","0","0","0","0","0","0","0","0"],"ay3":["0","0","0","0"],"balance1":["500","0","0","0","0","0","0","0","0","0","0"],"balance2":["500","0","0","0","0","0","0","0","0","0","0"],"balance3":["0","0","0","0"],"currentNumBatch":"6","ethAddr1":["247512291986854564435551364600938690683113101007","0","0","0","0","0","0","0","0","0","0"],"ethAddr2":["721457446580647751014191829380889690493307935711","0","0","0","0","0","0","0","0","0","0"],"ethAddr3":["0","0","0","0"],"feeIdxs":["0","0","0","0"],"feePlanTokens":["0","0","0","0"],"fromBjjCompressed":[["0","0","0","0","1","0","1","0","0","0","1","1","0","1","0","1","1","0","0","0","0","1","0","0","0","1","1","1","0","0","1","1","0","1","1","1","0","0","1","1","0","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","0","1","0","1","1","0","1","0","1","0","0","0","0","1","1","1","1","1","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","1","1","0","0","0","0","0","0","0","0","0","1","0","0","0","1","0","0","0","0","0","1","0","0","0","0","1","1","1","1","0","1","1","0","1","1","0","0","1","0","1","0","0","1","0","0","1","0","1","1","0","1","0","1","0","0","1","1","1","1","0","0","1","0","0","0","0","1","0","1","0","0","1","1","0","0","1","1","0","0","1","1","0","1","1","0","0","0","0","1","0","1","1","0","0","1","1","1","0","1","0","1","1","1","0","1","0","1","0","0","1","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","1","0","1","0","1","0","0","1","0","0","0","0","0","1","1","1","0","0","0","0","1","1","1","0","1","1","0","0","0","0","0","0","0","1","1","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["247512291986854564435551364600938690683113101007","0","0","0","0","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["0","0","0","0"],"imInitStateRootFee":"9061858435528794221929846392270405504056106238451760714188625065949729889651","imOnChain":["1","0","0","0","0","0","0","0","0","0"],"imOutIdx":["259","259","259","259","259","259","259","259","259","259"],"imStateRoot":["9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651"],"imStateRootFee":["9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651","9061858435528794221929846392270405504056106238451760714188625065949729889651"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["500","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","0","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["257","0","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"258","oldStateRoot":"8530501758307821623834726627056947648600328521261384179220598288701741436285","oldValue1":["2922089750045328070912118133388673780503526961997250912389906760012441956739","0","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["1","0","0","0","0","0","0","0","0","0","0"],"r8x":["0","0","0","0","0","0","0","0","0","0","0"],"r8y":["0","0","0","0","0","0","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","0","0","0","0","0","0"],"siblings1":[["1710235828661315901335609496186904918476852477452857549422035401421643123212","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["19677433422546073304881045118354145314800019963824870333445601305998583462671","10972626243456729342705938923671683591346073099827296619717726184311017773643","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"toIdx":["256","0","0","0","0","0","0","0","0","0","0"],"tokenID1":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID3":["0","0","0","0"],"txCompressedData":["20282409603651670423950573954575","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"]}` //nolint:lll
  705. assert.Equal(t, expected, string(s))
  706. // printZKInputs(t, ptOut.ZKInputs)
  707. log.Debug("block:0 batch:7")
  708. // simulate the PoolL2Txs of the batch7
  709. batchPoolL2 := `
  710. Type: PoolL2
  711. PoolTransferToEthAddr(1) A-B: 200 (126)
  712. PoolTransferToEthAddr(0) B-C: 100 (126)`
  713. poolL2Txs, err := tc.GeneratePoolL2Txs(batchPoolL2)
  714. require.NoError(t, err)
  715. // Coordinator Idx where to send the fees
  716. coordIdxs := []common.Idx{261, 263}
  717. l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[6].Batch.ForgeL1TxsNum])
  718. l2Txs = poolL2Txs
  719. ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs,
  720. blocks[0].Rollup.Batches[6].L1CoordinatorTxs, l2Txs)
  721. require.NoError(t, err)
  722. assert.Equal(t,
  723. "4392049343656836675348565048374261353937130287163762821533580216441778455298",
  724. sdb.MT.Root().BigInt().String())
  725. h, err = ptOut.ZKInputs.HashGlobalData()
  726. require.NoError(t, err)
  727. assert.Equal(t,
  728. "16933045224569170916286405531152273569266691791699589574035702855645450977474",
  729. h.String())
  730. s, err = json.Marshal(ptOut.ZKInputs)
  731. require.NoError(t, err)
  732. // the 'expected' data has been checked with the circom circuits
  733. expected = `{"amountF":["0","0","0","0","0","200","100","0","0","0","0"],"auxFromIdx":["260","261","262","263","264","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","262","264","0","0","0","0"],"ay1":["7299054315324763317564375227723527917820889071879589087797584828752306403468","13127348242808033949662858905093082484882988923889598397206419708399907983738","21759653464180282217133439550283093276794317614482080451288933258136700169296","13127348242808033949662858905093082484882988923889598397206419708399907983738","20534271334408079873799448508761237599936782740731511933526664305820108254173","14382649545529405976710664157356364657039027681269256663271478725131562622080","21759653464180282217133439550283093276794317614482080451288933258136700169296","0","0","0","0"],"ay2":["0","0","0","0","0","21759653464180282217133439550283093276794317614482080451288933258136700169296","20534271334408079873799448508761237599936782740731511933526664305820108254173","0","0","0","0"],"ay3":["13127348242808033949662858905093082484882988923889598397206419708399907983738","13127348242808033949662858905093082484882988923889598397206419708399907983738","0","0"],"balance1":["800","0","0","0","0","500","400","0","0","0","0"],"balance2":["0","0","0","0","0","0","0","0","0","0","0"],"balance3":["0","0","0","0"],"currentNumBatch":"7","ethAddr1":["1288347612158191397270705234830805381732297126518","176962662172908264953938498278848696642639144728","247512291986854564435551364600938690683113101007","176962662172908264953938498278848696642639144728","594179275863704165266696689399235767493667371625","721457446580647751014191829380889690493307935711","247512291986854564435551364600938690683113101007","0","0","0","0"],"ethAddr2":["0","0","0","0","0","247512291986854564435551364600938690683113101007","594179275863704165266696689399235767493667371625","0","0","0","0"],"ethAddr3":["176962662172908264953938498278848696642639144728","176962662172908264953938498278848696642639144728","0","0"],"feeIdxs":["261","263","0","0"],"feePlanTokens":["1","0","0","0"],"fromBjjCompressed":[["0","0","1","1","0","0","0","1","0","0","0","1","1","1","1","0","0","0","1","1","1","0","1","0","1","1","0","0","0","1","1","0","1","1","0","0","0","0","0","1","1","1","0","1","1","0","0","0","1","1","0","0","0","1","1","1","0","1","1","0","1","0","0","0","1","0","0","1","1","1","1","0","0","1","1","0","1","1","1","1","1","1","0","0","1","0","1","1","0","1","0","0","1","1","0","1","0","0","0","0","1","1","0","0","1","0","1","1","0","0","0","0","1","1","0","0","1","1","1","1","0","1","0","0","1","0","0","1","1","1","1","1","0","0","1","0","1","0","0","0","0","1","1","1","0","0","0","1","1","0","0","0","1","1","1","1","1","0","0","1","0","1","0","0","1","0","1","1","0","1","1","0","1","1","0","1","0","0","1","0","0","1","0","1","1","1","1","0","1","0","1","0","0","1","1","1","1","1","0","1","1","0","1","1","0","0","0","1","1","0","1","0","0","1","0","0","1","1","0","1","1","0","0","1","1","1","0","1","0","0","1","0","0","1","1","1","1","0","0","0","1","1","0","0","0","1","0","0","0","0","0","0","1","0","0","0"],["0","1","0","1","1","1","1","0","1","0","0","0","1","0","1","0","1","1","0","1","1","0","1","0","0","0","1","0","1","0","1","0","0","0","0","0","0","1","1","1","0","1","1","1","1","1","1","0","1","1","0","0","1","1","0","1","1","0","1","0","1","0","0","0","1","1","1","1","1","0","1","1","1","1","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","0","0","0","0","1","1","0","0","1","1","1","1","0","0","0","1","0","0","0","0","1","1","0","0","1","0","1","0","1","1","0","0","1","1","0","1","1","1","0","0","0","0","0","0","0","1","0","0","0","0","0","1","0","1","0","1","1","0","1","0","0","0","0","1","1","0","1","0","0","1","0","0","1","1","1","1","0","1","0","0","0","0","1","1","0","0","0","0","1","1","0","1","0","0","1","0","1","1","0","1","1","0","1","1","0","1","0","0","0","1","1","0","0","0","1","1","1","0","1","1","1","0","0","0","0","1","1","1","0","0","0","1","1","1","0","0","0","0","1","1","0","1","1","0","0","0","0","1","0","1","1","1","0","1","0","0","0","0","0","1","0","1","1","1","0","0","0"],["0","0","0","0","1","0","1","0","0","0","1","1","0","1","0","1","1","0","0","0","0","1","0","0","0","1","1","1","0","0","1","1","0","1","1","1","0","0","1","1","0","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","0","1","0","1","1","0","1","0","1","0","0","0","0","1","1","1","1","1","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","1","1","0","0","0","0","0","0","0","0","0","1","0","0","0","1","0","0","0","0","0","1","0","0","0","0","1","1","1","1","0","1","1","0","1","1","0","0","1","0","1","0","0","1","0","0","1","0","1","1","0","1","0","1","0","0","1","1","1","1","0","0","1","0","0","0","0","1","0","1","0","0","1","1","0","0","1","1","0","0","1","1","0","1","1","0","0","0","0","1","0","1","1","0","0","1","1","1","0","1","0","1","1","1","0","1","0","1","0","0","1","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","1","0","1","0","1","0","0","1","0","0","0","0","0","1","1","1","0","0","0","0","1","1","1","0","1","1","0","0","0","0","0","0","0","1","1","0","0"],["0","1","0","1","1","1","1","0","1","0","0","0","1","0","1","0","1","1","0","1","1","0","1","0","0","0","1","0","1","0","1","0","0","0","0","0","0","1","1","1","0","1","1","1","1","1","1","0","1","1","0","0","1","1","0","1","1","0","1","0","1","0","0","0","1","1","1","1","1","0","1","1","1","1","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","0","0","0","0","1","1","0","0","1","1","1","1","0","0","0","1","0","0","0","0","1","1","0","0","1","0","1","0","1","1","0","0","1","1","0","1","1","1","0","0","0","0","0","0","0","1","0","0","0","0","0","1","0","1","0","1","1","0","1","0","0","0","0","1","1","0","1","0","0","1","0","0","1","1","1","1","0","1","0","0","0","0","1","1","0","0","0","0","1","1","0","1","0","0","1","0","1","1","0","1","1","0","1","1","0","1","0","0","0","1","1","0","0","0","1","1","1","0","1","1","1","0","0","0","0","1","1","1","0","0","0","1","1","1","0","0","0","0","1","1","0","1","1","0","0","0","0","1","0","1","1","1","0","1","0","0","0","0","0","1","0","1","1","1","0","0","0"],["1","0","1","1","1","0","1","1","1","1","0","1","0","1","1","1","0","1","1","1","1","0","1","0","1","0","0","0","1","0","1","1","1","0","0","0","1","0","1","1","1","1","1","0","0","0","0","1","1","1","1","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","1","1","1","1","0","1","1","1","0","0","0","0","0","0","0","0","0","1","0","0","1","0","0","1","0","1","0","1","1","1","0","1","0","0","1","0","1","1","0","1","1","1","0","0","0","1","1","1","1","0","0","0","1","0","0","0","1","1","0","1","1","0","1","1","1","1","0","0","1","0","1","0","1","0","1","0","0","0","0","1","0","0","1","0","1","0","0","0","1","1","1","1","1","1","1","0","1","1","1","1","1","0","0","0","1","0","1","0","0","0","1","1","0","1","0","0","1","0","1","0","0","1","0","0","0","1","1","0","1","1","0","1","1","0","1","0","1","0","1","1","1","0","1","1","1","1","0","1","0","1","1","0","1","0","1","0","1","0","1","1","1","0","1","0","1","0","0","0","1","1","1","1","1","1","1","0","1","0","0","1","1","0","1","0","1","1","0","1","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["1288347612158191397270705234830805381732297126518","176962662172908264953938498278848696642639144728","247512291986854564435551364600938690683113101007","176962662172908264953938498278848696642639144728","594179275863704165266696689399235767493667371625","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","0","258","259","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["20","0","0","0"],["20","10","0","0"],["20","10","0","0"],["20","10","0","0"],["20","10","0","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["20","10","0","0"],"imInitStateRootFee":"21568970628531903183192590637378661071540070590973406609839025437699471470737","imOnChain":["1","1","1","1","1","0","0","0","0","0"],"imOutIdx":["260","261","262","263","264","264","264","264","264","264"],"imStateRoot":["8055843862775304254706568826463499646250013231089379492032756142632539485910","6440734492684925103504435324083111099059468455159698803777795430519320156387","17080150834634128835371940985724783570700385951141894137839985999722076129393","5478219012134053524299229475329917964241210884198322594193567802008066288663","20148816818886541368926506049436147840148462806275262307164042642547964024891","775514322804357482319368265967771001913542032911682455477513067859744757485","21568970628531903183192590637378661071540070590973406609839025437699471470737","21568970628531903183192590637378661071540070590973406609839025437699471470737","21568970628531903183192590637378661071540070590973406609839025437699471470737","21568970628531903183192590637378661071540070590973406609839025437699471470737"],"imStateRootFee":["21845262663036701885789796823768213178166652003885839590605490469705095935737","4392049343656836675348565048374261353937130287163762821533580216441778455298","4392049343656836675348565048374261353937130287163762821533580216441778455298"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["800","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","1","1","1","1","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["256","257","258","259","256","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"259","oldStateRoot":"9061858435528794221929846392270405504056106238451760714188625065949729889651","oldValue1":["6562150729229138743267014455891184273725543385273447095310127546128519424449","2922089750045328070912118133388673780503526961997250912389906760012441956739","19421590014860408017031009388212071206394178842142297789395859339862413023436","21249140223342182448031284949669740061229572538781098063822693710701073699774","6562150729229138743267014455891184273725543385273447095310127546128519424449","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["1","1","1","1","1","0","0","0","0","0","0"],"r8x":["0","0","0","0","0","8770607706668248359945566576303935616256160265651383435960480211364357546112","17262037212461398576365522795088670538843993587203604546876447958120541451621","0","0","0","0"],"r8y":["0","0","0","0","0","12311093168939799397001823764682802643621697334938201583983933572943934371028","569635881931475424289735109573228576314932933558639111262539597035286146201","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","1191222821583579210553734313486151664513131537567645746568450777927266616354","233823659238401174531419568367279478352512368281766259271702380652050530855","0","0","0","0"],"siblings1":[["19677433422546073304881045118354145314800019963824870333445601305998583462671","10972626243456729342705938923671683591346073099827296619717726184311017773643","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["314380649644034437497614645111544018494756142166059028559280780414545104685","2137207421531663714413080941127393343547214451331189124229908005951387501300","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["8815033147089566264192433432193552302111477712729353545932093180903883923584","12518700578932768688965291105493517842195670873964632084733004769915655162566","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["11272492735170242722575437927373003223779291420137042751188753413926084073118","2199003480782397842508894964778228853972027960419082805229304997775258699423","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["4643196374972907526340613742135810086161994487018477480251770189214133189614","18704948542474136639904658844208369945039074813383956110034045279972062222266","18415507397039526176679688506579114602308891419321366426899227563735979799040","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["4643196374972907526340613742135810086161994487018477480251770189214133189614","19792116367207470577093418522642680102063643343783661189577437171467838431223","10581016785966093296352870001556755985871105059569418078686917863666115190249","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["17363003769841670694219084152185831959290353086252876353958035484166924121343","2199003480782397842508894964778228853972027960419082805229304997775258699423","18706346248973561030123698363077940738032023383805113107999029340942965867581","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["4643196374972907526340613742135810086161994487018477480251770189214133189614","19792116367207470577093418522642680102063643343783661189577437171467838431223","6797559045384535081852691020171750614120022792545883159476356649291644130253","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["8058635939323113621595178698218683776665665927945114003208363967804168776971","21523542291587713439369917543031392600625173237739392380890514174693422096979","18415507397039526176679688506579114602308891419321366426899227563735979799040","12482543472932494767369915162702586718952672410215622757039325707968621010863","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["18794008474280432366030304157244077690848898062286062938735618673955093983148","9743960653694217950134710833940692866621720432852769177126779949777123685924","6925334635958825334942359093560850539634901248387497427591330889995136411874","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["18794008474280432366030304157244077690848898062286062938735618673955093983148","6544148003981681871222929255662142912204014765383469000776030058211355312642","5969849198478509518422038172983111571637630011762865430793127273511995054256","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","247512291986854564435551364600938690683113101007","594179275863704165266696689399235767493667371625","0","0","0","0"],"toIdx":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID1":["0","1","1","0","0","1","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","1","0","0","0","0","0"],"tokenID3":["1","0","0","0"],"txCompressedData":["3322668559","22300745198530623141535718272648364828648975","22300745198530623141535718272648364828648975","3322668559","3322668559","13269348750238205523937693788887673002803923556187533286952003167759","13269348750238205523937671488142474472180782020469260920065473897999","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","51833393555617990327881616362842488512835329244224786936933384450","51833393555617990327881529250556548829772431193891525049876218115","0","0","0","0"]}` //nolint:lll
  734. assert.Equal(t, expected, string(s))
  735. // printZKInputs(t, ptOut.ZKInputs)
  736. log.Debug("block:0 batch:8")
  737. // simulate the PoolL2Txs of the batch8
  738. batchPoolL2 = `
  739. Type: PoolL2
  740. PoolTransfer(0) A-B: 100 (126)
  741. PoolTransfer(0) C-A: 50 (126)
  742. PoolTransfer(1) B-C: 100 (126)
  743. PoolExit(0) A: 100 (126)`
  744. poolL2Txs, err = tc.GeneratePoolL2Txs(batchPoolL2)
  745. require.NoError(t, err)
  746. l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[7].Batch.ForgeL1TxsNum])
  747. l2Txs = poolL2Txs
  748. ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs,
  749. blocks[0].Rollup.Batches[7].L1CoordinatorTxs, l2Txs)
  750. require.NoError(t, err)
  751. assert.Equal(t,
  752. "8905191229562583213069132470917469035834300549892959854483573322676101624713",
  753. sdb.MT.Root().BigInt().String())
  754. h, err = ptOut.ZKInputs.HashGlobalData()
  755. require.NoError(t, err)
  756. assert.Equal(t,
  757. "869575727906495310720152785126167041690256162889185479974211887085438433227",
  758. h.String())
  759. s, err = json.Marshal(ptOut.ZKInputs)
  760. require.NoError(t, err)
  761. // the 'expected' data has been checked with the circom circuits
  762. expected = `{"amountF":["100","50","100","100","0","0","0","0","0","0","0"],"auxFromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["14382649545529405976710664157356364657039027681269256663271478725131562622080","20534271334408079873799448508761237599936782740731511933526664305820108254173","21759653464180282217133439550283093276794317614482080451288933258136700169296","14382649545529405976710664157356364657039027681269256663271478725131562622080","0","0","0","0","0","0","0"],"ay2":["21759653464180282217133439550283093276794317614482080451288933258136700169296","14382649545529405976710664157356364657039027681269256663271478725131562622080","20534271334408079873799448508761237599936782740731511933526664305820108254173","14382649545529405976710664157356364657039027681269256663271478725131562622080","0","0","0","0","0","0","0"],"ay3":["13127348242808033949662858905093082484882988923889598397206419708399907983738","13127348242808033949662858905093082484882988923889598397206419708399907983738","0","0"],"balance1":["600","100","200","540","0","0","0","0","0","0","0"],"balance2":["290","490","0","0","0","0","0","0","0","0","0"],"balance3":["20","10","0","0"],"currentNumBatch":"8","ethAddr1":["721457446580647751014191829380889690493307935711","594179275863704165266696689399235767493667371625","247512291986854564435551364600938690683113101007","721457446580647751014191829380889690493307935711","0","0","0","0","0","0","0"],"ethAddr2":["247512291986854564435551364600938690683113101007","721457446580647751014191829380889690493307935711","594179275863704165266696689399235767493667371625","721457446580647751014191829380889690493307935711","0","0","0","0","0","0","0"],"ethAddr3":["176962662172908264953938498278848696642639144728","176962662172908264953938498278848696642639144728","0","0"],"feeIdxs":["261","263","0","0"],"feePlanTokens":["1","0","0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"fromIdx":["256","264","262","256","0","0","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","10","0","0"],["0","15","0","0"],["10","15","0","0"],["10","25","0","0"],["10","25","0","0"],["10","25","0","0"],["10","25","0","0"],["10","25","0","0"],["10","25","0","0"],["10","25","0","0"]],"imExitRoot":["0","0","0","13250144760662777978687264077050092444905467656476402514654550449973838329915","13250144760662777978687264077050092444905467656476402514654550449973838329915","13250144760662777978687264077050092444905467656476402514654550449973838329915","13250144760662777978687264077050092444905467656476402514654550449973838329915","13250144760662777978687264077050092444905467656476402514654550449973838329915","13250144760662777978687264077050092444905467656476402514654550449973838329915","13250144760662777978687264077050092444905467656476402514654550449973838329915"],"imFinalAccFee":["10","25","0","0"],"imInitStateRootFee":"19962327573331823712800383558137412102534362820564928130799687004921920771313","imOnChain":["0","0","0","0","0","0","0","0","0","0"],"imOutIdx":["264","264","264","264","264","264","264","264","264","264"],"imStateRoot":["8420929917779855083168392086161338664556718284168929126509559204106289781063","11198618361999400902293809915790827434464820798953604129344599023037447634598","6477291986074195281648500263979114495040056997695257266171651150837704900583","19962327573331823712800383558137412102534362820564928130799687004921920771313","19962327573331823712800383558137412102534362820564928130799687004921920771313","19962327573331823712800383558137412102534362820564928130799687004921920771313","19962327573331823712800383558137412102534362820564928130799687004921920771313","19962327573331823712800383558137412102534362820564928130799687004921920771313","19962327573331823712800383558137412102534362820564928130799687004921920771313","19962327573331823712800383558137412102534362820564928130799687004921920771313"],"imStateRootFee":["9105638988464013543472781290807744116809126573578336130887297617775620716136","8905191229562583213069132470917469035834300549892959854483573322676101624713","8905191229562583213069132470917469035834300549892959854483573322676101624713"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","1","0","0","0","0","0","0","0"],"loadAmountF":["0","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["0","0","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","1","0","0","0","0","0","0","0"],"nonce1":["0","0","0","1","0","0","0","0","0","0","0"],"nonce2":["1","1","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["0","0","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"264","oldStateRoot":"4392049343656836675348565048374261353937130287163762821533580216441778455298","oldValue1":["0","0","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["0","0","0","0","0","0","0","0","0","0","0"],"r8x":["302270758435675574214809309069888323408433789550831886268345938426962682309","21563216029909764711992290530977610010762511172265638092685581723343592382617","1307101098299668782959966220864381212229594588154549480302963429093727822076","1001436453055464042643031027259486452586388894353802935436799723822945175624","0","0","0","0","0","0","0"],"r8y":["15328240804450798523189452255713680159657624365150725550171659311102113064708","4903123605274597892730158883972882319106389492311830708633761710406787160699","12923634409989923846870569999684844292643864036887460574113021300453562902791","9409912941229961179815689897660498509982109379169455108223078399469008689451","0","0","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["2232928562311535160082257159195694446558581426657978661469662341375468867078","2435270033855580861065349426451862556602265060510556123816193814033378449425","1121951993240504450657593564089855251244412256187010257909501329320850726325","1061137444505423864271596294262176587432105609076591513874123129881120605628","0","0","0","0","0","0","0"],"siblings1":[["9655301783219273887629572676111617796112581965264718657943912718193181603668","21523542291587713439369917543031392600625173237739392380890514174693422096979","18415507397039526176679688506579114602308891419321366426899227563735979799040","3085966888465024427488614056821630329516667319623612962287131639756765962203","0","0","0","0","0","0","0","0","0","0","0","0","0"],["3033069444170099495505610499193861118958966715969824210168911690601767964124","21523542291587713439369917543031392600625173237739392380890514174693422096979","18415507397039526176679688506579114602308891419321366426899227563735979799040","6819435423288173311979537247717891599632371007054341641382056868866104308972","0","0","0","0","0","0","0","0","0","0","0","0","0"],["3033069444170099495505610499193861118958966715969824210168911690601767964124","2196439739514605091558275107767510317388338213428672646343338815591764215958","6797559045384535081852691020171750614120022792545883159476356649291644130253","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["7015172979258569944003373329951688091097704900937171304974050920728592423751","16139509698469054999538233992982712555809977778601726919301017987108938945574","18415507397039526176679688506579114602308891419321366426899227563735979799040","6297316909055097129174836401224799012703267232549005289288013654975501958320","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["18103319615126982250697112131049137841460002780173831702103268504054464924675","6544148003981681871222929255662142912204014765383469000776030058211355312642","1913604847655644513265342567797581129316275172835434743130072093522946907100","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["3033069444170099495505610499193861118958966715969824210168911690601767964124","21523542291587713439369917543031392600625173237739392380890514174693422096979","18415507397039526176679688506579114602308891419321366426899227563735979799040","6297316909055097129174836401224799012703267232549005289288013654975501958320","0","0","0","0","0","0","0","0","0","0","0","0","0"],["10654609496535964558909566290432480298919624370744901502569342519550073424476","11872834193405429155785221606635733041877785946183895548055231228630415671526","13338303469345047684537862475562058883161632564586987947839572622273990170507","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["10481589107625349543356999071414880624641854424821273757413664142067964978076","11872834193405429155785221606635733041877785946183895548055231228630415671526","752163647728876524378487984296494416527655885600573772722793563230109953871","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["10481589107625349543356999071414880624641854424821273757413664142067964978076","9511566748286243410718405432244363254186644304849399669411385661138784704473","18183543918182770941889882117666634479723575558022332914228723866339567730166","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["21759653464180282217133439550283093276794317614482080451288933258136700169296","14382649545529405976710664157356364657039027681269256663271478725131562622080","20534271334408079873799448508761237599936782740731511933526664305820108254173","0","0","0","0","0","0","0","0"],"toEthAddr":["247512291986854564435551364600938690683113101007","721457446580647751014191829380889690493307935711","594179275863704165266696689399235767493667371625","0","0","0","0","0","0","0","0"],"toIdx":["259","256","257","1","0","0","0","0","0","0","0"],"tokenID1":["0","0","1","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","1","0","0","0","0","0","0","0","0"],"tokenID3":["1","0","0","0"],"txCompressedData":["13269348750238205523937671488142474492700876111663723512368426903055","13269348750238205523937671488142474492463191624120932751387608737295","13269348750238205523937693788887673023165561322353469174392705246735","13269348750238301304908975606196121868949207077307500584429224191503","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["51833393555617990327881529250556548829772431193964427068844278016","51833393555617990327881529250556544868364305480746702966716629256","51833393555617990327881616362842480590019077817863366651552989446","51833393555618364472300685961703608973089606562344838443583930624","0","0","0","0","0","0","0"]}` //nolint:lll
  763. assert.Equal(t, expected, string(s))
  764. // printZKInputs(t, ptOut.ZKInputs)
  765. log.Debug("(batch9) block:1 batch:1")
  766. // simulate the PoolL2Txs of the batch9
  767. batchPoolL2 = `
  768. Type: PoolL2
  769. PoolTransfer(0) D-A: 300 (126)
  770. PoolTransfer(0) B-D: 100 (126)`
  771. poolL2Txs, err = tc.GeneratePoolL2Txs(batchPoolL2)
  772. require.NoError(t, err)
  773. l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[1].Rollup.Batches[0].Batch.ForgeL1TxsNum])
  774. l2Txs = poolL2Txs
  775. coordIdxs = []common.Idx{263}
  776. ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs,
  777. blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs)
  778. require.NoError(t, err)
  779. assert.Equal(t,
  780. "20593679664586247774284790801579542411781976279024409415159440382607791042723",
  781. sdb.MT.Root().BigInt().String())
  782. h, err = ptOut.ZKInputs.HashGlobalData()
  783. require.NoError(t, err)
  784. assert.Equal(t,
  785. "7723923111532070914423697360795228093551422843840326809969093849660043067823",
  786. h.String())
  787. s, err = json.Marshal(ptOut.ZKInputs)
  788. require.NoError(t, err)
  789. // the 'expected' data has been checked with the circom circuits
  790. expected = `{"amountF":["0","100","200","100","300","100","0","0","0","0","0"],"auxFromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["20534271334408079873799448508761237599936782740731511933526664305820108254173","20534271334408079873799448508761237599936782740731511933526664305820108254173","7299054315324763317564375227723527917820889071879589087797584828752306403468","21759653464180282217133439550283093276794317614482080451288933258136700169296","7299054315324763317564375227723527917820889071879589087797584828752306403468","21759653464180282217133439550283093276794317614482080451288933258136700169296","0","0","0","0","0"],"ay2":["0","7299054315324763317564375227723527917820889071879589087797584828752306403468","21759653464180282217133439550283093276794317614482080451288933258136700169296","21759653464180282217133439550283093276794317614482080451288933258136700169296","14382649545529405976710664157356364657039027681269256663271478725131562622080","7299054315324763317564375227723527917820889071879589087797584828752306403468","0","0","0","0","0"],"ay3":["13127348242808033949662858905093082484882988923889598397206419708399907983738","0","0","0"],"balance1":["45","545","900","590","700","490","0","0","0","0","0"],"balance2":["0","800","390","0","430","370","0","0","0","0","0"],"balance3":["35","0","0","0"],"currentNumBatch":"9","ethAddr1":["594179275863704165266696689399235767493667371625","594179275863704165266696689399235767493667371625","1288347612158191397270705234830805381732297126518","247512291986854564435551364600938690683113101007","1288347612158191397270705234830805381732297126518","247512291986854564435551364600938690683113101007","0","0","0","0","0"],"ethAddr2":["0","1288347612158191397270705234830805381732297126518","247512291986854564435551364600938690683113101007","247512291986854564435551364600938690683113101007","721457446580647751014191829380889690493307935711","1288347612158191397270705234830805381732297126518","0","0","0","0","0"],"ethAddr3":["176962662172908264953938498278848696642639144728","0","0","0"],"feeIdxs":["263","0","0","0"],"feePlanTokens":["0","0","0","0"],"fromBjjCompressed":[["1","0","1","1","1","0","1","1","1","1","0","1","0","1","1","1","0","1","1","1","1","0","1","0","1","0","0","0","1","0","1","1","1","0","0","0","1","0","1","1","1","1","1","0","0","0","0","1","1","1","1","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","1","1","1","1","0","1","1","1","0","0","0","0","0","0","0","0","0","1","0","0","1","0","0","1","0","1","0","1","1","1","0","1","0","0","1","0","1","1","0","1","1","1","0","0","0","1","1","1","1","0","0","0","1","0","0","0","1","1","0","1","1","0","1","1","1","1","0","0","1","0","1","0","1","0","1","0","0","0","0","1","0","0","1","0","1","0","0","0","1","1","1","1","1","1","1","0","1","1","1","1","1","0","0","0","1","0","1","0","0","0","1","1","0","1","0","0","1","0","1","0","0","1","0","0","0","1","1","0","1","1","0","1","1","0","1","0","1","0","1","1","1","0","1","1","1","1","0","1","0","1","1","0","1","0","1","0","1","0","1","1","1","0","1","0","1","0","0","0","1","1","1","1","1","1","1","0","1","0","0","1","1","0","1","0","1","1","0","1","0","0"],["1","0","1","1","1","0","1","1","1","1","0","1","0","1","1","1","0","1","1","1","1","0","1","0","1","0","0","0","1","0","1","1","1","0","0","0","1","0","1","1","1","1","1","0","0","0","0","1","1","1","1","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","1","1","1","1","0","1","1","1","0","0","0","0","0","0","0","0","0","1","0","0","1","0","0","1","0","1","0","1","1","1","0","1","0","0","1","0","1","1","0","1","1","1","0","0","0","1","1","1","1","0","0","0","1","0","0","0","1","1","0","1","1","0","1","1","1","1","0","0","1","0","1","0","1","0","1","0","0","0","0","1","0","0","1","0","1","0","0","0","1","1","1","1","1","1","1","0","1","1","1","1","1","0","0","0","1","0","1","0","0","0","1","1","0","1","0","0","1","0","1","0","0","1","0","0","0","1","1","0","1","1","0","1","1","0","1","0","1","0","1","1","1","0","1","1","1","1","0","1","0","1","1","0","1","0","1","0","1","0","1","1","1","0","1","0","1","0","0","0","1","1","1","1","1","1","1","0","1","0","0","1","1","0","1","0","1","1","0","1","0","0"],["0","0","1","1","0","0","0","1","0","0","0","1","1","1","1","0","0","0","1","1","1","0","1","0","1","1","0","0","0","1","1","0","1","1","0","0","0","0","0","1","1","1","0","1","1","0","0","0","1","1","0","0","0","1","1","1","0","1","1","0","1","0","0","0","1","0","0","1","1","1","1","0","0","1","1","0","1","1","1","1","1","1","0","0","1","0","1","1","0","1","0","0","1","1","0","1","0","0","0","0","1","1","0","0","1","0","1","1","0","0","0","0","1","1","0","0","1","1","1","1","0","1","0","0","1","0","0","1","1","1","1","1","0","0","1","0","1","0","0","0","0","1","1","1","0","0","0","1","1","0","0","0","1","1","1","1","1","0","0","1","0","1","0","0","1","0","1","1","0","1","1","0","1","1","0","1","0","0","1","0","0","1","0","1","1","1","1","0","1","0","1","0","0","1","1","1","1","1","0","1","1","0","1","1","0","0","0","1","1","0","1","0","0","1","0","0","1","1","0","1","1","0","0","1","1","1","0","1","0","0","1","0","0","1","1","1","1","0","0","0","1","1","0","0","0","1","0","0","0","0","0","0","1","0","0","0"],["0","0","0","0","1","0","1","0","0","0","1","1","0","1","0","1","1","0","0","0","0","1","0","0","0","1","1","1","0","0","1","1","0","1","1","1","0","0","1","1","0","0","1","1","0","1","1","0","1","0","0","1","1","0","0","0","0","1","0","1","1","0","1","0","1","0","0","0","0","1","1","1","1","1","1","1","0","1","0","0","0","1","1","1","0","1","0","0","1","1","1","0","0","1","1","0","0","0","0","0","0","0","0","0","1","0","0","0","1","0","0","0","0","0","1","0","0","0","0","1","1","1","1","0","1","1","0","1","1","0","0","1","0","1","0","0","1","0","0","1","0","1","1","0","1","0","1","0","0","1","1","1","1","0","0","1","0","0","0","0","1","0","1","0","0","1","1","0","0","1","1","0","0","1","1","0","1","1","0","0","0","0","1","0","1","1","0","0","1","1","1","0","1","0","1","1","1","0","1","0","1","0","0","1","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","1","0","1","0","1","0","0","1","0","0","0","0","0","1","1","1","0","0","0","0","1","1","1","0","1","1","0","0","0","0","0","0","0","1","1","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["594179275863704165266696689399235767493667371625","594179275863704165266696689399235767493667371625","1288347612158191397270705234830805381732297126518","247512291986854564435551364600938690683113101007","0","0","0","0","0","0","0"],"fromIdx":["264","264","260","259","260","259","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["30","0","0","0"],["40","0","0","0"],["40","0","0","0"],["40","0","0","0"],["40","0","0","0"],["40","0","0","0"]],"imExitRoot":["0","0","0","16216388525409452520367650034131597795216465011356595646109550140247241387347","16216388525409452520367650034131597795216465011356595646109550140247241387347","16216388525409452520367650034131597795216465011356595646109550140247241387347","16216388525409452520367650034131597795216465011356595646109550140247241387347","16216388525409452520367650034131597795216465011356595646109550140247241387347","16216388525409452520367650034131597795216465011356595646109550140247241387347","16216388525409452520367650034131597795216465011356595646109550140247241387347"],"imFinalAccFee":["40","0","0","0"],"imInitStateRootFee":"12063160053709941400160547588624831667157042937323422396363359123696668555050","imOnChain":["1","1","1","1","0","0","0","0","0","0"],"imOutIdx":["264","264","264","264","264","264","264","264","264","264"],"imStateRoot":["8509190661143151169114766973894404305602702837528290925057905282067787815654","2011390155821304865953272527118765311483288188489014250830216039229563912314","455315233741541690383276804940414455205404930777288049237187986098680838352","3997132609476047186503565211524094551548282946156072921848486839507070828008","14726340140654602491676977019044730457558506243628844084529519410722544143560","12063160053709941400160547588624831667157042937323422396363359123696668555050","12063160053709941400160547588624831667157042937323422396363359123696668555050","12063160053709941400160547588624831667157042937323422396363359123696668555050","12063160053709941400160547588624831667157042937323422396363359123696668555050","12063160053709941400160547588624831667157042937323422396363359123696668555050"],"imStateRootFee":["20593679664586247774284790801579542411781976279024409415159440382607791042723","20593679664586247774284790801579542411781976279024409415159440382607791042723","20593679664586247774284790801579542411781976279024409415159440382607791042723"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","1","0","0","0","0","0","0","0"],"loadAmountF":["500","400","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["0","0","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","1","0","0","0","0","0","0","0"],"nonce1":["1","1","0","1","0","1","0","0","0","0","0"],"nonce2":["0","0","1","0","2","1","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["0","0","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"264","oldStateRoot":"8905191229562583213069132470917469035834300549892959854483573322676101624713","oldValue1":["0","0","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["1","1","1","1","0","0","0","0","0","0","0"],"r8x":["0","0","0","0","16254759499172734417722307213036425081723135786393041297785552945066455173881","3395671717403944983520146880528871871064486932447683466946776953558014089536","0","0","0","0","0"],"r8y":["0","0","0","0","17817737840274164371918975562337388999980903089248613923797910713206113489854","7342398271243038196138915394650506262231940591927774706965905817094280818661","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","2022657604301051614246963175651179116510951523171651563999591629963414240754","1779886882342479525779817527854774386819321478449351536968533800669111511381","0","0","0","0","0"],"siblings1":[["803023705192123541955777584206814514084066785011454827642873305228346631419","16139509698469054999538233992982712555809977778601726919301017987108938945574","18415507397039526176679688506579114602308891419321366426899227563735979799040","3733363825033960041993832455273006372365256793537049497701258715360801923303","0","0","0","0","0","0","0","0","0","0","0","0","0"],["803023705192123541955777584206814514084066785011454827642873305228346631419","16139509698469054999538233992982712555809977778601726919301017987108938945574","18415507397039526176679688506579114602308891419321366426899227563735979799040","3733363825033960041993832455273006372365256793537049497701258715360801923303","0","0","0","0","0","0","0","0","0","0","0","0","0"],["803023705192123541955777584206814514084066785011454827642873305228346631419","16139509698469054999538233992982712555809977778601726919301017987108938945574","4621198588491236789915271808966193912932371874379056565652261456168799774329","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["4326223072727001253775200618679375783609012839552971932038458727184727710492","9511566748286243410718405432244363254186644304849399669411385661138784704473","14953588290083376396795731213913673284537083615083251729160883959876747477655","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["6979864763769362693023771274212159033883599944157916606562186608306912532121","16139509698469054999538233992982712555809977778601726919301017987108938945574","4621198588491236789915271808966193912932371874379056565652261456168799774329","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["9860176942790404988853823159486469440448221482229555552577267990362268222667","9511566748286243410718405432244363254186644304849399669411385661138784704473","14953588290083376396795731213913673284537083615083251729160883959876747477655","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["803023705192123541955777584206814514084066785011454827642873305228346631419","16139509698469054999538233992982712555809977778601726919301017987108938945574","4621198588491236789915271808966193912932371874379056565652261456168799774329","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["4326223072727001253775200618679375783609012839552971932038458727184727710492","9511566748286243410718405432244363254186644304849399669411385661138784704473","14953588290083376396795731213913673284537083615083251729160883959876747477655","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["6979864763769362693023771274212159033883599944157916606562186608306912532121","16139509698469054999538233992982712555809977778601726919301017987108938945574","6359100303258919637796150829394060021769124024950410155746732217725400866259","20344417271658968953097914183087577010545934187405279090971244958040170314694","0","0","0","0","0","0","0","0","0","0","0","0","0"],["2874873048254704512782501288656967685893402721036588948194321175693399505939","16139509698469054999538233992982712555809977778601726919301017987108938945574","18908151756180406251762769112222699887463227656846887383022223012263677638724","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["530511219117683784235812760691745621426160630714567200056439438196957984","9511566748286243410718405432244363254186644304849399669411385661138784704473","11544148174490001160374664103342829693902057185104149240635194962449774676165","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","14382649545529405976710664157356364657039027681269256663271478725131562622080","7299054315324763317564375227723527917820889071879589087797584828752306403468","0","0","0","0","0"],"toEthAddr":["0","0","0","0","721457446580647751014191829380889690493307935711","1288347612158191397270705234830805381732297126518","0","0","0","0","0"],"toIdx":["0","260","259","1","256","260","0","0","0","0","0"],"tokenID1":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID3":["0","0","0","0"],"txCompressedData":["74309397174281743","20599322253708802083718601369103","20520094091194536620225150576143","79228162514337239615834678799","13269348750238205523937671488142474492463191624120931625487701894671","13269348750238301304908975606196121889469301168501964865582037460495","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","51833393555617990327881529250556564675404934046831101352704213252","51833393555618364472300685961703608973089606562417740462551990531","0","0","0","0","0"]}` //nolint:lll
  791. assert.Equal(t, expected, string(s))
  792. // printZKInputs(t, ptOut.ZKInputs)
  793. log.Debug("(batch10) block:1 batch:2")
  794. l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[1].Rollup.Batches[1].Batch.ForgeL1TxsNum])
  795. l2Txs = []common.PoolL2Tx{}
  796. coordIdxs = []common.Idx{}
  797. ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs,
  798. blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs)
  799. require.NoError(t, err)
  800. assert.Equal(t,
  801. "7635139306183028888189957942287689775017794868718398189334978386355501406695",
  802. sdb.MT.Root().BigInt().String())
  803. h, err = ptOut.ZKInputs.HashGlobalData()
  804. require.NoError(t, err)
  805. assert.Equal(t,
  806. "19819774768501383376082666649646195708939895273062203328571310678881620534373",
  807. h.String())
  808. s, err = json.Marshal(ptOut.ZKInputs)
  809. require.NoError(t, err)
  810. // the 'expected' data has been checked with the circom circuits
  811. expected = `{"amountF":["0","0","0","0","0","0","0","0","0","0","0"],"auxFromIdx":["265","0","0","0","0","0","0","0","0","0","0"],"auxToIdx":["0","0","0","0","0","0","0","0","0","0","0"],"ay1":["14399896874050294773416960703887603710722794411453238547230464125238466395720","0","0","0","0","0","0","0","0","0","0"],"ay2":["0","0","0","0","0","0","0","0","0","0","0"],"ay3":["0","0","0","0"],"balance1":["0","0","0","0","0","0","0","0","0","0","0"],"balance2":["0","0","0","0","0","0","0","0","0","0","0"],"balance3":["0","0","0","0"],"currentNumBatch":"10","ethAddr1":["1310124058894944929521848911038157567604058624321","0","0","0","0","0","0","0","0","0","0"],"ethAddr2":["0","0","0","0","0","0","0","0","0","0","0"],"ethAddr3":["0","0","0","0"],"feeIdxs":["0","0","0","0"],"feePlanTokens":["0","0","0","0"],"fromBjjCompressed":[["0","0","0","1","0","0","1","0","0","1","1","1","1","1","0","0","1","0","1","1","0","0","1","1","1","1","0","1","0","0","0","0","0","0","0","0","1","0","0","1","1","0","1","1","0","0","0","0","1","1","1","1","0","1","1","1","0","0","0","0","1","0","0","0","0","0","1","1","0","0","1","0","0","0","0","1","1","0","0","1","1","0","1","1","1","0","0","1","0","1","1","1","1","0","0","0","0","1","1","1","1","0","0","1","0","1","1","0","0","1","1","1","0","0","1","1","0","0","1","0","0","0","1","0","1","0","0","0","0","0","0","1","1","0","1","1","0","0","1","1","1","1","0","0","1","0","1","1","1","1","1","1","1","1","1","0","0","0","1","1","1","0","0","0","0","1","1","1","0","0","0","1","1","0","0","0","0","0","1","0","0","0","0","1","0","0","0","0","1","0","0","0","0","1","0","1","1","0","0","0","0","0","1","0","1","0","1","1","1","1","1","1","1","1","1","0","1","1","0","1","0","0","0","1","0","0","1","0","0","0","0","1","1","0","1","1","0","0","0","0","0","1","1","0","1","0","1","1","1","1","1","1","1","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["1310124058894944929521848911038157567604058624321","0","0","0","0","0","0","0","0","0","0"],"fromIdx":["0","0","0","0","0","0","0","0","0","0","0"],"globalChainID":"0","imAccFeeOut":[["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"],["0","0","0","0"]],"imExitRoot":["0","0","0","0","0","0","0","0","0","0"],"imFinalAccFee":["0","0","0","0"],"imInitStateRootFee":"7635139306183028888189957942287689775017794868718398189334978386355501406695","imOnChain":["1","0","0","0","0","0","0","0","0","0"],"imOutIdx":["265","265","265","265","265","265","265","265","265","265"],"imStateRoot":["7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695"],"imStateRootFee":["7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695","7635139306183028888189957942287689775017794868718398189334978386355501406695"],"isOld0_1":["0","0","0","0","0","0","0","0","0","0","0"],"isOld0_2":["0","0","0","0","0","0","0","0","0","0","0"],"loadAmountF":["0","0","0","0","0","0","0","0","0","0","0"],"maxNumBatch":["0","0","0","0","0","0","0","0","0","0","0"],"newAccount":["1","0","0","0","0","0","0","0","0","0","0"],"newExit":["0","0","0","0","0","0","0","0","0","0","0"],"nonce1":["0","0","0","0","0","0","0","0","0","0","0"],"nonce2":["0","0","0","0","0","0","0","0","0","0","0"],"nonce3":["0","0","0","0"],"oldKey1":["257","0","0","0","0","0","0","0","0","0","0"],"oldKey2":["0","0","0","0","0","0","0","0","0","0","0"],"oldLastIdx":"264","oldStateRoot":"20593679664586247774284790801579542411781976279024409415159440382607791042723","oldValue1":["4257195831259797492404954778722311885833296640062431738498839551435681147467","0","0","0","0","0","0","0","0","0","0"],"oldValue2":["0","0","0","0","0","0","0","0","0","0","0"],"onChain":["1","0","0","0","0","0","0","0","0","0","0"],"r8x":["0","0","0","0","0","0","0","0","0","0","0"],"r8y":["0","0","0","0","0","0","0","0","0","0","0"],"rqOffset":["0","0","0","0","0","0","0","0","0","0","0"],"rqToBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"rqToEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"rqTxCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"],"s":["0","0","0","0","0","0","0","0","0","0","0"],"siblings1":[["530511219117683784235812760691745621426160630714567200056439438196957984","18367588618280584551737321951686614373027695088935238448076283632726161942664","7724712759630475264744487573511141664766742804458973883688465500340683191441","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0","0","0","0","0","0","0","0","0"],"sign2":["0","0","0","0","0","0","0","0","0","0","0"],"sign3":["0","0","0","0"],"toBjjAy":["0","0","0","0","0","0","0","0","0","0","0"],"toEthAddr":["0","0","0","0","0","0","0","0","0","0","0"],"toIdx":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID1":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID2":["0","0","0","0","0","0","0","0","0","0","0"],"tokenID3":["0","0","0","0"],"txCompressedData":["3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559","3322668559"],"txCompressedDataV2":["0","0","0","0","0","0","0","0","0","0","0"]}` //nolint:lll
  812. assert.Equal(t, expected, string(s))
  813. // printZKInputs(t, ptOut.ZKInputs)
  814. }
  815. func TestZKInputsForceExitNotEnoughBalance(t *testing.T) {
  816. // Test to check a ForceExit of more ethers than the existing in the
  817. // Account.Balance. The ExitTree should not be updated, and the
  818. // ZKInputs for that Exit should be updated with EffectiveAmount=0.
  819. dir, err := ioutil.TempDir("", "tmpdb")
  820. require.NoError(t, err)
  821. defer assert.NoError(t, os.RemoveAll(dir))
  822. nLevels := 16
  823. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  824. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  825. assert.NoError(t, err)
  826. chainID := uint16(1)
  827. tc := til.NewContext(chainID, common.RollupConstMaxL1UserTx)
  828. set := `
  829. Type: Blockchain
  830. CreateAccountDeposit(0) A: 100
  831. > batchL1 // batch1: freeze L1User{1}
  832. > batchL1 // batch2: forge L1User{1}
  833. ForceExit(0) A: 110
  834. > batchL1 // batch3: freeze L1User{1}
  835. > batchL1 // batch4: forge L1User{1}
  836. > block
  837. `
  838. blocks, err := tc.GenerateBlocks(set)
  839. require.NoError(t, err)
  840. err = tc.FillBlocksExtra(blocks, &til.ConfigExtra{})
  841. require.NoError(t, err)
  842. err = tc.FillBlocksForgedL1UserTxs(blocks)
  843. require.NoError(t, err)
  844. config := Config{
  845. NLevels: uint32(nLevels),
  846. MaxTx: 3,
  847. MaxL1Tx: 2,
  848. MaxFeeTx: 2,
  849. ChainID: chainID,
  850. }
  851. tp := NewTxProcessor(sdb, config)
  852. // process Batch2:
  853. ptOut, err := tp.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil)
  854. require.NoError(t, err)
  855. assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
  856. assert.Equal(t,
  857. "13250144760662777978687264077050092444905467656476402514654550449973838329915",
  858. ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String())
  859. assert.Equal(t, "100", ptOut.ZKInputs.DepositAmountF[0].String())
  860. h, err := ptOut.ZKInputs.HashGlobalData()
  861. require.NoError(t, err)
  862. assert.Equal(t,
  863. "17028360168812316324862802266561698472229601571231630405748921483293273094640",
  864. h.String())
  865. // printZKInputs(t, ptOut.ZKInputs)
  866. // process Batch4:
  867. ptOut, err = tp.ProcessTxs(nil, blocks[0].Rollup.Batches[3].L1UserTxs, nil, nil)
  868. require.NoError(t, err)
  869. assert.Equal(t,
  870. "9817949306315488277882761441334442702413477797580483156608957607254414748724",
  871. ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String())
  872. assert.Equal(t,
  873. "13250144760662777978687264077050092444905467656476402514654550449973838329915",
  874. ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String())
  875. assert.Equal(t, "110", ptOut.ZKInputs.AmountF[0].String())
  876. h, err = ptOut.ZKInputs.HashGlobalData()
  877. require.NoError(t, err)
  878. assert.Equal(t,
  879. "10454439683412079257718620570784770435517390814985647079468048472416044260361",
  880. h.String())
  881. // printZKInputs(t, ptOut.ZKInputs)
  882. s, err := json.Marshal(ptOut.ZKInputs)
  883. require.NoError(t, err)
  884. // the 'expected' data has been checked with the circom circuits
  885. expected := `{"amountF":["110","0","0"],"auxFromIdx":["0","0","0"],"auxToIdx":["0","0","0"],"ay1":["14382649545529405976710664157356364657039027681269256663271478725131562622080","0","0"],"ay2":["14382649545529405976710664157356364657039027681269256663271478725131562622080","0","0"],"ay3":["0","0"],"balance1":["100","0","0"],"balance2":["0","0","0"],"balance3":["0","0"],"currentNumBatch":"2","ethAddr1":["721457446580647751014191829380889690493307935711","0","0"],"ethAddr2":["721457446580647751014191829380889690493307935711","0","0"],"ethAddr3":["0","0"],"feeIdxs":["0","0"],"feePlanTokens":["0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","1","0","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","1","1","1","1","0","0","1","0","1","0","1","1","1","0","1","0","1","1","1","1","0","0","1","0","0","0","0","1","1","0","1","1","0","1","1","1","0","1","0","0","0","1","0","1","0","0","1","0","1","1","1","1","1","1","0","0","1","1","0","1","0","1","1","1","1","1","1","0","0","1","1","1","1","1","1","0","0","0","0","1","1","1","1","0","0","1","0","1","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","0","0","1","0","0","0","0","0","1","1","1","1","1","1","1","1","0","1","1","0","1","0","1","0","1","0","0","1","1","1","0","0","0","1","1","0","0","0","1","0","1","1","0","1","0","1","0","1","1","1","0","0","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","0","0","1","1","0","0","0","1","1","0","0","1","0","0","1","1","0","0","1","0","0","0","1","0","1","0","1","0","0","1","0","0","0","1","1","0","0","1","1","1","1","1","1","1","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","0","0"],"fromIdx":["256","0","0"],"globalChainID":"1","imAccFeeOut":[["0","0"],["0","0"]],"imExitRoot":["9817949306315488277882761441334442702413477797580483156608957607254414748724","9817949306315488277882761441334442702413477797580483156608957607254414748724"],"imFinalAccFee":["0","0"],"imInitStateRootFee":"13250144760662777978687264077050092444905467656476402514654550449973838329915","imOnChain":["1","0"],"imOutIdx":["256","256"],"imStateRoot":["13250144760662777978687264077050092444905467656476402514654550449973838329915","13250144760662777978687264077050092444905467656476402514654550449973838329915"],"imStateRootFee":["13250144760662777978687264077050092444905467656476402514654550449973838329915"],"isOld0_1":["0","0","0"],"isOld0_2":["1","0","0"],"loadAmountF":["0","0","0"],"maxNumBatch":["0","0","0"],"newAccount":["0","0","0"],"newExit":["1","0","0"],"nonce1":["0","0","0"],"nonce2":["0","0","0"],"nonce3":["0","0"],"oldKey1":["0","0","0"],"oldKey2":["0","0","0"],"oldLastIdx":"256","oldStateRoot":"13250144760662777978687264077050092444905467656476402514654550449973838329915","oldValue1":["0","0","0"],"oldValue2":["0","0","0"],"onChain":["1","0","0"],"r8x":["0","0","0"],"r8y":["0","0","0"],"rqOffset":["0","0","0"],"rqToBjjAy":["0","0","0"],"rqToEthAddr":["0","0","0"],"rqTxCompressedDataV2":["0","0","0"],"s":["0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0"],"sign2":["0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0"],"toEthAddr":["0","0","0"],"toIdx":["1","0","0"],"tokenID1":["0","0","0"],"tokenID2":["0","0","0"],"tokenID3":["0","0"],"txCompressedData":["79228162514336395195199514127","7617635855","7617635855"],"txCompressedDataV2":["0","0","0"]}` //nolint:lll
  886. assert.Equal(t, expected, string(s))
  887. }
  888. func TestZKInputsTwoExits(t *testing.T) {
  889. ptOuts, _, ptOuts3 := testTwoExits(t, statedb.TypeBatchBuilder)
  890. // printZKInputs(t, ptOuts[3].ZKInputs)
  891. h, err := ptOuts[3].ZKInputs.HashGlobalData()
  892. require.NoError(t, err)
  893. assert.Equal(t,
  894. "10950797006638190377739621448211611127089922602417256848192618264349501853874",
  895. h.String())
  896. s, err := json.Marshal(ptOuts[3].ZKInputs)
  897. require.NoError(t, err)
  898. // the 'expected' data has been checked with the circom circuits
  899. expected := `{"amountF":["20","20","0"],"auxFromIdx":["0","0","0"],"auxToIdx":["0","0","0"],"ay1":["14382649545529405976710664157356364657039027681269256663271478725131562622080","14382649545529405976710664157356364657039027681269256663271478725131562622080","0"],"ay2":["14382649545529405976710664157356364657039027681269256663271478725131562622080","14382649545529405976710664157356364657039027681269256663271478725131562622080","0"],"ay3":["0","0"],"balance1":["100","80","0"],"balance2":["0","20","0"],"balance3":["0","0"],"currentNumBatch":"4","ethAddr1":["721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0"],"ethAddr2":["721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0"],"ethAddr3":["0","0"],"feeIdxs":["0","0"],"feePlanTokens":["0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","1","0","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","1","1","1","1","0","0","1","0","1","0","1","1","1","0","1","0","1","1","1","1","0","0","1","0","0","0","0","1","1","0","1","1","0","1","1","1","0","1","0","0","0","1","0","1","0","0","1","0","1","1","1","1","1","1","0","0","1","1","0","1","0","1","1","1","1","1","1","0","0","1","1","1","1","1","1","0","0","0","0","1","1","1","1","0","0","1","0","1","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","0","0","1","0","0","0","0","0","1","1","1","1","1","1","1","1","0","1","1","0","1","0","1","0","1","0","0","1","1","1","0","0","0","1","1","0","0","0","1","0","1","1","0","1","0","1","0","1","1","1","0","0","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","0","0","1","1","0","0","0","1","1","0","0","1","0","0","1","1","0","0","1","0","0","0","1","0","1","0","1","0","0","1","0","0","0","1","1","0","0","1","1","1","1","1","1","1","0","0","0"],["0","0","0","0","0","0","0","1","0","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","1","1","1","1","0","0","1","0","1","0","1","1","1","0","1","0","1","1","1","1","0","0","1","0","0","0","0","1","1","0","1","1","0","1","1","1","0","1","0","0","0","1","0","1","0","0","1","0","1","1","1","1","1","1","0","0","1","1","0","1","0","1","1","1","1","1","1","0","0","1","1","1","1","1","1","0","0","0","0","1","1","1","1","0","0","1","0","1","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","0","0","1","0","0","0","0","0","1","1","1","1","1","1","1","1","0","1","1","0","1","0","1","0","1","0","0","1","1","1","0","0","0","1","1","0","0","0","1","0","1","1","0","1","0","1","0","1","1","1","0","0","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","0","0","1","1","0","0","0","1","1","0","0","1","0","0","1","1","0","0","1","0","0","0","1","0","1","0","1","0","0","1","0","0","0","1","1","0","0","1","1","1","1","1","1","1","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0"],"fromIdx":["256","256","0"],"globalChainID":"1","imAccFeeOut":[["0","0"],["0","0"]],"imExitRoot":["2380063175300407347922357090412951175338645700746082570859905790898687000391","8964275250005792757357032892700084623149151898870284979399455550215173903222"],"imFinalAccFee":["0","0"],"imInitStateRootFee":"6280060925616273995219951863334303302604233442731990438879089264288785679485","imOnChain":["1","1"],"imOutIdx":["256","256"],"imStateRoot":["13565041521633989754749284676794467244560674489122118283653378907823392086389","6280060925616273995219951863334303302604233442731990438879089264288785679485"],"imStateRootFee":["6280060925616273995219951863334303302604233442731990438879089264288785679485"],"isOld0_1":["0","0","0"],"isOld0_2":["1","0","0"],"loadAmountF":["0","0","0"],"maxNumBatch":["0","0","0"],"newAccount":["0","0","0"],"newExit":["1","0","0"],"nonce1":["0","0","0"],"nonce2":["0","0","0"],"nonce3":["0","0"],"oldKey1":["0","0","0"],"oldKey2":["0","256","0"],"oldLastIdx":"256","oldStateRoot":"13250144760662777978687264077050092444905467656476402514654550449973838329915","oldValue1":["0","0","0"],"oldValue2":["0","3754513185696405615089356386152191454901549499148105430574660491752246564672","0"],"onChain":["1","1","0"],"r8x":["0","0","0"],"r8y":["0","0","0"],"rqOffset":["0","0","0"],"rqToBjjAy":["0","0","0"],"rqToEthAddr":["0","0","0"],"rqTxCompressedDataV2":["0","0","0"],"s":["0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0"],"sign2":["0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0"],"toEthAddr":["0","0","0"],"toIdx":["1","1","0"],"tokenID1":["0","0","0"],"tokenID2":["0","0","0"],"tokenID3":["0","0"],"txCompressedData":["79228162514336395195199514127","79228162514336395195199514127","7617635855"],"txCompressedDataV2":["0","0","0"]}` //nolint:lll
  900. assert.Equal(t, expected, string(s))
  901. // test the third ptOuts (ptOuts3)
  902. // printZKInputs(t, ptOuts3[3].ZKInputs)
  903. h, err = ptOuts3[3].ZKInputs.HashGlobalData()
  904. require.NoError(t, err)
  905. assert.Equal(t,
  906. "2011008604319628982038191506606026052967422135774742642236003642255766949753",
  907. h.String())
  908. s, err = json.Marshal(ptOuts3[3].ZKInputs)
  909. require.NoError(t, err)
  910. // the 'expected' data has been checked with the circom circuits
  911. expected = `{"amountF":["40","100","0"],"auxFromIdx":["0","0","0"],"auxToIdx":["0","0","0"],"ay1":["14382649545529405976710664157356364657039027681269256663271478725131562622080","14382649545529405976710664157356364657039027681269256663271478725131562622080","0"],"ay2":["14382649545529405976710664157356364657039027681269256663271478725131562622080","14382649545529405976710664157356364657039027681269256663271478725131562622080","0"],"ay3":["0","0"],"balance1":["100","60","0"],"balance2":["0","40","0"],"balance3":["0","0"],"currentNumBatch":"4","ethAddr1":["721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0"],"ethAddr2":["721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0"],"ethAddr3":["0","0"],"feeIdxs":["0","0"],"feePlanTokens":["0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","1","0","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","1","1","1","1","0","0","1","0","1","0","1","1","1","0","1","0","1","1","1","1","0","0","1","0","0","0","0","1","1","0","1","1","0","1","1","1","0","1","0","0","0","1","0","1","0","0","1","0","1","1","1","1","1","1","0","0","1","1","0","1","0","1","1","1","1","1","1","0","0","1","1","1","1","1","1","0","0","0","0","1","1","1","1","0","0","1","0","1","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","0","0","1","0","0","0","0","0","1","1","1","1","1","1","1","1","0","1","1","0","1","0","1","0","1","0","0","1","1","1","0","0","0","1","1","0","0","0","1","0","1","1","0","1","0","1","0","1","1","1","0","0","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","0","0","1","1","0","0","0","1","1","0","0","1","0","0","1","1","0","0","1","0","0","0","1","0","1","0","1","0","0","1","0","0","0","1","1","0","0","1","1","1","1","1","1","1","0","0","0"],["0","0","0","0","0","0","0","1","0","0","1","1","1","0","0","1","1","1","0","0","1","0","0","0","1","1","1","1","0","0","1","0","1","0","1","1","1","0","1","0","1","1","1","1","0","0","1","0","0","0","0","1","1","0","1","1","0","1","1","1","0","1","0","0","0","1","0","1","0","0","1","0","1","1","1","1","1","1","0","0","1","1","0","1","0","1","1","1","1","1","1","0","0","1","1","1","1","1","1","0","0","0","0","1","1","1","1","0","0","1","0","1","1","0","0","0","0","0","1","1","0","0","0","0","1","1","1","0","1","0","0","0","0","1","1","0","1","0","0","0","0","1","0","0","0","0","0","1","1","1","1","1","1","1","1","0","1","1","0","1","0","1","0","1","0","0","1","1","1","0","0","0","1","1","0","0","0","1","0","1","1","0","1","0","1","0","1","1","1","0","0","1","1","1","0","1","1","1","1","1","1","0","0","1","0","0","0","1","0","0","0","1","1","0","0","0","1","1","0","0","1","0","0","1","1","0","0","1","0","0","0","1","0","1","0","1","0","0","1","0","0","0","1","1","0","0","1","1","1","1","1","1","1","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","721457446580647751014191829380889690493307935711","0"],"fromIdx":["256","256","0"],"globalChainID":"1","imAccFeeOut":[["0","0"],["0","0"]],"imExitRoot":["8964275250005792757357032892700084623149151898870284979399455550215173903222","8964275250005792757357032892700084623149151898870284979399455550215173903222"],"imFinalAccFee":["0","0"],"imInitStateRootFee":"6280060925616273995219951863334303302604233442731990438879089264288785679485","imOnChain":["1","1"],"imOutIdx":["256","256"],"imStateRoot":["6280060925616273995219951863334303302604233442731990438879089264288785679485","6280060925616273995219951863334303302604233442731990438879089264288785679485"],"imStateRootFee":["6280060925616273995219951863334303302604233442731990438879089264288785679485"],"isOld0_1":["0","0","0"],"isOld0_2":["1","0","0"],"loadAmountF":["0","0","0"],"maxNumBatch":["0","0","0"],"newAccount":["0","0","0"],"newExit":["1","0","0"],"nonce1":["0","0","0"],"nonce2":["0","0","0"],"nonce3":["0","0"],"oldKey1":["0","0","0"],"oldKey2":["0","256","0"],"oldLastIdx":"256","oldStateRoot":"13250144760662777978687264077050092444905467656476402514654550449973838329915","oldValue1":["0","0","0"],"oldValue2":["0","15961349976762727207855784573778993150875000642950341362424341593271470369988","0"],"onChain":["1","1","0"],"r8x":["0","0","0"],"r8y":["0","0","0"],"rqOffset":["0","0","0"],"rqToBjjAy":["0","0","0"],"rqToEthAddr":["0","0","0"],"rqTxCompressedDataV2":["0","0","0"],"s":["0","0","0"],"siblings1":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0"],"sign2":["0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0"],"toEthAddr":["0","0","0"],"toIdx":["1","1","0"],"tokenID1":["0","0","0"],"tokenID2":["0","0","0"],"tokenID3":["0","0"],"txCompressedData":["79228162514336395195199514127","79228162514336395195199514127","7617635855"],"txCompressedDataV2":["0","0","0"]}` //nolint:lll
  912. assert.Equal(t, expected, string(s))
  913. }
  914. func TestZKInputsDepositTransferDifferentTokenIDs(t *testing.T) {
  915. // Test to check when a L1Tx of DepositTransfer has different TokenIDs
  916. // for the sender and the receiver. In this case, the Deposit should be
  917. // accepted and the Transfer not.
  918. dir, err := ioutil.TempDir("", "tmpdb")
  919. require.NoError(t, err)
  920. defer assert.NoError(t, os.RemoveAll(dir))
  921. nLevels := 16
  922. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  923. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  924. assert.NoError(t, err)
  925. chainID := uint16(1)
  926. tc := til.NewContext(chainID, common.RollupConstMaxL1UserTx)
  927. set := `
  928. Type: Blockchain
  929. AddToken(1)
  930. CreateAccountDeposit(0) A: 100
  931. CreateAccountDeposit(1) B: 100
  932. > batchL1 // batch1: freeze L1User{2}
  933. > batchL1 // batch2: forge L1User{2}
  934. // Til would not support the next DepositTransfer as it checks
  935. // the validity regarding TokenIDs of the accounts, that's why
  936. // the tx is generated by hand outside Til, but it's commented
  937. // here for readability
  938. // DepositTransfer(0) A-B: 200, 50
  939. > batchL1 // batch3: freeze L1User{1}
  940. > batchL1 // batch4: forge L1User{1}
  941. // expected balances:
  942. // A (0): 300
  943. // B (1): 100
  944. > block
  945. `
  946. blocks, err := tc.GenerateBlocks(set)
  947. require.NoError(t, err)
  948. err = tc.FillBlocksExtra(blocks, &til.ConfigExtra{})
  949. require.NoError(t, err)
  950. err = tc.FillBlocksForgedL1UserTxs(blocks)
  951. require.NoError(t, err)
  952. config := Config{
  953. NLevels: uint32(nLevels),
  954. MaxTx: 3,
  955. MaxL1Tx: 2,
  956. MaxFeeTx: 2,
  957. ChainID: chainID,
  958. }
  959. tp := NewTxProcessor(sdb, config)
  960. assert.Equal(t, "256", tc.Users["A"].Accounts[0].Idx.String())
  961. assert.Equal(t, "257", tc.Users["B"].Accounts[1].Idx.String())
  962. // process Batch2:
  963. ptOut, err := tp.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil)
  964. require.NoError(t, err)
  965. assert.Equal(t,
  966. "15840908427090148754401850838287012766516231419678649885722313476293488046059",
  967. ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String())
  968. checkBalanceByIdx(t, tp.s, 256, "100") // A
  969. checkBalanceByIdx(t, tp.s, 257, "100") // B
  970. // process Batch4:
  971. depositTransferTx := common.L1Tx{
  972. FromIdx: 256,
  973. ToIdx: 257,
  974. Amount: big.NewInt(50),
  975. DepositAmount: big.NewInt(200),
  976. FromEthAddr: tc.Users["A"].Addr,
  977. UserOrigin: true,
  978. Type: common.TxTypeDepositTransfer,
  979. }
  980. l1UserTxs := []common.L1Tx{depositTransferTx}
  981. ptOut, err = tp.ProcessTxs(nil, l1UserTxs, nil, nil)
  982. require.NoError(t, err)
  983. assert.Equal(t,
  984. "14230709344017026161842015882701267639148413699586803973757674240329499158042",
  985. ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String())
  986. checkBalanceByIdx(t, tp.s, 256, "300") // A
  987. checkBalanceByIdx(t, tp.s, 257, "100") // B
  988. // extra check directly with the Tx
  989. tp.computeEffectiveAmounts(&depositTransferTx)
  990. assert.Equal(t, big.NewInt(200), depositTransferTx.EffectiveDepositAmount)
  991. assert.Equal(t, big.NewInt(0), depositTransferTx.EffectiveAmount)
  992. // printZKInputs(t, ptOut.ZKInputs)
  993. h, err := ptOut.ZKInputs.HashGlobalData()
  994. require.NoError(t, err)
  995. assert.Equal(t,
  996. "2485980010399774177034042608918278055925032145897765910598368849182120296709",
  997. h.String())
  998. s, err := json.Marshal(ptOut.ZKInputs)
  999. require.NoError(t, err)
  1000. // the 'expected' data has been checked with the circom circuits
  1001. expected := `{"amountF":["50","0","0"],"auxFromIdx":["0","0","0"],"auxToIdx":["0","0","0"],"ay1":["14382649545529405976710664157356364657039027681269256663271478725131562622080","0","0"],"ay2":["21759653464180282217133439550283093276794317614482080451288933258136700169296","0","0"],"ay3":["0","0"],"balance1":["100","0","0"],"balance2":["100","0","0"],"balance3":["0","0"],"currentNumBatch":"2","ethAddr1":["721457446580647751014191829380889690493307935711","0","0"],"ethAddr2":["247512291986854564435551364600938690683113101007","0","0"],"ethAddr3":["0","0"],"feeIdxs":["0","0"],"feePlanTokens":["0","0"],"fromBjjCompressed":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"fromEthAddr":["721457446580647751014191829380889690493307935711","0","0"],"fromIdx":["256","0","0"],"globalChainID":"1","imAccFeeOut":[["0","0"],["0","0"]],"imExitRoot":["0","0"],"imFinalAccFee":["0","0"],"imInitStateRootFee":"14230709344017026161842015882701267639148413699586803973757674240329499158042","imOnChain":["1","0"],"imOutIdx":["257","257"],"imStateRoot":["14230709344017026161842015882701267639148413699586803973757674240329499158042","14230709344017026161842015882701267639148413699586803973757674240329499158042"],"imStateRootFee":["14230709344017026161842015882701267639148413699586803973757674240329499158042"],"isOld0_1":["0","0","0"],"isOld0_2":["0","0","0"],"loadAmountF":["200","0","0"],"maxNumBatch":["0","0","0"],"newAccount":["0","0","0"],"newExit":["0","0","0"],"nonce1":["0","0","0"],"nonce2":["0","0","0"],"nonce3":["0","0"],"oldKey1":["0","0","0"],"oldKey2":["0","0","0"],"oldLastIdx":"257","oldStateRoot":"15840908427090148754401850838287012766516231419678649885722313476293488046059","oldValue1":["0","0","0"],"oldValue2":["0","0","0"],"onChain":["1","0","0"],"r8x":["0","0","0"],"r8y":["0","0","0"],"rqOffset":["0","0","0"],"rqToBjjAy":["0","0","0"],"rqToEthAddr":["0","0","0"],"rqTxCompressedDataV2":["0","0","0"],"s":["0","0","0"],"siblings1":[["5993131179168317590128848694409809345900017684003771122621047119523950577591","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings2":[["5160745702297026561327885672205679976200681208820502543394227113874522176952","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"siblings3":[["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]],"sign1":["0","0","0"],"sign2":["0","0","0"],"sign3":["0","0"],"toBjjAy":["0","0","0"],"toEthAddr":["0","0","0"],"toIdx":["257","0","0"],"tokenID1":["0","0","0"],"tokenID2":["1","0","0"],"tokenID3":["0","0"],"txCompressedData":["20361637766166006819142450800143","7617635855","7617635855"],"txCompressedDataV2":["0","0","0"]}` //nolint:lll
  1002. assert.Equal(t, expected, string(s))
  1003. }
  1004. func TestZKInputsL1CoordinatorTxsAfterL1Exit(t *testing.T) {
  1005. // Test to check that the ISExitRoot values for the L1CoordinatorTx
  1006. // slots, after a L1User Exit tx, have the expected value (!=0)
  1007. dir, err := ioutil.TempDir("", "tmpdb")
  1008. require.NoError(t, err)
  1009. defer assert.NoError(t, os.RemoveAll(dir))
  1010. nLevels := 16
  1011. sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128,
  1012. Type: statedb.TypeBatchBuilder, NLevels: nLevels})
  1013. assert.NoError(t, err)
  1014. chainID := uint16(1)
  1015. tc := til.NewContext(chainID, common.RollupConstMaxL1UserTx)
  1016. set := `
  1017. Type: Blockchain
  1018. CreateAccountDeposit(0) A: 100
  1019. > batchL1 // batch1: freeze L1User{1}
  1020. > batchL1 // batch2: forge L1User{1}
  1021. ForceExit(0) A: 10
  1022. > batchL1 // batch1: freeze L1User{1}
  1023. // Coordinator creates needed 'To' accounts for the L2Txs
  1024. CreateAccountCoordinator(0) B
  1025. CreateAccountCoordinator(0) C
  1026. > batchL1 // batch3: forge L1User{1}, L1Coord{2}
  1027. > block
  1028. `
  1029. blocks, err := tc.GenerateBlocks(set)
  1030. require.NoError(t, err)
  1031. err = tc.FillBlocksExtra(blocks, &til.ConfigExtra{})
  1032. require.NoError(t, err)
  1033. err = tc.FillBlocksForgedL1UserTxs(blocks)
  1034. require.NoError(t, err)
  1035. config := Config{
  1036. NLevels: uint32(nLevels),
  1037. MaxTx: 5,
  1038. MaxL1Tx: 3,
  1039. MaxFeeTx: 3,
  1040. ChainID: chainID,
  1041. }
  1042. tp := NewTxProcessor(sdb, config)
  1043. // process Batch2:
  1044. ptOut, err := tp.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil)
  1045. require.NoError(t, err)
  1046. assert.Equal(t,
  1047. "13250144760662777978687264077050092444905467656476402514654550449973838329915",
  1048. ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String())
  1049. checkBalanceByIdx(t, tp.s, 256, "100") // A
  1050. // batch3
  1051. batchPoolL2 := `
  1052. Type: PoolL2
  1053. PoolTransferToEthAddr(0) A-B: 10 (126)
  1054. PoolTransferToEthAddr(0) A-C: 10 (126)`
  1055. poolL2Txs, err := tc.GeneratePoolL2Txs(batchPoolL2)
  1056. require.NoError(t, err)
  1057. // process Batch4:
  1058. l1UserTxs := blocks[0].Rollup.Batches[3].L1UserTxs
  1059. ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, poolL2Txs)
  1060. require.NoError(t, err)
  1061. assert.Equal(t,
  1062. "2449079255569259710281173899922223113570673452636649748260745275814779988814",
  1063. ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String())
  1064. checkBalanceByIdx(t, tp.s, 256, "68") // A
  1065. checkBalanceByIdx(t, tp.s, 257, "10") // B
  1066. // Check that all the ISExitRoot values have the expected value, and
  1067. // that there are no 0 for the L1Coordinator tx slots after the L1User
  1068. // slots
  1069. for i := 0; i < len(ptOut.ZKInputs.ISExitRoot); i++ {
  1070. assert.Equal(t, "17688031540912620894848983912708704736922099609001460827147265569563156468242", ptOut.ZKInputs.ISExitRoot[i].String())
  1071. }
  1072. h, err := ptOut.ZKInputs.HashGlobalData()
  1073. require.NoError(t, err)
  1074. assert.Equal(t,
  1075. "8192411682160084684833065083388970624427902618662264011806545490260079530864",
  1076. h.String())
  1077. // printZKInputs(t, ptOut.ZKInputs)
  1078. }