Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,18 @@ message WasmClosure {

message Callback {
reserved 6;
reserved 8;
reserved 9;

uint64 call_context_id = 1;
WasmClosure on_reply = 2;
WasmClosure on_reject = 3;
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;
}
Expand Down Expand Up @@ -212,6 +210,7 @@ message ExecutionTask {

message AbortedExecution {
reserved 2;
reserved 4;

message AbortedResponse {
state.queues.v1.Response response = 7;
Expand All @@ -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;
}

Expand Down
19 changes: 0 additions & 19 deletions rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,12 @@ pub struct Callback {
pub cycles_sent: ::core::option::Option<super::super::queues::v1::Cycles>,
#[prost(message, optional, tag = "7")]
pub respondent: ::core::option::Option<super::super::super::types::v1::CanisterId>,
#[prost(message, optional, tag = "8")]
pub prepayment_for_response_execution: ::core::option::Option<super::super::queues::v1::Cycles>,
#[prost(message, optional, tag = "9")]
pub prepayment_for_response_transmission:
::core::option::Option<super::super::queues::v1::Cycles>,
/// 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<super::super::queues::v1::CompoundCycles>,
/// To replace `prepayment_for_response_transmission`.
#[prost(message, optional, tag = "12")]
pub prepayment_for_response_transmission_compound:
::core::option::Option<super::super::queues::v1::CompoundCycles>,
Expand Down Expand Up @@ -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<super::super::super::queues::v1::Cycles>,
/// 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<super::super::super::queues::v1::CompoundCycles>,
Expand Down Expand Up @@ -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<super::super::super::queues::v1::Cycles>,
#[prost(uint64, optional, tag = "4")]
pub call_id: ::core::option::Option<u64>,
/// 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<super::super::super::queues::v1::CompoundCycles>,
Expand Down
41 changes: 8 additions & 33 deletions rs/replicated_state/src/canister_state/system_state/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Comment thread
dsarlis marked this conversation as resolved.
*prepaid_execution_cycles,
)),
Expand All @@ -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,
)),
Expand All @@ -146,14 +139,6 @@ impl TryFrom<pb::ExecutionTask> 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::{
Expand Down Expand Up @@ -193,15 +178,10 @@ impl TryFrom<pb::ExecutionTask> 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::<Instructions>::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,
Expand All @@ -216,15 +196,10 @@ impl TryFrom<pb::ExecutionTask> 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::<Instructions>::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",
))?;
Expand Down
61 changes: 13 additions & 48 deletions rs/types/types/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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(),
),
Expand Down Expand Up @@ -374,44 +365,18 @@ impl TryFrom<pb::Callback> 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.
Comment thread
mraszyk marked this conversation as resolved.
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),
Expand Down
Loading