erigon icon indicating copy to clipboard operation
erigon copied to clipboard

erigon 2.33.0 trace_call rpc method return traces with type "suicide" as "call" with null "action" field

Open Yxang opened this issue 3 years ago • 2 comments

System information

Erigon version: erigon version 2.33.0-stable-cbc27008

OS & Version: Ubuntu

Commit hash : cbc27008

chain: mainnet

Expected behaviour

Rpc method trace_call should return trace type == "suicide" correctly.

Not sure if it is just me having the problem.

Taking txn 0x41cf300a3240b8b7fb33dc555179142c71afda9c2e59ee9efc2443cace7d994e as the example. Other transactions with contract suicides seems also have this problem

Expected return:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        {
            "action": {
                "from": "0xe51db2167c42688789099516771d138f2e650880",
                "callType": "call",
                "gas": "0x4b20",
                "input": "0x9cb8a26a",
                "to": "0x4a1e2bb34441c093f3d9a029118cfe1bb06a55f3",
                "value": "0x0"
            },
            "blockHash": "0x26c6897a873e6c2ea95478cec47f6ec2420e44370b7ca28baefc9337176db9fc",
            "blockNumber": 16373908,
            "result": {
                "gasUsed": "0x3c28",
                "output": "0x"
            },
            "subtraces": 1,
            "traceAddress": [],
            "transactionHash": "0x41cf300a3240b8b7fb33dc555179142c71afda9c2e59ee9efc2443cace7d994e",
            "transactionPosition": 72,
            "type": "call"
        },
        {
            "action": {
                "from": "0x4a1e2bb34441c093f3d9a029118cfe1bb06a55f3",
                "callType": "delegatecall",
                "gas": "0x3fd7",
                "input": "0x9cb8a26a",
                "to": "0xe38f942db7a1b4213d6213f70c499b59287b01f1",
                "value": "0x0"
            },
            "blockHash": "0x26c6897a873e6c2ea95478cec47f6ec2420e44370b7ca28baefc9337176db9fc",
            "blockNumber": 16373908,
            "result": {
                "gasUsed": "0x31c1",
                "output": "0x"
            },
            "subtraces": 1,
            "traceAddress": [
                0
            ],
            "transactionHash": "0x41cf300a3240b8b7fb33dc555179142c71afda9c2e59ee9efc2443cace7d994e",
            "transactionPosition": 72,
            "type": "call"
        },
        {
            "action": {
                "address": "0x4a1e2bb34441c093f3d9a029118cfe1bb06a55f3",
                "refundAddress": "0xe51db2167c42688789099516771d138f2e650880",
                "balance": "0x0"
            },
            "blockHash": "0x26c6897a873e6c2ea95478cec47f6ec2420e44370b7ca28baefc9337176db9fc",
            "blockNumber": 16373908,
            "result": null,
            "subtraces": 0,
            "traceAddress": [
                0,
                0
            ],
            "transactionHash": "0x41cf300a3240b8b7fb33dc555179142c71afda9c2e59ee9efc2443cace7d994e",
            "transactionPosition": 72,
            "type": "suicide"
        }
    ]
}

Actual behaviour

Erigon v2.33.0 returns this

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        {
            "action": {
                "from": "0xe51db2167c42688789099516771d138f2e650880",
                "callType": "call",
                "gas": "0x4b20",
                "input": "0x9cb8a26a",
                "to": "0x4a1e2bb34441c093f3d9a029118cfe1bb06a55f3",
                "value": "0x0"
            },
            "blockHash": "0x26c6897a873e6c2ea95478cec47f6ec2420e44370b7ca28baefc9337176db9fc",
            "blockNumber": 16373908,
            "result": {
                "gasUsed": "0x3c28",
                "output": "0x"
            },
            "subtraces": 1,
            "traceAddress": [],
            "transactionHash": "0x41cf300a3240b8b7fb33dc555179142c71afda9c2e59ee9efc2443cace7d994e",
            "transactionPosition": 72,
            "type": "call"
        },
        {
            "action": {
                "from": "0x4a1e2bb34441c093f3d9a029118cfe1bb06a55f3",
                "callType": "delegatecall",
                "gas": "0x3fd7",
                "input": "0x9cb8a26a",
                "to": "0xe38f942db7a1b4213d6213f70c499b59287b01f1",
                "value": "0x0"
            },
            "blockHash": "0x26c6897a873e6c2ea95478cec47f6ec2420e44370b7ca28baefc9337176db9fc",
            "blockNumber": 16373908,
            "result": {
                "gasUsed": "0x31c1",
                "output": "0x"
            },
            "subtraces": 2,                             <----------- also seems incorrect
            "traceAddress": [
                0
            ],
            "transactionHash": "0x41cf300a3240b8b7fb33dc555179142c71afda9c2e59ee9efc2443cace7d994e",
            "transactionPosition": 72,
            "type": "call"
        },
        {
            "action": null,                                <----------- here
            "blockHash": "0x26c6897a873e6c2ea95478cec47f6ec2420e44370b7ca28baefc9337176db9fc",
            "blockNumber": 16373908,
            "result": {
                "gasUsed": "0x0",
                "output": "0x"
            },
            "subtraces": 0,
            "traceAddress": [
                0,
                0                                                <----------- also seems incorrect
            ],
            "transactionHash": "0x41cf300a3240b8b7fb33dc555179142c71afda9c2e59ee9efc2443cace7d994e",
            "transactionPosition": 72,
            "type": "call"                                <----------- here
        }
    ]
}

