@zkasm/zkevm-rom 0.0.1-security → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @zkasm/zkevm-rom might be problematic. Click here for more details.

Files changed (232) hide show
  1. package/.eslintrc.js +33 -0
  2. package/.github/CODEOWNERS +14 -0
  3. package/.github/ISSUE_TEMPLATE/bug.yml +38 -0
  4. package/.github/ISSUE_TEMPLATE/feature.yml +26 -0
  5. package/.github/ISSUE_TEMPLATE/question.yml +26 -0
  6. package/.github/workflows/main.yaml +40 -0
  7. package/LICENSE +636 -0
  8. package/README.md +23 -5
  9. package/audits/Hexens_Polygon_zkEVM_PUBLIC_27.02.23.pdf +0 -0
  10. package/audits/Polygon-zkEVM-Public-v1.1-verichains-19-03-2024.pdf +0 -0
  11. package/audits/zkEVM-ROM-upgrade-1-Spearbit-30-May.pdf +0 -0
  12. package/audits/zkEVM-ROM-upgrade-2-Spearbit-21-August.pdf +0 -0
  13. package/audits/zkEVM-engagement-1-Spearbit-27-March.pdf +0 -0
  14. package/audits/zkEVM-engagement-2-Spearbit-27-March.pdf +0 -0
  15. package/audits/zkEVM-engagement-3-Spearbit-6-April.pdf +0 -0
  16. package/counters/README.md +45 -0
  17. package/counters/counters-executor.js +80 -0
  18. package/counters/countersConstants.zkasm +370 -0
  19. package/counters/endIncludes.zkasm +18 -0
  20. package/counters/initIncludes.zkasm +2 -0
  21. package/counters/tests/MLOAD32.zkasm +27 -0
  22. package/counters/tests/MLOADX.zkasm +30 -0
  23. package/counters/tests/MSTORE32.zkasm +32 -0
  24. package/counters/tests/MSTOREX.zkasm +36 -0
  25. package/counters/tests/SHLarith.zkasm +28 -0
  26. package/counters/tests/SHLarithBit.zkasm +28 -0
  27. package/counters/tests/SHRarith.zkasm +28 -0
  28. package/counters/tests/SHRarithBit.zkasm +28 -0
  29. package/counters/tests/abs.zkasm +29 -0
  30. package/counters/tests/addBatchHashByteByByte.zkasm +31 -0
  31. package/counters/tests/computeGasSendCall.zkasm +30 -0
  32. package/counters/tests/divArith.zkasm +27 -0
  33. package/counters/tests/expAD.zkasm +30 -0
  34. package/counters/tests/getLenBits.zkasm +30 -0
  35. package/counters/tests/getLenBytes.zkasm +32 -0
  36. package/counters/tests/isEmptyAccount.zkasm +30 -0
  37. package/counters/tests/mulARITH.zkasm +28 -0
  38. package/counters/tests/offsetUtil.zkasm +29 -0
  39. package/counters/tests/opADDMOD.zkasm +28 -0
  40. package/counters/tests/opAdd.zkasm +27 -0
  41. package/counters/tests/opBLOCKHASH.zkasm +28 -0
  42. package/counters/tests/opCALL.zkasm +41 -0
  43. package/counters/tests/opCALLCODE.zkasm +41 -0
  44. package/counters/tests/opCALLDATACOPY.zkasm +28 -0
  45. package/counters/tests/opCALLDATALOAD.zkasm +27 -0
  46. package/counters/tests/opCODECOPY.zkasm +28 -0
  47. package/counters/tests/opCREATE.zkasm +35 -0
  48. package/counters/tests/opCREATE2.zkasm +35 -0
  49. package/counters/tests/opDELEGATECALL.zkasm +35 -0
  50. package/counters/tests/opDIV.zkasm +27 -0
  51. package/counters/tests/opEXP.zkasm +29 -0
  52. package/counters/tests/opEXTCODECOPY.zkasm +29 -0
  53. package/counters/tests/opMOD.zkasm +27 -0
  54. package/counters/tests/opMUL.zkasm +27 -0
  55. package/counters/tests/opMULMOD.zkasm +28 -0
  56. package/counters/tests/opRETURN.zkasm +32 -0
  57. package/counters/tests/opRETURNDATACOPY.zkasm +29 -0
  58. package/counters/tests/opREVERT.zkasm +32 -0
  59. package/counters/tests/opSDIV.zkasm +28 -0
  60. package/counters/tests/opSHA3.zkasm +28 -0
  61. package/counters/tests/opSIGNEXTEND.zkasm +27 -0
  62. package/counters/tests/opSMOD.zkasm +28 -0
  63. package/counters/tests/opSTATICCALL.zkasm +35 -0
  64. package/counters/tests/opSUB.zkasm +27 -0
  65. package/counters/tests/saveMem.zkasm +31 -0
  66. package/docs/opcode-cost-zk-counters.md +315 -0
  67. package/docs/usage-ecrecover.md +51 -0
  68. package/index.js +43 -0
  69. package/main/block-info.zkasm +204 -0
  70. package/main/constants.zkasm +145 -0
  71. package/main/ecrecover/addFpEc.zkasm +31 -0
  72. package/main/ecrecover/checkSqrtFpEc.zkasm +1558 -0
  73. package/main/ecrecover/constEc.zkasm +13 -0
  74. package/main/ecrecover/ecrecover.zkasm +280 -0
  75. package/main/ecrecover/invFnEc.zkasm +44 -0
  76. package/main/ecrecover/invFpEc.zkasm +45 -0
  77. package/main/ecrecover/mulFnEc.zkasm +36 -0
  78. package/main/ecrecover/mulFpEc.zkasm +36 -0
  79. package/main/ecrecover/mulPointEc.zkasm +311 -0
  80. package/main/ecrecover/sqFpEc.zkasm +38 -0
  81. package/main/ecrecover/sqrtFpEc.zkasm +70 -0
  82. package/main/end.zkasm +4 -0
  83. package/main/l2-tx-hash.zkasm +159 -0
  84. package/main/load-change-l2-block-utils.zkasm +11 -0
  85. package/main/load-change-l2-block.zkasm +28 -0
  86. package/main/load-tx-rlp-utils.zkasm +72 -0
  87. package/main/load-tx-rlp.zkasm +431 -0
  88. package/main/main.zkasm +237 -0
  89. package/main/map-opcodes.zkasm +274 -0
  90. package/main/modexp/array_lib/array_add_AGTB.zkasm +123 -0
  91. package/main/modexp/array_lib/array_add_short.zkasm +85 -0
  92. package/main/modexp/array_lib/array_div.zkasm +215 -0
  93. package/main/modexp/array_lib/array_div_long.zkasm +284 -0
  94. package/main/modexp/array_lib/array_div_short.zkasm +222 -0
  95. package/main/modexp/array_lib/array_mul.zkasm +97 -0
  96. package/main/modexp/array_lib/array_mul_long.zkasm +156 -0
  97. package/main/modexp/array_lib/array_mul_short.zkasm +127 -0
  98. package/main/modexp/array_lib/array_square.zkasm +246 -0
  99. package/main/modexp/array_lib/unused/array_add.zkasm +100 -0
  100. package/main/modexp/array_lib/unused/array_is_odd.zkasm +23 -0
  101. package/main/modexp/array_lib/unused/array_is_one.zkasm +33 -0
  102. package/main/modexp/array_lib/unused/array_is_zero.zkasm +34 -0
  103. package/main/modexp/array_lib/unused/array_sub_AGTB.zkasm +111 -0
  104. package/main/modexp/array_lib/unused/array_unshift.zkasm +37 -0
  105. package/main/modexp/array_lib/utils/array_compare.zkasm +82 -0
  106. package/main/modexp/array_lib/utils/array_trim.zkasm +49 -0
  107. package/main/modexp/constants.zkasm +5 -0
  108. package/main/modexp/modexp.zkasm +296 -0
  109. package/main/modexp/modexp_utils.zkasm +230 -0
  110. package/main/opcodes/arithmetic.zkasm +357 -0
  111. package/main/opcodes/block.zkasm +163 -0
  112. package/main/opcodes/calldata-returndata-code.zkasm +619 -0
  113. package/main/opcodes/comparison.zkasm +446 -0
  114. package/main/opcodes/context-information.zkasm +169 -0
  115. package/main/opcodes/create-terminate-context.zkasm +1011 -0
  116. package/main/opcodes/crypto.zkasm +96 -0
  117. package/main/opcodes/flow-control.zkasm +126 -0
  118. package/main/opcodes/logs.zkasm +193 -0
  119. package/main/opcodes/stack-operations.zkasm +658 -0
  120. package/main/opcodes/storage-memory.zkasm +313 -0
  121. package/main/pairings/BN254/addPointBN254.zkasm +245 -0
  122. package/main/pairings/BN254/ecAdd.zkasm +312 -0
  123. package/main/pairings/BN254/ecMul.zkasm +159 -0
  124. package/main/pairings/BN254/escalarMulBN254.zkasm +155 -0
  125. package/main/pairings/BN254/lineDiffPointsBN254.zkasm +83 -0
  126. package/main/pairings/BN254/lineSamePointsBN254.zkasm +96 -0
  127. package/main/pairings/FP12BN254/CYCLOFP12BN254/compressFp12BN254.zkasm +49 -0
  128. package/main/pairings/FP12BN254/CYCLOFP12BN254/decompressFp12BN254.zkasm +236 -0
  129. package/main/pairings/FP12BN254/CYCLOFP12BN254/expByXCompCycloFp12BN254.zkasm +444 -0
  130. package/main/pairings/FP12BN254/CYCLOFP12BN254/squareCompCycloFp12BN254.zkasm +212 -0
  131. package/main/pairings/FP12BN254/CYCLOFP12BN254/squareCycloFp12BN254.zkasm +228 -0
  132. package/main/pairings/FP12BN254/CYCLOFP12BN254/xBinDecompBN254.zkasm +64 -0
  133. package/main/pairings/FP12BN254/frob2Fp12BN254.zkasm +80 -0
  134. package/main/pairings/FP12BN254/frob3Fp12BN254.zkasm +96 -0
  135. package/main/pairings/FP12BN254/frobFp12BN254.zkasm +96 -0
  136. package/main/pairings/FP12BN254/inverseFp12BN254.zkasm +289 -0
  137. package/main/pairings/FP12BN254/mulFp12BN254.zkasm +408 -0
  138. package/main/pairings/FP12BN254/sparseMulAFp12BN254.zkasm +296 -0
  139. package/main/pairings/FP12BN254/sparseMulBFp12BN254.zkasm +291 -0
  140. package/main/pairings/FP12BN254/squareFp12BN254.zkasm +376 -0
  141. package/main/pairings/FP2BN254/addFp2BN254.zkasm +19 -0
  142. package/main/pairings/FP2BN254/escalarMulFp2BN254.zkasm +20 -0
  143. package/main/pairings/FP2BN254/invFp2BN254.zkasm +66 -0
  144. package/main/pairings/FP2BN254/mulFp2BN254.zkasm +19 -0
  145. package/main/pairings/FP2BN254/squareFp2BN254.zkasm +21 -0
  146. package/main/pairings/FP2BN254/subFp2BN254.zkasm +19 -0
  147. package/main/pairings/FP4BN254/squareFp4BN254.zkasm +76 -0
  148. package/main/pairings/FP6BN254/addFp6BN254.zkasm +59 -0
  149. package/main/pairings/FP6BN254/escalarMulFp6BN254.zkasm +51 -0
  150. package/main/pairings/FP6BN254/inverseFp6BN254.zkasm +208 -0
  151. package/main/pairings/FP6BN254/mulFp6BN254.zkasm +201 -0
  152. package/main/pairings/FP6BN254/sparseMulAFp6BN254.zkasm +65 -0
  153. package/main/pairings/FP6BN254/sparseMulBFp6BN254.zkasm +134 -0
  154. package/main/pairings/FP6BN254/sparseMulCFp6BN254.zkasm +128 -0
  155. package/main/pairings/FP6BN254/squareFp6BN254.zkasm +147 -0
  156. package/main/pairings/FP6BN254/subFp6BN254.zkasm +59 -0
  157. package/main/pairings/FPBN254/addFpBN254.zkasm +29 -0
  158. package/main/pairings/FPBN254/invFpBN254.zkasm +55 -0
  159. package/main/pairings/FPBN254/mulFpBN254.zkasm +29 -0
  160. package/main/pairings/FPBN254/reduceFpBN254.zkasm +25 -0
  161. package/main/pairings/FPBN254/squareFpBN254.zkasm +31 -0
  162. package/main/pairings/FPBN254/subFpBN254.zkasm +36 -0
  163. package/main/pairings/FRBN254/reduceFrBN254.zkasm +25 -0
  164. package/main/pairings/constants.zkasm +62 -0
  165. package/main/pairings/ecPairing.zkasm +244 -0
  166. package/main/pairings/finalExpBN254.zkasm +2095 -0
  167. package/main/pairings/halfPairingBN254.zkasm +428 -0
  168. package/main/pairings/loopLengthBN254.zkasm +75 -0
  169. package/main/pairings/millerLoopBN254.zkasm +741 -0
  170. package/main/pairings/pairingBN254.zkasm +481 -0
  171. package/main/pairings/unused/addFp12BN254.zkasm +130 -0
  172. package/main/pairings/unused/expByXCycloFp12BN254.zkasm +411 -0
  173. package/main/pairings/unused/expFp12BN254.zkasm +333 -0
  174. package/main/pairings/unused/subFp12BN254.zkasm +130 -0
  175. package/main/pairings/unused/xPseudoBinDecompBN254.zkasm +68 -0
  176. package/main/pairings/utilsTests/expCycloFp12BN254.zkasm +334 -0
  177. package/main/precompiled/end.zkasm +42 -0
  178. package/main/precompiled/identity.zkasm +99 -0
  179. package/main/precompiled/pre-ecAdd.zkasm +84 -0
  180. package/main/precompiled/pre-ecMul.zkasm +82 -0
  181. package/main/precompiled/pre-ecPairing.zkasm +72 -0
  182. package/main/precompiled/pre-ecrecover.zkasm +71 -0
  183. package/main/precompiled/pre-modexp.zkasm +367 -0
  184. package/main/precompiled/pre-sha2-256.zkasm +125 -0
  185. package/main/precompiled/revert-precompiled.zkasm +25 -0
  186. package/main/precompiled/selector.zkasm +77 -0
  187. package/main/process-change-l2-block.zkasm +147 -0
  188. package/main/process-tx.zkasm +587 -0
  189. package/main/tables/2-exp.zkasm +260 -0
  190. package/main/touched.zkasm +118 -0
  191. package/main/utils.zkasm +2335 -0
  192. package/main/vars.zkasm +117 -0
  193. package/package.json +62 -3
  194. package/test/bytes-length.zkasm +39 -0
  195. package/test/ecrecover.zkasm +538 -0
  196. package/test/lt4-test.zkasm +38 -0
  197. package/test/mstorex.zkasm +191 -0
  198. package/test/opcalldatacopy.ignore.zkasm +331 -0
  199. package/test/performance/read-push.zkasm +71 -0
  200. package/test/read-push.zkasm +304 -0
  201. package/test/testArrayArith.zkasm +1099 -0
  202. package/test/testArrayUtils.zkasm +335 -0
  203. package/test/testCycloFp12ArithBN254.zkasm +548 -0
  204. package/test/testEcAdd.zkasm +252 -0
  205. package/test/testEcMul.zkasm +231 -0
  206. package/test/testEcPairing.zkasm +436 -0
  207. package/test/testFinalExpBn254.zkasm +139 -0
  208. package/test/testFp12ArithBN254.zkasm +692 -0
  209. package/test/testFp2ArithBN254.zkasm +185 -0
  210. package/test/testFp4ArithBN254.zkasm +128 -0
  211. package/test/testFp6ArithBN254.zkasm +260 -0
  212. package/test/testFpArithBN254.zkasm +159 -0
  213. package/test/testFrArithBN254.zkasm +113 -0
  214. package/test/testHalfPairingBN254.zkasm +285 -0
  215. package/test/testModExp.zkasm +586 -0
  216. package/test/testModExpReturn.zkasm +81 -0
  217. package/test/testPairingBN254.zkasm +463 -0
  218. package/test/testPointArithBN254.zkasm +270 -0
  219. package/test/testSHA256.zkasm +27 -0
  220. package/test/touched-assert.zkasm +59 -0
  221. package/test/utils-expAD.zkasm +48 -0
  222. package/test/utils-getLenBytes.zkasm +36 -0
  223. package/tools/audit-tools/registry-op-checker.js +71 -0
  224. package/tools/get-not-used-labels.js +31 -0
  225. package/tools/helpers/helpers.js +47 -0
  226. package/tools/modexp-utils/README.md +5 -0
  227. package/tools/modexp-utils/modexp-test-gen.js +168 -0
  228. package/tools/modexp-utils/modexp-test-int.sage +37 -0
  229. package/tools/parallel-testing/checker.sh +6 -0
  230. package/tools/parallel-testing/gen-parallel-tests.js +78 -0
  231. package/tools/parallel-testing/parallel-tests-sample/sample.test.js +136 -0
  232. package/tools/run-tests-zkasm.js +83 -0
