erigon
erigon copied to clipboard
Missing Failed Subcalls in Erigon Tracers When Encountering `ErrInsufficientBalance`
System information
Erigon version: erigon version 3.00.0-alpha7-1cee6584
OS & Version: Linux
Commit hash: https://github.com/erigontech/erigon/commit/1cee6584013282b9d5c5cb2b2c8506a6821c9a0a
Chain/Network: Ethereum
Expected behaviour
For a transaction with a failed subcall due to ErrInsufficientBalance, the tracer should return the full trace, including all subcalls, even if some fail. The expected output is:
{
"txHash": "0xd0d52b784a239d1a7e765f6cd9daf0ffdee29f6c942f517b42b42388b8a7ff87",
"result": {
"from": "0xfdce42116f541fc8f7b0776e2b30832bd5621c85",
"gas": "0x14e9b",
"gasUsed": "0xf240",
"to": "0x3dbacbf3da19ff6dedea74ed5c8722107672cb83",
"input": "0x3bfc026c",
"calls": [
{
"from": "0x3dbacbf3da19ff6dedea74ed5c8722107672cb83",
"gas": "0xcc05",
"gasUsed": "0x56f0",
"to": "0xb7e811662fa10ac068aee115ac2e682821630535",
"input": "0x",
"value": "0xde0b6b3a7640000",
"type": "CALL"
},
{
"from": "0x3dbacbf3da19ff6dedea74ed5c8722107672cb83",
"gas": "0x5b64",
"gasUsed": "0x0",
"to": "0xb7e811662fa10ac068aee115ac2e682821630535",
"input": "0x",
"error": "insufficient balance for transfer",
"value": "0xde0b6b3a7640000",
"type": "CALL"
}
],
"value": "0xde0b6b3a7640000",
"type": "CALL"
}
}
This behavior matches the output from geth and reth.
Actual behaviour
In erigon, the tracer does not include the second subcall, resulting in the following truncated output:
{
"txHash": "0xd0d52b784a239d1a7e765f6cd9daf0ffdee29f6c942f517b42b42388b8a7ff87",
"result": {
"from": "0xfdce42116f541fc8f7b0776e2b30832bd5621c85",
"gas": "0x14e9b",
"gasUsed": "0xf240",
"to": "0x3dbacbf3da19ff6dedea74ed5c8722107672cb83",
"input": "0x3bfc026c",
"calls": [
{
"from": "0x3dbacbf3da19ff6dedea74ed5c8722107672cb83",
"gas": "0xcc05",
"gasUsed": "0x56f0",
"to": "0xb7e811662fa10ac068aee115ac2e682821630535",
"input": "0x",
"value": "0xde0b6b3a7640000",
"type": "CALL"
}
],
"value": "0xde0b6b3a7640000",
"type": "CALL"
}
}
The second subcall with the ErrInsufficientBalance error is missing, which differs from the behavior of geth and reth.
Steps to reproduce the behaviour
Option 1: Testnet with Custom Nodes
- Set up a testnet using
gethanderigonas nodes. Use kurtosis for automation. - Deploy the PoC contracts to the testnet.
- Send a transaction that includes a failed subcall due to
ErrInsufficientBalance. One can directly use the PoC.zip and run:
forge script ./script/DeployAndInteract.s.sol:DeployAndInteract --rpc-url $TESTNET_RPC_URL --broadcast
- Inspect the transaction trace via the RPC of
gethanderigon:
debug_traceTransactionon both nodes.- Compare the outputs to observe the discrepancy in the erigon trace.
Option 2: Mainnet Analysis
- Identify a mainnet transaction with a failed subcall caused by
ErrInsufficientBalance. - Trace the transaction using the
debug_traceTransactionRPC method:
- Use geth RPC.
- Use erigon RPC.
- Compare the outputs from both nodes.
I believe the root cause can be traced to the following section of code: https://github.com/erigontech/erigon/blob/ab8c054a7179072bb12fa30c94dbb28f008c28d3/core/vm/evm.go#L181-L202
Specifically, the issue appears to be the absence of Enter and Exit hooks in this portion of the code. Would be happy to contribute to addressing this.
Will probably be addressed with PR #10757
@yperbasis Correct, the PR moves the CallEnter/Exit to cover all failures cases.
somnathb1 changed Importance from Imp1 to Imp3
Should be fixed by PR #14289