Skip to content

indexers: use recordmode#372

Open
kcalvinalvin wants to merge 5 commits into
utreexo:mainfrom
kcalvinalvin:2026-03-05-use-recordmode
Open

indexers: use recordmode#372
kcalvinalvin wants to merge 5 commits into
utreexo:mainfrom
kcalvinalvin:2026-03-05-use-recordmode

Conversation

@kcalvinalvin
Copy link
Copy Markdown
Contributor

No description provided.

@kcalvinalvin kcalvinalvin force-pushed the 2026-03-05-use-recordmode branch from a4cd2fd to 47dfce8 Compare March 5, 2026 06:59
Move the per-block replay logic out of the initConsistentUtreexoState
loop into its own replayBlock method. Always use ModifyAndReturnTTLs
since the Forest backend provides TTL data regardless of prune mode.
@kcalvinalvin kcalvinalvin force-pushed the 2026-03-05-use-recordmode branch from 47dfce8 to 5587e9b Compare March 5, 2026 08:49
Add recordModeEndHeight parameter to InitUtreexoState and
initConsistentUtreexoState. Add replayBlockRecord method that
uses Forest.Record() to defer parent hash computation during
crash recovery replay, calling HashAll() at the end height.

Both callers pass -1 for now (no record mode), so there is
no behavior change yet.
Add maxTTLStumpHeight() which computes the last TTL stump height
from chaincfg params. Add recordModeEndHeight field and
inRecordMode() method to both FlatUtreexoProofIndex and
UtreexoProofIndex. The field is not yet wired up.
During IBD up to the TTL stump height, use Forest.Record() instead
of Modify() to defer all parent hash computation. At the stump
height, call HashAll() once and flush. This avoids expensive
per-block SHA computations for blocks where proofs aren't needed.

- Init: compute recordModeEndHeight, pass to InitUtreexoState
- ConnectBlock: dispatch to connectBlockRecord in record mode
- connectBlockRecord: Record(), empty proof/roots placeholders,
  real TTL data, HashAll+flush at boundary
- attachBlock: use Record() in record mode
- initUtreexoRootsState: skip record mode heights (no valid roots)
Same optimization as the flat index: during IBD up to the TTL
stump height, use Forest.Record() instead of Modify() to defer
parent hash computation. At the stump height, call HashAll()
once, store the real utreexo state, and flush.

- Init: compute recordModeEndHeight, pass to InitUtreexoState
- ConnectBlock: dispatch to connectBlockRecord in record mode
- connectBlockRecord: Record(), HashAll+store state+flush at boundary
- initUtreexoRootsState: skip record mode heights
- initBlockSummaryState: skip record mode heights
@kcalvinalvin kcalvinalvin force-pushed the 2026-03-05-use-recordmode branch from 5587e9b to 6a5fd2a Compare March 5, 2026 11:42
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.

1 participant