-
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
Class-based promisified rewrite of runCall and runCode #483
Conversation
Great stuff! 😀 For clarification: despite not in the final form, do you already consider this consistent and ready for review and want to iterate after merge or do you want to first continue to work on this along this PR? |
I was thinking of doing more iterations in future PRs. This one provides the groundwork for more targeted PRs. |
Ok, will try to do a review soon. |
Starting slowly to grasp what's going on here! 😛 I'm totally impressed, how do you get the tests passing on such large PRs, do you have some certain strategy for that? Do you do incremental changes and run the tests again and again or do everything at once and then do fixes so long until tests pass again? |
(some typos, edited the post, should always post-read, especially since I often post from mobile these days) |
I think for each PR like this one I probably run the state tests like 20-30 times 😄 😄 it's different from case to case. For this PR some parts I did incrementally, but for the |
Side note, because I stumbled upon this here: we should really add tests for the events we emit (not sure how complex this is though) - at least on a basic level (minimally: event received, but surely better with one example of the data structure) since this is crucial part of the API. Seems you have thought on leaving the event on the VM (for now, I think later this will probably listened to on the EVM instance to reduce coupling), if I read the code correct. |
Yeah I left event emitting on the VM now. Agree it'd be better to have it decoupled. It'd also reduce dependency of these classes on Regarding tests, yes the events are not being tested directly. Although indirectly since they're being used in the tests when |
I was also already thinking if Stack, Memory, gas?, other? should have their own events, together with some thought-through event name taxonomy, maybe let's open a separate issue on this and discuss this and have this formed out. Side note: we should also think security questions along. |
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.
Ok, I've studied the code changes within this PR for over 2 hours now and while I can't guarantee for equivalency of every line of code I can say that this is a consistent rewrite preserving the existing functionality.
Would give this a go now to enable further refactoring work.
Thanks for taking the time Holger! :) |
Summary This PR introduces two classes
Interpreter
andLoop
as alternatives for respectivelyrunCall
andrunCode
. Most of the code is directly ported fromrunCall
andrunCode
and has been promisified without much modifications to the logic. Two auxiliary data typesMessage
andTxContext
have also been used to help with structuring the data. The PR doesn't change external API.More details:
runTx
instantiates anInterpreter
and callsexecuteMessage
on it, instead of callingrunCall
. ThereforerunCall
andrunCode
are removed from the main flow.runCall
andrunCode
also use the classes internally. I personally would prefer however at some point to drop them.runCall
inrunTx
andrunBlock
tests have been removed.(To be merged into #479)