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
3 changes: 3 additions & 0 deletions rs/execution_environment/src/execution_environment/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1988,6 +1988,7 @@ fn http_request_bound_holds() {
context: transform_context.clone(),
}),
is_replicated: None,
pricing_version: None,
};

// Create request to HTTP_REQUEST method.
Expand Down Expand Up @@ -2769,6 +2770,7 @@ fn execute_canister_http_request() {
context: transform_context.clone(),
}),
is_replicated: None,
pricing_version: None,
};

// Create request to HTTP_REQUEST method.
Expand Down Expand Up @@ -2849,6 +2851,7 @@ fn execute_canister_http_request_disabled() {
context: vec![0, 1, 2],
}),
is_replicated: None,
pricing_version: None,
};

// Create request to HTTP_REQUEST method.
Expand Down
3 changes: 3 additions & 0 deletions rs/execution_environment/src/scheduler/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3042,6 +3042,7 @@ fn canister_is_stopped_if_timeout_occurs_and_ready_to_stop() {
transform: None,
max_response_bytes: None,
is_replicated: None,
pricing_version: None,
})
.unwrap();

Expand Down Expand Up @@ -4115,6 +4116,7 @@ fn consumed_cycles_http_outcalls_are_added_to_consumed_cycles_total() {
context: transform_context,
}),
is_replicated: None,
pricing_version: None,
};

// Create request to `HttpRequest` method.
Expand Down Expand Up @@ -4204,6 +4206,7 @@ fn http_outcalls_free() {
context: transform_context,
}),
is_replicated: None,
pricing_version: None,
};

// Create request to `HttpRequest` method.
Expand Down
1 change: 1 addition & 0 deletions rs/execution_environment/tests/subnet_size_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ fn simulate_http_request_cost(subnet_type: SubnetType, subnet_size: usize) -> Cy
context: vec![],
}),
is_replicated: None,
pricing_version: None,
})
.unwrap(),
),
Expand Down
27 changes: 25 additions & 2 deletions rs/https_outcalls/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ic_https_outcalls_service::{
};
use ic_interfaces::execution_environment::{QueryExecutionInput, QueryExecutionService};
use ic_interfaces_adapter_client::{NonBlockingChannel, SendError, TryReceiveError};
use ic_logger::{ReplicaLogger, info};
use ic_logger::{ReplicaLogger, info, warn};
use ic_management_canister_types_private::{CanisterHttpResponsePayload, TransformArgs};
use ic_metrics::MetricsRegistry;
use ic_nns_delegation_manager::{CanisterRangesFilter, NNSDelegationReader};
Expand Down Expand Up @@ -146,11 +146,33 @@ impl NonBlockingChannel<CanisterHttpRequest> for CanisterHttpAdapterClientImpl {
http_method: request_http_method,
max_response_bytes: request_max_response_bytes,
transform: request_transform,
pricing_version: request_pricing_version,
..
},
socks_proxy_addrs,
} = canister_http_request;

if request_pricing_version == ic_types::canister_http::PricingVersion::PayAsYouGo {
warn!(
log,
"Canister HTTP request with PayAsYouGo pricing is not supported yet: request_id {}, sender {}, process_id: {}",
request_id,
request_sender,
std::process::id(),
);
let _ = permit.send(CanisterHttpResponse {
id: request_id,
timeout: request_timeout,
canister_id: request_sender,
content: CanisterHttpResponseContent::Reject(CanisterHttpReject {
reject_code: RejectCode::SysFatal,
message: "Canister HTTP request with PayAsYouGo pricing is not supported"
.to_string(),
}),
});
return;
}

