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

implement serde for interpreter #1909

Merged

Conversation

FredCoen
Copy link
Contributor

@FredCoen FredCoen commented Dec 11, 2024

I tried to tackle #1890

I am not sure this is correct. To my understanding the instruction_pointer is just a pointer and so i have replaced it with the program counter for serialization which i know is not the same but i also wonder what the value of that pointer is in a different context. To my understanding doing an absolute jump back to that offset should give us the correct instruction_pointer again when deserializing.

I probably need some guidance here, if this is too far from expecatiations please let me know i can also just let it go :)

In case this is correct i probably have to add a test where the instruction_pointer changes i.e a running execution. What is the best way to mock the host, do i have to implement a transaction, block etc. from scratch? @rakita thanks!

@FredCoen FredCoen marked this pull request as draft December 11, 2024 12:43
} = ExtBytecodeSerde::deserialize(deserializer)?;

let mut bytecode = Self::new(base);
bytecode.absolute_jump(program_counter);
Copy link
Member

@rakita rakita Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would put a small sanity check above this line, if program_counter >= bytecode.bytecode_len() { panic!("serde pc: {program_counter} is less than bytecode len");

Copy link
Contributor Author

@FredCoen FredCoen Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added!

i believe you meant the message to be " is greater than or equal to bytecode len"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe you meant the message to be " is greater than or equal to bytecode len"

Yeah, i edited my msg after i have reread it :D

Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did it correctly.

Left few nits, otherwise lgtm

@FredCoen FredCoen force-pushed the Reimplement-serde-for-Interpreter-#1890 branch from a8d268e to 8999776 Compare December 12, 2024 20:18
@FredCoen
Copy link
Contributor Author

ah great to hear :) i might dare a second one this weekend :)

@FredCoen FredCoen marked this pull request as ready for review December 12, 2024 20:24
Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rakita rakita merged commit 22435a4 into bluealloy:main Dec 14, 2024
27 checks passed
royvardhan pushed a commit to royvardhan/revm that referenced this pull request Dec 20, 2024
* implement serde for interpreter

* add bytecode check

* remove bytecode check

* remove defaults generic params

* add sanity check + cargo fmt

* modify panic message
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 this pull request may close these issues.

2 participants