Skip to content

Commit 278bf30

Browse files
committed
remove wrong claude commits and do changes
1 parent ae6f143 commit 278bf30

2 files changed

Lines changed: 151 additions & 16 deletions

File tree

src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,4 +702,139 @@ public async Task eth_simulateV1_intrinsic_gas_returns_spec_error_code_and_messa
702702
Assert.That(result.Result!.Error, Is.EqualTo(SimulateErrorMessages.IntrinsicGas));
703703
}
704704

705+
/// <summary>
706+
/// Regression test: eth_simulateV1 with validation:true and a nonce below the account's current
707+
/// nonce must return -38010 (NonceTooLow).
708+
/// </summary>
709+
[Test]
710+
public async Task eth_simulateV1_nonce_too_low_returns_spec_error_code()
711+
{
712+
TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain();
713+
714+
// Set the account's nonce to 10, then send a tx with nonce 0 (below current).
715+
SimulatePayload<TransactionForRpc> payload = new()
716+
{
717+
BlockStateCalls =
718+
[
719+
new()
720+
{
721+
StateOverrides = new Dictionary<Address, AccountOverride>
722+
{
723+
{ TestItem.AddressA, new AccountOverride { Balance = 1.Ether, Nonce = 10 } }
724+
},
725+
Calls =
726+
[
727+
new LegacyTransactionForRpc
728+
{
729+
From = TestItem.AddressA,
730+
To = TestItem.AddressB,
731+
Value = UInt256.Zero,
732+
Nonce = 0,
733+
GasPrice = UInt256.Zero,
734+
Gas = 21_000
735+
}
736+
]
737+
}
738+
],
739+
Validation = true
740+
};
741+
742+
ResultWrapper<IReadOnlyList<SimulateBlockResult<SimulateCallResult>>> result =
743+
chain.EthRpcModule.eth_simulateV1(payload, BlockParameter.Latest);
744+
745+
Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.NonceTooLow));
746+
}
747+
748+
/// <summary>
749+
/// Regression test: eth_simulateV1 with validation:true and a nonce above the account's current
750+
/// nonce must return -38011 (NonceTooHigh).
751+
/// </summary>
752+
[Test]
753+
public async Task eth_simulateV1_nonce_too_high_returns_spec_error_code()
754+
{
755+
TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain();
756+
757+
// Account nonce is 0; send a tx with nonce 100 (way above current).
758+
SimulatePayload<TransactionForRpc> payload = new()
759+
{
760+
BlockStateCalls =
761+
[
762+
new()
763+
{
764+
StateOverrides = new Dictionary<Address, AccountOverride>
765+
{
766+
{ TestItem.AddressA, new AccountOverride { Balance = 1.Ether } }
767+
},
768+
Calls =
769+
[
770+
new LegacyTransactionForRpc
771+
{
772+
From = TestItem.AddressA,
773+
To = TestItem.AddressB,
774+
Value = UInt256.Zero,
775+
Nonce = 100,
776+
GasPrice = UInt256.Zero,
777+
Gas = 21_000
778+
}
779+
]
780+
}
781+
],
782+
Validation = true
783+
};
784+
785+
ResultWrapper<IReadOnlyList<SimulateBlockResult<SimulateCallResult>>> result =
786+
chain.EthRpcModule.eth_simulateV1(payload, BlockParameter.Latest);
787+
788+
Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.NonceTooHigh));
789+
}
790+
791+
/// <summary>
792+
/// Regression test: eth_simulateV1 with validation:true and a sender address that has deployed
793+
/// code (EIP-3607) must return -38024 (SenderIsNotEoa).
794+
/// </summary>
795+
[Test]
796+
public async Task eth_simulateV1_sender_is_not_eoa_returns_spec_error_code()
797+
{
798+
TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain();
799+
800+
// Override TestItem.AddressC with contract code — makes it a non-EOA sender.
801+
SimulatePayload<TransactionForRpc> payload = new()
802+
{
803+
BlockStateCalls =
804+
[
805+
new()
806+
{
807+
StateOverrides = new Dictionary<Address, AccountOverride>
808+
{
809+
{
810+
TestItem.AddressC,
811+
new AccountOverride
812+
{
813+
Balance = 1.Ether,
814+
Code = Bytes.FromHexString("0x60006000")
815+
}
816+
}
817+
},
818+
Calls =
819+
[
820+
new LegacyTransactionForRpc
821+
{
822+
From = TestItem.AddressC,
823+
To = TestItem.AddressB,
824+
Value = UInt256.Zero,
825+
GasPrice = UInt256.Zero,
826+
Gas = 21_000
827+
}
828+
]
829+
}
830+
],
831+
Validation = true
832+
};
833+
834+
ResultWrapper<IReadOnlyList<SimulateBlockResult<SimulateCallResult>>> result =
835+
chain.EthRpcModule.eth_simulateV1(payload, BlockParameter.Latest);
836+
837+
Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.SenderIsNotEoa));
838+
}
839+
705840
}

src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,44 +123,44 @@ public static class ErrorCodes
123123
public const int Default = -32000;
124124

125125
/// <summary>
126-
/// Transaction maxFeePerGas is below the block base fee — eth_simulateV1 spec error
126+
/// Transaction nonce is lower than the account's current nonce — eth_simulateV1 spec error
127127
/// </summary>
128-
public const int FeeCapBelowBaseFee = -38012;
128+
public const int NonceTooLow = -38010;
129129

130130
/// <summary>
131-
/// Transaction gas limit is below the intrinsic gas cost
131+
/// Transaction nonce is higher than the account's current nonce — eth_simulateV1 spec error
132132
/// </summary>
133-
public const int IntrinsicGas = -38013;
133+
public const int NonceTooHigh = -38011;
134134

135135
/// <summary>
136-
/// Not enough value to cover transaction costs
136+
/// Transaction maxFeePerGas is below the block base fee — eth_simulateV1 spec error
137137
/// </summary>
138-
public const int InsufficientFunds = -38014;
138+
public const int FeeCapBelowBaseFee = -38012;
139139

140140
/// <summary>
141-
/// Gas limit reached
141+
/// Transaction gas limit is below the intrinsic gas cost — eth_simulateV1 spec error
142142
/// </summary>
143-
public const int BlockGasLimitReached = -38015;
143+
public const int IntrinsicGas = -38013;
144144

145145
/// <summary>
146-
/// Transaction nonce is lower than the account's current nonce
146+
/// Not enough value to cover transaction costs — eth_simulateV1 spec error
147147
/// </summary>
148-
public const int NonceTooLow = -38010;
148+
public const int InsufficientFunds = -38014;
149149

150150
/// <summary>
151-
/// Transaction nonce is higher than the account's current nonce
151+
/// Gas limit reached — eth_simulateV1 spec error
152152
/// </summary>
153-
public const int NonceTooHigh = -38011;
153+
public const int BlockGasLimitReached = -38015;
154154

155155
/// <summary>
156-
/// EIP-3860. Code size is to big
156+
/// Sender account has deployed code (is not an EOA) — eth_simulateV1 spec error
157157
/// </summary>
158-
public const int MaxInitCodeSizeExceeded = -38025;
158+
public const int SenderIsNotEoa = -38024;
159159

160160
/// <summary>
161-
/// Sender account has deployed code (is not an EOA)
161+
/// EIP-3860. Code size is too big — eth_simulateV1 spec error
162162
/// </summary>
163-
public const int SenderIsNotEoa = -38024;
163+
public const int MaxInitCodeSizeExceeded = -38025;
164164

165165
/// <summary>
166166
/// Error during EVM execution

0 commit comments

Comments
 (0)