Skip to content

Fix GetTreeState to follow Orchard SkipHash independently#549

Open
zmanian wants to merge 1 commit intozcash:masterfrom
zmanian:fix-gettreestate-orchard
Open

Fix GetTreeState to follow Orchard SkipHash independently#549
zmanian wants to merge 1 commit intozcash:masterfrom
zmanian:fix-gettreestate-orchard

Conversation

@zmanian
Copy link

@zmanian zmanian commented Feb 11, 2026

Summary

  • GetTreeState followed only the Sapling SkipHash chain, then returned whatever Orchard state happened to be at that ancestor block
  • Since Sapling and Orchard have independent SkipHash chains, the Sapling ancestor often lacks Orchard FinalState, causing empty orchardTree for post-NU5 blocks
  • Now follows Orchard's SkipHash chain independently when needed
  • Pre-NU5 blocks correctly return empty OrchardTree (no Orchard SkipHash exists)

Closes #438

Test plan

  • go build ./... passes
  • go vet ./frontend/... passes
  • Query GetTreeState for a post-NU5 block and verify both saplingTree and orchardTree are populated
  • Query GetTreeState for a pre-NU5 block and verify orchardTree is empty (expected)
  • Query GetLatestTreeState and verify both trees are populated

Generated with Claude Code

The GetTreeState handler followed only the Sapling SkipHash chain to
find a block with Sapling FinalState, then returned whatever Orchard
state happened to be at that same block. Since Sapling and Orchard have
independent SkipHash chains, the Sapling ancestor block often lacks
Orchard FinalState, causing GetTreeState to return an empty OrchardTree
for post-NU5 blocks.

Now, after finding Sapling FinalState, if Orchard FinalState is missing,
we restart from the originally requested block and follow Orchard's own
SkipHash chain. Pre-NU5 blocks correctly return an empty OrchardTree
since no Orchard SkipHash exists.

Also fixes a pre-existing "cannot marshal" typo (should be "cannot
unmarshal") and adds an iteration bound to both SkipHash loops to
guard against infinite loops from malformed zcashd responses.

Fixes zcash#438

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zmanian zmanian force-pushed the fix-gettreestate-orchard branch from 8f685c3 to c00fa1b Compare February 11, 2026 23: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.

GetTreeState gRPC needs more updates for Orchard

1 participant