Meanwhile, v2.32.0 returns expected values.

Steps to reproduce the behaviour

curl --location --request POST [[ node URL ]] \
--header 'Content-Type: application/json' \
--data-raw '{
    "method": "trace_transaction",
    "params": [
        "0x41cf300a3240b8b7fb33dc555179142c71afda9c2e59ee9efc2443cace7d994e"
    ],
    "id": 1,
    "jsonrpc": "2.0"
}'

Tried this but did not work:

./build/bin/integration state_stages --unwind=10000 --datadir=/data02/erigon --chain=mainnet

Chain is synced with a modified version on v2.33.0, here is the patch. All Above is tested on the stable version but not the modified one. I am not sure if this is the reason but I think it should not influence suicide traces.

Subject: [PATCH] rpc: add state output for LOG opcode in tracing
---
Index: cmd/rpcdaemon/commands/trace_adhoc.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/cmd/rpcdaemon/commands/trace_adhoc.go b/cmd/rpcdaemon/commands/trace_adhoc.go
--- a/cmd/rpcdaemon/commands/trace_adhoc.go	(revision cbc27008d509df6c04f340609e6635d7c98dfb09)
+++ b/cmd/rpcdaemon/commands/trace_adhoc.go	(revision c942f36ca16b6fbe4eb9e26bdbbe7f93200bba0c)
@@ -573,6 +573,27 @@
 			if st.Len() > 1 {
 				ot.lastVmOp.Ex.Store = &VmTraceStore{Key: st.Back(0).String(), Val: st.Back(1).String()}
 			}
