-
Notifications
You must be signed in to change notification settings - Fork 654
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 CREATE2 Opcode #1186
Implement CREATE2 Opcode #1186
Conversation
2587834
to
1861136
Compare
1861136
to
6aa5ed1
Compare
Note to self: |
e2532e9
to
e556728
Compare
eth/utils/address.py
Outdated
salt: int, | ||
call_data: bytes) -> Address: | ||
return Address( | ||
keccak(decode_hex('0xff') + address + int_to_big_endian(salt) + keccak(call_data))[-20:] |
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 might be easier to read (and slightly more cleanly typed as) as:
return force_bytes_to_address(keccak(
decode_hex('0xff') + address + int_to_big_endian(salt) + keccak(call_data)
))
Also, the decode_hex('0xff')
should probably be replaced with a constant CREATE2_PREFIX
or just a bytes literal.
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.
Right! Changing it to:
return force_bytes_to_address(
keccak(b'\xff' + address + int_to_big_endian(salt) + keccak(call_data))
)
I'll also change generate_contract_address
to use force_bytes_to_address
to be aligned with this change.
e556728
to
ae88e85
Compare
ae88e85
to
5997620
Compare
What was wrong?
We don't support the
CREATE2
Opcode for Constantinople yet.How was it fixed?
Implemented
CREATE2
Opcode based on the existingCREATE
opcode. Broken down:get_stack_data
to allow overwriting and hence read with/withoutsalt
generate_contract_address
to allow overwriting and hence implement the different version formatKnown issues
Cute Animal Picture