Skip to content

smartcontract: add Index account for multicast group code uniqueness#3414

Closed
martinsander00 wants to merge 1 commit intomainfrom
ms/pda-derivation-onchain
Closed

smartcontract: add Index account for multicast group code uniqueness#3414
martinsander00 wants to merge 1 commit intomainfrom
ms/pda-derivation-onchain

Conversation

@martinsander00
Copy link
Copy Markdown
Contributor

Resolves: #3408

Summary

  • Introduce an Index account (PDA derived from entity type + lowercased code) that enforces unique multicast group codes onchain and enables O(1) code-to-pubkey lookup
  • Integrate Index lifecycle into existing multicast group instructions: create (atomically creates Index), update (renames Index on code change), delete/close (closes Index)
  • Add standalone CreateIndex/DeleteIndex instructions (variants 104/105) for migration backfill of existing accounts
  • Add Index account type to Go, Python, and TypeScript SDKs

Split from #3256 (1/2). Rust SDK integration in #PENDING.

New derivation workflow: #3256 (comment)

Diff Breakdown

Category Files Lines (+/-) Net
Onchain program 16 +598 / -32 +566
SDKs (Go/Py/TS) 3 +3 / -0 +3
Activator 1 +10 / -1 +9
E2E 1 +0 / -1 -1
Tests 9 +691 / -47 +644
Other 1 +2 / -0 +2
Total 31 +1304 / -81 +1223

~53% tests, ~46% onchain program, ~1% other (activator, e2e, Go/Py/TS SDKs, changelog)

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 serialization
  • smartcontract/programs/doublezero-serviceability/src/processors/index/create.rs — standalone CreateIndex processor for migration backfill
  • smartcontract/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 group
  • smartcontract/programs/doublezero-serviceability/src/processors/index/delete.rs — standalone DeleteIndex processor for cleanup
  • smartcontract/programs/doublezero-serviceability/src/pda.rsget_index_pda() with case-insensitive seed derivation
  • sdk/serviceability/go/state.go, sdk/serviceability/python/serviceability/state.py, sdk/serviceability/typescript/serviceability/state.ts — add Index account type

Testing Verification

  • All existing integration tests updated to pass Index accounts to CreateMulticastGroup
  • New index_test.rs with tests for Index creation, duplicate rejection, deletion, and rename
  • Multicast group tests updated for Index lifecycle during create/update/delete/close
  • Onchain allocation tests cover Index + multicast group interaction

Introduce an Index account (PDA derived from entity type + lowercased
code) that enforces unique multicast group codes onchain and enables
O(1) code-to-pubkey lookup. Integrate Index lifecycle into multicast
group create/update/delete/close instructions. Add standalone
CreateIndex/DeleteIndex instructions (variants 104/105) for migration
backfill. Update Go, Python, and TypeScript SDKs with Index account type.
@martinsander00
Copy link
Copy Markdown
Contributor Author

Superseded — using #3256 directly as PR1 instead

@martinsander00 martinsander00 deleted the ms/pda-derivation-onchain branch March 31, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Establish Index PDA account pattern

1 participant