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

Update EIP-7873: Creator Contract - revert reason & magic value #9391

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions EIPS/eip-7873.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,20 @@
let size := calldatasize()
if lt(size, 64) { revert(0, 0) }

let tx_initcode_hash := calldataload(0)
let salt := calldataload(32)

mstore8(0, 0xff) // a magic value to ensure a specific preimage space
calldatacopy(1, 0, size) // copy tx_initcode_hash, salt and init_data to memory to hash
let commitment_size := add(size, 1)
let final_salt := keccak256(0, commitment_size)
calldatacopy(0, 0, size) // copy tx_initcode_hash, salt and init_data to memory to hash
let final_salt := keccak256(0, size)

let tx_initcode_hash := calldataload(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

This could also be mload(0). Is there any reason to prefer one over the other? Are there any planned gas schedule changes that would impact here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

calldataload(0) is simpler/safer, as it reads from an immutable buffer, independent from code that wrote that data into memory.

Not sure about gas schedule changes, but anyway I'd prefer simplicity today over performance in the future.

let init_data_size := sub(size, 64)
calldatacopy(0, 64, init_data_size)

let ret := txcreate(tx_initcode_hash, callvalue(), final_salt, 0, init_data_size)
if iszero(ret) { revert(0, 0) }
// reuse init_data which has been already copied to memory above
let ret := txcreate(tx_initcode_hash, callvalue(), final_salt, 64, init_data_size)

if iszero(ret) {
let ret_data_size := returndatasize()
returndatacopy(0, 0, ret_data_size)
revert(0, ret_data_size)
}

mstore(0, ret)
return(0, 32)
Expand Down Expand Up @@ -212,7 +213,7 @@

Needs discussion.

<!-- TODO -->

Check warning on line 216 in EIPS/eip-7873.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

HTML comments are only allowed while `status` is one of: `Draft`, `Withdrawn`

warning[markdown-html-comments]: HTML comments are only allowed while `status` is one of: `Draft`, `Withdrawn` --> EIPS/eip-7873.md | 216 | <!-- TODO --> | = help: see https://ethereum.github.io/eipw/markdown-html-comments/

## Copyright

Expand Down
Loading