Feature/storage maintenance#490
Open
jessie-hash-pixel wants to merge 4 commits into
Open
Conversation
Implements cleanup_revoked_commitment(ip_id) which removes a revoked IP record and its commitment-owner index entry from persistent storage. Only the record owner may call this after revoking. - Add DataKey variants: CompressedCommitment, ShardIps, IpAuditTrail, IpDisputes, NextDisputeId, Snapshot, NextSnapshotId, CommitmentChecksumV2 - Add CommitmentSnapshot struct - Add cleanup_revoked_commitment() contract method - Add require_is_revoked() validation helper - Add tests: cleanup removes record, cleanup of non-revoked panics
Implements create_snapshot(caller) and get_snapshot(snapshot_id) for lightweight registry state snapshots. Each snapshot records total IP count and a sha256 checksum of the NextId counter as a state fingerprint. Snapshot IDs are monotonically increasing. Admin-only creation. - Add create_snapshot() contract method - Add get_snapshot() contract method - Add snapshot tests: create/get, sequential IDs, nonexistent returns None - Add docs/storage-maintenance.md documentation
Implements compute_integrity_checksum(caller) and verify_integrity_checksum() to detect data corruption or unauthorized state changes. The checksum is sha256 over all active (non-revoked) commitment hashes in ID order, stored under CommitmentChecksumV2. Revoked commitments are excluded so revoking an IP changes the checksum. Admin-only for computation. - Add compute_integrity_checksum() contract method - Add verify_integrity_checksum() contract method - Add tests: compute+verify, no stored checksum returns true, revoked IPs change the checksum
Implements batch_revoke_commitments(owner, ip_ids) which revokes a list of IP commitments atomically. The caller must own every IP in the list. Each revoked IP emits a revoked event and an immutable audit entry. Returns the count of IPs revoked. - Add batch_revoke_commitments() contract method - Add tests: all revoked, correct count, already-revoked panics, wrong owner panics
|
@jessie-hash-pixel Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Storage Maintenance: Cleanup, Snapshots, Integrity Checksums & Batch Revoke
Summary
This PR implements four storage maintenance features for the IP Registry contract. Each feature is delivered as its own commit with implementation, tests, and documentation.
Branch:
feature/storage-maintenance→mainChanges
closes #440
closes #441
closes #442
closes #443
Commit 1 — Cleanup Expired/Revoked Commitments (
90a52d7)Adds
cleanup_revoked_commitment(ip_id)which permanently removes a revoked IP record and itsCommitmentOwnerindex entry from persistent ledger storage. Only the record owner may call this, and the IP must already be revoked. The owner's ID list is updated atomically and acleanupevent is emitted.Why: Soroban persistent storage has rent costs. Leaving revoked records on-chain indefinitely wastes ledger space and increases rent fees for the contract. This gives owners a way to reclaim that space after revoking.
Commit 2 — Periodic Snapshots for Disaster Recovery (
44b4576)Adds
create_snapshot(caller)andget_snapshot(snapshot_id). Each snapshot is aCommitmentSnapshotrecord containing:snapshot_id— monotonically increasing identifiertimestamp— ledger timestamp at creationtotal_count— number of IPs committed at snapshot timechecksum— sha256 of theNextIdcounter as a lightweight state fingerprintAdmin-only creation. Snapshots are stored in persistent storage and retrievable by ID indefinitely.
Why: Provides a recoverable reference point for the registry state. Operators can compare snapshot
total_countandchecksumagainst live state to detect divergence after an incident.Commit 3 — Cryptographic Checksum Integrity Verification (
8a5a9b7)Adds
compute_integrity_checksum(caller)andverify_integrity_checksum(). The checksum is sha256 over the concatenation of all active (non-revoked) commitment hashes in ID order, stored underCommitmentChecksumV2. Revoked commitments are excluded, so revoking an IP changes the checksum.verify_integrity_checksum()recomputes and compares — returnstrueif they match or no checksum has been stored yet.Why: Detects silent data corruption or unauthorized state mutations between checkpoints. Complements the existing
IpCommitmentChecksum(which used an empty preimage) with a real iterative checksum over live data.Commit 4 — Batch Expire Commitments (
3a758f5)Adds
batch_revoke_commitments(owner, ip_ids)which revokes a list of IP commitments atomically in one transaction. The caller must own every IP in the list — if any check fails the entire transaction panics. Each revoked IP emits arevokedevent and an immutable audit entry. Returns the count of IPs revoked.Why: Owners with many IPs (e.g. a company winding down a product line) would otherwise need one transaction per IP to revoke. Batching reduces gas costs and simplifies client-side tooling.
Files Changed
contracts/ip_registry/src/lib.rsDataKeyvariants,CommitmentSnapshotstruct, four new contract methods,require_is_revokedhelpercontracts/ip_registry/src/test.rsdocs/storage-maintenance.md+559 lines, 0 deletions across 3 files.
Tests
12 new tests added to
contracts/ip_registry/src/test.rs:test_cleanup_revoked_commitment_removes_recordtest_cleanup_non_revoked_panicstest_create_and_get_snapshottest_snapshot_ids_are_sequentialtest_get_snapshot_nonexistent_returns_nonetest_compute_and_verify_integrity_checksumtest_verify_integrity_checksum_no_stored_returns_truetest_checksum_excludes_revoked_commitmentstest_batch_revoke_commitments_marks_all_revokedtest_batch_revoke_returns_correct_counttest_batch_revoke_already_revoked_panicstest_batch_revoke_wrong_owner_panicsChecklist
batch_revoke_commitments)docs/storage-maintenance.md)