Skip to content

Commit

Permalink
feat: [IC-272] add fetch_canister_logs stub to the management caniste…
Browse files Browse the repository at this point in the history
…r API
  • Loading branch information
maksymar committed Jan 25, 2024
1 parent c2a2729 commit c49d406
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 2 deletions.
6 changes: 6 additions & 0 deletions rs/execution_environment/src/canister_manager.rs
Expand Up @@ -531,6 +531,12 @@ impl CanisterManager {
}
},

// TODO(IC-272).
Ok(Ic00Method::FetchCanisterLogs) => Err(UserError::new(
ErrorCode::CanisterRejectedMessage,
format!("{} API is not yet implemented", Ic00Method::FetchCanisterLogs)
)),

Ok(Ic00Method::ProvisionalCreateCanisterWithCycles)
| Ok(Ic00Method::BitcoinGetSuccessors)
| Ok(Ic00Method::ProvisionalTopUpCanister) => {
Expand Down
16 changes: 14 additions & 2 deletions rs/execution_environment/src/execution_environment.rs
Expand Up @@ -1086,6 +1086,14 @@ impl ExecutionEnvironment {
Some((res, msg.take_cycles()))
}

Ok(Ic00Method::DeleteChunks) | Ok(Ic00Method::InstallChunkedCode) => Some((
Err(UserError::new(
ErrorCode::CanisterRejectedMessage,
"Chunked upload API is not yet implemented.",
)),
msg.take_cycles(),
)),

Ok(Ic00Method::NodeMetricsHistory) => {
let res = match NodeMetricsHistoryArgs::decode(payload) {
Err(err) => Err(err),
Expand All @@ -1094,10 +1102,14 @@ impl ExecutionEnvironment {
Some((res, msg.take_cycles()))
}

Ok(Ic00Method::DeleteChunks) | Ok(Ic00Method::InstallChunkedCode) => Some((
Ok(Ic00Method::FetchCanisterLogs) => Some((
// TODO(IC-272).
Err(UserError::new(
ErrorCode::CanisterRejectedMessage,
"Chunked upload API is not yet implemented.",
format!(
"{} API is not yet implemented.",
Ic00Method::FetchCanisterLogs
),
)),
msg.take_cycles(),
)),
Expand Down
5 changes: 5 additions & 0 deletions rs/execution_environment/src/ic00_permissions.rs
Expand Up @@ -138,6 +138,11 @@ impl Ic00MethodPermissions {
allow_remote_subnet_sender: true,
allow_only_nns_subnet_sender: false,
},
Ic00Method::FetchCanisterLogs => Self {
method,
allow_remote_subnet_sender: false, // Only users can call this method, not canisters (also no nested composite query calls).
allow_only_nns_subnet_sender: false,
},
Ic00Method::ProvisionalCreateCanisterWithCycles => Self {
method,
allow_remote_subnet_sender: true,
Expand Down
1 change: 1 addition & 0 deletions rs/execution_environment/src/scheduler.rs
Expand Up @@ -2338,6 +2338,7 @@ fn get_instructions_limits_for_subnet_message(
| BitcoinGetCurrentFeePercentiles
| BitcoinGetSuccessors
| NodeMetricsHistory
| FetchCanisterLogs
| ProvisionalCreateCanisterWithCycles
| ProvisionalTopUpCanister
| UploadChunk
Expand Down
10 changes: 10 additions & 0 deletions rs/system_api/src/routing.rs
Expand Up @@ -177,6 +177,16 @@ pub(super) fn resolve_destination(
Ok(Ic00Method::NodeMetricsHistory) => {
Ok(NodeMetricsHistoryArgs::decode(payload)?.subnet_id)
}
Ok(Ic00Method::FetchCanisterLogs) => {
// TODO(IC-272).
Err(ResolveDestinationError::UserError(UserError::new(
ic_error_types::ErrorCode::CanisterRejectedMessage,
format!(
"{} API is not yet implemented",
Ic00Method::FetchCanisterLogs
),
)))
}
Ok(Ic00Method::ECDSAPublicKey) => {
let key_id = ECDSAPublicKeyArgs::decode(payload)?.key_id;
route_ecdsa_message(
Expand Down
1 change: 1 addition & 0 deletions rs/system_api/src/sandbox_safe_system_state.rs
Expand Up @@ -243,6 +243,7 @@ impl SystemStateChanges {
| Ok(Ic00Method::BitcoinSendTransaction)
| Ok(Ic00Method::BitcoinGetCurrentFeePercentiles)
| Ok(Ic00Method::NodeMetricsHistory)
| Ok(Ic00Method::FetchCanisterLogs)
| Ok(Ic00Method::UploadChunk)
| Ok(Ic00Method::StoredChunks)
| Ok(Ic00Method::DeleteChunks)
Expand Down
2 changes: 2 additions & 0 deletions rs/types/ic00_types/src/lib.rs
Expand Up @@ -77,6 +77,8 @@ pub enum Method {

NodeMetricsHistory,

FetchCanisterLogs,

// These methods are only available on test IC instances where there is a
// need to fabricate cycles without burning ICP first.
ProvisionalCreateCanisterWithCycles,
Expand Down
1 change: 1 addition & 0 deletions rs/types/types/src/messages/ingress_messages.rs
Expand Up @@ -511,6 +511,7 @@ pub fn extract_effective_canister_id(
Ok(record) => Ok(Some(record.get_canister_id())),
Err(err) => Err(ParseIngressError::InvalidSubnetPayload(err.to_string())),
},
Ok(Method::FetchCanisterLogs) => Err(ParseIngressError::UnknownSubnetMethod), // TODO(IC-272).
Ok(Method::DeleteChunks)
| Ok(Method::TakeCanisterSnapshot)
| Ok(Method::LoadCanisterSnapshot)
Expand Down
1 change: 1 addition & 0 deletions rs/types/types/src/messages/inter_canister.rs
Expand Up @@ -147,6 +147,7 @@ impl Request {
Err(_) => None,
}
}
Ok(Method::FetchCanisterLogs) => None, // TODO(IC-272).
Ok(Method::UploadChunk) => match UploadChunkArgs::decode(&self.method_payload) {
Ok(record) => Some(record.get_canister_id()),
Err(_) => None,
Expand Down

0 comments on commit c49d406

Please sign in to comment.