Skip to content

smartcontract: add TopologyInfo account, flex-algo state, and topology processors#3497

Draft
ben-malbeclabs wants to merge 5 commits intomainfrom
bc/rfc18-pr1
Draft

smartcontract: add TopologyInfo account, flex-algo state, and topology processors#3497
ben-malbeclabs wants to merge 5 commits intomainfrom
bc/rfc18-pr1

Conversation

@ben-malbeclabs
Copy link
Copy Markdown
Contributor

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

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) and link_flags (LINK_FLAG_UNICAST_DRAINED); extends Tenant with include_topologies; adds flex_algo_node_segments to Interface V2
  • ActivateLink 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 15 +735 / -34 +701
Scaffolding 49 +377 / -0 +377
Tests 23 +3,712 / -39 +3,673

Majority of prod lines are new — 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.

Key files (click to expand)
  • 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)

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

@ben-malbeclabs ben-malbeclabs force-pushed the bc/rfc18-pr1 branch 3 times, most recently from 4eb328b to 71ee150 Compare April 9, 2026 20:40
…pport

- Add flex_algo_node_segments field to Interface::V2; add
  deserialize_legacy_v2_interface for reading pre-RFC-18 accounts
- Add MigrateDeviceInterfaces processor: rewrites pre-RFC-18 device
  accounts (no flex_algo bytes) to new V2 layout; idempotent so the
  activator startup sweep can call it unconditionally; accepts
  foundation, device owner, or activator authority as signer
- Wire MigrateDeviceInterfaces into entrypoint and instructions
- Update ActivateLink to pass unicast_default_topology_pda
  unconditionally; processor tags link only when account is initialized
- Update topology backfill/create processors
- Remove V3 discriminant from smartcontract Go SDK; DeserializeInterfaceV2
  now reads flex_algo_node_segments unconditionally (requires migration)
- Register topology commands in Rust SDK
- Add integration tests for MigrateDeviceInterfaces: idempotency,
  authorization (unauthorized/activator/non-signer), legacy account migration
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