Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: call tracer in rosetta-ethereum does not recognize internal error #119

Open
aeharvlee opened this issue May 4, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@aeharvlee
Copy link

aeharvlee commented May 4, 2022

Describe the bug
JS call tracer used by rosetta-ethereum cannot parse CALL which contains internal failed call(caused by failed CREATE opcode).
JS call tracer used by Geth works fine for same CALL.

TLDR
The trace result by JS call tracer (= callTracerLegacy) by Geth. Take a look calls field which contains internal calls in this tx.

  • There is no to field.
  • There is error field which contains error message.
{
  "type": "CALL",
  "from": "0xca7a99380131e6c76cfa622396347107aeedca2d",
  "to": "0xe213d8b68ca3d01e51a6dba669de59ac9a8359ee",
  "value": "0x0",
  "gas": "0x17c0a5e8",
  "gasUsed": "0x2888f",
  "input": "0x160d2ed00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000036d6f6d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036461750000000000000000000000000000000000000000000000000000000000",
  "error": "execution reverted",
  "time": "2.218877542s",
  "calls": [
    {
      "type": "CREATE",
      "from": "0xe213d8b68ca3d01e51a6dba669de59ac9a8359ee",
      "value": "0x0",
      "gas": "0xdb612228",
      "gasUsed": "0x20530",
      "input": "0x608060405234801561001057600080fd5b506040516103353803806103358339810180604052604081101561003357600080fd5b81019080805164010000000081111561004b57600080fd5b8281019050602081018481111561006157600080fd5b815185600182028301116401000000008211171561007e57600080fd5b50509291906020018051906020019092919050505081600090805190602001906100a99291906100b8565b5080600181905550505061015d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100f957805160ff1916838001178555610127565b82800160010185558215610127579182015b8281111561012657825182559160200191906001019061010b565b5b5090506101349190610138565b5090565b61015a91905b8082111561015657600081600090555060010161013e565b5090565b90565b6101c98061016c6000396000f3fe608060405234801561001057600080fd5b5060043610610053576000357c01000000000000000000000000000000000000000000000000000000009004806306fdde0314610058578063262a9dff146100db575b600080fd5b6100606100f9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100a0578082015181840152602081019050610085565b50505050905090810190601f1680156100cd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100e3610197565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561018f5780601f106101645761010080835404028352916020019161018f565b820191906000526020600020905b81548152906001019060200180831161017257829003601f168201915b505050505081565b6001548156fea165627a7a72305820f533e6576b68db195c74bfd2c7cf3342bed686f7be1afd2664c4fbd44a0198ee00290000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000036461750000000000000000000000000000000000000000000000000000000000",
      "error": "internal failure"
    }
  ]
}

BUT JS call tracer by rosetta-ethereum do wrong parse for this CALL like below.
image

