-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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-1014 according to coredev decision #1375
Conversation
Hi! I'm a bot, and I wanted to automerge your PR, but couldn't because of the following issue(s):
|
Shouldn't the different options be moved into the Rationale section, while leaving the final one under Specification ? |
@Souptacular @5chdn @chfast is this the last version agreed on the call? If so, can this be merged? |
@@ -12,6 +12,8 @@ created: 2018-04-20 | |||
|
|||
Adds a new opcode at 0xf5, which takes 4 stack arguments: endowment, memory_start, memory_length, salt. Behaves identically to CREATE, except using `sha3(msg.sender ++ salt ++ init_code)[12:]` instead of the usual sender-and-nonce-hash as the address where the contract is initialized at. | |||
|
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.
Here still the wrong formula is cited.
It would also be good to have a short explanation of the difference between init_code
and code
added to the EIP.
Some examples would be very helpful here for having the basic hash creation verified, optimally also providing both the complete contract code and the init code for the contract. |
I agree. I'll try to update this PR with the comments from @axic (remove unused formulas) and some examples |
I have pushed some updates to this PR now. Please review (I still haven't added any examples though). cc @SergioDemianLerner |
Can #1247 merged first? |
Needs a rebase. Also should clarify how |
Example 0
Example 1
Example 2
Example 3
Example 4
Example 5
|
1ae8d18
to
6985e8c
Compare
Added examples, rebased, added comment about salt. I don't understand the question about endianness for |
ping @vbuterin PTAL |
Adds a new opcode at 0xf5, which takes 4 stack arguments: endowment, memory_start, memory_length, salt. Behaves identically to CREATE, except using `keccak256(msg.sender ++ salt ++ init_code)[12:]` instead of the usual sender-and-nonce-hash as the address where the contract is initialized at. | ||
Adds a new opcode at 0xf5, which takes 4 stack arguments: endowment, memory_start, memory_length, salt. Behaves identically to CREATE, except using `keccak256( 0xff ++ address ++ salt ++ keccak256(init_code)))[12:]` instead of the usual sender-and-nonce-hash as the address where the contract is initialized at. The `salt` is a 32-byte stack item. | ||
|
||
The coredev-call at 2018-08-10 decided to use the formula above. |
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.
Move it to Rationale?
EIPS/eip-1014.md
Outdated
|
||
### Clarifications | ||
|
||
The `initcode` is the code that, when executed, produces the runtime bytecode that will be placed into the state, and which typically is used by high level languages to implement a 'constructor'. |
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.
Should be init_code
.
Yeah, me neither. 0xff is a single byte. Salt is always 32 bytes. Edit: this example from @holiman is correct.
|
* Ensures that the hash preimage has a fixed size, | ||
|
||
This also has the side-effect of being able to possibly reuse the `keccak256(init_code)` from earlier calculation, either within a client or via `EXTCODEHASH` if the init-code is deployed on-chain. | ||
|
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.
But the init_code is not the code that gets installed into the smart contract. That's the difference between code and init_code.
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.
So how it can improve EXTCODEHASH ?
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.
So the thought was, that if it's a very large initcode, and the verification of a given contract needs to be cheap in gas, the init_code
could be deployed on-chain.
If a contract A
wants to verify a given contract address C
, instead of feeding it the initcode and then force A
do calculate the sha3(init_code)
, A
could just use the EXTCODEHASH(D)
. Then A
would know that yes, the initcode
matches what's in D
. Where D
would be a piece of whitelisted init_code
.
But yeah, maybe I should remove that. It was a 'hmm maybe this is useful for some scenario somewhere' kind of thing.
One issue that is still unaddressed is who pays the cost of hashing (if it turns out that it has significance compared to other costs) It was raised by @holiman here: And I proposed a simple solution here: #1014 (comment) |
Ah I see; yes, this is genuinely an important point.
That solution seems fine to me. |
Whether 0xff is an actual single byte or a stack item with the value of 0xff. In general I think the EIP is vague and could be improved regarding clarity. |
Re the cost of hashing, I'll do some benchmarks. However, I think all initcode is already hashed today, for making a key to the lookup on valid-jumpdest-map. So that key can be reused, even though I suspect it may be is hashed twice right now (for geth I know it is) |
Hello @holiman Martin, having problems getting the examples to run, I am getting different hashes. I assume the If so: can you rename this to Update with some contextual links:
|
I'd support changing the first paragraph to:
Possibly add to the end: Additionally, an extra |
Update: ok, failing hash creation was (as most of the time 😄) a bug on the implementation side, now fixed this and can confirm that all examples are working. I've created an example json file from these over on Nevertheless would pledge to rename |
I'll
Re upper/lowercase, I printed it from golang which automatically checksums addresses on String(). I don't think we should add gascost for initcode until it's been discussed and ok:ed by allcoredevs. Until then, I'll try to benchmark it and see if it's an issue |
Fixed, ptal |
Since there are additional gas costs involved now, could the expected gas costs be part of the tests? |
For reference - discussion here: https://gitter.im/ethereum/AllCoreDevs?at=5bb315de6e5a401c2d037971 I have now updated the PR again, to include cost per byte. Yes, that should be included in testcases, I guess... |
Testcases updated |
This PR has been sitting a long time, and the EIP that is "current" contains errors. I'm going to admin-merge this, since,
|
This updates EIP 1014 with a third option for address calculation, the formula that was accepted at the coredev-call on Aug 10, 2018.
See #1014 (comment)