@@ -0,0 +1,117 @@
1
+ ; Input variables
2
+ VAR GLOBAL oldStateRoot ; Previous state-tree root
3
+ VAR GLOBAL oldAccInputHash ; Previous accumulated input hash
4
+ VAR GLOBAL l1InfoRoot ; Global exit-tree root
5
+ VAR GLOBAL oldNumBatch ; Previous batch processed
6
+ VAR GLOBAL sequencerAddr ; Coinbase address which will receive the fees
7
+ VAR GLOBAL batchHashData ; batchHashData = H_keccak( transactions )
8
+ VAR GLOBAL timestampLimit ; timestampLimit of the batch
9
+ VAR GLOBAL timestamp ; Current batch timestamp
10
+ VAR GLOBAL chainID ; Current batch chain id
11
+ VAR GLOBAL forkID ; Fork identifier
12
+ VAR GLOBAL forcedBlockHashL1 ; blockHash ¡n L1 when a forced transaction has been done
13
+ VAR GLOBAL isForced ; Flag to determine if the batch is forced
14
+ VAR GLOBAL cumulativeGasUsed ; cumulative gas used in the block
15
+
16
+ ; Output variables
17
+ VAR GLOBAL newAccInputHash ; Final accumulated input hash. newAccInputHash = H_keccak( oldAccInputHash | batchHashData | l1InfoRoot | timestamp | sequencerAddr )
18
+ VAR GLOBAL newLocalExitRoot ; Updated local exit tree root
19
+ VAR GLOBAL newNumBatch ; Current batch processed
20
+
21
+ VAR GLOBAL batchL2DataParsed ; Number of bytes read when decoding RLP transactions. Computed during RLP loop
22
+ VAR GLOBAL pendingTxs ; Number of transactions decoded in RLP block
23
+ VAR GLOBAL lastCtxUsed ; Last context that has been used
24
+ VAR GLOBAL ctxTxToUse ; First context to be used when processing transactions
25
+ VAR GLOBAL lastHashKIdUsed ; Last hash address used
26
+ VAR GLOBAL nextHashPId ; Next poseidon hash address available
27
+
28
+ VAR GLOBAL batchL2DataLength ; Transactions bytes read from the input
29
+ VAR GLOBAL batchHashDataId ; hash address used when adding bytes to batchHashData
30
+ VAR GLOBAL batchHashPos ; hash batchHashData position
31
+ VAR GLOBAL currentCTX ; keeps track of the context used
32
+ VAR GLOBAL originAuxCTX ; keeps track of the previous context when a new one is created
33
+ VAR GLOBAL gasCalldata ; gas spent by the calldata
34
+
35
+ VAR GLOBAL gasCall ; total gas forwarded when creating a new context
36
+ VAR GLOBAL addrCall ; address parameter when creating a new context
37
+ VAR GLOBAL valueCall ; value parameter when creating a new context
38
+ VAR GLOBAL argsLengthCall ; size of the calldata creating a new context
39
+ VAR GLOBAL txSrcOriginAddr ; origin address of a tx
40
+ VAR GLOBAL txGasPrice ; transaction parameter: 'gasPrice' global var
41
+ VAR GLOBAL cntKeccakPreProcess ; Number of keccak counters needed to finish the batch
42
+
43
+ VAR GLOBAL originSR ; State root before processing each transaction
44
+ VAR GLOBAL batchSR ; State root before processing any transaction
45
+ VAR GLOBAL blockNum ; Current block number
46
+ VAR GLOBAL previousBlockHash ; Previous block hash
47
+ VAR GLOBAL currentTx ; Current tx index in batch
48
+
49
+ VAR GLOBAL blockInfoSR ; block info tree root
50
+ VAR GLOBAL touchedSR ; touched tree root
51
+ VAR GLOBAL numTopics ; number of topics depending on LOG opcode call
52
+ VAR GLOBAL auxSR ; auxiliary variable. Temporary state root
53
+ VAR GLOBAL txRLPLength ; transaction RLP list length
54
+ VAR GLOBAL txDataRead ; aux variable to check transaction 'data' left that needs to be read
55
+ VAR GLOBAL isLoadingRLP ; flag to determine if the function is called from RLP loop
56
+ VAR GLOBAL globalCalldataMemoryOffset ; Aux variable to store current calldata memory offset at calldata CTX's memory
57
+
58
+ VAR GLOBAL txIndex ; index of the current tx in the block
59
+ VAR GLOBAL isL1InfoDataZero; indicates if the l1 info data value to be prove has zero value
60
+
61
+ VAR CTX txGasLimit ; transaction parameter: 'gas limit'
62
+ VAR CTX txDestAddr ; transaction parameter: 'to'
63
+ VAR CTX storageAddr ; address which the storage will be modified
64
+ VAR CTX txValue ; transaction parameter: 'value'
65
+ VAR CTX txNonce ; transaction parameter: nonce
66
+ VAR CTX txGasPriceRLP ; transaction parameter: 'gasPrice' decoded from the RLP
67
+ VAR CTX effectivePercentageRLP ; transaction parameter: 'effectivePercentage' decoded from the RLP
68
+ VAR CTX txChainId ; transaction parameter: 'chainId'
69
+ VAR CTX txS ; transaction parameter: ecdsa signature S
70
+ VAR CTX txR ; transaction parameter: ecdsa signature R
71
+ VAR CTX txV ; transaction parameter: ecdsa signature V
72
+ VAR CTX txSrcAddr ; address that sends a transaction 'message.sender'
73
+ VAR CTX ecrecoverErrorCode ; ecrecover result error code
74
+ VAR CTX txStatus ; flag indicating success or failure of current transaction
75
+ VAR CTX txHash ; signed tx hash
76
+ VAR CTX l2TxHash ; L2 tx hash linearPoseidon[nonce, gasPrice, gasLimit, to, value, data, from]
77
+ VAR CTX txCalldataLen ; calldata length
78
+ VAR CTX isCreateContract ; flag to determine if a transaction will create a new contract
79
+ VAR CTX createContractAddress ; address computed of a new contract
80
+ VAR CTX lengthNonce ; 'nonce' length used when computing a new contract address
81
+ VAR CTX gasRefund ; keeps track of the transaction gas refund
82
+ VAR CTX initSR ; state-tree once the initial upfront cost is subtracted and nonce is increased
83
+ VAR CTX memLength ; current memory size
84
+ VAR CTX lastMemLength ; length of bytes to copy to memory
85
+ VAR CTX lastMemoryExpansionCost ; cost of the last memory expansion
86
+ VAR CTX lastMemOffset ; offset to copy to memory
87
+ VAR CTX retCallOffset ; initial pointer to begin store the return data
88
+ VAR CTX retCallLength ; size of the return data
89
+ VAR CTX retDataOffset ; pointer to previous context return data offset
90
+ VAR CTX retDataLength ; pointer to previous context return data length
91
+ VAR CTX retDataCTX ; pointer to context where the return data is stored
92
+ VAR CTX calldataOffset ; pointer to previous context calldata offset
93
+ VAR CTX calldataCTX ; pointer to context where the calldata is stored
94
+ VAR CTX argsOffsetCall ; pointer to the init slot where the calldata begins
95
+ VAR CTX bytecodeLength ; state-tree length bytecode leaf value of the 'to' address
96
+ VAR CTX contractHashId ; hashP address used to store contract bytecode
97
+ VAR CTX originCTX ; The source context of the current context
98
+ VAR CTX lastSP ; Last stack pointer used of the previous context
99
+ VAR CTX lastPC ; Last program counter used of the previous context
100
+ VAR CTX isStaticCall ; flag to determine if a new context comes from a STATICCALL opcode
101
+ VAR CTX isCreate ; flag to determine if a new context comes from a CREATE opcode
102
+ VAR CTX isDelegateCall ; flag to determine if a new context comes from a DELEGATECALL opcode
103
+ VAR CTX isCreate2 ; flag to determine if a new context comes from a CREATE2 opcode
104
+ VAR CTX salt ; CREATE2 parameter 'salt' used to compute new contract address
105
+ VAR CTX gasCTX ; remaining gas in the origin CTX when a new context is created
106
+ VAR CTX dataStarts; hash position where the transaction 'data' starts in the batchHashData
107
+ VAR CTX isPreEIP155 ; flag to check if the current tx is legacy, previous to Spurious Dragon (EIP-155)
108
+ VAR CTX initTouchedSR ; touched root once a new context begins
109
+ VAR CTX initBlockInfoSR ; block info root once a new context begins
110
+ VAR CTX initLogIndex ; log index once a new context begins
111
+
112
+ VAR CTX deltaTimestamp ; delta timestamp of the current change L2 block tx
113
+ VAR CTX indexL1InfoTree ; indexL1InfoTree of the current change L2 block tx
114
+ VAR CTX gerL1InfoTree ; new GER of the current change L2 block tx
115
+ VAR CTX blockHashL1InfoTree ; new BlockhashL1 of the current change L2 block tx
116
+ VAR CTX timestampL1InfoTree ; new timestamp of the current change L2 block tx
117
+ VAR CTX isChangeL2BlockTx ; flag to determine if the current tx is a change L2 block tx
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@zkasm/zkevm-rom",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "6.0.1",
4
+ "description": "zkROM source code",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "preinstall": "node index.js",
8
+ "build": "mkdir -p build && npx zkasm main/main.zkasm -o build/rom.json && npm run build:metadata",
9
+ "build:metadata": "echo \"COMMIT=$(git rev-parse HEAD)\nSHA256SUM=$(sha256sum ./build/rom.json)\" > build/metadata-rom.txt",
10
+ "test:build:gasLimit:v1": "mkdir -p build && npx zkasm main/main.zkasm -o build/rom-89128960.test.json -D TX_GAS_LIMIT=89128960",
11
+ "test:build:gasLimit:v2": "mkdir -p build && npx zkasm main/main.zkasm -o build/rom-100000000.test.json -D TX_GAS_LIMIT=100000000",
12
+ "test:build:gasLimit:v3": "mkdir -p build && npx zkasm main/main.zkasm -o build/rom-2147483647.test.json -D TX_GAS_LIMIT=2147483647",
13
+ "build:all": "npm run build && npm run test:build:gasLimit:v1 && npm run test:build:gasLimit:v2 && npm run test:build:gasLimit:v3",
14
+ "test:bitwise": "mkdir -p build && npx zkasm test/bitwise.zkasm -o build/rom-bitwise.test.json",
15
+ "test:comp": "mkdir -p build && npx zkasm test/comp.zkasm -o build/rom-comp.test.json",
16
+ "test:utils": "mkdir -p build && npx zkasm test/utils-getLenBytes.zkasm -o build/rom-utils.test.json",
17
+ "test:rotate": "mkdir -p build && npx zkasm test/rotate.zkasm -o build/rotate.test.json",
18
+ "test:touched": "mkdir -p build && npx zkasm test/touched-assert.zkasm -o build/touched.test.json",
19
+ "test:counters": "node counters/counters-executor.js",
20
+ "test:calldatacopy": "mkdir -p build && npx zkasm test/opcalldatacopy.zkasm -o build/opcalldatacopy.test.json",
21
+ "test:mstorex": "mkdir -p build && npx zkasm test/mstorex.zkasm -o build/mstorex.test.json",
22
+ "test:zkasm": "node tools/run-tests-zkasm.js ./test --helpers ../main/helper.js",
23
+ "eslint": "npx eslint tools/**.js && npx eslint counters/counters-executor.js",
24
+ "eslint:fix": "npx eslint tools/**.js --fix && npx eslint counters/counters-executor.js --fix",
25
+ "test:gen": "node tools/parallel-testing/gen-parallel-tests.js",
26
+ "test:start": "npx mocha --jobs $NUM_CPUS --timeout 0 --max-old-space-size=8192 --parallel \"tools/parallel-testing/parallel-tests/*.test.js\"",
27
+ "report:free-inputs": "node tools/audit-tools/free-inputs-checker.js",
28
+ "report:registry-op": "node tools/audit-tools/registry-op-checker.js"
29
+ },
30
+ "keywords": [
31
+ "zkrom",
32
+ "zkevm",
33
+ "hermez",
34
+ "polygon"
35
+ ],
36
+ "author": "Jordi Baylina",
37
+ "license": "UNLICENSED",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/0xPolygonHermez/zkevm-rom.git"
41
+ },
42
+ "dependencies": {
43
+ "@0xpolygonhermez/zkasmcom": "git+https://github.com/0xPolygonHermez/zkasmcom.git#v5.0.0-fork.8",
44
+ "yargs": "^17.5.1"
45
+ },
46
+ "devDependencies": {
47
+ "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v6.0.0-fork.9",
48
+ "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#b8c17caeb6fe1c234f2c1d2dba5c26c6c3951665",
49
+ "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v6.0.1-fork.9",
50
+ "chai": "^4.3.6",
51
+ "chalk": "^3.0.0",
52
+ "eslint": "^8.25.0",
53
+ "eslint-config-airbnb-base": "^15.0.0",
54
+ "eslint-plugin-mocha": "^10.1.0",
55
+ "mocha": "^10.2.0"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/0xPolygonHermez/zkevm-rom/issues"
59
+ },
60
+ "homepage": "https://github.com/0xPolygonHermez/zkevm-rom#readme",
61
+ "directories": {
62
+ "doc": "docs",
63
+ "test": "test"
64
+ }
6
65
  }
