Skip to content

feat: add BatchAVLProver::restore_root - #22

Closed
mwaddip wants to merge 1 commit into
ergoplatform:mainfrom
mwaddip:feat/restore-root
Closed

feat: add BatchAVLProver::restore_root#22
mwaddip wants to merge 1 commit into
ergoplatform:mainfrom
mwaddip:feat/restore-root

Conversation

@mwaddip

@mwaddip mwaddip commented Jul 30, 2026

Copy link
Copy Markdown

Add BatchAVLProver::restore_root(root, height) — a single method that installs a persisted root and rebases the proof cycle atomically.

Replaces the ad-hoc field assignments currently spread across four restore sites in ergo-node-rust (startup resume, snapshot bootstrap, reset_to, rollback_prover_to). Each site does a different incomplete subset of old_top_node sync, flag reset, and buffer clear — restore_root owns the invariant in one place.

Depends on PR #21 (new_persisted constructors — nodes from unpack() need is_new = false so tree.reset() can reach them) and PR #18 (needs_cycle_reset guard — restore_root calls tree.reset() inline and must suppress the implicit reset in the next perform_one_operation). The full restore_root body with the needs_cycle_reset gate ships when all three land.

Add a public method that installs a persisted root and rebases the
proof cycle atomically. Replaces the ad-hoc field assignments currently
spread across four restore sites in the node.

After restoring a storage-loaded root, callers must:
- Clear is_new/visited flags on the fresh tree
- Drop stale changed-node buffers from the previous cycle
- Rebase old_top_node to the new root
- Clear accumulated directions from any prior (failed) cycle

restore_root() does all of this in one place, owning the proof-cycle
invariant.
@mwaddip

mwaddip commented Aug 12, 2026

Copy link
Copy Markdown
Author

Superseded by #27, which carries this commit patch-identical, alongside #11 and #18. It also clears modified_nodes in restore_root: only generate_proof() clears that map, and a rewound cycle never reaches it.

@mwaddip mwaddip closed this Aug 12, 2026
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