Skip to content

eth: return iterator errors from debug_storageRangeAt - #35554

Open
ghwo336 wants to merge 1 commit into
ethereum:masterfrom
ghwo336:fix/storage-range-iterator-error
Open

eth: return iterator errors from debug_storageRangeAt#35554
ghwo336 wants to merge 1 commit into
ethereum:masterfrom
ghwo336:fix/storage-range-iterator-error

Conversation

@ghwo336

@ghwo336 ghwo336 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

debug_storageRangeAt stops iterating when the iterator's Next method
returns false. Next returns false both when the range is exhausted and
when a trie node cannot be resolved, storing the failure in the
iterator's Err field. The method does not check Err after iteration, so
a trie failure can be reported as a normal result.

This also gives the response the wrong pagination meaning. When
iteration fails, the follow-up Next call used to compute NextKey returns
false and leaves NextKey nil. StorageRangeResult defines a nil NextKey
as meaning that the response includes the last key in the trie. The
caller is therefore told that the range is complete even though it was
truncated by a trie error.

Return the error already produced by the iterator. This follows the
existing handling used by other trie.NewIterator consumers, including
cmd/geth/dbcmd.go and the generators in core/state/snapshot and
triedb/pathdb.

Added a regression test that removes a storage trie node from the
database and verifies that storageRangeAt returns an error instead of a
truncated result.

@ghwo336
ghwo336 requested a review from rjl493456442 as a code owner August 18, 2026 10:53
Comment thread eth/api_debug_test.go Outdated
}
}

// TestStorageRangeAtMissingNode ensures that storageRangeAt returns an error,

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.

Pls remove the attached test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, removed the test.

@ghwo336
ghwo336 force-pushed the fix/storage-range-iterator-error branch from 85663ea to 4dff7d8 Compare August 24, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants