@feelyourprotocol/evm 8141.0.0

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.
Files changed (565) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +690 -0
  3. package/dist/cjs/binaryTreeAccessWitness.d.ts +61 -0
  4. package/dist/cjs/binaryTreeAccessWitness.d.ts.map +1 -0
  5. package/dist/cjs/binaryTreeAccessWitness.js +314 -0
  6. package/dist/cjs/binaryTreeAccessWitness.js.map +1 -0
  7. package/dist/cjs/chunkCache.d.ts +13 -0
  8. package/dist/cjs/chunkCache.d.ts.map +1 -0
  9. package/dist/cjs/chunkCache.js +30 -0
  10. package/dist/cjs/chunkCache.js.map +1 -0
  11. package/dist/cjs/constructors.d.ts +11 -0
  12. package/dist/cjs/constructors.d.ts.map +1 -0
  13. package/dist/cjs/constructors.js +30 -0
  14. package/dist/cjs/constructors.js.map +1 -0
  15. package/dist/cjs/eip7708.d.ts +24 -0
  16. package/dist/cjs/eip7708.d.ts.map +1 -0
  17. package/dist/cjs/eip7708.js +37 -0
  18. package/dist/cjs/eip7708.js.map +1 -0
  19. package/dist/cjs/eof/constants.d.ts +22 -0
  20. package/dist/cjs/eof/constants.d.ts.map +1 -0
  21. package/dist/cjs/eof/constants.js +31 -0
  22. package/dist/cjs/eof/constants.js.map +1 -0
  23. package/dist/cjs/eof/container.d.ts +87 -0
  24. package/dist/cjs/eof/container.d.ts.map +1 -0
  25. package/dist/cjs/eof/container.js +380 -0
  26. package/dist/cjs/eof/container.js.map +1 -0
  27. package/dist/cjs/eof/errors.d.ts +66 -0
  28. package/dist/cjs/eof/errors.d.ts.map +1 -0
  29. package/dist/cjs/eof/errors.js +200 -0
  30. package/dist/cjs/eof/errors.js.map +1 -0
  31. package/dist/cjs/eof/setup.d.ts +9 -0
  32. package/dist/cjs/eof/setup.d.ts.map +1 -0
  33. package/dist/cjs/eof/setup.js +26 -0
  34. package/dist/cjs/eof/setup.js.map +1 -0
  35. package/dist/cjs/eof/stackDelta.d.ts +10 -0
  36. package/dist/cjs/eof/stackDelta.d.ts.map +1 -0
  37. package/dist/cjs/eof/stackDelta.js +164 -0
  38. package/dist/cjs/eof/stackDelta.js.map +1 -0
  39. package/dist/cjs/eof/util.d.ts +8 -0
  40. package/dist/cjs/eof/util.d.ts.map +1 -0
  41. package/dist/cjs/eof/util.js +18 -0
  42. package/dist/cjs/eof/util.js.map +1 -0
  43. package/dist/cjs/eof/verify.d.ts +38 -0
  44. package/dist/cjs/eof/verify.d.ts.map +1 -0
  45. package/dist/cjs/eof/verify.js +436 -0
  46. package/dist/cjs/eof/verify.js.map +1 -0
  47. package/dist/cjs/errors.d.ts +40 -0
  48. package/dist/cjs/errors.d.ts.map +1 -0
  49. package/dist/cjs/errors.js +43 -0
  50. package/dist/cjs/errors.js.map +1 -0
  51. package/dist/cjs/evm.d.ts +181 -0
  52. package/dist/cjs/evm.d.ts.map +1 -0
  53. package/dist/cjs/evm.js +1142 -0
  54. package/dist/cjs/evm.js.map +1 -0
  55. package/dist/cjs/frameContext.d.ts +50 -0
  56. package/dist/cjs/frameContext.d.ts.map +1 -0
  57. package/dist/cjs/frameContext.js +17 -0
  58. package/dist/cjs/frameContext.js.map +1 -0
  59. package/dist/cjs/index.d.ts +18 -0
  60. package/dist/cjs/index.d.ts.map +1 -0
  61. package/dist/cjs/index.js +43 -0
  62. package/dist/cjs/index.js.map +1 -0
  63. package/dist/cjs/interpreter.d.ts +361 -0
  64. package/dist/cjs/interpreter.d.ts.map +1 -0
  65. package/dist/cjs/interpreter.js +1057 -0
  66. package/dist/cjs/interpreter.js.map +1 -0
  67. package/dist/cjs/journal.d.ts +69 -0
  68. package/dist/cjs/journal.d.ts.map +1 -0
  69. package/dist/cjs/journal.js +247 -0
  70. package/dist/cjs/journal.js.map +1 -0
  71. package/dist/cjs/logger.d.ts +38 -0
  72. package/dist/cjs/logger.d.ts.map +1 -0
  73. package/dist/cjs/logger.js +126 -0
  74. package/dist/cjs/logger.js.map +1 -0
  75. package/dist/cjs/memory.d.ts +29 -0
  76. package/dist/cjs/memory.d.ts.map +1 -0
  77. package/dist/cjs/memory.js +75 -0
  78. package/dist/cjs/memory.js.map +1 -0
  79. package/dist/cjs/message.d.ts +70 -0
  80. package/dist/cjs/message.d.ts.map +1 -0
  81. package/dist/cjs/message.js +51 -0
  82. package/dist/cjs/message.js.map +1 -0
  83. package/dist/cjs/opcodes/EIP1283.d.ts +13 -0
  84. package/dist/cjs/opcodes/EIP1283.d.ts.map +1 -0
  85. package/dist/cjs/opcodes/EIP1283.js +58 -0
  86. package/dist/cjs/opcodes/EIP1283.js.map +1 -0
  87. package/dist/cjs/opcodes/EIP2200.d.ts +13 -0
  88. package/dist/cjs/opcodes/EIP2200.d.ts.map +1 -0
  89. package/dist/cjs/opcodes/EIP2200.js +64 -0
  90. package/dist/cjs/opcodes/EIP2200.js.map +1 -0
  91. package/dist/cjs/opcodes/EIP2929.d.ts +68 -0
  92. package/dist/cjs/opcodes/EIP2929.d.ts.map +1 -0
  93. package/dist/cjs/opcodes/EIP2929.js +146 -0
  94. package/dist/cjs/opcodes/EIP2929.js.map +1 -0
  95. package/dist/cjs/opcodes/codes.d.ts +45 -0
  96. package/dist/cjs/opcodes/codes.d.ts.map +1 -0
  97. package/dist/cjs/opcodes/codes.js +453 -0
  98. package/dist/cjs/opcodes/codes.js.map +1 -0
  99. package/dist/cjs/opcodes/functions.d.ts +11 -0
  100. package/dist/cjs/opcodes/functions.d.ts.map +1 -0
  101. package/dist/cjs/opcodes/functions.js +1778 -0
  102. package/dist/cjs/opcodes/functions.js.map +1 -0
  103. package/dist/cjs/opcodes/gas.d.ts +15 -0
  104. package/dist/cjs/opcodes/gas.d.ts.map +1 -0
  105. package/dist/cjs/opcodes/gas.js +1016 -0
  106. package/dist/cjs/opcodes/gas.js.map +1 -0
  107. package/dist/cjs/opcodes/index.d.ts +4 -0
  108. package/dist/cjs/opcodes/index.d.ts.map +1 -0
  109. package/dist/cjs/opcodes/index.js +20 -0
  110. package/dist/cjs/opcodes/index.js.map +1 -0
  111. package/dist/cjs/opcodes/util.d.ts +86 -0
  112. package/dist/cjs/opcodes/util.d.ts.map +1 -0
  113. package/dist/cjs/opcodes/util.js +281 -0
  114. package/dist/cjs/opcodes/util.js.map +1 -0
  115. package/dist/cjs/package.json +3 -0
  116. package/dist/cjs/params.d.ts +3 -0
  117. package/dist/cjs/params.d.ts.map +1 -0
  118. package/dist/cjs/params.js +424 -0
  119. package/dist/cjs/params.js.map +1 -0
  120. package/dist/cjs/precompiles/01-ecrecover.d.ts +4 -0
  121. package/dist/cjs/precompiles/01-ecrecover.d.ts.map +1 -0
  122. package/dist/cjs/precompiles/01-ecrecover.js +58 -0
  123. package/dist/cjs/precompiles/01-ecrecover.js.map +1 -0
  124. package/dist/cjs/precompiles/02-sha256.d.ts +4 -0
  125. package/dist/cjs/precompiles/02-sha256.d.ts.map +1 -0
  126. package/dist/cjs/precompiles/02-sha256.js +27 -0
  127. package/dist/cjs/precompiles/02-sha256.js.map +1 -0
  128. package/dist/cjs/precompiles/03-ripemd160.d.ts +4 -0
  129. package/dist/cjs/precompiles/03-ripemd160.d.ts.map +1 -0
  130. package/dist/cjs/precompiles/03-ripemd160.js +26 -0
  131. package/dist/cjs/precompiles/03-ripemd160.js.map +1 -0
  132. package/dist/cjs/precompiles/04-identity.d.ts +4 -0
  133. package/dist/cjs/precompiles/04-identity.d.ts.map +1 -0
  134. package/dist/cjs/precompiles/04-identity.js +24 -0
  135. package/dist/cjs/precompiles/04-identity.js.map +1 -0
  136. package/dist/cjs/precompiles/05-modexp.d.ts +5 -0
  137. package/dist/cjs/precompiles/05-modexp.d.ts.map +1 -0
  138. package/dist/cjs/precompiles/05-modexp.js +185 -0
  139. package/dist/cjs/precompiles/05-modexp.js.map +1 -0
  140. package/dist/cjs/precompiles/06-bn254-add.d.ts +4 -0
  141. package/dist/cjs/precompiles/06-bn254-add.d.ts.map +1 -0
  142. package/dist/cjs/precompiles/06-bn254-add.js +42 -0
  143. package/dist/cjs/precompiles/06-bn254-add.js.map +1 -0
  144. package/dist/cjs/precompiles/07-bn254-mul.d.ts +4 -0
  145. package/dist/cjs/precompiles/07-bn254-mul.d.ts.map +1 -0
  146. package/dist/cjs/precompiles/07-bn254-mul.js +43 -0
  147. package/dist/cjs/precompiles/07-bn254-mul.js.map +1 -0
  148. package/dist/cjs/precompiles/08-bn254-pairing.d.ts +4 -0
  149. package/dist/cjs/precompiles/08-bn254-pairing.d.ts.map +1 -0
  150. package/dist/cjs/precompiles/08-bn254-pairing.js +45 -0
  151. package/dist/cjs/precompiles/08-bn254-pairing.js.map +1 -0
  152. package/dist/cjs/precompiles/09-blake2f.d.ts +5 -0
  153. package/dist/cjs/precompiles/09-blake2f.d.ts.map +1 -0
  154. package/dist/cjs/precompiles/09-blake2f.js +201 -0
  155. package/dist/cjs/precompiles/09-blake2f.js.map +1 -0
  156. package/dist/cjs/precompiles/0a-kzg-point-evaluation.d.ts +5 -0
  157. package/dist/cjs/precompiles/0a-kzg-point-evaluation.d.ts.map +1 -0
  158. package/dist/cjs/precompiles/0a-kzg-point-evaluation.js +68 -0
  159. package/dist/cjs/precompiles/0a-kzg-point-evaluation.js.map +1 -0
  160. package/dist/cjs/precompiles/0b-bls12-g1add.d.ts +4 -0
  161. package/dist/cjs/precompiles/0b-bls12-g1add.d.ts.map +1 -0
  162. package/dist/cjs/precompiles/0b-bls12-g1add.js +49 -0
  163. package/dist/cjs/precompiles/0b-bls12-g1add.js.map +1 -0
  164. package/dist/cjs/precompiles/0c-bls12-g1msm.d.ts +4 -0
  165. package/dist/cjs/precompiles/0c-bls12-g1msm.d.ts.map +1 -0
  166. package/dist/cjs/precompiles/0c-bls12-g1msm.js +62 -0
  167. package/dist/cjs/precompiles/0c-bls12-g1msm.js.map +1 -0
  168. package/dist/cjs/precompiles/0d-bls12-g2add.d.ts +4 -0
  169. package/dist/cjs/precompiles/0d-bls12-g2add.d.ts.map +1 -0
  170. package/dist/cjs/precompiles/0d-bls12-g2add.js +51 -0
  171. package/dist/cjs/precompiles/0d-bls12-g2add.js.map +1 -0
  172. package/dist/cjs/precompiles/0e-bls12-g2msm.d.ts +4 -0
  173. package/dist/cjs/precompiles/0e-bls12-g2msm.d.ts.map +1 -0
  174. package/dist/cjs/precompiles/0e-bls12-g2msm.js +60 -0
  175. package/dist/cjs/precompiles/0e-bls12-g2msm.js.map +1 -0
  176. package/dist/cjs/precompiles/0f-bls12-pairing.d.ts +4 -0
  177. package/dist/cjs/precompiles/0f-bls12-pairing.d.ts.map +1 -0
  178. package/dist/cjs/precompiles/0f-bls12-pairing.js +66 -0
  179. package/dist/cjs/precompiles/0f-bls12-pairing.js.map +1 -0
  180. package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.d.ts +4 -0
  181. package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.d.ts.map +1 -0
  182. package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.js +44 -0
  183. package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.js.map +1 -0
  184. package/dist/cjs/precompiles/100-p256verify.d.ts +4 -0
  185. package/dist/cjs/precompiles/100-p256verify.d.ts.map +1 -0
  186. package/dist/cjs/precompiles/100-p256verify.js +131 -0
  187. package/dist/cjs/precompiles/100-p256verify.js.map +1 -0
  188. package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.d.ts +4 -0
  189. package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.d.ts.map +1 -0
  190. package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.js +47 -0
  191. package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.js.map +1 -0
  192. package/dist/cjs/precompiles/bls12_381/constants.d.ts +10 -0
  193. package/dist/cjs/precompiles/bls12_381/constants.d.ts.map +1 -0
  194. package/dist/cjs/precompiles/bls12_381/constants.js +274 -0
  195. package/dist/cjs/precompiles/bls12_381/constants.js.map +1 -0
  196. package/dist/cjs/precompiles/bls12_381/index.d.ts +5 -0
  197. package/dist/cjs/precompiles/bls12_381/index.d.ts.map +1 -0
  198. package/dist/cjs/precompiles/bls12_381/index.js +24 -0
  199. package/dist/cjs/precompiles/bls12_381/index.js.map +1 -0
  200. package/dist/cjs/precompiles/bls12_381/mcl.d.ts +45 -0
  201. package/dist/cjs/precompiles/bls12_381/mcl.d.ts.map +1 -0
  202. package/dist/cjs/precompiles/bls12_381/mcl.js +264 -0
  203. package/dist/cjs/precompiles/bls12_381/mcl.js.map +1 -0
  204. package/dist/cjs/precompiles/bls12_381/noble.d.ts +39 -0
  205. package/dist/cjs/precompiles/bls12_381/noble.d.ts.map +1 -0
  206. package/dist/cjs/precompiles/bls12_381/noble.js +228 -0
  207. package/dist/cjs/precompiles/bls12_381/noble.js.map +1 -0
  208. package/dist/cjs/precompiles/bls12_381/util.d.ts +35 -0
  209. package/dist/cjs/precompiles/bls12_381/util.d.ts.map +1 -0
  210. package/dist/cjs/precompiles/bls12_381/util.js +68 -0
  211. package/dist/cjs/precompiles/bls12_381/util.js.map +1 -0
  212. package/dist/cjs/precompiles/bn254/index.d.ts +3 -0
  213. package/dist/cjs/precompiles/bn254/index.d.ts.map +1 -0
  214. package/dist/cjs/precompiles/bn254/index.js +8 -0
  215. package/dist/cjs/precompiles/bn254/index.js.map +1 -0
  216. package/dist/cjs/precompiles/bn254/noble.d.ts +13 -0
  217. package/dist/cjs/precompiles/bn254/noble.d.ts.map +1 -0
  218. package/dist/cjs/precompiles/bn254/noble.js +124 -0
  219. package/dist/cjs/precompiles/bn254/noble.js.map +1 -0
  220. package/dist/cjs/precompiles/bn254/rustbn.d.ts +16 -0
  221. package/dist/cjs/precompiles/bn254/rustbn.d.ts.map +1 -0
  222. package/dist/cjs/precompiles/bn254/rustbn.js +33 -0
  223. package/dist/cjs/precompiles/bn254/rustbn.js.map +1 -0
  224. package/dist/cjs/precompiles/index.d.ts +67 -0
  225. package/dist/cjs/precompiles/index.d.ts.map +1 -0
  226. package/dist/cjs/precompiles/index.js +262 -0
  227. package/dist/cjs/precompiles/index.js.map +1 -0
  228. package/dist/cjs/precompiles/types.d.ts +13 -0
  229. package/dist/cjs/precompiles/types.d.ts.map +1 -0
  230. package/dist/cjs/precompiles/types.js +3 -0
  231. package/dist/cjs/precompiles/types.js.map +1 -0
  232. package/dist/cjs/precompiles/util.d.ts +30 -0
  233. package/dist/cjs/precompiles/util.d.ts.map +1 -0
  234. package/dist/cjs/precompiles/util.js +63 -0
  235. package/dist/cjs/precompiles/util.js.map +1 -0
  236. package/dist/cjs/stack.d.ts +55 -0
  237. package/dist/cjs/stack.d.ts.map +1 -0
  238. package/dist/cjs/stack.js +143 -0
  239. package/dist/cjs/stack.js.map +1 -0
  240. package/dist/cjs/stemCache.d.ts +20 -0
  241. package/dist/cjs/stemCache.d.ts.map +1 -0
  242. package/dist/cjs/stemCache.js +37 -0
  243. package/dist/cjs/stemCache.js.map +1 -0
  244. package/dist/cjs/transientStorage.d.ts +54 -0
  245. package/dist/cjs/transientStorage.d.ts.map +1 -0
  246. package/dist/cjs/transientStorage.js +113 -0
  247. package/dist/cjs/transientStorage.js.map +1 -0
  248. package/dist/cjs/types.d.ts +465 -0
  249. package/dist/cjs/types.d.ts.map +1 -0
  250. package/dist/cjs/types.js +28 -0
  251. package/dist/cjs/types.js.map +1 -0
  252. package/dist/esm/binaryTreeAccessWitness.d.ts +61 -0
  253. package/dist/esm/binaryTreeAccessWitness.d.ts.map +1 -0
  254. package/dist/esm/binaryTreeAccessWitness.js +308 -0
  255. package/dist/esm/binaryTreeAccessWitness.js.map +1 -0
  256. package/dist/esm/chunkCache.d.ts +13 -0
  257. package/dist/esm/chunkCache.d.ts.map +1 -0
  258. package/dist/esm/chunkCache.js +26 -0
  259. package/dist/esm/chunkCache.js.map +1 -0
  260. package/dist/esm/constructors.d.ts +11 -0
  261. package/dist/esm/constructors.d.ts.map +1 -0
  262. package/dist/esm/constructors.js +27 -0
  263. package/dist/esm/constructors.js.map +1 -0
  264. package/dist/esm/eip7708.d.ts +24 -0
  265. package/dist/esm/eip7708.d.ts.map +1 -0
  266. package/dist/esm/eip7708.js +32 -0
  267. package/dist/esm/eip7708.js.map +1 -0
  268. package/dist/esm/eof/constants.d.ts +22 -0
  269. package/dist/esm/eof/constants.d.ts.map +1 -0
  270. package/dist/esm/eof/constants.js +28 -0
  271. package/dist/esm/eof/constants.js.map +1 -0
  272. package/dist/esm/eof/container.d.ts +87 -0
  273. package/dist/esm/eof/container.d.ts.map +1 -0
  274. package/dist/esm/eof/container.js +375 -0
  275. package/dist/esm/eof/container.js.map +1 -0
  276. package/dist/esm/eof/errors.d.ts +66 -0
  277. package/dist/esm/eof/errors.d.ts.map +1 -0
  278. package/dist/esm/eof/errors.js +195 -0
  279. package/dist/esm/eof/errors.js.map +1 -0
  280. package/dist/esm/eof/setup.d.ts +9 -0
  281. package/dist/esm/eof/setup.d.ts.map +1 -0
  282. package/dist/esm/eof/setup.js +23 -0
  283. package/dist/esm/eof/setup.js.map +1 -0
  284. package/dist/esm/eof/stackDelta.d.ts +10 -0
  285. package/dist/esm/eof/stackDelta.d.ts.map +1 -0
  286. package/dist/esm/eof/stackDelta.js +161 -0
  287. package/dist/esm/eof/stackDelta.js.map +1 -0
  288. package/dist/esm/eof/util.d.ts +8 -0
  289. package/dist/esm/eof/util.d.ts.map +1 -0
  290. package/dist/esm/eof/util.js +14 -0
  291. package/dist/esm/eof/util.js.map +1 -0
  292. package/dist/esm/eof/verify.d.ts +38 -0
  293. package/dist/esm/eof/verify.d.ts.map +1 -0
  294. package/dist/esm/eof/verify.js +432 -0
  295. package/dist/esm/eof/verify.js.map +1 -0
  296. package/dist/esm/errors.d.ts +40 -0
  297. package/dist/esm/errors.d.ts.map +1 -0
  298. package/dist/esm/errors.js +39 -0
  299. package/dist/esm/errors.js.map +1 -0
  300. package/dist/esm/evm.d.ts +181 -0
  301. package/dist/esm/evm.d.ts.map +1 -0
  302. package/dist/esm/evm.js +1131 -0
  303. package/dist/esm/evm.js.map +1 -0
  304. package/dist/esm/frameContext.d.ts +50 -0
  305. package/dist/esm/frameContext.d.ts.map +1 -0
  306. package/dist/esm/frameContext.js +14 -0
  307. package/dist/esm/frameContext.js.map +1 -0
  308. package/dist/esm/index.d.ts +18 -0
  309. package/dist/esm/index.d.ts.map +1 -0
  310. package/dist/esm/index.js +15 -0
  311. package/dist/esm/index.js.map +1 -0
  312. package/dist/esm/interpreter.d.ts +361 -0
  313. package/dist/esm/interpreter.d.ts.map +1 -0
  314. package/dist/esm/interpreter.js +1054 -0
  315. package/dist/esm/interpreter.js.map +1 -0
  316. package/dist/esm/journal.d.ts +69 -0
  317. package/dist/esm/journal.d.ts.map +1 -0
  318. package/dist/esm/journal.js +243 -0
  319. package/dist/esm/journal.js.map +1 -0
  320. package/dist/esm/logger.d.ts +38 -0
  321. package/dist/esm/logger.d.ts.map +1 -0
  322. package/dist/esm/logger.js +121 -0
  323. package/dist/esm/logger.js.map +1 -0
  324. package/dist/esm/memory.d.ts +29 -0
  325. package/dist/esm/memory.d.ts.map +1 -0
  326. package/dist/esm/memory.js +71 -0
  327. package/dist/esm/memory.js.map +1 -0
  328. package/dist/esm/message.d.ts +70 -0
  329. package/dist/esm/message.d.ts.map +1 -0
  330. package/dist/esm/message.js +47 -0
  331. package/dist/esm/message.js.map +1 -0
  332. package/dist/esm/opcodes/EIP1283.d.ts +13 -0
  333. package/dist/esm/opcodes/EIP1283.d.ts.map +1 -0
  334. package/dist/esm/opcodes/EIP1283.js +55 -0
  335. package/dist/esm/opcodes/EIP1283.js.map +1 -0
  336. package/dist/esm/opcodes/EIP2200.d.ts +13 -0
  337. package/dist/esm/opcodes/EIP2200.d.ts.map +1 -0
  338. package/dist/esm/opcodes/EIP2200.js +61 -0
  339. package/dist/esm/opcodes/EIP2200.js.map +1 -0
  340. package/dist/esm/opcodes/EIP2929.d.ts +68 -0
  341. package/dist/esm/opcodes/EIP2929.d.ts.map +1 -0
  342. package/dist/esm/opcodes/EIP2929.js +138 -0
  343. package/dist/esm/opcodes/EIP2929.js.map +1 -0
  344. package/dist/esm/opcodes/codes.d.ts +45 -0
  345. package/dist/esm/opcodes/codes.d.ts.map +1 -0
  346. package/dist/esm/opcodes/codes.js +448 -0
  347. package/dist/esm/opcodes/codes.js.map +1 -0
  348. package/dist/esm/opcodes/functions.d.ts +11 -0
  349. package/dist/esm/opcodes/functions.d.ts.map +1 -0
  350. package/dist/esm/opcodes/functions.js +1775 -0
  351. package/dist/esm/opcodes/functions.js.map +1 -0
  352. package/dist/esm/opcodes/gas.d.ts +15 -0
  353. package/dist/esm/opcodes/gas.d.ts.map +1 -0
  354. package/dist/esm/opcodes/gas.js +1013 -0
  355. package/dist/esm/opcodes/gas.js.map +1 -0
  356. package/dist/esm/opcodes/index.d.ts +4 -0
  357. package/dist/esm/opcodes/index.d.ts.map +1 -0
  358. package/dist/esm/opcodes/index.js +4 -0
  359. package/dist/esm/opcodes/index.js.map +1 -0
  360. package/dist/esm/opcodes/util.d.ts +86 -0
  361. package/dist/esm/opcodes/util.d.ts.map +1 -0
  362. package/dist/esm/opcodes/util.js +257 -0
  363. package/dist/esm/opcodes/util.js.map +1 -0
  364. package/dist/esm/package.json +3 -0
  365. package/dist/esm/params.d.ts +3 -0
  366. package/dist/esm/params.d.ts.map +1 -0
  367. package/dist/esm/params.js +421 -0
  368. package/dist/esm/params.js.map +1 -0
  369. package/dist/esm/precompiles/01-ecrecover.d.ts +4 -0
  370. package/dist/esm/precompiles/01-ecrecover.d.ts.map +1 -0
  371. package/dist/esm/precompiles/01-ecrecover.js +55 -0
  372. package/dist/esm/precompiles/01-ecrecover.js.map +1 -0
  373. package/dist/esm/precompiles/02-sha256.d.ts +4 -0
  374. package/dist/esm/precompiles/02-sha256.d.ts.map +1 -0
  375. package/dist/esm/precompiles/02-sha256.js +24 -0
  376. package/dist/esm/precompiles/02-sha256.js.map +1 -0
  377. package/dist/esm/precompiles/03-ripemd160.d.ts +4 -0
  378. package/dist/esm/precompiles/03-ripemd160.d.ts.map +1 -0
  379. package/dist/esm/precompiles/03-ripemd160.js +23 -0
  380. package/dist/esm/precompiles/03-ripemd160.js.map +1 -0
  381. package/dist/esm/precompiles/04-identity.d.ts +4 -0
  382. package/dist/esm/precompiles/04-identity.d.ts.map +1 -0
  383. package/dist/esm/precompiles/04-identity.js +21 -0
  384. package/dist/esm/precompiles/04-identity.js.map +1 -0
  385. package/dist/esm/precompiles/05-modexp.d.ts +5 -0
  386. package/dist/esm/precompiles/05-modexp.d.ts.map +1 -0
  387. package/dist/esm/precompiles/05-modexp.js +181 -0
  388. package/dist/esm/precompiles/05-modexp.js.map +1 -0
  389. package/dist/esm/precompiles/06-bn254-add.d.ts +4 -0
  390. package/dist/esm/precompiles/06-bn254-add.d.ts.map +1 -0
  391. package/dist/esm/precompiles/06-bn254-add.js +39 -0
  392. package/dist/esm/precompiles/06-bn254-add.js.map +1 -0
  393. package/dist/esm/precompiles/07-bn254-mul.d.ts +4 -0
  394. package/dist/esm/precompiles/07-bn254-mul.d.ts.map +1 -0
  395. package/dist/esm/precompiles/07-bn254-mul.js +40 -0
  396. package/dist/esm/precompiles/07-bn254-mul.js.map +1 -0
  397. package/dist/esm/precompiles/08-bn254-pairing.d.ts +4 -0
  398. package/dist/esm/precompiles/08-bn254-pairing.d.ts.map +1 -0
  399. package/dist/esm/precompiles/08-bn254-pairing.js +42 -0
  400. package/dist/esm/precompiles/08-bn254-pairing.js.map +1 -0
  401. package/dist/esm/precompiles/09-blake2f.d.ts +5 -0
  402. package/dist/esm/precompiles/09-blake2f.d.ts.map +1 -0
  403. package/dist/esm/precompiles/09-blake2f.js +197 -0
  404. package/dist/esm/precompiles/09-blake2f.js.map +1 -0
  405. package/dist/esm/precompiles/0a-kzg-point-evaluation.d.ts +5 -0
  406. package/dist/esm/precompiles/0a-kzg-point-evaluation.d.ts.map +1 -0
  407. package/dist/esm/precompiles/0a-kzg-point-evaluation.js +64 -0
  408. package/dist/esm/precompiles/0a-kzg-point-evaluation.js.map +1 -0
  409. package/dist/esm/precompiles/0b-bls12-g1add.d.ts +4 -0
  410. package/dist/esm/precompiles/0b-bls12-g1add.d.ts.map +1 -0
  411. package/dist/esm/precompiles/0b-bls12-g1add.js +46 -0
  412. package/dist/esm/precompiles/0b-bls12-g1add.js.map +1 -0
  413. package/dist/esm/precompiles/0c-bls12-g1msm.d.ts +4 -0
  414. package/dist/esm/precompiles/0c-bls12-g1msm.d.ts.map +1 -0
  415. package/dist/esm/precompiles/0c-bls12-g1msm.js +59 -0
  416. package/dist/esm/precompiles/0c-bls12-g1msm.js.map +1 -0
  417. package/dist/esm/precompiles/0d-bls12-g2add.d.ts +4 -0
  418. package/dist/esm/precompiles/0d-bls12-g2add.d.ts.map +1 -0
  419. package/dist/esm/precompiles/0d-bls12-g2add.js +48 -0
  420. package/dist/esm/precompiles/0d-bls12-g2add.js.map +1 -0
  421. package/dist/esm/precompiles/0e-bls12-g2msm.d.ts +4 -0
  422. package/dist/esm/precompiles/0e-bls12-g2msm.d.ts.map +1 -0
  423. package/dist/esm/precompiles/0e-bls12-g2msm.js +57 -0
  424. package/dist/esm/precompiles/0e-bls12-g2msm.js.map +1 -0
  425. package/dist/esm/precompiles/0f-bls12-pairing.d.ts +4 -0
  426. package/dist/esm/precompiles/0f-bls12-pairing.d.ts.map +1 -0
  427. package/dist/esm/precompiles/0f-bls12-pairing.js +63 -0
  428. package/dist/esm/precompiles/0f-bls12-pairing.js.map +1 -0
  429. package/dist/esm/precompiles/10-bls12-map-fp-to-g1.d.ts +4 -0
  430. package/dist/esm/precompiles/10-bls12-map-fp-to-g1.d.ts.map +1 -0
  431. package/dist/esm/precompiles/10-bls12-map-fp-to-g1.js +41 -0
  432. package/dist/esm/precompiles/10-bls12-map-fp-to-g1.js.map +1 -0
  433. package/dist/esm/precompiles/100-p256verify.d.ts +4 -0
  434. package/dist/esm/precompiles/100-p256verify.d.ts.map +1 -0
  435. package/dist/esm/precompiles/100-p256verify.js +128 -0
  436. package/dist/esm/precompiles/100-p256verify.js.map +1 -0
  437. package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.d.ts +4 -0
  438. package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.d.ts.map +1 -0
  439. package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.js +44 -0
  440. package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.js.map +1 -0
  441. package/dist/esm/precompiles/bls12_381/constants.d.ts +10 -0
  442. package/dist/esm/precompiles/bls12_381/constants.d.ts.map +1 -0
  443. package/dist/esm/precompiles/bls12_381/constants.js +271 -0
  444. package/dist/esm/precompiles/bls12_381/constants.js.map +1 -0
  445. package/dist/esm/precompiles/bls12_381/index.d.ts +5 -0
  446. package/dist/esm/precompiles/bls12_381/index.d.ts.map +1 -0
  447. package/dist/esm/precompiles/bls12_381/index.js +5 -0
  448. package/dist/esm/precompiles/bls12_381/index.js.map +1 -0
  449. package/dist/esm/precompiles/bls12_381/mcl.d.ts +45 -0
  450. package/dist/esm/precompiles/bls12_381/mcl.d.ts.map +1 -0
  451. package/dist/esm/precompiles/bls12_381/mcl.js +254 -0
  452. package/dist/esm/precompiles/bls12_381/mcl.js.map +1 -0
  453. package/dist/esm/precompiles/bls12_381/noble.d.ts +39 -0
  454. package/dist/esm/precompiles/bls12_381/noble.d.ts.map +1 -0
  455. package/dist/esm/precompiles/bls12_381/noble.js +218 -0
  456. package/dist/esm/precompiles/bls12_381/noble.js.map +1 -0
  457. package/dist/esm/precompiles/bls12_381/util.d.ts +35 -0
  458. package/dist/esm/precompiles/bls12_381/util.d.ts.map +1 -0
  459. package/dist/esm/precompiles/bls12_381/util.js +63 -0
  460. package/dist/esm/precompiles/bls12_381/util.js.map +1 -0
  461. package/dist/esm/precompiles/bn254/index.d.ts +3 -0
  462. package/dist/esm/precompiles/bn254/index.d.ts.map +1 -0
  463. package/dist/esm/precompiles/bn254/index.js +3 -0
  464. package/dist/esm/precompiles/bn254/index.js.map +1 -0
  465. package/dist/esm/precompiles/bn254/noble.d.ts +13 -0
  466. package/dist/esm/precompiles/bn254/noble.d.ts.map +1 -0
  467. package/dist/esm/precompiles/bn254/noble.js +120 -0
  468. package/dist/esm/precompiles/bn254/noble.js.map +1 -0
  469. package/dist/esm/precompiles/bn254/rustbn.d.ts +16 -0
  470. package/dist/esm/precompiles/bn254/rustbn.d.ts.map +1 -0
  471. package/dist/esm/precompiles/bn254/rustbn.js +29 -0
  472. package/dist/esm/precompiles/bn254/rustbn.js.map +1 -0
  473. package/dist/esm/precompiles/index.d.ts +67 -0
  474. package/dist/esm/precompiles/index.d.ts.map +1 -0
  475. package/dist/esm/precompiles/index.js +251 -0
  476. package/dist/esm/precompiles/index.js.map +1 -0
  477. package/dist/esm/precompiles/types.d.ts +13 -0
  478. package/dist/esm/precompiles/types.d.ts.map +1 -0
  479. package/dist/esm/precompiles/types.js +2 -0
  480. package/dist/esm/precompiles/types.js.map +1 -0
  481. package/dist/esm/precompiles/util.d.ts +30 -0
  482. package/dist/esm/precompiles/util.d.ts.map +1 -0
  483. package/dist/esm/precompiles/util.js +57 -0
  484. package/dist/esm/precompiles/util.js.map +1 -0
  485. package/dist/esm/stack.d.ts +55 -0
  486. package/dist/esm/stack.d.ts.map +1 -0
  487. package/dist/esm/stack.js +139 -0
  488. package/dist/esm/stack.js.map +1 -0
  489. package/dist/esm/stemCache.d.ts +20 -0
  490. package/dist/esm/stemCache.d.ts.map +1 -0
  491. package/dist/esm/stemCache.js +33 -0
  492. package/dist/esm/stemCache.js.map +1 -0
  493. package/dist/esm/transientStorage.d.ts +54 -0
  494. package/dist/esm/transientStorage.d.ts.map +1 -0
  495. package/dist/esm/transientStorage.js +109 -0
  496. package/dist/esm/transientStorage.js.map +1 -0
  497. package/dist/esm/types.d.ts +465 -0
  498. package/dist/esm/types.d.ts.map +1 -0
  499. package/dist/esm/types.js +23 -0
  500. package/dist/esm/types.js.map +1 -0
  501. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
  502. package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
  503. package/package.json +98 -0
  504. package/src/binaryTreeAccessWitness.ts +447 -0
  505. package/src/chunkCache.ts +36 -0
  506. package/src/constructors.ts +35 -0
  507. package/src/eip7708.ts +47 -0
  508. package/src/eof/constants.ts +36 -0
  509. package/src/eof/container.ts +495 -0
  510. package/src/eof/errors.ts +214 -0
  511. package/src/eof/setup.ts +27 -0
  512. package/src/eof/stackDelta.ts +169 -0
  513. package/src/eof/util.ts +16 -0
  514. package/src/eof/verify.ts +531 -0
  515. package/src/errors.ts +45 -0
  516. package/src/evm.ts +1415 -0
  517. package/src/frameContext.ts +56 -0
  518. package/src/index.ts +75 -0
  519. package/src/interpreter.ts +1437 -0
  520. package/src/journal.ts +317 -0
  521. package/src/logger.ts +180 -0
  522. package/src/memory.ts +82 -0
  523. package/src/message.ts +114 -0
  524. package/src/opcodes/EIP1283.ts +77 -0
  525. package/src/opcodes/EIP2200.ts +87 -0
  526. package/src/opcodes/EIP2929.ts +173 -0
  527. package/src/opcodes/codes.ts +528 -0
  528. package/src/opcodes/functions.ts +1937 -0
  529. package/src/opcodes/gas.ts +1329 -0
  530. package/src/opcodes/index.ts +3 -0
  531. package/src/opcodes/util.ts +313 -0
  532. package/src/params.ts +423 -0
  533. package/src/precompiles/01-ecrecover.ts +77 -0
  534. package/src/precompiles/02-sha256.ts +32 -0
  535. package/src/precompiles/03-ripemd160.ts +32 -0
  536. package/src/precompiles/04-identity.ts +29 -0
  537. package/src/precompiles/05-modexp.ts +215 -0
  538. package/src/precompiles/06-bn254-add.ts +49 -0
  539. package/src/precompiles/07-bn254-mul.ts +50 -0
  540. package/src/precompiles/08-bn254-pairing.ts +54 -0
  541. package/src/precompiles/09-blake2f.ts +243 -0
  542. package/src/precompiles/0a-kzg-point-evaluation.ts +94 -0
  543. package/src/precompiles/0b-bls12-g1add.ts +63 -0
  544. package/src/precompiles/0c-bls12-g1msm.ts +87 -0
  545. package/src/precompiles/0d-bls12-g2add.ts +66 -0
  546. package/src/precompiles/0e-bls12-g2msm.ts +84 -0
  547. package/src/precompiles/0f-bls12-pairing.ts +86 -0
  548. package/src/precompiles/10-bls12-map-fp-to-g1.ts +58 -0
  549. package/src/precompiles/100-p256verify.ts +152 -0
  550. package/src/precompiles/11-bls12-map-fp2-to-g2.ts +61 -0
  551. package/src/precompiles/bls12_381/constants.ts +278 -0
  552. package/src/precompiles/bls12_381/index.ts +4 -0
  553. package/src/precompiles/bls12_381/mcl.ts +376 -0
  554. package/src/precompiles/bls12_381/noble.ts +307 -0
  555. package/src/precompiles/bls12_381/util.ts +78 -0
  556. package/src/precompiles/bn254/index.ts +2 -0
  557. package/src/precompiles/bn254/noble.ts +156 -0
  558. package/src/precompiles/bn254/rustbn.ts +35 -0
  559. package/src/precompiles/index.ts +344 -0
  560. package/src/precompiles/types.ts +15 -0
  561. package/src/precompiles/util.ts +70 -0
  562. package/src/stack.ts +166 -0
  563. package/src/stemCache.ts +45 -0
  564. package/src/transientStorage.ts +131 -0
  565. package/src/types.ts +538 -0
