ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.13k stars 5.74k forks source link

The `--asm-json` output suppresses `--asm` #14628

Open cameel opened 11 months ago

cameel commented 11 months ago

If you request the JSON assembly output on the CLI with --asm-json the normal assembly output (--asm) no longer appears.

This is not how other outputs work on the CLI. Standard JSON also does not behave this way - it is possible to request both evm.assembly and evm.legacyAssembly at the same time.

Environment

How to reproduce

Only --asm

echo 'contract C {}' | solc - --asm
Output ``` ======= :C ======= EVM assembly: /* "":0:13 contract C {} */ mstore(0x40, 0x80) callvalue dup1 iszero tag_1 jumpi 0x00 dup1 revert tag_1: pop dataSize(sub_0) dup1 dataOffset(sub_0) 0x00 codecopy 0x00 return stop sub_0: assembly { /* "":0:13 contract C {} */ mstore(0x40, 0x80) 0x00 dup1 revert auxdata: 0xa26469706673582212203de2612385ddacb7fd5cc0b2a4bd9f59a2c09a735e08d1d1461c0e3e3f66778264736f6c63430008150033 } ```

Only --asm-json

echo 'contract C {}' | solc - --asm-json
Output ``` ======= :C ======= EVM assembly: {".code":[{"begin":0,"end":13,"name":"PUSH","source":0,"value":"80"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"40"},{"begin":0,"end":13,"name":"MSTORE","source":0},{"begin":0,"end":13,"name":"CALLVALUE","source":0},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"ISZERO","source":0},{"begin":0,"end":13,"name":"PUSH [tag]","source":0,"value":"1"},{"begin":0,"end":13,"name":"JUMPI","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"REVERT","source":0},{"begin":0,"end":13,"name":"tag","source":0,"value":"1"},{"begin":0,"end":13,"name":"JUMPDEST","source":0},{"begin":0,"end":13,"name":"POP","source":0},{"begin":0,"end":13,"name":"PUSH #[$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"PUSH [$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"CODECOPY","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"RETURN","source":0}],".data":{"0":{".auxdata":"a26469706673582212203de2612385ddacb7fd5cc0b2a4bd9f59a2c09a735e08d1d1461c0e3e3f66778264736f6c63430008150033",".code":[{"begin":0,"end":13,"name":"PUSH","source":0,"value":"80"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"40"},{"begin":0,"end":13,"name":"MSTORE","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"REVERT","source":0}]}},"sourceList":["","#utility.yul"]} ```

--asm and --asm-json

echo 'contract C {}' | solc - --asm --asm-json
Note that the output is identical to the case with only `--asm-json`. Output ``` ======= :C ======= EVM assembly: {".code":[{"begin":0,"end":13,"name":"PUSH","source":0,"value":"80"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"40"},{"begin":0,"end":13,"name":"MSTORE","source":0},{"begin":0,"end":13,"name":"CALLVALUE","source":0},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"ISZERO","source":0},{"begin":0,"end":13,"name":"PUSH [tag]","source":0,"value":"1"},{"begin":0,"end":13,"name":"JUMPI","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"REVERT","source":0},{"begin":0,"end":13,"name":"tag","source":0,"value":"1"},{"begin":0,"end":13,"name":"JUMPDEST","source":0},{"begin":0,"end":13,"name":"POP","source":0},{"begin":0,"end":13,"name":"PUSH #[$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"PUSH [$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"CODECOPY","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"RETURN","source":0}],".data":{"0":{".auxdata":"a26469706673582212203de2612385ddacb7fd5cc0b2a4bd9f59a2c09a735e08d1d1461c0e3e3f66778264736f6c63430008150033",".code":[{"begin":0,"end":13,"name":"PUSH","source":0,"value":"80"},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"40"},{"begin":0,"end":13,"name":"MSTORE","source":0},{"begin":0,"end":13,"name":"PUSH","source":0,"value":"0"},{"begin":0,"end":13,"name":"DUP1","source":0},{"begin":0,"end":13,"name":"REVERT","source":0}]}},"sourceList":["","#utility.yul"]} ```
Ekzer commented 11 months ago

Hi @cameel ! happy to try to solve this one :)

Ekzer commented 11 months ago

14630

cameel commented 2 months ago

This also affects #14612 (see https://github.com/ethereum/solidity/pull/14612#discussion_r1483457495), which is likely to be merged soon.