Skip to content

feat: add ProxyRuntime#84

Merged
lpahlavi merged 9 commits intomainfrom
lpahlavi/defi-2643-proxy-runtime
Mar 4, 2026
Merged

feat: add ProxyRuntime#84
lpahlavi merged 9 commits intomainfrom
lpahlavi/defi-2643-proxy-runtime

Conversation

@lpahlavi
Copy link
Contributor

@lpahlavi lpahlavi commented Feb 27, 2026

Add a ProxyRuntime that wraps another Runtime instance and forwards update calls through the provided proxy canister.

@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2643-proxy-runtime branch 2 times, most recently from adbcc5d to 2365ffa Compare February 27, 2026 12:08
@lpahlavi lpahlavi marked this pull request as ready for review February 27, 2026 13:29
@lpahlavi lpahlavi requested a review from a team as a code owner February 27, 2026 13:29
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2643-proxy-runtime branch from 2365ffa to 3e3db6d Compare February 27, 2026 13:32
@lpahlavi lpahlavi force-pushed the lpahlavi/defi-2643-proxy-runtime branch from 3e3db6d to 50dee58 Compare February 27, 2026 13:32
In: ArgumentEncoder + Send,
Out: CandidType + DeserializeOwned,
{
self.runtime.query_call(id, method, args).await
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't query call also go through the proxy? E.g. Some query endpoints on the target canister could be restricted to a controller (which would be the proxy)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, and yes I agree that this is not quite optimal but the problem is that the proxy canister only has one proxy endpoint which is an update endpoint.

To be very honest though, I'm not actually 100% certain how the ic-cdk differentiates between update and query calls with the new API since both types of calls are made with Call::bounded_wait or Call::unbounded_wait anyways...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the problem is that the proxy canister only has one proxy endpoint which is an update endpoint.

right I forgot that query endpoint cannot trigger inter-canister calls, so that doesn't make sense (should also answer your question about Call)


#[async_trait]
impl<R: Runtime + Send + Sync> Runtime for ProxyRuntime<R> {
async fn update_call<In, Out>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have at least one smoke integration test (with the proxy canister wasm) to ensure that it works as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I will add one!

@lpahlavi lpahlavi requested a review from gregorydemay March 3, 2026 12:27
@lpahlavi
Copy link
Contributor Author

lpahlavi commented Mar 3, 2026

@gregorydemay I've added some simple integration tests for the new ProxyRuntime, PTAL 🙏

@lpahlavi lpahlavi merged commit f429557 into main Mar 4, 2026
10 checks passed
@lpahlavi lpahlavi deleted the lpahlavi/defi-2643-proxy-runtime branch March 4, 2026 09:06
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.

2 participants