Skip to content

Commit

Permalink
Update canisters post release (#6054)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Jul 18, 2024
1 parent f289a88 commit b927766
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 54 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions backend/canisters/group_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1240](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1240-group_index)] - 2024-07-17

### Fixed

- Handle `mark_local_group_index_full` in `inspect_message` ([#6010](https://github.com/open-chat-labs/open-chat/pull/6010))
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/identity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1239](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1239-identity)] - 2024-07-17

### Added

- Sync userIds to Identity canister ([#6027](https://github.com/open-chat-labs/open-chat/pull/6027))
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/local_user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1241](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1241-local_user_index)] - 2024-07-17

### Added

- Support gates with multiple verifiable credentials ([#6029](https://github.com/open-chat-labs/open-chat/pull/6029))
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/proposals_bot/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1237](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1237-proposals_bot)] - 2024-07-16

### Added

- Add `lookup_proposal_message` ([#6031](https://github.com/open-chat-labs/open-chat/pull/6031))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ pub struct NervousSystem {
min_neuron_stake: u64,
min_dissolve_delay_to_vote: Milliseconds,
proposal_rejection_fee: u64,
#[serde(default)]
proposal_messages: BTreeMap<ProposalId, (MessageIndex, MessageId)>,
}

Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1243](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1243-user)] - 2024-07-17

### Changed

- Added lots more achievements to enum ([#6020](https://github.com/open-chat-labs/open-chat/pull/6020))
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1242](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1242-user_index)] - 2024-07-17

### Added

- Sync userIds to Identity canister ([#6027](https://github.com/open-chat-labs/open-chat/pull/6027))
Expand Down
1 change: 0 additions & 1 deletion backend/canisters/user_index/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ sha2 = { workspace = true }
stable_memory = { path = "../../../libraries/stable_memory" }
storage_index_canister = { path = "../../storage_index/api" }
storage_index_canister_c2c_client = { path = "../../storage_index/c2c_client" }
test-case = { workspace = true }
testing = { path = "../../../libraries/testing" }
time = { workspace = true }
tracing = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions backend/canisters/user_index/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,7 @@ struct Data {
pub empty_users: HashSet<UserId>,
pub chit_leaderboard: ChitLeaderboard,
pub deleted_users: Vec<DeletedUser>,
#[serde(default)]
pub ic_root_key: Vec<u8>,
#[serde(default)]
pub identity_canister_user_sync_queue: VecDeque<(Principal, Option<UserId>)>,
}

Expand Down
50 changes: 1 addition & 49 deletions backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,13 +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 test_case::test_case;
use tracing::info;
use types::CanisterId;
use user_index_canister::post_upgrade::Args;
use utils::cycles::init_cycles_dispenser_client;

Expand All @@ -26,50 +24,4 @@ fn post_upgrade(args: Args) {
init_state(env, data, args.wasm_version);

info!(version = %args.wasm_version, "Post-upgrade complete");

mutate_state(|state| {
for user in state.data.users.iter() {
state
.data
.identity_canister_user_sync_queue
.push_back((user.principal, Some(user.user_id)));
}
crate::jobs::sync_users_to_identity_canister::start_job_if_required(state);

for canister_id in state.data.deleted_users.iter().map(|u| CanisterId::from(u.user_id)) {
let local_user_index = local_user_index_canister(canister_id, state.data.test_mode);
let event = local_user_index_canister::Event::AddCanisterToPool(canister_id);
state.data.user_index_event_sync_queue.push(local_user_index, event);
}
crate::jobs::sync_events_to_local_user_index_canisters::start_job_if_required(state);
})
}

fn local_user_index_canister(canister_id: CanisterId, test_mode: bool) -> CanisterId {
let bytes = canister_id.as_slice();
if bytes > [0, 0, 0, 0, 2, 32, 0, 0, 1, 1].as_slice() && bytes < [0, 0, 0, 0, 2, 48, 0, 0, 1, 1].as_slice() {
return CanisterId::from_text("aboy3-giaaa-aaaar-aaaaq-cai").unwrap();
}
if bytes > [0, 0, 0, 0, 0, 160, 0, 0, 1, 1].as_slice() && bytes < [0, 0, 0, 0, 0, 176, 0, 0, 1, 1].as_slice() {
return if test_mode {
CanisterId::from_text("pecvb-tqaaa-aaaaf-bhdiq-cai").unwrap()
} else {
CanisterId::from_text("nq4qv-wqaaa-aaaaf-bhdgq-cai").unwrap()
};
}

assert!(test_mode);
// This will only be reached during tests + local development
CanisterId::from_text("be2us-64aaa-aaaaa-qaabq-cai").unwrap()
}

#[test_case("foyjw-giaaa-aaaaf-big5a-cai", true, "pecvb-tqaaa-aaaaf-bhdiq-cai")]
#[test_case("x2jhd-2yaaa-aaaaf-bif6a-cai", true, "pecvb-tqaaa-aaaaf-bhdiq-cai")]
#[test_case("ueepn-qiaaa-aaaar-ampla-cai", false, "aboy3-giaaa-aaaar-aaaaq-cai")]
#[test_case("nfjlt-kaaaa-aaaar-axpxq-cai", false, "aboy3-giaaa-aaaar-aaaaq-cai")]
#[test_case("7msbr-laaaa-aaaaf-ayvuq-cai", false, "nq4qv-wqaaa-aaaaf-bhdgq-cai")]
#[test_case("2cpmn-myaaa-aaaaf-ayvia-cai", false, "nq4qv-wqaaa-aaaaf-bhdgq-cai")]
fn local_user_index_canister_tests(canister_id: &str, test_mode: bool, expected: &str) {
let result = local_user_index_canister(CanisterId::from_text(canister_id).unwrap(), test_mode);
assert_eq!(result.to_text(), expected);
}

0 comments on commit b927766

Please sign in to comment.