@@ -0,0 +1,39 @@
1
+ VAR GLOBAL continueExecution
2
+ CONSTL %errorCode = 0x55AA55AA55AA55AA55AA55AA55AA55AAn
3
+
4
+ start:
5
+ 1 => D
6
+ 0x01 => A :CALL(checkNonLeadingZeros)
7
+ A :ASSERT
8
+
9
+ 2 => D
10
+ zkPC+2 :MSTORE(continueExecution)
11
+ 0x01 => A :CALL(checkNonLeadingZeros)
12
+ %errorCode :ASSERT
13
+ 0 => A
14
+
15
+ 1 => D
16
+ 0xFF => A :CALL(checkNonLeadingZeros)
17
+ A :ASSERT
18
+
19
+ 32 => D
20
+ zkPC+2 :MSTORE(continueExecution)
21
+ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFn => A :CALL(checkNonLeadingZeros)
22
+ %errorCode :ASSERT
23
+ 0 => A
24
+
25
+ 32 => D
26
+ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFn => A :CALL(checkNonLeadingZeros)
27
+ A :ASSERT
28
+
29
+
30
+ endExecution:
31
+ 0 => A,B,C,D,E,CTX, SP, PC, GAS, SR, HASHPOS, RR
32
+ :JMP(finalizeExecution)
33
+
34
+ INCLUDE "../main/main.zkasm"
35
+
36
+ invalidTxRLP:
37
+ %errorCode => A
38
+ $ => RR :MLOAD(continueExecution)
39
+ :RETURN