Skip to content

Commit

Permalink
Revert "migrate individual template data stage 1 (#198)"
Browse files Browse the repository at this point in the history
This reverts commit 951f0ab.
  • Loading branch information
saikatdas0790 committed Dec 8, 2023
1 parent 951f0ab commit 0ded555
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 44 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions src/canister/individual_user_template/Cargo.toml
Expand Up @@ -10,8 +10,6 @@ crate-type = ["cdylib"]

[dependencies]
candid = { workspace = true }
ciborium = { workspace = true }
ic-stable-structures = {workspace = true }
ic-cdk = { workspace = true }
ic-cdk-timers = { workspace = true }
serde = { workspace = true }
Expand Down
Expand Up @@ -22,6 +22,7 @@ fn post_upgrade() {
save_upgrade_args_to_memory();
refetch_well_known_principals();
reenqueue_timers_for_pending_bet_outcomes();
send_canister_metrics();
}

fn restore_data_from_stable_memory() {
Expand Down
@@ -1,22 +1,17 @@
use ciborium::ser;
use ic_stable_structures::writer::Writer;
use shared_utils::common::utils::stable_memory_serializer_deserializer;

use crate::data_model::memory;
use crate::CANISTER_DATA;

pub const BUFFER_SIZE_BYTES: usize = 2 * 1024 * 1024; // 2 MiB

#[ic_cdk::pre_upgrade]
fn pre_upgrade() {
let mut state_bytes = vec![];
CANISTER_DATA.with(|canister_data_ref_cell| {
ser::into_writer(&*canister_data_ref_cell.borrow(), &mut state_bytes)
})
.expect("failed to encode state");

let len = state_bytes.len() as u32;
let mut memory = memory::get_upgrades_memory();
let mut writer = Writer::new(&mut memory, 0);
writer.write(&len.to_le_bytes()).unwrap();
writer.write(&state_bytes).unwrap();
}
let canister_data = canister_data_ref_cell.take();
stable_memory_serializer_deserializer::serialize_to_stable_memory(
canister_data,
BUFFER_SIZE_BYTES,
)
.expect("Failed to serialize canister data");
});
}
22 changes: 0 additions & 22 deletions src/canister/individual_user_template/src/data_model/memory.rs

This file was deleted.

Expand Up @@ -17,7 +17,6 @@ use shared_utils::{
use self::version_details::VersionDetails;

pub mod version_details;
pub mod memory;

#[derive(Default, Deserialize, Serialize)]
pub struct CanisterData {
Expand Down
Expand Up @@ -62,7 +62,7 @@ fn when_canister_cycle_balance_is_below_the_configured_or_freezing_threshold_the
alice_canister_id,
*user_index_canister_id,
"return_cycles_to_user_index_canister",
candid::encode_one(Some(600_000_000_000_u128)).unwrap(),
candid::encode_one(Some(1_000_000_000_000_u128)).unwrap(),
)
.unwrap();

Expand Down Expand Up @@ -125,5 +125,5 @@ fn when_canister_cycle_balance_is_below_the_configured_or_freezing_threshold_the
alice_cycle_balance_after_user_index_upgrade
);

assert!(alice_cycle_balance_after_user_index_upgrade >= 600_000_000_000);
assert!(alice_cycle_balance_after_user_index_upgrade >= 1_000_000_000_000);
}
2 changes: 1 addition & 1 deletion src/lib/shared_utils/src/constant.rs
Expand Up @@ -2,7 +2,7 @@ use candid::Principal;

use crate::common::types::known_principal::{KnownPrincipalMap, KnownPrincipalType};

pub const INDIVIDUAL_USER_CANISTER_RECHARGE_AMOUNT: u128 = 600_000_000_000; // 0.6T Cycles
pub const INDIVIDUAL_USER_CANISTER_RECHARGE_AMOUNT: u128 = 1_000_000_000_000; // 1T Cycles
pub const CYCLES_THRESHOLD_TO_INITIATE_RECHARGE: u128 = 500_000_000_000; // 0.5T Cycles

pub const MAX_USERS_IN_FOLLOWER_FOLLOWING_LIST: u64 = 10000;
Expand Down

0 comments on commit 0ded555

Please sign in to comment.