let adapter_req_timer = Instant::now();
let max_response_size_bytes = request_max_response_bytes
.unwrap_or(NumBytes::new(MAX_CANISTER_HTTP_RESPONSE_BYTES))
Expand Down Expand Up @@ -396,7 +418,7 @@ mod tests {
use ic_interfaces::execution_environment::{QueryExecutionError, QueryExecutionResponse};
use ic_logger::replica_logger::no_op_logger;
use ic_test_utilities_types::messages::RequestBuilder;
use ic_types::canister_http::{Replication, Transform};
use ic_types::canister_http::{PricingVersion, Replication, Transform};
use ic_types::{
Time, canister_http::CanisterHttpMethod, messages::CallbackId, time::UNIX_EPOCH,
time::current_time,
Expand Down Expand Up @@ -489,6 +511,7 @@ mod tests {
}),
time: UNIX_EPOCH,
replication: Replication::FullyReplicated,
pricing_version: PricingVersion::Legacy,
},
socks_proxy_addrs: vec![],
}
Expand Down
9 changes: 9 additions & 0 deletions rs/https_outcalls/consensus/src/payload_builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ fn timeout_priority() {
// this is the important one
time: UNIX_EPOCH,
replication: ic_types::canister_http::Replication::FullyReplicated,
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};
init_state
.metadata
Expand Down Expand Up @@ -849,6 +850,7 @@ fn non_replicated_request_response_coming_in_gossip_payload_created() {
transform: None,
time: UNIX_EPOCH,
replication: ic_types::canister_http::Replication::NonReplicated(delegated_node_id),
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};

// Insert the context in the replicated state
Expand Down Expand Up @@ -952,6 +954,7 @@ fn non_replicated_request_with_extra_share_includes_only_delegated_share() {
transform: None,
time: UNIX_EPOCH,
replication: ic_types::canister_http::Replication::NonReplicated(delegated_node_id),
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};

// Insert the context in the replicated state
Expand Down Expand Up @@ -1056,6 +1059,7 @@ fn non_replicated_share_is_ignored_if_content_is_missing() {
transform: None,
time: UNIX_EPOCH,
replication: ic_types::canister_http::Replication::NonReplicated(delegated_node_id),
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};

let mut init_state = ic_test_utilities_state::get_initial_state(0, 0);
Expand Down Expand Up @@ -1134,6 +1138,7 @@ fn validate_payload_succeeds_for_valid_non_replicated_response() {
transform: None,
time: UNIX_EPOCH,
replication: ic_types::canister_http::Replication::NonReplicated(delegated_node_id),
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};

// Inject this context into the state reader used by the validator.
Expand Down Expand Up @@ -1200,6 +1205,7 @@ fn validate_payload_fails_for_non_replicated_response_with_wrong_signer() {
transform: None,
time: UNIX_EPOCH,
replication: ic_types::canister_http::Replication::NonReplicated(delegated_node_id),
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};

// Inject this context into the state reader.
Expand Down Expand Up @@ -1282,6 +1288,7 @@ fn validate_payload_fails_for_response_with_no_signatures() {
transform: None,
time: UNIX_EPOCH,
replication: ic_types::canister_http::Replication::NonReplicated(delegated_node_id),
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};

// Inject this context into the state reader used by the validator.
Expand Down Expand Up @@ -1369,6 +1376,7 @@ fn validate_payload_fails_when_non_replicated_proof_is_for_fully_replicated_requ
time: UNIX_EPOCH,
// The state says the request is replicated.
replication: ic_types::canister_http::Replication::FullyReplicated,
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};

// Inject this context into the state reader.
Expand Down Expand Up @@ -1461,6 +1469,7 @@ fn validate_payload_fails_for_duplicate_non_replicated_response() {
transform: None,
time: UNIX_EPOCH,
replication: ic_types::canister_http::Replication::NonReplicated(delegated_node_id),
pricing_version: ic_types::canister_http::PricingVersion::Legacy,
};

// 2. Inject this context into the state reader
Expand Down
15 changes: 15 additions & 0 deletions rs/https_outcalls/consensus/src/pool_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::FullyReplicated,
pricing_version: PricingVersion::Legacy,
};

state_manager
Expand Down Expand Up @@ -854,6 +855,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::FullyReplicated,
pricing_version: PricingVersion::Legacy,
};

// NOTE: We need at least some context in the state, otherwise next_callback_id will be 0 and no
Expand Down Expand Up @@ -967,6 +969,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::FullyReplicated,
pricing_version: PricingVersion::Legacy,
};

state_manager
Expand Down Expand Up @@ -1099,6 +1102,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};

state_manager
Expand Down Expand Up @@ -1237,6 +1241,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};
state_manager
.get_mut()
Expand Down Expand Up @@ -1340,6 +1345,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::FullyReplicated,
pricing_version: PricingVersion::Legacy,
};

