-
Notifications
You must be signed in to change notification settings - Fork 642
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
feat: EXTCODEHASH load bytecode and check if it is EOF #1501
Conversation
@@ -72,6 +73,13 @@ pub fn extcodehash<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, | |||
} else { | |||
gas!(interpreter, 400); | |||
} | |||
if let Some((bytecode, _)) = host.code(address) { |
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 needs to go where Host
is implemented here:
revm/crates/revm/src/context.rs
Line 156 in 561fbdb
fn code_hash(&mut self, address: Address) -> Option<(B256, bool)> { |
host.code_hash needs to return whatever is needed for instruction.
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.
makes sense, let me do it 💪
crates/primitives/src/constants.rs
Outdated
pub const EOF_BYTECODE_HASH: &[u8] = &[ | ||
0x9d, 0xbf, 0x36, 0x48, 0xdb, 0x82, 0x10, 0x55, 0x2e, 0x9c, 0x4f, 0x75, 0xc6, 0xa1, 0xc3, 0x05, | ||
0x7c, 0x0c, 0xa4, 0x32, 0x04, 0x3b, 0xd6, 0x48, 0xbe, 0x15, 0xfe, 0x7b, 0xe0, 0x56, 0x46, 0xf5, | ||
]; |
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.
You can use &hex!("..")
here, it is more readable
.ok(); | ||
|
||
if let Some((bytecode, is_cold)) = self.code(address) { | ||
if bytecode.is_eof() { |
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.
@rakita What do you think about doing this instead of checking the first byte?
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 fine, as only EOF 0xEFXX
is 0xEF00
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.
thanks for the clarification
I took over this PR, as we need these kind of changes asap. Closing in favour of #1504 |
if EXTCODEHASH target is an account with EOF bytecode, we need to return 0x9dbf3648db8210552e9c4f75c6a1c3057c0ca432043bd648be15fe7be05646f5
This means that extcodehash would need to load account bytecode and check first byte of it.
https://github.com/ipsilon/eof/blob/main/spec/eof.md#modified-behavior
When executed from a legacy contract, if the target account of EXTCODEHASH is an EOF contract,
then it will return 0x9dbf3648db8210552e9c4f75c6a1c3057c0ca432043bd648be15fe7be05646f5
(the hash of EF00, as if that would be the code).
ISSUE