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

feat(async-flow): endowments #9566

Merged
merged 12 commits into from
Jun 25, 2024
Merged

feat(async-flow): endowments #9566

merged 12 commits into from
Jun 25, 2024

Conversation

erights
Copy link
Member

@erights erights commented Jun 22, 2024

closes: #XXXX
refs: #9449 #9521 #9304 #9281

Description

Changed async-flow to support endowments. Changed orchestrate to use asyncFlow with endowments. Changed sendAnywhere example orchestration contract to be more compatible with this new orchestrate.

The CI errors are all in the orchestration package. After some earlier iteration where orchestration failures indicated async-flow bugs, which I fixed, the remaining errors seem plausibly to be integration bugs on the orchestration side revealed by using this improved orchestrate function. If so, that satisfies the purpose of this PR -- to enable integration testing to reveal such errors. However, this leaves open the question of how to bring this PR to fruition despite these CI errors.

In that iteration, the majority of errors were due to host-side promises, which we expected. To proceed with integration testing, I temporarily turned that case into a warning, by wrapping the host-side promise with a host-side vow. This stopgap measure is obviously fragile under upgrade. It would cause may upgrades to fail

However, I have not investigated these CI errors enough to be at all confident that none of them are due to bugs in async-flow. For any of those, they should be fixed in this PR.

Security Considerations

nothing new

Scaling Considerations

none, given that total endowments are low cardinality. All these endowments are prepare-time per-function. There should not be any cardinality limit on the activations making use of these endowments. But like all other async-flow scaling issues, that remains to be tested.

Documentation Considerations

The endowment rules and taxonomy is interesting, and should be documented.

Testing Considerations

We get CI errors only from the orchestration package. Some of these may be the integration bugs we wanted this exercise to reveal. However, others may be async-flow bugs, which should have been caught by async-flow unit tests.

The warning stopgap I mentioned above appears in CI as, for example