state_manager
Expand Down Expand Up @@ -1452,6 +1458,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};

state_manager
Expand Down Expand Up @@ -1633,6 +1640,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};

state_manager
Expand Down Expand Up @@ -1744,6 +1752,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};
state_manager
.get_mut()
Expand Down Expand Up @@ -1867,6 +1876,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};
state_manager
.get_mut()
Expand Down Expand Up @@ -1998,6 +2008,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};
state_manager
.get_mut()
Expand Down Expand Up @@ -2120,6 +2131,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};

state_manager
Expand Down Expand Up @@ -2236,6 +2248,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::FullyReplicated,
pricing_version: PricingVersion::Legacy,
};

state_manager
Expand Down Expand Up @@ -2384,6 +2397,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::NonReplicated(delegated_node_id),
pricing_version: PricingVersion::Legacy,
};
state_manager
.get_mut()
Expand Down Expand Up @@ -2482,6 +2496,7 @@ pub mod test {
transform: None,
time: ic_types::Time::from_nanos_since_unix_epoch(10),
replication: Replication::FullyReplicated,
pricing_version: PricingVersion::Legacy,
};

// Expect times to be called exactly once to check that already
Expand Down
8 changes: 8 additions & 0 deletions rs/protobuf/def/state/metadata/v1/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,17 @@ message CanisterHttpRequestContext {
optional uint64 max_response_bytes = 9;
google.protobuf.BytesValue transform_context = 10;
optional Replication replication = 11;
optional PricingVersion pricing_version = 12;
reserved 5;
}

message PricingVersion {
oneof version {
google.protobuf.Empty legacy = 1;
google.protobuf.Empty pay_as_you_go = 2;
}
}

message Replication {
oneof replication_type {
google.protobuf.Empty fully_replicated = 1;
Expand Down
17 changes: 17 additions & 0 deletions rs/protobuf/src/gen/state/state.metadata.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,23 @@ pub struct CanisterHttpRequestContext {
pub transform_context: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
#[prost(message, optional, tag = "11")]
pub replication: ::core::option::Option<Replication>,
#[prost(message, optional, tag = "12")]
pub pricing_version: ::core::option::Option<PricingVersion>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PricingVersion {
#[prost(oneof = "pricing_version::Version", tags = "1, 2")]
pub version: ::core::option::Option<pricing_version::Version>,
}
/// Nested message and enum types in `PricingVersion`.
pub mod pricing_version {
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum Version {
#[prost(message, tag = "1")]
Legacy(()),
#[prost(message, tag = "2")]
PayAsYouGo(()),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Replication {
Expand Down
3 changes: 2 additions & 1 deletion rs/replicated_state/src/metadata_state/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use ic_test_utilities_types::{
use ic_types::{
Cycles, ExecutionRound, Height,
batch::BlockmakerMetrics,
canister_http::{CanisterHttpMethod, CanisterHttpRequestContext, Replication},
canister_http::{CanisterHttpMethod, CanisterHttpRequestContext, PricingVersion, Replication},
consensus::idkg::{IDkgMasterPublicKeyId, PreSigId, common::PreSignature},
crypto::{
AlgorithmId,
Expand Down Expand Up @@ -603,6 +603,7 @@ fn subnet_call_contexts_deserialization() {
transform: Some(transform.clone()),
time: UNIX_EPOCH,
replication: Replication::FullyReplicated,
pricing_version: PricingVersion::Legacy,
};
subnet_call_context_manager.push_context(SubnetCallContext::CanisterHttpRequest(
canister_http_request,
Expand Down
4 changes: 3 additions & 1 deletion rs/rust_canisters/proxy_canister/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct UnvalidatedCanisterHttpRequestArgs {
pub method: HttpMethod,
pub transform: Option<TransformContext>,
pub is_replicated: Option<bool>,
pub pricing_version: Option<u32>,
}
impl Payload<'_> for UnvalidatedCanisterHttpRequestArgs {}

Expand All @@ -53,7 +54,8 @@ impl From<UnvalidatedCanisterHttpRequestArgs>
body: args.body,
method: args.method,
transform: args.transform,
is_replicated: None,
is_replicated: args.is_replicated,
pricing_version: args.pricing_version,
}
}
}
Expand Down
Loading
Loading