Fix eth_call error format to match Geth compatibility
Summary
This PR fixes discrepancies between Nethermind and Geth for eth_call error responses, specifically for execution reverted errors. The issue was that Nethermind returned different error codes, messages, and data formats compared to Geth.
Problem
When eth_call encounters a revert, Geth and Nethermind returned different responses:
Geth response:
{
"error": {
"code": 3,
"data": "0xdf2d9b42",
"message": "execution reverted"
}
}
Nethermind response (before fix):
{
"error": {
"code": -32015,
"data": "err: 0xdf2d9b42 (supplied gas 36000000)",
"message": "VM execution error."
}
}
Solution
The fix introduces Geth-compatible error handling for revert cases while preserving existing behavior for other execution errors:
-
Added new error code:
ErrorCodes.ExecutionReverted = 3for Geth compatibility -
Enhanced error detection: Modified
CallTxExecutorto detect revert errors by checking if the error string starts with "revert" - Updated error format: For reverts, return raw revert data instead of wrapped format with gas information
- Maintained backward compatibility: Non-revert errors still use the existing format
Key Changes
-
ErrorCodes.cs: Added
ExecutionReverted = 3constant -
EthRpcModule.TransactionExecutor.cs:
- Added
IsRevertError()method to detect revert vs other execution errors - Modified
CallTxExecutor.ExecuteTx()to handle reverts with Geth-compatible format
- Added
- EthRpcModuleTests.EthCall.cs: Updated existing test to expect new revert format
Flow
CallOutput.Error starts with "revert"?
├─ Yes: Return code 3, message "execution reverted", raw output data
└─ No: Return code -32015, message "VM execution error.", wrapped error data
Testing
- Verified revert detection logic works correctly for various error scenarios
- Updated existing test that was expecting old revert format
- Maintains compatibility for all non-revert execution errors
The fix handles both test cases from the original issue:
- Revert with data
0xdf2d9b42→ Returns code3, message "execution reverted", data"0xdf2d9b42" - Revert with empty data → Returns code
3, message "execution reverted", data"0x"
Fixes #8813.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Why have you added dotnet-install.sh?
I accidentally added dotnet-install.sh in commit 87cc380 while working on the eth_call fix. This file was unrelated to the issue and shouldn't have been included. I've removed it in commit d2cdf3c.