Skip to content

[Storehouse] 002 - Payloadless forest#8573

Open
zhangchiqing wants to merge 7 commits into
leo/payloadless-testsfrom
leo/payloadless-forest
Open

[Storehouse] 002 - Payloadless forest#8573
zhangchiqing wants to merge 7 commits into
leo/payloadless-testsfrom
leo/payloadless-forest

Conversation

@zhangchiqing

@zhangchiqing zhangchiqing commented Jun 8, 2026

Copy link
Copy Markdown
Member

This PR adds Payloadless forest.

Strategy: same copy-then-modify pattern as Spec 001 (mtrie/forest.go → payloadless/forest.go).
See spec

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 623fc2ae-7c75-4f57-bf6c-0333d90f555f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch leo/payloadless-forest

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

these tests are to verify payloadless implementation with the existing full trie implementation.

}

// look up for non existing paths
exists, err := f.HasPaths(r)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The full trie forest uses ValueSize() method to look up for non existing paths, but since payloadless forest does not store value size anymore, instead, a HasPaths() method is added to be used here.


// TestForestEquivalence_HasPathsVsValueSizes verifies that for every path,
// payloadless.HasPaths reports true iff the full forest's ValueSizes is > 0.
func TestForestEquivalence_HasPathsVsValueSizes(t *testing.T) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

verify HasPaths is equivalent to ValueSize in checking the path exists.

// Under the hood it uses a circular buffer
// of mtrie pointers and a map of rootHash to cache index for fast lookup
type TrieCache struct {
tries []*MTrie

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

same implementation as ledger/complete/mtrie/trieCache.go, except the tries is a slice of payloadless trie

@zhangchiqing zhangchiqing marked this pull request as ready for review June 8, 2026 16:25
@zhangchiqing zhangchiqing requested a review from a team as a code owner June 8, 2026 16:25
@zhangchiqing zhangchiqing changed the title [Storehouse Payloadless forest [Storehouse] Payloadless forest Jun 8, 2026
@zhangchiqing zhangchiqing changed the title [Storehouse] Payloadless forest [Storehouse] Spec 002 - Payloadless forest Jun 8, 2026
@zhangchiqing zhangchiqing changed the title [Storehouse] Spec 002 - Payloadless forest [Storehouse] 002 - Payloadless forest Jun 8, 2026
@janezpodhostnik

Copy link
Copy Markdown
Contributor

This is a bit difficult to review, because its copy and modify. Do you think you could split this into a copy PR + modify PR?

@zhangchiqing zhangchiqing changed the base branch from leo/payloadless-tests to leo/payloadless-forest-base June 18, 2026 16:41
@zhangchiqing

zhangchiqing commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

This is a bit difficult to review, because its copy and modify. Do you think you could split this into a copy PR + modify PR?

It's hard to do. I tried to add a commit with the original forest file copied to payloadless package to be used as a comparison base, and changed the base branch. But it doesn't work, because github would complain about merge conflict.

Is that ok if you use local diff tool to show the actual diff?
for instance:

vimdiff ledger/complete/mtrie/trieCache.go ledger/complete/payloadless/trieCache.go

@zhangchiqing zhangchiqing changed the base branch from leo/payloadless-forest-base to leo/payloadless-tests June 18, 2026 16:46
@janezpodhostnik

Copy link
Copy Markdown
Contributor

That is ok, thank you for checking. I'll continue diffing locally

Comment thread ledger/complete/payloadless/forest.go Outdated
return nil, err
}

return trie.ReadSingleLeafHash(r.Path), nil

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.

we previously copied the value to prevent bugs/problems where downstream code would modify the value. Do we want to return a copy here as well, for the same reason.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah, make sense, updated

@zhangchiqing zhangchiqing force-pushed the leo/payloadless-tests branch from a5b9162 to b213f48 Compare July 2, 2026 18:00
zhangchiqing and others added 7 commits July 2, 2026 11:00
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- switch package to payloadless and drop import of mtrie/trie
- Forest now stores leaf hashes per register, not payloads
- replace ValueSizes with HasPaths (returns existence, not byte sizes)
- replace Read/ReadSingleValue with ReadLeafHashes/ReadSingleLeafHash
- Update/NewTrie extract value bytes from u.Payloads and discard keys
- Proofs returns *ledger.PayloadlessTrieBatchProof
- drop RegSize metrics and payload-size accounting

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- switch package to payloadless and drop external imports of mtrie/{trie,node}, ptrie, prf
- read assertions now compare HashLeaf(path, value) against returned *hash.Hash
- ReadSingleValue tests become ReadSingleLeafHash
- ValueSizes tests become HasPaths (existence-only flags)
- drop tests that depend on full-payload proof verification or partial-trie reconstruction:
  TestNonExistingInvalidProof, TestRandomUpdateReadProofValueSizes, TestProofGenerationInclusion
- randomMTrie uses NewNode and NewMTrie from the payloadless package

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@zhangchiqing zhangchiqing force-pushed the leo/payloadless-forest branch from b10a8f7 to ba46fa2 Compare July 2, 2026 18:00
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