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

TrapCaps for async host, synchronous guest relationships #3171

Merged
merged 31 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
714b214
feat: implement exportAsSyncable, and Sync powers
michaelfig May 24, 2021
06168be
test: update tests for Sync/exportAsSyncable
michaelfig May 25, 2021
3d500a1
feat: implement Sync for makeLoopback
michaelfig May 25, 2021
b90ae08
fix: don't create new promise IDs and stall the pipeline
michaelfig May 25, 2021
1455298
fix: break up incoherent GetApply function into SyncImpl record
michaelfig May 31, 2021
c838e91
feat(captp): return Sync replies via arbitrary comm protocol
michaelfig Jun 1, 2021
d642c41
fix(captp): ensure Sync(x) never returns a thenable
michaelfig Jun 3, 2021
790735b
chore: pivot to TrapCaps to reflect guest/host relationship
michaelfig Jun 3, 2021
1eb035c
refactor: separate CapTP communications from trap iterator driver
michaelfig Jun 16, 2021
4135491
docs(captp): fix up description of trap-driver.js
michaelfig Jun 16, 2021
55a8c8f
chore(captp): add type linting
michaelfig Jun 17, 2021
254b735
chore(captp): rename lib -> src
michaelfig Jun 17, 2021
8b20562
fix(solo): clean up unnecessary deep captp import
michaelfig Jun 17, 2021
9e28e9e
refactor(captp): cleanup style and typing
michaelfig Jun 22, 2021
3800ad0
refactor(captp): less opinionated trapGuest (part 1/2)
michaelfig Jul 11, 2021
75a9a6c
refactor(captp): make continuations explicit (part 2/3)
michaelfig Jul 12, 2021
57ebb71
test(captp): test takeMore implementation (part 3/3)
michaelfig Jul 12, 2021
67cc4cb
chore(captp): fix the lint
michaelfig Jul 12, 2021
a8e0e96
feat(captp): take suggestion in #3289 to prefix questionIDs
michaelfig Jul 15, 2021
a350b9d
feat(captp): leverage makeSubscriptionKit to drive trapHost
michaelfig Jul 15, 2021
4aa941c
refactor(captp): rename and simplify TrapCaps
michaelfig Jul 16, 2021
ec5dfbe
refactor(captp): clarify the Atomics trapGuest/trapHost protocol
michaelfig Jul 17, 2021
1b60eb6
style(captp): clarify documentation and review changes
michaelfig Jul 17, 2021
933d5a7
style(captp): the ProxyHandler is not readOnly, it's freezable
michaelfig Jul 17, 2021
592f0b7
fix(captp): properly export src/index.js
michaelfig Jul 17, 2021
feda6c8
fix(captp): ensure trapcap reply iteration is serial
michaelfig Jul 17, 2021
003c3d1
fix(captp): more robust CTP_TRAP_ITERATE error handling
michaelfig Jul 17, 2021
5a370a8
fix(captp): don't rely on TextDecoder stream flag
michaelfig Jul 19, 2021
6fc842c
fix(captp): relax it.throw signature
michaelfig Jul 19, 2021
15292fe
style(captp): fix types line wrapping
michaelfig Jul 19, 2021
21b72cd
fix(captp): clarify error handling
michaelfig Jul 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/captp/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ User-visible changes in captp:
Moved from https://github.com/Agoric/captp into the `packages/captp/`
directory in the monorepo at https://github.com/Agoric/agoric-sdk .

## Release 1.8.0

* introduce TrapCaps for synchronous "kernel trap" interfaces (see the
README.md).
40 changes: 40 additions & 0 deletions packages/captp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,43 @@ E(getBootstrap()).method(args).then(res => console.log('got res', res));
// Tear down the CapTP connection if it fails (e.g. connection is closed).
abort(Error('Connection aborted by user.'));
```

## Loopback

The `makeLoopback()` function creates an async barrier between "near" and "far"
objects. This is useful for testing and isolation within the same address
space.

## TrapCaps

In addition to the normal CapTP facilities, this library also has the notion of
"TrapCaps", which enable a "guest" endpoint to call a "host" object (which may
resolve an answer promise at its convenience), but the guest synchronously
blocks until it receives the resolved answer.

This is a specialized and advanced use case, not for mutually-suspicious CapTP
parties, but instead for clear "guest"/"host" relationship, such as user-space
code and synchronous devices.

1. Supply the `trapHost` and `trapGuest` protocol implementation (such as the
one based on `SharedArrayBuffers` in `src/atomics.js`) to the host and guest
`makeCapTP` calls.
2. On the host side, use the returned `makeTrapHandler(target)` to mark a target
as synchronous-enabled.
3. On the guest side, use the returned `Trap(target)` proxy maker much like
`E(target)`, but it will return a synchronous result. `Trap` will throw an
error if `target` was not marked as a TrapHandler by the host.

To understand how `trapHost` and `trapGuest` relate, consider the `trapHost` as
a maker of AsyncIterators which don't return any useful value. These specific
iterators are used to drive the transfer of serialized data back to the guest.

`trapGuest` receives arguments to describe the specific trap request, including
`startTrap()` which sends data to the host to perform the actual work of the
trap. The returned (synchronous) iterator from `startTrap()` drives the async
iterator of the host until it fully transfers the trap results to the guest, and
the guest unblocks.

The Loopback implementation provides partial support for TrapCaps, except it
cannot unwrap promises. Loopback TrapHandlers must return synchronously, or an
exception will be thrown.
43 changes: 0 additions & 43 deletions packages/captp/SETUP-DELETEME.md

This file was deleted.

18 changes: 18 additions & 0 deletions packages/captp/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",

"noEmit": true,
/*
// The following flags are for creating .d.ts files:
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
*/
"downlevelIteration": true,
"strictNullChecks": true,
"moduleResolution": "node",
},
"include": ["src/**/*.js", "src/**/*.d.ts", "exported.js"],
}
Loading