The yellow paper says that the memory model for the EVM is a word-addressed byte array (YP 9.1), but when I run debug.traceTransaction in Geth, the memory looks more like an array of words, maybe a byte-addressed word array. Did this change between the YP and the actual implementation?

      depth: 1,
      gas: 3971707,
      gasCost: 3,
      memory: ["0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000060", "00000000000000000000000000000000000000000000000005d5349f8718c000"],
      op: "DUP1",
      pc: 2888,
      stack: ["00000000000000000000000000000000000000000000000000000000c6bd3052", "0000000000000000000000000000000000000000000000000000000000000080", "0000000000000000000000000000000000000000000000000000000000000060"],
      storage: {
        0000000000000000000000000000000000000000000000000000000000000006: "00000000000000000000000000000000000000000000000005d5349f8718c000"

2 Answers 2


I view it as a byte-addressed byte-array.

It is certainly byte-addressed, in that consecutive integer addresses refer to consecutive bytes in memory.

It is true that you can only read a 32 byte word (mload reads 32 consecutive bytes), but reads are not word-aligned. mload(0) and mload(1) are both valid and have 31 bytes in common. so it is not really a word-array.

Writing is the same, except that you can also store a single byte with mstore8.

The only "word-array" aspect I can think of is that when memory is expanded, it is always rounded up to a multiple of 32 bytes. And this fact is only important for gas calculation.

  • Thanks. After you explained it that way, I looked at the code and it seems to agree with you. The byte-addressed aspect is in the opMload function /core/vm/instructions.go and the byte-array aspect is in the Memory struct definition in /core/vm/memory.go Jan 7, 2018 at 18:51
  • Yes, I don't know why the YP says it is word-addressed. On the face of it this does not appear to be correct. Jan 7, 2018 at 18:53
  • 2
    By word-addressed it means that each address is a word. I.e. the address space is 2^256 since the address is one word (256 bits). It is a byte array in that each address points to a single byte, as opposed to storage, in which each address points to a full word. Jan 8, 2018 at 18:27

Memory is a word-addressed byte array. Storage is a word-addressed word array.

Geth simply chooses to display the memory in 32-byte segments, which is a bit of an odd choice, but when reading and writing to memory in the EVM each byte is independently accessable with mstore8

  • mload8 is not a valid opcode. Reading memory always reads 32 bytes. Jan 7, 2018 at 18:18
  • Yup, that's right good catch Jan 8, 2018 at 0:52

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.