@@ -0,0 +1,1778 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handlers = void 0;
4
+ const util_1 = require("@feelyourprotocol/util");
5
+ const sha3_js_1 = require("@noble/hashes/sha3.js");
6
+ const container_ts_1 = require("../eof/container.js");
7
+ const errors_ts_1 = require("../eof/errors.js");
8
+ const util_ts_1 = require("../eof/util.js");
9
+ const errors_ts_2 = require("../errors.js");
10
+ const util_ts_2 = require("./util.js");
11
+ // the opcode functions
12
+ exports.handlers = new Map([
13
+ // 0x00: STOP
14
+ [
15
+ 0x00,
16
+ function () {
17
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.STOP);
18
+ },
19
+ ],
20
+ // 0x01: ADD
21
+ [
22
+ 0x01,
23
+ function (runState) {
24
+ const [a, b] = runState.stack.popN(2);
25
+ const r = (0, util_ts_2.mod)(a + b, util_1.TWO_POW256);
26
+ runState.stack.push(r);
27
+ },
28
+ ],
29
+ // 0x02: MUL
30
+ [
31
+ 0x02,
32
+ function (runState) {
33
+ const [a, b] = runState.stack.popN(2);
34
+ const r = (0, util_ts_2.mod)(a * b, util_1.TWO_POW256);
35
+ runState.stack.push(r);
36
+ },
37
+ ],
38
+ // 0x03: SUB
39
+ [
40
+ 0x03,
41
+ function (runState) {
42
+ const [a, b] = runState.stack.popN(2);
43
+ const r = (0, util_ts_2.mod)(a - b, util_1.TWO_POW256);
44
+ runState.stack.push(r);
45
+ },
46
+ ],
47
+ // 0x04: DIV
48
+ [
49
+ 0x04,
50
+ function (runState) {
51
+ const [a, b] = runState.stack.popN(2);
52
+ let r;
53
+ if (b === util_1.BIGINT_0) {
54
+ r = util_1.BIGINT_0;
55
+ }
56
+ else {
57
+ r = (0, util_ts_2.mod)(a / b, util_1.TWO_POW256);
58
+ }
59
+ runState.stack.push(r);
60
+ },
61
+ ],
62
+ // 0x05: SDIV
63
+ [
64
+ 0x05,
65
+ function (runState) {
66
+ const [a, b] = runState.stack.popN(2);
67
+ let r;
68
+ if (b === util_1.BIGINT_0) {
69
+ r = util_1.BIGINT_0;
70
+ }
71
+ else {
72
+ r = (0, util_ts_2.toTwos)((0, util_ts_2.fromTwos)(a) / (0, util_ts_2.fromTwos)(b));
73
+ }
74
+ runState.stack.push(r);
75
+ },
76
+ ],
77
+ // 0x06: MOD
78
+ [
79
+ 0x06,
80
+ function (runState) {
81
+ const [a, b] = runState.stack.popN(2);
82
+ let r;
83
+ if (b === util_1.BIGINT_0) {
84
+ r = b;
85
+ }
86
+ else {
87
+ r = (0, util_ts_2.mod)(a, b);
88
+ }
89
+ runState.stack.push(r);
90
+ },
91
+ ],
92
+ // 0x07: SMOD
93
+ [
94
+ 0x07,
95
+ function (runState) {
96
+ const [a, b] = runState.stack.popN(2);
97
+ let r;
98
+ if (b === util_1.BIGINT_0) {
99
+ r = b;
100
+ }
101
+ else {
102
+ r = (0, util_ts_2.fromTwos)(a) % (0, util_ts_2.fromTwos)(b);
103
+ }
104
+ runState.stack.push((0, util_ts_2.toTwos)(r));
105
+ },
106
+ ],
107
+ // 0x08: ADDMOD
108
+ [
109
+ 0x08,
110
+ function (runState) {
111
+ const [a, b, c] = runState.stack.popN(3);
112
+ let r;
113
+ if (c === util_1.BIGINT_0) {
114
+ r = util_1.BIGINT_0;
115
+ }
116
+ else {
117
+ r = (0, util_ts_2.mod)(a + b, c);
118
+ }
119
+ runState.stack.push(r);
120
+ },
121
+ ],
122
+ // 0x09: MULMOD
123
+ [
124
+ 0x09,
125
+ function (runState) {
126
+ const [a, b, c] = runState.stack.popN(3);
127
+ let r;
128
+ if (c === util_1.BIGINT_0) {
129
+ r = util_1.BIGINT_0;
130
+ }
131
+ else {
132
+ r = (0, util_ts_2.mod)(a * b, c);
133
+ }
134
+ runState.stack.push(r);
135
+ },
136
+ ],
137
+ // 0x0a: EXP
138
+ [
139
+ 0x0a,
140
+ function (runState) {
141
+ const [base, exponent] = runState.stack.popN(2);
142
+ if (base === util_1.BIGINT_2) {
143
+ switch (exponent) {
144
+ case util_1.BIGINT_96:
145
+ runState.stack.push(util_1.BIGINT_2EXP96);
146
+ return;
147
+ case util_1.BIGINT_160:
148
+ runState.stack.push(util_1.BIGINT_2EXP160);
149
+ return;
150
+ case util_1.BIGINT_224:
151
+ runState.stack.push(util_1.BIGINT_2EXP224);
152
+ return;
153
+ }
154
+ }
155
+ if (exponent === util_1.BIGINT_0) {
156
+ runState.stack.push(util_1.BIGINT_1);
157
+ return;
158
+ }
159
+ if (base === util_1.BIGINT_0) {
160
+ runState.stack.push(base);
161
+ return;
162
+ }
163
+ const r = (0, util_ts_2.exponentiation)(base, exponent);
164
+ runState.stack.push(r);
165
+ },
166
+ ],
167
+ // 0x0b: SIGNEXTEND
168
+ [
169
+ 0x0b,
170
+ function (runState) {
171
+ /* eslint-disable-next-line prefer-const */
172
+ let [k, val] = runState.stack.popN(2);
173
+ if (k < util_1.BIGINT_31) {
174
+ const signBit = k * util_1.BIGINT_8 + util_1.BIGINT_7;
175
+ const mask = (util_1.BIGINT_1 << signBit) - util_1.BIGINT_1;
176
+ if ((val >> signBit) & util_1.BIGINT_1) {
177
+ val = val | BigInt.asUintN(256, ~mask);
178
+ }
179
+ else {
180
+ val = val & mask;
181
+ }
182
+ }
183
+ runState.stack.push(val);
184
+ },
185
+ ],
186
+ // 0x10 range - bit ops
187
+ // 0x10: LT
188
+ [
189
+ 0x10,
190
+ function (runState) {
191
+ const [a, b] = runState.stack.popN(2);
192
+ const r = a < b ? util_1.BIGINT_1 : util_1.BIGINT_0;
193
+ runState.stack.push(r);
194
+ },
195
+ ],
196
+ // 0x11: GT
197
+ [
198
+ 0x11,
199
+ function (runState) {
200
+ const [a, b] = runState.stack.popN(2);
201
+ const r = a > b ? util_1.BIGINT_1 : util_1.BIGINT_0;
202
+ runState.stack.push(r);
203
+ },
204
+ ],
205
+ // 0x12: SLT
206
+ [
207
+ 0x12,
208
+ function (runState) {
209
+ const [a, b] = runState.stack.popN(2);
210
+ const r = (0, util_ts_2.fromTwos)(a) < (0, util_ts_2.fromTwos)(b) ? util_1.BIGINT_1 : util_1.BIGINT_0;
211
+ runState.stack.push(r);
212
+ },
213
+ ],
214
+ // 0x13: SGT
215
+ [
216
+ 0x13,
217
+ function (runState) {
218
+ const [a, b] = runState.stack.popN(2);
219
+ const r = (0, util_ts_2.fromTwos)(a) > (0, util_ts_2.fromTwos)(b) ? util_1.BIGINT_1 : util_1.BIGINT_0;
220
+ runState.stack.push(r);
221
+ },
222
+ ],
223
+ // 0x14: EQ
224
+ [
225
+ 0x14,
226
+ function (runState) {
227
+ const [a, b] = runState.stack.popN(2);
228
+ const r = a === b ? util_1.BIGINT_1 : util_1.BIGINT_0;
229
+ runState.stack.push(r);
230
+ },
231
+ ],
232
+ // 0x15: ISZERO
233
+ [
234
+ 0x15,
235
+ function (runState) {
236
+ const a = runState.stack.pop();
237
+ const r = a === util_1.BIGINT_0 ? util_1.BIGINT_1 : util_1.BIGINT_0;
238
+ runState.stack.push(r);
239
+ },
240
+ ],
241
+ // 0x16: AND
242
+ [
243
+ 0x16,
244
+ function (runState) {
245
+ const [a, b] = runState.stack.popN(2);
246
+ const r = a & b;
247
+ runState.stack.push(r);
248
+ },
249
+ ],
250
+ // 0x17: OR
251
+ [
252
+ 0x17,
253
+ function (runState) {
254
+ const [a, b] = runState.stack.popN(2);
255
+ const r = a | b;
256
+ runState.stack.push(r);
257
+ },
258
+ ],
259
+ // 0x18: XOR
260
+ [
261
+ 0x18,
262
+ function (runState) {
263
+ const [a, b] = runState.stack.popN(2);
264
+ const r = a ^ b;
265
+ runState.stack.push(r);
266
+ },
267
+ ],
268
+ // 0x19: NOT
269
+ [
270
+ 0x19,
271
+ function (runState) {
272
+ const a = runState.stack.pop();
273
+ const r = BigInt.asUintN(256, ~a);
274
+ runState.stack.push(r);
275
+ },
276
+ ],
277
+ // 0x1a: BYTE
278
+ [
279
+ 0x1a,
280
+ function (runState) {
281
+ const [pos, word] = runState.stack.popN(2);
282
+ if (pos > util_1.BIGINT_32) {
283
+ runState.stack.push(util_1.BIGINT_0);
284
+ return;
285
+ }
286
+ const r = (word >> ((util_1.BIGINT_31 - pos) * util_1.BIGINT_8)) & util_1.BIGINT_255;
287
+ runState.stack.push(r);
288
+ },
289
+ ],
290
+ // 0x1b: SHL
291
+ [
292
+ 0x1b,
293
+ function (runState) {
294
+ const [a, b] = runState.stack.popN(2);
295
+ if (a > util_1.BIGINT_256) {
296
+ runState.stack.push(util_1.BIGINT_0);
297
+ return;
298
+ }
299
+ const r = (b << a) & util_1.MAX_INTEGER_BIGINT;
300
+ runState.stack.push(r);
301
+ },
302
+ ],
303
+ // 0x1c: SHR
304
+ [
305
+ 0x1c,
306
+ function (runState) {
307
+ const [a, b] = runState.stack.popN(2);
308
+ if (a > 256) {
309
+ runState.stack.push(util_1.BIGINT_0);
310
+ return;
311
+ }
312
+ const r = b >> a;
313
+ runState.stack.push(r);
314
+ },
315
+ ],
316
+ // 0x1d: SAR
317
+ [
318
+ 0x1d,
319
+ function (runState) {
320
+ const [a, b] = runState.stack.popN(2);
321
+ let r;
322
+ const bComp = BigInt.asIntN(256, b);
323
+ const isSigned = bComp < 0;
324
+ if (a > 256) {
325
+ if (isSigned) {
326
+ r = util_1.MAX_INTEGER_BIGINT;
327
+ }
328
+ else {
329
+ r = util_1.BIGINT_0;
330
+ }
331
+ runState.stack.push(r);
332
+ return;
333
+ }
334
+ const c = b >> a;
335
+ if (isSigned) {
336
+ const shiftedOutWidth = util_1.BIGINT_255 - a;
337
+ const mask = (util_1.MAX_INTEGER_BIGINT >> shiftedOutWidth) << shiftedOutWidth;
338
+ r = c | mask;
339
+ }
340
+ else {
341
+ r = c;
342
+ }
343
+ runState.stack.push(r);
344
+ },
345
+ ],
346
+ // 0x1e: CLZ
347
+ [
348
+ 0x1e,
349
+ function (runState) {
350
+ const x = runState.stack.pop();
351
+ // If x is zero, return 256
352
+ if (x === util_1.BIGINT_0) {
353
+ runState.stack.push(util_1.BIGINT_256);
354
+ return;
355
+ }
356
+ // toString(2) yields a binary string with no leading zeros.
357
+ // So 256 - binaryStr.length equals the leading-zero count.
358
+ const binaryStr = x.toString(2);
359
+ const leadingZeros = 256 - binaryStr.length;
360
+ runState.stack.push(BigInt(leadingZeros));
361
+ },
362
+ ],
363
+ // 0x20 range - crypto
364
+ // 0x20: KECCAK256
365
+ [
366
+ 0x20,
367
+ function (runState, common) {
368
+ const [offset, length] = runState.stack.popN(2);
369
+ let data = new Uint8Array(0);
370
+ if (length !== util_1.BIGINT_0) {
371
+ data = runState.memory.read(Number(offset), Number(length));
372
+ }
373
+ const r = BigInt((0, util_1.bytesToHex)((common.customCrypto.keccak256 ?? sha3_js_1.keccak_256)(data)));
374
+ runState.stack.push(r);
375
+ },
376
+ ],
377
+ // 0x30 range - closure state
378
+ // 0x30: ADDRESS
379
+ [
380
+ 0x30,
381
+ function (runState) {
382
+ const address = (0, util_1.bytesToBigInt)(runState.interpreter.getAddress().bytes);
383
+ runState.stack.push(address);
384
+ },
385
+ ],
386
+ // 0x31: BALANCE
387
+ [
388
+ 0x31,
389
+ async function (runState) {
390
+ const addressBigInt = runState.stack.pop();
391
+ const address = (0, util_ts_2.createAddressFromStackBigInt)(addressBigInt);
392
+ const balance = await runState.interpreter.getExternalBalance(address);
393
+ runState.stack.push(balance);
394
+ },
395
+ ],
396
+ // 0x32: ORIGIN
397
+ [
398
+ 0x32,
399
+ function (runState) {
400
+ runState.stack.push(runState.interpreter.getTxOrigin());
401
+ },
402
+ ],
403
+ // 0x33: CALLER
404
+ [
405
+ 0x33,
406
+ function (runState) {
407
+ runState.stack.push(runState.interpreter.getCaller());
408
+ },
409
+ ],
410
+ // 0x34: CALLVALUE
411
+ [
412
+ 0x34,
413
+ function (runState) {
414
+ runState.stack.push(runState.interpreter.getCallValue());
415
+ },
416
+ ],
417
+ // 0x35: CALLDATALOAD
418
+ [
419
+ 0x35,
420
+ function (runState) {
421
+ const pos = runState.stack.pop();
422
+ if (pos > runState.interpreter.getCallDataSize()) {
423
+ runState.stack.push(util_1.BIGINT_0);
424
+ return;
425
+ }
426
+ const i = Number(pos);
427
+ let loaded = runState.interpreter.getCallData().subarray(i, i + 32);
428
+ loaded = loaded.length ? loaded : Uint8Array.from([0]);
429
+ let r = (0, util_1.bytesToBigInt)(loaded);
430
+ if (loaded.length < 32) {
431
+ r = r << (util_1.BIGINT_8 * BigInt(32 - loaded.length));
432
+ }
433
+ runState.stack.push(r);
434
+ },
435
+ ],
436
+ // 0x36: CALLDATASIZE
437
+ [
438
+ 0x36,
439
+ function (runState) {
440
+ const r = runState.interpreter.getCallDataSize();
441
+ runState.stack.push(r);
442
+ },
443
+ ],
444
+ // 0x37: CALLDATACOPY
445
+ [
446
+ 0x37,
447
+ function (runState) {
448
+ const [memOffset, dataOffset, dataLength] = runState.stack.popN(3);
449
+ if (dataLength !== util_1.BIGINT_0) {
450
+ const data = (0, util_ts_2.getDataSlice)(runState.interpreter.getCallData(), dataOffset, dataLength);
451
+ const memOffsetNum = Number(memOffset);
452
+ const dataLengthNum = Number(dataLength);
453
+ runState.memory.write(memOffsetNum, dataLengthNum, data);
454
+ }
455
+ },
456
+ ],
457
+ // 0x38: CODESIZE
458
+ [
459
+ 0x38,
460
+ function (runState) {
461
+ runState.stack.push(runState.interpreter.getCodeSize());
462
+ },
463
+ ],
464
+ // 0x39: CODECOPY
465
+ [
466
+ 0x39,
467
+ function (runState) {
468
+ const [memOffset, codeOffset, dataLength] = runState.stack.popN(3);
469
+ if (dataLength !== util_1.BIGINT_0) {
470
+ const data = (0, util_ts_2.getDataSlice)(runState.interpreter.getCode(), codeOffset, dataLength);
471
+ const memOffsetNum = Number(memOffset);
472
+ const lengthNum = Number(dataLength);
473
+ runState.memory.write(memOffsetNum, lengthNum, data);
474
+ }
475
+ },
476
+ ],
477
+ // 0x3b: EXTCODESIZE
478
+ [
479
+ 0x3b,
480
+ async function (runState) {
481
+ const addressBigInt = runState.stack.pop();
482
+ const address = (0, util_ts_2.createAddressFromStackBigInt)(addressBigInt);
483
+ // EIP-7928: Track address access in BAL
484
+ if (runState.interpreter._evm.common.isActivatedEIP(7928)) {
485
+ runState.interpreter._evm.blockLevelAccessList?.addAddress(address.toString());
486
+ }
487
+ // EOF check
488
+ const code = await runState.stateManager.getCode(address);
489
+ if ((0, util_ts_1.isEOF)(code)) {
490
+ // In legacy code, the target code is treated as to be "EOFBYTES" code
491
+ runState.stack.push(BigInt(util_ts_1.EOFBYTES.length));
492
+ return;
493
+ }
494
+ const size = BigInt(code.length);
495
+ runState.stack.push(size);
496
+ },
497
+ ],
498
+ // 0x3c: EXTCODECOPY
499
+ [
500
+ 0x3c,
501
+ async function (runState) {
502
+ const [addressBigInt, memOffset, codeOffset, dataLength] = runState.stack.popN(4);
503
+ const address = (0, util_ts_2.createAddressFromStackBigInt)(addressBigInt);
504
+ // EIP-7928: Track address access in BAL
505
+ if (runState.interpreter._evm.common.isActivatedEIP(7928)) {
506
+ runState.interpreter._evm.blockLevelAccessList?.addAddress(address.toString());
507
+ }
508
+ if (dataLength !== util_1.BIGINT_0) {
509
+ let code = await runState.stateManager.getCode(address);
510
+ if ((0, util_ts_1.isEOF)(code)) {
511
+ // In legacy code, the target code is treated as to be "EOFBYTES" code
512
+ code = util_ts_1.EOFBYTES;
513
+ }
514
+ const data = (0, util_ts_2.getDataSlice)(code, codeOffset, dataLength);
515
+ const memOffsetNum = Number(memOffset);
516
+ const lengthNum = Number(dataLength);
517
+ runState.memory.write(memOffsetNum, lengthNum, data);
518
+ }
519
+ },
520
+ ],
521
+ // 0x3f: EXTCODEHASH
522
+ [
523
+ 0x3f,
524
+ async function (runState) {
525
+ const addressBigInt = runState.stack.pop();
526
+ const address = (0, util_ts_2.createAddressFromStackBigInt)(addressBigInt);
527
+ // EIP-7928: Track address access in BAL
528
+ if (runState.interpreter._evm.common.isActivatedEIP(7928)) {
529
+ runState.interpreter._evm.blockLevelAccessList?.addAddress(address.toString());
530
+ }
531
+ // EOF check
532
+ const code = await runState.stateManager.getCode(address);
533
+ if ((0, util_ts_1.isEOF)(code)) {
534
+ // In legacy code, the target code is treated as to be "EOFBYTES" code
535
+ // Therefore, push the hash of EOFBYTES to the stack
536
+ runState.stack.push((0, util_1.bytesToBigInt)(util_ts_1.EOFHASH));
537
+ return;
538
+ }
539
+ const account = await runState.stateManager.getAccount(address);
540
+ if (!account || account.isEmpty()) {
541
+ runState.stack.push(util_1.BIGINT_0);
542
+ return;
543
+ }
544
+ runState.stack.push(BigInt((0, util_1.bytesToHex)(account.codeHash)));
545
+ },
546
+ ],
547
+ // 0x3d: RETURNDATASIZE
548
+ [
549
+ 0x3d,
550
+ function (runState) {
551
+ runState.stack.push(runState.interpreter.getReturnDataSize());
552
+ },
553
+ ],
554
+ // 0x3e: RETURNDATACOPY
555
+ [
556
+ 0x3e,
557
+ function (runState) {
558
+ const [memOffset, returnDataOffset, dataLength] = runState.stack.popN(3);
559
+ if (dataLength !== util_1.BIGINT_0) {
560
+ const data = (0, util_ts_2.getDataSlice)(runState.interpreter.getReturnData(), returnDataOffset, dataLength);
561
+ const memOffsetNum = Number(memOffset);
562
+ const lengthNum = Number(dataLength);
563
+ runState.memory.write(memOffsetNum, lengthNum, data);
564
+ }
565
+ },
566
+ ],
567
+ // 0x3a: GASPRICE
568
+ [
569
+ 0x3a,
570
+ function (runState) {
571
+ runState.stack.push(runState.interpreter.getTxGasPrice());
572
+ },
573
+ ],
574
+ // '0x40' range - block operations
575
+ // 0x40: BLOCKHASH
576
+ [
577
+ 0x40,
578
+ async function (runState, common) {
579
+ const number = runState.stack.pop();
580
+ if (common.isActivatedEIP(7709)) {
581
+ if (number >= runState.interpreter.getBlockNumber()) {
582
+ runState.stack.push(util_1.BIGINT_0);
583
+ return;
584
+ }
585
+ const diff = runState.interpreter.getBlockNumber() - number;
586
+ // block lookups must be within the original window even if historyStorageAddress's
587
+ // historyServeWindow is much greater than 256
588
+ if (diff > util_1.BIGINT_256 || diff <= util_1.BIGINT_0) {
589
+ runState.stack.push(util_1.BIGINT_0);
590
+ return;
591
+ }
592
+ const historyAddress = new util_1.Address((0, util_1.bigIntToAddressBytes)(common.param('historyStorageAddress')));
593
+ const historyServeWindow = common.param('historyServeWindow');
594
+ const key = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(number % historyServeWindow), 32);
595
+ if (common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) {
596
+ // create witnesses and charge gas
597
+ const statelessGas = runState.env.accessWitness.readAccountStorage(historyAddress, number);
598
+ runState.interpreter.useGas(statelessGas, `BLOCKHASH`);
599
+ }
600
+ const storage = await runState.stateManager.getStorage(historyAddress, key);
601
+ runState.stack.push((0, util_1.bytesToBigInt)(storage));
602
+ }
603
+ else {
604
+ const diff = runState.interpreter.getBlockNumber() - number;
605
+ // block lookups must be within the past 256 blocks
606
+ if (diff > util_1.BIGINT_256 || diff <= util_1.BIGINT_0) {
607
+ runState.stack.push(util_1.BIGINT_0);
608
+ return;
609
+ }
610
+ const block = await runState.blockchain.getBlock(Number(number));
611
+ runState.stack.push((0, util_1.bytesToBigInt)(block.hash()));
612
+ }
613
+ },
614
+ ],
615
+ // 0x41: COINBASE
616
+ [
617
+ 0x41,
618
+ function (runState) {
619
+ runState.stack.push(runState.interpreter.getBlockCoinbase());
620
+ },
621
+ ],
622
+ // 0x42: TIMESTAMP
623
+ [
624
+ 0x42,
625
+ function (runState) {
626
+ runState.stack.push(runState.interpreter.getBlockTimestamp());
627
+ },
628
+ ],
629
+ // 0x43: NUMBER
630
+ [
631
+ 0x43,
632
+ function (runState) {
633
+ runState.stack.push(runState.interpreter.getBlockNumber());
634
+ },
635
+ ],
636
+ // 0x44: DIFFICULTY (EIP-4399: supplanted as PREVRANDAO)
637
+ [
638
+ 0x44,
639
+ function (runState, common) {
640
+ if (common.isActivatedEIP(4399)) {
641
+ runState.stack.push(runState.interpreter.getBlockPrevRandao());
642
+ }
643
+ else {
644
+ runState.stack.push(runState.interpreter.getBlockDifficulty());
645
+ }
646
+ },
647
+ ],
648
+ // 0x45: GASLIMIT
649
+ [
650
+ 0x45,
651
+ function (runState) {
652
+ runState.stack.push(runState.interpreter.getBlockGasLimit());
653
+ },
654
+ ],
655
+ // 0x4b: SLOTNUM (EIP-7843)
656
+ [
657
+ 0x4b,
658
+ function (runState) {
659
+ runState.stack.push(runState.interpreter.getBlockSlotNumber());
660
+ },
661
+ ],
662
+ // 0x46: CHAINID
663
+ [
664
+ 0x46,
665
+ function (runState) {
666
+ runState.stack.push(runState.interpreter.getChainId());
667
+ },
668
+ ],
669
+ // 0x47: SELFBALANCE
670
+ [
671
+ 0x47,
672
+ function (runState) {
673
+ runState.stack.push(runState.interpreter.getSelfBalance());
674
+ },
675
+ ],
676
+ // 0x48: BASEFEE
677
+ [
678
+ 0x48,
679
+ function (runState) {
680
+ runState.stack.push(runState.interpreter.getBlockBaseFee());
681
+ },
682
+ ],
683
+ // 0x49: BLOBHASH
684
+ [
685
+ 0x49,
686
+ function (runState) {
687
+ const index = runState.stack.pop();
688
+ if (runState.env.blobVersionedHashes.length > Number(index)) {
689
+ runState.stack.push(BigInt(runState.env.blobVersionedHashes[Number(index)]));
690
+ }
691
+ else {
692
+ runState.stack.push(util_1.BIGINT_0);
693
+ }
694
+ },
695
+ ],
696
+ // 0x4a: BLOBBASEFEE
697
+ [
698
+ 0x4a,
699
+ function (runState) {
700
+ runState.stack.push(runState.interpreter.getBlobBaseFee());
701
+ },
702
+ ],
703
+ // 0x50 range - 'storage' and execution
704
+ // 0x50: POP
705
+ [
706
+ 0x50,
707
+ function (runState) {
708
+ runState.stack.pop();
709
+ },
710
+ ],
711
+ // 0x51: MLOAD
712
+ [
713
+ 0x51,
714
+ function (runState) {
715
+ const pos = runState.stack.pop();
716
+ const word = runState.memory.read(Number(pos), 32, true);
717
+ runState.stack.push((0, util_1.bytesToBigInt)(word));
718
+ },
719
+ ],
720
+ // 0x52: MSTORE
721
+ [
722
+ 0x52,
723
+ function (runState) {
724
+ const [offset, word] = runState.stack.popN(2);
725
+ const buf = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(word), 32);
726
+ const offsetNum = Number(offset);
727
+ runState.memory.write(offsetNum, 32, buf);
728
+ },
729
+ ],
730
+ // 0x53: MSTORE8
731
+ [
732
+ 0x53,
733
+ function (runState) {
734
+ const [offset, byte] = runState.stack.popN(2);
735
+ const buf = (0, util_1.bigIntToBytes)(byte & util_1.BIGINT_255);
736
+ const offsetNum = Number(offset);
737
+ runState.memory.write(offsetNum, 1, buf);
738
+ },
739
+ ],
740
+ // 0x54: SLOAD
741
+ [
742
+ 0x54,
743
+ async function (runState) {
744
+ const key = runState.stack.pop();
745
+ const keyBuf = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(key), 32);
746
+ const value = await runState.interpreter.storageLoad(keyBuf);
747
+ const valueBigInt = value.length ? (0, util_1.bytesToBigInt)(value) : util_1.BIGINT_0;
748
+ runState.stack.push(valueBigInt);
749
+ },
750
+ ],
751
+ // 0x55: SSTORE
752
+ [
753
+ 0x55,
754
+ async function (runState) {
755
+ const [key, val] = runState.stack.popN(2);
756
+ const keyBuf = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(key), 32);
757
+ // NOTE: this should be the shortest representation
758
+ let value;
759
+ if (val === util_1.BIGINT_0) {
760
+ value = Uint8Array.from([]);
761
+ }
762
+ else {
763
+ value = (0, util_1.bigIntToBytes)(val);
764
+ }
765
+ await runState.interpreter.storageStore(keyBuf, value);
766
+ },
767
+ ],
768
+ // 0x56: JUMP
769
+ [
770
+ 0x56,
771
+ function (runState) {
772
+ const dest = runState.stack.pop();
773
+ if (dest > runState.interpreter.getCodeSize()) {
774
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_JUMP + ' at ' + (0, util_ts_2.describeLocation)(runState));
775
+ }
776
+ const destNum = Number(dest);
777
+ if (!(0, util_ts_2.jumpIsValid)(runState, destNum)) {
778
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_JUMP + ' at ' + (0, util_ts_2.describeLocation)(runState));
779
+ }
780
+ runState.programCounter = destNum;
781
+ },
782
+ ],
783
+ // 0x57: JUMPI
784
+ [
785
+ 0x57,
786
+ function (runState) {
787
+ const [dest, cond] = runState.stack.popN(2);
788
+ if (cond !== util_1.BIGINT_0) {
789
+ if (dest > runState.interpreter.getCodeSize()) {
790
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_JUMP + ' at ' + (0, util_ts_2.describeLocation)(runState));
791
+ }
792
+ const destNum = Number(dest);
793
+ if (!(0, util_ts_2.jumpIsValid)(runState, destNum)) {
794
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_JUMP + ' at ' + (0, util_ts_2.describeLocation)(runState));
795
+ }
796
+ runState.programCounter = destNum;
797
+ }
798
+ },
799
+ ],
800
+ // 0x58: PC
801
+ [
802
+ 0x58,
803
+ function (runState) {
804
+ runState.stack.push(BigInt(runState.programCounter - 1));
805
+ },
806
+ ],
807
+ // 0x59: MSIZE
808
+ [
809
+ 0x59,
810
+ function (runState) {
811
+ runState.stack.push(runState.memoryWordCount * util_1.BIGINT_32);
812
+ },
813
+ ],
814
+ // 0x5a: GAS
815
+ [
816
+ 0x5a,
817
+ function (runState) {
818
+ runState.stack.push(runState.interpreter.getGasLeft());
819
+ },
820
+ ],
821
+ // 0x5b: JUMPDEST
822
+ [0x5b, function () { }],
823
+ // 0x5c: TLOAD (EIP 1153)
824
+ [
825
+ 0x5c,
826
+ function (runState) {
827
+ const key = runState.stack.pop();
828
+ const keyBuf = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(key), 32);
829
+ const value = runState.interpreter.transientStorageLoad(keyBuf);
830
+ const valueBN = value.length ? (0, util_1.bytesToBigInt)(value) : util_1.BIGINT_0;
831
+ runState.stack.push(valueBN);
832
+ },
833
+ ],
834
+ // 0x5d: TSTORE (EIP 1153)
835
+ [
836
+ 0x5d,
837
+ function (runState) {
838
+ // TSTORE
839
+ if (runState.interpreter.isStatic()) {
840
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
841
+ }
842
+ const [key, val] = runState.stack.popN(2);
843
+ const keyBuf = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(key), 32);
844
+ // NOTE: this should be the shortest representation
845
+ let value;
846
+ if (val === util_1.BIGINT_0) {
847
+ value = Uint8Array.from([]);
848
+ }
849
+ else {
850
+ value = (0, util_1.bigIntToBytes)(val);
851
+ }
852
+ runState.interpreter.transientStorageStore(keyBuf, value);
853
+ },
854
+ ],
855
+ // 0x5e: MCOPY (5656)
856
+ [
857
+ 0x5e,
858
+ function (runState) {
859
+ const [dst, src, length] = runState.stack.popN(3);
860
+ const data = runState.memory.read(Number(src), Number(length), true);
861
+ runState.memory.write(Number(dst), Number(length), data);
862
+ },
863
+ ],
864
+ // 0x5f: PUSH0
865
+ [
866
+ 0x5f,
867
+ function (runState) {
868
+ runState.stack.push(util_1.BIGINT_0);
869
+ },
870
+ ],
871
+ // 0x60: PUSH
872
+ [
873
+ 0x60,
874
+ function (runState, common) {
875
+ const numToPush = runState.opCode - 0x5f;
876
+ if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
877
+ runState.env.chargeCodeAccesses === true) {
878
+ const contract = runState.interpreter.getAddress();
879
+ const startOffset = Math.min(runState.code.length, runState.programCounter + 1);
880
+ const endOffset = Math.min(runState.code.length, startOffset + numToPush - 1);
881
+ const statelessGas = runState.env.accessWitness.readAccountCodeChunks(contract, startOffset, endOffset);
882
+ runState.interpreter.useGas(statelessGas, `PUSH`);
883
+ }
884
+ if (!runState.shouldDoJumpAnalysis) {
885
+ runState.stack.push(runState.cachedPushes[runState.programCounter]);
886
+ runState.programCounter += numToPush;
887
+ }
888
+ else {
889
+ let loadedBytes = runState.code.subarray(runState.programCounter, runState.programCounter + numToPush);
890
+ if (loadedBytes.length < numToPush) {
891
+ loadedBytes = (0, util_1.setLengthRight)(loadedBytes, numToPush);
892
+ }
893
+ runState.programCounter += numToPush;
894
+ runState.stack.push((0, util_1.bytesToBigInt)(loadedBytes));
895
+ }
896
+ },
897
+ ],
898
+ // 0x80: DUP
899
+ [
900
+ 0x80,
901
+ function (runState) {
902
+ const stackPos = runState.opCode - 0x7f;
903
+ runState.stack.dup(stackPos);
904
+ },
905
+ ],
906
+ // 0x90: SWAP
907
+ [
908
+ 0x90,
909
+ function (runState) {
910
+ const stackPos = runState.opCode - 0x8f;
911
+ runState.stack.swap(stackPos);
912
+ },
913
+ ],
914
+ // 0xa0: LOG
915
+ [
916
+ 0xa0,
917
+ function (runState) {
918
+ const [memOffset, memLength] = runState.stack.popN(2);
919
+ const topicsCount = runState.opCode - 0xa0;
920
+ const topics = runState.stack.popN(topicsCount);
921
+ const topicsBuf = topics.map(function (a) {
922
+ return (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(a), 32);
923
+ });
924
+ let mem = new Uint8Array(0);
925
+ if (memLength !== util_1.BIGINT_0) {
926
+ mem = runState.memory.read(Number(memOffset), Number(memLength));
927
+ }
928
+ runState.interpreter.log(mem, topicsCount, topicsBuf);
929
+ },
930
+ ],
931
+ // 0xd0: DATALOAD
932
+ [
933
+ 0xd0,
934
+ function (runState) {
935
+ if (runState.env.eof === undefined) {
936
+ // Opcode not available in legacy contracts
937
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
938
+ }
939
+ const pos = runState.stack.pop();
940
+ if (pos > runState.env.eof.container.body.dataSection.length) {
941
+ runState.stack.push(util_1.BIGINT_0);
942
+ return;
943
+ }
944
+ const i = Number(pos);
945
+ let loaded = runState.env.eof.container.body.dataSection.subarray(i, i + 32);
946
+ loaded = loaded.length ? loaded : Uint8Array.from([0]);
947
+ let r = (0, util_1.bytesToBigInt)(loaded);
948
+ // Pad the loaded length with 0 bytes in case it is smaller than 32
949
+ if (loaded.length < 32) {
950
+ r = r << (util_1.BIGINT_8 * BigInt(32 - loaded.length));
951
+ }
952
+ runState.stack.push(r);
953
+ },
954
+ ],
955
+ // 0xd1: DATALOADN
956
+ [
957
+ 0xd1,
958
+ function (runState) {
959
+ if (runState.env.eof === undefined) {
960
+ // Opcode not available in legacy contracts
961
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
962
+ }
963
+ const toLoad = Number((0, util_1.bytesToBigInt)(runState.code.subarray(runState.programCounter, runState.programCounter + 2)));
964
+ const data = (0, util_1.bytesToBigInt)(runState.env.eof.container.body.dataSection.subarray(toLoad, toLoad + 32));
965
+ runState.stack.push(data);
966
+ runState.programCounter += 2;
967
+ },
968
+ ],
969
+ // 0xd2: DATASIZE
970
+ [
971
+ 0xd2,
972
+ function (runState) {
973
+ if (runState.env.eof === undefined) {
974
+ // Opcode not available in legacy contracts
975
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
976
+ }
977
+ runState.stack.push(BigInt(runState.env.eof.container.body.dataSection.length));
978
+ },
979
+ ],
980
+ // 0xd3: DATACOPY
981
+ [
982
+ 0xd3,
983
+ function (runState) {
984
+ if (runState.env.eof === undefined) {
985
+ // Opcode not available in legacy contracts
986
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
987
+ }
988
+ const [memOffset, offset, size] = runState.stack.popN(3);
989
+ if (size !== util_1.BIGINT_0) {
990
+ const data = (0, util_ts_2.getDataSlice)(runState.env.eof.container.body.dataSection, offset, size);
991
+ const memOffsetNum = Number(memOffset);
992
+ const dataLengthNum = Number(size);
993
+ runState.memory.write(memOffsetNum, dataLengthNum, data);
994
+ }
995
+ },
996
+ ],
997
+ // 0xe0: RJUMP
998
+ [
999
+ 0xe0,
1000
+ function (runState) {
1001
+ if (runState.env.eof === undefined) {
1002
+ // Opcode not available in legacy contracts
1003
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1004
+ }
1005
+ else {
1006
+ const code = runState.env.code;
1007
+ const rjumpDest = new DataView(code.buffer).getInt16(runState.programCounter);
1008
+ runState.programCounter += 2 + rjumpDest;
1009
+ }
1010
+ },
1011
+ ],
1012
+ // 0xe1: RJUMPI
1013
+ [
1014
+ 0xe1,
1015
+ function (runState) {
1016
+ if (runState.env.eof === undefined) {
1017
+ // Opcode not available in legacy contracts
1018
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1019
+ }
1020
+ else {
1021
+ const cond = runState.stack.pop();
1022
+ // Move PC to the PC post instruction
1023
+ if (cond > 0) {
1024
+ const code = runState.env.code;
1025
+ const rjumpDest = new DataView(code.buffer).getInt16(runState.programCounter);
1026
+ runState.programCounter += rjumpDest;
1027
+ }
1028
+ // In all cases, increment PC with 2 (also in the case if `cond` is `0`)
1029
+ runState.programCounter += 2;
1030
+ }
1031
+ },
1032
+ ],
1033
+ // 0xe2: RJUMPV
1034
+ [
1035
+ 0xe2,
1036
+ function (runState) {
1037
+ if (runState.env.eof === undefined) {
1038
+ // Opcode not available in legacy contracts
1039
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1040
+ }
1041
+ else {
1042
+ const code = runState.env.code;
1043
+ const jumptableEntries = code[runState.programCounter];
1044
+ // Note: if the size of the immediate is `0`, this thus means that the actual size is `2`
1045
+ // This allows for 256 entries in the table instead of 255
1046
+ const jumptableSize = (jumptableEntries + 1) * 2;
1047
+ // Move PC to start of the jump table
1048
+ runState.programCounter += 1;
1049
+ const jumptableCase = runState.stack.pop();
1050
+ if (jumptableCase <= jumptableEntries) {
1051
+ const rjumpDest = new DataView(code.buffer).getInt16(runState.programCounter + Number(jumptableCase) * 2);
1052
+ runState.programCounter += jumptableSize + rjumpDest;
1053
+ }
1054
+ else {
1055
+ runState.programCounter += jumptableSize;
1056
+ }
1057
+ }
1058
+ },
1059
+ ],
1060
+ // 0xe3: CALLF
1061
+ [
1062
+ 0xe3,
1063
+ function (runState) {
1064
+ if (runState.env.eof === undefined) {
1065
+ // Opcode not available in legacy contracts
1066
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1067
+ }
1068
+ const sectionTarget = (0, util_1.bytesToInt)(runState.code.slice(runState.programCounter, runState.programCounter + 2));
1069
+ const stackItems = runState.stack.length;
1070
+ const typeSection = runState.env.eof.container.body.typeSections[sectionTarget];
1071
+ if (stackItems > 1024 - typeSection.maxStackHeight + typeSection.inputs) {
1072
+ (0, util_ts_2.trap)(errors_ts_1.EOFErrorMessage.STACK_OVERFLOW);
1073
+ }
1074
+ if (runState.env.eof.eofRunState.returnStack.length >= 1024) {
1075
+ (0, util_ts_2.trap)(errors_ts_1.EOFErrorMessage.RETURN_STACK_OVERFLOW);
1076
+ }
1077
+ runState.env.eof?.eofRunState.returnStack.push(runState.programCounter + 2);
1078
+ // Find out the opcode we should jump into
1079
+ runState.programCounter = runState.env.eof.container.header.getCodePosition(sectionTarget);
1080
+ },
1081
+ ],
1082
+ // 0xe4: RETF
1083
+ [
1084
+ 0xe4,
1085
+ function (runState) {
1086
+ if (runState.env.eof === undefined) {
1087
+ // Opcode not available in legacy contracts
1088
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1089
+ }
1090
+ const newPc = runState.env.eof.eofRunState.returnStack.pop();
1091
+ if (newPc === undefined) {
1092
+ // This should NEVER happen since it is validated that functions either terminate (the call frame) or return
1093
+ (0, util_ts_2.trap)(errors_ts_1.EOFErrorMessage.RETF_NO_RETURN);
1094
+ }
1095
+ runState.programCounter = newPc;
1096
+ },
1097
+ ],
1098
+ // 0xe5: JUMPF
1099
+ [
1100
+ 0xe5,
1101
+ function (runState) {
1102
+ if (runState.env.eof === undefined) {
1103
+ // Opcode not available in legacy contracts
1104
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1105
+ }
1106
+ // NOTE: (and also TODO) this code is exactly the same as CALLF, except pushing to the return stack is now skipped
1107
+ // (and also the return stack overflow check)
1108
+ // It is commented out here
1109
+ const sectionTarget = (0, util_1.bytesToInt)(runState.code.slice(runState.programCounter, runState.programCounter + 2));
1110
+ const stackItems = runState.stack.length;
1111
+ const typeSection = runState.env.eof.container.body.typeSections[sectionTarget];
1112
+ if (stackItems > 1024 - typeSection.maxStackHeight + typeSection.inputs) {
1113
+ (0, util_ts_2.trap)(errors_ts_1.EOFErrorMessage.STACK_OVERFLOW);
1114
+ }
1115
+ /*if (runState.env.eof!.eofRunState.returnStack.length >= 1024) {
1116
+ trap(EOFErrorMessage.ReturnStackOverflow)
1117
+ }
1118
+ runState.env.eof?.eofRunState.returnStack.push(runState.programCounter + 2)*/
1119
+ // Find out the opcode we should jump into
1120
+ runState.programCounter = runState.env.eof.container.header.getCodePosition(sectionTarget);
1121
+ },
1122
+ ],
1123
+ // 0xe6: DUPN
1124
+ [
1125
+ 0xe6,
1126
+ function (runState, common) {
1127
+ if (!common.isActivatedEIP(8024)) {
1128
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1129
+ }
1130
+ const immediate = (0, util_ts_2.readImmediateByteOrZero)(runState);
1131
+ const toDup = (0, util_ts_2.decodeEIP8024SingleImmediate)(immediate);
1132
+ runState.stack.dup(toDup);
1133
+ },
1134
+ ],
1135
+ // 0xe7: SWAPN
1136
+ [
1137
+ 0xe7,
1138
+ function (runState, common) {
1139
+ if (!common.isActivatedEIP(8024)) {
1140
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1141
+ }
1142
+ const immediate = (0, util_ts_2.readImmediateByteOrZero)(runState);
1143
+ const toSwap = (0, util_ts_2.decodeEIP8024SingleImmediate)(immediate);
1144
+ runState.stack.swap(toSwap);
1145
+ },
1146
+ ],
1147
+ // 0xe8: EXCHANGE
1148
+ [
1149
+ 0xe8,
1150
+ function (runState, common) {
1151
+ if (!common.isActivatedEIP(8024)) {
1152
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1153
+ }
1154
+ const immediate = (0, util_ts_2.readImmediateByteOrZero)(runState);
1155
+ const [x, y] = (0, util_ts_2.decodeEIP8024PairImmediate)(immediate);
1156
+ runState.stack.exchange(x, y);
1157
+ },
1158
+ ],
1159
+ // 0xec: EOFCREATE
1160
+ [
1161
+ 0xec,
1162
+ async function (runState) {
1163
+ if (runState.env.eof === undefined) {
1164
+ // Opcode not available in legacy contracts
1165
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1166
+ }
1167
+ else {
1168
+ if (runState.interpreter.isStatic()) {
1169
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
1170
+ }
1171
+ // Read container index
1172
+ const containerIndex = runState.env.code[runState.programCounter];
1173
+ const containerCode = runState.env.eof.container.body.containerSections[containerIndex];
1174
+ // Pop stack values
1175
+ const [value, salt, inputOffset, inputSize] = runState.stack.popN(4);
1176
+ const gasLimit = runState.messageGasLimit;
1177
+ runState.messageGasLimit = undefined;
1178
+ let data = new Uint8Array(0);
1179
+ if (inputSize !== util_1.BIGINT_0) {
1180
+ data = runState.memory.read(Number(inputOffset), Number(inputSize), true);
1181
+ }
1182
+ runState.programCounter++; // Jump over the immediate byte
1183
+ const ret = await runState.interpreter.eofcreate(gasLimit, value, containerCode, (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(salt), 32), data);
1184
+ runState.stack.push(ret);
1185
+ }
1186
+ },
1187
+ ],
1188
+ // 0xee: RETURNCONTRACT
1189
+ [
1190
+ 0xee,
1191
+ async function (runState) {
1192
+ if (runState.env.eof === undefined) {
1193
+ // Opcode not available in legacy contracts
1194
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1195
+ }
1196
+ else {
1197
+ // Read container index
1198
+ const containerIndex = runState.env.code[runState.programCounter];
1199
+ const containerCode = runState.env.eof.container.body.containerSections[containerIndex];
1200
+ // Read deployContainer as EOFCreate (initcode) container
1201
+ const deployContainer = new container_ts_1.EOFContainer(containerCode, container_ts_1.EOFContainerMode.Initmode);
1202
+ // Pop stack values
1203
+ const [auxDataOffset, auxDataSize] = runState.stack.popN(2);
1204
+ let auxData = new Uint8Array(0);
1205
+ if (auxDataSize !== util_1.BIGINT_0) {
1206
+ auxData = runState.memory.read(Number(auxDataOffset), Number(auxDataSize));
1207
+ }
1208
+ const originalDataSize = deployContainer.header.dataSize;
1209
+ const preDeployDataSectionSize = deployContainer.body.dataSection.length;
1210
+ const actualSectionSize = preDeployDataSectionSize + Number(auxDataSize);
1211
+ if (actualSectionSize < originalDataSize) {
1212
+ (0, util_ts_2.trap)(errors_ts_1.EOFErrorMessage.INVALID_RETURN_CONTRACT_DATA_SIZE);
1213
+ }
1214
+ if (actualSectionSize > 0xffff) {
1215
+ // Data section size is now larger than the max data section size
1216
+ // Temp: trap OOG?
1217
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
1218
+ }
1219
+ const newSize = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(BigInt(actualSectionSize)), 2);
1220
+ // Write the bytes to the containerCode
1221
+ const dataSizePtr = deployContainer.header.dataSizePtr;
1222
+ containerCode[dataSizePtr] = newSize[0];
1223
+ containerCode[dataSizePtr + 1] = newSize[1];
1224
+ const returnContainer = (0, util_1.concatBytes)(containerCode, auxData);
1225
+ runState.interpreter.finish(returnContainer);
1226
+ }
1227
+ },
1228
+ ],
1229
+ // '0xf0' range - closures
1230
+ // 0xf0: CREATE
1231
+ [
1232
+ 0xf0,
1233
+ async function (runState, common) {
1234
+ const [value, offset, length] = runState.stack.popN(3);
1235
+ if (common.isActivatedEIP(3860) &&
1236
+ length > Number(common.param('maxInitCodeSize')) &&
1237
+ !runState.interpreter._evm.allowUnlimitedInitCodeSize) {
1238
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INITCODE_SIZE_VIOLATION);
1239
+ }
1240
+ const gasLimit = runState.messageGasLimit;
1241
+ runState.messageGasLimit = undefined;
1242
+ let data = new Uint8Array(0);
1243
+ if (length !== util_1.BIGINT_0) {
1244
+ data = runState.memory.read(Number(offset), Number(length), true);
1245
+ }
1246
+ if ((0, util_ts_1.isEOF)(data)) {
1247
+ // Legacy cannot deploy EOF code
1248
+ runState.stack.push(util_1.BIGINT_0);
1249
+ return;
1250
+ }
1251
+ const ret = await runState.interpreter.create(gasLimit, value, data);
1252
+ runState.stack.push(ret);
1253
+ },
1254
+ ],
1255
+ // 0xf5: CREATE2
1256
+ [
1257
+ 0xf5,
1258
+ async function (runState, common) {
1259
+ if (runState.interpreter.isStatic()) {
1260
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
1261
+ }
1262
+ const [value, offset, length, salt] = runState.stack.popN(4);
1263
+ if (common.isActivatedEIP(3860) &&
1264
+ length > Number(common.param('maxInitCodeSize')) &&
1265
+ !runState.interpreter._evm.allowUnlimitedInitCodeSize) {
1266
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INITCODE_SIZE_VIOLATION);
1267
+ }
1268
+ const gasLimit = runState.messageGasLimit;
1269
+ runState.messageGasLimit = undefined;
1270
+ let data = new Uint8Array(0);
1271
+ if (length !== util_1.BIGINT_0) {
1272
+ data = runState.memory.read(Number(offset), Number(length), true);
1273
+ }
1274
+ if ((0, util_ts_1.isEOF)(data)) {
1275
+ // Legacy cannot deploy EOF code
1276
+ runState.stack.push(util_1.BIGINT_0);
1277
+ return;
1278
+ }
1279
+ const ret = await runState.interpreter.create2(gasLimit, value, data, (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(salt), 32));
1280
+ runState.stack.push(ret);
1281
+ },
1282
+ ],
1283
+ // 0xf1: CALL
1284
+ [
1285
+ 0xf1,
1286
+ async function (runState, common) {
1287
+ const [_currentGasLimit, toAddr, value, inOffset, inLength, outOffset, outLength] = runState.stack.popN(7);
1288
+ const toAddress = (0, util_ts_2.createAddressFromStackBigInt)(toAddr);
1289
+ let data = new Uint8Array(0);
1290
+ if (inLength !== util_1.BIGINT_0) {
1291
+ data = runState.memory.read(Number(inOffset), Number(inLength), true);
1292
+ }
1293
+ let gasLimit = runState.messageGasLimit;
1294
+ if (value !== util_1.BIGINT_0) {
1295
+ const callStipend = common.param('callStipendGas');
1296
+ runState.interpreter.addStipend(callStipend);
1297
+ gasLimit += callStipend;
1298
+ }
1299
+ runState.messageGasLimit = undefined;
1300
+ const ret = await runState.interpreter.call(gasLimit, toAddress, value, data);
1301
+ // Write return data to memory
1302
+ (0, util_ts_2.writeCallOutput)(runState, outOffset, outLength);
1303
+ runState.stack.push(ret);
1304
+ },
1305
+ ],
1306
+ // 0xf2: CALLCODE
1307
+ [
1308
+ 0xf2,
1309
+ async function (runState, common) {
1310
+ const [_currentGasLimit, toAddr, value, inOffset, inLength, outOffset, outLength] = runState.stack.popN(7);
1311
+ const toAddress = (0, util_ts_2.createAddressFromStackBigInt)(toAddr);
1312
+ let gasLimit = runState.messageGasLimit;
1313
+ if (value !== util_1.BIGINT_0) {
1314
+ const callStipend = common.param('callStipendGas');
1315
+ runState.interpreter.addStipend(callStipend);
1316
+ gasLimit += callStipend;
1317
+ }
1318
+ runState.messageGasLimit = undefined;
1319
+ let data = new Uint8Array(0);
1320
+ if (inLength !== util_1.BIGINT_0) {
1321
+ data = runState.memory.read(Number(inOffset), Number(inLength), true);
1322
+ }
1323
+ const ret = await runState.interpreter.callCode(gasLimit, toAddress, value, data);
1324
+ // Write return data to memory
1325
+ (0, util_ts_2.writeCallOutput)(runState, outOffset, outLength);
1326
+ runState.stack.push(ret);
1327
+ },
1328
+ ],
1329
+ // 0xf4: DELEGATECALL
1330
+ [
1331
+ 0xf4,
1332
+ async function (runState) {
1333
+ const value = runState.interpreter.getCallValue();
1334
+ const [_currentGasLimit, toAddr, inOffset, inLength, outOffset, outLength] = runState.stack.popN(6);
1335
+ const toAddress = (0, util_ts_2.createAddressFromStackBigInt)(toAddr);
1336
+ let data = new Uint8Array(0);
1337
+ if (inLength !== util_1.BIGINT_0) {
1338
+ data = runState.memory.read(Number(inOffset), Number(inLength), true);
1339
+ }
1340
+ const gasLimit = runState.messageGasLimit;
1341
+ runState.messageGasLimit = undefined;
1342
+ const ret = await runState.interpreter.callDelegate(gasLimit, toAddress, value, data);
1343
+ // Write return data to memory
1344
+ (0, util_ts_2.writeCallOutput)(runState, outOffset, outLength);
1345
+ runState.stack.push(ret);
1346
+ },
1347
+ ],
1348
+ // 0xf7: RETURNDATALOAD
1349
+ [
1350
+ 0xf7,
1351
+ function (runState) {
1352
+ if (runState.env.eof === undefined) {
1353
+ // Opcode not available in legacy contracts
1354
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1355
+ }
1356
+ const pos = runState.stack.pop();
1357
+ if (pos > runState.interpreter.getReturnDataSize()) {
1358
+ runState.stack.push(util_1.BIGINT_0);
1359
+ return;
1360
+ }
1361
+ const i = Number(pos);
1362
+ let loaded = runState.interpreter.getReturnData().subarray(i, i + 32);
1363
+ loaded = loaded.length ? loaded : Uint8Array.from([0]);
1364
+ let r = (0, util_1.bytesToBigInt)(loaded);
1365
+ if (loaded.length < 32) {
1366
+ r = r << (util_1.BIGINT_8 * BigInt(32 - loaded.length));
1367
+ }
1368
+ runState.stack.push(r);
1369
+ },
1370
+ ],
1371
+ // 0xf8: EXTCALL
1372
+ [
1373
+ 0xf8,
1374
+ async function (runState) {
1375
+ if (runState.env.eof === undefined) {
1376
+ // Opcode not available in legacy contracts
1377
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1378
+ }
1379
+ else {
1380
+ const [toAddr, inOffset, inLength, value] = runState.stack.popN(4);
1381
+ const gasLimit = runState.messageGasLimit;
1382
+ runState.messageGasLimit = undefined;
1383
+ if (gasLimit === -util_1.BIGINT_1) {
1384
+ // Special case, abort doing any logic (this logic is defined in `gas.ts`), and put `1` on stack per spec
1385
+ runState.stack.push(util_1.BIGINT_1);
1386
+ runState.returnBytes = new Uint8Array(0);
1387
+ return;
1388
+ }
1389
+ const toAddress = (0, util_ts_2.createAddressFromStackBigInt)(toAddr);
1390
+ let data = new Uint8Array(0);
1391
+ if (inLength !== util_1.BIGINT_0) {
1392
+ data = runState.memory.read(Number(inOffset), Number(inLength), true);
1393
+ }
1394
+ const ret = await runState.interpreter.call(gasLimit, toAddress, value, data);
1395
+ // Write return data to memory
1396
+ runState.stack.push(ret);
1397
+ }
1398
+ },
1399
+ ],
1400
+ // 0xf9: EXTDELEGATECALL
1401
+ [
1402
+ 0xf9,
1403
+ async function (runState) {
1404
+ if (runState.env.eof === undefined) {
1405
+ // Opcode not available in legacy contracts
1406
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1407
+ }
1408
+ else {
1409
+ const value = runState.interpreter.getCallValue();
1410
+ const [toAddr, inOffset, inLength] = runState.stack.popN(3);
1411
+ const gasLimit = runState.messageGasLimit;
1412
+ runState.messageGasLimit = undefined;
1413
+ if (gasLimit === -util_1.BIGINT_1) {
1414
+ // Special case, abort doing any logic (this logic is defined in `gas.ts`), and put `1` on stack per spec
1415
+ runState.stack.push(util_1.BIGINT_1);
1416
+ runState.returnBytes = new Uint8Array(0);
1417
+ return;
1418
+ }
1419
+ const toAddress = (0, util_ts_2.createAddressFromStackBigInt)(toAddr);
1420
+ const code = await runState.stateManager.getCode(toAddress);
1421
+ if (!(0, util_ts_1.isEOF)(code)) {
1422
+ // EXTDELEGATECALL cannot call legacy contracts
1423
+ runState.stack.push(util_1.BIGINT_1);
1424
+ runState.returnBytes = new Uint8Array(0);
1425
+ return;
1426
+ }
1427
+ let data = new Uint8Array(0);
1428
+ if (inLength !== util_1.BIGINT_0) {
1429
+ data = runState.memory.read(Number(inOffset), Number(inLength), true);
1430
+ }
1431
+ const ret = await runState.interpreter.callDelegate(gasLimit, toAddress, value, data);
1432
+ runState.stack.push(ret);
1433
+ }
1434
+ },
1435
+ ],
1436
+ // 0xfa: STATICCALL
1437
+ [
1438
+ 0xfa,
1439
+ async function (runState) {
1440
+ const value = util_1.BIGINT_0;
1441
+ const [_currentGasLimit, toAddr, inOffset, inLength, outOffset, outLength] = runState.stack.popN(6);
1442
+ const toAddress = (0, util_ts_2.createAddressFromStackBigInt)(toAddr);
1443
+ const gasLimit = runState.messageGasLimit;
1444
+ runState.messageGasLimit = undefined;
1445
+ let data = new Uint8Array(0);
1446
+ if (inLength !== util_1.BIGINT_0) {
1447
+ data = runState.memory.read(Number(inOffset), Number(inLength), true);
1448
+ }
1449
+ const ret = await runState.interpreter.callStatic(gasLimit, toAddress, value, data);
1450
+ // Write return data to memory
1451
+ (0, util_ts_2.writeCallOutput)(runState, outOffset, outLength);
1452
+ runState.stack.push(ret);
1453
+ },
1454
+ ],
1455
+ // 0xfb: EXTSTATICCALL
1456
+ [
1457
+ 0xfb,
1458
+ async function (runState) {
1459
+ if (runState.env.eof === undefined) {
1460
+ // Opcode not available in legacy contracts
1461
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1462
+ }
1463
+ else {
1464
+ const value = util_1.BIGINT_0;
1465
+ const [toAddr, inOffset, inLength] = runState.stack.popN(3);
1466
+ const gasLimit = runState.messageGasLimit;
1467
+ runState.messageGasLimit = undefined;
1468
+ if (gasLimit === -util_1.BIGINT_1) {
1469
+ // Special case, abort doing any logic (this logic is defined in `gas.ts`), and put `1` on stack per spec
1470
+ runState.stack.push(util_1.BIGINT_1);
1471
+ runState.returnBytes = new Uint8Array(0);
1472
+ return;
1473
+ }
1474
+ const toAddress = (0, util_ts_2.createAddressFromStackBigInt)(toAddr);
1475
+ let data = new Uint8Array(0);
1476
+ if (inLength !== util_1.BIGINT_0) {
1477
+ data = runState.memory.read(Number(inOffset), Number(inLength), true);
1478
+ }
1479
+ const ret = await runState.interpreter.callStatic(gasLimit, toAddress, value, data);
1480
+ runState.stack.push(ret);
1481
+ }
1482
+ },
1483
+ ],
1484
+ // 0xf3: RETURN
1485
+ [
1486
+ 0xf3,
1487
+ function (runState) {
1488
+ const [offset, length] = runState.stack.popN(2);
1489
+ let returnData = new Uint8Array(0);
1490
+ if (length !== util_1.BIGINT_0) {
1491
+ returnData = runState.memory.read(Number(offset), Number(length));
1492
+ }
1493
+ runState.interpreter.finish(returnData);
1494
+ },
1495
+ ],
1496
+ // 0xfd: REVERT
1497
+ [
1498
+ 0xfd,
1499
+ function (runState) {
1500
+ const [offset, length] = runState.stack.popN(2);
1501
+ let returnData = new Uint8Array(0);
1502
+ if (length !== util_1.BIGINT_0) {
1503
+ returnData = runState.memory.read(Number(offset), Number(length));
1504
+ }
1505
+ runState.interpreter.revert(returnData);
1506
+ },
1507
+ ],
1508
+ // '0x70', range - other
1509
+ // 0xff: SELFDESTRUCT
1510
+ [
1511
+ 0xff,
1512
+ async function (runState) {
1513
+ const selfdestructToAddressBigInt = runState.stack.pop();
1514
+ const selfdestructToAddress = (0, util_ts_2.createAddressFromStackBigInt)(selfdestructToAddressBigInt);
1515
+ return runState.interpreter.selfDestruct(selfdestructToAddress);
1516
+ },
1517
+ ],
1518
+ // EIP-8141: Frame Transaction opcodes
1519
+ // 0xaa: APPROVE
1520
+ [
1521
+ 0xaa,
1522
+ async function (runState) {
1523
+ const scope = runState.stack.pop();
1524
+ const evm = runState.interpreter._evm;
1525
+ const fctx = evm.frameExecutionContext;
1526
+ if (fctx === undefined) {
1527
+ return (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1528
+ }
1529
+ const { tx, state } = fctx;
1530
+ const address = runState.env.address;
1531
+ const currentFrame = state.parsedFrames[state.currentFrameIndex];
1532
+ const frameTarget = currentFrame.target ?? tx.sender;
1533
+ if (!(0, util_1.equalsBytes)(address.bytes, frameTarget.bytes)) {
1534
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1535
+ }
1536
+ if (scope === util_1.BIGINT_0) {
1537
+ if (state.senderApproved)
1538
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1539
+ if (!(0, util_1.equalsBytes)(frameTarget.bytes, tx.sender.bytes)) {
1540
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1541
+ }
1542
+ state.senderApproved = true;
1543
+ }
1544
+ else if (scope === util_1.BIGINT_1) {
1545
+ if (state.payerApproved)
1546
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1547
+ if (!state.senderApproved)
1548
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1549
+ let account = await runState.stateManager.getAccount(frameTarget);
1550
+ if (account === undefined)
1551
+ account = new util_1.Account();
1552
+ if (account.balance < state.totalGasCost + state.totalBlobGasCost) {
1553
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1554
+ }
1555
+ account.nonce += util_1.BIGINT_1;
1556
+ account.balance -= state.totalGasCost + state.totalBlobGasCost;
1557
+ await runState.stateManager.putAccount(frameTarget, account);
1558
+ state.payerApproved = true;
1559
+ state.payer = frameTarget;
1560
+ }
1561
+ else if (scope === util_1.BIGINT_2) {
1562
+ if (state.senderApproved || state.payerApproved) {
1563
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1564
+ }
1565
+ if (!(0, util_1.equalsBytes)(frameTarget.bytes, tx.sender.bytes)) {
1566
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1567
+ }
1568
+ let account = await runState.stateManager.getAccount(frameTarget);
1569
+ if (account === undefined)
1570
+ account = new util_1.Account();
1571
+ if (account.balance < state.totalGasCost + state.totalBlobGasCost) {
1572
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1573
+ }
1574
+ state.senderApproved = true;
1575
+ account.nonce += util_1.BIGINT_1;
1576
+ account.balance -= state.totalGasCost + state.totalBlobGasCost;
1577
+ await runState.stateManager.putAccount(frameTarget, account);
1578
+ state.payerApproved = true;
1579
+ state.payer = frameTarget;
1580
+ }
1581
+ else {
1582
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.REVERT);
1583
+ }
1584
+ state.approveCalledInCurrentFrame = true;
1585
+ runState.interpreter.finish(new Uint8Array(0));
1586
+ },
1587
+ ],
1588
+ // 0xb0: TXPARAM
1589
+ [
1590
+ 0xb0,
1591
+ function (runState) {
1592
+ const [param, in2] = runState.stack.popN(2);
1593
+ const evm = runState.interpreter._evm;
1594
+ const fctx = evm.frameExecutionContext;
1595
+ if (fctx === undefined) {
1596
+ return (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1597
+ }
1598
+ const { tx, state } = fctx;
1599
+ const paramNum = Number(param);
1600
+ switch (paramNum) {
1601
+ case 0x00:
1602
+ if (in2 !== util_1.BIGINT_0)
1603
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1604
+ runState.stack.push(BigInt(tx.type));
1605
+ break;
1606
+ case 0x01:
1607
+ if (in2 !== util_1.BIGINT_0)
1608
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1609
+ runState.stack.push(tx.nonce);
1610
+ break;
1611
+ case 0x02:
1612
+ if (in2 !== util_1.BIGINT_0)
1613
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1614
+ runState.stack.push((0, util_1.bytesToBigInt)(tx.sender.bytes));
1615
+ break;
1616
+ case 0x03:
1617
+ if (in2 !== util_1.BIGINT_0)
1618
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1619
+ runState.stack.push(tx.maxPriorityFeePerGas);
1620
+ break;
1621
+ case 0x04:
1622
+ if (in2 !== util_1.BIGINT_0)
1623
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1624
+ runState.stack.push(tx.maxFeePerGas);
1625
+ break;
1626
+ case 0x05:
1627
+ if (in2 !== util_1.BIGINT_0)
1628
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1629
+ runState.stack.push(tx.maxFeePerBlobGas);
1630
+ break;
1631
+ case 0x06:
1632
+ if (in2 !== util_1.BIGINT_0)
1633
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1634
+ runState.stack.push(state.totalGasCost + state.totalBlobGasCost);
1635
+ break;
1636
+ case 0x07:
1637
+ if (in2 !== util_1.BIGINT_0)
1638
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1639
+ runState.stack.push(BigInt(tx.blobVersionedHashes.length));
1640
+ break;
1641
+ case 0x08:
1642
+ if (in2 !== util_1.BIGINT_0)
1643
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1644
+ runState.stack.push((0, util_1.bytesToBigInt)(tx.getHashedMessageToSign()));
1645
+ break;
1646
+ case 0x09:
1647
+ if (in2 !== util_1.BIGINT_0)
1648
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1649
+ runState.stack.push(BigInt(state.parsedFrames.length));
1650
+ break;
1651
+ case 0x10:
1652
+ if (in2 !== util_1.BIGINT_0)
1653
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1654
+ runState.stack.push(BigInt(state.currentFrameIndex));
1655
+ break;
1656
+ case 0x11: {
1657
+ const idx = Number(in2);
1658
+ if (idx >= state.parsedFrames.length)
1659
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1660
+ const t = state.parsedFrames[idx].target;
1661
+ runState.stack.push(t !== null ? (0, util_1.bytesToBigInt)(t.bytes) : (0, util_1.bytesToBigInt)(tx.sender.bytes));
1662
+ break;
1663
+ }
1664
+ case 0x12: {
1665
+ const idx = Number(in2);
1666
+ if (idx >= state.parsedFrames.length)
1667
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1668
+ runState.stack.push(state.parsedFrames[idx].gasLimit);
1669
+ break;
1670
+ }
1671
+ case 0x13: {
1672
+ const idx = Number(in2);
1673
+ if (idx >= state.parsedFrames.length)
1674
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1675
+ runState.stack.push(BigInt(state.parsedFrames[idx].mode));
1676
+ break;
1677
+ }
1678
+ case 0x14: {
1679
+ const idx = Number(in2);
1680
+ if (idx >= state.parsedFrames.length)
1681
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1682
+ const frame = state.parsedFrames[idx];
1683
+ if (frame.mode === 1) {
1684
+ runState.stack.push(util_1.BIGINT_0);
1685
+ }
1686
+ else {
1687
+ runState.stack.push(BigInt(frame.data.length));
1688
+ }
1689
+ break;
1690
+ }
1691
+ case 0x15: {
1692
+ const idx = Number(in2);
1693
+ if (idx >= state.parsedFrames.length)
1694
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1695
+ if (idx >= state.currentFrameIndex)
1696
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1697
+ const fr = state.frameResults[idx];
1698
+ if (fr === undefined)
1699
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1700
+ runState.stack.push(BigInt(fr.status));
1701
+ break;
1702
+ }
1703
+ default:
1704
+ (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1705
+ }
1706
+ },
1707
+ ],
1708
+ // 0xb1: FRAMEDATALOAD
1709
+ [
1710
+ 0xb1,
1711
+ function (runState) {
1712
+ const [offset, frameIndex] = runState.stack.popN(2);
1713
+ const evm = runState.interpreter._evm;
1714
+ const fctx = evm.frameExecutionContext;
1715
+ if (fctx === undefined)
1716
+ return (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1717
+ const { state } = fctx;
1718
+ const idx = Number(frameIndex);
1719
+ if (idx >= state.parsedFrames.length)
1720
+ return (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1721
+ const frame = state.parsedFrames[idx];
1722
+ if (frame.mode === 1) {
1723
+ runState.stack.push(util_1.BIGINT_0);
1724
+ return;
1725
+ }
1726
+ const i = Number(offset);
1727
+ let loaded = frame.data.subarray(i, i + 32);
1728
+ loaded = loaded.length > 0 ? loaded : Uint8Array.from([0]);
1729
+ let r = (0, util_1.bytesToBigInt)(loaded);
1730
+ if (loaded.length < 32) {
1731
+ r = r << (util_1.BIGINT_8 * BigInt(32 - loaded.length));
1732
+ }
1733
+ runState.stack.push(r);
1734
+ },
1735
+ ],
1736
+ // 0xb2: FRAMEDATACOPY
1737
+ [
1738
+ 0xb2,
1739
+ function (runState) {
1740
+ const [memOffset, dataOffset, length, frameIndex] = runState.stack.popN(4);
1741
+ const evm = runState.interpreter._evm;
1742
+ const fctx = evm.frameExecutionContext;
1743
+ if (fctx === undefined)
1744
+ return (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1745
+ const { state } = fctx;
1746
+ const idx = Number(frameIndex);
1747
+ if (idx >= state.parsedFrames.length)
1748
+ return (0, util_ts_2.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
1749
+ const frame = state.parsedFrames[idx];
1750
+ if (frame.mode === 1 || length === util_1.BIGINT_0) {
1751
+ return;
1752
+ }
1753
+ const data = (0, util_ts_2.getDataSlice)(frame.data, dataOffset, length);
1754
+ const memOffsetNum = Number(memOffset);
1755
+ const lengthNum = Number(length);
1756
+ runState.memory.extend(memOffsetNum, lengthNum);
1757
+ runState.memory.write(memOffsetNum, lengthNum, data);
1758
+ },
1759
+ ],
1760
+ ]);
1761
+ // Fill in rest of PUSHn, DUPn, SWAPn, LOGn for handlers
1762
+ const pushFn = exports.handlers.get(0x60);
1763
+ for (let i = 0x61; i <= 0x7f; i++) {
1764
+ exports.handlers.set(i, pushFn);
1765
+ }
1766
+ const dupFn = exports.handlers.get(0x80);
1767
+ for (let i = 0x81; i <= 0x8f; i++) {
1768
+ exports.handlers.set(i, dupFn);
1769
+ }
1770
+ const swapFn = exports.handlers.get(0x90);
1771
+ for (let i = 0x91; i <= 0x9f; i++) {
1772
+ exports.handlers.set(i, swapFn);
1773
+ }
1774
+ const logFn = exports.handlers.get(0xa0);
1775
+ for (let i = 0xa1; i <= 0xa4; i++) {
1776
+ exports.handlers.set(i, logFn);
1777
+ }
1778
+ //# sourceMappingURL=functions.js.map