Skip to content

Document caching shard store + test drop/flush different behavior.#185

Draft
dannywillems wants to merge 4 commits into
zcash:mainfrom
dannywillems:dw/document-caching-deferred-actions
Draft

Document caching shard store + test drop/flush different behavior.#185
dannywillems wants to merge 4 commits into
zcash:mainfrom
dannywillems:dw/document-caching-deferred-actions

Conversation

@dannywillems

Copy link
Copy Markdown
Contributor

No description provided.

nuttycom and others added 2 commits June 30, 2026 13:04
Adds the ability to mark a checkpoint for retention so that it is exempt
from automatic pruning of excess checkpoints. A retained checkpoint's root,
and witnesses for marked leaves at or before it, remain computable even
after it has aged more than `max_checkpoints` behind the tip of the tree.

Retention is an explicit operation, decoupled from leaf marking:
`ShardTree::ensure_retained` records a checkpoint id in a new retention set
on the `ShardStore` (`add_retained_checkpoint` / `remove_retained_checkpoint`
/ `retained_checkpoints`), and `ShardTree::remove_retained_checkpoint`
releases it. `prune_excess_checkpoints` excludes retained checkpoints from
the `max_checkpoints` budget and never removes them. The witness-supporting
nodes survive because the retained checkpoint's own `CHECKPOINT` retention
keeps the subtree straddling its position from collapsing; no `Reference`
retention is required.

See zcash#183.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
@dannywillems
dannywillems marked this pull request as draft July 2, 2026 09:18
Explain the deferred-action mechanism in `CachingShardStore`. The store
serves reads and additive writes from its in-memory cache and, on
`flush`, reconstructs the backend by re-writing the full cached state.
That re-write reproduces additions but cannot express removals, so
destructive operations are recorded as `Action`s and replayed against
the backend before the additive state is written back.

Document each `Action` variant with the `ShardStore` removal method it
replays, and describe the two-phase flush and the drop-without-flush
behavior on the `flush` method.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dannywillems
dannywillems force-pushed the dw/document-caching-deferred-actions branch from e2a30f7 to dde8a17 Compare July 2, 2026 09:18
Add two tests covering how `CachingShardStore` propagates cached
mutations to the backend. The backend is passed to the store as `&mut`
(via the blanket `ShardStore for &mut S` impl), so it stays owned by the
test and can be inspected once the store, and its borrow, are gone.

`flush_persists_to_backend` asserts the backend is populated only after
`flush` is called. `drop_without_flush_does_not_persist` lets the store
go out of scope without flushing and asserts the backend is never
written.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dannywillems
dannywillems force-pushed the dw/document-caching-deferred-actions branch from dde8a17 to 7e05038 Compare July 2, 2026 09:21
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