To Reproduce

  1. Run local geth built by this repo.
  • I just added a line to trigger failed CREATE opcode by force.
  • Deploy bytecode 0x608060405234801561001057600080fd5b506108a1806100206000396000f3fe608060405234801561001057600080fd5b5060043610610069576000357c01000000000000000000000000000000000000000000000000000000009004806306fdde031461006e578063160d2ed0146100f1578063262a9dff14610257578063fcf5ed0614610275575b600080fd5b6100766102bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b657808201518184015260208101905061009b565b50505050905090810190601f1680156100e35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102556004803603608081101561010757600080fd5b810190808035906020019064010000000081111561012457600080fd5b82018360208201111561013657600080fd5b8035906020019184600183028401116401000000008311171561015857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190803590602001906401000000008111156101c557600080fd5b8201836020820111156101d757600080fd5b803590602001918460018302840111640100000000831117156101f957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019092919050505061035d565b005b61025f610462565b6040518082815260200191505060405180910390f35b61027d610468565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103555780601f1061032a57610100808354040283529160200191610355565b820191906000526020600020905b81548152906001019060200180831161033857829003601f168201915b505050505081565b818160405161036b9061048e565b8080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156103ae578082015181840152602081019050610393565b50505050905090810190601f1680156103db5780820380516001836020036101000a031916815260200191505b509350505050604051809103906000f0801580156103fd573d6000803e3d6000fd5b50600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550836000908051906020019061045492919061049b565b508260018190555050505050565b60015481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6103358061054183390190565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106104dc57805160ff191683800117855561050a565b8280016001018555821561050a579182015b828111156105095782518255916020019190600101906104ee565b5b509050610517919061051b565b5090565b61053d91905b80821115610539576000816000905550600101610521565b5090565b9056fe608060405234801561001057600080fd5b506040516103353803806103358339810180604052604081101561003357600080fd5b81019080805164010000000081111561004b57600080fd5b8281019050602081018481111561006157600080fd5b815185600182028301116401000000008211171561007e57600080fd5b50509291906020018051906020019092919050505081600090805190602001906100a99291906100b8565b5080600181905550505061015d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100f957805160ff1916838001178555610127565b82800160010185558215610127579182015b8281111561012657825182559160200191906001019061010b565b5b5090506101349190610138565b5090565b61015a91905b8082111561015657600081600090555060010161013e565b5090565b90565b6101c98061016c6000396000f3fe608060405234801561001057600080fd5b5060043610610053576000357c01000000000000000000000000000000000000000000000000000000009004806306fdde0314610058578063262a9dff146100db575b600080fd5b6100606100f9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100a0578082015181840152602081019050610085565b50505050905090810190601f1680156100cd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100e3610197565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561018f5780601f106101645761010080835404028352916020019161018f565b820191906000526020600020905b81548152906001019060200180831161017257829003601f168201915b505050505081565b6001548156fea165627a7a72305820f533e6576b68db195c74bfd2c7cf3342bed686f7be1afd2664c4fbd44a0198ee0029a165627a7a72305820ee16a4449d9a61a2f830b6eb4cabb3539fd5cc525ea6887595e1f11e684d976c0029. This can be obtained by compiling Mom contract.
  1. Call build with parameters. I already created encoded input 0x160d2ed00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000036d6f6d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036461750000000000000000000000000000000000000000000000000000000000, so you can send transaction like eth.sendTransaction({from: "0x<sender>", to: "0x<contractAddress>", input: <encodedInput>, gas: ...}).
  2. After you send transaction executing Mom.build method then you can trace it by using debug.traceBlockByHash.

Expected behavior
rosetta-ethereum must parse failed internal CALL (caused by failed CREATE opcode) and return block structure like below.
Below result is produced by fixed version of rosetta-ethereum by myself. Check this out. I only added 3 lines to call debug api for using Geth js call tracer.

Please check the below parsed CALL when use Geth js call tracer.

  • There is an error message and revert field is false. (CORRECT!)

image

The result of fetching block from rosetta-ethereum which uses Geth JS tracer is below(IT MUST BE RETURNED LIKE BELOW):

