1

It is stated in the Ethereum yellow paper:

codeHash: The hash of the EVM code of this account—this is the code that gets executed should this address receive a message call; it is immutable and thus, unlike all other fields, can-not be changed after construction. All such code fragments are contained in the state database un-der their corresponding hashes for later retrieval. This hash is formally denoted σ[a]c, and thus the code may be denoted as b, given that KEC(b) = σ[a]c.

However, later on, in the Contract Creation section depicting the contract deployment scenario (so not an external address):

The account’s nonce is initially defined as zero, the balance as the value passed, the storage as empty and the code hash as the Keccak 256-bit hash of the empty string;

states that codeHash is set to a hash of an empty string after contract deployment.

The question is: What is set in the codeHash variable after contract deployment? It seems to me that these two quotations are contradictory, one stating the codeHash variable contains the hash of the contract code, the other the hash of an empty string.

  • Are you sure that the second statement isn't just talking about a blank contact creation? – jojeyh Dec 12 '17 at 17:18
  • I would say it does not talk about an empty contract, I conclude that from the statement: "There are a number of intrinsic parameters used when creating an account: sender (s), original transactor (o), available gas (g), gas price (p), endowment (v) together with an arbitrary length byte array, i, the initialisation EVM code and finally the present depth of the message-call/contract-creation stack (e)." – user3223162 Dec 13 '17 at 10:41
2

I believe that the hash of the empty string is the code hash only until the constructor returns the body code.

I always find the yellow paper hard to read, but if you continue reading the Contract Creation section, there's an equation 98 which appears to show the code hash being stored with the code returned by the constructor. The text that follows that equation:

The exception in the determination of σ' dictates that o, the resultant byte sequence from the execution of the initialisation code, specifies the final body code for the newly-created account.

| improve this answer | |
  • This would make sense. And I think equation 98. specifies it. Thank you. – user3223162 Dec 13 '17 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.