-
Notifications
You must be signed in to change notification settings - Fork 790
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
VM Debugging #1080
VM Debugging #1080
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
100% in favor 🙂 |
…sed debugging (e.g. vm:ops:sstore)
Ok, have now also adding a debug logger for opcode based logging, this comes in really really handy, e.g. by just logging on all the |
Ok, I'll stop here, have also added some additional README instructions, this is now ready for review. 😄 @jochem-brouwer I'll try to add an additional Please note though that this is meant to be a general purpose debugging helper not necessarily (only) meant to be for our client runs but for all sorts of development and user activity (adding new opcodes, testing some functionality changes in the |
I have a few suggestions after just reading the readme: (can be in a subsequent PR)
In general what would also help is to verify our |
Hi Jochem, thanks for the suggestions, just an answer on the first one on a first round: If I get this right the operations address on a So e.g. vm:evm New message caller=0x147013436bd5c7def49a8e27c7fba8ac2b9dfe1f gasLimit=276872 to=0x9ca228250f9d8f86c23690074c2b96d5f5479f79 value=0 delegatecall=no +0ms
...and then closing with
vm:evm message checkpoint +96ms And for CREATE vm:evm New message caller=0x9ca228250f9d8f86c23690074c2b96d5f5479f79 gasLimit=243805 to= value=0 delegatecall=no +0ms
vm:evm Message CREATE execution (to undefined) +0ms
vm:evm Reduce sender (0x9ca228250f9d8f86c23690074c2b96d5f5479f79) balance (-> 40000000000000000) +1ms
vm:evm Generated CREATE contract address 0x8398ff6c618e9515468c1c4b198d53666cbe8462 +1ms
... and closing again with
vm:evm message checkpoint committed +0ms# |
Isn't point 2 (CALL / CREATE succeeds or not) included in the message results? 🤔 So e.g.: vm:evm Received message results gasUsed=106040 execResult: [ gasUsed=106040 exceptionError= returnValue=0000000000000000000000008398ff6c618e9515468c1c4b19... gasRefund=undefined ] +11ms |
if (!(nameLC in this.opDebuggers)) { | ||
this.opDebuggers[nameLC] = createDebugLogger(`vm:ops:${nameLC}`) | ||
} | ||
this.opDebuggers[nameLC](JSON.stringify(opTrace)) |
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.
This is really nice.
@jochem-brouwer You mentioned wanting to diff the geth / ethereumjs traces - would the most convenient thing be to have two files with JSONs of the respective traces?
If so debug has custom formatters which might help with this.
I think you could collect the steps into a trace and then write to ejs.vm.<txhash>.json
, when DEBUG=vm:savetrace
(or something)
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.
I would guess this is a good suggestion since comparing might be easiest on a per file basis with some linux CLI tools? @jochem-brouwer WDYT?
if (totalGas.sub(returnFee).lte(message.gasLimit)) { | ||
// we cannot pay the code deposit fee (but the deposit code actually did run) | ||
result = { ...result, ...COOGResult(totalGas.sub(returnFee)) } | ||
//result = { ...result, ...COOGResult(totalGas.sub(returnFee)) } | ||
result.gasUsed = totalGas.sub(returnFee) |
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.
Out of curiosity - this is a simplification e.g the result is already formatted as COOGResult?
Should COOGResult be removed in this PR?
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.
Oh oh oh, this actually sneaked in along doing debugging work for #1076, this shouldn't be here. 😏
@jochem-brouwer just to make you aware, can you please take care of this along working on #1081 respectively along some rebase since you are touching this code anyhow? Thanks!
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.
Looks great to me! 💯
I am so tired of VM debugging where it becomes extremely hard to follow on the control flow that I would want to add some debugging analog to what is done in the
devp2p
andclient
packages. This should make it significantly easier for us to track bugs like in #1076.This is a first test commit to gather some feedback, I would continue with this tomorrow if there is no significant objection or critics.
This produces output like the following if activated with e.g.
DEBUG=vm:tx ts-node test.ts
:(so only the upper part, JSON below is just a
console.log()
from the script run)