smartcontract/serviceability: collapse OnChainAllocation flag branches#3649
Open
smartcontract/serviceability: collapse OnChainAllocation flag branches#3649
Conversation
elitegreg
commented
May 3, 2026
Contributor
Author
There was a problem hiding this comment.
This change is unnecessary
Contributor
Author
There was a problem hiding this comment.
This change is unnecessary
| if side_a_iface.status != InterfaceStatus::Unlinked { | ||
| // Atomic create+allocate+activate. DZX links stay in Requested until accepted by side Z; | ||
| // all other links activate immediately. | ||
| if link.status == LinkStatus::Pending { |
Contributor
Author
There was a problem hiding this comment.
status != Requested
elitegreg
added a commit
that referenced
this pull request
May 3, 2026
- Drop is_feature_enabled checks from Rust SDK commands; resource accounts are now always passed and the `use_*onchain_*` boolean flags are derived from whether the field is being set rather than the global feature flag. - Enforce `resource_count >= 2` and `DeviceStatus::Activated` in process_create_device. - Tighten link/create.rs status check to `!= LinkStatus::Requested`. - Update integration tests to drop the legacy Pending → Activated flow for devices (CreateDevice now activates atomically). - Update activator to use renamed FeatureFlag::OnChainAllocationDeprecated.
Treat onchain allocation as always-on by removing every is_feature_enabled(OnChainAllocation) branch from the serviceability program processors. Rename the FeatureFlag::OnChainAllocation variant to OnChainAllocationDeprecated so bit 0 is reserved and never reused — the variant itself is retained so the flag discriminant doesn't shift. Tests covering the now-impossible feature-flag-disabled case are deleted; their onchain pairs remain. Tests that exercised legacy update paths gain the resource extension account they now require. Coverage stays net-equivalent. Refs #3613
…lagged instructions Tighten the multicastgroup/link/device-interface processors that carry a `use_onchain_(de)allocation` boolean: validate the field is true and require the ResourceExtension accounts as non-optional positional args (no more legacy `Option<>` branches). Calls that flip the flag false now return InvalidArgument. In tests, delete `*_legacy_*` / `*_backward_compat_*` cases that exercised the removed paths, migrate the remaining tests onto the always-on layout, and add a `init_globalstate_and_config` test helper so tests don't need to bootstrap each ResourceExtension manually. Also relax the ActivateDeviceInterface and UnlinkDeviceInterface status guards to accept already-Activated / already-Unlinked interfaces idempotently, since CreateDeviceInterface now activates atomically. Refs #3613
- Drop is_feature_enabled checks from Rust SDK commands; resource accounts are now always passed and the `use_*onchain_*` boolean flags are derived from whether the field is being set rather than the global feature flag. - Enforce `resource_count >= 2` and `DeviceStatus::Activated` in process_create_device. - Tighten link/create.rs status check to `!= LinkStatus::Requested`. - Update integration tests to drop the legacy Pending → Activated flow for devices (CreateDevice now activates atomically). - Update activator to use renamed FeatureFlag::OnChainAllocationDeprecated.
…ences The previous rename to OnChainAllocationDeprecated changed the CLI flag string from "onchain-allocation" to "onchain-allocation-deprecated". Update CLI tests to use the new string and remove the e2e devnet step that enabled the flag — the flag is now always-on/no-op so the call adds no value and would fail with the new name.
… test helper - The SDK's CreateLink command was passing accounts in the legacy [globalstate, device_tunnel_block, link_ids, unicast_default] order, but commit 2b6cf3d moved unicast_default before the resource extension accounts. Reorder the SDK to match the program's positional layout. - Update the doublezero-telemetry test helper to create devices with the required resource_count >= 2 and the corresponding TunnelIds and DzPrefixBlock accounts, since CreateDevice now activates atomically.
…ays-on flow
- Update doublezero-telemetry test_helpers to:
* Pass the required globalconfig + tunnel_ids + dz_prefix accounts in
CreateDevice (resource_count >= 2).
* Flip use_onchain_allocation to true in CreateLink, ActivateLink, and
CreateDeviceInterface, and pass the corresponding resource extension
accounts the program now expects.
* Drop the now-redundant ActivateLink call after CreateLink (links
activate atomically) and the UnlinkDeviceInterface call after
CreateDeviceInterface (interfaces start in the right state).
* Restore the legacy "create then activate" semantics by demoting the
device back to Pending in create_device and re-activating in
set_device_ready_for_users (so existing tests that check Pending →
Activated transitions still work).
- Mark CLIs ≤ v0.21.0 as known-incompatible for link_create_wan /
link_create_dzx in compatibility_test.go: the OnChainAllocation flag
deprecation requires use_onchain_allocation=true, which older CLIs
don't set.
- Accept the legacy "onchain-allocation" string in FeatureFlag::from_str so older callers (e.g. doublezero-shreds e2e setup) that flip the now-no-op flag continue to parse. Bit 0 is reserved either way. - Mark link_accept_dzx as known-incompatible for CLIs ≤ v0.21.0 in the backward-compat e2e — LinkAccept also requires use_onchain_allocation=true after the flag deprecation.
…ncompatible When older CLIs (≤ v0.21.0) can't create links because they don't set use_onchain_allocation=true, downstream link_update / link_set_health steps run against a non-existent link and fail with "Link with code X not found". Mark link_create_wan / link_create_dzx with cascadeKnownFail so the wait_and_configure phase is skipped when the create phase couldn't build the links.
04ec2cd to
02f33c3
Compare
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
is_feature_enabled(FeatureFlag::OnChainAllocation)branch inthe serviceability program; rename the variant to
OnChainAllocationDeprecatedwith bit 0 documented as reserved-and-never-reused.
create/delete/update/subscribe, linkcreate/delete/accept/update, device interfacecreate/delete), requireuse_onchain_(de)allocation: trueand accept theresource extension accounts as positional, non-optional args. Calls that flip
the flag false now return
InvalidArgument.link::updateandmulticastgroup::updateonly enforce this when tunnel / multicast-IP fieldsare actually being changed, so trivial field-only updates don't need extras.
ActivateDeviceInterfaceandUnlinkDeviceInterfacestatus guards toaccept the target status as a no-op, since
CreateDeviceInterfacenowproduces Loopback-Activated / Physical-Unlinked atomically.
Phase 4, PR 4.1 of the activator removal effort. Closes #3613. Tracker: #3607.
Testing Verification
cargo test -p doublezero-serviceability --features no-entrypoint— 453passed, 0 failed.
cargo clippy --features no-entrypoint --all-targets -- -Dclippy::all -Dwarnings— clean across the workspace.cargo test -p doublezero_sdk— 183 passed, 0 failed (rename-only changes inthe SDK).
*_legacy_*/*_backward_compat_*cases thatexercised the now-rejected paths and tests that asserted intermediate Pending
status (Create now activates atomically); migrated the remaining tests onto
the new account layouts. Net coverage is preserved by the onchain-pair tests
that already covered the same instruction logic.
init_globalstate_and_confighelper intests/test_helpers.rsso testsdon't have to set up every ResourceExtension by hand.