Skip to content

[evmtool] Tracer does not log storage under DELEGATE CALL #9619

@R9295

Description

@R9295

When a contract calls another contract using DELEGATECALL, the caller's context is made available to the callee. This includes storage. Thus, from my understanding, this should be accommodated by the opcode tracer and logged.

Proof of Concept

{"asdf":{"env":{"currentBaseFee":"0x0a","currentCoinbase":"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba","currentDifficulty":"0x020000","currentGasLimit":"0x1000000","currentNumber":"0x01","currentRandom":"0x0000000000000000000000000000000000000000000000000000000000020000","currentTimestamp":"0x3E8","parentBaseFee":"0x01"},"post":{"Osaka"[{"hash":"0x03c6214f175cc08014bce38b2e9aaf87dd6d80d2be6e92a170d3fc723a2c4773","indexes":{"data":0,"gas":0,"value":0}}]},"pre":{"0x0101010101010101010101010101010101010101":{"balance":"0xffffffffffffffffffffffffffffffff","code":"0x7fc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae460e05566fe84253f8e17607f6007600c60003960076000f36083546156033500000000000000000000000000600052601360006000f06000600060006000620186a08590f460006000f3","nonce":"0x0","storage":{}},"0x0202020202020202020202020202020202020202":{"balance":"0xffffffffffffffffffffffffffffffff","code":"","nonce":"0x0","storage":{}},"0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B":{"balance":"0xffffffffffffffffffffffffffffffff","code":"","nonce":"0x0","storage":{}}},"transaction":{"data":["0xeb"],"gas":"0x1000000","gasLimit":["0x1000000"],"gasPrice":"0x0a","nonce":"0x0","secretKey":"0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8","to":"0x0101010101010101010101010101010101010101","value":["0xffffffffffffffff"]}}}⏎       

Steps to Reproduce

./evmtool state-test --trace --trace.storage ./poc

Expected behavior: [What you expect to happen]
As shown in the output, storage entries are shown since it is a DELEGATECALL

...
{"pc":102,"op":96,"gas":16698414,"gasCost":3,"memSize":32,"stack":["0xfe84253f8e1760","0x1c81a61a407017c58397a47d2ab28191b9b8ec9b","0x1"],"depth":1,"refund":0,"opName":"PUSH1","storage":{"0xe0":"0xc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae4"}}
{"pc":6,"op":53,"gas":97894,"gasCost":3,"memSize":0,"stack":["0x0","0x5603"],"depth":2,"refund":0,"opName":"CALLDATALOAD","storage":{"0xe0":"0xc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae4"}}
{"pc":3,"op":97,"gas":97897,"gasCost":3,"memSize":0,"stack":["0x0"],"depth":2,"refund":0,"opName":"PUSH2","storage":{"0xe0":"0xc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae4"}}
{"pc":2,"op":84,"gas":99997,"gasCost":2100,"memSize":0,"stack":["0x83"],"depth":2,"refund":0,"opName":"SLOAD","storage":{"0xe0":"0xc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae4"}}
{"pc":0,"op":96,"gas":100000,"gasCost":3,"memSize":0,"stack":[],"depth":2,"refund":0,"opName":"PUSH1","storage":{"0xe0":"0xc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae4"}}
{"pc":101,"op":244,"gas":16700623,"gasCost":100100,"memSize":32,"stack":["0xfe84253f8e1760","0x1c81a61a407017c58397a47d2ab28191b9b8ec9b","0x0","0x0","0x0","0x0","0x1c81a61a407017c58397a47d2ab28191b9b8ec9b","0x186a0"],"depth":1,"refund":0,"opName":"DELEGATECALL","storage":{"0xe0":"0xc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae4"}}
...

Actual behavior: [What actually happens]

....
{"pc":102,"op":96,"gas":16698414,"gasCost":3,"memSize":32,"stack":["0xfe84253f8e1760","0x1c81a61a407017c58397a47d2ab28191b9b8ec9b","0x1"],"depth":1,"refund":0,"opName":"PUSH1","storage":{"0xe0":"0xc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae4"}}
{"pc":6,"op":53,"gas":97894,"gasCost":3,"memSize":0,"stack":["0x0","0x5603"],"depth":2,"refund":0,"opName":"CALLDATALOAD"}
{"pc":3,"op":97,"gas":97897,"gasCost":3,"memSize":0,"stack":["0x0"],"depth":2,"refund":0,"opName":"PUSH2"}
{"pc":2,"op":84,"gas":99997,"gasCost":2100,"memSize":0,"stack":["0x83"],"depth":2,"refund":0,"opName":"SLOAD"}
{"pc":0,"op":96,"gas":100000,"gasCost":3,"memSize":0,"stack":[],"depth":2,"refund":0,"opName":"PUSH1"}
{"pc":101,"op":244,"gas":16700623,"gasCost":100100,"memSize":32,"stack":["0xfe84253f8e1760","0x1c81a61a407017c58397a47d2ab28191b9b8ec9b","0x0","0x0","0x0","0x0","0x1c81a61a407017c58397a47d2ab28191b9b8ec9b","0x186a0"],"depth":1,"refund":0,"opName":"DELEGATECALL","storage":{"0xe0":"0xc947397ff996e69cb8f1bbcedbb9c43b2bd8538247c1747641b4a1825833dae4"}}
....

Versions (Add all that apply)

besu: latest master (and before i guess?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions