smartcontract: add TopologyInfo account, flex-algo state, and topology processors#3497
Draft
ben-malbeclabs wants to merge 11 commits intomainfrom
Draft
smartcontract: add TopologyInfo account, flex-algo state, and topology processors#3497ben-malbeclabs wants to merge 11 commits intomainfrom
ben-malbeclabs wants to merge 11 commits intomainfrom
Conversation
76986c3 to
a1a2260
Compare
This was referenced Apr 9, 2026
Closed
Draft
…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
a1a2260 to
b710d74
Compare
get_topology_pda normalizes via to_ascii_uppercase so any case input derives the same PDA. The create processor stores the uppercased name, ensuring names are always uppercase in onchain state and cEOS config.
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 1 of 5 · see
rfcs/rfc-0018-flex-algo.mdSeries: #3497 · #3512 · #3513 · #3514 · #3515
Summary of Changes
TopologyInfoonchain account (RFC-18 flex-algo) withadmin_group_bit,flex_algo_number, andTopologyConstraint; createsAdminGroupBitsresource extension singleton for bit allocationCreateTopology,DeleteTopology,ClearTopology,BackfillTopologyLinkwithlink_topologies(Vec) andlink_flags(LINK_FLAG_UNICAST_DRAINED); extendsTenantwithinclude_topologies; addsflex_algo_node_segmentsto Interface V2ActivateLinknow requires the unicast-default topology account and auto-tags the link into itUpdateLinkgains foundation-gatedlink_topologiesupdate and contributor-gatedunicast_drainedflagDiff Breakdown
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 includeflex_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 byMigrateDeviceInterfacesbefore this deserialization path is usedsmartcontract/programs/doublezero-serviceability/src/state/topology.rs— newTopologyInfoaccount: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-gatedlink_topologiesupdate (validates each topology account onchain) and contributor-gatedunicast_drainedflag (LINK_FLAG_UNICAST_DRAINED bit 0)smartcontract/programs/doublezero-serviceability/src/processors/link/activate.rs— requiresunicast_default_topology_accountas a mandatory account; auto-tags new link into the unicast-default topology on activationsmartcontract/programs/doublezero-serviceability/src/processors/globalconfig/set.rs— createsAdminGroupBitsResourceExtension PDA on global config initializationsmartcontract/programs/doublezero-serviceability/src/state/link.rs— addslink_topologies: Vec<Pubkey>,link_flags: u64, andLINK_FLAG_UNICAST_DRAINED = 0x01smartcontract/programs/doublezero-serviceability/src/instructions.rs— registers four new instruction variants (CreateTopology=107, DeleteTopology=108, ClearTopology=109, BackfillTopology=110)Testing Verification
make rust-lintandmake rust-testpass clean on this branchtopology_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 backfilllink_wan_test.rs,tenant_test.rs, and telemetry tests updated to account for the new mandatoryunicast_default_topology_accountinActivateLink