+		}
+		switch {
+		case op >= vm.LOG0 && op <= vm.LOG4:
+			// get stack as topics
+			var showStack = int(ot.lastOp-vm.LOG0) + 2
+			for i := showStack - 1; i >= 0; i-- {
+				ot.lastVmOp.Ex.Push = append(ot.lastVmOp.Ex.Push, st.Back(i).String())
+			}
+
+			ot.lastVmOp.Ex.Push = append(ot.lastVmOp.Ex.Push, scope.Contract.Address().String())
+			// get memory as data
+			var lastMemOff = st.Back(0).Uint64()
+			var lastMemLen = st.Back(1).Uint64()
+			if memory != nil && memory.Len() > int(lastMemLen) {
+				cpy := memory.GetCopy(int64(ot.lastMemOff), int64(ot.lastMemLen))
+				if len(cpy) == 0 {
+					cpy = make([]byte, lastMemLen)
+				}
+				ot.lastVmOp.Ex.Mem = &VmTraceMem{Data: fmt.Sprintf("0x%0x", cpy), Off: int(lastMemOff)}
+			}
+
 		}
 		if ot.lastVmOp.Ex.Used < 0 {
 			ot.lastVmOp.Ex = nil

Backtrace

[backtrace]

Yxang avatar Jan 10 '23 08:01 Yxang

I've facing the same exact issue in this transaction 0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a with Stable 2.33.0 version.

Expected Behavior

{
  "jsonrpc": "2.0",
  "id": "4263c436-1503-4645-bb9e-73ec6cbcffa6",
  "result": [
    {
      "action": {
        "callType": "call",
        "from": "0xa7fb5ca286fc3fd67525629048a4de3ba24cba2e",
        "gas": "0x13334",
        "input": "0xf3fef3a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004cec4",
        "to": "0xc77ad0a71008d7094a62cfbd250a2eb2afdf2776",
        "value": "0x0"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "gasUsed": "0xc8dc",
        "output": "0x"
      },
      "subtraces": 1,
      "traceAddress": [],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "call"
    },
    {
      "action": {
        "creationMethod": "create2",
        "from": "0xc77ad0a71008d7094a62cfbd250a2eb2afdf2776",
        "gas": "0x92fb",
        "init": "0x608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe",
        "value": "0x0"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "address": "0x738c4964a4f926a3f6b819c0a3ad2bd4304a29d6",
        "code": "0x",
        "gasUsed": "0x22e3"
      },
      "subtraces": 3,
      "traceAddress": [
        0
      ],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "create"
    },
    {
      "action": {
        "callType": "staticcall",
        "from": "0x738c4964a4f926a3f6b819c0a3ad2bd4304a29d6",
        "gas": "0x8f76",
        "input": "0x66d003ac",
        "to": "0xc77ad0a71008d7094a62cfbd250a2eb2afdf2776",
        "value": "0x0"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "gasUsed": "0x953",
        "output": "0x000000000000000000000000a7fb5ca286fc3fd67525629048a4de3ba24cba2e"
      },
      "subtraces": 0,
      "traceAddress": [
        0,
        0
      ],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "call"
    },
    {
      "action": {
        "callType": "staticcall",
        "from": "0x738c4964a4f926a3f6b819c0a3ad2bd4304a29d6",
        "gas": "0x843f",
        "input": "0xfc0c546a",
        "to": "0xc77ad0a71008d7094a62cfbd250a2eb2afdf2776",
        "value": "0x0"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "gasUsed": "0x1a9",
        "output": "0x0000000000000000000000000000000000000000000000000000000000000000"
      },
      "subtraces": 0,
      "traceAddress": [
        0,
        1
      ],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "call"
    },
    {
      "action": {
        "address": "0x738c4964a4f926a3f6b819c0a3ad2bd4304a29d6",
        "balance": "0x1cc6e836ae4000",
        "refundAddress": "0xa7fb5ca286fc3fd67525629048a4de3ba24cba2e"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": null,
      "subtraces": 0,
      "traceAddress": [
        0,
        2
      ],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "suicide"
    }
  ]
}

Actual Behavior

{
  "jsonrpc": "2.0",
  "id": "2760b3db-a683-4ece-9a62-1f26d330f0b2",
  "result": [
    {
      "action": {
        "from": "0xa7fb5ca286fc3fd67525629048a4de3ba24cba2e",
        "callType": "call",
        "gas": "0x13334",
        "input": "0xf3fef3a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004cec4",
        "to": "0xc77ad0a71008d7094a62cfbd250a2eb2afdf2776",
        "value": "0x0"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "gasUsed": "0xc8dc",
        "output": "0x"
      },
      "subtraces": 1,
      "traceAddress": [],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "call"
    },
    {
      "action": {
        "from": "0xc77ad0a71008d7094a62cfbd250a2eb2afdf2776",
        "gas": "0x92fb",
        "init": "0x608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe",
        "value": "0x0"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "address": "0x738c4964a4f926a3f6b819c0a3ad2bd4304a29d6",
        "code": "0x",
        "gasUsed": "0x22e3"
      },
      "subtraces": 4,
      "traceAddress": [
        0
      ],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "create"
    },
    {
      "action": {
        "from": "0x738c4964a4f926a3f6b819c0a3ad2bd4304a29d6",
        "callType": "staticcall",
        "gas": "0x8f76",
        "input": "0x66d003ac",
        "to": "0xc77ad0a71008d7094a62cfbd250a2eb2afdf2776",
        "value": "0x0"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "gasUsed": "0x953",
        "output": "0x000000000000000000000000a7fb5ca286fc3fd67525629048a4de3ba24cba2e"
      },
      "subtraces": 0,
      "traceAddress": [
        0,
        0
      ],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "call"
    },
    {
      "action": {
        "from": "0x738c4964a4f926a3f6b819c0a3ad2bd4304a29d6",
        "callType": "staticcall",
        "gas": "0x843f",
        "input": "0xfc0c546a",
        "to": "0xc77ad0a71008d7094a62cfbd250a2eb2afdf2776",
        "value": "0x0"
      },
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "gasUsed": "0x1a9",
        "output": "0x0000000000000000000000000000000000000000000000000000000000000000"
      },
      "subtraces": 0,
      "traceAddress": [
        0,
        1
      ],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "call"
    },
    {
      "action": null,
      "blockHash": "0x1136c63463fba174bced26a85bee8f4c2d443c0d54a92df88406379d4cdcc455",
      "blockNumber": 16368572,
      "result": {
        "gasUsed": "0x0",
        "output": "0x"
      },
      "subtraces": 0,
      "traceAddress": [
        0,
        2
      ],
      "transactionHash": "0x9f82ab2f2aa80172ed3961cc14305f938c31d23b594a2493e91bc9da01a9301a",
      "transactionPosition": 23,
      "type": "call"
    }
  ]
}

Texnomic avatar Jan 10 '23 12:01 Texnomic

Updated to v2.33.1 and problem fixed. Thanks and I am closing this issue.

Yxang avatar Jan 11 '23 02:01 Yxang