Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Weigelt committed Oct 23, 2024
1 parent 56cedb2 commit 3fc8484
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion rs/execution_environment/src/canister_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ impl CanisterManager {
| Ok(Ic00Method::BitcoinSendTransactionInternal)
| Ok(Ic00Method::BitcoinGetCurrentFeePercentiles)
| Ok(Ic00Method::NodeMetricsHistory)
| Ok(Ic00Method::SubnetStats) => Err(UserError::new(
| Ok(Ic00Method::SubnetMetrics) => Err(UserError::new(
ErrorCode::CanisterRejectedMessage,
format!("Only canisters can call ic00 method {}", method_name),
)),
Expand Down
17 changes: 9 additions & 8 deletions rs/execution_environment/src/execution_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use ic_management_canister_types::{
LoadCanisterSnapshotArgs, MasterPublicKeyId, Method as Ic00Method, NodeMetricsHistoryArgs,
Payload as Ic00Payload, ProvisionalCreateCanisterWithCyclesArgs, ProvisionalTopUpCanisterArgs,
SchnorrPublicKeyArgs, SchnorrPublicKeyResponse, SetupInitialDKGArgs, SignWithECDSAArgs,
SignWithSchnorrArgs, StoredChunksArgs, SubnetStatsArgs, SubnetStatsResponse,
SignWithSchnorrArgs, StoredChunksArgs, SubnetMetricsArgs, SubnetMetricsResponse,
TakeCanisterSnapshotArgs, UninstallCodeArgs, UpdateSettingsArgs, UploadChunkArgs, IC_00,
};
use ic_metrics::MetricsRegistry;
Expand Down Expand Up @@ -1378,9 +1378,9 @@ impl ExecutionEnvironment {
}
}

Ok(Ic00Method::SubnetStats) => {
let res = SubnetStatsArgs::decode(payload)
.and_then(|args| self.subnet_stats(&state, args));
Ok(Ic00Method::SubnetMetrics) => {
let res = SubnetMetricsArgs::decode(payload)
.and_then(|args| self.subnet_stats(&registry_settings, args));
ExecuteSubnetMessageResult::Finished {
response: res,
refund: msg.take_cycles(),
Expand Down Expand Up @@ -2236,8 +2236,8 @@ impl ExecutionEnvironment {

fn subnet_stats(
&self,
state: &ReplicatedState,
args: SubnetStatsArgs,
registry_settings: &RegistryExecutionSettings,
args: SubnetMetricsArgs,
) -> Result<Vec<u8>, UserError> {
// TODO: Check taken from node_metric_history; but is this actually needed? Can such a call be routed wrong?
if args.subnet_id != self.own_subnet_id.get() {
Expand All @@ -2249,8 +2249,9 @@ impl ExecutionEnvironment {
),
));
}
let replica_version = String::from(state.metadata.replica_version.clone());
let res = SubnetStatsResponse { replica_version };
let res = SubnetMetricsResponse {
replica_version: registry_settings.replica_version.clone(),
};
Ok(Encode!(&res).unwrap())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl ExecutionEnvironmentMetrics {
| ic00::Method::BitcoinSendTransaction
| ic00::Method::BitcoinGetCurrentFeePercentiles
| ic00::Method::NodeMetricsHistory
| ic00::Method::SubnetStats
| ic00::Method::SubnetMetrics
| ic00::Method::FetchCanisterLogs
| ic00::Method::ProvisionalCreateCanisterWithCycles
| ic00::Method::ProvisionalTopUpCanister
Expand Down
2 changes: 1 addition & 1 deletion rs/execution_environment/src/ic00_permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl Ic00MethodPermissions {
allow_remote_subnet_sender: true,
allow_only_nns_subnet_sender: false,
},
Ic00Method::SubnetStats => Self {
Ic00Method::SubnetMetrics => Self {
method,
allow_remote_subnet_sender: true,
allow_only_nns_subnet_sender: false,
Expand Down
4 changes: 2 additions & 2 deletions rs/execution_environment/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,7 @@ fn can_execute_subnet_msg(
| Ic00Method::BitcoinSendTransactionInternal
| Ic00Method::BitcoinGetSuccessors
| Ic00Method::NodeMetricsHistory
| Ic00Method::SubnetStats
| Ic00Method::SubnetMetrics
| Ic00Method::FetchCanisterLogs
| Ic00Method::ProvisionalCreateCanisterWithCycles
| Ic00Method::ProvisionalTopUpCanister
Expand Down Expand Up @@ -2467,7 +2467,7 @@ fn get_instructions_limits_for_subnet_message(
| BitcoinGetCurrentFeePercentiles
| BitcoinGetSuccessors
| NodeMetricsHistory
| SubnetStats
| SubnetMetrics
| FetchCanisterLogs
| ProvisionalCreateCanisterWithCycles
| ProvisionalTopUpCanister
Expand Down
2 changes: 1 addition & 1 deletion rs/execution_environment/tests/dts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ fn dts_aborted_execution_does_not_block_subnet_messages() {
| Method::BitcoinSendTransactionInternal
| Method::BitcoinGetSuccessors
| Method::NodeMetricsHistory
| Method::SubnetStats
| Method::SubnetMetrics
| Method::ProvisionalCreateCanisterWithCycles
| Method::ProvisionalTopUpCanister => {}
// Unsupported methods accepting just one argument.
Expand Down
4 changes: 2 additions & 2 deletions rs/system_api/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ic_management_canister_types::{
ECDSAPublicKeyArgs, InstallChunkedCodeArgs, InstallCodeArgsV2, ListCanisterSnapshotArgs,
LoadCanisterSnapshotArgs, MasterPublicKeyId, Method as Ic00Method, NodeMetricsHistoryArgs,
Payload, ProvisionalTopUpCanisterArgs, SchnorrPublicKeyArgs, SignWithECDSAArgs,
SignWithSchnorrArgs, StoredChunksArgs, SubnetStatsArgs, TakeCanisterSnapshotArgs,
SignWithSchnorrArgs, StoredChunksArgs, SubnetMetricsArgs, TakeCanisterSnapshotArgs,
UninstallCodeArgs, UpdateSettingsArgs, UploadChunkArgs,
};
use ic_replicated_state::NetworkTopology;
Expand Down Expand Up @@ -168,7 +168,7 @@ pub(super) fn resolve_destination(
Ok(Ic00Method::NodeMetricsHistory) => {
Ok(NodeMetricsHistoryArgs::decode(payload)?.subnet_id)
}
Ok(Ic00Method::SubnetStats) => Ok(SubnetStatsArgs::decode(payload)?.subnet_id),
Ok(Ic00Method::SubnetMetrics) => Ok(SubnetMetricsArgs::decode(payload)?.subnet_id),
Ok(Ic00Method::FetchCanisterLogs) => {
Err(ResolveDestinationError::UserError(UserError::new(
ic_error_types::ErrorCode::CanisterRejectedMessage,
Expand Down
2 changes: 1 addition & 1 deletion rs/system_api/src/sandbox_safe_system_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl SystemStateChanges {
| Ok(Ic00Method::BitcoinSendTransaction)
| Ok(Ic00Method::BitcoinGetCurrentFeePercentiles)
| Ok(Ic00Method::NodeMetricsHistory)
| Ok(Ic00Method::SubnetStats)
| Ok(Ic00Method::SubnetMetrics)
| Ok(Ic00Method::FetchCanisterLogs)
| Ok(Ic00Method::UploadChunk)
| Ok(Ic00Method::StoredChunks)
Expand Down
14 changes: 7 additions & 7 deletions rs/types/management_canister_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub enum Method {

// Subnet information
NodeMetricsHistory,
SubnetStats,
SubnetMetrics,

FetchCanisterLogs,

Expand Down Expand Up @@ -2588,31 +2588,31 @@ pub enum QueryMethod {
FetchCanisterLogs,
}

/// `CandidType` for `SubnetStatsArgs`
/// `CandidType` for `SubnetMetricsArgs`
/// ```text
/// record {
/// subnet_id: principal;
/// }
/// ```
#[derive(Clone, Debug, Default, CandidType, Deserialize)]
pub struct SubnetStatsArgs {
pub struct SubnetMetricsArgs {
pub subnet_id: PrincipalId,
}

impl Payload<'_> for SubnetStatsArgs {}
impl Payload<'_> for SubnetMetricsArgs {}

/// `CandidType` for `SubnetStatsResponse`
/// `CandidType` for `SubnetMetricsResponse`
/// ```text
/// record {
/// replica_version: text;
/// }
/// ```
#[derive(Clone, Debug, Default, CandidType, Deserialize)]
pub struct SubnetStatsResponse {
pub struct SubnetMetricsResponse {
pub replica_version: String,
}

impl Payload<'_> for SubnetStatsResponse {}
impl Payload<'_> for SubnetMetricsResponse {}

/// `CandidType` for `NodeMetricsHistoryArgs`
/// ```text
Expand Down
2 changes: 1 addition & 1 deletion rs/types/types/src/messages/ingress_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ pub fn extract_effective_canister_id(
| Ok(Method::BitcoinGetSuccessors)
| Ok(Method::BitcoinGetCurrentFeePercentiles)
| Ok(Method::NodeMetricsHistory)
| Ok(Method::SubnetStats)
| Ok(Method::SubnetMetrics)
| Ok(Method::FetchCanisterLogs) => {
// Subnet method not allowed for ingress.
Err(ParseIngressError::SubnetMethodNotAllowed)
Expand Down
2 changes: 1 addition & 1 deletion rs/types/types/src/messages/inter_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl Request {
| Ok(Method::BitcoinGetSuccessors)
| Ok(Method::BitcoinGetCurrentFeePercentiles)
| Ok(Method::NodeMetricsHistory)
| Ok(Method::SubnetStats) => {
| Ok(Method::SubnetMetrics) => {
// No effective canister id.
None
}
Expand Down

0 comments on commit 3fc8484

Please sign in to comment.