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.

193 lines
4.4 KiB

Update missing parts, improve til, and more - Node - Updated configuration to initialize the interface to all the smart contracts - Common - Moved BlockData and BatchData types to common so that they can be shared among: historydb, til and synchronizer - Remove hash.go (it was never used) - Remove slot.go (it was never used) - Remove smartcontractparams.go (it was never used, and appropriate structs are defined in `eth/`) - Comment state / status method until requirements of this method are properly defined, and move it to Synchronizer - Synchronizer - Simplify `Sync` routine to only sync one block per call, and return useful information. - Use BlockData and BatchData from common - Check that events belong to the expected block hash - In L1Batch, query L1UserTxs from HistoryDB - Fill ERC20 token information - Test AddTokens with test.Client - HistryDB - Use BlockData and BatchData from common - Add `GetAllTokens` method - Uncomment and update GetL1UserTxs (with corresponding tests) - Til - Rename all instances of RegisterToken to AddToken (to follow the smart contract implementation naming) - Use BlockData and BatchData from common - Move testL1CoordinatorTxs and testL2Txs to a separate struct from BatchData in Context - Start Context with BatchNum = 1 (which the protocol defines to be the first batchNum) - In every Batch, set StateRoot and ExitRoot to a non-nil big.Int (zero). - In all L1Txs, if LoadAmount is not used, set it to 0; if Amount is not used, set it to 0; so that no *big.Int is nil. - In L1UserTx, don't set BatchNum, because when L1UserTxs are created and obtained by the synchronizer, the BatchNum is not known yet (it's a synchronizer job to set it) - In L1UserTxs, set `UserOrigin` and set `ToForgeL1TxsNum`.
4 years ago
  1. package til
  2. // sets of instructions to be used in tests of other packages
  3. // SetBlockchain0 contains a set of transactions simulated to be from the smart contract
  4. var SetBlockchain0 = `
  5. // Set containing Blockchain transactions
  6. Type: Blockchain
  7. AddToken(1)
  8. AddToken(2)
  9. AddToken(3)
  10. // Coordinator accounts, Idxs: 256, 257, 258, 259
  11. CreateAccountCoordinator(0) Coord
  12. CreateAccountCoordinator(1) Coord
  13. CreateAccountCoordinator(2) Coord
  14. CreateAccountCoordinator(3) Coord
  15. > batch
  16. // deposits TokenID: 1
  17. CreateAccountDeposit(1) A: 50
  18. CreateAccountDeposit(1) B: 5
  19. CreateAccountDeposit(1) C: 20
  20. CreateAccountDeposit(1) D: 25
  21. CreateAccountDeposit(1) E: 25
  22. CreateAccountDeposit(1) F: 25
  23. CreateAccountDeposit(1) G: 25
  24. CreateAccountDeposit(1) H: 25
  25. CreateAccountDeposit(1) I: 25
  26. CreateAccountDeposit(1) J: 25
  27. CreateAccountDeposit(1) K: 25
  28. CreateAccountDeposit(1) L: 25
  29. CreateAccountDeposit(1) M: 25
  30. CreateAccountDeposit(1) N: 25
  31. CreateAccountDeposit(1) O: 25
  32. CreateAccountDeposit(1) P: 25
  33. CreateAccountDeposit(1) Q: 25
  34. CreateAccountDeposit(1) R: 25
  35. CreateAccountDeposit(1) S: 25
  36. CreateAccountDeposit(1) T: 25
  37. CreateAccountDeposit(1) U: 25
  38. CreateAccountDeposit(1) V: 25
  39. CreateAccountDeposit(1) W: 25
  40. CreateAccountDeposit(1) X: 25
  41. CreateAccountDeposit(1) Y: 25
  42. CreateAccountDeposit(1) Z: 25
  43. // deposits TokenID: 2
  44. CreateAccountDeposit(2) B: 5
  45. CreateAccountDeposit(2) A: 20
  46. // deposits TokenID: 3
  47. CreateAccountDeposit(3) B: 100
  48. // deposits TokenID: 0
  49. CreateAccountDeposit(0) B: 10000
  50. CreateAccountDeposit(0) C: 1
  51. > batchL1
  52. // transactions TokenID: 1
  53. Transfer(1) A-B: 5 (1)
  54. Transfer(1) A-L: 10 (1)
  55. Transfer(1) A-M: 5 (1)
  56. Transfer(1) A-N: 5 (1)
  57. Transfer(1) A-O: 5 (1)
  58. Transfer(1) B-C: 3 (1)
  59. Transfer(1) C-A: 3 (255)
  60. Transfer(1) D-A: 5 (1)
  61. Transfer(1) D-Z: 5 (1)
  62. Transfer(1) D-Y: 5 (1)
  63. Transfer(1) D-X: 5 (1)
  64. Transfer(1) E-Z: 5 (2)
  65. Transfer(1) E-Y: 5 (1)
  66. Transfer(1) E-X: 5 (1)
  67. Transfer(1) F-Z: 5 (1)
  68. Transfer(1) G-K: 3 (1)
  69. Transfer(1) G-K: 3 (1)
  70. Transfer(1) G-K: 3 (1)
  71. Transfer(1) H-K: 3 (2)
  72. Transfer(1) H-K: 3 (1)
  73. Transfer(1) H-K: 3 (1)
  74. Transfer(0) B-C: 50 (192)
  75. > batchL1
  76. > block
  77. // A (3) still does not exist, coordinator should create new L1Tx to create the account
  78. CreateAccountCoordinator(3) A
  79. Transfer(3) B-A: 5 (1)
  80. Transfer(2) A-B: 5 (1)
  81. Transfer(1) I-K: 3 (1)
  82. Transfer(1) I-K: 3 (1)
  83. Transfer(1) I-K: 3 (1)
  84. Transfer(1) J-K: 3 (1)
  85. Transfer(1) J-K: 3 (1)
  86. Transfer(1) J-K: 3 (1)
  87. Transfer(1) K-J: 3 (1)
  88. Transfer(1) L-A: 5 (1)
  89. Transfer(1) L-Z: 5 (1)
  90. Transfer(1) L-Y: 5 (1)
  91. Transfer(1) L-X: 5 (1)
  92. Transfer(1) M-A: 5 (1)
  93. Transfer(1) M-Z: 5 (1)
  94. Transfer(1) M-Y: 5 (1)
  95. Transfer(1) N-A: 5 (1)
  96. Transfer(1) N-Z: 5 (2)
  97. Transfer(1) N-Y: 5 (1)
  98. Transfer(1) O-T: 3 (1)
  99. Transfer(1) O-U: 3 (1)
  100. Transfer(1) O-V: 3 (1)
  101. Transfer(1) P-T: 3 (1)
  102. Transfer(1) P-U: 3 (1)
  103. Transfer(1) P-V: 3 (5)
  104. Transfer(1) Q-O: 3 (1)
  105. Transfer(1) Q-P: 3 (1)
  106. Transfer(1) R-O: 3 (1)
  107. Transfer(1) R-P: 3 (1)
  108. Transfer(1) R-Q: 3 (1)
  109. Transfer(1) S-O: 3 (1)
  110. Transfer(1) S-P: 3 (1)
  111. Transfer(1) S-Q: 3 (1)
  112. Transfer(1) T-O: 3 (1)
  113. Transfer(1) T-P: 3 (1)
  114. Transfer(1) T-Q: 3 (1)
  115. Transfer(1) U-Z: 5 (3)
  116. Transfer(1) U-Y: 5 (1)
  117. Transfer(1) U-T: 3 (1)
  118. Transfer(1) V-Z: 5 (0)
  119. Transfer(1) V-Y: 6 (1)
  120. Transfer(1) V-T: 3 (1)
  121. Transfer(1) W-K: 3 (1)
  122. Transfer(1) W-J: 3 (1)
  123. Transfer(1) W-A: 5 (1)
  124. Transfer(1) W-Z: 5 (1)
  125. Transfer(1) X-B: 5 (1)
  126. Transfer(1) X-C: 5 (50)
  127. Transfer(1) X-D: 5 (1)
  128. Transfer(1) X-E: 5 (1)
  129. Transfer(1) Y-B: 5 (1)
  130. Transfer(1) Y-C: 5 (1)
  131. Transfer(1) Y-D: 5 (1)
  132. Transfer(1) Y-E: 5 (1)
  133. Transfer(1) Z-A: 5 (1)
  134. // exits
  135. ForceExit(1) A: 5
  136. Exit(1) K: 5 (1)
  137. Exit(1) X: 5 (1)
  138. Exit(1) Y: 5 (1)
  139. Exit(1) Z: 5 (1)
  140. > batch
  141. Deposit(1) A: 50
  142. Deposit(1) B: 5
  143. Deposit(1) C: 20
  144. Deposit(1) D: 25
  145. Deposit(1) E: 25
  146. Deposit(1) F: 25
  147. Deposit(1) G: 25
  148. Deposit(1) H: 25
  149. Deposit(1) I: 25
  150. Transfer(1) A-B: 5 (1)
  151. Transfer(1) A-L: 10 (1)
  152. Transfer(1) A-M: 5 (1)
  153. Transfer(1) B-N: 5 (1)
  154. Transfer(1) C-O: 5 (1)
  155. Transfer(1) H-O: 5 (1)
  156. Transfer(1) I-H: 5 (1)
  157. Exit(1) A: 5 (1)
  158. // create CoordinatorTx CreateAccount for D, TokenId 2, used at SetPool0 for 'PoolTransfer(2) B-D: 3 (1)'
  159. CreateAccountCoordinator(2) D
  160. > batchL1
  161. > batchL1
  162. > block
  163. `
  164. // SetPool0 contains a set of transactions from the PoolL2
  165. var SetPool0 = `
  166. Type: PoolL2
  167. PoolTransfer(1) A-B: 6 (1)
  168. PoolTransfer(1) B-C: 3 (1)
  169. PoolTransfer(1) C-A: 3 (1)
  170. PoolTransfer(1) A-B: 1 (1)
  171. PoolTransfer(2) A-B: 15 (1)
  172. PoolTransfer(2) B-D: 3 (1)
  173. PoolExit(1) A: 3 (1)
  174. PoolTransfer(1) A-B: 6 (1)
  175. PoolTransfer(1) B-C: 3 (1)
  176. PoolTransfer(1) A-C: 3 (1)
  177. PoolTransferToEthAddr(1) A-C: 3 (1)
  178. PoolTransferToBJJ(1) A-C: 3 (1)
  179. `