Skip to content

smartcontract,controlplane: add flex-algo link/tenant CLI extensions and migrate command#3513

Open
ben-malbeclabs wants to merge 9 commits intobc/rfc18-pr2from
bc/rfc18-pr3
Open

smartcontract,controlplane: add flex-algo link/tenant CLI extensions and migrate command#3513
ben-malbeclabs wants to merge 9 commits intobc/rfc18-pr2from
bc/rfc18-pr3

Conversation

@ben-malbeclabs
Copy link
Copy Markdown
Contributor

@ben-malbeclabs ben-malbeclabs commented Apr 10, 2026

RFC-18 flex-algo · PR 3 of 5 · see rfcs/rfc-0018-flex-algo.md
Depends on: #3512 (PR 2)
Series: #3497 · #3512 · #3513 · #3514 · #3515

Summary of Changes

  • Extends doublezero link get/list/update to display topology assignments (link_topologies) and drain status; adds --link-topology (comma-separated topology names, default to clear all) and --unicast-drained flags to link update; adds --topology filter to link list
  • Extends doublezero tenant get/list/update to display included topologies (include_topologies) and adds --include-topologies (comma-separated topology names, default to clear) to tenant update
  • Adds doublezero-admin migrate flex-algo [--dry-run] command that backfills link topology assignments and VPNv4 loopback flex-algo node segments across all existing devices and links

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 11 +471 / -57 +414
Scaffolding 7 +16 / -5 +11

Mostly core logic — the migrate command alone is 180 lines of backfill and dry-run orchestration.

Key files (click to expand)
  • controlplane/doublezero-admin/src/cli/migrate.rs — new: migrate flex-algo command; validates UNICAST-DEFAULT PDA exists, backfills link topologies for all links, backfills flex-algo node segments for all VPNv4 loopback interfaces on all devices; supports --dry-run
  • smartcontract/cli/src/link/list.rs — adds --topology <name> filter and displays link_topologies/unicast_drained columns, resolving topology pubkeys to human-readable names
  • smartcontract/cli/src/link/get.rs — displays topology assignments and drain status; fetches topology map to resolve pubkeys to names
  • smartcontract/cli/src/link/update.rs — adds --link-topology (accepts comma-separated list of topology names; use default to clear) and --unicast-drained flags
  • smartcontract/cli/src/tenant/list.rs — displays include_topologies column
  • smartcontract/cli/src/tenant/get.rs — displays included topology names
  • smartcontract/cli/src/tenant/update.rs — adds --include-topologies (accepts comma-separated list; use default to clear)

Testing Verification

  • cargo test -p doublezero_sdk -p doublezero_cli -p doublezero-admin passes
  • cargo clippy -- -D warnings clean
  • make rust-fmt applied before commit

@ben-malbeclabs ben-malbeclabs marked this pull request as ready for review April 15, 2026 04:00
elitegreg added a commit that referenced this pull request Apr 18, 2026
…y processors (#3497)

RFC-18 flex-algo · PR 1 of 5 · see `rfcs/rfc-0018-flex-algo.md`
Series: #3497 · #3512 · #3513 · #3514 · #3515

## Summary of Changes
- Adds `TopologyInfo` onchain account (RFC-18 flex-algo) with
`admin_group_bit`, `flex_algo_number`, and `TopologyConstraint`; creates
`AdminGroupBits` resource extension singleton for bit allocation
- Adds four new foundation-only instructions (107–110):
`CreateTopology`, `DeleteTopology`, `ClearTopology`, `BackfillTopology`
- Extends `Link` with `link_topologies` (Vec<Pubkey>) and `link_flags`
(LINK_FLAG_UNICAST_DRAINED); extends `Tenant` with `include_topologies`;
adds `flex_algo_node_segments` to Interface V2
- `CreateLink` now requires the unicast-default topology account and
auto-tags the link into it
- `UpdateLink` gains foundation-gated `link_topologies` update and
contributor-gated `unicast_drained` flag

## Diff Breakdown
| Category    | Files | Lines (+/-)   | Net   |
|-------------|-------|---------------|-------|
| Core logic  |    22 | +1,306 / -38  | +1,268|
| Scaffolding |    49 | +133 / -3     |  +130 |
| Tests       |    27 | +4,592 / -74  | +4,518|

The scaffolding is mechanical struct field additions (`link_topologies:
vec![]`, `include_topologies: vec![]`, `flex_algo_node_segments:
vec![]`) across CLI, SDK, activator, and client to keep the workspace
compiling. Core logic is concentrated in the new topology processors,
state types, and link/activate updates.

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

-
`smartcontract/programs/doublezero-serviceability/src/state/interface.rs`
— updates Interface V2 (discriminant 1) to include
`flex_algo_node_segments: Vec<FlexAlgoNodeSegment>`; V1 accounts
(pre-CYOA format) are left as-is; pre-RFC-18 V2 accounts on mainnet are
upgraded in-place by `MigrateDeviceInterfaces` before this
deserialization path is used
-
`smartcontract/programs/doublezero-serviceability/src/state/topology.rs`
— new `TopologyInfo` account: `admin_group_bit` (u8), `flex_algo_number`
(128+bit), `TopologyConstraint` (IncludeAny/Exclude)
-
`smartcontract/programs/doublezero-serviceability/src/processors/topology/`
— five new processors: create (allocates AdminGroupBit, validates
IdRange 1–127), delete, clear (removes topology from all links),
backfill (allocates FlexAlgoNodeSegment on all device interfaces)
-
`smartcontract/programs/doublezero-serviceability/src/processors/link/update.rs`
— adds foundation-gated `link_topologies` update (validates each
topology account onchain) and contributor-gated `unicast_drained` flag
(LINK_FLAG_UNICAST_DRAINED bit 0)
-
`smartcontract/programs/doublezero-serviceability/src/processors/link/activate.rs`
— requires `unicast_default_topology_account` as a mandatory account;
auto-tags new link into the unicast-default topology on activation
-
`smartcontract/programs/doublezero-serviceability/src/processors/globalconfig/set.rs`
— creates `AdminGroupBits` ResourceExtension PDA on global config
initialization
- `smartcontract/programs/doublezero-serviceability/src/state/link.rs` —
adds `link_topologies: Vec<Pubkey>`, `link_flags: u64`, and
`LINK_FLAG_UNICAST_DRAINED = 0x01`
- `smartcontract/programs/doublezero-serviceability/src/instructions.rs`
— registers four new instruction variants (CreateTopology=107,
DeleteTopology=108, ClearTopology=109, BackfillTopology=110)

</details>

## Testing Verification
- `make rust-lint` and `make rust-test` pass clean on this branch
- `topology_test.rs` (~2,400 lines) covers all four topology processors:
create/delete/clear/backfill, including error paths (duplicate names,
out-of-range bits, unauthorized signers, invalid topology accounts),
segment allocation, and multi-topology backfill
- Existing `link_wan_test.rs`, `tenant_test.rs`, and telemetry tests
updated to account for the new mandatory
`unicast_default_topology_account` in `ActivateLink`

---------

Co-authored-by: Greg Mitchell <greg@malbeclabs.com>
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.

1 participant