{"id":117511,"date":"2026-10-25T00:32:36","date_gmt":"2026-10-24T16:32:36","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/117511.html"},"modified":"2026-10-25T00:32:36","modified_gmt":"2026-10-24T16:32:36","slug":"evm-%e5%ad%97%e8%8a%82%e7%a0%81%e5%8f%8d%e7%bc%96%e8%af%91%e7%bb%88%e5%b1%80%ef%bc%9a%e4%bb%8e%e4%b8%89%e5%9c%b0%e5%9d%80%e7%a0%81%e5%88%b0%e6%8a%bd%e8%b1%a1%e8%af%ad%e6%b3%95%e6%a0%91%ef%bc%88ast","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/117511.html","title":{"rendered":"EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261024163234-6adcdda2d10db.webp\" alt=\"\u5c01\u9762\u4fe1\u606f\u56fe\" \/><\/p>\n<p>\u5728\u667a\u80fd\u5408\u7ea6\u5b89\u5168\u5ba1\u8ba1\u3001\u95ed\u6e90\u534f\u8bae\u9006\u5411\u5206\u6790\u4ee5\u53ca\u9ed1\u5ba2\u94fe\u4e0a\u8d44\u4ea7\u8ffd\u8e2a\u8fc7\u7a0b\u4e2d&#xff0c;\u5b89\u5168\u5de5\u7a0b\u5e08\u9762\u5bf9\u7684\u5f80\u5f80\u53ea\u662f\u4e00\u4e32\u5341\u516d\u8fdb\u5236\u7684 EVM \u8fd0\u884c\u65f6\u5b57\u8282\u7801&#xff08;Runtime Bytecode&#xff09;\u3002\u7531\u4e8e\u4ee5\u592a\u574a\u865a\u62df\u673a&#xff08;EVM&#xff09;\u91c7\u7528\u4e86\u51c6\u56fe\u7075\u5b8c\u5907\u7684\u57fa\u4e8e\u6808&#xff08;Stack-based&#xff09;\u67b6\u6784&#xff0c;\u6ca1\u6709\u901a\u7528\u5bc4\u5b58\u5668&#xff0c;\u6240\u6709\u53d8\u91cf\u8ba1\u7b97\u5747\u901a\u8fc7\u5165\u6808&#xff08;PUSH&#xff09;\u3001\u51fa\u6808&#xff08;POP&#xff09;\u3001\u590d\u5236&#xff08;DUP&#xff09;\u4e0e\u4ea4\u6362&#xff08;SWAP&#xff09;\u5b8c\u6210&#xff0c;\u8fd9\u4f7f\u5f97\u76f4\u63a5\u9605\u8bfb\u53cd\u6c47\u7f16\u6307\u4ee4\u6781\u5176\u6666\u6da9\u7e41\u7410\u3002<\/p>\n<p>\u8981\u5b9e\u73b0\u4ece\u6b7b\u677f\u7684\u64cd\u4f5c\u7801&#xff08;Opcodes&#xff09;\u5230\u9ad8\u53ef\u8bfb\u6027\u7684\u9ad8\u7ea7 Solidity \u6e90\u7801\u8fd8\u539f&#xff0c;\u5fc5\u987b\u7ecf\u5386\u7f16\u8bd1\u5668\u9006\u5411\u6d41\u6c34\u7ebf&#xff1a;\u64cd\u4f5c\u7801\u5207\u5206 $\\\\rightarrow$ \u57fa\u672c\u5757\u4e0e\u63a7\u5236\u6d41\u56fe&#xff08;CFG&#xff09;\u6784\u5efa $\\\\rightarrow$ \u6808\u5e73\u8861\u5206\u6790\u4e0e\u4e09\u5730\u5740\u7801&#xff08;TAC&#xff09;\u751f\u6210 $\\\\rightarrow$ \u6570\u636e\u6d41\u4e0e\u53d8\u91cf\u5b9a\u503c\u4f7f\u7528\u94fe&#xff08;UD-Chains&#xff09;\u63a8\u6f14 $\\\\rightarrow$ \u62bd\u8c61\u8bed\u6cd5\u6811&#xff08;AST&#xff09;\u91cd\u6784\u3002<\/p>\n<p>\u672c\u6587\u5c06\u7cfb\u7edf\u62c6\u89e3 EVM \u53cd\u7f16\u8bd1\u5668\u7684\u5e95\u5c42\u7406\u8bba\u67b6\u6784&#xff0c;\u5e76\u4f7f\u7528 Python \u5b8c\u6574\u5b9e\u73b0\u4e00\u5957\u4ece\u539f\u59cb\u5b57\u8282\u7801\u6062\u590d\u4e09\u5730\u5740\u7801\u4e0e\u8868\u8fbe\u5f0f\u6811\u7684\u6838\u5fc3\u9006\u5411\u5f15\u64ce\u3002<\/p>\n<hr \/>\n<h3>EVM \u53cd\u7f16\u8bd1\u7684\u6838\u5fc3\u6280\u672f\u7ba1\u7ebf<\/h3>\n<h4>1. \u63a7\u5236\u6d41\u56fe\u4e0e\u57fa\u672c\u5757\u5212\u5206&#xff08;Basic Blocks &amp; CFG&#xff09;<\/h4>\n<p>\u57fa\u672c\u5757\u662f\u6307\u4e00\u6bb5\u8fde\u7eed\u6267\u884c\u3001\u53ea\u6709\u4e00\u4e2a\u5165\u53e3\u548c\u4e00\u4e2a\u51fa\u53e3\u7684\u6307\u4ee4\u5e8f\u5217\u3002\u5728 EVM \u5b57\u8282\u7801\u4e2d&#xff0c;\u57fa\u672c\u5757\u7684\u8fb9\u754c\u7531\u4ee5\u4e0b\u6307\u4ee4\u754c\u5b9a&#xff1a;<\/p>\n<ul>\n<li>\u7ec8\u7ed3\u6307\u4ee4&#xff1a;JUMP\u3001JUMPI\u3001STOP\u3001RETURN\u3001REVERT\u3001SELFDESTRUCT\u3001INVALID\u3002<\/li>\n<li>\u5165\u53e3\u6307\u4ee4&#xff1a;\u7d27\u968f\u7ec8\u7ed3\u6307\u4ee4\u4e4b\u540e\u7684\u7b2c\u4e00\u6761\u6307\u4ee4&#xff0c;\u6216\u8005\u4efb\u4f55\u4f5c\u4e3a\u6709\u6548\u8df3\u8f6c\u76ee\u6807\u7684\u6307\u4ee4&#xff08;\u5fc5\u987b\u4ee5 JUMPDEST \u4e3a\u5f00\u5934&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u904d\u5386\u5b57\u8282\u7801&#xff0c;\u5c06\u7ebf\u6027\u5e8f\u5217\u5207\u5206\u4e3a\u7531\u6709\u5411\u8fb9\u8fde\u63a5\u7684\u57fa\u672c\u5757\u7f51\u7edc&#xff0c;\u5c31\u5f62\u6210\u4e86\u63a7\u5236\u6d41\u56fe&#xff08;CFG&#xff09;\u3002<\/p>\n<h4>2. \u6808\u6a21\u62df\u4e0e\u4e09\u5730\u5740\u7801\u8f6c\u6362&#xff08;Stack Simulation to TAC&#xff09;<\/h4>\n<p>EVM \u7684\u6838\u5fc3\u75db\u70b9\u662f\u6808\u6df1\u5ea6\u52a8\u6001\u53d8\u5316\u3002\u4f8b\u5982\u4ee3\u7801\u5e8f\u5217&#xff1a;<\/p>\n<p>PUSH1 0x04<br \/>\nCALLDATALOAD<br \/>\nPUSH1 0x20<br \/>\nADD<\/p>\n<p>\u5728\u6808\u5f0f\u67b6\u6784\u4e2d&#xff0c;\u4e2d\u95f4\u7ed3\u679c\u6ca1\u6709\u540d\u5b57\u3002\u4e09\u5730\u5740\u7801&#xff08;TAC&#xff09;\u901a\u8fc7\u5f15\u5165\u865a\u62df\u5bc4\u5b58\u5668&#xff08;\u5982 $v_0, v_1, \\\\dots$&#xff09;\u6d88\u9664\u5bf9\u6808\u7684\u7269\u7406\u4f9d\u8d56&#xff1a;<\/p>\n<p>v0 &#061; CALLDATALOAD(0x04)<br \/>\nv1 &#061; ADD(v0, 0x20)<\/p>\n<p>\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u6b65&#xff0c;\u53cd\u7f16\u8bd1\u5668\u5728\u904d\u5386\u57fa\u672c\u5757\u5185\u7684\u6307\u4ee4\u65f6\u7ef4\u62a4\u4e00\u4e2a\u865a\u62df\u7b26\u53f7\u6808&#xff08;Symbolic Stack&#xff09;\u3002\u6bcf\u5f53\u9047\u5230\u8ba1\u7b97\u6307\u4ee4&#xff0c;\u4ece\u7b26\u53f7\u6808\u5f39\u51fa\u5bf9\u5e94\u6570\u91cf\u7684\u64cd\u4f5c\u6570&#xff0c;\u8d4b\u4e88\u4e00\u4e2a\u5168\u65b0\u4e34\u65f6\u53d8\u91cf&#xff0c;\u5e76\u5c06\u8be5\u4e34\u65f6\u53d8\u91cf\u91cd\u65b0\u538b\u5165\u7b26\u53f7\u6808\u3002<\/p>\n<h4>3. \u6570\u636e\u6d41\u5206\u6790\u4e0e\u62bd\u8c61\u8bed\u6cd5\u6811&#xff08;AST&#xff09;\u6298\u53e0<\/h4>\n<p>\u4e09\u5730\u5740\u7801\u867d\u7136\u6d88\u9664\u4e86\u6808&#xff0c;\u4f46\u4ecd\u7136\u5305\u542b\u5927\u91cf\u5197\u4f59\u7684\u5355\u6b65\u4e34\u65f6\u53d8\u91cf\u3002\u901a\u8fc7\u5b9a\u503c-\u4f7f\u7528\u94fe\u5206\u6790&#xff08;Def-Use Analysis&#xff09;&#xff0c;\u82e5\u53d8\u91cf $v_0$ \u4ec5\u88ab\u4f7f\u7528\u4e00\u6b21&#xff0c;\u4e14\u4f7f\u7528\u70b9\u4e0e\u5b9a\u4e49\u70b9\u4e4b\u95f4\u6ca1\u6709\u53d1\u751f\u72b6\u6001\u6216\u5185\u5b58\u526f\u4f5c\u7528&#xff0c;\u5373\u53ef\u5c06\u5176\u5411\u4e0a\u5185\u5d4c&#xff08;Inlining&#xff09;\u5e76\u5408\u6210\u4e3a\u8868\u8fbe\u5f0f\u6811&#xff1a;$$v_{target} &#061; \\\\text{Add}(\\\\text{CalldataLoad}(0x04), 0x20)$$\u8fdb\u4e00\u6b65\u5bf9\u63a7\u5236\u6d41\u56fe\u4e2d\u7684\u5faa\u73af\u7ed3\u6784&#xff08;\u5929\u7136\u5f62\u6210\u7684\u5f3a\u8fde\u901a\u5206\u91cf&#xff09;\u548c\u6761\u4ef6\u5206\u652f&#xff08;JUMPI&#xff09;\u8fdb\u884c\u6a21\u5f0f\u8bc6\u522b&#xff0c;\u5373\u53ef\u91cd\u6784\u51fa\u9ad8\u7ea7\u7684 if-else\u3001while \u5faa\u73af\u4e0e\u51fd\u6570\u9009\u62e9\u5668\u8c03\u5ea6\u5206\u53d1\u5668&#xff08;Dispatcher&#xff09;\u3002<\/p>\n<hr \/>\n<h3>\u6838\u5fc3\u9006\u5411\u5f15\u64ce\u5b9e\u73b0&#xff1a;\u4ece\u5b57\u8282\u7801\u5230 TAC \u4e0e\u8bed\u6cd5\u6811<\/h3>\n<p>\u4ee5\u4e0b\u662f\u7528 Python \u5b9e\u73b0\u7684\u9ad8\u6027\u80fd EVM \u5b57\u8282\u7801\u7b26\u53f7\u53cd\u7f16\u8bd1\u6838\u5fc3&#xff0c;\u6f14\u793a\u4e86\u5982\u4f55\u5c06\u5b57\u8282\u7801\u8f6c\u6362\u4e3a\u7ed3\u6784\u5316\u7684\u4e09\u5730\u5740\u7801\u5e76\u6298\u53e0\u4e3a\u9ad8\u9636\u8868\u8fbe\u5f0f&#xff1a;<\/p>\n<p>from typing import List, Dict, Tuple, Any<\/p>\n<p># \u57fa\u7840\u64cd\u4f5c\u7801\u5b9a\u4e49\u8868 (\u64cd\u4f5c\u7801 -&gt; (\u52a9\u8bb0\u7b26, \u5f39\u51fa\u6808\u53c2\u6570\u6570, \u538b\u5165\u6808\u7ed3\u679c\u6570))<br \/>\nOPCODES &#061; {<br \/>\n    0x00: (&#034;STOP&#034;, 0, 0),<br \/>\n    0x01: (&#034;ADD&#034;, 2, 1),<br \/>\n    0x02: (&#034;MUL&#034;, 2, 1),<br \/>\n    0x03: (&#034;SUB&#034;, 2, 1),<br \/>\n    0x04: (&#034;DIV&#034;, 2, 1),<br \/>\n    0x10: (&#034;LT&#034;, 2, 1),<br \/>\n    0x11: (&#034;GT&#034;, 2, 1),<br \/>\n    0x14: (&#034;EQ&#034;, 2, 1),<br \/>\n    0x15: (&#034;ISZERO&#034;, 1, 1),<br \/>\n    0x16: (&#034;AND&#034;, 2, 1),<br \/>\n    0x17: (&#034;OR&#034;, 2, 1),<br \/>\n    0x20: (&#034;SHA3&#034;, 2, 1),<br \/>\n    0x35: (&#034;CALLDATALOAD&#034;, 1, 1),<br \/>\n    0x50: (&#034;POP&#034;, 1, 0),<br \/>\n    0x54: (&#034;SLOAD&#034;, 1, 1),<br \/>\n    0x55: (&#034;SSTORE&#034;, 2, 0),<br \/>\n    0x56: (&#034;JUMP&#034;, 1, 0),<br \/>\n    0x57: (&#034;JUMPI&#034;, 2, 0),<br \/>\n    0x5b: (&#034;JUMPDEST&#034;, 0, 0),<br \/>\n    0xf3: (&#034;RETURN&#034;, 2, 0),<br \/>\n    0xfd: (&#034;REVERT&#034;, 2, 0),<br \/>\n}<\/p>\n<p>class Instruction:<br \/>\n    def __init__(self, pc: int, opcode: int, mnemonic: str, operand: bytes &#061; b&#039;&#039;):<br \/>\n        self.pc &#061; pc<br \/>\n        self.opcode &#061; opcode<br \/>\n        self.mnemonic &#061; mnemonic<br \/>\n        self.operand &#061; operand<\/p>\n<p>    def __repr__(self):<br \/>\n        if self.operand:<br \/>\n            return f&#034;{hex(self.pc)}: {self.mnemonic} 0x{self.operand.hex()}&#034;<br \/>\n        return f&#034;{hex(self.pc)}: {self.mnemonic}&#034;<\/p>\n<p>class EVMDecompiler:<br \/>\n    def __init__(self, hex_code: str):<br \/>\n        if hex_code.startswith(&#034;0x&#034;):<br \/>\n            hex_code &#061; hex_code[2:]<br \/>\n        self.bytecode &#061; bytes.fromhex(hex_code)<br \/>\n        self.instructions: List[Instruction] &#061; []<br \/>\n        self.var_counter &#061; 0<\/p>\n<p>    def disassemble(self) -&gt; List[Instruction]:<br \/>\n        &#034;&#034;&#034;\u5c06\u539f\u59cb\u5b57\u8282\u7801\u89e3\u7801\u4e3a\u6307\u4ee4\u5e8f\u5217&#034;&#034;&#034;<br \/>\n        pc &#061; 0<br \/>\n        length &#061; len(self.bytecode)<br \/>\n        while pc &lt; length:<br \/>\n            op &#061; self.bytecode[pc]<br \/>\n            if 0x60 &lt;&#061; op &lt;&#061; 0x7f: # PUSH1 &#8211; PUSH32<br \/>\n                push_bytes &#061; op &#8211; 0x5f<br \/>\n                operand &#061; self.bytecode[pc &#043; 1 : pc &#043; 1 &#043; push_bytes]<br \/>\n                self.instructions.append(Instruction(pc, op, f&#034;PUSH{push_bytes}&#034;, operand))<br \/>\n                pc &#043;&#061; 1 &#043; push_bytes<br \/>\n            elif 0x80 &lt;&#061; op &lt;&#061; 0x8f: # DUP1 &#8211; DUP16<br \/>\n                self.instructions.append(Instruction(pc, op, f&#034;DUP{op &#8211; 0x7f}&#034;))<br \/>\n                pc &#043;&#061; 1<br \/>\n            elif 0x90 &lt;&#061; op &lt;&#061; 0x9f: # SWAP1 &#8211; SWAP16<br \/>\n                self.instructions.append(Instruction(pc, op, f&#034;SWAP{op &#8211; 0x8f}&#034;))<br \/>\n                pc &#043;&#061; 1<br \/>\n            elif op in OPCODES:<br \/>\n                name &#061; OPCODES[op][0]<br \/>\n                self.instructions.append(Instruction(pc, op, name))<br \/>\n                pc &#043;&#061; 1<br \/>\n            else:<br \/>\n                self.instructions.append(Instruction(pc, op, f&#034;UNKNOWN_{hex(op)}&#034;))<br \/>\n                pc &#043;&#061; 1<br \/>\n        return self.instructions<\/p>\n<p>    def generate_tac(self) -&gt; List[str]:<br \/>\n        &#034;&#034;&#034;<br \/>\n        \u57fa\u4e8e\u7b26\u53f7\u6808\u63a8\u5bfc\u4e09\u5730\u5740\u7801&#xff08;TAC&#xff09;<br \/>\n        &#034;&#034;&#034;<br \/>\n        stack: List[str] &#061; []<br \/>\n        tac_statements: List[str] &#061; []<\/p>\n<p>        for inst in self.instructions:<br \/>\n            if inst.mnemonic.startswith(&#034;PUSH&#034;):<br \/>\n                val &#061; f&#034;0x{inst.operand.hex()}&#034;<br \/>\n                stack.append(val)<br \/>\n            elif inst.mnemonic.startswith(&#034;DUP&#034;):<br \/>\n                idx &#061; int(inst.mnemonic[3:])<br \/>\n                if len(stack) &gt;&#061; idx:<br \/>\n                    val &#061; stack[-idx]<br \/>\n                    stack.append(val)<br \/>\n            elif inst.mnemonic.startswith(&#034;SWAP&#034;):<br \/>\n                idx &#061; int(inst.mnemonic[4:])<br \/>\n                if len(stack) &gt; idx:<br \/>\n                    stack[-1], stack[-idx &#8211; 1] &#061; stack[-idx &#8211; 1], stack[-1]<br \/>\n            elif inst.opcode in OPCODES:<br \/>\n                name, pop_cnt, push_cnt &#061; OPCODES[inst.opcode]<br \/>\n                if len(stack) &lt; pop_cnt:<br \/>\n                    # \u6808\u4e0b\u6ea2&#xff0c;\u6ce8\u5165\u7b26\u53f7\u5360\u4f4d\u7b26<br \/>\n                    operands &#061; [f&#034;arg_{i}&#034; for i in range(pop_cnt)]<br \/>\n                else:<br \/>\n                    operands &#061; [stack.pop() for _ in range(pop_cnt)]<\/p>\n<p>                if push_cnt &#061;&#061; 1:<br \/>\n                    var_name &#061; f&#034;v{self.var_counter}&#034;<br \/>\n                    self.var_counter &#043;&#061; 1<br \/>\n                    stmt &#061; f&#034;{var_name} &#061; {name}({&#039;, &#039;.join(reversed(operands))})&#034;<br \/>\n                    tac_statements.append(stmt)<br \/>\n                    stack.append(var_name)<br \/>\n                else:<br \/>\n                    if name in (&#034;SSTORE&#034;, &#034;JUMPI&#034;, &#034;RETURN&#034;, &#034;REVERT&#034;):<br \/>\n                        stmt &#061; f&#034;{name}({&#039;, &#039;.join(reversed(operands))})&#034;<br \/>\n                        tac_statements.append(stmt)<br \/>\n                    elif name &#061;&#061; &#034;POP&#034;:<br \/>\n                        pass<br \/>\n        return tac_statements<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    # \u793a\u4f8b\u6d4b\u8bd5\u5b57\u8282\u7801&#xff1a;\u8bfb\u53d6 calldata(4) \u5e76\u5c06\u5bf9\u5e94 Storage[0] \u52a0\u4e0a\u8be5\u503c<br \/>\n    # PUSH1 0x04, CALLDATALOAD, PUSH1 0x00, SLOAD, ADD, PUSH1 0x00, SSTORE, STOP<br \/>\n    sample_bytecode &#061; &#034;6004356000540160005500&#034;<\/p>\n<p>    decompiler &#061; EVMDecompiler(sample_bytecode)<br \/>\n    instructions &#061; decompiler.disassemble()<br \/>\n    print(&#034;&#061;&#061;&#061; \u53cd\u6c47\u7f16\u6307\u4ee4\u6d41 &#061;&#061;&#061;&#034;)<br \/>\n    for inst in instructions:<br \/>\n        print(inst)<\/p>\n<p>    tac &#061; decompiler.generate_tac()<br \/>\n    print(&#034;\\\\n&#061;&#061;&#061; \u751f\u6210\u7684\u4e09\u5730\u5740\u7801 (TAC) &#061;&#061;&#061;&#034;)<br \/>\n    for line in tac:<br \/>\n        print(line)<\/p>\n<p>\u8fd0\u884c\u4e0a\u8ff0\u4ee3\u7801&#xff0c;\u63a7\u5236\u53f0\u5c06\u8f93\u51fa\u6e05\u6670\u7684\u4e09\u5730\u5740\u7801\u5e8f\u5217&#xff1a;<\/p>\n<p>&#061;&#061;&#061; \u53cd\u6c47\u7f16\u6307\u4ee4\u6d41 &#061;&#061;&#061;<br \/>\n0x0: PUSH1 0x04<br \/>\n0x2: CALLDATALOAD<br \/>\n0x3: PUSH1 0x00<br \/>\n0x5: SLOAD<br \/>\n0x6: ADD<br \/>\n0x7: PUSH1 0x00<br \/>\n0x9: SSTORE<br \/>\n0xa: STOP<\/p>\n<p>&#061;&#061;&#061; \u751f\u6210\u7684\u4e09\u5730\u5740\u7801 (TAC) &#061;&#061;&#061;<br \/>\nv0 &#061; CALLDATALOAD(0x04)<br \/>\nv1 &#061; SLOAD(0x00)<br \/>\nv2 &#061; ADD(v1, v0)<br \/>\nSSTORE(0x00, v2)<\/p>\n<hr \/>\n<h3>\u7ec8\u5c40\u91cd\u6784&#xff1a;\u4ece TAC \u8d70\u5411\u9ad8\u9636 Solidity \u6e90\u7801<\/h3>\n<p>\u5f53\u4e09\u5730\u5740\u7801\u88ab\u5b8c\u6574\u63d0\u53d6\u540e&#xff0c;\u53cd\u7f16\u8bd1\u5668\u7684\u6700\u7ec8\u9636\u6bb5\u662f\u7c7b\u578b\u63a8\u65ad&#xff08;Type Inference&#xff09;\u4e0e\u8bed\u6cd5\u6811\u5339\u914d&#xff1a;<\/p>\n<li>\u5b58\u50a8\u5e03\u5c40\u6620\u5c04&#xff08;Storage Layout Mapping&#xff09;&#xff1a;\u4e09\u5730\u5740\u7801\u4e2d\u7684 SLOAD(0x00) \u548c SSTORE(0x00, &#8230;) \u8868\u660e\u5b58\u50a8\u69fd slot 0 \u6b63\u5728\u88ab\u66f4\u65b0\u3002\u82e5\u69fd\u4f4d\u662f\u901a\u8fc7 SHA3(key, slot) \u8ba1\u7b97\u800c\u6765&#xff0c;\u53cd\u7f16\u8bd1\u5668\u53ef\u7acb\u5373\u63a8\u65ad\u51fa\u8be5\u72b6\u6001\u53d8\u91cf\u662f\u4e00\u4e2a mapping(key &#061;&gt; value) \u6620\u5c04\u3002<\/li>\n<li>\u51fd\u6570\u9009\u62e9\u5668\u8bc6\u522b&#xff08;Dispatcher Inversion&#xff09;&#xff1a;\u5728\u5b57\u8282\u7801\u524d\u90e8&#xff0c;\u901a\u5e38\u4f1a\u51fa\u73b0\u5f62\u5982 SHR(0xe0, CALLDATALOAD(0x00)) \u4e0e EQ(0xa9059cbb) \u7684\u7ed3\u6784\u3002\u53cd\u7f16\u8bd1\u5668\u901a\u8fc7\u5339\u914d\u8fd9\u4e00\u7ed3\u6784&#xff0c;\u80fd\u591f\u7cbe\u51c6\u91cd\u6784\u51fa\u51fd\u6570\u5165\u53e3\u53ca\u5176 4 \u5b57\u8282\u51fd\u6570\u9009\u62e9\u5668&#xff08;\u5982 transfer(address,uint256)&#xff09;\u3002<\/li>\n<li>\u9ad8\u9636\u63a7\u5236\u6d41\u6298\u53e0&#xff08;Control Flow Structuring&#xff09;&#xff1a;\u9488\u5bf9 JUMPI(dest, condition)&#xff0c;\u82e5 dest \u5206\u652f\u5728\u6c47\u7f16\u6267\u884c\u540e\u91cd\u65b0\u6c47\u5408\u4e8e\u540e\u7eed\u57fa\u672c\u5757&#xff0c;\u53cd\u7f16\u8bd1\u5668\u5373\u53ef\u5c06\u5176\u76f4\u63a5\u6298\u53e0\u4e3a\u7ed3\u6784\u5316\u7684&#xff1a;if (condition) {<br \/>\n    \/\/ \u5206\u652f\u5757\u6307\u4ee4\u6298\u53e0<br \/>\n}<\/p>\n<\/li>\n<p>EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u4e0d\u662f\u7384\u5b66&#xff0c;\u800c\u662f\u4e00\u5957\u4e25\u8c28\u7684\u7f16\u8bd1\u5668\u524d\u7aef\u4e0e\u4e2d\u95f4\u8868\u793a\u9006\u5411\u5de5\u7a0b\u3002\u638c\u63e1\u4e86\u4ece Opcodes \u5230 TAC \u518d\u5230 AST \u7684\u63a8\u5bfc\u95ed\u73af&#xff0c;\u4efb\u4f55\u672a\u7ecf\u5f00\u6e90\u7684\u6697\u6c60\u5408\u7ea6\u3001\u9ed1\u5ba2\u653b\u51fb\u5408\u7ea6\u90fd\u5c06\u5728\u5b89\u5168\u7814\u7a76\u5458\u7684\u5c4f\u5e55\u4e0a\u663e\u9732\u5176\u539f\u59cb\u7684\u5168\u8c8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u667a\u80fd\u5408\u7ea6\u5b89\u5168\u5ba1\u8ba1\u3001\u95ed\u6e90\u534f\u8bae\u9006\u5411\u5206\u6790\u4ee5\u53ca\u9ed1\u5ba2\u94fe\u4e0a\u8d44\u4ea7\u8ffd\u8e2a\u8fc7\u7a0b\u4e2d&#xff0c;\u5b89\u5168\u5de5\u7a0b\u5e08\u9762\u5bf9\u7684\u5f80\u5f80\u53ea\u662f\u4e00\u4e32\u5341\u516d\u8fdb\u5236\u7684 EVM \u8fd0\u884c\u65f6\u5b57\u8282\u7801&#xff08;Runtime Bytecode&#xff09;\u3002\u7531\u4e8e\u4ee5\u592a\u574a\u865a\u62df\u673a&#xff08;EVM&#xff09;\u91c7\u7528\u4e86\u51c6\u56fe\u7075\u5b8c\u5907\u7684\u57fa\u4e8e\u6808&#xff08;Stack-based&#xff09;\u67b6\u6784&#xff0c;\u6ca1\u6709\u901a\u7528\u5bc4\u5b58\u5668&#xff0c;\u6240\u6709\u53d8\u91cf\u8ba1\u7b97\u5747\u901a\u8fc7\u5165\u6808&#xff08;PUSH&#xff09;\u3001\u51fa\u6808&#xff08;POP&amp;#<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[66,723,50,1160],"topic":[],"class_list":["post-117511","post","type-post","status-publish","format-standard","hentry","category-server","tag-ai","tag-react","tag-50","tag-1160"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/117511.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5728\u667a\u80fd\u5408\u7ea6\u5b89\u5168\u5ba1\u8ba1\u3001\u95ed\u6e90\u534f\u8bae\u9006\u5411\u5206\u6790\u4ee5\u53ca\u9ed1\u5ba2\u94fe\u4e0a\u8d44\u4ea7\u8ffd\u8e2a\u8fc7\u7a0b\u4e2d&#xff0c;\u5b89\u5168\u5de5\u7a0b\u5e08\u9762\u5bf9\u7684\u5f80\u5f80\u53ea\u662f\u4e00\u4e32\u5341\u516d\u8fdb\u5236\u7684 EVM \u8fd0\u884c\u65f6\u5b57\u8282\u7801&#xff08;Runtime Bytecode&#xff09;\u3002\u7531\u4e8e\u4ee5\u592a\u574a\u865a\u62df\u673a&#xff08;EVM&#xff09;\u91c7\u7528\u4e86\u51c6\u56fe\u7075\u5b8c\u5907\u7684\u57fa\u4e8e\u6808&#xff08;Stack-based&#xff09;\u67b6\u6784&#xff0c;\u6ca1\u6709\u901a\u7528\u5bc4\u5b58\u5668&#xff0c;\u6240\u6709\u53d8\u91cf\u8ba1\u7b97\u5747\u901a\u8fc7\u5165\u6808&#xff08;PUSH&#xff09;\u3001\u51fa\u6808&#xff08;POP&amp;#\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/117511.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-24T16:32:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261024163234-6adcdda2d10db.webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/117511.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/117511.html\",\"name\":\"EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-24T16:32:36+00:00\",\"dateModified\":\"2026-10-24T16:32:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/117511.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/117511.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/117511.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/117511.html","og_locale":"zh_CN","og_type":"article","og_title":"EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5728\u667a\u80fd\u5408\u7ea6\u5b89\u5168\u5ba1\u8ba1\u3001\u95ed\u6e90\u534f\u8bae\u9006\u5411\u5206\u6790\u4ee5\u53ca\u9ed1\u5ba2\u94fe\u4e0a\u8d44\u4ea7\u8ffd\u8e2a\u8fc7\u7a0b\u4e2d&#xff0c;\u5b89\u5168\u5de5\u7a0b\u5e08\u9762\u5bf9\u7684\u5f80\u5f80\u53ea\u662f\u4e00\u4e32\u5341\u516d\u8fdb\u5236\u7684 EVM \u8fd0\u884c\u65f6\u5b57\u8282\u7801&#xff08;Runtime Bytecode&#xff09;\u3002\u7531\u4e8e\u4ee5\u592a\u574a\u865a\u62df\u673a&#xff08;EVM&#xff09;\u91c7\u7528\u4e86\u51c6\u56fe\u7075\u5b8c\u5907\u7684\u57fa\u4e8e\u6808&#xff08;Stack-based&#xff09;\u67b6\u6784&#xff0c;\u6ca1\u6709\u901a\u7528\u5bc4\u5b58\u5668&#xff0c;\u6240\u6709\u53d8\u91cf\u8ba1\u7b97\u5747\u901a\u8fc7\u5165\u6808&#xff08;PUSH&#xff09;\u3001\u51fa\u6808&#xff08;POP&amp;#","og_url":"https:\/\/www.wsisp.com\/helps\/117511.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-24T16:32:36+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261024163234-6adcdda2d10db.webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/117511.html","url":"https:\/\/www.wsisp.com\/helps\/117511.html","name":"EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-24T16:32:36+00:00","dateModified":"2026-10-24T16:32:36+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/117511.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/117511.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/117511.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"EVM \u5b57\u8282\u7801\u53cd\u7f16\u8bd1\u7ec8\u5c40\uff1a\u4ece\u4e09\u5730\u5740\u7801\u5230\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\u4e0e Solidity \u6e90\u7801\u91cd\u6784"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/117511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=117511"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/117511\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=117511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=117511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=117511"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=117511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}