Skip to content

Conversation

@jpgonzalezra
Copy link
Contributor

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

@jpgonzalezra jpgonzalezra marked this pull request as draft June 9, 2024 00:30
@jpgonzalezra jpgonzalezra marked this pull request as ready for review June 9, 2024 03:08
} else {
gas!(interpreter, 400);
}
if let Some((bytecode, _)) = host.code(address) {
Copy link
Member

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:

fn code_hash(&mut self, address: Address) -> Option<(B256, bool)> {

host.code_hash needs to return whatever is needed for instruction.

Copy link
Contributor Author

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 💪

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,
];
Copy link
Member

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

@jpgonzalezra jpgonzalezra marked this pull request as draft June 10, 2024 00:31
@jpgonzalezra jpgonzalezra requested a review from rakita June 10, 2024 02:36
@jpgonzalezra jpgonzalezra marked this pull request as ready for review June 10, 2024 02:36
.ok();

if let Some((bytecode, is_cold)) = self.code(address) {
if bytecode.is_eof() {
Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the clarification

@rakita
Copy link
Member

rakita commented Jun 10, 2024

I took over this PR, as we need these kind of changes asap. Closing in favour of #1504

@rakita rakita closed this Jun 10, 2024
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