-
Notifications
You must be signed in to change notification settings - Fork 82
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
spec: support composite query #420
Conversation
spec/Candid.md
Outdated
A function type describes the list of parameters and results and their respective types. It can optionally be annotated to be *query*, *composite_query* or *oneway*. | ||
|
||
* `query` indicates that the function does not modify any state and can potentially be executed more efficiently (e.g., on cached state). | ||
* `composite_query` is a special `query` function that cannot be called in inter-canister calls. The composite query function can call other query and composite query functions on the same subnet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot be called in inter-canister calls
I think it should be "cannot be called by update methods" because it is possible to make an inter-canister composite query call.
Could you please also add that the restriction about the "update method" and "same subnet" are due to the incompleteness of current implementation and may be lifted in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am approving assuming this comment will be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be lifted in the future
Lifting all restrictions means we will have just the query
method, and no composite query
method, or it's the other way around?
Candid spec is quite high level, and tries to be platform agnostic. See the paragraph above about query
method. It's only suggesting that query
method can be more efficient. I prefer to describe composite query
without mentioning subnet, but seems like it's not easy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. I thought I've replied already, but don't see my reply here.
Lifting all restrictions means we will have just the query method, and no composite query method, or it's the other way around?
Query and composite query will become the same thing:
- query will be able to call query and composite query
- composite query will be callable from an update
Candid spec is quite high level, and tries to be platform agnostic. See the paragraph above about query method. It's only suggesting that query method can be more efficient.
It seems inconsistent that we mention limitations of composite queries without mentioning the main limitation of query: it cannot call any other methods.
If we want to stay platform agnostic, then maybe we should write something more vague: "composite query is a kind of a query with additional platform-specific features and limitations"?
That's said, my personal preference would be to be more pragmatic and mention all information that might be useful for the users (maybe with some comment that it only applies to IC):
- composite queries can be called only from other composite queries.
- composite queries can call composite queries and queries.
- composite query calls cannot be made cross-subnets.
- queries cannot call any other methods.
All these limitations are temporary due to the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made another pass. PTAL.
composite queries can be called only from other composite queries.
It can also be called outside of IC.
queries cannot call any other methods.
There used to be a hack that a query function can call another terminating query function. Is this being removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the latest version lgtm!
There used to be a hack that a query function can call another terminating query function. Is this being removed?
Do you mean ICQC on system and verified application subnets? There non-replicated queries can call other queries on the same subnet. That is exactly what we are packaging as composite_query and releasing on all subnets.
Right now, queries on application subnets cannot call any other queries (terminating or not).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do address @ulan's suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, thanks!
spec/Candid.md
Outdated
A function type describes the list of parameters and results and their respective types. It can optionally be annotated to be *query*, *composite_query* or *oneway*. | ||
|
||
* `query` indicates that the function does not modify any state and can potentially be executed more efficiently (e.g., on cached state). | ||
* `composite_query` is a special `query` function that cannot be called in inter-canister calls. The composite query function can call other query and composite query functions on the same subnet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am approving assuming this comment will be addressed.
This change adds a new query type: `composite_query` in idl.ts. It corresponds to the following changes in the upstream candid: - dfinity/candid#420 (spec change) - dfinity/candid#435 (rust change)
This change adds a new query type: `composite_query` in idl.ts. It corresponds to the following changes in the upstream candid: - dfinity/candid#420 (spec change) - dfinity/candid#435 (rust change)
Follow up with dfinity/interface-spec#144