这是我的整个程序。其背后的原因是以太坊上的程序越大,加载它的成本就越高(因为每字节的 Gas 成本非常高)。
CALLER
CALLDATASIZE
ISZERO
PUSH1 0x07
JUMPI
PUSH3 0x5b6000
SSTORE
所以我要跳入 PUSH3 0x5b6000
但如果我们反汇编 0x5b6000
那么这意味着
JUMPDEST
PUSH1 0x00
因此,由于 evm 操作码编码为 fully variable length (除了 PUSHxx 之外,所有指令都是一个字节长)并且我跳进了 JUMPDEST
,为什么 this transaction 会这样?失败?
黄皮书中哪里指定前往 JUMPDEST
并不是有效跳转目的地的唯一要求?
最佳答案
我不确定 yellow paper 是哪个版本最初提出此问题时可用,但以下是 Istanbul 尔版本第 13 页的摘录:
9.4.3. Jump Destination Validity. We previously used D as the function to determine the set of valid jump destinations given the code that is being run. We define this as any position in the code occupied by a JUMPDEST instruction.
All such positions must be on valid instruction boundaries, rather than sitting in the data portion of PUSH operations and must appear within the explicitly defined portion of the code (rather than in the implicitly defined STOP operations that trail it).
这是 geth source location对此进行分析的代码。
关于assembly - 为什么即使包含 JUMPDEST 也无法跳转到指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64413862/