Skip to content

fix(rpc): emit spec message for eth_simulateV1 -38020#11665

Merged
svlachakis merged 2 commits into
NethermindEth:masterfrom
0xDevNinja:fix/11219-simulateV1-out-of-order-message
May 19, 2026
Merged

fix(rpc): emit spec message for eth_simulateV1 -38020#11665
svlachakis merged 2 commits into
NethermindEth:masterfrom
0xDevNinja:fix/11219-simulateV1-out-of-order-message

Conversation

@0xDevNinja

Copy link
Copy Markdown
Contributor

Fixes #11219

Changes

  • SimulateTxExecutor.Execute returned -38020 (InvalidInputBlocksOutOfOrder) with a verbose, value-interpolated message: $"Block number out of order {given} is <= than previous block number of {prev}!". The execution-apis spec mandates a fixed message: "Block number in sequence did not increase".
  • Added SimulateErrorMessages.BlockNumberNotIncreasing so this canonical string sits next to the other spec-mandated messages (IntrinsicGas, FeeCapBelowBaseFee, InsufficientFunds) already shared with the test suite.
  • Use the constant at the validation site (SimulateTxExecutor.cs:137).
  • Added regression test Test_eth_simulate_returns_spec_message_when_block_numbers_not_increasing in EthSimulateTestsBlocksAndTransactions. Builds a SimulatePayload with a second BlockStateCall whose Number is strictly less than the first and asserts both ErrorCode == -38020 and Error == SimulateErrorMessages.BlockNumberNotIncreasing.

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

  • New regression test in EthSimulateTestsBlocksAndTransactions exercises the error path end-to-end through SimulateTxExecutor.Execute.
  • All 22 EthSimulateTestsBlocksAndTransactions tests pass.
  • dotnet format whitespace --folder clean.

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

The execution-apis spec defines error -38020 (`InvalidInputBlocksOutOfOrder`)
with a fixed message: "Block number in sequence did not increase". Nethermind
was returning a verbose `$"Block number out of order {given} is <= than previous
block number of {prev}!"` that fails strict spec conformance tests.

Add `SimulateErrorMessages.BlockNumberNotIncreasing` and use it at the
validation site so the test class continues to be the single source of truth
for canonical eth_simulateV1 error messages.

Regression test asserts both the error code (-38020) and the verbatim spec
message on a SimulatePayload whose second BlockStateCall has a strictly lower
Number than the first.

Fixes NethermindEth#11219
@LukaszRozmej

Copy link
Copy Markdown
Member

@claude review

@claude

claude Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Claude finished @LukaszRozmej's task in 1m 30s —— View job


Review

  • Read changed files
  • Review SimulateTxExecutor.cs changes
  • Review EthSimulateTestsBlocksAndTransactions.cs test additions
  • Check against repo rules and coding guidelines
  • Post findings

The fix is minimal, correct, and well-structured. The verbose, value-interpolated message is replaced with the spec-mandated constant, and the new constant is co-located with the other spec-mandated messages in SimulateErrorMessages with consistent documentation style.

Low — Assertion style inconsistency in new test

The new test at line 274–275 uses FluentAssertions (Should().Be()), while the comparable error-checking test at line 310–311 uses NUnit Assert.That. Both styles are mixed throughout this file, but the nearest equivalent test uses Assert.That. Minor; does not affect correctness.

// New test (lines 274-275) – FluentAssertions
result.ErrorCode.Should().Be(ErrorCodes.InvalidInputBlocksOutOfOrder);
result.Result!.Error.Should().Be(SimulateErrorMessages.BlockNumberNotIncreasing);

// Existing error test (lines 310-311) – NUnit
Assert.That(result.Result!.Error, Is.EqualTo(SimulateErrorMessages.InsufficientFunds));
Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.InsufficientFunds));

Low — Sibling error at line 161 has the same verbose-message pattern

BlockTimestampNotIncreased (-38021) still returns a value-interpolated string:

// SimulateTxExecutor.cs:161
return ResultWrapper<...>.Fail(
    $"Block timestamp out of order {blockToSimulate.BlockOverrides.Time} is <= than given base timestamp of {lastBlockTime}!",
    ErrorCodes.BlockTimestampNotIncreased);

If the execution-apis spec mandates a fixed message for -38021 (analogous to -38020), this should receive the same treatment. Worth a follow-up issue/PR.


Overall: clean fix, no blocking issues.

…urce

Collapse the standalone -38020 regression test plus the five existing
per-error tests into one parameterized eth_simulateV1_returns_spec_error,
fed by static payload factories. Drops ~125 lines of duplicated chain-
setup + assertion boilerplate while keeping per-case names visible in the
test runner. sender_is_not_eoa kept separate (needs a custom EIP-3607
chain).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@svlachakis svlachakis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is possible to change in the spec, but let's merge for now

@svlachakis svlachakis merged commit 574ee28 into NethermindEth:master May 19, 2026
542 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eth_simulateV1 wrong message for out-of-order block number (-38020)

3 participants