4

On page 4 of the yellow-paper, the definition of an "empty" account is provided.

An account is empty when it has no code, zero nonce and zero balance.

A formal definition is then provided, where "no code" is taken to mean that the account's codeHash is equal to the KEC hash of the empty string.

The paper then goes on to say:

Even callable precompiled contracts can have an empty account state. This is because their account states do not usually contain the code describing its behaviour.

This confuses me. If the account has code, wouldn't its codeHash != KEC(""), and thus not be empty?

0

1 Answer 1

3

Possibly a kind soul will chime in with more details. At a high level, a "pre-compile" has a specific meaning. It is not contract code that has been compiled and deployed in advance as one might think it implies.

It's more like a "hook" to off-chain code that runs in the node. As you know, address(0) is used for deployments. Other addresses, e.g. address(1), address(2), etc. are "pre-compiles."

Pre-compiles are defined at the protocol level. They are deterministic and do things like performing cryptographic operations - usually useful things that would be computationally heavy if written in Solidity. Implementation uses the node's code, e.g. written in Go. The structure lets the compiler treat pre-compiles similarly to other contracts. The nodes that run transactions notice the call to the "special" address and use their subroutines to compute the deterministic response.

If the account has code, wouldn't its codeHash != KEC(""), and thus not be empty?

If one inspects the blockchain, one will find there is no code deployed to those addresses because the implementation is not like a regular contract.

Hope it helps.

1
  • Thanks! Indeed, this was the first instance where the yellow-paper uses the term "pre-compiled", and so I was unaware of this contextual meaning. Commented Mar 9, 2021 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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