activator,sdk: add topology event handler and update Python/TypeScript SDKs for RFC-18#3514
Open
ben-malbeclabs wants to merge 5 commits intobc/rfc18-pr2from
Open
activator,sdk: add topology event handler and update Python/TypeScript SDKs
for RFC-18#3514ben-malbeclabs wants to merge 5 commits intobc/rfc18-pr2from
ben-malbeclabs wants to merge 5 commits intobc/rfc18-pr2from
Conversation
This was referenced Apr 10, 2026
834ffe0 to
ed49424
Compare
af4189e to
be77997
Compare
ed49424 to
93ecaeb
Compare
compat test to use 120s request timeout
be77997 to
dc2ef9c
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC-18 flex-algo · PR 4 of 5 · see
rfcs/rfc-0018-flex-algo.mdDepends on: #3512 (PR 2)
Series: #3497 · #3512 · #3513 · #3514 · #3515
Summary of Changes
process_topology_eventto the activator: when aTopologyInfoaccount is created or updated, the activator callsBackfillTopologyon all devices that have an activated VPNv4 loopback (idempotent — skips devices that already have a segment for this topology)--enable-flex-algoflag to the activator (default: off); topology events are ignored unless the flag is setTopologyConstraint,TopologyInfo, andFlexAlgoNodeSegment, and readsflex_algo_node_segmentsfrom V2 interface accountsFlexAlgoNodeSegmentfrom V2 interface accounts and adds a configurable request timeout to the RPC clientDiff Breakdown
Mostly core logic concentrated in the new topology event handler and Python SDK deserialization.
Key files (click to expand)
activator/src/process/topology.rs— new: topology event handler; lists all active devices, filters to those with activated VPNv4 loopbacks, batches BackfillTopology callsactivator/src/process/iface_mgr.rs— calls backfill after a VPNv4 loopback is activated, so newly provisioned devices immediately get node segments for existing topologiesactivator/src/process/device.rs— topology-aware device processingactivator/src/processor.rs— wires inprocess_topology_eventforAccountData::Topologyevents; addsenable_flex_algoguardsdk/serviceability/python/serviceability/state.py— addsTopologyConstraintenum,TopologyInfodataclass,FlexAlgoNodeSegmentdataclass; readsflex_algo_node_segmentsvec from V2 interface accountssdk/serviceability/typescript/serviceability/state.ts— addsFlexAlgoNodeSegmenttype; reads it from V2 interface accountssdk/serviceability/typescript/serviceability/rpc.ts— adds configurable request timeoutTesting Verification
cargo test -p doublezero-activator— 76 tests passcargo clippy -- -D warningsclean after fixingfor_kv_maplint intopology.rs