From ff0f13200c4af973593eb7120576212a5184313a Mon Sep 17 00:00:00 2001 From: ManuelArto Date: Mon, 8 Jun 2026 19:14:42 +0200 Subject: [PATCH 1/3] fix(eth_sendRawTransaction): return InvalidParams error for malformed RLP and enhance error messages --- .../Modules/Eth/EthRpcModuleTests.cs | 17 +++++++++++------ .../Modules/Eth/EthRpcModule.cs | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index cb47cdaefb66..b7322b512b2c 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs @@ -1904,14 +1904,19 @@ public async Task Send_raw_transaction_will_send_transaction(string rawTransacti Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Invalid, InvalidTxSignature: Signature is invalid.\"},\"id\":67}")); } - [Test] - public async Task Send_raw_transaction_returns_invalid_rlp_for_empty_list() + [TestCase("c0", TestName = "EmptyList")] + [TestCase("d4", TestName = "TruncatedShortList")] + [TestCase("09c0", TestName = "UnknownTxType")] + [TestCase("03c0", TestName = "Eip4844_TruncatedList")] + [TestCase("04c0", TestName = "Eip7702_TruncatedList")] + public async Task Send_raw_transaction_returns_invalid_params_for_malformed_rlp(string rawTxHex) { using Context ctx = await Context.Create(); - string serialized = await ctx.Test.TestEthRpc("eth_sendRawTransaction", "c0"); + string serialized = await ctx.Test.TestEthRpc("eth_sendRawTransaction", rawTxHex); - Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Invalid RLP.\"},\"id\":67}")); + Assert.That(serialized, Does.Contain($"\"code\":{ErrorCodes.InvalidParams}")); + Assert.That(serialized, Does.Contain("Invalid RLP.")); } [TestCaseSource(nameof(SendRawTransactionSyncFailureCases))] @@ -1929,7 +1934,7 @@ public async Task EthSendRawTransactionSync_WhenSubmitFailsOrTimesOut_ReturnsExp private static IEnumerable SendRawTransactionSyncFailureCases() { - yield return new TestCaseData("c0", null, ErrorCodes.TransactionRejected, "Invalid RLP") + yield return new TestCaseData("c0", null, ErrorCodes.InvalidParams, "Invalid RLP")") .SetName("InvalidRlp"); Transaction tx = Build.A.Transaction @@ -2391,7 +2396,7 @@ public async Task eth_sendRawTransaction_returns_correct_error_if_AuthorityTuple string result = await test.TestEthRpc("eth_sendRawTransaction", Bytes.ToHexString(Rlp.Encode(invalidSetCodeTx).Bytes)); JsonRpcErrorResponse actual = new EthereumJsonSerializer().Deserialize(result); - Assert.That(actual.Error!.Code, Is.EqualTo(ErrorCodes.TransactionRejected)); + Assert.That(actual.Error!.Code, Is.EqualTo(ErrorCodes.InvalidParams)); } [Test] diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs index d2c88f4027ac..09c5b9719f25 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -366,9 +366,9 @@ public virtual async Task> eth_sendRawTransaction(byte[] RlpBehaviors.AllowUnsigned | RlpBehaviors.SkipTypedWrapping | RlpBehaviors.InMempoolForm); return await SendTx(tx); } - catch (RlpException) + catch (RlpException e) { - return ResultWrapper.Fail("Invalid RLP.", ErrorCodes.TransactionRejected); + return ResultWrapper.Fail("Invalid RLP: " + e.Message, ErrorCodes.InvalidParams); } } From 93cb4413574de1e134b2df1b4f5ad4f0e9241f8d Mon Sep 17 00:00:00 2001 From: ManuelArto Date: Mon, 15 Jun 2026 16:49:58 +0200 Subject: [PATCH 2/3] fix(tests): correct error message formatting for invalid RLP in eth_sendRawTransaction tests --- .../Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index 0929f2e644d3..b9b097dcf432 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs @@ -1933,7 +1933,7 @@ public async Task Send_raw_transaction_returns_invalid_params_for_malformed_rlp( string serialized = await ctx.Test.TestEthRpc("eth_sendRawTransaction", rawTxHex); Assert.That(serialized, Does.Contain($"\"code\":{ErrorCodes.InvalidParams}")); - Assert.That(serialized, Does.Contain("Invalid RLP.")); + Assert.That(serialized, Does.Contain("Invalid RLP:")); } [TestCaseSource(nameof(SendRawTransactionSyncFailureCases))] @@ -1951,7 +1951,7 @@ public async Task EthSendRawTransactionSync_WhenSubmitFailsOrTimesOut_ReturnsExp private static IEnumerable SendRawTransactionSyncFailureCases() { - yield return new TestCaseData("c0", null, ErrorCodes.InvalidParams, "Invalid RLP")") + yield return new TestCaseData("c0", null, ErrorCodes.InvalidParams, "Invalid RLP") .SetName("InvalidRlp"); Transaction tx = Build.A.Transaction From bc502991e73856f963d6ba47aeea0f5bade4ae3b Mon Sep 17 00:00:00 2001 From: Manuel Arto <43347768+manusw7@users.noreply.github.com> Date: Mon, 15 Jun 2026 18:19:52 +0200 Subject: [PATCH 3/3] Update src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> --- src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs index 09c5b9719f25..4917af28f883 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -368,7 +368,7 @@ public virtual async Task> eth_sendRawTransaction(byte[] } catch (RlpException e) { - return ResultWrapper.Fail("Invalid RLP: " + e.Message, ErrorCodes.InvalidParams); + return ResultWrapper.Fail($"Invalid RLP: {e.Message}", ErrorCodes.InvalidParams); } }