Commit ffcb132
committed
shardtree: truncate exactly at an achievable boundary, never retaining data beyond the cut
truncate_to_checkpoint_internal swallowed the None that
LocatedPrunableTree::truncate_to_position returns when the requested
position falls inside a pruned hash leaf or a Nil region: shards, cap,
and checkpoints were all left untouched while the call reported success.
A caller that truncates after a chain reorg then re-inserts recomputed
subtrees over the retained stale hashes, and insert_subtree fails with
InsertionError::Conflict at the stale address, deterministically and
forever.
Truncation at a position inside a pruned region is not representable: a
single pruned hash commits to data on both sides of the cut. Truncation
is now total and honest instead: any node committing to data beyond the
cut is discarded, the boundary retreats to the position immediately
preceding the discarded node's range, cached annotations along the cut
path are cleared, shards and cap are truncated at the same achieved
boundary, checkpoints are always truncated, and checkpoints recording
positions beyond the achieved boundary (including the truncation target
itself) are removed. truncate_to_checkpoint and
truncate_to_checkpoint_depth report the achieved TreeState so callers
can re-insert data beyond the boundary, e.g. by rescanning the chain
from the achieved state.1 parent 7b23adb commit ffcb132
4 files changed
Lines changed: 563 additions & 89 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
47 | 68 | | |
48 | 69 | | |
49 | 70 | | |
| |||
0 commit comments