Hi everyone,
I’ve been exploring the behavior of the in_replicated_execution
method in the rust cdk and noticed something unexpected regarding its execution mode. Based on the IC interface spec, I was under the impression that inspect_message
only runs on a single node and is not executed in replicated mode.
However, when I tested the ic_cdk::api::in_replicated_execution
function within an inspect_message
method, it appears to indicate that inspect_message
is running in replicated execution mode. Here’s the code I used for testing:
#[ic_cdk::inspect_message]
fn inspect_message() {
let in_replicated_execution = ic_cdk::api::in_replicated_execution();
ic_cdk::println!(
"Inspect message is in replicated execution: {}",
in_replicated_execution
);
ic_cdk::api::call::accept_message();
}
#[ic_cdk::update]
fn update() {
let in_replicated_execution = ic_cdk::api::in_replicated_execution();
ic_cdk::println!(
"Update is in replicated execution: {}",
in_replicated_execution
);
}
When I call dfx canister call backend update
, the following logs are produced:
2025-01-17 22:10:07.393336193 UTC: [Canister a4tbr-q4aaa-aaaaa-qaafq-cai] Inspect message is in replicated execution: true
2025-01-17 22:10:07.634569429 UTC: [Canister a4tbr-q4aaa-aaaaa-qaafq-cai] Update is in replicated execution: true
This suggests that both the inspect_message
and update
methods are considered to be in replicated execution.
Am I misunderstanding something about how inspect_message
is supposed to work? My expectation was that in_replicated_execution
would return false
for inspect_message
, given that the spec mentions it is not executed in replicated mode.
Any clarification on this behavior would be greatly appreciated!
Thanks in advance!