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

Use Remote<T> to indicate tolerance of far types #9027

Closed
Tracked by #8867
michaelfig opened this issue Mar 2, 2024 · 0 comments · Fixed by #9102
Closed
Tracked by #8867

Use Remote<T> to indicate tolerance of far types #9027

michaelfig opened this issue Mar 2, 2024 · 0 comments · Fixed by #9102
Assignees
Labels
enhancement New feature or request

Comments

@michaelfig
Copy link
Member

michaelfig commented Mar 2, 2024

What is the Problem Being Solved?

The state-of-the-art typing used in Agoric SDK to indicate potentially remote presences is:

  1. ERef<T> only indicates that T may or may not be a promise. The downside is after await T, is performed, there is no propagation of the remote nature of T.
  2. FarRef<T> is a more complex type that attempts to express promise-or-not, awaitable local properties, and a remote brand check, but without propagation.

It would be useful to have a type designation (Remote<T>) for an object created by Far or an exo, which says that a function producing or consuming such a type will (by default) treat it as potentially remote.

Description of the Design

Now that RemotableBrand has been supported for a long time in @endo/eventual-send, and has been added to Far, Remotable, and zone.exo*, we can use it. This will build more sophisticated remote typing than ERef<T> and clearer than FarRef<T>.

With care, Remote<T> can be used in any situation, conserving information as a function argument or return value, as well as a variable or in a data structure.

Security Considerations

Improves correctness when handling remote objects.

Scaling Considerations

Encourages synchronous calls to be converted to async, which introduces more turns. For performance-sensitive code running in the same vat as a remotable such as Remote<{ getNum(): number }>, if a locality assertion like 'getNum' in remotable is true, remotable will be narrowed to a synchronous callable (such that remotable.getNum() is possible).

Test Plan

Use Remote<T> in existing code and verify that Typescript only points out problems to solve that are understandable consequences of the new typing.

Upgrade Considerations

Types are erased, so there is no runtime impact on code that uses Remote<T>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant