smartcontract: add TopologyInfo account, flex-algo state, and topology processors#3497
Draft
ben-malbeclabs wants to merge 1 commit intomainfrom
Draft
smartcontract: add TopologyInfo account, flex-algo state, and topology processors#3497ben-malbeclabs wants to merge 1 commit intomainfrom
ben-malbeclabs wants to merge 1 commit intomainfrom
Conversation
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.
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_segmentstoInterfaceV3ActivateLinknow 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— adds Interface V3 discriminant withflex_algo_node_segments: Vec<FlexAlgoNodeSegment>; V1/V2 accounts default to empty vec viaunwrap_or_default()smartcontract/programs/doublezero-serviceability/src/state/topology.rs— newTopologyInfoaccount: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-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_accountinActivateLinkrfcs/for the full specification. PRs 2–4 (topology CLI, link/tenant CLI extensions, SDKs/activator) follow and depend on this foundation