The state machine of IC and query methods

Suppose:

  • The state of a canister changes from A to B (it was in the state A before we start).
  • There are two methods able to determine whether it is in B or still in A, one update method U and one query method Q.

Is it true that after the method Q will return that the state is B, U will also return that the state is B?

The real problem: I am doing a callback from a Web server (more precisely, a HTTP/HTTPS proxy) to IC, to determine that the request from IC is genuine (not faked by a third party). I need to query the state of IC several times. I prefer cheap query methods, but I also need update method, to be sure that the state of IC wasn’t forged.

As far as I understand, all update methods (from a single IP) are serialize, to be sure that the order of operations is correct. But does it apply also to query methods?

I ask for the case, when the IC replica that serves the query method is not hacked. (Otherwise, query can return whatever the hacked replica wants.)

Docs say:

Query calls, also referred to as non-replicated queries, are executed on a single node and return a synchronous response.

Should the word “synchronous” be understood as a positive answer to my question (that query calls are executed in order with update calls)?

As I see from “Comparison of update calls vs query calls” section of the above linked docs, they don’t mean that. So, my question is still open.

The answer to my question is “no”, see this docs.

To solve my real problem I will use message inspection to do several update calls for free, until a “working” update call returns a “positive” result.

No to both. Message ordering is only guaranteed if made from a canister. I don’t even feel confident saying that it is probable that the ordering is preserved if you make two requests close to each other

That is a good idea. I guess if you have something like a transaction counter against which you can compare this would be pretty simple