smartcontract: derive multicast group PDA from code to prevent duplicates#3155
Open
martinsander00 wants to merge 3 commits intomainfrom
Open
smartcontract: derive multicast group PDA from code to prevent duplicates#3155martinsander00 wants to merge 3 commits intomainfrom
martinsander00 wants to merge 3 commits intomainfrom
Conversation
…0.9.0 testnet v0.9.0 was released before the code-based PDA change, so it computes the wrong PDA against the current program.
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.
Resolves: #3115
Summary
account_index, allowing two groups with the samecodeto be created at different addresses. Changed PDA derivation to usecodeas the seed (matching the Tenant pattern), so duplicate codes are structurally impossible — a second create with the same code derives the same PDA, which already exists, triggeringAccountAlreadyInitialized.get <code>) now derive the PDA directly for O(1) lookup instead of scanning all accounts. A fallback togetProgramAccountsscan ensures backward compatibility with legacy index-based accounts.account_indexfor multicast groups).Lines of Code
Testing Verification
test_multicastgroup_create_duplicate_code_failsthat creates a multicast group, then attempts to create another with the same code and asserts failuretest_commands_multicastgroup_get_legacy_index_pda_fallbackthat verifies code-based lookup falls back togetProgramAccountsscan when the code-derived PDA doesn't exist (legacy account scenario)