Skip to content

smartcontract: integrate Index into multicast group lifecycle#3415

Draft
martinsander00 wants to merge 2 commits intomainfrom
ms/pda-derivation-sdk
Draft

smartcontract: integrate Index into multicast group lifecycle#3415
martinsander00 wants to merge 2 commits intomainfrom
ms/pda-derivation-sdk

Conversation

@martinsander00
Copy link
Copy Markdown
Contributor

@martinsander00 martinsander00 commented Mar 31, 2026

Stacked on #3256

Summary

  • Wire Index account management into multicast group create, update, delete, and close instructions
  • Add rename_index/close_index args to control Index lifecycle during updates and deactivation
  • Update Rust SDK commands to derive and pass Index PDAs for all multicast group operations
  • Add Index account type to Go, Python, and TypeScript SDKs
  • Update activator to pass Index accounts during multicast group activation

Diff Breakdown

Category Files Lines (+/-) Net
Onchain program 5 +225 / -28 +197
Rust SDK 9 +337 / -63 +274
SDKs (Go/Py/TS) 3 +3 / -0 +3
Activator 1 +10 / -1 +9
E2E 1 +0 / -1 -1
Tests 8 +237 / -49 +188
Other 1 +2 / -0 +2
Total 28 +814 / -142 +672

~41% Rust SDK, ~28% onchain program, ~29% tests, ~2% other

Key files (click to expand)
  • smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/update.rs — atomic Index rename when multicast group code changes
  • smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/create.rs — creates Index account alongside multicast group
  • smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/delete.rs — closes Index during deletion
  • smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/closeaccount.rs — closes Index during account close
  • smartcontract/sdk/rs/src/commands/multicastgroup/get.rs — O(1) Index PDA lookup with fallback scan for pre-migration accounts
  • smartcontract/sdk/rs/src/commands/multicastgroup/deactivate.rs — derives Index PDA for deactivation flow
  • smartcontract/sdk/rs/src/commands/multicastgroup/update.rs — derives old/new Index PDAs when code changes

Testing Verification

  • All existing integration tests updated to pass Index accounts to multicast group instructions
  • Index lifecycle verified during create/update/delete/close flows
  • Onchain allocation tests updated to cover Index + multicast group interaction

@martinsander00 martinsander00 marked this pull request as draft March 31, 2026 04:40
@martinsander00 martinsander00 force-pushed the ms/pda-derivation-sdk branch from eee8619 to 913dd96 Compare March 31, 2026 04:42
@martinsander00 martinsander00 changed the title smartcontract: add Index PDA derivation to Rust SDK commands smartcontract: integrate Index into multicast group lifecycle Mar 31, 2026
@martinsander00 martinsander00 force-pushed the ms/pda-derivation-sdk branch 2 times, most recently from b46c0e8 to 1d42f65 Compare March 31, 2026 04:44
martinsander00 added a commit that referenced this pull request Apr 1, 2026
Resolves: #3408

## Summary
- Introduce an Index account (PDA derived from entity type + lowercased
code) for O(1) code-to-pubkey lookup and onchain uniqueness enforcement
- Add standalone CreateIndex/DeleteIndex instructions (variants 104/105)
for migration backfill of existing accounts
- Add Index PDA derivation (`get_index_pda`) and Rust SDK command
wrappers

Split PR (1/2). Integration into multicast group lifecycle follows in
#3415.

New derivation workflow:
#3256 (comment)

## Diff Breakdown
| Category         | Files | Lines (+/-)   | Net   |
|------------------|-------|---------------|-------|
| Onchain program  |    12 | +373 / -4     | +369  |
| Rust SDK         |     4 | +75 / -0      | +75   |
| Tests            |     2 | +456 / -0     | +456  |
| CHANGELOG            |     1 | +2 / -0     | +2  |
| **Total**        |    18 | +906 / -4     | +902  |

~50% tests, ~41% onchain program, ~9% Rust SDK

<details>
<summary>Key files (click to expand)</summary>

- `smartcontract/programs/doublezero-serviceability/src/state/index.rs`
— new Index account struct (account_type + pubkey + bump_seed) with
Borsh serialization
-
`smartcontract/programs/doublezero-serviceability/src/processors/index/create.rs`
— standalone CreateIndex processor
-
`smartcontract/programs/doublezero-serviceability/src/processors/index/delete.rs`
— standalone DeleteIndex processor
- `smartcontract/programs/doublezero-serviceability/src/pda.rs` —
`get_index_pda()` with case-insensitive seed derivation
- `smartcontract/sdk/rs/src/commands/index/create.rs` — CreateIndex SDK
command wrapper
- `smartcontract/sdk/rs/src/commands/index/delete.rs` — DeleteIndex SDK
command wrapper

</details>

## Testing Verification
- New `index_test.rs` with 5 tests: create, duplicate rejection,
unauthorized create, delete, unauthorized delete
- New test helpers for transactions with extra accounts
- All existing tests continue to pass (no modifications to existing
processors)
Base automatically changed from ms/pda-derivation to main April 1, 2026 01:14
@martinsander00 martinsander00 force-pushed the ms/pda-derivation-sdk branch from b0b790c to b0fe8cf Compare April 8, 2026 22:17
Wire Index account management into multicast group create, update,
delete, and close instructions. Update Rust SDK commands to derive
and pass Index PDAs. Add close_index/rename_index args to control
Index lifecycle during deactivation and updates. Update activator,
Go/Python/TypeScript SDKs, and all integration tests.
@martinsander00 martinsander00 force-pushed the ms/pda-derivation-sdk branch from b0fe8cf to 588613f Compare April 8, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants