Skip to content

onchain allocation: DeleteUser deallocate+closeaccount atomically#3113

Draft
elitegreg wants to merge 3 commits intomainfrom
gm/onchain-allocation-issue-2403
Draft

onchain allocation: DeleteUser deallocate+closeaccount atomically#3113
elitegreg wants to merge 3 commits intomainfrom
gm/onchain-allocation-issue-2403

Conversation

@elitegreg
Copy link
Contributor

Closes #2403

Summary of Changes

  • Modified process_delete_user to handle deallocation and account closure if feature flag is enabled and the user's cli is new enough (passing the extra accounts).
  • Changes the SDK DeleteUser to appropriately call the smartcontract based on feature flag

Testing Verification

  • New tests added
  • Existing tests pass

Add dz_prefix_count and multicast_publisher_count fields to UserDeleteArgs
for atomic delete+deallocate+close in a single transaction. When
dz_prefix_count > 0, the instruction deallocates tunnel_net, tunnel_id,
and dz_ip from ResourceExtension accounts, decrements device counters,
and closes the user account. Legacy path (dz_prefix_count=0) unchanged.

Gated behind the OnChainAllocation feature flag.
…teUser

Read the OnChainAllocation feature flag from GlobalState to automatically
skip multicast unsubscribe + retry logic and instead include device,
UserTunnelBlock, MulticastPublisherBlock, TunnelIds, DzPrefixBlock,
optional tenant, and owner accounts for atomic delete+deallocate+close.

if matches!(user.status, UserStatus::Deleting | UserStatus::Updating) {
return Err(DoubleZeroError::InvalidStatus.into());
// Status check differs between legacy and atomic paths
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is not right. Need to think about it.

@elitegreg elitegreg marked this pull request as draft February 26, 2026 16:31
client_ip: user.client_ip,
publisher: false,
subscriber: false,
// With onchain deallocation, the program handles everything atomically —
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multicast unsubscribe still needs to happen.

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.

Phase 2: Modify DeleteUser for atomic deallocation

1 participant