diff --git a/rs/bitcoin/ckbtc/minter/tests/tests.rs b/rs/bitcoin/ckbtc/minter/tests/tests.rs index fc1cb9b37655..f01385e0c278 100644 --- a/rs/bitcoin/ckbtc/minter/tests/tests.rs +++ b/rs/bitcoin/ckbtc/minter/tests/tests.rs @@ -1501,8 +1501,7 @@ impl CkBtcSetup { } pub fn print_minter_canister_logs(&self) { - let log = self.env.canister_log(self.minter_id); - let mut records = log.records().iter().collect::>(); + let mut records = self.env.canister_log_records(self.minter_id); records.sort_by_key(|a| a.idx); for entry in records { println!( diff --git a/rs/config/src/execution_environment.rs b/rs/config/src/execution_environment.rs index de66980ff620..c40d04893854 100644 --- a/rs/config/src/execution_environment.rs +++ b/rs/config/src/execution_environment.rs @@ -15,23 +15,8 @@ const REPLICATED_INTER_CANISTER_LOG_FETCH_FEATURE: FlagStatus = FlagStatus::Disa const FLEXIBLE_HTTP_REQUESTS_FEATURE: FlagStatus = FlagStatus::Disabled; -// TODO(DSM-105): remove after the feature is enabled by default. -pub const LOG_MEMORY_STORE_FEATURE_ENABLED: bool = true; -pub const LOG_MEMORY_STORE_FEATURE: FlagStatus = if LOG_MEMORY_STORE_FEATURE_ENABLED { - FlagStatus::Enabled -} else { - FlagStatus::Disabled -}; -pub const TEST_DEFAULT_LOG_MEMORY_LIMIT: u64 = if LOG_MEMORY_STORE_FEATURE_ENABLED { - 4 * KIB -} else { - 0 -}; -pub const TEST_DEFAULT_LOG_MEMORY_USAGE: u64 = if LOG_MEMORY_STORE_FEATURE_ENABLED { - 4 * KIB + 4 * KIB + TEST_DEFAULT_LOG_MEMORY_LIMIT // header, index table, data region -} else { - 0 -}; +pub const TEST_DEFAULT_LOG_MEMORY_LIMIT: u64 = 4 * KIB; +pub const TEST_DEFAULT_LOG_MEMORY_USAGE: u64 = 4 * KIB + 4 * KIB + TEST_DEFAULT_LOG_MEMORY_LIMIT; // header, index table, data region /// This specifies the threshold in bytes at which the subnet memory usage is /// considered to be high. If this value is greater or equal to the subnet diff --git a/rs/embedders/src/wasmtime_embedder/system_api/sandbox_safe_system_state.rs b/rs/embedders/src/wasmtime_embedder/system_api/sandbox_safe_system_state.rs index 61aa3d1b3894..9e5010433037 100644 --- a/rs/embedders/src/wasmtime_embedder/system_api/sandbox_safe_system_state.rs +++ b/rs/embedders/src/wasmtime_embedder/system_api/sandbox_safe_system_state.rs @@ -393,16 +393,10 @@ impl SystemStateModifications { ) -> HypervisorResult { // Append delta logs. if !self.canister_log.is_empty() { - // TODO(DSM-11): Move this into append_delta_log() once there is only one of it. metrics.observe_delta_log_size(self.canister_log.bytes_used()); } system_state .log_memory_store - .append_delta_log(&mut self.canister_log.clone()); - // Keep the legacy `canister_log` store up to date so that checkpoints - // remain readable by replicas that predate the log memory store. - system_state - .canister_log .append_delta_log(&mut self.canister_log); // Verify total cycle change is not positive and update cycles balance. diff --git a/rs/ethereum/cketh/test_utils/src/lib.rs b/rs/ethereum/cketh/test_utils/src/lib.rs index 4050a31dd8db..093d417da481 100644 --- a/rs/ethereum/cketh/test_utils/src/lib.rs +++ b/rs/ethereum/cketh/test_utils/src/lib.rs @@ -698,9 +698,7 @@ impl CkEthSetup { } pub fn minter_canister_logs(&self) -> Vec { - let log = self.env.canister_log(self.minter_id); - - let mut records = log.records().iter().collect::>(); + let mut records = self.env.canister_log_records(self.minter_id); records.sort_by_key(|a| a.idx); records .into_iter() diff --git a/rs/execution_environment/src/canister_manager/tests.rs b/rs/execution_environment/src/canister_manager/tests.rs index e88c16171ac5..59aa31e99858 100644 --- a/rs/execution_environment/src/canister_manager/tests.rs +++ b/rs/execution_environment/src/canister_manager/tests.rs @@ -20,10 +20,9 @@ use ic_config::embedders::DEFAULT_CREATE_EXECUTION_STATE_BASE_COST; use ic_config::{ execution_environment::{ CANISTER_GUARANTEED_CALLBACK_QUOTA, Config, DEFAULT_WASM_MEMORY_LIMIT, - LOG_MEMORY_STORE_FEATURE_ENABLED, MAX_ENVIRONMENT_VARIABLE_NAME_LENGTH, - MAX_ENVIRONMENT_VARIABLE_VALUE_LENGTH, MAX_ENVIRONMENT_VARIABLES, - MAX_NUMBER_OF_SNAPSHOTS_PER_CANISTER, SUBNET_CALLBACK_SOFT_LIMIT, - SUBNET_MEMORY_RESERVATION, TEST_DEFAULT_LOG_MEMORY_USAGE, + MAX_ENVIRONMENT_VARIABLE_NAME_LENGTH, MAX_ENVIRONMENT_VARIABLE_VALUE_LENGTH, + MAX_ENVIRONMENT_VARIABLES, MAX_NUMBER_OF_SNAPSHOTS_PER_CANISTER, + SUBNET_CALLBACK_SOFT_LIMIT, SUBNET_MEMORY_RESERVATION, TEST_DEFAULT_LOG_MEMORY_USAGE, }, flag_status::FlagStatus, subnet_config::{CANISTER_CREATION_FEE, SchedulerConfig}, @@ -536,11 +535,8 @@ fn install_canister_fails_if_memory_capacity_exceeded() { // Try installing canister2, should fail due to insufficient memory capacity on the subnet. let err = test.install_canister(canister2, wasm).unwrap_err(); - let msg = if LOG_MEMORY_STORE_FEATURE_ENABLED { - "Canister requested 10.00 MiB of memory but only 9.99 MiB are available in the subnet." - } else { - "Canister requested 10.00 MiB of memory but only 10.00 MiB are available in the subnet." - }; + let msg = + "Canister requested 10.00 MiB of memory but only 9.99 MiB are available in the subnet."; err.assert_contains(ErrorCode::SubnetOversubscribed, msg); assert_eq!( test.canister_state(canister2).system_state.balance(), @@ -2294,11 +2290,8 @@ fn upgrading_canister_fails_if_memory_capacity_exceeded() { // Try upgrading the canister, should fail because there is not enough memory capacity // on the subnet. - let msg = if LOG_MEMORY_STORE_FEATURE_ENABLED { - "Canister requested 10.00 MiB of memory but only 9.99 MiB are available in the subnet." - } else { - "Canister requested 10.00 MiB of memory but only 10.00 MiB are available in the subnet." - }; + let msg = + "Canister requested 10.00 MiB of memory but only 9.99 MiB are available in the subnet."; test.upgrade_canister(canister2, wasm) .unwrap_err() .assert_contains(ErrorCode::SubnetOversubscribed, msg); diff --git a/rs/execution_environment/src/execution/install.rs b/rs/execution_environment/src/execution/install.rs index 4570e8adaff1..447eb10a67a7 100644 --- a/rs/execution_environment/src/execution/install.rs +++ b/rs/execution_environment/src/execution/install.rs @@ -90,7 +90,7 @@ pub(crate) fn execute_install( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } @@ -109,7 +109,7 @@ pub(crate) fn execute_install( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } }; @@ -136,7 +136,7 @@ pub(crate) fn execute_install( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } helper.clear_certified_data(); @@ -250,7 +250,7 @@ fn install_stage_2a_process_start_result( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } @@ -362,7 +362,7 @@ fn install_stage_3_process_init_result( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } helper.finish(clean_canister, original, round, round_limits) diff --git a/rs/execution_environment/src/execution/install_code.rs b/rs/execution_environment/src/execution/install_code.rs index 38521e1ee3df..a45dd179f595 100644 --- a/rs/execution_environment/src/execution/install_code.rs +++ b/rs/execution_environment/src/execution/install_code.rs @@ -23,9 +23,7 @@ use ic_replicated_state::canister_state::system_state::{ use ic_replicated_state::metadata_state::subnet_call_context_manager::InstallCodeCallId; use ic_replicated_state::{CanisterState, ExecutionState, num_bytes_try_from}; use ic_sys::PAGE_SIZE; -use ic_types::{ - CanisterLog, CanisterTimer, MemoryAllocation, NumInstructions, Time, messages::CanisterCall, -}; +use ic_types::{CanisterTimer, MemoryAllocation, NumInstructions, Time, messages::CanisterCall}; use ic_types_cycles::{CompoundCycles, Cycles, CyclesUseCase, Instructions}; use ic_wasm_types::WasmHash; @@ -249,20 +247,19 @@ impl InstallCodeHelper { paused: PausedInstallCodeHelper, original: &OriginalContext, round: &RoundContext, - ) -> Result< - Self, - ( - CanisterManagerError, - NumInstructions, - (CanisterLog, LogMemoryStore), - ), - > { + ) -> Result { let mut helper = Self::new(clean_canister, original); let paused_instructions_left = paused.instructions_left; for state_change in paused.steps.into_iter() { helper .replay_step(state_change, original, round) - .map_err(|err| (err, paused_instructions_left, helper.take_canister_log()))?; + .map_err(|err| { + ( + err, + paused_instructions_left, + helper.clone_log_memory_store(), + ) + })?; } debug_assert_eq!(paused_instructions_left, helper.instructions_left()); Ok(helper) @@ -349,7 +346,7 @@ impl InstallCodeHelper { original, round, CanisterManagerError::Hypervisor(self.canister.canister_id(), err), - self.take_canister_log(), + self.clone_log_memory_store(), ); } } @@ -393,7 +390,7 @@ impl InstallCodeHelper { original, round, err, - self.take_canister_log(), + self.clone_log_memory_store(), ); } } @@ -422,7 +419,7 @@ impl InstallCodeHelper { original, round, err, - self.take_canister_log(), + self.clone_log_memory_store(), ); } } @@ -466,7 +463,7 @@ impl InstallCodeHelper { original, round, err, - self.take_canister_log(), + self.clone_log_memory_store(), ); } } @@ -617,13 +614,12 @@ impl InstallCodeHelper { } } - /// Takes the canister log. - pub(crate) fn take_canister_log(&mut self) -> (CanisterLog, LogMemoryStore) { - // TODO(DSM-105): Remove duplication when the migration is fully done. - ( - self.canister.system_state.canister_log.take(), - self.canister.system_state.log_memory_store.clone(), - ) + /// Returns a clone of the canister's log memory store. + /// + /// Cloning is cheap as the log memory store is backed by a persistent + /// `PageMap` whose clone creates an independent snapshot cheaply. + pub(crate) fn clone_log_memory_store(&self) -> LogMemoryStore { + self.canister.system_state.log_memory_store.clone() } /// Checks the result of Wasm execution and applies the state changes. @@ -859,11 +855,11 @@ pub(crate) fn finish_err( original: OriginalContext, round: RoundContext, err: CanisterManagerError, - new_canister_log: (CanisterLog, LogMemoryStore), + new_log_memory_store: LogMemoryStore, ) -> DtsInstallCodeResult { let mut new_canister = clean_canister; - new_canister.set_log(new_canister_log); + new_canister.set_log(new_log_memory_store); new_canister .system_state .apply_ingress_induction_cycles_debit( diff --git a/rs/execution_environment/src/execution/upgrade.rs b/rs/execution_environment/src/execution/upgrade.rs index b84742d07dda..85180845c3ba 100644 --- a/rs/execution_environment/src/execution/upgrade.rs +++ b/rs/execution_environment/src/execution/upgrade.rs @@ -111,7 +111,7 @@ pub(crate) fn execute_upgrade( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } @@ -128,7 +128,7 @@ pub(crate) fn execute_upgrade( original, round, (canister_id, HypervisorError::WasmModuleNotFound).into(), - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } }; @@ -237,7 +237,7 @@ fn upgrade_stage_1_process_pre_upgrade_result( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } @@ -275,7 +275,7 @@ fn upgrade_stage_2_and_3a_create_execution_state_and_call_start( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } }; @@ -308,7 +308,7 @@ fn upgrade_stage_2_and_3a_create_execution_state_and_call_start( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } }; @@ -326,7 +326,7 @@ fn upgrade_stage_2_and_3a_create_execution_state_and_call_start( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } @@ -439,7 +439,7 @@ fn upgrade_stage_3b_process_start_result( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } @@ -554,7 +554,7 @@ fn upgrade_stage_4b_process_post_upgrade_result( original, round, err, - helper.take_canister_log(), + helper.clone_log_memory_store(), ); } helper.finish(clean_canister, original, round, round_limits) diff --git a/rs/execution_environment/tests/backtraces.rs b/rs/execution_environment/tests/backtraces.rs index e93e0c1edfe1..24c860299a55 100644 --- a/rs/execution_environment/tests/backtraces.rs +++ b/rs/execution_environment/tests/backtraces.rs @@ -81,8 +81,8 @@ fn assert_error( .execute_ingress_as(CONTROLLER, canister_id, method, Encode!(&()).unwrap()) .unwrap_err(); result.assert_matches(code, &format!("{message}.*{backtrace}.*")); - let logs = env.canister_log(canister_id); - let last_error = std::str::from_utf8(&logs.records().back().as_ref().unwrap().content).unwrap(); + let logs = env.canister_log_records(canister_id); + let last_error = std::str::from_utf8(&logs.last().as_ref().unwrap().content).unwrap(); let backtrace_regex = RegexBuilder::new(&format!(".*{backtrace}.*")) .dot_matches_new_line(true) .build() @@ -129,8 +129,8 @@ fn no_backtrace_without_name_section() { "Result message: {} cointains unexpected 'Backtrace'", result.description(), ); - let logs = env.canister_log(canister_id); - for log in logs.records() { + let logs = env.canister_log_records(canister_id); + for log in &logs { let log = std::str::from_utf8(&log.content).unwrap(); assert!( !log.contains("Backtrace"), @@ -236,9 +236,8 @@ mod visibility { ); } // The backtrace should still be in the logs. - let logs = env.canister_log(canister_id); - let last_error = - std::str::from_utf8(&logs.records().back().as_ref().unwrap().content).unwrap(); + let logs = env.canister_log_records(canister_id); + let last_error = std::str::from_utf8(&logs.last().as_ref().unwrap().content).unwrap(); assert!( backtrace_regex.is_match(last_error), "Last log:\n----------\n{last_error}\n----------\ndoesn't contain backtrace: {backtrace}" diff --git a/rs/execution_environment/tests/canister_logging.rs b/rs/execution_environment/tests/canister_logging.rs index 8cf3752ac62f..b4f28c760dc5 100644 --- a/rs/execution_environment/tests/canister_logging.rs +++ b/rs/execution_environment/tests/canister_logging.rs @@ -1,7 +1,5 @@ use ic_base_types::PrincipalId; -use ic_config::execution_environment::{ - Config as ExecutionConfig, LOG_MEMORY_STORE_FEATURE_ENABLED, TEST_DEFAULT_LOG_MEMORY_USAGE, -}; +use ic_config::execution_environment::{Config as ExecutionConfig, TEST_DEFAULT_LOG_MEMORY_USAGE}; use ic_config::flag_status::FlagStatus; use ic_config::subnet_config::SubnetConfig; use ic_execution_environment::units::{KIB, MIB}; @@ -1002,7 +1000,7 @@ fn test_canister_log_in_state_stays_within_limit() { let _ = env.execute_ingress(canister_id, "test", vec![]); } // Expect that the total size of the log in canister state is not zero and less than the limit. - let log_size = env.canister_log(canister_id).bytes_used(); + let log_size = env.canister_log_bytes_used(canister_id); assert_lt!(0, log_size); assert_le!(log_size, TEST_DEFAULT_LOG_MEMORY_LIMIT); } @@ -1746,46 +1744,12 @@ fn test_logging_of_long_running_dts_over_checkpoint() { const METRIC_BYTES_OVERHEAD_FACTOR: f64 = 1.05; const METRIC_PAYLOAD_SIZE: usize = 1_000; -#[test] -fn test_metric_canister_log_memory_usage_bytes_from_canister_log() { - // When the log memory store feature is disabled, the metric tracks - // `CanisterLog.bytes_used()`, which grows with each debug_print. - if LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } - const METRIC: &str = "canister_log_memory_usage_bytes_v3"; - let env = setup_env(); - let canister_id = create_and_install_canister( - &env, - CanisterSettingsArgsBuilder::new().build(), - wat_canister() - .update("test", wat_fn().debug_print(&[37; METRIC_PAYLOAD_SIZE])) - .build_wasm(), - ); - - // Nothing logged yet — sum is zero. - let stats = fetch_histogram_stats(env.metrics_registry(), METRIC).unwrap(); - assert_eq!(stats.sum, 0.0); - - // One debug_print — sum reflects the payload plus small record metadata. - let _ = env.execute_ingress(canister_id, "test", vec![]); - let stats = fetch_histogram_stats(env.metrics_registry(), METRIC).unwrap(); - assert_le!(METRIC_PAYLOAD_SIZE as f64, stats.sum); - assert_le!( - stats.sum, - METRIC_BYTES_OVERHEAD_FACTOR * METRIC_PAYLOAD_SIZE as f64 - ); -} - #[test] fn test_metric_canister_log_memory_usage_bytes_from_log_memory_store() { - // When the log memory store feature is enabled, the metric tracks - // `LogMemoryStore.memory_usage()` — the allocated capacity of the store. - // It is set at canister creation from the default limit and stays stable - // under debug_print; only a `log_memory_limit` resize changes it. - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } + // The metric tracks `LogMemoryStore.memory_usage()` — the allocated + // capacity of the store. It is set at canister creation from the default + // limit and stays stable under debug_print; only a `log_memory_limit` + // resize changes it. const METRIC: &str = "canister_log_memory_usage_bytes_v3"; let env = setup_env(); let canister_id = create_and_install_canister( @@ -1846,9 +1810,7 @@ fn test_metric_canister_log_delta_memory_usage_bytes() { fn test_metric_canister_log_retention_seconds() { // Observed by the scheduler at round finalization for canisters that // appended log records this round. Retention is the wall-clock span - // between the oldest and newest records held in the buffer. Both log - // stores (old `CanisterLog` and new `LogMemoryStore`) compute it the - // same way — the assertions hold regardless of the feature flag. + // between the oldest and newest records held in the `LogMemoryStore`. const METRIC: &str = "canister_log_retention_seconds"; const TIME_ADVANCE: Duration = Duration::from_secs(60); let env = setup_env(); @@ -1880,9 +1842,6 @@ fn test_metric_canister_log_resize_duration_seconds() { // Observed at the resize call site in `CanisterManager::update_settings` // whenever `log_memory_limit` actually changes. The `would_resize` gate // ensures no-op resizes (same limit) do not emit samples. - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } const METRIC: &str = "canister_log_resize_duration_seconds"; let controller = PrincipalId::new_anonymous(); let (env, canister_id) = setup_with_controller(controller, UNIVERSAL_CANISTER_WASM.to_vec()); @@ -2082,9 +2041,6 @@ fn test_canister_log_on_cleanup() { #[test] fn test_default_log_memory_limit_and_size() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let controller = PrincipalId::new_anonymous(); let (env, canister_id) = setup_with_controller(controller, UNIVERSAL_CANISTER_WASM.to_vec()); @@ -2101,9 +2057,6 @@ fn test_default_log_memory_limit_and_size() { #[test] fn test_changing_log_memory_limit_and_size() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let controller = PrincipalId::new_anonymous(); let (env, canister_id) = setup_with_controller(controller, UNIVERSAL_CANISTER_WASM.to_vec()); @@ -2128,9 +2081,6 @@ fn test_changing_log_memory_limit_and_size() { #[test] fn test_setting_log_memory_limit_to_zero() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let controller = PrincipalId::new_anonymous(); let (env, canister_id) = setup_with_controller(controller, UNIVERSAL_CANISTER_WASM.to_vec()); @@ -2151,9 +2101,6 @@ fn test_setting_log_memory_limit_to_zero() { #[test] fn test_canister_reinstall_clears_logs_but_preserves_log_memory_limit() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let expected_memory_usage = 8 * KIB + TEST_DEFAULT_LOG_MEMORY_LIMIT as u64; let controller = PrincipalId::new_anonymous(); let wasm = wat_canister() @@ -2182,9 +2129,6 @@ fn test_canister_reinstall_clears_logs_but_preserves_log_memory_limit() { #[test] fn test_canister_uninstall_code_clears_logs() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let controller = PrincipalId::new_anonymous(); let wasm = wat_canister() .update("test", wat_fn().debug_print(b"hello")) @@ -2226,9 +2170,6 @@ fn test_canister_uninstall_code_clears_logs() { #[test] fn test_canister_uninstall_and_install_clears_log() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let controller = PrincipalId::new_anonymous(); let wasm = wat_canister() .update("test", wat_fn().debug_print(b"hello")) @@ -2260,9 +2201,6 @@ fn test_canister_uninstall_and_install_clears_log() { #[test] fn test_large_delta_log_in_single_execution() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } // Test that a single message execution can generate a large delta log // (e.g., ~1.5 MiB) that exceeds the default 4 KiB capacity but is still // within the configured canister log memory limit. @@ -2295,9 +2233,6 @@ fn test_large_delta_log_in_single_execution() { #[test] fn test_canister_resize_up_preserves_logs() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let log_memory_limit = 2 * MIB; let env = setup_env(); @@ -2348,9 +2283,6 @@ fn test_canister_resize_up_preserves_logs() { #[test] fn test_canister_resize_down_preserves_logs() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let log_memory_limit = 2 * MIB; let env = setup_env(); @@ -2401,9 +2333,6 @@ fn test_canister_resize_down_preserves_logs() { #[test] fn test_canister_log_resize_deducts_cycles() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let log_memory_limit = 2 * MIB; let env = setup_env(); @@ -2455,9 +2384,6 @@ fn test_canister_log_resize_deducts_cycles() { #[test] fn test_canister_log_resize_rejected_insufficient_cycles() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let log_memory_limit = 256 * KIB; let env = setup_env(); @@ -2508,9 +2434,6 @@ fn test_canister_log_resize_rejected_insufficient_cycles() { #[test] fn test_canister_log_resize_empty_buffer_minimal_charge() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let log_memory_limit = 2 * MIB; let env = setup_env(); let controller = PrincipalId::new_anonymous(); @@ -2554,60 +2477,6 @@ fn test_canister_log_resize_empty_buffer_minimal_charge() { ); } -#[test] -fn test_canister_log_resize_no_extra_charge_feature_disabled() { - if LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } - let env = setup_env(); - let controller = PrincipalId::new_anonymous(); - let canister_id = create_and_install_canister( - &env, - CanisterSettingsArgsBuilder::new() - .with_controllers(vec![controller]) - .build(), - wat_canister() - .update("test", wat_fn().debug_print(b"hello")) - .build_wasm(), - ); - - // Write some logs (goes to old canister_log, not log_memory_store). - let _ = env.execute_ingress(canister_id, "test", vec![]); - let _ = env.execute_ingress(canister_id, "test", vec![]); - let _ = env.execute_ingress(canister_id, "test", vec![]); - - // Baseline: update_settings without log_memory_limit. - let balance_before_baseline = env.cycle_balance(canister_id); - let _ = env.update_settings( - &canister_id, - CanisterSettingsArgsBuilder::new() - .with_log_visibility(LogVisibilityV2::Public) - .build(), - ); - let baseline_cost = balance_before_baseline - env.cycle_balance(canister_id); - - // Update_settings with log_memory_limit — should cost the same as baseline - // because log_memory_store.bytes_used() is 0 when the feature is disabled. - let balance_before_resize = env.cycle_balance(canister_id); - let result = env.update_settings( - &canister_id, - CanisterSettingsArgsBuilder::new() - .with_log_memory_limit(4096) - .build(), - ); - assert!(result.is_ok()); - let resize_cost = balance_before_resize - env.cycle_balance(canister_id); - - // Costs should be roughly equal — no extra charge for resize. - assert_le!( - resize_cost, - baseline_cost * 2, - "With feature disabled, resize cost ({}) should be close to baseline ({})", - resize_cost, - baseline_cost - ); -} - #[test] fn test_fetch_canister_logs_update_call_rejected_insufficient_cycles() { let user_controller = PrincipalId::new_user_test_id(42); @@ -2692,12 +2561,8 @@ fn test_fetch_canister_logs_update_call_deducts_cycles() { #[test] fn test_canister_log_with_zero_log_memory_limit() { let subnet_type = SubnetType::Application; - let config = StateMachineConfig::new( - SubnetConfig::new(subnet_type), - ExecutionConfig { - ..Default::default() - }, - ); + let config = + StateMachineConfig::new(SubnetConfig::new(subnet_type), ExecutionConfig::default()); let env = StateMachineBuilder::new() .with_config(Some(config.clone())) .with_subnet_type(subnet_type) @@ -2725,20 +2590,18 @@ fn test_canister_log_with_zero_log_memory_limit() { .build(), ); - // Produce a second log with no ring buffer. Both canister_log and - // persistent_next_idx advance to next_idx == 2. + // Produce a second log with no ring buffer. persistent_next_idx advances + // to next_idx == 2. let _ = env.execute_ingress( canister_id, "update", wasm().debug_print(b"log").reply().build(), ); - // Both canister_log.next_idx() and lms.next_idx() must be 2 before - // and after a checkpoint/reload cycle. + // lms.next_idx() must be 2 before and after a checkpoint/reload cycle. let check_next_idx = |env: &StateMachine| { let state = env.get_latest_state(); let ss = &state.canister_state(&canister_id).unwrap().system_state; - assert_eq!(ss.canister_log.next_idx(), 2); assert_eq!(ss.log_memory_store.next_idx(), 2); }; check_next_idx(&env); @@ -2750,9 +2613,6 @@ fn test_canister_log_with_zero_log_memory_limit() { #[test] fn test_log_memory_store_deallocated_when_canister_out_of_cycles() { // Test that the log memory store is deallocated when a canister runs out of cycles. - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let controller = PrincipalId::new_anonymous(); let env = setup_env(); // Use 300T cycles — enough to satisfy the freeze-threshold reserve for diff --git a/rs/execution_environment/tests/memory_matrix.rs b/rs/execution_environment/tests/memory_matrix.rs index f5353c3d6b79..a5c145090c01 100644 --- a/rs/execution_environment/tests/memory_matrix.rs +++ b/rs/execution_environment/tests/memory_matrix.rs @@ -35,7 +35,6 @@ The scenarios cover the following: */ use ic_base_types::{CanisterId, NumBytes, PrincipalId, SnapshotId}; -use ic_config::execution_environment::LOG_MEMORY_STORE_FEATURE_ENABLED; use ic_cycles_account_manager::ResourceSaturation; use ic_error_types::{ErrorCode, UserError}; use ic_execution_environment::units::{GIB, KIB}; @@ -1628,9 +1627,6 @@ fn test_memory_suite_decrease_memory_allocation() { #[test] fn test_memory_suite_increase_log_memory_limit() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let op = |test: &mut ExecutionTest, canister_id: CanisterId, ()| { let update_settings_args = update_memory_allocation_args(canister_id, None, Some(1024 * KIB)); @@ -1648,9 +1644,6 @@ fn test_memory_suite_increase_log_memory_limit() { #[test] fn test_memory_suite_increase_log_memory_limit_and_memory_allocation() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let op = |test: &mut ExecutionTest, canister_id: CanisterId, ()| { let current_memory_allocation = test .canister_state(canister_id) @@ -1675,9 +1668,6 @@ fn test_memory_suite_increase_log_memory_limit_and_memory_allocation() { #[test] fn test_memory_suite_decrease_log_memory_limit() { - if !LOG_MEMORY_STORE_FEATURE_ENABLED { - return; - } let op = |test: &mut ExecutionTest, canister_id: CanisterId, ()| { let update_settings_args = update_memory_allocation_args(canister_id, None, Some(256 * KIB)); diff --git a/rs/ledger_suite/icp/ledger/tests/tests.rs b/rs/ledger_suite/icp/ledger/tests/tests.rs index d0d7f5e86724..627a7e5f58f5 100644 --- a/rs/ledger_suite/icp/ledger/tests/tests.rs +++ b/rs/ledger_suite/icp/ledger/tests/tests.rs @@ -1963,9 +1963,9 @@ fn test_notify_caller_logging() { ); // Verify that the ledger logged the caller of the notify method. - let log = env.canister_log(canister_id); + let log = env.canister_log_records(canister_id); let expected_log_entry = format!("notify method called by [{user1}]"); - for record in log.records().iter() { + for record in log.iter() { let entry = String::from_utf8(record.content.clone()).expect("log entry should be a string"); if entry.contains(&expected_log_entry) { diff --git a/rs/migration_canister/tests/tests.rs b/rs/migration_canister/tests/tests.rs index 901bc41430d9..4e69953777f4 100644 --- a/rs/migration_canister/tests/tests.rs +++ b/rs/migration_canister/tests/tests.rs @@ -1,7 +1,6 @@ use candid::{CandidType, Decode, Encode, Principal, Reserved}; use canister_test::Project; use ic_base_types::{CanisterId, PrincipalId}; -use ic_config::execution_environment::LOG_MEMORY_STORE_FEATURE_ENABLED; use ic_management_canister_types::{CanisterLogRecord, CanisterSettings}; use ic_management_canister_types_private::{ CanisterChangeDetails, CanisterInfoRequest, CanisterInfoResponse, Payload as _, @@ -182,11 +181,7 @@ async fn setup( let cycles = if enough_cycles { None } else { - Some(if LOG_MEMORY_STORE_FEATURE_ENABLED { - 40_000_000_000 - } else { - 30_000_000_000 - }) + Some(40_000_000_000) }; let migrated_canister = pic .create_canister_with_params( diff --git a/rs/protobuf/def/state/canister_state_bits/v1/canister_state_bits.proto b/rs/protobuf/def/state/canister_state_bits/v1/canister_state_bits.proto index 703b6d304445..352a6a7f6ae9 100644 --- a/rs/protobuf/def/state/canister_state_bits/v1/canister_state_bits.proto +++ b/rs/protobuf/def/state/canister_state_bits/v1/canister_state_bits.proto @@ -448,7 +448,7 @@ message TaskQueue { // Next ID: 70 message CanisterStateBits { - reserved 1, 2, 3, 5, 6, 9, 10, 14, 16, 17, 24, 30, 35, 42, 47, 48, 49, 52, 53; + reserved 1, 2, 3, 5, 6, 9, 10, 14, 16, 17, 24, 30, 35, 42, 43, 44, 47, 48, 49, 52, 53, 66; uint64 compute_allocation = 4; ExecutionStateBits execution_state_bits = 7; @@ -514,13 +514,6 @@ message CanisterStateBits { LogVisibilityV2 log_visibility_v2 = 51; // The capacity of the canister log in bytes. uint64 log_memory_limit = 56; - // Log records of the canister. - repeated CanisterLogRecord canister_log_records = 43; - // The index of the next log record to be created. - uint64 next_canister_log_record_idx = 44; - // Whether the one-time migration from CanisterLog to LogMemoryStore has - // already been performed for this canister. - bool log_memory_store_migrated = 66; // The persistent high-water mark for log record indexing in LogMemoryStore. uint64 log_memory_store_persistent_next_idx = 67; // The Wasm memory limit. This is a field in developer-visible canister diff --git a/rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs b/rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs index 5686a38a67b7..f112407cb59e 100644 --- a/rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs +++ b/rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs @@ -770,16 +770,6 @@ pub struct CanisterStateBits { /// The capacity of the canister log in bytes. #[prost(uint64, tag = "56")] pub log_memory_limit: u64, - /// Log records of the canister. - #[prost(message, repeated, tag = "43")] - pub canister_log_records: ::prost::alloc::vec::Vec, - /// The index of the next log record to be created. - #[prost(uint64, tag = "44")] - pub next_canister_log_record_idx: u64, - /// Whether the one-time migration from CanisterLog to LogMemoryStore has - /// already been performed for this canister. - #[prost(bool, tag = "66")] - pub log_memory_store_migrated: bool, /// The persistent high-water mark for log record indexing in LogMemoryStore. #[prost(uint64, tag = "67")] pub log_memory_store_persistent_next_idx: u64, diff --git a/rs/replicated_state/src/canister_state.rs b/rs/replicated_state/src/canister_state.rs index d28794b86003..6bcd988c92cb 100644 --- a/rs/replicated_state/src/canister_state.rs +++ b/rs/replicated_state/src/canister_state.rs @@ -25,8 +25,7 @@ use ic_registry_subnet_type::SubnetType; use ic_types::messages::{CallbackId, CanisterMessage, Ingress, RequestOrResponse, Response}; use ic_types::methods::{SystemMethod, WasmMethod}; use ic_types::{ - CanisterId, CanisterLog, ComputeAllocation, MemoryAllocation, NumBytes, NumInstructions, - PrincipalId, Time, + CanisterId, ComputeAllocation, MemoryAllocation, NumBytes, NumInstructions, PrincipalId, Time, }; use ic_validate_eq::ValidateEq; use ic_validate_eq_derive::ValidateEq; @@ -630,19 +629,16 @@ impl CanisterState { /// Clears the canister log. pub fn clear_log(&mut self) { - self.system_state.canister_log.clear(); self.system_state.log_memory_store.clear(); } /// Removes the canister log. pub fn remove_log(&mut self) { - self.system_state.canister_log.clear(); self.system_state.log_memory_store.deallocate(); } /// Sets the new canister log. - pub fn set_log(&mut self, (canister_log, log_memory_store): (CanisterLog, LogMemoryStore)) { - self.system_state.canister_log = canister_log; + pub fn set_log(&mut self, log_memory_store: LogMemoryStore) { self.system_state.log_memory_store = log_memory_store; } diff --git a/rs/replicated_state/src/canister_state/system_state.rs b/rs/replicated_state/src/canister_state/system_state.rs index 7f7d381fb961..17143f99b7a1 100644 --- a/rs/replicated_state/src/canister_state/system_state.rs +++ b/rs/replicated_state/src/canister_state/system_state.rs @@ -41,8 +41,8 @@ use ic_types::messages::{ use ic_types::methods::{Callback, WasmClosure}; use ic_types::time::{CoarseTime, UNIX_EPOCH}; use ic_types::{ - CanisterId, CanisterLog, CanisterTimer, ComputeAllocation, CountBytes, MemoryAllocation, - NumBytes, NumInstructions, PrincipalId, Time, + CanisterId, CanisterTimer, ComputeAllocation, CountBytes, MemoryAllocation, NumBytes, + NumInstructions, PrincipalId, Time, }; use ic_types_cycles::{ CanisterCyclesCostSchedule, CompoundCycles, Cycles, CyclesUseCase, CyclesUseCaseKind, @@ -588,10 +588,6 @@ pub struct SystemState { /// Status visibility of the canister. pub status_visibility: StatusVisibility, - /// Log records of the canister. - #[validate_eq(CompareWithValidateEq)] - pub canister_log: CanisterLog, - /// The memory used for storing log entries. #[validate_eq(CompareWithValidateEq)] pub log_memory_store: LogMemoryStore, @@ -776,10 +772,6 @@ impl SystemState { log_visibility: Default::default(), snapshot_visibility: Default::default(), status_visibility: Default::default(), - // TODO(EXC-2118): CanisterLog does not store log records efficiently, - // therefore it should not scale to memory limit from above. - // Remove this field after migration is done. - canister_log: CanisterLog::default_aggregate(), log_memory_store: LogMemoryStore::new(), wasm_memory_limit: None, next_snapshot_id: 0, @@ -814,7 +806,6 @@ impl SystemState { log_visibility: LogVisibilityV2, snapshot_visibility: SnapshotVisibility, status_visibility: StatusVisibility, - canister_log: CanisterLog, log_memory_store_data: Option, log_memory_store_persistent_next_idx: u64, wasm_memory_limit: Option, @@ -851,7 +842,6 @@ impl SystemState { log_visibility, snapshot_visibility, status_visibility, - canister_log, log_memory_store: LogMemoryStore::from_checkpoint( log_memory_store_data, log_memory_store_persistent_next_idx, @@ -2687,10 +2677,6 @@ pub mod testing { log_visibility: Default::default(), snapshot_visibility: Default::default(), status_visibility: Default::default(), - // TODO(EXC-2118): CanisterLog does not store log records efficiently, - // therefore it should not scale to memory limit from above. - // Remove this field after migration is done. - canister_log: CanisterLog::default_aggregate(), log_memory_store: LogMemoryStore::new(), wasm_memory_limit: Default::default(), next_snapshot_id: Default::default(), diff --git a/rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs b/rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs index 5be20686f255..593e8fe31672 100644 --- a/rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs +++ b/rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs @@ -361,12 +361,28 @@ impl LogMemoryStore { } /// Returns the canister log records, optionally filtered. + /// + /// The result is trimmed to fit within the maximum message response size + /// (`RESULT_MAX_SIZE`), so this must NOT be used (e.g. with a `None` filter) + /// to obtain the complete set of stored records: doing so silently drops + /// records once they exceed the response-size limit. Callers that need all + /// records must use [`Self::all_records_for_testing`] instead. pub fn records(&self, filter: Option) -> Vec { self.load_ring_buffer() .map(|rb| rb.records(filter)) .unwrap_or_default() } + /// Returns all canister log records currently stored in the ring buffer. + /// + /// Unlike `records`, this does not trim the result to the maximum message + /// response size, so it is only intended for testing. + pub fn all_records_for_testing(&self) -> Vec { + self.load_ring_buffer() + .map(|rb| rb.iter().collect()) + .unwrap_or_default() + } + /// Appends a delta log to the ring buffer if it exists. pub fn append_delta_log(&mut self, delta_log: &mut CanisterLog) { if delta_log.is_empty() { diff --git a/rs/state_layout/src/state_layout.rs b/rs/state_layout/src/state_layout.rs index b6ab10f40723..ddc0ec464840 100644 --- a/rs/state_layout/src/state_layout.rs +++ b/rs/state_layout/src/state_layout.rs @@ -20,8 +20,8 @@ use ic_replicated_state::{ }; use ic_sys::{fs::sync_path, mmap::ScopedMmap}; use ic_types::{ - CanisterId, CanisterLog, CanisterTimer, ComputeAllocation, ExecutionRound, Height, - MemoryAllocation, NumInstructions, PrincipalId, SnapshotId, Time, batch::TotalQueryStats, + CanisterId, CanisterTimer, ComputeAllocation, ExecutionRound, Height, MemoryAllocation, + NumInstructions, PrincipalId, SnapshotId, Time, batch::TotalQueryStats, }; use ic_types_cycles::{Cycles, CyclesUseCase, NominalCycles}; use ic_utils::thread::maybe_parallel_map; @@ -210,9 +210,6 @@ pub struct CanisterStateBits { pub snapshot_visibility: SnapshotVisibility, pub status_visibility: StatusVisibility, pub log_memory_limit: NumBytes, - pub canister_log: CanisterLog, - pub next_canister_log_record_idx: u64, - pub log_memory_store_migrated: bool, pub log_memory_store_persistent_next_idx: u64, pub wasm_memory_limit: Option, pub next_snapshot_id: u64, diff --git a/rs/state_layout/src/state_layout/proto.rs b/rs/state_layout/src/state_layout/proto.rs index 2dea75b07bec..3f3babf67a01 100644 --- a/rs/state_layout/src/state_layout/proto.rs +++ b/rs/state_layout/src/state_layout/proto.rs @@ -74,14 +74,6 @@ impl From for pb_canister_state_bits::CanisterStateBits { ) .into(), log_memory_limit: item.log_memory_limit.get(), - canister_log_records: item - .canister_log - .records() - .iter() - .map(|record| record.into()) - .collect(), - next_canister_log_record_idx: item.next_canister_log_record_idx, - log_memory_store_migrated: item.log_memory_store_migrated, log_memory_store_persistent_next_idx: item.log_memory_store_persistent_next_idx, wasm_memory_limit: item.wasm_memory_limit.map(|v| v.get()), next_snapshot_id: item.next_snapshot_id, @@ -235,16 +227,6 @@ impl TryFrom for CanisterStateBits { ) .unwrap_or_default(), log_memory_limit: NumBytes::from(value.log_memory_limit), - canister_log: CanisterLog::new_aggregate( - value.next_canister_log_record_idx, - value - .canister_log_records - .into_iter() - .map(|record| record.into()) - .collect(), - ), - next_canister_log_record_idx: value.next_canister_log_record_idx, - log_memory_store_migrated: value.log_memory_store_migrated, log_memory_store_persistent_next_idx: value.log_memory_store_persistent_next_idx, wasm_memory_limit: value.wasm_memory_limit.map(NumBytes::from), next_snapshot_id: value.next_snapshot_id, diff --git a/rs/state_layout/src/state_layout/tests.rs b/rs/state_layout/src/state_layout/tests.rs index fa7f8a48541d..3ec261e75cc2 100644 --- a/rs/state_layout/src/state_layout/tests.rs +++ b/rs/state_layout/src/state_layout/tests.rs @@ -1,6 +1,5 @@ use super::*; -use ic_config::execution_environment::LOG_MEMORY_STORE_FEATURE_ENABLED; use ic_management_canister_types_private::{ CanisterChange, CanisterChangeDetails, CanisterChangeOrigin, CanisterInstallMode, IC_00, }; @@ -62,8 +61,6 @@ fn default_canister_state_bits() -> CanisterStateBits { snapshot_visibility: Default::default(), status_visibility: Default::default(), log_memory_limit: NumBytes::from(0), - canister_log: CanisterLog::default_aggregate(), - next_canister_log_record_idx: 0, wasm_memory_limit: None, next_snapshot_id: 0, environment_variables: BTreeMap::new(), @@ -73,7 +70,6 @@ fn default_canister_state_bits() -> CanisterStateBits { local_subnet_messages_executed: 0, http_outcalls_executed: 0, heartbeats_and_global_timers_executed: 0, - log_memory_store_migrated: LOG_MEMORY_STORE_FEATURE_ENABLED, log_memory_store_persistent_next_idx: 0, } } diff --git a/rs/state_machine_tests/src/lib.rs b/rs/state_machine_tests/src/lib.rs index 09fe2a913339..8620610812ef 100644 --- a/rs/state_machine_tests/src/lib.rs +++ b/rs/state_machine_tests/src/lib.rs @@ -59,12 +59,12 @@ use ic_limits::{MAX_INGRESS_TTL, PERMITTED_DRIFT, SMALL_APP_SUBNET_MAX_SIZE}; use ic_logger::replica_logger::test_logger; use ic_logger::{ReplicaLogger, error}; use ic_management_canister_types_private::{ - self as ic00, CanisterIdRecord, CanisterSnapshotDataKind, CanisterSnapshotDataOffset, - InstallCodeArgs, ListCanisterSnapshotArgs, ListCanisterSnapshotResponse, MasterPublicKeyId, - Method, Payload, ReadCanisterSnapshotDataArgs, ReadCanisterSnapshotDataResponse, - ReadCanisterSnapshotMetadataArgs, ReadCanisterSnapshotMetadataResponse, - UploadCanisterSnapshotDataArgs, UploadCanisterSnapshotMetadataArgs, - UploadCanisterSnapshotMetadataResponse, + self as ic00, CanisterIdRecord, CanisterLogRecord, CanisterSnapshotDataKind, + CanisterSnapshotDataOffset, InstallCodeArgs, ListCanisterSnapshotArgs, + ListCanisterSnapshotResponse, MasterPublicKeyId, Method, Payload, ReadCanisterSnapshotDataArgs, + ReadCanisterSnapshotDataResponse, ReadCanisterSnapshotMetadataArgs, + ReadCanisterSnapshotMetadataResponse, UploadCanisterSnapshotDataArgs, + UploadCanisterSnapshotMetadataArgs, UploadCanisterSnapshotMetadataResponse, }; use ic_management_canister_types_private::{ CanisterHttpResponsePayload, CanisterInstallMode, CanisterSettingsArgs, @@ -141,9 +141,8 @@ use ic_test_utilities_registry::{ use ic_test_utilities_time::FastForwardTimeSource; pub use ic_types::ingress::WasmResult; use ic_types::{ - CanisterId, CanisterLog, CountBytes, CryptoHashOfPartialState, CryptoHashOfState, Height, - NodeId, NumBytes, PrincipalId, Randomness, RegistryVersion, ReplicaVersion, SnapshotId, - SubnetId, UserId, + CanisterId, CountBytes, CryptoHashOfPartialState, CryptoHashOfState, Height, NodeId, NumBytes, + PrincipalId, Randomness, RegistryVersion, ReplicaVersion, SnapshotId, SubnetId, UserId, artifact::IngressMessageId, batch::{ Batch, BatchContent, BatchMessages, BatchSummary, BlockmakerMetrics, ChainKeyData, @@ -5029,13 +5028,25 @@ impl StateMachine { dst } - /// Returns the canister log of the specified canister. - pub fn canister_log(&self, canister_id: CanisterId) -> CanisterLog { + /// Returns all canister log records of the specified canister. + pub fn canister_log_records(&self, canister_id: CanisterId) -> Vec { let replicated_state = self.state_manager.get_latest_state().take(); let canister_state = replicated_state .canister_state(&canister_id) .unwrap_or_else(|| panic!("Canister {canister_id} does not exist")); - canister_state.system_state.canister_log.clone() + canister_state + .system_state + .log_memory_store + .all_records_for_testing() + } + + /// Returns the number of bytes used by the canister log of the specified canister. + pub fn canister_log_bytes_used(&self, canister_id: CanisterId) -> usize { + let replicated_state = self.state_manager.get_latest_state().take(); + let canister_state = replicated_state + .canister_state(&canister_id) + .unwrap_or_else(|| panic!("Canister {canister_id} does not exist")); + canister_state.system_state.log_memory_store.bytes_used() } /// Sets the content of the stable memory for the specified canister. diff --git a/rs/state_manager/src/checkpoint.rs b/rs/state_manager/src/checkpoint.rs index 8d5a1f79acc3..78c5c52b47c7 100644 --- a/rs/state_manager/src/checkpoint.rs +++ b/rs/state_manager/src/checkpoint.rs @@ -869,7 +869,6 @@ pub fn load_canister_state( canister_state_bits.log_visibility, canister_state_bits.snapshot_visibility, canister_state_bits.status_visibility, - canister_state_bits.canister_log, log_memory_store_data, canister_state_bits.log_memory_store_persistent_next_idx, canister_state_bits.wasm_memory_limit, @@ -878,15 +877,6 @@ pub fn load_canister_state( metrics, ); - let lms_next_idx = system_state.log_memory_store.next_idx(); - let log_next_idx = system_state.canister_log.next_idx(); - if lms_next_idx != log_next_idx { - metrics.observe_broken_soft_invariant(format!( - "canister {canister_id}: log_memory_store.next_idx ({lms_next_idx}) \ - != canister_log.next_idx ({log_next_idx})", - )); - } - let canister_state = CanisterState { system_state, execution_state, diff --git a/rs/state_manager/src/tip.rs b/rs/state_manager/src/tip.rs index 621bf2ad05f9..31534e3f55c8 100644 --- a/rs/state_manager/src/tip.rs +++ b/rs/state_manager/src/tip.rs @@ -1412,13 +1412,6 @@ fn serialize_canister_protos_to_checkpoint_readwrite( snapshot_visibility: canister_state.system_state.snapshot_visibility.clone(), status_visibility: canister_state.system_state.status_visibility.clone(), log_memory_limit: canister_state.log_memory_limit(), - canister_log: canister_state.system_state.canister_log.clone(), - next_canister_log_record_idx: canister_state.system_state.canister_log.next_idx(), - // The one-time migration from `CanisterLog` to `LogMemoryStore` - // completed on all subnets, so this is always `true`. The field is - // still serialized (rather than dropped) so checkpoints remain - // readable by replicas that predate the log memory store. - log_memory_store_migrated: true, log_memory_store_persistent_next_idx: canister_state .system_state .log_memory_store diff --git a/rs/types/types/src/canister_log.rs b/rs/types/types/src/canister_log.rs index aefd27a867f3..6a72499614de 100644 --- a/rs/types/types/src/canister_log.rs +++ b/rs/types/types/src/canister_log.rs @@ -182,9 +182,7 @@ impl CanisterLog { self.records.get() } - // TODO(DSM-11): remove allow(dead_code) when log memory store is used in production. /// Returns mutable reference to the canister log records. - #[allow(dead_code)] pub fn records_mut(&mut self) -> &mut VecDeque { self.records.get_mut() }