Fix space revocation bug #122
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix panics caused by data inconsistency from Expired space revocations
Summary
This PR fixes two related panics that occurred when interacting with spaces that were revoked due to expiration. Both issues stemmed from the same root cause: data inconsistency where
RevokeReason::Expiredonly removed the Outpoint->Spaceout mapping but left the Space->Outpoint mapping, creating orphaned entries.Issues Fixed
1. Panic when querying revoked spaces (
getspacecommand)Location:
client/src/store.rsandclient/src/client.rsget_space_infowould panic with "should exist if outpoint exists" because the Space->Outpoint mapping existed but the Spaceout was missing.RevokeReason::Expiredhandler only removed Outpoint->Spaceout mapping but didn't remove Space->Outpoint mapping.get_space_infohandle inconsistencies gracefully by returningNoneand cleaning up orphaned mappings instead of panicking2. Panic in open subcommand (
spaces open)Location:
protocol/src/script.rs.expect("spaceout exists")with propermatchstatement to handleNonecase gracefully, treating missing spaceout as a new space (since the space was effectively revoked/unregistered).Changes
client/src/client.rs: FixedRevokeReason::Expiredto remove both Space->Outpoint and Outpoint->Spaceout mappingsclient/src/store.rs: Added graceful handling of data inconsistencies inget_space_infowith automatic cleanupprotocol/src/script.rs: Fixedprepare_opento handle missing spaceout gracefully instead of panickingTesting
Both fixes have been tested and verified:
getspacecommand now returns gracefully instead of panickingspaces opencommand now handles revoked spaces correctly instead of panickingImpact