diff --git a/backend/canisters/user_index/CHANGELOG.md b/backend/canisters/user_index/CHANGELOG.md index 8b85167a56..4b782f17be 100644 --- a/backend/canisters/user_index/CHANGELOG.md +++ b/backend/canisters/user_index/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Fixed + +- Bump `date_updated` after submitting proof of uniqueness ([#6135](https://github.com/open-chat-labs/open-chat/pull/6135)) + +## [[2.0.1265](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1265-user_index)] - 2024-07-29 + ### Changed - Register the AirdropBot user ([#6129](https://github.com/open-chat-labs/open-chat/pull/6129)) diff --git a/backend/canisters/user_index/impl/src/lib.rs b/backend/canisters/user_index/impl/src/lib.rs index 63241c2e64..110bced8fa 100644 --- a/backend/canisters/user_index/impl/src/lib.rs +++ b/backend/canisters/user_index/impl/src/lib.rs @@ -31,7 +31,7 @@ use types::{ }; use utils::canister::{CanistersRequiringUpgrade, FailedUpgradeCount}; use utils::canister_event_sync_queue::CanisterEventSyncQueue; -use utils::consts::{DEV_TEAM_DFX_PRINCIPAL, IC_ROOT_KEY}; +use utils::consts::DEV_TEAM_DFX_PRINCIPAL; use utils::env::Environment; use utils::time::{MonthKey, DAY_IN_MS}; @@ -283,7 +283,6 @@ struct Data { pub notifications_index_canister_id: CanisterId, pub identity_canister_id: CanisterId, pub proposals_bot_canister_id: CanisterId, - #[serde(default = "init_airdrop_bot_canister_id")] pub airdrop_bot_canister_id: CanisterId, pub canisters_requiring_upgrade: CanistersRequiringUpgrade, pub total_cycles_spent_on_canisters: Cycles, @@ -318,19 +317,11 @@ struct Data { pub empty_users: HashSet, pub chit_leaderboard: ChitLeaderboard, pub deleted_users: Vec, - #[serde(with = "serde_bytes", skip_deserializing, default = "ic_root_key")] + #[serde(with = "serde_bytes")] pub ic_root_key: Vec, pub identity_canister_user_sync_queue: VecDeque<(Principal, Option)>, } -fn ic_root_key() -> Vec { - IC_ROOT_KEY.to_vec() -} - -fn init_airdrop_bot_canister_id() -> CanisterId { - Principal::from_text("62rh2-kiaaa-aaaaf-bmy5q-cai").unwrap() -} - impl Data { #[allow(clippy::too_many_arguments)] pub fn new( diff --git a/backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs b/backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs index df7925c92f..c163dddb67 100644 --- a/backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs +++ b/backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs @@ -1,12 +1,11 @@ use crate::lifecycle::{init_env, init_state}; use crate::memory::get_upgrades_memory; -use crate::{mutate_state, Data}; +use crate::Data; use canister_logger::LogEntry; use canister_tracing_macros::trace; use ic_cdk::post_upgrade; use stable_memory::get_reader; use tracing::info; -use types::UserType; use user_index_canister::post_upgrade::Args; use utils::cycles::init_cycles_dispenser_client; @@ -24,17 +23,5 @@ fn post_upgrade(args: Args) { init_cycles_dispenser_client(data.cycles_dispenser_canister_id, data.test_mode); init_state(env, data, args.wasm_version); - mutate_state(|state| { - // Register the AirdropBot - state.data.users.register( - state.data.airdrop_bot_canister_id, - state.data.airdrop_bot_canister_id.into(), - "AirdropBot".to_string(), - 0, - None, - UserType::OcControlledBot, - ); - }); - info!(version = %args.wasm_version, "Post-upgrade complete"); } diff --git a/backend/canisters/user_index/impl/src/model/user_map.rs b/backend/canisters/user_index/impl/src/model/user_map.rs index 6a69b0c7bf..69f9aedeaa 100644 --- a/backend/canisters/user_index/impl/src/model/user_map.rs +++ b/backend/canisters/user_index/impl/src/model/user_map.rs @@ -354,12 +354,18 @@ impl UserMap { } } - pub fn record_proof_of_unique_personhood(&mut self, user_id: UserId, proof: UniquePersonProof) -> bool { + pub fn record_proof_of_unique_personhood( + &mut self, + user_id: UserId, + proof: UniquePersonProof, + now: TimestampMillis, + ) -> bool { if let Some(user) = self.users.get_mut(&user_id) { if user.unique_person_proof.is_none() { self.unique_person_proofs_submitted += 1; } user.unique_person_proof = Some(proof); + user.date_updated = now; true } else { false diff --git a/backend/canisters/user_index/impl/src/updates/c2c_notify_events.rs b/backend/canisters/user_index/impl/src/updates/c2c_notify_events.rs index c923a1afc6..799876fd74 100644 --- a/backend/canisters/user_index/impl/src/updates/c2c_notify_events.rs +++ b/backend/canisters/user_index/impl/src/updates/c2c_notify_events.rs @@ -99,7 +99,10 @@ fn handle_event(event: Event, state: &mut RuntimeState) { } Event::NotifyUniquePersonProof(ev) => { let (user_id, proof) = *ev; - state.data.users.record_proof_of_unique_personhood(user_id, proof.clone()); + state + .data + .users + .record_proof_of_unique_personhood(user_id, proof.clone(), state.env.now()); state.push_event_to_all_local_user_indexes( LocalUserIndexEvent::NotifyUniquePersonProof(user_id, proof), Some(caller), diff --git a/backend/canisters/user_index/impl/src/updates/submit_proof_of_unique_personhood.rs b/backend/canisters/user_index/impl/src/updates/submit_proof_of_unique_personhood.rs index f9281b04c4..13652264b0 100644 --- a/backend/canisters/user_index/impl/src/updates/submit_proof_of_unique_personhood.rs +++ b/backend/canisters/user_index/impl/src/updates/submit_proof_of_unique_personhood.rs @@ -28,7 +28,10 @@ fn submit_proof_of_unique_personhood_impl(args: Args, state: &mut RuntimeState) now, ) { Ok(proof) => { - state.data.users.record_proof_of_unique_personhood(user_id, proof.clone()); + state + .data + .users + .record_proof_of_unique_personhood(user_id, proof.clone(), now); state.push_event_to_all_local_user_indexes( local_user_index_canister::Event::NotifyUniquePersonProof(user_id, proof), None,