-
Notifications
You must be signed in to change notification settings - Fork 72
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
optimize memory recording #84
optimize memory recording #84
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.
okay final request, is the type changes to Bytes
because Bytes is cheap to clone, unlike Vec
and we should add a one line comment (see foundry code) that explains why we're using the previous step's memory
if we change the type to Bytes, we may need to change some methods of |
hmm, good point, I need to do some digging first and find out why we're resizing or whether this is even correct... |
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.
lgtm, tysm!
I need to check the expected behaviour of vmtrace before merging
not relevant to this issue but can you please suggest me where I can learn more in-depth about call traces, revm-inspectors design and how / where is it used (applications)? |
you can checkout the trace_ debug_ endpoints in reth: |
okay @h3lio5 I did some digging and it looks like, for geth memory is recorded before the expansion which we also do however, this means, that this is now a bit more difficult to track, because we can only reuse the previous step's memory if the previous step does not modify memory. for the parity tracer I think we can optimize the memory delta computation separately, I believe this is currently implemented wrong: |
@mattsse Maybe I'm missing the point here, could you please clarify why we cannot reuse the previous step's memory if it modifies memory? iiuc, the edit: ah, I get it now. The previous step memory snapshot doesn't capture the expanded memory (does tracing before expansion), so we cannot reuse the prev memory? |
I think we can fetch the prev step's opcode (if it isn't the first step in the trace) using |
that works yes
we need the memory when the opcode is executed, before memory expansion, when the step_start is invoked, the opcode hasn't been executed yet, so same memory as the after the previous opcode.
exactly |
haven't forgotten about this, just need to run a few more cross client tests... |
Makes #84 worth it, helps with parity memory traces
Verified manually with the forge debugger, i removed the resizing because i don't think it's worth having, this will slightly modify its behavior because loads/stores won't be highlighted if they also expand memory I also fixed the logic because the step memory is from the previous opcode, so we have to check modifies_memory only on the previous step. |
Record memory only when necessary, i.e., the opcode modifies the memory.
Ported the
modifies_memory!()
macro from foundryFixes #64