From 5b726c345b1b8613b28f39a9a5f1025a5a66bf5f Mon Sep 17 00:00:00 2001 From: realgu <36865815+ChengruiGu@users.noreply.github.com> Date: Thu, 13 Feb 2025 00:14:55 +0800 Subject: [PATCH] Update realgu.md --- realgu.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/realgu.md b/realgu.md index 8336313..2c64da9 100644 --- a/realgu.md +++ b/realgu.md @@ -56,6 +56,32 @@ func stf(parent types.Block, block types.Block, state state.StateDB) (state.Stat ``` 问题: what exactly does a 'state' contains? what are the tries? +### 2024.02.12 +Ethereum state is stored in four different modified merkle patricia tries (MMPTs): +- Transaction Trie +- Receipt Trie +- World State Trie +- Account State Trie + +计算机组成课flashback: + +1 word = 32 bytes, 1 byte = 8 digits = 2 digits in hexadecimal + +The EVM stack has a maximum size of 1024 items. PUSH -> PUSH -> ADD +Also there's a program counter and JUMP. But where is compare and jump insn like bne, bge, blt? +And there's an available gas counter. + + +EVM memory is a byte array of 2256 (or practically infinite) bytes . All locations in memory are well-defined initially as zero. +MSTORE takes two values from the stack: an address offset and a 32-byte value. It then writes the value to memory at the specified offset. + +In EVM, memory is dynamically allocated in multiples of 1 word “pages”. Gas is charged for the number of pages expanded. +MSIZE: number of words/pages allocated + +Storage can only be accessed via the code of its associated account. External accounts don't have code and therefore cannot access their own storage. + +SSTORE takes two values from the stack: a storage slot and a 32-byte value. It then writes the value to storage of the account. So an account have associated storage +