smartcontract: add Index account for multicast group code uniqueness#3256
Draft
martinsander00 wants to merge 1 commit intomainfrom
Draft
smartcontract: add Index account for multicast group code uniqueness#3256martinsander00 wants to merge 1 commit intomainfrom
martinsander00 wants to merge 1 commit intomainfrom
Conversation
bcfbe3c to
9ba8974
Compare
Introduce an Index account pattern that enforces unique multicast group codes onchain and enables O(1) code-to-pubkey lookup. The Index PDA is derived from the entity type seed and lowercased code, providing case-insensitive uniqueness. Integrated into existing instructions: - CreateMulticastGroup: creates Index alongside the group - UpdateMulticastGroup: atomically renames Index on code change - DeleteMulticastGroup/CloseAccount: closes Index if provided Standalone CreateIndex/DeleteIndex instructions (variants 104/105) added for migration backfill of existing accounts. SDK updated with Index PDA derivation in create/update/get commands and new CreateIndex/DeleteIndex command wrappers.
9ba8974 to
a67cb86
Compare
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.
Summary of Changes
Diff Breakdown
~45% tests, ~45% core logic, ~10% scaffolding (module wiring, SDK command wrappers)
Key files (click to expand)
smartcontract/programs/doublezero-serviceability/src/state/index.rs— new Index account struct (34 bytes: account_type + pubkey + bump_seed) with Borsh serializationsmartcontract/programs/doublezero-serviceability/src/processors/index/create.rs— standalone CreateIndex processor for migration backfillsmartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/update.rs— atomic Index rename when multicast group code changes (close old, create new)smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/create.rs— creates Index account alongside multicast groupsmartcontract/programs/doublezero-serviceability/src/processors/index/delete.rs— standalone DeleteIndex processor for cleanupsmartcontract/programs/doublezero-serviceability/src/pda.rs—get_index_pda()with case-insensitive seed derivationsmartcontract/sdk/rs/src/commands/multicastgroup/get.rs— O(1) Index PDA lookup with fallback scan for pre-migration accountssmartcontract/sdk/rs/src/commands/multicastgroup/update.rs— derives old/new Index PDAs when code changesTesting Verification
make rust-build,make rust-lint, andmake rust-testall pass