Suggested amendments for PR #8569: [Storehouse] 001 - Add payloadless node and trie implementation#8599
Merged
Conversation
…ne docs, add node/trie tests Encapsulate the "move a compact leaf to a new height" operation inside node.go (NewRelevelledLeaf) so trie.go business logic no longer branches on the allocated- vs-unallocated-register distinction; refine node/trie documentation and the mtrie README Update case taxonomy; add exhaustive node_test.go / trie_test.go coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[Storehouse] 001 - Add payloadless node and trie implementation
zhangchiqing
approved these changes
Jul 8, 2026
Co-authored-by: Leo Zhang <zhangchiqing@gmail.com>
Co-authored-by: Leo Zhang <zhangchiqing@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status: draft
Opened as a draft on purpose. The code-level changes are reviewed and I am happy with them, but the motivation behind them deserves a fuller write-up — this description is a first pass at that motivation, to be refined.
Summary
Suggested amendments stacked directly on
leo/payloadless(the head of #8569). The central change improves encapsulation and separation of concerns for constructing and re-leveling compact leaves, so the trie update logic no longer has to reason whether internal implementation details ofnoderepresent allocated- vs unallocated-registers. Also added several documentation and spec refinements with node/trie unit tests for the code I modified.Encapsulating leaf re-leveling
In #8569, moving an existing compact leaf to a new height uses
NewLeafWithHash(node.go L96–106). Its contract places an unchecked requirement on the caller:leafHashmust beHashLeaf(path, originalValue). UnlikeNewLeaf(node.go L72), which handles nil/empty values internally,NewLeafWithHashdoes not — so the higher-level trie code must itself distinguish allocated vs unallocated registers and select the right constructor. That created the need for additionalifbranching in trie code (further driving complexity): trie.go L294 and trie.go L348.Consequences:
update.HashLeaf(path, [])toNewLeafWithHashwould silently mint a non-default leaf for an empty value — an invalid leaf by our construction convention. Today's callers avoid this, but the guard lives on the caller side, not in the constructor.(Background: internal Slack discussion + PR review comment #8569 (discussion_r3464907588).)
Change: self-contained constructor
Introduce
NewRelevelledLeaf(leaf, relevellingHeight)(node.go L188–211): a single constructor that re-levels an existing leaf and performs the consistency checks internally, so valid input ⇒ valid output regardless of whether the leaf represents an allocated or unallocated register.nilinput yieldsniloutput (a default leaf must carry the representative path of the register it stands for). The trie then delegates via a single call — trie.go L300–308 — and the caller-side split disappears.Also included:
mtrie/README.mdUpdate case-taxonomy renumbered and clarified (explicit Case 0 re-use, consistent sub-case labels, spec-accuracy fixes).node_test.goandtrie_test.go(complements [Storehouse] 001 - Add payloadless node and trie implementation #8569, which defers tests to [Storehouse] 001 Part2 - Add payloadless trie test cases #8572).Notes for reviewers
leo/payloadless(notmaster), so the diff is exactly the delta on top of [Storehouse] 001 - Add payloadless node and trie implementation #8569.node_test.gocarries a pre-existinggofmtcomment-alignment nit (intentional doc alignment); left as-is.