From ae6f14362b8c9644da53b0c00ded0046b5bf556f Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Thu, 30 Apr 2026 13:21:54 +0530 Subject: [PATCH 1/4] added eth_simulate_error_code --- src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs | 15 +++++++++++++++ .../Modules/Eth/SimulateTxExecutor.cs | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs b/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs index d981d916986..30bd7ea5f54 100644 --- a/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs +++ b/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs @@ -142,11 +142,26 @@ public static class ErrorCodes /// public const int BlockGasLimitReached = -38015; + /// + /// Transaction nonce is lower than the account's current nonce + /// + public const int NonceTooLow = -38010; + + /// + /// Transaction nonce is higher than the account's current nonce + /// + public const int NonceTooHigh = -38011; + /// /// EIP-3860. Code size is to big /// public const int MaxInitCodeSizeExceeded = -38025; + /// + /// Sender account has deployed code (is not an EOA) + /// + public const int SenderIsNotEoa = -38024; + /// /// Error during EVM execution /// diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs index 189c9343a40..c02c211c815 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs @@ -255,11 +255,11 @@ private static int MapSimulateErrorCode(TransactionResult txResult) TransactionResult.ErrorType.MaxFeePerGasBelowBaseFee or TransactionResult.ErrorType.MinerPremiumNegative => ErrorCodes.FeeCapBelowBaseFee, TransactionResult.ErrorType.NonceOverflow => ErrorCodes.InternalError, - TransactionResult.ErrorType.SenderHasDeployedCode => ErrorCodes.InvalidParams, + TransactionResult.ErrorType.SenderHasDeployedCode => ErrorCodes.SenderIsNotEoa, TransactionResult.ErrorType.SenderNotSpecified => ErrorCodes.InternalError, TransactionResult.ErrorType.TransactionSizeOverMaxInitCodeSize => ErrorCodes.MaxInitCodeSizeExceeded, - TransactionResult.ErrorType.TransactionNonceTooHigh => ErrorCodes.InternalError, - TransactionResult.ErrorType.TransactionNonceTooLow => ErrorCodes.InternalError, + TransactionResult.ErrorType.TransactionNonceTooHigh => ErrorCodes.NonceTooHigh, + TransactionResult.ErrorType.TransactionNonceTooLow => ErrorCodes.NonceTooLow, _ => ErrorCodes.InternalError }; } From 278bf30f3ea655b6346f5d11cdb94800dfc5638d Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Thu, 30 Apr 2026 14:39:15 +0530 Subject: [PATCH 2/4] remove wrong claude commits and do changes --- .../EthSimulateTestsBlocksAndTransactions.cs | 135 ++++++++++++++++++ .../Nethermind.JsonRpc/ErrorCodes.cs | 32 ++--- 2 files changed, 151 insertions(+), 16 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs index 2ee6e297c9f..3344fe96052 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs @@ -702,4 +702,139 @@ public async Task eth_simulateV1_intrinsic_gas_returns_spec_error_code_and_messa Assert.That(result.Result!.Error, Is.EqualTo(SimulateErrorMessages.IntrinsicGas)); } + /// + /// Regression test: eth_simulateV1 with validation:true and a nonce below the account's current + /// nonce must return -38010 (NonceTooLow). + /// + [Test] + public async Task eth_simulateV1_nonce_too_low_returns_spec_error_code() + { + TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain(); + + // Set the account's nonce to 10, then send a tx with nonce 0 (below current). + SimulatePayload payload = new() + { + BlockStateCalls = + [ + new() + { + StateOverrides = new Dictionary + { + { TestItem.AddressA, new AccountOverride { Balance = 1.Ether, Nonce = 10 } } + }, + Calls = + [ + new LegacyTransactionForRpc + { + From = TestItem.AddressA, + To = TestItem.AddressB, + Value = UInt256.Zero, + Nonce = 0, + GasPrice = UInt256.Zero, + Gas = 21_000 + } + ] + } + ], + Validation = true + }; + + ResultWrapper>> result = + chain.EthRpcModule.eth_simulateV1(payload, BlockParameter.Latest); + + Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.NonceTooLow)); + } + + /// + /// Regression test: eth_simulateV1 with validation:true and a nonce above the account's current + /// nonce must return -38011 (NonceTooHigh). + /// + [Test] + public async Task eth_simulateV1_nonce_too_high_returns_spec_error_code() + { + TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain(); + + // Account nonce is 0; send a tx with nonce 100 (way above current). + SimulatePayload payload = new() + { + BlockStateCalls = + [ + new() + { + StateOverrides = new Dictionary + { + { TestItem.AddressA, new AccountOverride { Balance = 1.Ether } } + }, + Calls = + [ + new LegacyTransactionForRpc + { + From = TestItem.AddressA, + To = TestItem.AddressB, + Value = UInt256.Zero, + Nonce = 100, + GasPrice = UInt256.Zero, + Gas = 21_000 + } + ] + } + ], + Validation = true + }; + + ResultWrapper>> result = + chain.EthRpcModule.eth_simulateV1(payload, BlockParameter.Latest); + + Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.NonceTooHigh)); + } + + /// + /// Regression test: eth_simulateV1 with validation:true and a sender address that has deployed + /// code (EIP-3607) must return -38024 (SenderIsNotEoa). + /// + [Test] + public async Task eth_simulateV1_sender_is_not_eoa_returns_spec_error_code() + { + TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain(); + + // Override TestItem.AddressC with contract code — makes it a non-EOA sender. + SimulatePayload payload = new() + { + BlockStateCalls = + [ + new() + { + StateOverrides = new Dictionary + { + { + TestItem.AddressC, + new AccountOverride + { + Balance = 1.Ether, + Code = Bytes.FromHexString("0x60006000") + } + } + }, + Calls = + [ + new LegacyTransactionForRpc + { + From = TestItem.AddressC, + To = TestItem.AddressB, + Value = UInt256.Zero, + GasPrice = UInt256.Zero, + Gas = 21_000 + } + ] + } + ], + Validation = true + }; + + ResultWrapper>> result = + chain.EthRpcModule.eth_simulateV1(payload, BlockParameter.Latest); + + Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.SenderIsNotEoa)); + } + } diff --git a/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs b/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs index 30bd7ea5f54..bdc798a89f8 100644 --- a/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs +++ b/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs @@ -123,44 +123,44 @@ public static class ErrorCodes public const int Default = -32000; /// - /// Transaction maxFeePerGas is below the block base fee — eth_simulateV1 spec error + /// Transaction nonce is lower than the account's current nonce — eth_simulateV1 spec error /// - public const int FeeCapBelowBaseFee = -38012; + public const int NonceTooLow = -38010; /// - /// Transaction gas limit is below the intrinsic gas cost + /// Transaction nonce is higher than the account's current nonce — eth_simulateV1 spec error /// - public const int IntrinsicGas = -38013; + public const int NonceTooHigh = -38011; /// - /// Not enough value to cover transaction costs + /// Transaction maxFeePerGas is below the block base fee — eth_simulateV1 spec error /// - public const int InsufficientFunds = -38014; + public const int FeeCapBelowBaseFee = -38012; /// - /// Gas limit reached + /// Transaction gas limit is below the intrinsic gas cost — eth_simulateV1 spec error /// - public const int BlockGasLimitReached = -38015; + public const int IntrinsicGas = -38013; /// - /// Transaction nonce is lower than the account's current nonce + /// Not enough value to cover transaction costs — eth_simulateV1 spec error /// - public const int NonceTooLow = -38010; + public const int InsufficientFunds = -38014; /// - /// Transaction nonce is higher than the account's current nonce + /// Gas limit reached — eth_simulateV1 spec error /// - public const int NonceTooHigh = -38011; + public const int BlockGasLimitReached = -38015; /// - /// EIP-3860. Code size is to big + /// Sender account has deployed code (is not an EOA) — eth_simulateV1 spec error /// - public const int MaxInitCodeSizeExceeded = -38025; + public const int SenderIsNotEoa = -38024; /// - /// Sender account has deployed code (is not an EOA) + /// EIP-3860. Code size is too big — eth_simulateV1 spec error /// - public const int SenderIsNotEoa = -38024; + public const int MaxInitCodeSizeExceeded = -38025; /// /// Error during EVM execution From f792b227d0dacfb02bbb213d456a1260d60e0d0c Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Thu, 30 Apr 2026 14:47:49 +0530 Subject: [PATCH 3/4] correct sender_is_not_eoa test --- .../Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs index 3344fe96052..f8fc9ed74a1 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs @@ -795,7 +795,9 @@ public async Task eth_simulateV1_nonce_too_high_returns_spec_error_code() [Test] public async Task eth_simulateV1_sender_is_not_eoa_returns_spec_error_code() { - TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain(); + OverridableReleaseSpec spec = new(London.Instance) { IsEip3607Enabled = true }; + TestSpecProvider specProvider = new(spec) { AllowTestChainOverride = false }; + TestRpcBlockchain chain = await TestRpcBlockchain.ForTest(new TestRpcBlockchain()).Build(specProvider); // Override TestItem.AddressC with contract code — makes it a non-EOA sender. SimulatePayload payload = new() From 1cd2774be0e5d21a34cf55dd0ce5a81c5fc89a57 Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Mon, 4 May 2026 23:34:32 +0530 Subject: [PATCH 4/4] add hive test failure to known failing tests --- scripts/known-failing-hive-tests.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/known-failing-hive-tests.txt b/scripts/known-failing-hive-tests.txt index 8b1b62be06b..9a04671e37b 100644 --- a/scripts/known-failing-hive-tests.txt +++ b/scripts/known-failing-hive-tests.txt @@ -10,6 +10,7 @@ eth_simulateV1/ethSimulate-check-invalid-nonce (nethermind) eth_simulateV1/ethSimulate-gas-fees-and-value-error-38014-with-validation (nethermind) eth_simulateV1/ethSimulate-simple-no-funds-with-validation (nethermind) eth_simulateV1/ethSimulate-simple-no-funds-with-validation-without-nonces (nethermind) +eth_simulateV1/ethSimulate-simple-send-from-contract-with-validation (nethermind) # graphql