Skip to content

fix(evm): align insufficient-funds-for-transfer message with Geth#12167

Merged
LukaszRozmej merged 4 commits into
masterfrom
fix/eth-call-insufficient-funds-for-transfer
Jun 30, 2026
Merged

fix(evm): align insufficient-funds-for-transfer message with Geth#12167
LukaszRozmej merged 4 commits into
masterfrom
fix/eth-call-insufficient-funds-for-transfer

Conversation

@manusw7

@manusw7 manusw7 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #12164.

  • Changes the error message for insufficient balance on value transfer from "insufficient sender balance for transfer" to "insufficient funds for transfer" to match Geth's output
  • Removes the now-redundant string replacement in StructLogEnvelopeWriter since the message is correct at the source
  • Updates all test assertions to use the new message string

Why

viem, ethers, and other client libraries regex-match on "insufficient funds" to detect this error. Nethermind's non-standard message caused false negatives in those libraries.

@claude

claude Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Claude finished @manusw7's task in 2m 9s —— View job


Review: PR #12167 — align insufficient-funds-for-transfer message with Geth

  • Read PR diff
  • Review error-message change for correctness/ambiguity
  • Verify Geth alignment
  • Check StructLogEnvelopeWriter fallthrough
  • Confirm all assertions updated
  • Post review

The change is clean and well-targeted. Renaming TransactionResult.InsufficientSenderBalance / GasEstimator.InsufficientBalance to "insufficient funds for transfer" makes the substring "insufficient funds" match for client libraries, and removing the now-redundant ReplacePrefix in StructLogEnvelopeWriter is correct — the ErrorType.InsufficientSenderBalance case now falls through to _ => detail (line 118) and returns the already-correct source message. All RPC-boundary assertions were updated consistently, and the eth_call/eth_estimateGas path is fully covered (BlockchainBridge.Call converts InsufficientBalanceExceptionTransactionResult.InsufficientSenderBalance at BlockchainBridge.cs:412-414).

Findings

Medium — alignment is incomplete; a sibling RPC error path still emits the old wording

InsufficientBalanceException (src/Nethermind/Nethermind.State/InsufficientBalanceException.cs:8) still carries:

: StateException($"insufficient sender balance for transfer: address {address}")

This .Message is surfaced directly to JSON-RPC callers via JsonRpcService.GetInsufficientBalanceMessage (JsonRpcService.cs:557-558) under the InvalidInput branch (JsonRpcService.cs:531). For eth_call/eth_estimateGas this is harmless because BlockchainBridge catches and converts the exception. But any RPC method that lets this exception reach the JsonRpcService catch-all returns "insufficient sender balance for transfer: address 0x…", which does not contain "insufficient funds" — i.e. the exact regex-match failure this PR aims to fix would still occur on that surface.

Suggest either aligning this message too (e.g. "insufficient funds for transfer: address {address}") for consistency, or explicitly noting in the PR that this path is intentionally out of scope. Fix this →

Low — no new regression test

CONTRIBUTING asks for a regression test when fixing a bug. The PR updates existing assertions rather than adding a new test. This is acceptable here since the changed message is already guarded at the RPC boundary by BlockchainBridgeTests and EthRpcModuleTests.EstimateGas, but if the Medium item above is addressed it should come with a dedicated assertion.

Low — verify exact Geth string

"insufficient funds for transfer" satisfies the stated goal (contains "insufficient funds"). Worth a quick confirmation that this is the exact Geth wording for the value-transfer case (Geth's combined check is "insufficient funds for gas * price + value", and its EVM-level error is "insufficient balance for transfer", which Nethermind already mirrors in EvmExceptionExtensions.cs:21).

Verdict

No correctness, security, or performance concerns — string-only change on a non-hot path. The Medium finding is a consistency gap relative to the PR's own rationale; it does not break anything but should be addressed or explicitly acknowledged before merge.

@svlachakis

svlachakis commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This looks like it was changed here #11561

@benaadams Is there any reason? Any other tests maybe failing somewhere else or just an accident?

@manusw7

manusw7 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

EVM Opcode Benchmark Diff

Aggregated runs: base=3, pr=3
Noisy rerun opcodes: DIV, SELFDESTRUCT, SGT

Improvements (1)

Opcode Base Median (ns) PR Median (ns) Delta Abs Δ (ns) Base CV PR CV Threshold Uncertainty Effective
SELFDESTRUCT 1560.500 250.150 -83.97% 1310.350 6.4% 23.2% ±5.0% ±7.4% ±46.4%

@LukaszRozmej LukaszRozmej left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Potentially some tests should also share the const, but that is debatable and probably not all, so I will leave it up to you.

Comment thread src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs Outdated
Comment thread src/Nethermind/Nethermind.State/InsufficientBalanceException.cs Outdated
@manusw7
manusw7 requested a review from LukaszRozmej June 29, 2026 21:55
@LukaszRozmej
LukaszRozmej merged commit 016ac63 into master Jun 30, 2026
698 of 700 checks passed
@LukaszRozmej
LukaszRozmej deleted the fix/eth-call-insufficient-funds-for-transfer branch June 30, 2026 09:12
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_call / eth_estimateGas: insufficient-funds-for-transfer message does not contain Geth canonical substring

4 participants