Skip to content

trie: fix embedded node size validation#2652

Merged
ucwong merged 1 commit into
masterfrom
dev
Feb 19, 2026
Merged

trie: fix embedded node size validation#2652
ucwong merged 1 commit into
masterfrom
dev

Conversation

@ucwong
Copy link
Copy Markdown
Member

@ucwong ucwong commented Feb 19, 2026

The decodeRef function used size > hashLen to reject oversized embedded nodes, but this incorrectly allowed nodes of exactly 32 bytes through. The encoding side (hasher.go, stacktrie.go) consistently uses len(enc) < 32 to decide whether to embed a node inline, meaning nodes of 32+ bytes are always hash-referenced. The error message itself already stated want size < 32, confirming the intended threshold. Changed size > hashLen to size >= hashLen in decodeRef to align the decoding validation with the encoding logic, the Yellow Paper spec, and the surrounding comments.

The `decodeRef` function used `size > hashLen` to reject oversized
embedded nodes, but this incorrectly allowed nodes of exactly 32 bytes
through. The encoding side (hasher.go, stacktrie.go) consistently uses
`len(enc) < 32` to decide whether to embed a node inline, meaning nodes
of 32+ bytes are always hash-referenced. The error message itself
already stated `want size < 32`, confirming the intended threshold.
Changed `size > hashLen` to `size >= hashLen` in `decodeRef` to align
the decoding validation with the encoding logic, the Yellow Paper spec,
and the surrounding comments.
@ucwong ucwong marked this pull request as ready for review February 19, 2026 08:42
@ucwong ucwong merged commit 0383d9e into master Feb 19, 2026
1 check failed
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