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

spec: support composite query #420

Merged
merged 3 commits into from
May 23, 2023
Merged

spec: support composite query #420

merged 3 commits into from
May 23, 2023

Conversation

chenyan-dfinity
Copy link
Contributor

@chenyan-dfinity chenyan-dfinity requested review from ulan and crusso April 18, 2023 23:21
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.
Copy link
Contributor

@ulan ulan Apr 21, 2023

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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).

Copy link
Contributor

@crusso crusso left a 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.

Copy link
Contributor

@ulan ulan left a 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.
Copy link
Contributor

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.

chenyan-dfinity and others added 2 commits May 17, 2023 16:22

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@chenyan-dfinity chenyan-dfinity merged commit 51c0047 into master May 23, 2023
@chenyan-dfinity chenyan-dfinity deleted the composite-query branch May 23, 2023 15:09
ulan added a commit to ulan/agent-js that referenced this pull request Jun 27, 2023
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)
THLO pushed a commit to dfinity/agent-js that referenced this pull request Jul 6, 2023
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants