Skip to content

Commit

Permalink
chore: [IC-272] make canister logging feature flag more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
maksymar committed Feb 14, 2024
1 parent 1b4fcf4 commit 051a5b1
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions rs/config/src/execution_environment.rs
Expand Up @@ -262,8 +262,8 @@ pub struct Config {
pub canister_snapshots: FlagStatus,

// TODO(IC-272): remove this flag once the feature is enabled by default.
/// Indicates whether fetching canister logs API is enabled or not.
pub fetch_canister_logs: FlagStatus,
/// Indicates whether canister logging feature is enabled or not.
pub canister_logging: FlagStatus,

/// Indicates whether dirty page logging is enabled or not.
pub dirty_page_logging: FlagStatus,
Expand Down Expand Up @@ -337,7 +337,7 @@ impl Default for Config {
wasm_chunk_store: FlagStatus::Enabled,
stop_canister_timeout_duration: STOP_CANISTER_TIMEOUT_DURATION,
canister_snapshots: FlagStatus::Disabled,
fetch_canister_logs: FlagStatus::Disabled,
canister_logging: FlagStatus::Disabled,
dirty_page_logging: FlagStatus::Disabled,
}
}
Expand Down
4 changes: 2 additions & 2 deletions rs/execution_environment/src/canister_manager.rs
Expand Up @@ -437,7 +437,7 @@ impl CanisterManager {
provisional_whitelist: &ProvisionalWhitelist,
ingress: &SignedIngressContent,
effective_canister_id: Option<CanisterId>,
fetch_canister_logs: FlagStatus,
canister_logging: FlagStatus,
) -> Result<(), UserError> {
let method_name = ingress.method_name();
let sender = ingress.sender();
Expand Down Expand Up @@ -533,7 +533,7 @@ impl CanisterManager {
},

Ok(Ic00Method::FetchCanisterLogs) => {
match fetch_canister_logs {
match canister_logging {
FlagStatus::Enabled => Err(UserError::new(
ErrorCode::CanisterRejectedMessage,
format!(
Expand Down
4 changes: 2 additions & 2 deletions rs/execution_environment/src/execution_environment.rs
Expand Up @@ -1108,7 +1108,7 @@ impl ExecutionEnvironment {
Some((res, msg.take_cycles()))
}

Ok(Ic00Method::FetchCanisterLogs) => match self.config.fetch_canister_logs {
Ok(Ic00Method::FetchCanisterLogs) => match self.config.canister_logging {
FlagStatus::Enabled => Some((
Err(UserError::new(
ErrorCode::CanisterRejectedMessage,
Expand Down Expand Up @@ -1895,7 +1895,7 @@ impl ExecutionEnvironment {
provisional_whitelist,
ingress,
effective_canister_id,
self.config.fetch_canister_logs,
self.config.canister_logging,
);
}

Expand Down
4 changes: 2 additions & 2 deletions rs/execution_environment/src/execution_environment/tests.rs
Expand Up @@ -3274,7 +3274,7 @@ fn test_fetch_canister_logs_should_accept_ingress_message_disabled() {
// - disable the fetch_canister_logs API
// - set the log visibility to public so any user can read the logs
let mut test = ExecutionTestBuilder::new()
.with_fetch_canister_logs(FlagStatus::Disabled)
.with_canister_logging(FlagStatus::Disabled)
.build();
let canister_id = test.universal_canister().unwrap();
let not_a_controller = user_test_id(42);
Expand Down Expand Up @@ -3307,7 +3307,7 @@ fn test_fetch_canister_logs_should_accept_ingress_message_enabled() {
// - enable the fetch_canister_logs API
// - set the log visibility to public so any user can read the logs
let mut test = ExecutionTestBuilder::new()
.with_fetch_canister_logs(FlagStatus::Enabled)
.with_canister_logging(FlagStatus::Enabled)
.build();
let canister_id = test.universal_canister().unwrap();
let not_a_controller = user_test_id(42);
Expand Down
2 changes: 1 addition & 1 deletion rs/execution_environment/src/hypervisor.rs
Expand Up @@ -234,7 +234,7 @@ impl Hypervisor {
let mut embedder_config = config.embedders_config.clone();
embedder_config.subnet_type = own_subnet_type;
embedder_config.dirty_page_overhead = dirty_page_overhead;
embedder_config.feature_flags.canister_logging = config.fetch_canister_logs;
embedder_config.feature_flags.canister_logging = config.canister_logging;

let wasm_executor: Arc<dyn WasmExecutor> = match config.canister_sandboxing_flag {
FlagStatus::Enabled => {
Expand Down
2 changes: 1 addition & 1 deletion rs/execution_environment/src/query_handler.rs
Expand Up @@ -240,7 +240,7 @@ impl QueryHandler for InternalHttpQueryHandler {
BitcoinGetBalanceArgs::decode(&query.method_payload)?.network
}
Ok(QueryMethod::FetchCanisterLogs) => {
return match self.config.fetch_canister_logs {
return match self.config.canister_logging {
FlagStatus::Enabled => fetch_canister_logs(
query.source.get(),
state.get_ref(),
Expand Down
4 changes: 2 additions & 2 deletions rs/execution_environment/tests/fetch_canister_logs.rs
Expand Up @@ -14,12 +14,12 @@ use ic_test_utilities::universal_canister::UNIVERSAL_CANISTER_WASM;
use ic_test_utilities_execution_environment::get_reply;
use ic_types::{CanisterId, Cycles};

fn setup(fetch_canister_logs: FlagStatus) -> (StateMachine, CanisterId) {
fn setup(canister_logging: FlagStatus) -> (StateMachine, CanisterId) {
let subnet_type = SubnetType::Application;
let config = StateMachineConfig::new(
SubnetConfig::new(subnet_type),
ExecutionConfig {
fetch_canister_logs,
canister_logging,
..ExecutionConfig::default()
},
);
Expand Down
4 changes: 2 additions & 2 deletions rs/test_utilities/execution_environment/src/lib.rs
Expand Up @@ -1933,8 +1933,8 @@ impl ExecutionTestBuilder {
self
}

pub fn with_fetch_canister_logs(mut self, status: FlagStatus) -> Self {
self.execution_config.fetch_canister_logs = status;
pub fn with_canister_logging(mut self, status: FlagStatus) -> Self {
self.execution_config.canister_logging = status;
self
}

Expand Down

0 comments on commit 051a5b1

Please sign in to comment.