Skip to content

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

Draft
ben-malbeclabs wants to merge 1 commit intomainfrom
bc/rfc18-pr1
Draft

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

Conversation

@ben-malbeclabs
Copy link
Copy Markdown
Contributor

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 V3
  • 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 — adds Interface V3 discriminant with flex_algo_node_segments: Vec<FlexAlgoNodeSegment>; V1/V2 accounts default to empty vec via unwrap_or_default()
  • smartcontract/programs/doublezero-serviceability/src/state/topology.rs — new TopologyInfo account: admin_group_bit (u8), flex_algo_number (128+bit), TopologyConstraint (IncludeAny/IncludeAll/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
  • This is PR 1 of 4 for RFC-18; see rfcs/ for the full specification. PRs 2–4 (topology CLI, link/tenant CLI extensions, SDKs/activator) follow and depend on this foundation

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