feat: upgrade HTTP request calls from query to update upon canister's request#195
feat: upgrade HTTP request calls from query to update upon canister's request#195paulyoung wants to merge 11 commits intodfinity:mainfrom
Conversation
Instead of on each request.
hansl
left a comment
There was a problem hiding this comment.
Hi @paulyoung ! Nice to see you :D
We're working towards a proposal system for those big changes to protocols. There are a lot of details here that will bring problems so I want to make sure we take them all into account.
I suggest you wait for this new system and that we work together for a better design document. You can champion the changes if you want to take the work.
Cheers!
Hans
|
As a note I'll keep this PR open to make sure we don't forget about it. |
|
@hansl sounds good, please keep me posted. |
|
I just wanted to leave a note for myself to say that (assuming it works for my use case) I might prefer the approach @nomeata took in |
|
I wouldn't say automatically, it upgrades upon canister's request |
|
I think I’ve convinced myself that @nomeata’s “upgrade” approach is the way to go. I explain why that is here: https://forum.dfinity.org/t/is-it-possible-to-build-a-rest-api-in-a-canister/5355/4?u=paulyoung I’m happy to make further changes to that effect but I’ve been holding off until the proposal system @hansl mentioned is ready. |
|
I made changes to this effect but haven't pushed them yet. I wanted to try them out some more locally first. |
| .build() | ||
| } | ||
|
|
||
| pub fn http_request_update<'canister: 'agent, M: Into<String>, U: Into<String>, B: AsRef<[u8]>>( |
There was a problem hiding this comment.
I think it would be worth introducing http_request_query as well for consistency. We could keep http_request as a wrapper around that for backwards compatibility for now.
There was a problem hiding this comment.
I think it would be worth introducing
http_request_queryas well for consistency. We could keephttp_requestas a wrapper around that for backwards compatibility for now.
Should we do this?
|
Is there anything I can do to help move this along? I’ve heard that there’s a HTTP Gateway spec that relates to this but I don’t think that’s been made public. |
|
Sounds like a “community proposal” in https://forum.dfinity.org/t/megathread-community-submissions-for-dfinity-foundation-s-roadmap/6175/55 might be a good way to get this on the agenda. |
|
@paulyoung , would you please push a change that fixes the formatting and lint CI errors? Then we'll get this merged. Thanks! |
|
Having the canister request the upgrade is certainly one approach, but it seems to me that many times the client may know what it wants. Should we not have a way for the client to specify that it wants an update e.g. in a header? |
|
In my use case, many clients already exist and work with an existing API spec. It would be a big blow if I couldn’t control this on the canister side. |
|
@paulyoung I would have both, client chosen and canister driven. |
|
If you have a dedicated client that has application specific knowledge anyways, then often you'd just to plain IC calls, instead of piggybacking on HTTP as an extra layer here. So client-specified is much less important and pressing than canister side. (And clients can just call |
|
I agree that the client could use IC calls, but sometimes e.g. forms it might be easier to use plain HTTP. |
|
Right, but then the canister could just do it as well, which keeps the client (and thus the overall mental complexity for the developer) simple. How would you even let the client choose? A custom header? Hard to do in a plain form… I'm not strongly opposed, but it's a distraction from the highly relevant and somewhat urgent proposal by Paul that we should get in. |
|
Agreed that this is more trouble than it is worth at this point. LGTM |
|
We need a spec and service worker change AFAICT @nomeata ? |
|
There is a spec on some internal Notion page. Or actually two, one for the HTTP gateway feature and one for the certification protocol. That ought to be moved somewhere more proper (possibly a new section of the Interface Specification?), and then extended. This would also help to uncover things like this: in update calls, we can't use certified variables to certify responses. But that's ok, as update responses are certified by the system! So no problem, but worth pointing out, and implementing as such in the service worker. |
|
When we submit this, let's create an issue to upgrade the service worker to allow upgrades on the http asset path. |
|
Hey looks like we are good to go on this feature, Is there something I can do to help move this forward? |
|
Does anyone have any advice on what to do here now?
|
|
I guess I should open a PR at https://github.com/dfinity/icx-proxy for the changes here that are specific to that. |
I think we™ need to
|
|
Closing this PR since icx-proxy now lives at https://github.com/dfinity/icx-proxy |
This lays the groundwork for upgrading HTTP requests from query calls to update calls. This applies changes from dfinity#195 that are specific to ic-utils so that they can be used downstream in icx-proxy.
This applies changes from dfinity/agent-rs#195 that are specific to icx-proxy. It necessarily depends on a newer version of agent-rs and ic-utils. This will most likely be something like 10.X.0 but temporarily uses a Git URL for now.
This lays the groundwork for upgrading HTTP requests from query calls to update calls. It applies the changes from dfinity#195 that are specific to ic-utils so that they can be used downstream in icx-proxy.
This applies changes from dfinity/agent-rs#195 that are specific to icx-proxy. It necessarily depends on a newer version of agent-rs and ic-utils. This will most likely be something like 10.X.0 but temporarily uses a Git URL for now.
|
I opened #291 and dfinity/icx-proxy#6. |
This lays the groundwork for upgrading HTTP requests from query calls to update calls. It applies the changes from #195 that are specific to ic-utils so that they can be used downstream in icx-proxy.
This lays the groundwork for upgrading HTTP requests from query calls to update calls. It applies the changes from dfinity/agent-rs#195 that are specific to ic-utils so that they can be used downstream in icx-proxy.
This lays the groundwork for upgrading HTTP requests from query calls to update calls. It applies the changes from dfinity/agent-rs#195 that are specific to ic-utils so that they can be used downstream in icx-proxy.
This lays the groundwork for upgrading HTTP requests from query calls to update calls. It applies the changes from dfinity/agent-rs#195 that are specific to ic-utils so that they can be used downstream in icx-proxy.
Edit: the code in this PR no longer infers when to make an update call, it does it upon the canister’s request.
This is a first pass at inferring when to make an update call instead of a query call based on HTTP request methods.
It's based on this discussion thread in the developer forum. Thanks to @nomeata for some feedback and help getting to this point.
I think this could be made a lot more configurable (perhaps via a file that is read when
icx-proxystarts which maps methods/routes to functions) but what's here suits my needs for now so I thought I'd share it in case there's any interest in merging.Thanks in advance for considering this change.