-
Notifications
You must be signed in to change notification settings - Fork 746
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
Client: Add debugCode CLI option to generate Block execution script #1091
Conversation
…utable script to locally reproduce a VM block execution error
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
Hi @holgerd77, please check this PR #1093. I wanted to fetch the Geth JSON trace from an archive node, but sadly the eth dev ops node seems to be down. I am currently spinning up a Rinkeby archive node to get the trace. I'll upload it to the PR, so you can directly compare traces and see exactly at which point the two transactions diverge 😄 |
@jochem-brouwer great 👍 |
Will merge the debug stuff here (you can remove these debug files later when ready for review) so we can compare stack traces. |
@jochem-brouwer Ok. 😄 The CI got stuck at some point, I will merge this in by admin merge so that we can continue. |
|
No, not yet. You need to run the client with the new option |
(so this will work for all future debugging cases) |
const stateManager = new DefaultStateManager({ trie, common }) | ||
// Ensure we run on the right root | ||
stateManager.setStateRoot(Buffer.from('${( | ||
await execution.vm.stateManager.getStateRoot(true) |
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.
Ah yes, I should have spotted this earlier. You should get the state root of the previous block, and set the state managers' root to the root of that block. (Can probably just get it from vm's blockchain)
* Block: ${block.header.number} | ||
* Hardfork: ${execution.hardfork} | ||
* | ||
* Run with: DEBUG=vm:*:*,vm:*,-vm:ops:* ts-node [SCRIPT_NAME].ts |
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.
Should be export DEBUG
. If I don't use export then debug is not triggered.
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.
Ah, no, export should not be needed. Your are likely putting an &&
in between the commands?
Fixing #1090
I will actually not start working on new consensus bugs without adding a new meaningful debug tool. 😂
This one from this first commit 8d0afb7 is actually super-handy: it adds a new CLI option (mainly for internal usage, but of course also can be leveraged by consumers)
debugCode
which generates a dynamic script on a VM block execution failure.So this can be run with:
Script looks something like this and will be logged out to the console:
The script works out of the box, has all the correct values filled in (HFs, directories, block RLP) and can directly be copied over into the VM folder and then executed to reliably reproduce the error locally. 😄