Skip to content

Commit 8025017

Browse files
committed
fix(rpc): change ExecutionError code from -32003 to -32000 to match Geth
1 parent 6d6e14e commit 8025017

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EthCall.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public async Task Eth_call_web3_should_return_insufficient_balance_error()
6464
$"{{\"from\":\"{TestAccountAddress}\",\"gasPrice\":\"0x100000\", \"data\": \"{BalanceOfCallData}\", \"to\": \"{BatTokenAddress}\", \"value\": 500, \"gas\": 1000000}}");
6565
string serialized = await ctx.Test.TestEthRpc("eth_call", transaction);
6666
JToken parsed = JToken.Parse(serialized);
67-
Assert.That(parsed["error"]!["code"]!.Value<int>(), Is.EqualTo(-32003));
67+
Assert.That(parsed["error"]!["code"]!.Value<int>(), Is.EqualTo(-32000));
6868
Assert.That(parsed["error"]!["message"]!.Value<string>(), Does.Contain("insufficient funds for gas * price + value"));
6969
AssertAccountDoesNotExist(ctx, TestAccount);
7070
}
@@ -111,7 +111,7 @@ public async Task Eth_call_no_recipient_should_work_as_init()
111111
string serialized =
112112
await ctx.Test.TestEthRpc("eth_call", transaction, "latest");
113113
Assert.That(
114-
serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32003,\"message\":\"stack underflow\"},\"id\":67}"));
114+
serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"stack underflow\"},\"id\":67}"));
115115
}
116116

117117

@@ -334,7 +334,7 @@ public async Task Eth_call_with_value_transfer_without_from_address_should_throw
334334
$"{{\"type\": \"0x2\", \"value\":\"{1.Ether}\", \"data\": \"{dataStr}\"}}");
335335
string serialized = await ctx.Test.TestEthRpc("eth_call", transaction);
336336
JToken parsed = JToken.Parse(serialized);
337-
Assert.That(parsed["error"]!["code"]!.Value<int>(), Is.EqualTo(-32003));
337+
Assert.That(parsed["error"]!["code"]!.Value<int>(), Is.EqualTo(-32000));
338338
Assert.That(parsed["error"]!["message"]!.Value<string>(), Does.Contain("insufficient funds for gas * price + value"));
339339
}
340340

@@ -498,7 +498,7 @@ public async Task Eth_call_uses_gas_cap_when_not_specified()
498498
$"{{\"from\": \"{SecondaryTestAddress}\", \"data\": \"{InfiniteLoopCode.ToHexString(true)}\"}}");
499499

500500
string serialized = await ctx.Test.TestEthRpc("eth_call", transaction);
501-
Assert.That(JToken.Parse(serialized), Is.EqualTo(JToken.Parse($"{{\"jsonrpc\":\"2.0\",\"error\":{{\"code\":-32003,\"message\":\"out of gas\"}},\"id\":67}}")).Using(JToken.EqualityComparer));
501+
Assert.That(JToken.Parse(serialized), Is.EqualTo(JToken.Parse($"{{\"jsonrpc\":\"2.0\",\"error\":{{\"code\":-32000,\"message\":\"out of gas\"}},\"id\":67}}")).Using(JToken.EqualityComparer));
502502
}
503503

504504
[Test]
@@ -821,7 +821,7 @@ public async Task Eth_call_bubbles_up_precompile_errors()
821821

822822
string serialized = await ctx.Test.TestEthRpc("eth_call", transaction);
823823

824-
Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32003,\"message\":\"Precompile MODEXP failed with error: one or more of base/exponent/modulus length exceeded 1024 bytes\"},\"id\":67}"));
824+
Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Precompile MODEXP failed with error: one or more of base/exponent/modulus length exceeded 1024 bytes\"},\"id\":67}"));
825825
}
826826

827827
[TestCase("""{"input":"0x23e52","gasPrice":"0x1"}""", TestName = "Legacy tx odd-length input")]
@@ -854,7 +854,7 @@ private static async Task TestEthCallOutOfGas(Context ctx, ulong? specifiedGasLi
854854
$"{{\"from\": \"{SecondaryTestAddress}\"{gasParam}, \"data\": \"{InfiniteLoopCode.ToHexString(true)}\"}}");
855855

856856
string serialized = await ctx.Test.TestEthRpc("eth_call", transaction);
857-
Assert.That(JToken.Parse(serialized), Is.EqualTo(JToken.Parse($"{{\"jsonrpc\":\"2.0\",\"error\":{{\"code\":-32003,\"message\":\"out of gas\"}},\"id\":67}}")).Using(JToken.EqualityComparer));
857+
Assert.That(JToken.Parse(serialized), Is.EqualTo(JToken.Parse($"{{\"jsonrpc\":\"2.0\",\"error\":{{\"code\":-32000,\"message\":\"out of gas\"}},\"id\":67}}")).Using(JToken.EqualityComparer));
858858
}
859859

860860
// Each test uses a state override to inject one-opcode contract code at the target address,
@@ -1013,7 +1013,7 @@ public async Task Eth_call_setCode_invalid_transaction_returns_error(string txJs
10131013
string serialized = await ctx.Test.TestEthRpc("eth_call", transaction, "latest");
10141014

10151015
JToken parsed = JToken.Parse(serialized);
1016-
Assert.That(parsed["error"]!["code"]!.Value<int>(), Is.EqualTo(-32003));
1016+
Assert.That(parsed["error"]!["code"]!.Value<int>(), Is.EqualTo(-32000));
10171017
Assert.That(parsed["error"]!["message"]!.Value<string>(), Does.Contain(expectedMessage));
10181018
}
10191019

@@ -1067,7 +1067,7 @@ public async Task Eth_call_zero_balance_reports_full_required_balance(
10671067

10681068
using (Assert.EnterMultipleScope())
10691069
{
1070-
Assert.That(parsed["error"]!["code"]!.Value<int>(), Is.EqualTo(-32003));
1070+
Assert.That(parsed["error"]!["code"]!.Value<int>(), Is.EqualTo(-32000));
10711071
Assert.That(message, Does.Contain("insufficient funds for gas * price + value"));
10721072
Assert.That(message, Does.Contain(expectedDetailSubstring));
10731073
}

src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static class ErrorCodes
4545
/// <summary>
4646
/// EVM execution error (out of gas, insufficient funds during execution, etc.)
4747
/// </summary>
48-
public const int ExecutionError = -32003;
48+
public const int ExecutionError = -32000;
4949

5050
/// <summary>
5151
/// Requested resource not found

src/Nethermind/Nethermind.Runner.Test/JsonRpc/StartupTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public async Task HttpJsonRpcResponseSink_OmitsNullErrorData()
281281
Error = new Error { Code = ErrorCodes.ExecutionError, Message = "out of gas" }
282282
});
283283

284-
Assert.That(response, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32003,\"message\":\"out of gas\"},\"id\":1}"));
284+
Assert.That(response, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"out of gas\"},\"id\":1}"));
285285
}
286286

287287
[Test]

0 commit comments

Comments
 (0)