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

9796 continuing ica #10023

Merged
merged 4 commits into from
Sep 6, 2024
Merged

9796 continuing ica #10023

merged 4 commits into from
Sep 6, 2024

Conversation

turadg
Copy link
Member

@turadg turadg commented Sep 3, 2024

closes: #9796

Description

Demonstrates a pattern for creating continuing invitations that have handlers written as orchestration flows.

Builds upon the combine-invitation-makers from #9821

Security Considerations

None

Scaling Considerations

Augmenting an existing exo's invitationMaker requires two new ones: the exo holding the other makers and an exo to wrap them both.

Documentation Considerations

Once this lands it should have an explicit tutorial for developers needing this functionality.

Testing Considerations

new tests

Upgrade Considerations

not yet deployed

Copy link

cloudflare-workers-and-pages bot commented Sep 3, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2689372
Status: ✅  Deploy successful!
Preview URL: https://b3938cac.agoric-sdk.pages.dev
Branch Preview URL: https://9796-continuing-ica.agoric-sdk.pages.dev

View logs

@turadg turadg force-pushed the 9796-continuing-ica branch from b931fa6 to 5304024 Compare September 4, 2024 23:42
mergify bot added a commit that referenced this pull request Sep 5, 2024
refs: #9796 

## Description

#10023 started with a series of refactors and cleanup. This separates those into another PR to be reviewed more rapidly.

It also includes a new feature to orchestrateAll to ease calling flows from flows. Each flow is available on the context object under `flows`.

### Security Considerations
Every flow can call another flow. In the event a developer wants isolate between flows, they won't put them in the same `orchestrateAll`.

### Scaling Considerations
n/a

### Documentation Considerations
none

### Testing Considerations
new tests

### Upgrade Considerations
not yet deployed
@turadg turadg force-pushed the 9796-continuing-ica branch from 5304024 to 5b70d25 Compare September 5, 2024 21:45
@turadg turadg marked this pull request as ready for review September 5, 2024 22:35
Copy link
Member

@0xpatrickdev 0xpatrickdev left a comment

Choose a reason for hiding this comment

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

Looks good, going to play around with it a bit more locally before approving since it's marked as Closes.

I see a clear path for sharing state from flow1 with subsequent flows. Wondering if it will cover state created in flow2 that's needed by flow3, e.g. the repeater in the restake contract.

);

return vowTools.watch(invP);
},
Copy link
Member

Choose a reason for hiding this comment

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

Nice. We might want to include an example with a seat and offerArgs as well, something like:

      DepositAndDelegate() {
        const { account } = this.state;

        const invP = zcf.makeInvitation(
          (seat, delegations) =>
            orchFns.depositAndDelegate(account, seat, delegations),
          'Deposit and delegate',
          undefined,
          {
            give: {
              Stake: NatAmountShape,
            },
          },
        );

        return vowTools.watch(invP);
      },

Copy link
Member

Choose a reason for hiding this comment

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

Aside - I was surprised to see we don't need to do seat.exit() (nor seat.tryExit() in the tests).

const overrides = {};
for (const invMakers of invitationMakers) {
// remove '__getInterfaceGuard__', '__getMethodNames__'
const names = getMethodNames(invMakers).filter(n => !n.startsWith('__'));
Copy link
Member

@0xpatrickdev 0xpatrickdev Sep 6, 2024

Choose a reason for hiding this comment

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

Nb: should we move this to @agoric/internal and call it getPublicMethodNames?

Copy link
Member Author

Choose a reason for hiding this comment

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

no opinion here. WDYT @mhofman ?

Copy link
Member Author

@turadg turadg Sep 6, 2024

Choose a reason for hiding this comment

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

turadg and others added 4 commits September 6, 2024 08:51
- Takes two or more InvitationMaker exos and combines them into a new one.
- Useful for combining exos that are already instantiated
@turadg turadg force-pushed the 9796-continuing-ica branch from 5b70d25 to 2689372 Compare September 6, 2024 16:00
@turadg turadg requested a review from 0xpatrickdev September 6, 2024 16:01
@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label Sep 6, 2024
amount,
) => {
console.log('depositAndDelegate', account, seat, validator, amount);
// TODO deposit the amount
Copy link
Member

Choose a reason for hiding this comment

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

Ticket # would be nice, but thanks for including this!

@mergify mergify bot merged commit 1976c50 into master Sep 6, 2024
90 checks passed
@mergify mergify bot deleted the 9796-continuing-ica branch September 6, 2024 16:34
},
);

return vowTools.watch(invP);
Copy link
Member

Choose a reason for hiding this comment

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

Thinking on this more, I don't think we need vowTools.watch here. We can expect the promise for an Invitation to resolve promptly - it's just the offer handler that needs to return a vow.

If we feel we should return a vow here, we should also make this change in the orchAccount exos. Currently, we're always returning a promise.

The only instance coming to mind where it'd be helpful to return a vow is if a developer wanted to call an invitationMaker from inside a flow - it'd need to be a vow to cross the membrane. I'm not sure how common this will be - we don't have any examples that need this currently.

Copy link
Member Author

@turadg turadg Sep 7, 2024

Choose a reason for hiding this comment

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

wanted to call an invitationMaker from inside a flow

I think that's what motivated the vow: an earlier version of this branch was calling between guest fns. But definitely not needed now. Thanks for pointing it out.

We can expect the promise for an Invitation to resolve promptly

I believe "promptly" means in "in the same run". zcf.makeInvitation calls out to another vat so I don't think it can be in the same run.

const invitationHandle = storeOfferHandler(offerHandler);
const invitationP = E(zoeInstanceAdmin).makeInvitation(
invitationHandle,

mergify bot added a commit that referenced this pull request Sep 7, 2024
refs: #10023

## Description
@0xpatrickdev points out it doesn't need to return a vow

### Security Considerations
n/a
### Scaling Considerations
n/a

### Documentation Considerations
n/a

### Testing Considerations
Should not affect tests

### Upgrade Considerations
undeployed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

async-flow contracts: patterns for shared state and continuing invitations
2 participants