feat(indexer): reconcile in-memory tree from DB on rollback#748
feat(indexer): reconcile in-memory tree from DB on rollback#748kilianglas wants to merge 10 commits into
Conversation
Replace per-leaf rollback history with post-rollback reconciliation from the accounts table, removing TREE_MAX_BLOCK_AGE and pruning failure modes. Co-authored-by: Cursor <cursoragent@cursor.com>
TreeState is already Clone via an internal Arc, so wrapping it again was unnecessary. Co-authored-by: Cursor <cursoragent@cursor.com>
|
/otto review |
|
I've kicked off a thorough review of PR #748 — the subagent is cloning the repo, analyzing the diff, and will post inline comments directly on the PR along with a summary. I'll let you know once it's done. |
| value: U256, | ||
| event_id: WorldIdRegistryEventId, | ||
| _event_id: WorldIdRegistryEventId, | ||
| ) -> TreeResult<()> { |
There was a problem hiding this comment.
Now that _event_id is unused in both TreeState::apply_leaf and VersionedTreeState::set_leaf_at_index, might be worth a follow-up to remove the parameter from the TreeApplier trait and all callers to reduce API surface noise. Not blocking for this PR — just a thought for cleanup.
There was a problem hiding this comment.
/otto remove this
Review SummaryOverall: Looks good 👍 This is a well-motivated simplification. Replacing the bounded per-leaf in-memory history with a DB-based reconciliation after rollback is strictly more robust — it eliminates the What I liked:
One thing to verify: since See inline comments for minor items (none blocking). |
|
The review is complete. Here's what was done on PR #748: Verdict: Looks good — a solid net simplification (~300 lines removed) that makes the rollback mechanism more robust by eliminating the 5 inline comments were posted:
A brief top-level summary was also posted on the PR. |
|
Fixed — pushed a commit that corrects the duplicate |
|
/otto review again |
|
Re-review kicked off — the subagent is doing a fresh pass on the updated PR, skipping already-addressed comments. I'll update you when it's done. |
|
|
||
| /// Set each affected in-memory leaf to the post-rollback `accounts` row, or zero | ||
| /// when the account was removed. | ||
| pub async fn reconcile_tree_from_db( |
There was a problem hiding this comment.
Nit/observability: since this is a pub function that could be called from different contexts, consider adding a tracing::info! at the top (and on completion) to make rollback debugging easier:
tracing::info!(affected_leaves = affected_leaf_indices.len(), ?target_event_id, "reconciling in-memory tree from DB");rollback_to_event logs the affected count already, but those logs appear before the DB commit, while this function runs after — having both helps confirm the commit succeeded and reconciliation started/finished.
Review SummaryThis is a solid simplification. Replacing the bounded per-leaf history rollback with a DB-based reconciliation eliminates the Correctness: I traced through the full rollback flow ( Test coverage: The new Two minor observations (non-blocking):
LGTM overall. 👍 |
|
Re-review is done. Here's the summary: Overall verdict: LGTM — the core rollback logic is correct. The subagent traced through the full rollback flow and confirmed:
New inline comment posted:
Non-blocking observations in summary:
|
c750a33 to
c8b15bc
Compare
Summary
Replace per-leaf rollback history-based rollback mechanism of indexer in-memory tree with DB-based rollbacks. This makes the logic simpler and overall more robust.