Does making a change during an update call, then calling an intercanister query method, commits the change?

Are there any difference between these 2 scenarios?

A)

  1. make a change on canister X
  2. call a query method on canister Y
  3. does the change on canister X gets committed if the method exist on canister Y?

B) (am i right on this?)

  1. make a change on canister X
  2. call an update method on canister Y
  3. the change on canister X gets committed if the method exist on canister Y

Whenever your canister makes a call to another canister it commits it changes. It’s always committed even if if e.g. something goes wrong with the call.

Keep in mind, the canister can receive and process other incoming calls while it waits for a response so the canister state before and after receiving the response of an inter canister call can change! This is a common security pitfall in IC application design.

As for query/update, inter-canister calls are always executed as replicated calls so also query methods will be called as if they were update methods.

Lastly we have the more recent addition of composite queries which can call other canister composite query methods. These do not mutate state in any of the involved canisters so less of a security pitfall here.

Though not sure if composite queries before and after calling another canister use the previous or current state. I’m guessing previous state if I remember some talks on the forum before (correct me if I’m wrong).

2 Likes