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 e678611ff862..7bc6fe70c885 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 @@ -64,6 +64,8 @@ message WasmClosure { message Callback { reserved 6; + reserved 8; + reserved 9; uint64 call_context_id = 1; WasmClosure on_reply = 2; @@ -71,13 +73,9 @@ message Callback { WasmClosure on_cleanup = 4; state.queues.v1.Cycles cycles_sent = 5; types.v1.CanisterId respondent = 7; - state.queues.v1.Cycles prepayment_for_response_execution = 8; - state.queues.v1.Cycles prepayment_for_response_transmission = 9; // If non-zero, this is a best-effort call. uint32 deadline_seconds = 10; - // To replace `prepayment_for_response_execution`. state.queues.v1.CompoundCycles prepayment_for_response_execution_compound = 11; - // To replace `prepayment_for_response_transmission`. state.queues.v1.CompoundCycles prepayment_for_response_transmission_compound = 12; state.queues.v1.CompoundCycles prepayment_for_call_transmission = 13; } @@ -212,6 +210,7 @@ message ExecutionTask { message AbortedExecution { reserved 2; + reserved 4; message AbortedResponse { state.queues.v1.Response response = 7; @@ -226,26 +225,20 @@ message ExecutionTask { } // The execution cost that has already been charged from the canister. // Retried execution does not have to pay for it again. - state.queues.v1.Cycles prepaid_execution_cycles = 4; - // The execution cost that has already been charged from the canister. - // Retried execution does not have to pay for it again. - // This field will replace the existing `prepaid_execution_cycles`. state.queues.v1.CompoundCycles prepaid_execution_compound_cycles = 7; } message AbortedInstallCode { + reserved 3; + oneof message { state.queues.v1.Request request = 1; ingress.v1.Ingress ingress = 2; } - // The execution cost that has already been charged from the canister. - // Retried execution does not have to pay for it again. - state.queues.v1.Cycles prepaid_execution_cycles = 3; reserved "request_id"; optional uint64 call_id = 4; // The execution cost that has already been charged from the canister. // Retried execution does not have to pay for it again. - // Will replace the existing `prepaid_execution_cycles`. state.queues.v1.CompoundCycles prepaid_execution_compound_cycles = 5; } 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 ebe4854dcc7a..937eb38379a0 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 @@ -94,19 +94,12 @@ pub struct Callback { pub cycles_sent: ::core::option::Option, #[prost(message, optional, tag = "7")] pub respondent: ::core::option::Option, - #[prost(message, optional, tag = "8")] - pub prepayment_for_response_execution: ::core::option::Option, - #[prost(message, optional, tag = "9")] - pub prepayment_for_response_transmission: - ::core::option::Option, /// If non-zero, this is a best-effort call. #[prost(uint32, tag = "10")] pub deadline_seconds: u32, - /// To replace `prepayment_for_response_execution`. #[prost(message, optional, tag = "11")] pub prepayment_for_response_execution_compound: ::core::option::Option, - /// To replace `prepayment_for_response_transmission`. #[prost(message, optional, tag = "12")] pub prepayment_for_response_transmission_compound: ::core::option::Option, @@ -324,12 +317,6 @@ pub mod execution_task { pub struct AbortedExecution { /// The execution cost that has already been charged from the canister. /// Retried execution does not have to pay for it again. - #[prost(message, optional, tag = "4")] - pub prepaid_execution_cycles: - ::core::option::Option, - /// The execution cost that has already been charged from the canister. - /// Retried execution does not have to pay for it again. - /// This field will replace the existing `prepaid_execution_cycles`. #[prost(message, optional, tag = "7")] pub prepaid_execution_compound_cycles: ::core::option::Option, @@ -359,16 +346,10 @@ pub mod execution_task { } #[derive(Clone, PartialEq, ::prost::Message)] pub struct AbortedInstallCode { - /// The execution cost that has already been charged from the canister. - /// Retried execution does not have to pay for it again. - #[prost(message, optional, tag = "3")] - pub prepaid_execution_cycles: - ::core::option::Option, #[prost(uint64, optional, tag = "4")] pub call_id: ::core::option::Option, /// The execution cost that has already been charged from the canister. /// Retried execution does not have to pay for it again. - /// Will replace the existing `prepaid_execution_cycles`. #[prost(message, optional, tag = "5")] pub prepaid_execution_compound_cycles: ::core::option::Option, diff --git a/rs/replicated_state/src/canister_state/system_state/proto.rs b/rs/replicated_state/src/canister_state/system_state/proto.rs index 5653b3db0b4c..82e3a90e388d 100644 --- a/rs/replicated_state/src/canister_state/system_state/proto.rs +++ b/rs/replicated_state/src/canister_state/system_state/proto.rs @@ -2,7 +2,6 @@ use super::*; use ic_protobuf::proxy::{ProxyDecodeError, try_from_option_field}; use ic_protobuf::state::canister_state_bits::v1 as pb; use ic_protobuf::state::queues::v1::CompoundCycles as PbCompoundCycles; -use ic_types_cycles::{CanisterCyclesCostSchedule, CompoundCycles, Instructions}; impl From<&CanisterStatus> for pb::canister_state_bits::CanisterStatus { fn from(item: &CanisterStatus) -> Self { @@ -100,9 +99,6 @@ impl From<&ExecutionTask> for pb::ExecutionTask { task: Some(pb::execution_task::Task::AbortedExecution( pb::execution_task::AbortedExecution { input: Some(input), - prepaid_execution_cycles: Some( - (prepaid_execution_cycles.real()).into(), - ), prepaid_execution_compound_cycles: Some(PbCompoundCycles::from( *prepaid_execution_cycles, )), @@ -125,9 +121,6 @@ impl From<&ExecutionTask> for pb::ExecutionTask { pb::execution_task::AbortedInstallCode { message: Some(message), call_id: Some(call_id.get()), - prepaid_execution_cycles: Some( - (prepaid_execution_cycles.real()).into(), - ), prepaid_execution_compound_cycles: Some(PbCompoundCycles::from( *prepaid_execution_cycles, )), @@ -146,14 +139,6 @@ impl TryFrom for ExecutionTask { let task = value .task .ok_or(ProxyDecodeError::MissingField("ExecutionTask::task"))?; - // cost_schedule should ideally be read from the checkpoint, however there - // is no easy access to it here (will need to be propagated from `StateManager`). - // Given that the current state is that the values for `Cycles` and `NominalCycles` - // should still match and that they should be 0 on `Free` schedule, we can use `Normal` - // without any loss (to maintain values on subnets with `Normal` schedule). - // This code will be removed anyway when the new fields are set and the old fields - // containing just `Cycles` can be retired. - let cost_schedule = CanisterCyclesCostSchedule::Normal; let task = match task { pb::execution_task::Task::AbortedExecution(aborted) => { use pb::execution_task::{ @@ -193,15 +178,10 @@ impl TryFrom for ExecutionTask { CanisterMessageOrTask::Task(task) } }; - let prepaid_execution_cycles = match aborted.prepaid_execution_compound_cycles { - Some(value) => CompoundCycles::try_from(value)?, - None => { - let prepaid_execution_cycles = aborted - .prepaid_execution_cycles - .map_or_else(Cycles::zero, |c| c.into()); - CompoundCycles::::new(prepaid_execution_cycles, cost_schedule) - } - }; + let prepaid_execution_cycles = try_from_option_field( + aborted.prepaid_execution_compound_cycles, + "AbortedExecution::prepaid_execution_compound_cycles", + )?; ExecutionTask::AbortedExecution { input, prepaid_execution_cycles, @@ -216,15 +196,10 @@ impl TryFrom for ExecutionTask { Message::Request(v) => CanisterCall::Request(Arc::new(v.try_into()?)), Message::Ingress(v) => CanisterCall::Ingress(Arc::new(v.try_into()?)), }; - let prepaid_execution_cycles = match aborted.prepaid_execution_compound_cycles { - Some(value) => CompoundCycles::try_from(value)?, - None => { - let prepaid_execution_cycles = aborted - .prepaid_execution_cycles - .map_or_else(Cycles::zero, |c| c.into()); - CompoundCycles::::new(prepaid_execution_cycles, cost_schedule) - } - }; + let prepaid_execution_cycles = try_from_option_field( + aborted.prepaid_execution_compound_cycles, + "AbortedExecution::prepaid_execution_compound_cycles", + )?; let call_id = aborted.call_id.ok_or(ProxyDecodeError::MissingField( "AbortedInstallCode::call_id", ))?; diff --git a/rs/types/types/src/methods.rs b/rs/types/types/src/methods.rs index 7c0fd1873996..4cb2f8e821c0 100644 --- a/rs/types/types/src/methods.rs +++ b/rs/types/types/src/methods.rs @@ -9,10 +9,7 @@ use ic_heap_bytes::DeterministicHeapBytes; use ic_protobuf::proxy::{ProxyDecodeError, try_from_option_field}; use ic_protobuf::state::{canister_state_bits::v1 as pb, queues::v1::Cycles as PbCycles}; use ic_protobuf::types::v1 as pb_types; -use ic_types_cycles::{ - CanisterCyclesCostSchedule, CompoundCycles, Cycles, Instructions, - RequestAndResponseTransmission, -}; +use ic_types_cycles::{CompoundCycles, Cycles, Instructions, RequestAndResponseTransmission}; use serde::{Deserialize, Serialize}; use std::{ convert::{From, TryFrom}, @@ -333,12 +330,6 @@ impl From<&Callback> for pb::Callback { call_context_id: item.call_context_id.get(), respondent: Some(pb_types::CanisterId::from(item.respondent)), cycles_sent: Some(item.cycles_sent.into()), - prepayment_for_response_execution: Some( - item.prepayment_for_response_execution.real().into(), - ), - prepayment_for_response_transmission: Some( - item.prepayment_for_response_transmission.real().into(), - ), prepayment_for_response_execution_compound: Some( item.prepayment_for_response_execution.into(), ), @@ -374,44 +365,18 @@ impl TryFrom for Callback { let cycles_sent: PbCycles = try_from_option_field(value.cycles_sent, "Callback::cycles_sent")?; - // cost_schedule should ideally be read from the checkpoint, however there - // is no easy access to it here (will need to be propagated from `StateManager`). - // Given that the current state is that the values for `Cycles` and `NominalCycles` - // should still match and that they should be 0 on `Free` schedule, we can use `Normal` - // without any loss (to maintain values on subnets with `Normal` schedule). - // This code will be removed anyway when the new fields are set and the old fields - // containing just `Cycles` can be retired. - let cost_schedule = CanisterCyclesCostSchedule::Normal; - let prepayment_for_response_execution = - match value.prepayment_for_response_execution_compound { - Some(value) => CompoundCycles::try_from(value)?, - None => CompoundCycles::new( - try_from_option_field( - value.prepayment_for_response_execution, - "Callback::prepayment_for_response_execution", - )?, - cost_schedule, - ), - }; - let prepayment_for_response_transmission = - match value.prepayment_for_response_transmission_compound { - Some(value) => CompoundCycles::try_from(value)?, - None => CompoundCycles::new( - try_from_option_field( - value.prepayment_for_response_transmission, - "Callback::prepayment_for_response_transmission", - )?, - cost_schedule, - ), - }; - let prepayment_for_call_transmission = match value.prepayment_for_call_transmission { - Some(value) => CompoundCycles::try_from(value)?, - // Temporary code until the change is deployed and the field starts - // being populated in checkpoints. If no "old" callbacks exist, - // this can be changed to fail on `None` instead and always - // expect to find some value. - None => CompoundCycles::new(Cycles::zero(), cost_schedule), - }; + let prepayment_for_response_execution = try_from_option_field( + value.prepayment_for_response_execution_compound, + "Callback::prepayment_for_response_execution", + )?; + let prepayment_for_response_transmission = try_from_option_field( + value.prepayment_for_response_transmission_compound, + "Callback::prepayment_for_response_transmission", + )?; + let prepayment_for_call_transmission = try_from_option_field( + value.prepayment_for_call_transmission, + "Callback::prepayment_for_call_transmission", + )?; Ok(Self { call_context_id: CallContextId::from(value.call_context_id),