Skip to content
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

Memory recording improvements #64

Open
mattsse opened this issue Mar 9, 2024 · 6 comments · May be fixed by #84
Open

Memory recording improvements #64

mattsse opened this issue Mar 9, 2024 · 6 comments · May be fixed by #84
Assignees

Comments

@mattsse
Copy link
Contributor

mattsse commented Mar 9, 2024

Currently, if

https://github.com/paradigmxyz/evm-inspectors/blob/846dec1db14ac42067e7a4bb6a973091cd7eb808/src/tracing/config.rs#L15-L16

is enabled memory, memory is cloned on each step:

https://github.com/paradigmxyz/evm-inspectors/blob/846dec1db14ac42067e7a4bb6a973091cd7eb808/src/tracing/mod.rs#L306-L310

there are only a few opcodes that modify memory, so we can optimize this and only record memory when necessary.
This is also only relevant for the parity vmtrace setting:

https://github.com/paradigmxyz/evm-inspectors/blob/846dec1db14ac42067e7a4bb6a973091cd7eb808/src/tracing/builder/parity.rs#L383-L390

@h3lio5
Copy link

h3lio5 commented Apr 5, 2024

there are only a few opcodes that modify memory, so we can optimize this and only record memory when necessary.

A naive approach that comes to mind is to have a HashMap (OpCode => bool) that contains info if an OpCode modifies memory, record memory only if the hashmap entry is true.
Can you please suggest a better way to do it?

@mattsse
Copy link
Contributor Author

mattsse commented Apr 5, 2024

yep, great idea!

we've since added something similar to foundry:

https://github.com/foundry-rs/foundry/blob/1281421e04144a8de0341f9cad9b623a012a74bf/crates/evm/core/src/opcodes.rs#L5-L25

which we use for efficient memory recording as well:

https://github.com/foundry-rs/foundry/blob/1281421e04144a8de0341f9cad9b623a012a74bf/crates/evm/evm/src/inspectors/debugger.rs#L75-L81

so we can move this function in here and do the same trick

do you want to take this?

@h3lio5
Copy link

h3lio5 commented Apr 5, 2024

@mattsse yes, please assign me!

@rakita
Copy link
Contributor

rakita commented Apr 5, 2024

Oh, it would be good to move modifies_memory to revm, so it is easy to reuse. Created the task: bluealloy/revm#1263

@mattsse
Copy link
Contributor Author

mattsse commented Apr 5, 2024

great!

@h3lio5 do you want to take care of that as well?

@h3lio5 h3lio5 linked a pull request Apr 5, 2024 that will close this issue
@h3lio5
Copy link

h3lio5 commented Apr 5, 2024

@mattsse sure, I'll port it over to revm also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants