-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: complete vm and statediff tracers #3529
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
Conversation
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 still need to respect the config here, but the rest of the file doesnt seem to use the config yet + logging
gakonst
left a comment
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.
good start - supportive of this. thank you for taking the time. anything else you'd like to add before us taking a deeper look on this?
mattsse
left a comment
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.
tysm for taking this on, very much appreciated.
I can follow how this works but I have a few requests.
| holder.push(idx); | ||
| for child_idx in nodes[idx].children.iter() { | ||
| Self::get_all_children(nodes, holder, *child_idx); | ||
| } |
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.
please no recursive calls, this can be written iteratively
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.
yup - context is these overflow for deep traces
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.
got it....
I also use recursion to create the VmTrace, I should also try to change that?
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.
but for now will work on making the CallTraceNodeWalker iterative :)
mattsse
left a comment
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.
great progress, left a few suggestions
btw spec_opcode_gas is public and you should be able to import it
|
sweeet so i was able to make everything iterative it seems! I think is ready for more review now while i can start on testing soon (or vice versa) also on the also on opcode thing i dont think i can get it because its not used here and no pub mod |
mattsse
left a comment
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 looks pretty good already.
left a few nits
there are a few chunks that are commented out,
what is missing here?
I agree we can start testing this
| for child_idx in curr.children.iter() { | ||
| self.queue.push_back(*child_idx); | ||
| } |
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.
can use .extend here
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.
oooo nice thx fixed
| }; | ||
| use revm::interpreter::opcode; | ||
| use std::collections::VecDeque; | ||
|
|
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.
| let instructions = loop { | ||
| match current.children.get(child_idx) { | ||
| Some(child) => { | ||
| child_idx_stack.push(child_idx + 1); |
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.
why the +1 here?
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 to read the next child when it gets popped from the stack, i could pop from the stack then increment, not sure which u prefer
| breadth_first_addresses: I, | ||
| trace: &mut VmTrace, |
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.
nit: swap the order here, it's better to have iter types as last argument
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.
fixed
| curr_ref.code = match db_acc.code { | ||
| Some(code) => code.bytecode.into(), | ||
| None => Default::default(), | ||
| }; |
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 think we need to use code_by_hash here if the code_hash is not KECCAK_EMPTY and code is none
because code is stored separately
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.
fixed
| opcode::CREATE | ||
| | opcode::CREATE2 | ||
| | opcode::DELEGATECALL | ||
| | opcode::CALL | ||
| | opcode::STATICCALL | ||
| | opcode::CALLCODE => { |
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'd like to make this a helper function
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 think this comment was to be on the function vm_trace in src/tracing/builder/parity? sorry i realize my fmt touched this when it shouldnt have
if u can confirm i can fix
getting the spec gas costs from revm ^, and there is a
thats it! |
mattsse
left a comment
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.
sorry for the delay, lost the notification -.-
again, tysm for doing this!!
this is awesome.
let's try this and then run a few more checks/diffs
|
|
||
| VmInstruction { | ||
| pc: step.pc, | ||
| cost: 0, // todo::n |
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.
what to do here?
this is the gas cost of the opcode?
we should be able to get this via spec_opcode_gas
I think we need to get the spec id from the env during tracing.
I can add this in a follow up
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 the gas cost of the opcode?
yessir
Codecov Report
... and 251 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
yayy! great experience hope to be back! |
Co-authored-by: N <[email protected]> Co-authored-by: Matthias Seitz <[email protected]>
addresses issue #2577
todo! i need to get all the bytecodes from the dbwill likely need to use an auxillary struct or add fields to the builder so i can do a dfs on the calls to track the addresses, since they arent kept around the in
VmTracei would say this pr is at ~90% of the way done, it just needs tests and i need to fill in the (base?) gas cost of the opcode