Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(PocketIC): remove deprecated endpoint execute_ingress_message #3361

Merged
merged 1 commit into from
Jan 9, 2025
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
5 changes: 5 additions & 0 deletions rs/pocket_ic_server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Canisters created via `provisional_create_canister_with_cycles` with the management canister ID as the effective canister ID
are created on an arbitrary subnet.

### Removed
- The endpoint `/instances/<instance_id>/update/execute_ingress_message`:
use the two endpoints `/instances/<instance_id>/update/submit_ingress_message` and `/instances/<instance_id>/update/await_ingress_message`
to submit and then await an ingress message instead.



## 7.0.0 - 2024-11-13
Expand Down
65 changes: 0 additions & 65 deletions rs/pocket_ic_server/src/pocket_ic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1645,71 +1645,6 @@ impl Operation for AwaitIngressMessage {
}
}

#[derive(Clone, Debug)]
pub struct ExecuteIngressMessage(pub CanisterCall);

impl Operation for ExecuteIngressMessage {
fn compute(&self, pic: &mut PocketIc) -> OpOut {
let canister_call = self.0.clone();
let subnet = route_call(pic, canister_call);
match subnet {
Ok(subnet) => {
match subnet.submit_ingress_as(
self.0.sender,
self.0.canister_id,
self.0.method.clone(),
self.0.payload.clone(),
) {
Err(SubmitIngressError::HttpError(e)) => {
eprintln!("Failed to submit ingress message: {}", e);
OpOut::Error(PocketIcError::BadIngressMessage(e))
}
Err(SubmitIngressError::UserError(e)) => {
eprintln!("Failed to submit ingress message: {:?}", e);
Err::<ic_state_machine_tests::WasmResult, ic_state_machine_tests::UserError>(e).into()
}
Ok(msg_id) => {
// Now, we execute on all subnets until we have the result
let max_rounds = 100;
for _i in 0..max_rounds {
for subnet_ in pic.subnets.get_all() {
subnet_.state_machine.execute_round();
}
match subnet.ingress_status(&msg_id) {
IngressStatus::Known {
state: IngressState::Completed(result),
..
} => return Ok(result).into(),
IngressStatus::Known {
state: IngressState::Failed(error),
..
} => {
return Err::<
ic_state_machine_tests::WasmResult,
ic_state_machine_tests::UserError,
>(error)
.into()
}
_ => {}
}
}
OpOut::Error(PocketIcError::BadIngressMessage(format!(
"Failed to answer to ingress {} after {} rounds.",
msg_id, max_rounds
)))
}
}
}
Err(e) => OpOut::Error(PocketIcError::BadIngressMessage(e)),
}
}

fn id(&self) -> OpId {
let call_id = self.0.id();
OpId(format!("canister_update_{}", call_id.0))
}
}

#[derive(Clone, Debug)]
pub struct IngressMessageStatus {
pub message_id: MessageId,
Expand Down
32 changes: 3 additions & 29 deletions rs/pocket_ic_server/src/state_api/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use super::state::{ApiState, OpOut, PocketIcError, StateLabel, UpdateReply};
use crate::pocket_ic::{
AddCycles, AwaitIngressMessage, CallRequest, CallRequestVersion, CanisterReadStateRequest,
DashboardRequest, ExecuteIngressMessage, GetCanisterHttp, GetControllers, GetCyclesBalance,
GetStableMemory, GetSubnet, GetTime, GetTopology, IngressMessageStatus, MockCanisterHttp,
PubKey, Query, QueryRequest, SetStableMemory, SetTime, StatusRequest, SubmitIngressMessage,
DashboardRequest, GetCanisterHttp, GetControllers, GetCyclesBalance, GetStableMemory,
GetSubnet, GetTime, GetTopology, IngressMessageStatus, MockCanisterHttp, PubKey, Query,
QueryRequest, SetStableMemory, SetTime, StatusRequest, SubmitIngressMessage,
SubnetReadStateRequest, Tick,
};
use crate::{async_trait, pocket_ic::PocketIc, BlobStore, InstanceId, OpId, Operation};
Expand Down Expand Up @@ -98,10 +98,6 @@ where
"/await_ingress_message",
post(handler_await_ingress_message),
)
.directory_route(
"/execute_ingress_message",
post(handler_execute_ingress_message),
)
.directory_route("/set_time", post(handler_set_time))
.directory_route("/add_cycles", post(handler_add_cycles))
.directory_route("/set_stable_memory", post(handler_set_stable_memory))
Expand Down Expand Up @@ -1019,28 +1015,6 @@ pub async fn handler_await_ingress_message(
}
}

pub async fn handler_execute_ingress_message(
State(AppState { api_state, .. }): State<AppState>,
Path(instance_id): Path<InstanceId>,
headers: HeaderMap,
extract::Json(raw_canister_call): extract::Json<RawCanisterCall>,
) -> (StatusCode, Json<ApiResponse<RawCanisterResult>>) {
let timeout = timeout_or_default(headers);
match crate::pocket_ic::CanisterCall::try_from(raw_canister_call) {
Ok(canister_call) => {
let ingress_op = ExecuteIngressMessage(canister_call);
let (code, response) = run_operation(api_state, instance_id, timeout, ingress_op).await;
(code, Json(response))
}
Err(e) => (
StatusCode::BAD_REQUEST,
Json(ApiResponse::Error {
message: format!("{:?}", e),
}),
),
}
}

pub async fn handler_ingress_status(
State(AppState { api_state, .. }): State<AppState>,
Path(instance_id): Path<InstanceId>,
Expand Down
Loading