-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V4 tracker #479
V4 tracker #479
Conversation
* Bump version to 4 * Upgrade babel to 7, use transform-runtime plugin * evm: add Interpreter class (alternative to runCall) * evm: add Loop, a promisified version of runCode * evm: execute opFn calls through interpreter * evm/loop: mv pc range check out of hot loop * evm: use Interpreter and Loop in runCall and runCode * evm: use promisified state in interpreter and loop * evm/loop: break run into initRunState, runStep, handleOp, getOpHandler * evm/loop: minor fix * test: drop test cases assuming runCall * evm: use util.promisify package * evm: Mv some logic from executeMessage to private methods * Fix linting errors
* evm: add EEI class, use in opFns to get env values * evm: add selfdestruct, finish, revert and useGas to eei * evm: use storageStore, log eei methods in opFns * evm: add call method to eei, fix getAddress * evm: store selfdestructs in txRunState * evm: add callCode method to eei * evm: add callStatic, callDelegate methods to eei * eei: get isStatic from env * eei: refactor getting code in callCode, callDelegate * evm: refactor gas and output in call opFns * opFns: replace subGas with eei.useGas * eei: add create and create2 * evm: pass txRunState to loop in runCode * Fix linting error * Revert moving selfdestruct to txRunState
lib/evm/interpreter.js
Outdated
const PStateManager = require('../state/promisified') | ||
|
||
module.exports = class Interpreter { | ||
constructor (vm, txContext, block, storageReader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General note: I think every access through _vm here is an indicator that we have some misplacement of code or suboptimal structure.
* Detach list of precompiles from VM * evm: add getPrecompile method to interpreter
* Promisify runTx internals * Fix linting error
* Drop babel deps, add initial typescript config * Add prettier as dep, add format scripts * Mv bloom/index.js to bloom/index.ts * Migrate bloom to ts, limit its api to buffers * Mv lib/evm/stack.js to lib/evm/stack.ts * Migrate stack to ts, limit it to BN * Mv lib/evm/memory.js to lib/evm/memory.ts * Migrate evm memory to ts * Build:dist before coverage and api browser tests * Use tester dist flag for coverage tests
* Mv lib/state/promisified.js to lib/state/promisified.ts * Change state file types to ts * Migrate state module to ts
Looks like v4 release is on the horizon. Looking forward to it. Visiting the repo after long time & you have made awesome strides with ethereum VM in JS, making ethereum development very smooth and hopefully helping blockchain reach its true potential |
@startupgurukul thanks! 😀 |
* Change runCode filetype to ts * Migrate runCode to ts
* Change runCall filetype to ts * Migrate runCall to ts
* Change runTx filetype to ts * Migrate runTx to ts
* Change runBlock filetype to ts * Migrate runBlock to ts
* Change runBlockchain filetype to ts * Migrate runBlockchain to ts
* Use typescript configs * Fix tslint errors * Add prettier config * Fix formatting errors
@s1na if you feel comfortable with that I would suggest we try to do the Can you do some Let me know if you have any reservations, in doubt we are not completely bound to this date in any way and should rather make sure that the process is robust and we are confident with the integration work. |
That sounds good to me. Only would it be okay if I merge master into this branch, and later on we merge v4 into master (instead of rebase)? Due to the large number of commits, and because there are conflicts with master, rebasing can get difficult. I also took care to squash and merge the PRs, so we don't have tons of minor commits polluting the commit history. |
Ok, that sounds good! |
This pull request introduces 1 alert and fixes 1 when merging 074c0b1 into 068db32 - view on LGTM.com new alerts:
fixed alerts:
Comment posted by LGTM.com |
This pull request introduces 1 alert and fixes 1 when merging 00f99c2 into 068db32 - view on LGTM.com new alerts:
fixed alerts:
Comment posted by LGTM.com |
I have merged master into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooray!!! 🎉 🎉 🎉
This might still not be the optimal structure, but it will provide a much much more solid ground for all future work and comes with the most significant improvements this library has seen since I am involved in the project, thanks a lot Sina!!!
I've had a final look at all files, looks good.
Feel free to merge. 😄
Yay! can you also push the latest to npm pls |
@startupgurukul probably two days if nothing unexpected trigger a delay until a beta release on npm |
@s1na $ npm run testStatePetersburg
> ethereumjs-vm@3.0.0 testStatePetersburg
> npm run build:dist && node ./tests/tester -s --fork='Petersburg' --dist
> ethereumjs-config-build
+ exec tsc -p ./tsconfig.prod.json
TAP version 13
# GeneralStateTests
# file: addNonConst test: addNonConst
not ok 1 the state roots should match
---
operator: equal
expected: |-
'2d6da043f5cfd9fe3b1feab48970d855bf5570f5316492869642b228d8bed3ca'
actual: |-
'3c3f05727bc49ff870f5e780c5d00426d9c153de7e23443e70ec2da43d7f731c'
at: replenish (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:998:17)
...
not ok 2 the state roots should match
---
operator: equal
expected: |-
'e396abd1e58496cc86a1a5bc31af70c98926cceef3738e1189af4c226b61da15'
actual: |-
'3c3f05727bc49ff870f5e780c5d00426d9c153de7e23443e70ec2da43d7f731c'
at: replenish (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:998:17)
... Any idea? |
@holgerd77 Hmm 🤔 I tried on a fresh clone and the tests seem to pass. I wonder what could be the cause. Could you maybe add an to see if any error is occuring? |
@s1na Ah yes, great hint: + exec tsc -p ./tsconfig.prod.json
TAP version 13
# GeneralStateTests
# file: addNonConst test: addNonConst
TypeError: bloom_1.default is not a constructor
at txLogsBloom (/ethereumjs-vm/dist/runTx.js:250:17)
at VM.<anonymous> (/ethereumjs-vm/dist/runTx.js:157:37)
at step (/ethereumjs-vm/dist/runTx.js:32:23)
at Object.next (/ethereumjs-vm/dist/runTx.js:13:53)
at fulfilled (/ethereumjs-vm/dist/runTx.js:4:58)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
not ok 1 the state roots should match
---
operator: equal
expected: |-
'2d6da043f5cfd9fe3b1feab48970d855bf5570f5316492869642b228d8bed3ca'
actual: |-
'3c3f05727bc49ff870f5e780c5d00426d9c153de7e23443e70ec2da43d7f731c'
at: replenish (/node_modules/async/dist/async.js:998:17) |
Maybe the typescript compiler hasn't overwritten previously built files. Could you try removing |
Ah, yes, works: 😄 |
This PR tracks the changes planned for v4 (see #455). It also acts as a base branch for the pull requests, to prevent mixing experimental development in
master
. This'd allow us to maintain v3, fix bugs and do releases independently of the changes made here, and also have parallel release candidates for v4.