Warning for now: vow expected, not promise Promise { <pending> } (Error#1)
Error#1: where warning happened
  at makeGuestForHostVow (.../async-flow/src/replay-membrane.js:329:9)
  at eval (.../async-flow/src/convert.js:119:10)
  at innerConvert (.../async-flow/src/convert.js:63:8)
  at convertRecur (.../async-flow/src/convert.js:30:8)
  at convert (.../async-flow/src/convert.js:76:1)
  at performCall (.../async-flow/src/replay-membrane.js:137:1)
  at guestCallsHost (.../async-flow/src/replay-membrane.js:195:9)
  at In "getChain" method of (Orchestrator orchestrator) [as getChain] (.../async-flow/src/replay-membrane.js:282:8)
  at eval (.../orchestration/src/examples/unbondExample.contract.js:60:23)
  at eval (.../async-flow/src/async-flow.js:222:1)
  at Object.restart (.../async-flow/src/async-flow.js:222:30)
  at makeAsyncFlowKit (.../async-flow/src/async-flow.js:430:6)
  at asyncFlow_hostFlow (.../async-flow/src/async-flow.js:448:13)
  at orcFn (.../orchestration/src/facade.js:124:15)
  at eval (.../pass-style/src/make-far.js:224:31)

The relevant lines are

  at In "getChain" method of (Orchestrator orchestrator) [as getChain] (.../async-flow/src/replay-membrane.js:282:8)
  at eval (.../orchestration/src/examples/unbondExample.contract.js:60:23)

where the first line indicates what method or method guard provided the inappropriate promise

  getChain: M.callWhen(M.string()).returns(ChainInfoShape),

and the second line indicates where the guest code called it

const omni = await orch.getChain('omniflixhub');

Upgrade Considerations

The orchestration code in question cannot be truly upgrade safe until we see no more of these "vow expected, not promise" warnings. Even then, we should expect that async-flow as of this PR is ready for lots of testing, but not yet ready to run on the main chain with durable state expected to survive real upgrades.

@erights erights self-assigned this Jun 22, 2024
@erights erights added the asyncFlow related to membrane-based replay and upgrade of async functions label Jun 22, 2024
Copy link

cloudflare-workers-and-pages bot commented Jun 22, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: c4a252b
Status: ✅  Deploy successful!
Preview URL: https://f7b41959.agoric-sdk.pages.dev
Branch Preview URL: https://markm-endowment-asyncflow.agoric-sdk.pages.dev

View logs

@erights erights force-pushed the markm-endowment-asyncFlow branch 7 times, most recently from d19ac57 to 49046c8 Compare June 23, 2024 22:40
@erights erights marked this pull request as ready for review June 23, 2024 23:44
@erights erights requested review from mhofman, turadg and dckc June 23, 2024 23:45
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

notes on sendAnywhere

const { denom } = await findBrandInVBank(amt.brand);
const chain = await orch.getChain(chainName);

// FIXME ok to use a heap var crossing the membrane scope this way?
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// FIXME ok to use a heap var crossing the membrane scope this way?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Also cleaned up the two // XXX when() until membrane below

Copy link
Member

Choose a reason for hiding this comment

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

odd... it doesn't look done.

@erights erights requested a review from dckc June 24, 2024 17:10
@erights
Copy link
Member Author

erights commented Jun 24, 2024

swapExample and unbondExample were the remaining example contracts calling orchestrate, so I hoisted their guest function as well. Unlike sendAnywhere, these seemed to hoist cleanly.

@erights
Copy link
Member Author

erights commented Jun 24, 2024

The existing failures are Error: Promise returned by test never resolved, which looks like a bug in my code, not in the contracts being integration tested. Still trying to track that down.

@erights
Copy link
Member Author

erights commented Jun 24, 2024

The existing failures are Error: Promise returned by test never resolved, which looks like a bug in my code, not in the contracts being integration tested. Still trying to track that down.

That problem fixed

Copy link
Member

@dtribble dtribble left a comment

Choose a reason for hiding this comment

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

It looks good, though I have a few questions.

packages/async-flow/src/replay-membrane.js Outdated Show resolved Hide resolved
packages/async-flow/src/types.js Show resolved Hide resolved
packages/async-flow/src/bijection.js Show resolved Hide resolved
packages/async-flow/src/bijection.js Outdated Show resolved Hide resolved
packages/async-flow/src/endowments.js Show resolved Hide resolved
packages/async-flow/src/endowments.js Outdated Show resolved Hide resolved
packages/async-flow/src/endowments.js Show resolved Hide resolved
packages/async-flow/src/endowments.js Show resolved Hide resolved
@erights erights added the automerge:squash Automatically squash merge label Jun 25, 2024
@mergify mergify bot merged commit 4390d8c into master Jun 25, 2024
84 of 85 checks passed
@mergify mergify bot deleted the markm-endowment-asyncFlow branch June 25, 2024 18:56
mergify bot pushed a commit that referenced this pull request Jun 28, 2024
closes: #XXXX
refs: https://github.com/Agoric/agoric-sdk/pull/9566/files#r1653602477

## Description

At https://github.com/Agoric/agoric-sdk/pull/9566/files#r1653602477 @dckc commented on a cleanup that I thought I did and marked as done, but was not done. 

Before #9566, the code that would be guest code had several workarounds marked `// XXX when() until membrane` that correctly indicated that they should be cleaned up as of #9566, which introduces exactly that membrane.

In addition, guest code has no need for `heapVowE` since it doesn't see vows. It should just use the normal `E`. To keep this distinct, I stopped renaming `hostVowE` where host code needs it in the same file.

### Security Considerations
none
### Scaling Considerations
none
### Documentation Considerations
examples are now more like what we want to teach
### Testing Considerations
I believe this PR is a pure refactor that should not have any observable effects. Thus, it should not affect any tests. We'll see soon.
### Upgrade Considerations
none
mergify bot added a commit that referenced this pull request Jul 3, 2024
refs: #9566

## Description

address a type error from #9566:

```
Error: src/examples/sendAnywhere.contract.js(112,9): error TS2741: Property 'account' is missing in type '{}' but required in type '{ account: OrchestrationAccount<any> | undefined; }'.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
asyncFlow related to membrane-based replay and upgrade of async functions automerge:squash Automatically squash merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants