@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
package/README.md ADDED
@@ -0,0 +1,690 @@
1
+ # @ethereumjs/evm `v10`
2
+
3
+ [![NPM Package][evm-npm-badge]][evm-npm-link]
4
+ [![GitHub Issues][evm-issues-badge]][evm-issues-link]
5
+ [![Actions Status][evm-actions-badge]][evm-actions-link]
6
+ [![Code Coverage][evm-coverage-badge]][evm-coverage-link]
7
+ [![Discord][discord-badge]][discord-link]
8
+
9
+ | TypeScript implementation of the Ethereum EVM. |
10
+ | ---------------------------------------------- |
11
+
12
+ - 🦄 All hardforks up to **Osaka**
13
+ - 🌴 Tree-shakeable API
14
+ - 👷🏼 Controlled dependency set (7 external + `@Noble` crypto)
15
+ - 🧩 Flexible EIP on/off engine
16
+ - 🛠️ Custom precompiles
17
+ - 🚀 Built-in profiler
18
+ - 🪢 User-friendly colored debugging
19
+ - 🛵 422KB bundle size (110KB gzipped)
20
+ - 🏄🏾‍♂️ WASM-free default + Fully browser ready
21
+
22
+ ## Table of Contents
23
+
24
+ - [Installation](#installation)
25
+ - [Getting Started](#getting-started)
26
+ - [Examples](#examples)
27
+ - [Browser](#browser)
28
+ - [API](#api)
29
+ - [Architecture](#architecture)
30
+ - [Supported Hardforks](#supported-hardforks)
31
+ - [Supported EIPs](#supported-eips)
32
+ - [Precompiles](#precompiles)
33
+ - [Events](#events)
34
+ - [Understanding the EVM](#understanding-the-evm)
35
+ - [Profiling the EVM](#profiling-the-evm)
36
+ - [Development](#development)
37
+ - [EthereumJS](#ethereumjs)
38
+ - [License](#license)
39
+
40
+
41
+ ## Installation
42
+
43
+ To obtain the latest version, simply require the project using `npm`:
44
+
45
+ ```shell
46
+ npm install @ethereumjs/evm
47
+ ```
48
+
49
+ This package provides the core Ethereum Virtual Machine (EVM) implementation which is capable of executing EVM-compatible bytecode. The package has been extracted from the [@ethereumjs/vm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm) package along the VM `v6` release.
50
+
51
+ **Note:** Starting with the Dencun hardfork `EIP-4844` related functionality has become an integrated part of the EVM functionality with the activation of the point evaluation precompile. For this precompile to work a separate installation of the KZG library is necessary (we decided not to bundle due to large bundle sizes), see [KZG Setup](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx/README.md#kzg-setup) for instructions.
52
+
53
+ ## Getting Started
54
+
55
+ ### Basic
56
+
57
+ The following is the simplest example for an EVM instantiation with reasonable defaults for state and blockchain information (like blockhashes):
58
+
59
+ ```ts
60
+ // ./examples/simple.ts
61
+
62
+ import { createEVM } from '@ethereumjs/evm'
63
+ import { hexToBytes } from '@ethereumjs/util'
64
+
65
+ const main = async () => {
66
+ const evm = await createEVM()
67
+ const res = await evm.runCode({ code: hexToBytes('0x6001') }) // PUSH1 01 -- simple bytecode to push 1 onto the stack
68
+ console.log(res.executionGasUsed) // 3n
69
+ }
70
+
71
+ void main()
72
+ ```
73
+
74
+ ### Blockchain, State and Events
75
+
76
+ If you want the EVM to run against a specific state, you need an `@ethereumjs/statemanager`. An `@ethereumjs/blockchain` instance can be passed in to provide access to external interface information like a blockhash:
77
+
78
+ ```ts
79
+ // ./examples/withBlockchain.ts
80
+
81
+ import { createBlockchain } from '@ethereumjs/blockchain'
82
+ import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
83
+ import { createEVM } from '@ethereumjs/evm'
84
+ import { MerkleStateManager } from '@ethereumjs/statemanager'
85
+ import { bytesToHex, hexToBytes } from '@ethereumjs/util'
86
+
87
+ import type { PrefixedHexString } from '@ethereumjs/util'
88
+
89
+ const main = async () => {
90
+ const common = new Common({ chain: Mainnet, hardfork: Hardfork.Shanghai })
91
+ const stateManager = new MerkleStateManager()
92
+ const blockchain = await createBlockchain()
93
+
94
+ const evm = await createEVM({
95
+ common,
96
+ stateManager,
97
+ blockchain,
98
+ })
99
+
100
+ const STOP = '00'
101
+ const ADD = '01'
102
+ const PUSH1 = '60'
103
+
104
+ // Note that numbers added are hex values, so '20' would be '32' as decimal e.g.
105
+ const code = [PUSH1, '03', PUSH1, '05', ADD, STOP]
106
+
107
+ evm.events.on('step', function (data) {
108
+ // Note that data.stack is not immutable, i.e. it is a reference to the vm's internal stack object
109
+ console.log(`Opcode: ${data.opcode.name}\tStack: ${data.stack}`)
110
+ })
111
+
112
+ const results = await evm.runCode({
113
+ code: hexToBytes(('0x' + code.join('')) as PrefixedHexString),
114
+ gasLimit: BigInt(0xffff),
115
+ })
116
+
117
+ console.log(`Returned: ${bytesToHex(results.returnValue)}`)
118
+ console.log(`gasUsed: ${results.executionGasUsed.toString()}`)
119
+ }
120
+
121
+ void main()
122
+ ```
123
+
124
+ Additionally, this example shows how to use events to listen to the inner workings and procedural updates
125
+ (`step` event) of the EVM.
126
+
127
+ ### WASM Crypto Support
128
+
129
+ This library by default uses JavaScript implementations for the basic standard crypto primitives like hashing or signature verification (for included txs). See `@ethereumjs/common` [README](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/common) for instructions on how to replace them with, e.g., a more performant WASM implementation by using a shared `common` instance.
130
+
131
+ ## Examples
132
+
133
+ See the [examples](./examples/) folder for different meaningful examples on how to use the EVM package and invoke certain aspects of it, e.g. running a bytecode snippet, listening to events, or to activate an EVM with a certain EIP for experimental purposes.
134
+
135
+ ## Browser
136
+
137
+ We provide hybrid ESM/CJS builds for all our libraries. With the v10 breaking release round from Spring 2025, all libraries are "pure-JS" by default and we have eliminated all hard-wired WASM code. Additionally we have substantially lowered the bundle sizes, reduced the number of dependencies, and cut out all usages of Node.js-specific primitives (like the Node.js event emitter).
138
+
139
+ It is easily possible to run a browser build of one of the EthereumJS libraries within a modern browser using the provided ESM build. For a setup example see [./examples/browser.html](./examples/browser.html).
140
+
141
+ ## API
142
+
143
+ ### Docs
144
+
145
+ For documentation on `EVM` instantiation, exposed API and emitted `events` see generated [API docs](./docs/README.md).
146
+
147
+ ### Hybrid CJS/ESM Builds
148
+
149
+ With the breaking releases from Summer 2023 we have started to ship our libraries with both CommonJS (`cjs` folder) and ESM builds (`esm` folder), see `package.json` for the detailed setup.
150
+
151
+ If you use an ES6-style `import` in your code files, the ESM build will be used:
152
+
153
+ ```ts
154
+ import { EthereumJSClass } from '@ethereumjs/[PACKAGE_NAME]'
155
+ ```
156
+
157
+ If you use Node.js specific `require`, the CJS build will be used:
158
+
159
+ ```ts
160
+ const { EthereumJSClass } = require('@ethereumjs/[PACKAGE_NAME]')
161
+ ```
162
+
163
+ Using ESM will give you additional advantages over CJS beyond browser usage like static code analysis / Tree Shaking which CJS can not provide.
164
+
165
+ ## Architecture
166
+
167
+ ### VM/EVM Relation
168
+
169
+ This package contains the inner Ethereum Virtual Machine core functionality which was included in the [@ethereumjs/vm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm) package up to v5 and has been extracted along the v6 release.
170
+
171
+ This will make it easier to customize the inner EVM, which can now be passed as an optional argument to the outer `VM` instance.
172
+
173
+ ### State and Blockchain Information
174
+
175
+ For the EVM to properly work it needs access to a respective execution environment (to e.g. request on information like block hashes) as well as the connection to an outer account and contract state.
176
+
177
+ With the v2 release EVM, VM and StateManager have been substantially reworked in this regard, see PR [#2649](https://github.com/ethereumjs/ethereumjs-monorepo/pull/2649/) and PR [#2702](https://github.com/ethereumjs/ethereumjs-monorepo/pull/2702) for further deepening context.
178
+
179
+ The interfaces (in a non-TypeScript sense) between these packages have been simplified and the `EEI` package has been completely removed. Most of the EEI related logic is now either handled internally or more generic functionality being taken over by the `@ethereumjs/statemanager` package.
180
+
181
+ This allows for both a standalone EVM instantiation with reasonable defaults as well as for a simplified EVM -> VM passing if a customized EVM is needed.
182
+
183
+ ## Supported Hardforks
184
+
185
+ The EthereumJS EVM implements all hardforks from `Frontier` (`chainstart`) up to the latest active mainnet hardfork.
186
+
187
+ Currently the following hardfork rules are supported:
188
+
189
+ - `chainstart` (a.k.a. Frontier)
190
+ - `homestead`
191
+ - `tangerineWhistle`
192
+ - `spuriousDragon`
193
+ - `byzantium`
194
+ - `constantinople`
195
+ - `petersburg`
196
+ - `istanbul`
197
+ - `muirGlacier` (only `mainnet`)
198
+ - `berlin` (`v5.2.0`+)
199
+ - `london` (`v5.4.0`+)
200
+ - `arrowGlacier` (only `mainnet`) (`v5.6.0`+)
201
+ - `merge`
202
+ - `shanghai` (`v2.0.0`+)
203
+ - `cancun` (`v2.0.0`+)
204
+ - `prague` (`v10`+)
205
+
206
+ Default: `prague` (taken from `Common.DEFAULT_HARDFORK`)
207
+
208
+ A specific hardfork EVM ruleset can be activated by passing in the hardfork
209
+ along the `Common` instance to the outer `@ethereumjs/vm` instance.
210
+
211
+ ## Supported EIPs
212
+
213
+ If you want to activate an EIP not currently active on the hardfork your `common` instance is set to, it is possible to individually activate EIP support in the EVM by specifying the desired EIPs using the `eips` property in your `CommonOpts` setup, e.g.:
214
+
215
+ ```ts
216
+ // ./examples/eips.ts
217
+
218
+ import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
219
+ import { createEVM } from '@ethereumjs/evm'
220
+
221
+ const main = async () => {
222
+ const common = new Common({ chain: Mainnet, hardfork: Hardfork.Cancun, eips: [7702] })
223
+ const evm = await createEVM({ common })
224
+ console.log(
225
+ `EIP 7702 is active in isolation on top of the Cancun HF - ${evm.common.isActivatedEIP(7702)}`,
226
+ )
227
+ }
228
+
229
+ void main()
230
+
231
+ ```
232
+
233
+ Currently supported EIPs:
234
+
235
+ - [EIP-1153](https://eips.ethereum.org/EIPS/eip-1153) - Transient storage opcodes (Cancun)
236
+ - [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) - Fee market change for ETH 1.0 chain
237
+ - [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) - Precompile for BLS12-381 curve operations (Prague)
238
+ - [EIP-2565](https://eips.ethereum.org/EIPS/eip-2565) - ModExp gas cost
239
+ - [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) - Transaction Types
240
+ - [EIP-2935](https://eips.ethereum.org/EIPS/eip-2935) - Serve historical block hashes in state (Prague)
241
+ - [EIP-2929](https://eips.ethereum.org/EIPS/eip-2929) - gas cost increases for state access opcodes
242
+ - [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) - Optional access list tx type
243
+ - [EIP-3074](https://eips.ethereum.org/EIPS/eip-3074) - AUTH and AUTHCALL opcodes
244
+ - [EIP-3198](https://eips.ethereum.org/EIPS/eip-3198) - Base fee Opcode
245
+ - [EIP-3529](https://eips.ethereum.org/EIPS/eip-3529) - Reduction in refunds
246
+ - [EIP-3541](https://eips.ethereum.org/EIPS/eip-3541) - Reject new contracts starting with the 0xEF byte
247
+ - [EIP-3554](https://eips.ethereum.org/EIPS/eip-3554) - Difficulty Bomb Delay to December 2021 (only PoW networks)
248
+ - [EIP-3607](https://eips.ethereum.org/EIPS/eip-3607) - Reject transactions from senders with deployed code
249
+ - [EIP-3651](https://eips.ethereum.org/EIPS/eip-3651) - Warm COINBASE (Shanghai)
250
+ - [EIP-3675](https://eips.ethereum.org/EIPS/eip-3675) - Upgrade consensus to Proof-of-Stake
251
+ - [EIP-3855](https://eips.ethereum.org/EIPS/eip-3855) - Push0 opcode (Shanghai)
252
+ - [EIP-3860](https://eips.ethereum.org/EIPS/eip-3860) - Limit and meter initcode (Shanghai)
253
+ - [EIP-4345](https://eips.ethereum.org/EIPS/eip-4345) - Difficulty Bomb Delay to June 2022
254
+ - [EIP-4399](https://eips.ethereum.org/EIPS/eip-4399) - Supplant DIFFICULTY opcode with PREVRANDAO (Merge)
255
+ - [EIP-4788](https://eips.ethereum.org/EIPS/eip-4788) - Beacon block root in the EVM (Cancun)
256
+ - [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) - Shard Blob Transactions (Cancun)
257
+ - [EIP-4895](https://eips.ethereum.org/EIPS/eip-4895) - Beacon chain push withdrawals as operations (Shanghai)
258
+ - [EIP-5133](https://eips.ethereum.org/EIPS/eip-5133) - Delaying Difficulty Bomb to mid-September 2022 (Gray Glacier)
259
+ - [EIP-5656](https://eips.ethereum.org/EIPS/eip-5656) - MCOPY - Memory copying instruction (Cancun)
260
+ - [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110) - Supply validator deposits on chain (Prague)
261
+ - [EIP-6780](https://eips.ethereum.org/EIPS/eip-6780) - SELFDESTRUCT only in same transaction (Cancun)
262
+ - [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002) - Execution layer triggerable exits (Prague)
263
+ - [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251) - Increase the MAX_EFFECTIVE_BALANCE (Prague)
264
+ - [EIP-7516](https://eips.ethereum.org/EIPS/eip-7516) - BLOBBASEFEE opcode (Cancun)
265
+ - [EIP-7623](https://eips.ethereum.org/EIPS/eip-7623) - Increase calldata cost (Prague)
266
+ - [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685) - General purpose execution layer requests (Prague)
267
+ - [EIP-7691](https://eips.ethereum.org/EIPS/eip-7691) - Blob throughput increase (Prague)
268
+ - [EIP-7692](https://eips.ethereum.org/EIPS/eip-7692) - EVM Object Format (EOF) v1 (`experimental`)
269
+ - [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) - Set EOA account code (Prague)
270
+ - [EIP-7709](https://eips.ethereum.org/EIPS/eip-7709) - Read BLOCKHASH from storage and update cost (Verkle)
271
+
272
+ ### EIP-4844 Shard Blob Transactions Support (Cancun)
273
+
274
+ This library supports the blob transaction type introduced with [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844). EIP-4844 comes with a dedicated opcode `BLOBHASH` and has added a new point evaluation precompile at address `0x0a`.
275
+
276
+ **Note:** Usage of the point evaluation precompile needs a manual KZG library installation and global initialization, see [KZG Setup](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx/README.md#kzg-setup) for instructions.
277
+
278
+ ## Precompiles
279
+
280
+ This library supports all EVM precompiles up to the `Prague` hardfork.
281
+
282
+ In our `examples` folder we provide a helper function for simple direct precompile runs in the `precompiles` folder.
283
+
284
+ This is an example of a simple precompile run (BLS12_G1ADD precompile):
285
+
286
+ ```ts
287
+ // ./examples/precompiles/0b-bls12-g1add.ts
288
+
289
+ import { runPrecompile } from './util.ts'
290
+
291
+ const main = async () => {
292
+ // BLS12_G1ADD precompile (address 0xb)
293
+ // Data taken from test/eips/precompiles/bls/add_G1_bls.json
294
+ // Input: G1 and G2 points (each 128 bytes = 256 hex characters)
295
+ const g1Point =
296
+ '0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1'
297
+ const g2Point =
298
+ '00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21'
299
+ const data = `0x${g1Point}${g2Point}`
300
+
301
+ await runPrecompile('BLS12_G1ADD', '0xb', data)
302
+ }
303
+
304
+ void main()
305
+
306
+ ```
307
+
308
+
309
+ ### EIP-2537 BLS Precompiles (Prague)
310
+
311
+ Starting with `v10` the EVM supports the BLS precompiles introduced with [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) in its final version introduced with the `Prague` hardfork. These precompiles run natively using the [@noble/curves](https://github.com/paulmillr/noble-curves) library (❤️ to `@paulmillr`!).
312
+
313
+ An alternative WASM implementation (using [bls-wasm](https://github.com/herumi/bls-wasm)) can be optionally used like this if needed for performance reasons:
314
+
315
+ ```ts
316
+ import { EVM, MCLBLS } from '@ethereumjs/evm'
317
+
318
+ const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Prague })
319
+ await mcl.init(mcl.BLS12_381)
320
+ const mclbls = new MCLBLS(mcl)
321
+ const evm = await createEVM({ common, bls })
322
+ ```
323
+
324
+ ### EIP-7823/EIP-7883 MODEXP Precompile (Osaka)
325
+
326
+ The Osaka hardfork introduces some behavioral changes with [EIP-7823](https://eips.ethereum.org/EIPS/eip-7823) as well as a gas cost increase for the MODEXP precompile with [EIP-7883](https://eips.ethereum.org/EIPS/eip-7883).
327
+
328
+ You can use the following example as a starting point to compare on the changes between hardforks:
329
+
330
+ ```ts
331
+ // ./examples/precompiles/05-modexp.ts
332
+
333
+ import { Hardfork } from '@ethereumjs/common'
334
+ import { runPrecompile } from './util.ts'
335
+
336
+ const main = async () => {
337
+ // MODEXP precompile (address 0x05)
338
+ // Calculate: 2^3 mod 5 = 8 mod 5 = 3
339
+ //
340
+ // Input format:
341
+ // - First 32 bytes: base length (0x01 = 1 byte)
342
+ // - Next 32 bytes: exponent length (0x01 = 1 byte)
343
+ // - Next 32 bytes: modulus length (0x01 = 1 byte)
344
+ // - Next 1 byte: base value (0x02 = 2)
345
+ // - Next 1 byte: exponent value (0x03 = 3)
346
+ // - Next 1 byte: modulus value (0x05 = 5)
347
+
348
+ const baseLen = '0000000000000000000000000000000000000000000000000000000000000001' // 1 byte
349
+ const expLen = '0000000000000000000000000000000000000000000000000000000000000001' // 1 byte
350
+ const modLen = '0000000000000000000000000000000000000000000000000000000000000001' // 1 byte
351
+ const base = '02' // 2
352
+ const exponent = '03' // 3
353
+ const modulus = '05' // 5
354
+
355
+ const data = `0x${baseLen}${expLen}${modLen}${base}${exponent}${modulus}`
356
+
357
+ await runPrecompile('MODEXP', '0x05', data)
358
+ await runPrecompile('MODEXP', '0x05', data, Hardfork.Cancun)
359
+ }
360
+
361
+ void main()
362
+
363
+ ```
364
+
365
+ ### EIP-7951 Precompile for secp256r1 Curve Support (Osaka)
366
+
367
+ The Osaka hardfork introduces a new precompile for secp256r1 curve support with [EIP-7951](https://eips.ethereum.org/EIPS/eip-7951).
368
+
369
+ The following example code allows you to generate input values for the precompile using Noble Curves [v2.0.0](https://github.com/paulmillr/noble-curves/releases/tag/2.0.0) or later.
370
+
371
+ ```ts
372
+ // No direct examples integration (library version not taken in as a dependency)
373
+ import { p256 } from '@noble/curves/nist.js'
374
+ import { sha256 } from '@noble/hashes/sha2.js'
375
+ import { bigIntToHex, bytesToHex } from '@ethereumjs/util'
376
+
377
+ // Private/public key
378
+ const { secretKey, publicKey } = p256.keygen()
379
+ const pointPubKey = p256.Point.fromBytes(publicKey)
380
+ const pointX = bigIntToHex(pointPubKey.X)
381
+ const pointY = bigIntToHex(pointPubKey.Y)
382
+
383
+ // Message (hash) / signature
384
+ const msg = new TextEncoder().encode('Hello Fusaka!')
385
+ const sig = p256.sign(msg, secretKey, { lowS: false, prehash: false })
386
+ const msgHash = bytesToHex(sha256(msg))
387
+ const sigR = bytesToHex(sig).substring(2, 64 + 2)
388
+ const sigS = bytesToHex(sig).substring(64 + 2)
389
+ ```
390
+
391
+ ### Custom Precompiles
392
+
393
+ The EVM supports registering custom precompiles at arbitrary addresses. Custom precompiles can **add** new precompiles, **override** existing ones, or **delete** built-in precompiles.
394
+
395
+ Pass an array of `CustomPrecompile` entries to the `customPrecompiles` option when creating the EVM:
396
+
397
+ ```ts
398
+ // ./examples/precompiles/customPrecompile.ts
399
+
400
+ import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
401
+ import { createEVM } from '@ethereumjs/evm'
402
+ import {
403
+ bigIntToBytes,
404
+ bytesToBigInt,
405
+ bytesToHex,
406
+ createAddressFromString,
407
+ setLengthLeft,
408
+ } from '@ethereumjs/util'
409
+
410
+ import type { ExecResult, PrecompileInput } from '@ethereumjs/evm'
411
+
412
+ // Custom precompile that adds two 32-byte big-endian unsigned integers (mod 2^256).
413
+ const ADDITION_GAS = 15n
414
+
415
+ function additionPrecompile(input: PrecompileInput): ExecResult {
416
+ const a = bytesToBigInt(input.data.subarray(0, 32))
417
+ const b = bytesToBigInt(input.data.subarray(32, 64))
418
+ const sum = (a + b) % 2n ** 256n
419
+ return {
420
+ executionGasUsed: ADDITION_GAS,
421
+ returnValue: setLengthLeft(bigIntToBytes(sum), 32),
422
+ }
423
+ }
424
+
425
+ const main = async () => {
426
+ const common = new Common({ chain: Mainnet, hardfork: Hardfork.Prague })
427
+ const ADDRESS = '0x000000000000000000000000000000000000ff01'
428
+
429
+ // Register the custom precompile with a hex string address
430
+ const evm = await createEVM({
431
+ common,
432
+ customPrecompiles: [{ address: ADDRESS, function: additionPrecompile }],
433
+ })
434
+
435
+ // Verify it is registered
436
+ const fn = evm.getPrecompile(ADDRESS)
437
+ console.log(`Precompile registered at ${ADDRESS}: ${fn !== undefined}`)
438
+
439
+ // Build call data: two 32-byte values (7 + 35)
440
+ const a = setLengthLeft(bigIntToBytes(7n), 32)
441
+ const b = setLengthLeft(bigIntToBytes(35n), 32)
442
+ const callData = new Uint8Array(64)
443
+ callData.set(a, 0)
444
+ callData.set(b, 32)
445
+
446
+ // Execute via runCall
447
+ const result = await evm.runCall({
448
+ to: createAddressFromString(ADDRESS),
449
+ gasLimit: BigInt(30000),
450
+ data: callData,
451
+ })
452
+
453
+ console.log('--------------------------------')
454
+ console.log('Custom Addition Precompile')
455
+ console.log(`Input : 7 + 35`)
456
+ console.log(`Result : ${bytesToBigInt(result.execResult.returnValue)} (${bytesToHex(result.execResult.returnValue)})`)
457
+ console.log(`Gas used : ${result.execResult.executionGasUsed}`)
458
+ console.log('--------------------------------')
459
+ }
460
+
461
+ void main()
462
+
463
+ ```
464
+
465
+ The address for custom precompiles can be specified as either an `Address` instance or a `0x`-prefixed hex string. All relevant types (`CustomPrecompile`, `AddPrecompile`, `DeletePrecompile`, `PrecompileFunc`, `PrecompileInput`) are exported from `@ethereumjs/evm`.
466
+
467
+ You can use `evm.getPrecompile(address)` to retrieve a registered precompile function at any address (works for both built-in and custom precompiles):
468
+
469
+ ```ts
470
+ const fn = evm.getPrecompile('0x0000000000000000000000000000000000000002') // SHA256
471
+ const custom = evm.getPrecompile('0x000000000000000000000000000000000000ff01') // custom
472
+ ```
473
+
474
+ To **override** a built-in precompile, register a custom precompile at the same address. To **delete** a precompile, pass an entry with only the `address` field (no `function`):
475
+
476
+ ```ts
477
+ const evm = await createEVM({
478
+ customPrecompiles: [
479
+ { address: '0x0000000000000000000000000000000000000002' }, // deletes SHA256
480
+ ],
481
+ })
482
+ ```
483
+
484
+ ## Events
485
+
486
+ ### Tracing Events
487
+
488
+ The EVM emits events that support async listeners (using [EventEmitter3](https://github.com/primus/eventemitter3)).
489
+
490
+ You can subscribe to the following events:
491
+
492
+ - `beforeMessage`: Emits a `Message` right after running it.
493
+ - `afterMessage`: Emits an `EVMResult` right after running a message.
494
+ - `step`: Emits an `InterpreterStep` right before running an EVM step.
495
+ - `newContract`: Emits a `NewContractEvent` right before creating a contract. This event contains the deployment code, not the deployed code, as the creation message may not return such a code.
496
+
497
+ #### Event listeners
498
+
499
+ You can perform asynchronous operations from within an event handler
500
+ and prevent the EVM from continuing until they finish.
501
+
502
+ If subscribing to events with an async listener, specify the second
503
+ parameter of your listener as a `resolve` function that must be called once your listener code has finished.
504
+
505
+ See below for example usage:
506
+
507
+ ```ts
508
+ // ./examples/eventListener.ts#L7-L14
509
+
510
+ evm.events.on('beforeMessage', (event) => {
511
+ console.log('synchronous listener to beforeMessage', event)
512
+ })
513
+ evm.events.on('afterMessage', (event, resolve) => {
514
+ console.log('asynchronous listener to beforeMessage', event)
515
+ // we need to call resolve() to avoid the event listener hanging
516
+ resolve?.()
517
+ })
518
+ ```
519
+
520
+ If an exception is passed to that function, or thrown from within the
521
+ handler or a function called by it, the exception will bubble into the
522
+ EVM and interrupt it, possibly corrupting its state. It's strongly
523
+ recommended not to do that.
524
+
525
+ ## Understanding the EVM
526
+
527
+ If you want to understand your EVM runs we have added a hierarchically structured list of debug loggers for your convenience which can be activated in arbitrary combinations. We also use these loggers internally for development and testing. These loggers use the [debug](https://github.com/visionmedia/debug) library and can be activated on the CLI with `DEBUG=ethjs,[Logger Selection] node [Your Script to Run].js` and produce output like the following:
528
+
529
+ ![EthereumJS EVM Debug Logger](./debug.png?raw=true)
530
+
531
+ The following loggers are currently available:
532
+
533
+ | Logger | Description |
534
+ | ---------------------------------- | --------------------------------------------------- |
535
+ | `evm:evm` | EVM control flow, CALL or CREATE message execution |
536
+ | `evm:gas` | EVM gas logger |
537
+ | `evm:precompiles` | EVM precompiles logger |
538
+ | `evm:journal` | EVM journal logger |
539
+ | `evm:ops` | Opcode traces |
540
+ | `evm:ops:[Lower-case opcode name]` | Traces on a specific opcode |
541
+
542
+ Here are some examples of useful logger combinations.
543
+
544
+ Run one specific logger:
545
+
546
+ ```shell
547
+ DEBUG=ethjs,evm tsx test.ts
548
+ ```
549
+
550
+ Run all loggers currently available:
551
+
552
+ ```shell
553
+ DEBUG=ethjs,evm:*,evm:*:* tsx test.ts
554
+ ```
555
+
556
+ Run only the gas loggers:
557
+
558
+ ```shell
559
+ DEBUG=ethjs,evm:*:gas tsx test.ts
560
+ ```
561
+
562
+ Excluding the ops logger:
563
+
564
+ ```shell
565
+ DEBUG=ethjs,evm:*,evm:*:*,-evm:ops tsx test.ts
566
+ ```
567
+
568
+ Run some specific loggers including a logger specifically logging the `SSTORE` executions from the EVM (this is from the screenshot above):
569
+
570
+ ```shell
571
+ DEBUG=ethjs,evm,evm:ops:sstore,evm:*:gas tsx test.ts
572
+ ```
573
+
574
+ `ethjs` **must** be included in the `DEBUG` environment variables to enable **any** logs.
575
+ Additional log selections can be added with a comma separated list (no spaces). Logs with extensions can be enabled with a colon `:`, and `*` can be used to include all extensions.
576
+
577
+ `DEBUG=ethjs,evm:journal,evm:ops:* npx vitest test/runCall.spec.ts`
578
+
579
+ ### Internal Structure
580
+
581
+ The EVM processes state changes through a hierarchical flow of execution:
582
+
583
+ #### Top Level: Message Execution (`runCall`)
584
+ The `runCall` method handles the execution of messages, which can be either contract calls or contract creations:
585
+ - Creates a checkpoint in the state
586
+ - Sets up the execution environment (block context, transaction origin, etc.)
587
+ - Manages account nonce updates
588
+ - Handles value transfers between accounts
589
+ - Delegates to either `_executeCall` or `_executeCreate` based on whether the message has a `to` address
590
+ - **Both `_executeCall` and `_executeCreate` call into `runInterpreter` to actually execute the bytecode**
591
+ - Processes any errors or exceptions
592
+ - Manages selfdestruct sets and created contract addresses
593
+ - Commits or reverts state changes based on execution result
594
+ - Triggers events (`beforeMessage`, `afterMessage`)
595
+
596
+ #### Code Execution (`runCode` / `runInterpreter`)
597
+ The `runCode` method is a helper for directly running EVM bytecode (e.g., for testing or utility purposes) without the full message/transaction context:
598
+ - Sets up a minimal message context for code execution
599
+ - **Directly calls `runInterpreter` to execute the provided bytecode**
600
+ - Does not go through the full message handling logic of `runCall`
601
+
602
+ The `runInterpreter` method is used by both `runCall` (via `_executeCall`/`_executeCreate`) and `runCode` to process the actual bytecode.
603
+
604
+ #### Bytecode Processing (Interpreter)
605
+ The Interpreter class is the core bytecode processor:
606
+ - Manages execution state (program counter, stack, memory, gas)
607
+ - Executes a loop that:
608
+ - Analyzes jump destinations
609
+ - Fetches the next opcode
610
+ - Calculates gas costs (static and dynamic)
611
+ - Executes the opcode handler
612
+ - Updates the program counter
613
+ - Emits step events for debugging/tracing
614
+ - Handles stack, memory, and storage operations
615
+ - Processes call and creation operations by delegating back to the EVM
616
+
617
+ #### Opcode Functions
618
+ Each opcode has an associated handler function that:
619
+ - Validates inputs
620
+ - Calculates dynamic gas costs
621
+ - Performs the opcode's logic (stack operations, memory operations, etc.)
622
+ - Updates the EVM state
623
+ - The program counter is incremented in between the execution of the gas handler and opcode logic handler functions, this should be considered e.g. if parsing immediate input parameters
624
+ - Special opcodes like `CALL`, `CREATE`, `DELEGATECALL` create a new message and call back to the EVM's `runCall` method
625
+
626
+ #### Journal and State Management
627
+ - State changes are tracked in a journal system
628
+ - The journal supports checkpointing and reversion
629
+ - Transient storage (EIP-1153) has its own checkpoint mechanism
630
+ - When a message completes successfully, changes are committed to the state
631
+ - On failure (exceptions), changes are reverted
632
+
633
+ This layered architecture provides separation of concerns while allowing for the complex interactions needed to execute smart contracts on the Ethereum platform.
634
+
635
+ ## Profiling the EVM
636
+
637
+ The EthereumJS EVM comes with built-in profiling capabilities to detect performance bottlenecks and to generally support the targeted evolution of the JavaScript EVM performance.
638
+
639
+ While the EVM has a dedicated `profiler` setting to activate, the profiler is most useful when run through the EthereumJS [client](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/client) since this gives the most realistic conditions providing both real-world txs and a meaningful state size.
640
+
641
+ To repeatedly run the EVM profiler within the client sync the client on mainnet or a larger testnet to the desired block. Then the profiler should be run without sync (to not distort the results) by using the `--executeBlocks` and the `--vmProfileBlocks` (or `--vmProfileTxs`) flags in conjunction like:
642
+
643
+ ```shell
644
+ npm run client:start -- --sync=none --vmProfileBlocks --executeBlocks=962720
645
+ ```
646
+
647
+ This will give a profile output like the following:
648
+
649
+ ![EthereumJS EVM Profiler](./profiler.png?raw=true)
650
+
651
+ The `total (ms)` column gives you a good overview what takes the most significant amount of time, to be put in relation with the number of calls.
652
+
653
+ The number to optimize for is the `Mgas/s` value. This value indicates how much gas (being a measure for the computational cost for an opcode) can be processed by the second.
654
+
655
+ A good measure to putting this relation with is by taking both the Ethereum gas limit (the max amount of "computation" per block) and the time/slot into account. With a gas limit of 30 Mio and a 12 sec slot time this leads to a following (very) minimum `Mgas/s` value:
656
+
657
+ ```shell
658
+ 30M / 12 sec = 2.5 Million gas per second
659
+ ```
660
+
661
+ Note that this is nevertheless a very theoretical value but pretty valuable for some first rough orientation though.
662
+
663
+ Another note: profiler results for at least some opcodes are heavily distorted, first to mention the `SSTORE` opcode where the major "cost" occurs after block execution on checkpoint commit, which is not taken into account by the profiler.
664
+
665
+ Generally all results should rather encourage and need "self thinking" 😋 and are not suited to be blindly taken over without a deeper understanding/grasping of the underlying measurement conditions.
666
+
667
+ Happy EVM Profiling! 🎉 🤩
668
+
669
+ ## Development
670
+
671
+ See [@ethereumjs/vm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm) README.
672
+
673
+ ## EthereumJS
674
+
675
+ The `EthereumJS` GitHub organization and its repositories are managed by members of the former Ethereum Foundation JavaScript team and the broader Ethereum community. If you want to join for work or carry out improvements on the libraries see the [developer docs](../../DEVELOPER.md) for an overview of current standards and tools and review our [code of conduct](../../CODE_OF_CONDUCT.md).
676
+
677
+ ## License
678
+
679
+ [MPL-2.0](<https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)>)
680
+
681
+ [discord-badge]: https://img.shields.io/static/v1?logo=discord&label=discord&message=Join&color=blue
682
+ [discord-link]: https://discord.gg/TNwARpR
683
+ [evm-npm-badge]: https://img.shields.io/npm/v/@ethereumjs/evm.svg
684
+ [evm-npm-link]: https://www.npmjs.com/package/@ethereumjs/evm
685
+ [evm-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-monorepo/package:%20evm?label=issues
686
+ [evm-issues-link]: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A"package%3A+evm"
687
+ [evm-actions-badge]: https://github.com/ethereumjs/ethereumjs-monorepo/workflows/EVM/badge.svg
688
+ [evm-actions-link]: https://github.com/ethereumjs/ethereumjs-monorepo/actions?query=workflow%3A%22EVM%22
689
+ [evm-coverage-badge]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/branch/master/graph/badge.svg?flag=evm
690
+ [evm-coverage-link]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/tree/master/packages/evm