diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a4674843..114c5900e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ All notable changes to this project will be documented in this file. - Extend `validate_program_account!` migration to remaining user and multicastgroup allowlist processors (`set_bgp_status`, `delete`, `closeaccount`, publisher/subscriber `add`/`remove`) - Add `OutboundIcmp` target type (`= 2`) to the geolocation onchain program, enabling ICMP-based probing as an alternative to TWAMP for outbound geolocation targets - Allow pending users with subs to be deleted + - Rename subscribe processor functions (`process_subscribe_multicastgroup` → `process_update_multicastgroup_subscription`) to reflect that they handle both subscribe and unsubscribe, and simplify the status validation guard - Geolocation - Standardize CLI flag naming: probe mutation commands use `--probe` (was `--code`) accepting pubkey or code; rename `--signing-keypair` → `--signing-pubkey` and `--target-pk` → `--target-signing-pubkey`; add `--json-compact` to `get` commands - geoprobe-target can now store LocationOffset messages in ClickHouse diff --git a/smartcontract/programs/doublezero-serviceability/src/entrypoint.rs b/smartcontract/programs/doublezero-serviceability/src/entrypoint.rs index 555fac6e0..8fdca284f 100644 --- a/smartcontract/programs/doublezero-serviceability/src/entrypoint.rs +++ b/smartcontract/programs/doublezero-serviceability/src/entrypoint.rs @@ -77,7 +77,7 @@ use crate::{ delete::process_delete_multicastgroup, reactivate::process_reactivate_multicastgroup, reject::process_reject_multicastgroup, - subscribe::process_subscribe_multicastgroup, + subscribe::process_update_multicastgroup_subscription, suspend::process_suspend_multicastgroup, update::process_update_multicastgroup, }, @@ -294,7 +294,7 @@ pub fn process_instruction( process_remove_multicast_sub_allowlist(program_id, accounts, &value)? } DoubleZeroInstruction::SubscribeMulticastGroup(value) => { - process_subscribe_multicastgroup(program_id, accounts, &value)? + process_update_multicastgroup_subscription(program_id, accounts, &value)? } DoubleZeroInstruction::CreateSubscribeUser(value) => { process_create_subscribe_user(program_id, accounts, &value)? diff --git a/smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/subscribe.rs b/smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/subscribe.rs index 2fd17c7b5..9ad238f96 100644 --- a/smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/subscribe.rs +++ b/smartcontract/programs/doublezero-serviceability/src/processors/multicastgroup/subscribe.rs @@ -60,7 +60,7 @@ pub struct SubscribeUserResult { /// and post-activation subscription changes (add/remove toggle). The caller is /// responsible for setting `user.status = Updating` when /// `publisher_list_transitioned` is true and the user is already activated. -pub fn subscribe_user_to_multicastgroup( +pub fn update_user_multicastgroup_subscription( mgroup_account: &AccountInfo, accesspass: &AccessPass, user: &mut User, @@ -130,7 +130,7 @@ pub fn subscribe_user_to_multicastgroup( }) } -pub fn process_subscribe_multicastgroup( +pub fn process_update_multicastgroup_subscription( program_id: &Pubkey, accounts: &[AccountInfo], value: &MulticastGroupSubscribeArgs, @@ -171,7 +171,7 @@ pub fn process_subscribe_multicastgroup( let system_program = next_account_info(accounts_iter)?; #[cfg(test)] - msg!("process_subscribe_multicastgroup({:?})", value); + msg!("process_update_multicastgroup_subscription({:?})", value); // Check if the payer is a signer assert!(payer_account.is_signer, "Payer must be a signer"); @@ -201,14 +201,10 @@ pub fn process_subscribe_multicastgroup( // Parse and validate user let mut user: User = User::try_from(user_account)?; - // Allow pure-unsubscribe (both false) for any status so that users - // created atomically via CreateSubscribeUser can be cleaned up before - // activation. Subscribe operations still require Activated/Updating. - let is_unsubscribe_only = !value.publisher && !value.subscriber; - if !is_unsubscribe_only - && user.status != UserStatus::Activated - && user.status != UserStatus::Updating - { + // Unsubscribe is allowed for any status so that users + // created via CreateSubscribeUser can be cleaned up before activation. + let is_subscribe = value.publisher || value.subscriber; + if is_subscribe && user.status != UserStatus::Activated && user.status != UserStatus::Updating { msg!("UserStatus: {:?}", user.status); return Err(DoubleZeroError::InvalidStatus.into()); } @@ -252,7 +248,7 @@ pub fn process_subscribe_multicastgroup( } } - let result = subscribe_user_to_multicastgroup( + let result = update_user_multicastgroup_subscription( mgroup_account, &accesspass, &mut user, diff --git a/smartcontract/programs/doublezero-serviceability/src/processors/user/create_subscribe.rs b/smartcontract/programs/doublezero-serviceability/src/processors/user/create_subscribe.rs index 5bbe84e43..1434e7d5c 100644 --- a/smartcontract/programs/doublezero-serviceability/src/processors/user/create_subscribe.rs +++ b/smartcontract/programs/doublezero-serviceability/src/processors/user/create_subscribe.rs @@ -18,7 +18,7 @@ use super::{ create_core::{create_user_core, CreateUserCoreAccounts, PDAVersion}, resource_onchain_helpers, }; -use crate::processors::multicastgroup::subscribe::subscribe_user_to_multicastgroup; +use crate::processors::multicastgroup::subscribe::update_user_multicastgroup_subscription; #[derive(BorshSerialize, BorshDeserializeIncremental, PartialEq, Clone)] pub struct UserCreateSubscribeArgs { @@ -111,7 +111,7 @@ pub fn process_create_subscribe_user( )?; // Subscribe user to multicast group - let subscribe_result = subscribe_user_to_multicastgroup( + let subscribe_result = update_user_multicastgroup_subscription( mgroup_account, &result.accesspass, &mut result.user, diff --git a/smartcontract/programs/doublezero-serviceability/tests/multicastgroup_subscribe_test.rs b/smartcontract/programs/doublezero-serviceability/tests/multicastgroup_subscribe_test.rs index f686bb161..a5188846a 100644 --- a/smartcontract/programs/doublezero-serviceability/tests/multicastgroup_subscribe_test.rs +++ b/smartcontract/programs/doublezero-serviceability/tests/multicastgroup_subscribe_test.rs @@ -969,7 +969,7 @@ async fn test_duplicate_publisher_subscribe_is_noop() { } /// Foundation admin (payer != user.owner) can subscribe a user to a multicast group. -/// Regression test for the bug where process_subscribe_multicastgroup derived the AccessPass PDA +/// Regression test for the bug where process_update_multicastgroup_subscription derived the AccessPass PDA /// using payer_account.key instead of user.owner. #[tokio::test] async fn test_subscribe_foundation_admin_payer_differs_from_user_owner() {