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 CREATE2 Opcode #1186

Merged
merged 5 commits into from
Aug 17, 2018

Conversation

cburgdorf
Copy link
Contributor

@cburgdorf cburgdorf commented Aug 15, 2018

What was wrong?

We don't support the CREATE2 Opcode for Constantinople yet.

How was it fixed?

Implemented CREATE2 Opcode based on the existing CREATE opcode. Broken down:

  • address format is latest and greatest from last core dev call
  • reading items from the stack was abstracted into method get_stack_data to allow overwriting and hence read with/without salt
  • generating address was abstracted into method generate_contract_address to allow overwriting and hence implement the different version format

Known issues

  • not tested yet

Cute Animal Picture

put a cute animal picture link inside the parentheses

@cburgdorf cburgdorf force-pushed the christoph/feat/skinny-create branch 2 times, most recently from 2587834 to 1861136 Compare August 15, 2018 09:11
@cburgdorf
Copy link
Contributor Author

Note to self: CREATE2 state tests are coming. Should be helpful to validate the implementation (which isn't expected to work yet)

ethereum/tests#486

@cburgdorf cburgdorf force-pushed the christoph/feat/skinny-create branch 3 times, most recently from e2532e9 to e556728 Compare August 16, 2018 07:53
salt: int,
call_data: bytes) -> Address:
return Address(
keccak(decode_hex('0xff') + address + int_to_big_endian(salt) + keccak(call_data))[-20:]
Copy link
Member

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.

Copy link
Contributor Author

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.

@cburgdorf cburgdorf merged commit cde40db into ethereum:master Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants