EVM构造code的题
构造出一个返回值与code相等的字节码
1 | // SPDX-License-Identifier: UNLICENSED |
原理
如果没有require(safe(code), “deploy/code-unsafe”);
CODE: 0x600C6000600039600C6000F3
PUSH1: ?? 600C 指要COPY的code的长度
PUSH1: 00 6000 指要从哪个位置开始COPY
PUSH1: 00 6000 指要COPY到内存的哪个位置
CODECOPY 39
PUSH1 ?? 600C 指要读取的数据的长度
PUSH1 00 6000 指要从内存的指定位置开始读取
RETURN F3 F3
当有require(safe(code), “deploy/code-unsafe”);
CODE: 7F80607F60005360015260215260416000F300000000000000000000000000000080607F60005360015260215260416000F3000000000000000000000000000000
PUSH32 (??) 7F(??)
DUP1 80 80 复制一份
PUSH1 7F 607F 要存入内存的数据
PUSH1 00 6000 存入内存的地点
MSTORE8 53 53
PUSH1 01 6001
MSTORE 52 52
PUSH1 21 6021
MSTORE 52 52
PUSH1 41 6041
PUSH1 00 6000
RETURN F3 F3
STOP(*15) 00
CODE:7F(??)80607F60005360015260215260416000F3 000000000000000000000000000000
memory:7F(??)(??)
题目主要考察EVM字节码的构造,需要熟知才能运用自如