@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,131 @@
1
+ import { EthereumJSErrorWithoutCode, bytesToHex } from '@feelyourprotocol/util'
2
+
3
+ import type { Address } from '@feelyourprotocol/util'
4
+ import type { TransientStorageInterface } from './types.ts'
5
+
6
+ type TransientStorageCurrent = Map<string, Map<string, Uint8Array>>
7
+
8
+ interface TransientStorageModification {
9
+ addr: string
10
+ key: string
11
+ prevValue: Uint8Array
12
+ }
13
+
14
+ type TransientStorageJournal = TransientStorageModification[]
15
+
16
+ export class TransientStorage implements TransientStorageInterface {
17
+ /**
18
+ * The current values of the transient storage, keyed by contract address and then slot
19
+ */
20
+ private _storage: TransientStorageCurrent = new Map()
21
+ /**
22
+ * Each change to storage is recorded in the journal. This is never cleared.
23
+ */
24
+ private _changeJournal: TransientStorageJournal = []
25
+ /**
26
+ * The length of the journal at the beginning of each call in the call stack.
27
+ */
28
+ private _indices: number[] = [0]
29
+
30
+ /**
31
+ * Get the value for the given address and key
32
+ * @param addr the address for which transient storage is accessed
33
+ * @param key the key of the address to get
34
+ */
35
+ public get(addr: Address, key: Uint8Array): Uint8Array {
36
+ const map = this._storage.get(addr.toString())
37
+ if (!map) {
38
+ return new Uint8Array(32)
39
+ }
40
+ const value = map.get(bytesToHex(key))
41
+ if (!value) {
42
+ return new Uint8Array(32)
43
+ }
44
+ return value
45
+ }
46
+
47
+ /**
48
+ * Put the given value for the address and key
49
+ * @param addr the address of the contract for which the key is being set
50
+ * @param key the slot to set for the address
51
+ * @param value the new value of the transient storage slot to set
52
+ */
53
+ public put(addr: Address, key: Uint8Array, value: Uint8Array) {
54
+ if (key.length !== 32) {
55
+ throw EthereumJSErrorWithoutCode('Transient storage key must be 32 bytes long')
56
+ }
57
+
58
+ if (value.length > 32) {
59
+ throw EthereumJSErrorWithoutCode('Transient storage value cannot be longer than 32 bytes')
60
+ }
61
+
62
+ const addrString = addr.toString()
63
+ if (!this._storage.has(addrString)) {
64
+ this._storage.set(addrString, new Map())
65
+ }
66
+ const map = this._storage.get(addrString)!
67
+
68
+ const keyStr = bytesToHex(key)
69
+ const prevValue = map.get(keyStr) ?? new Uint8Array(32)
70
+
71
+ this._changeJournal.push({
72
+ addr: addrString,
73
+ key: keyStr,
74
+ prevValue,
75
+ })
76
+
77
+ map.set(keyStr, value)
78
+ }
79
+
80
+ /**
81
+ * Commit all the changes since the last checkpoint
82
+ */
83
+ public commit(): void {
84
+ if (this._indices.length === 0) throw EthereumJSErrorWithoutCode('Nothing to commit')
85
+ // by discarding the length of the array from the last time checkpoint was called, all changes are included in the last stack
86
+ this._indices.pop()
87
+ }
88
+
89
+ /**
90
+ * To be called whenever entering a new context. If revert is called after checkpoint, all changes after the latest checkpoint are reverted.
91
+ */
92
+ public checkpoint(): void {
93
+ this._indices.push(this._changeJournal.length)
94
+ }
95
+
96
+ /**
97
+ * Revert transient storage to the last checkpoint
98
+ */
99
+ public revert() {
100
+ const lastCheckpoint = this._indices.pop()
101
+ if (typeof lastCheckpoint === 'undefined') throw EthereumJSErrorWithoutCode('Nothing to revert')
102
+
103
+ for (let i = this._changeJournal.length - 1; i >= lastCheckpoint; i--) {
104
+ const { key, prevValue, addr } = this._changeJournal[i]
105
+ this._storage.get(addr)!.set(key, prevValue)
106
+ }
107
+ this._changeJournal.splice(lastCheckpoint, this._changeJournal.length - lastCheckpoint)
108
+ }
109
+
110
+ /**
111
+ * Create a JSON representation of the current transient storage state
112
+ */
113
+ public toJSON(): { [address: string]: { [key: string]: string } } {
114
+ const result: { [address: string]: { [key: string]: string } } = {}
115
+ for (const [address, map] of this._storage.entries()) {
116
+ result[address] = {}
117
+ for (const [key, value] of map.entries()) {
118
+ result[address][key] = bytesToHex(value)
119
+ }
120
+ }
121
+ return result
122
+ }
123
+
124
+ /**
125
+ * Clear transient storage state.
126
+ */
127
+ public clear(): void {
128
+ this._storage = new Map()
129
+ this._changeJournal = []
130
+ }
131
+ }
package/src/types.ts ADDED
@@ -0,0 +1,538 @@
1
+ import type {
2
+ BinaryTreeAccessWitnessInterface,
3
+ Common,
4
+ ParamsDict,
5
+ StateManagerInterface,
6
+ } from '@feelyourprotocol/common'
7
+ import type { Account, Address, BlockLevelAccessList, PrefixedHexString } from '@feelyourprotocol/util'
8
+ import type { EventEmitter } from 'eventemitter3'
9
+ import type { BinaryTreeAccessWitness } from './binaryTreeAccessWitness.ts'
10
+ import type { EOFContainer } from './eof/container.ts'
11
+ import type { EVMError } from './errors.ts'
12
+ import type { FrameExecutionContext } from './frameContext.ts'
13
+ import type { InterpreterStep, RunState } from './interpreter.ts'
14
+ import type { Message } from './message.ts'
15
+ import type { AsyncDynamicGasHandler, SyncDynamicGasHandler } from './opcodes/gas.ts'
16
+ import type { OpHandler } from './opcodes/index.ts'
17
+ import type { CustomPrecompile } from './precompiles/index.ts'
18
+ import type { PrecompileFunc } from './precompiles/types.ts'
19
+
20
+ export type DeleteOpcode = {
21
+ opcode: number
22
+ }
23
+
24
+ export type AddOpcode = {
25
+ opcode: number
26
+ opcodeName: string
27
+ baseFee: number
28
+ gasFunction?: AsyncDynamicGasHandler | SyncDynamicGasHandler
29
+ logicFunction: OpHandler
30
+ }
31
+
32
+ export type SelfdestructMap = Map<PrefixedHexString, PrefixedHexString>
33
+
34
+ export type CustomOpcode = AddOpcode | DeleteOpcode
35
+
36
+ // Typeguard
37
+ export function isAddOpcode(customOpcode: CustomOpcode): customOpcode is AddOpcode {
38
+ return (
39
+ 'opcode' in customOpcode &&
40
+ 'opcodeName' in customOpcode &&
41
+ 'baseFee' in customOpcode &&
42
+ 'logicFunction' in customOpcode
43
+ )
44
+ }
45
+
46
+ /**
47
+ * Base options for the `EVM.runCode()` / `EVM.runCall()` method.
48
+ */
49
+ interface EVMRunOpts {
50
+ /**
51
+ * The `block` the `tx` belongs to. If omitted a default blank block will be used.
52
+ */
53
+ block?: Block
54
+ /**
55
+ * The gas price for the call. Defaults to `0`
56
+ */
57
+ gasPrice?: bigint
58
+ /**
59
+ * The address where the call originated from. Defaults to the zero address.
60
+ */
61
+ origin?: Address
62
+ /**
63
+ * The address that ran this code (`msg.sender`). Defaults to the zero address.
64
+ */
65
+ caller?: Address
66
+ /**
67
+ * The EVM code to run.
68
+ */
69
+ code?: Uint8Array
70
+ /**
71
+ * The input data.
72
+ */
73
+ data?: Uint8Array
74
+ /**
75
+ * The gas limit for the call. Defaults to `16777215` (`0xffffff`)
76
+ */
77
+ gasLimit?: bigint
78
+ /**
79
+ * The value in ether that is being sent to `opts.address`. Defaults to `0`
80
+ */
81
+ value?: bigint
82
+ /**
83
+ * The call depth. Defaults to `0`
84
+ */
85
+ depth?: number
86
+ /**
87
+ * If the call should be executed statically. Defaults to false.
88
+ */
89
+ isStatic?: boolean
90
+ /**
91
+ * Selfdestructed addresses mapped to their beneficiary. Defaults to the empty map.
92
+ */
93
+ selfdestruct?: SelfdestructMap
94
+ /**
95
+ * The address of the account that is executing this code (`address(this)`). Defaults to the zero address.
96
+ */
97
+ to?: Address
98
+ /**
99
+ * Versioned hashes for each blob in a blob transaction
100
+ */
101
+ blobVersionedHashes?: PrefixedHexString[]
102
+ }
103
+
104
+ export interface EVMRunCodeOpts extends EVMRunOpts {
105
+ /*
106
+ * The initial program counter. Defaults to `0`
107
+ */
108
+ pc?: number
109
+ }
110
+
111
+ /**
112
+ * Options for running a call (or create) operation with `EVM.runCall()`
113
+ */
114
+ export interface EVMRunCallOpts extends EVMRunOpts {
115
+ /**
116
+ * If the code location is a precompile.
117
+ */
118
+ isCompiled?: boolean
119
+ /**
120
+ * An optional salt to pass to CREATE2.
121
+ */
122
+ salt?: Uint8Array
123
+ /**
124
+ * Created addresses in current context. Used in EIP 6780
125
+ */
126
+ createdAddresses?: Set<PrefixedHexString>
127
+ /**
128
+ * Skip balance checks if true. If caller balance is less than message value,
129
+ * sets balance to message value to ensure execution doesn't fail.
130
+ */
131
+ skipBalance?: boolean
132
+ /**
133
+ * If the call is a DELEGATECALL. Defaults to false.
134
+ */
135
+ delegatecall?: boolean
136
+ /**
137
+ * Refund counter. Defaults to `0`
138
+ */
139
+ gasRefund?: bigint
140
+ /**
141
+ * Optionally pass in an already-built message.
142
+ */
143
+ message?: Message
144
+
145
+ accessWitness?: BinaryTreeAccessWitnessInterface
146
+ }
147
+
148
+ interface NewContractEvent {
149
+ address: Address
150
+ // The deployment code
151
+ code: Uint8Array
152
+ }
153
+
154
+ export type EVMEvent = {
155
+ newContract: (data: NewContractEvent, resolve?: (result?: any) => void) => void
156
+ beforeMessage: (data: Message, resolve?: (result?: any) => void) => void
157
+ afterMessage: (data: EVMResult, resolve?: (result?: any) => void) => void
158
+ step: (data: InterpreterStep, resolve?: (result?: any) => void) => void
159
+ }
160
+
161
+ export interface EVMInterface {
162
+ common: Common
163
+ journal: {
164
+ commit(): Promise<void>
165
+ revert(): Promise<void>
166
+ checkpoint(): Promise<void>
167
+ cleanJournal(): void
168
+ cleanup(): Promise<void>
169
+ putAccount(address: Address, account: Account): Promise<void>
170
+ deleteAccount(address: Address): Promise<void>
171
+ accessList?: Map<string, Set<string>>
172
+ preimages?: Map<PrefixedHexString, Uint8Array>
173
+ addAlwaysWarmAddress(address: string, addToAccessList?: boolean): void
174
+ addAlwaysWarmSlot(address: string, slot: string, addToAccessList?: boolean): void
175
+ startReportingAccessList(): void
176
+ startReportingPreimages?(): void
177
+ }
178
+ stateManager: StateManagerInterface
179
+ precompiles: Map<string, PrecompileFunc>
180
+ getPrecompile?(address: Address | PrefixedHexString): PrecompileFunc | undefined
181
+ runCall(opts: EVMRunCallOpts): Promise<EVMResult>
182
+ runCode(opts: EVMRunCodeOpts): Promise<ExecResult>
183
+ events?: EventEmitter<EVMEvent>
184
+ binaryTreeAccessWitness?: BinaryTreeAccessWitness
185
+ systemBinaryTreeAccessWitness?: BinaryTreeAccessWitness
186
+ blockLevelAccessList?: BlockLevelAccessList
187
+ frameExecutionContext?: FrameExecutionContext
188
+ }
189
+
190
+ export type EVMProfilerOpts = {
191
+ enabled: boolean
192
+ // extra options here (such as use X hardfork for gas)
193
+ }
194
+
195
+ /**
196
+ * Options for instantiating a {@link EVM}.
197
+ */
198
+ export interface EVMOpts {
199
+ /**
200
+ * Use a {@link Common} instance for EVM instantiation.
201
+ *
202
+ * ### Supported EIPs
203
+ *
204
+ * - [EIP-1153](https://eips.ethereum.org/EIPS/eip-1153) - Transient storage opcodes (Cancun)
205
+ * - [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) - Fee market change for ETH 1.0 chain
206
+ * - [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) - Precompile for BLS12-381 curve operations (Prague)
207
+ * - [EIP-2565](https://eips.ethereum.org/EIPS/eip-2565) - ModExp gas cost
208
+ * - [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) - Typed Transaction Envelope
209
+ * - [EIP-2935](https://eips.ethereum.org/EIPS/eip-2935) - Serve historical block hashes from state (Prague)
210
+ * - [EIP-2929](https://eips.ethereum.org/EIPS/eip-2929) - gas cost increases for state access opcodes
211
+ * - [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) - Optional access list tx type
212
+ * - [EIP-3074](https://eips.ethereum.org/EIPS/eip-3074) - AUTH and AUTHCALL opcodes
213
+ * - [EIP-3198](https://eips.ethereum.org/EIPS/eip-3198) - Base fee Opcode
214
+ * - [EIP-3529](https://eips.ethereum.org/EIPS/eip-3529) - Reduction in refunds
215
+ * - [EIP-3541](https://eips.ethereum.org/EIPS/eip-3541) - Reject new contracts starting with the 0xEF byte
216
+ * - [EIP-3554](https://eips.ethereum.org/EIPS/eip-3554) - Difficulty Bomb Delay to December 2021 (only PoW networks)
217
+ * - [EIP-3607](https://eips.ethereum.org/EIPS/eip-3607) - Reject transactions from senders with deployed code
218
+ * - [EIP-3651](https://eips.ethereum.org/EIPS/eip-3651) - Warm COINBASE (Shanghai)
219
+ * - [EIP-3675](https://eips.ethereum.org/EIPS/eip-3675) - Upgrade consensus to Proof-of-Stake
220
+ * - [EIP-3855](https://eips.ethereum.org/EIPS/eip-3855) - Push0 opcode (Shanghai)
221
+ * - [EIP-3860](https://eips.ethereum.org/EIPS/eip-3860) - Limit and meter initcode (Shanghai)
222
+ * - [EIP-4345](https://eips.ethereum.org/EIPS/eip-4345) - Difficulty Bomb Delay to June 2022
223
+ * - [EIP-4399](https://eips.ethereum.org/EIPS/eip-4399) - Supplant DIFFICULTY opcode with PREVRANDAO (Merge)
224
+ * - [EIP-4788](https://eips.ethereum.org/EIPS/eip-4788) - Beacon block root in the EVM (Cancun)
225
+ * - [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) - Shard Blob Transactions (Cancun)
226
+ * - [EIP-4895](https://eips.ethereum.org/EIPS/eip-4895) - Beacon chain push withdrawals as operations (Shanghai)
227
+ * - [EIP-5133](https://eips.ethereum.org/EIPS/eip-5133) - Delaying Difficulty Bomb to mid-September 2022 (Gray Glacier)
228
+ * - [EIP-5656](https://eips.ethereum.org/EIPS/eip-5656) - MCOPY - Memory copying instruction (Cancun)
229
+ * - [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110) - Supply validator deposits on chain (Prague)
230
+ * - [EIP-6780](https://eips.ethereum.org/EIPS/eip-6780) - SELFDESTRUCT only in same transaction (Cancun)
231
+ * - [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002) - Execution layer triggerable exits (Prague)
232
+ * - [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251) - Increase the MAX_EFFECTIVE_BALANCE (Prague)
233
+ * - [EIP-7516](https://eips.ethereum.org/EIPS/eip-7516) - BLOBBASEFEE opcode (Cancun)
234
+ * - [EIP-7623](https://eips.ethereum.org/EIPS/eip-7623) - Increase calldata cost (Prague)
235
+ * - [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685) - General purpose execution layer requests (Prague)
236
+ * - [EIP-7691](https://eips.ethereum.org/EIPS/eip-7691) - Blob throughput increase (Prague)
237
+ * - [EIP-7692](https://eips.ethereum.org/EIPS/eip-7692) - EVM Object Format (EOF) v1 (`experimental`)
238
+ * - [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) - Set EOA account code (Prague)
239
+ * - [EIP-7709](https://eips.ethereum.org/EIPS/eip-7709) - Read BLOCKHASH from storage and update cost (Verkle)
240
+ * - [EIP-7934](https://eips.ethereum.org/EIPS/eip-7934) - RLP Execution Block Size Limit
241
+ *
242
+ * *Annotations:*
243
+ *
244
+ * - `experimental`: behaviour can change on patch versions
245
+ */
246
+ common?: Common
247
+
248
+ /**
249
+ * Allows unlimited contract sizes while debugging. By setting this to `true`, the check for
250
+ * contract size limit of 24KB (see [EIP-170](https://git.io/vxZkK)) is bypassed.
251
+ *
252
+ * Default: `false` [ONLY set to `true` during debugging]
253
+ */
254
+ allowUnlimitedContractSize?: boolean
255
+
256
+ /**
257
+ * Allows unlimited contract code-size init while debugging. This (partially) disables EIP-3860.
258
+ * Gas cost for initcode size analysis will still be charged. Use with caution.
259
+ */
260
+ allowUnlimitedInitCodeSize?: boolean
261
+
262
+ /**
263
+ * EVM parameters sorted by EIP can be found in the exported `paramsEVM` dictionary,
264
+ * which is internally passed to the associated `@feelyourprotocol/common` instance which
265
+ * manages parameter selection based on the hardfork and EIP settings.
266
+ *
267
+ * This option allows providing a custom set of parameters. Note that parameters
268
+ * get fully overwritten, so you need to extend the default parameter dict
269
+ * to provide the full parameter set.
270
+ *
271
+ * It is recommended to deep-clone the params object for this to avoid side effects:
272
+ *
273
+ * ```ts
274
+ * const params = JSON.parse(JSON.stringify(paramsEVM))
275
+ * params['1679']['bn254AddGas'] = 100 // 150
276
+ * ```
277
+ */
278
+ params?: ParamsDict
279
+
280
+ /**
281
+ * Override or add custom opcodes to the EVM instruction set
282
+ * These custom opcodes are EIP-agnostic and are always statically added
283
+ * To delete an opcode, add an entry of format `{opcode: number}`. This will delete that opcode from the EVM.
284
+ * If this opcode is then used in the EVM, the `INVALID` opcode would instead be used.
285
+ * To add an opcode, add an entry of the following format:
286
+ * {
287
+ * // The opcode number which will invoke the custom opcode logic
288
+ * opcode: number
289
+ * // The name of the opcode (as seen in the `step` event)
290
+ * opcodeName: string
291
+ * // The base fee of the opcode
292
+ * baseFee: number
293
+ * // If the opcode charges dynamic gas, add this here. To charge the gas, use the `i` methods of the BN, to update the charged gas
294
+ * gasFunction?: function(runState: RunState, gas: BN, common: Common)
295
+ * // The logic of the opcode which holds the logic of changing the current state
296
+ * logicFunction: function(runState: RunState)
297
+ * }
298
+ * Note: gasFunction and logicFunction can both be async or synchronous functions
299
+ */
300
+ customOpcodes?: CustomOpcode[]
301
+
302
+ /*
303
+ * Adds custom precompiles. This is hardfork-agnostic: these precompiles are always activated
304
+ * If only an address is given, the precompile is deleted
305
+ * If an address and a `PrecompileFunc` is given, this precompile is inserted or overridden
306
+ * Please ensure `PrecompileFunc` has exactly one parameter `input: PrecompileInput`
307
+ */
308
+ customPrecompiles?: CustomPrecompile[]
309
+
310
+ /**
311
+ * For the EIP-2537 BLS Precompiles, the native JS `ethereum-cryptography` (`@noble/curves`)
312
+ * https://github.com/ethereum/js-ethereum-cryptography BLS12-381 curve implementation
313
+ * is used (see `noble.ts` file in the `precompiles/bls12_381/` folder).
314
+ *
315
+ * To use an alternative implementation this option can be used by passing
316
+ * in a wrapper implementation integrating the desired library and adhering
317
+ * to the `EVMBLSInterface` specification.
318
+ *
319
+ * An interface for the MCL WASM implementation https://github.com/herumi/mcl-wasm
320
+ * is shipped with this library which can be used as follows (with `mcl-wasm` being
321
+ * explicitly added to the set of dependencies):
322
+ *
323
+ * ```ts
324
+ * import * as mcl from 'mcl-wasm'
325
+ *
326
+ * await mcl.init(mcl.BLS12_381)
327
+ * const evm = await createEVM({ bls: new MCLBLS(mcl) })
328
+ * ```
329
+ */
330
+ bls?: EVMBLSInterface
331
+
332
+ /**
333
+ * For the EIP-196/EIP-197 BN254 (alt_BN128) EC precompiles, the native JS `ethereum-cryptography`
334
+ * (`@noble/curves`) https://github.com/ethereum/js-ethereum-cryptography BN254 curve implementation
335
+ * is used (see `noble.ts` file in the `precompiles/bn254/` folder).
336
+ *
337
+ * To use an alternative implementation this option can be used by passing
338
+ * in a wrapper implementation integrating the desired library and adhering
339
+ * to the `EVMBN254Interface` specification.
340
+ *
341
+ * An interface for a WASM wrapper https://github.com/ethereumjs/rustbn.js around the
342
+ * Parity fork of the Zcash bn pairing cryptography library is shipped with this library
343
+ * which can be used as follows (with `rustbn.js` being explicitly added to the set of
344
+ * dependencies):
345
+ *
346
+ * ```ts
347
+ * import { initRustBN } from 'rustbn-wasm'
348
+ *
349
+ * const bn254 = await initRustBN()
350
+ * const evm = await createEVM({ bn254: new RustBN254(bn254) })
351
+ * ```
352
+ */
353
+ bn254?: EVMBN254Interface
354
+
355
+ /*
356
+ * The EVM comes with a basic dependency-minimized `SimpleStateManager` implementation
357
+ * which serves most code execution use cases and which is included in the
358
+ * `@feelyourprotocol/statemanager` package.
359
+ *
360
+ * The `@feelyourprotocol/statemanager` package also provides a variety of state manager
361
+ * implementations for different needs (MPT-tree backed, RPC, experimental binary tree)
362
+ * which can be used by this option as a replacement.
363
+ */
364
+ stateManager?: StateManagerInterface
365
+
366
+ /**
367
+ * The EVM comes with a basic mock blockchain interface and implementation for
368
+ * non-block containing use cases.
369
+ *
370
+ * For block-containing setups use the full blockchain implementation from the
371
+ * `@feelyourprotocol/blockchain package.
372
+ */
373
+ blockchain?: EVMMockBlockchainInterface
374
+
375
+ /**
376
+ *
377
+ */
378
+ profiler?: EVMProfilerOpts
379
+
380
+ /**
381
+ * If EIP-7928 is activated, a block-level access list can be provided here.
382
+ * If not provided, a new one will be created if EIP-7928 is activated
383
+ */
384
+ blockLevelAccessList?: BlockLevelAccessList
385
+
386
+ /**
387
+ * When running the EVM with PoA consensus, the `cliqueSigner` function from the `@feelyourprotocol/block` class
388
+ * must be provided along with a `BlockHeader` so that the coinbase can be correctly retrieved when the
389
+ * `Interpreter.getBlockCoinbase` method is called.
390
+ */
391
+ cliqueSigner?: (header: Block['header']) => Address
392
+ }
393
+
394
+ /**
395
+ * Result of executing a message via the {@link EVM}.
396
+ */
397
+ export interface EVMResult {
398
+ /**
399
+ * Address of created account during transaction, if any
400
+ */
401
+ createdAddress?: Address
402
+ /**
403
+ * Contains the results from running the code, if any, as described in {@link runCode}
404
+ */
405
+ execResult: ExecResult
406
+ }
407
+
408
+ /**
409
+ * Result of executing a call via the {@link EVM}.
410
+ */
411
+ export interface ExecResult {
412
+ runState?: RunState
413
+ /**
414
+ * Description of the exception, if any occurred
415
+ */
416
+ exceptionError?: EVMError
417
+ /**
418
+ * Amount of gas left
419
+ */
420
+ gas?: bigint
421
+ /**
422
+ * Amount of gas the code used to run
423
+ */
424
+ executionGasUsed: bigint
425
+ /**
426
+ * Return value from the contract
427
+ */
428
+ returnValue: Uint8Array
429
+ /**
430
+ * Array of logs that the contract emitted
431
+ */
432
+ logs?: Log[]
433
+ /**
434
+ * Selfdestructed accounts mapped to their beneficiary
435
+ */
436
+ selfdestruct?: SelfdestructMap
437
+ /**
438
+ * Map of addresses which were created (used in EIP 6780)
439
+ */
440
+ createdAddresses?: Set<PrefixedHexString>
441
+ /**
442
+ * The gas refund counter
443
+ */
444
+ gasRefund?: bigint
445
+ /**
446
+ * Amount of blob gas consumed by the transaction
447
+ */
448
+ blobGasUsed?: bigint
449
+ }
450
+
451
+ /**
452
+ * High level wrapper for BLS libraries used
453
+ * for the BLS precompiles
454
+ */
455
+ export type EVMBLSInterface = {
456
+ init?(): void
457
+ addG1(input: Uint8Array): Uint8Array
458
+ addG2(input: Uint8Array): Uint8Array
459
+ mapFPtoG1(input: Uint8Array): Uint8Array
460
+ mapFP2toG2(input: Uint8Array): Uint8Array
461
+ msmG1(input: Uint8Array): Uint8Array
462
+ msmG2(input: Uint8Array): Uint8Array
463
+ pairingCheck(input: Uint8Array): Uint8Array
464
+ }
465
+
466
+ /**
467
+ * High level wrapper for BN254 (alt_BN128) libraries
468
+ * used for the BN254 (alt_BN128) EC precompiles
469
+ */
470
+ export type EVMBN254Interface = {
471
+ add: (input: Uint8Array) => Uint8Array
472
+ mul: (input: Uint8Array) => Uint8Array
473
+ pairing: (input: Uint8Array) => Uint8Array
474
+ }
475
+
476
+ /**
477
+ * Log that the contract emits.
478
+ */
479
+ export type Log = [address: Uint8Array, topics: Uint8Array[], data: Uint8Array]
480
+
481
+ export type Block = {
482
+ header: {
483
+ number: bigint
484
+ coinbase: Address
485
+ timestamp: bigint
486
+ difficulty: bigint
487
+ prevRandao: Uint8Array
488
+ gasLimit: bigint
489
+ baseFeePerGas?: bigint
490
+ slotNumber?: bigint
491
+ getBlobGasPrice(): bigint | undefined
492
+ }
493
+ }
494
+
495
+ export interface TransientStorageInterface {
496
+ get(addr: Address, key: Uint8Array): Uint8Array
497
+ put(addr: Address, key: Uint8Array, value: Uint8Array): void
498
+ commit(): void
499
+ checkpoint(): void
500
+ revert(): void
501
+ toJSON(): { [address: string]: { [key: string]: string } }
502
+ clear(): void
503
+ }
504
+
505
+ export type EVMMockBlock = {
506
+ hash(): Uint8Array
507
+ }
508
+
509
+ export interface EVMMockBlockchainInterface {
510
+ getBlock(blockId: number): Promise<EVMMockBlock>
511
+ putBlock(block: EVMMockBlock): Promise<void>
512
+ shallowCopy(): EVMMockBlockchainInterface
513
+ }
514
+
515
+ export class EVMMockBlockchain implements EVMMockBlockchainInterface {
516
+ async getBlock() {
517
+ return {
518
+ hash() {
519
+ return new Uint8Array(32)
520
+ },
521
+ }
522
+ }
523
+ async putBlock() {}
524
+ shallowCopy() {
525
+ return this
526
+ }
527
+ }
528
+
529
+ // EOF type which holds the execution-related data for EOF
530
+ export type EOFEnv = {
531
+ container: EOFContainer
532
+ eofRunState: {
533
+ returnStack: number[]
534
+ }
535
+ }
536
+
537
+ // EIP-7702 flag: if contract code starts with these 3 bytes, it is a 7702-delegated EOA
538
+ export const DELEGATION_7702_FLAG = new Uint8Array([0xef, 0x01, 0x00])