{
    "block": {
        "block_identifier": {
            "index": 10112,
            "hash": "0xcd9514963ee9e738af0ab76b6250ed8d3aaf7e81dd5824c6d418a12f2f82a2fa"
        },
        "parent_block_identifier": {
            "index": 10111,
            "hash": "0xf74fa2ba652500054c408392d8674119c86c10c64b8d911b7938b2813c7b7952"
        },
        "timestamp": 1651646778000,
        "transactions": [
            {
                "transaction_identifier": {
                    "hash": "0xcd9514963ee9e738af0ab76b6250ed8d3aaf7e81dd5824c6d418a12f2f82a2fa"
                },
                "operations": [
                    {
                        "operation_identifier": {
                            "index": 0
                        },
                        "type": "MINER_REWARD",
                        "status": "SUCCESS",
                        "account": {
                            "address": "0xcA7A99380131e6C76cfa622396347107aeEDCA2D"
                        },
                        "amount": {
                            "value": "2000000000000000000",
                            "currency": {
                                "symbol": "ETH",
                                "decimals": 18
                            }
                        }
                    }
                ]
            },
            {
                "transaction_identifier": {
                    "hash": "0xc32b05d2d9294b6105288af61fa8dac0b254d30def6dfd2def51b8be1825c743"
                },
                "operations": [
                    {
                        "operation_identifier": {
                            "index": 0
                        },
                        "type": "FEE",
                        "status": "SUCCESS",
                        "account": {
                            "address": "0xcA7A99380131e6C76cfa622396347107aeEDCA2D"
                        },
                        "amount": {
                            "value": "-186446000000000",
                            "currency": {
                                "symbol": "ETH",
                                "decimals": 18
                            }
                        }
                    },
                    {
                        "operation_identifier": {
                            "index": 1
                        },
                        "related_operations": [
                            {
                                "index": 0
                            }
                        ],
                        "type": "FEE",
                        "status": "SUCCESS",
                        "account": {
                            "address": "0xcA7A99380131e6C76cfa622396347107aeEDCA2D"
                        },
                        "amount": {
                            "value": "186446000000000",
                            "currency": {
                                "symbol": "ETH",
                                "decimals": 18
                            }
                        }
                    },
                    {
                        "operation_identifier": {
                            "index": 2
                        },
                        "type": "FEE",
                        "status": "SUCCESS",
                        "account": {
                            "address": "0xcA7A99380131e6C76cfa622396347107aeEDCA2D"
                        },
                        "amount": {
                            "value": "-1305122",
                            "currency": {
                                "symbol": "ETH",
                                "decimals": 18
                            }
                        }
                    },
                    {
                        "operation_identifier": {
                            "index": 3
                        },
                        "type": "CREATE",
                        "status": "FAILURE",
                        "account": {
                            "address": "0x0f8CF0bD26383587e1Cc3a54D64EA7746Ae7C580"
                        },
                        "metadata": {
                            "error": "internal failure"
                        }
                    },
                    {
                        "operation_identifier": {
                            "index": 4
                        },
                        "related_operations": [
                            {
                                "index": 3
                            }
                        ],
                        "type": "CREATE",
                        "status": "FAILURE",
                        "account": {
                            "address": "0x0000000000000000000000000000000000000000"
                        },
                        "metadata": {
                            "error": "internal failure"
                        }
                    }
                ],
                "metadata": {
                    "gas_limit": "0x7a120",
                    "gas_price": "0x3b9aca0e",
                    "receipt": {
                        "blockHash": "0xcd9514963ee9e738af0ab76b6250ed8d3aaf7e81dd5824c6d418a12f2f82a2fa",
                        "blockNumber": "0x2780",
                        "contractAddress": "0x0000000000000000000000000000000000000000",
                        "cumulativeGasUsed": "0x2d84e",
                        "gasUsed": "0x2d84e",
                        "logs": [],
                        "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
                        "root": "0x",
                        "status": "0x0",
                        "transactionHash": "0xc32b05d2d9294b6105288af61fa8dac0b254d30def6dfd2def51b8be1825c743",
                        "transactionIndex": "0x0",
                        "type": "0x2"
                    },
                    "trace": {
                        "calls": [
                            {
                                "error": "internal failure",
                                "from": "0x0f8cf0bd26383587e1cc3a54d64ea7746ae7c580",
                                "gas": "0x6ac01",
                                "gasUsed": "0x1fe22",
                                "input": "0x608060405234801561001057600080fd5b506040516103183803806103188339810180604052604081101561003357600080fd5b81019080805164010000000081111561004b57600080fd5b8281019050602081018481111561006157600080fd5b815185600182028301116401000000008211171561007e57600080fd5b50509291906020018051906020019092919050505081600090805190602001906100a99291906100b8565b5080600181905550505061015d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100f957805160ff1916838001178555610127565b82800160010185558215610127579182015b8281111561012657825182559160200191906001019061010b565b5b5090506101349190610138565b5090565b61015a91905b8082111561015657600081600090555060010161013e565b5090565b90565b6101ac8061016c6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806306fdde031461003b578063262a9dff146100be575b600080fd5b6100436100dc565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610083578082015181840152602081019050610068565b50505050905090810190601f1680156100b05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100c661017a565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101725780601f1061014757610100808354040283529160200191610172565b820191906000526020600020905b81548152906001019060200180831161015557829003601f168201915b505050505081565b6001548156fea165627a7a72305820a093ae8cb087f19f24d4f91e4ad2b4b63f3797de1b1b54517edeef2669b6366100290000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000036461750000000000000000000000000000000000000000000000000000000000",
                                "type": "CREATE",
                                "value": "0x0"
                            }
                        ],
                        "error": "execution reverted",
                        "from": "0xca7a99380131e6c76cfa622396347107aeedca2d",
                        "gas": "0x74a48",
                        "gasUsed": "0x28176",
                        "input": "0x160d2ed00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000036d6f6d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036461750000000000000000000000000000000000000000000000000000000000",
                        "time": "3.045584ms",
                        "to": "0x0f8cf0bd26383587e1cc3a54d64ea7746ae7c580",
                        "type": "CALL",
                        "value": "0x0"
                    }
                }
            }
        ]
    }
}

Additional context
I don't have an idea why rosetta-ethereum uses its own call tracer which seems not working correctly.

@aeharvlee
Copy link
Author

aeharvlee commented May 5, 2022

One more thing.
rosetta-ethereum should not handle empty to field as Zero address(0x000...0) because that can be interpreted like
"Oh there was a CALL which someone tried to send transaction to Zero address.".
What was really happened is not that situation. There was empty to field, so above interpretation is wrong.

[Updated]
I think it should be handled as just 0x. That fits the actual context of the situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant