Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add elements using the '(re)applied index' index instead of the revert index #108

Closed
wants to merge 1 commit into from

Conversation

peterjan
Copy link
Member

@peterjan peterjan commented Apr 24, 2024

This PR passes an appliedIndex to revertChainUpdate which is used whenever we re-add elements. Before, we were re-adding those elements using the revertIndex which is definitely incorrect because we go and delete those in revertIndex. I renamed revertIndex to removeEvents and changed it to only remove events because if a revert is processed correctly the elements should already have been removed.

The idea of an appliedIndex as the counterpart for every revertIndex feels a bit naive maybe but I decided to propose it nonetheless because I don't see what's wrong with it either. If we can't do that I feel the only thing we're left with is soft deletion but that comes with its own issues, mostly complexity trade-off.

@peterjan peterjan self-assigned this Apr 24, 2024
@peterjan peterjan marked this pull request as ready for review April 24, 2024 13:22
@n8maninger
Copy link
Member

n8maninger commented Apr 24, 2024

Orphans can only be created when a reorg occurs and a rescan is interrupted. This is specific to walletd locking the main scan thread during a rescan. Reverted blocks should never create orphans since they’re reverted properly.

Base automatically changed from pj/remove-chain-index to master April 24, 2024 20:42
@peterjan
Copy link
Member Author

Orphans can only be created when a reorg occurs and a rescan is interrupted. This is specific to walletd locking the main scan thread during a rescan. Reverted blocks should never create orphans since they’re reverted properly.

I updated the PR to pass the corresponding appliedIndex along with every revertIndex because it's definitely wrong what we are doing currently in revertChainUpdate. When we revertIndex on the very last step we are removing the re-added elements.

@peterjan peterjan changed the title Revert orphans both when processing revert updates as well as apply updates Re-add elements using the '(re)applied index' index instead of the revert index Apr 29, 2024
@peterjan
Copy link
Member Author

peterjan commented May 2, 2024

Closing in favour of #109

@peterjan peterjan closed this May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants