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: vowTools.allSettled #10077

Merged
merged 4 commits into from
Sep 18, 2024
Merged

feat: vowTools.allSettled #10077

merged 4 commits into from
Sep 18, 2024

Conversation

0xpatrickdev
Copy link
Member

@0xpatrickdev 0xpatrickdev commented Sep 12, 2024

Description

Security Considerations

n/a

Scaling Considerations

n/a

Documentation Considerations

Updates vow/README.md with information about VowTools

Testing Considerations

Includes unit tests

Upgrade Considerations

n/a, library code

Copy link

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

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: c3babe6
Status: ✅  Deploy successful!
Preview URL: https://d9a47cf3.agoric-sdk.pages.dev
Branch Preview URL: https://pc-all-vows-settled.agoric-sdk.pages.dev

View logs

@@ -119,27 +173,36 @@ export const prepareWatchUtils = (
}
return kit.vow;
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a path for typing this, so we can keep the existing Vow<any[]> for allVows and something like Vow<({status: 'fulfilled', value: any} | {status: 'rejected', reason: Error})[]> for allVowsSettled?

h/t @Chris-Hibbert for the suggestion: https://github.com/Agoric/agoric-sdk/pull/9902/files#r1757395986

Copy link
Member

Choose a reason for hiding this comment

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

I've given this a shot above, but it is wholly untested. Hope it helps.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, your suggestion worked! In hindsight, it was obvious 😅

packages/vow/src/watch-utils.js Outdated Show resolved Hide resolved
Comment on lines 134 to 135
/**
* @param {EVow<unknown>[]} vows
Copy link
Member

Choose a reason for hiding this comment

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

Pet peeve; the arguments are not vows, they're unknown specimens that might be vows. That's what EVow describes:

Suggested change
/**
* @param {EVow<unknown>[]} vows
/**
* @param {EVow<unknown>[]} specimens

Copy link
Member

Choose a reason for hiding this comment

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

+1. regardless of pet peeves, this is a code interpretability issue worth improving.

incidentally, since ERef is "a ref or eventually a ref" one is likely to read EVow as "a vow or eventually a vow" but it's really "ERef or Vow". We could consider some other names like EVRef or VowRef.

Copy link
Member

Choose a reason for hiding this comment

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

Thinking about this further, the type should actually be:

* @param {unknown[]} specimens

packages/vow/src/watch-utils.js Outdated Show resolved Hide resolved
@@ -119,27 +173,36 @@ export const prepareWatchUtils = (
}
return kit.vow;
Copy link
Member

Choose a reason for hiding this comment

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

I've given this a shot above, but it is wholly untested. Hope it helps.

@0xpatrickdev 0xpatrickdev marked this pull request as draft September 13, 2024 16:29
@0xpatrickdev 0xpatrickdev force-pushed the pc/all-vows-settled branch 3 times, most recently from 26a118a to baedae2 Compare September 16, 2024 18:18
@0xpatrickdev 0xpatrickdev marked this pull request as ready for review September 16, 2024 18:21
@0xpatrickdev 0xpatrickdev added the force:integration Force integration tests to run on PR label Sep 16, 2024
packages/vow/src/tools.js Outdated Show resolved Hide resolved
@@ -77,6 +77,67 @@ const { watch, makeVowKit } = prepareVowTools(vowZone);
// Vows and resolvers you create can be saved in durable stores.
```

## VowTools
Copy link
Member

Choose a reason for hiding this comment

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

👏 !

packages/vow/src/tools.js Outdated Show resolved Hide resolved
@0xpatrickdev 0xpatrickdev force-pushed the pc/all-vows-settled branch 2 times, most recently from 82c4902 to 2bf7f89 Compare September 17, 2024 14:58
packages/vow/README.md Outdated Show resolved Hide resolved
Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

Some clarifications for the README.md. I haven't looked further yet.

packages/vow/README.md Outdated Show resolved Hide resolved
packages/vow/README.md Outdated Show resolved Hide resolved
packages/vow/README.md Outdated Show resolved Hide resolved
packages/vow/README.md Outdated Show resolved Hide resolved
packages/vow/README.md Outdated Show resolved Hide resolved
@0xpatrickdev 0xpatrickdev removed the force:integration Force integration tests to run on PR label Sep 17, 2024
@michaelfig michaelfig changed the title feat: vowTools.allVowsSettled feat: vowTools.allSettled Sep 18, 2024
Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

LGTM! Well done.

@0xpatrickdev 0xpatrickdev added the automerge:rebase Automatically rebase updates, then merge label Sep 18, 2024
@mergify mergify bot merged commit 6ee57ba into master Sep 18, 2024
90 checks passed
@mergify mergify bot deleted the pc/all-vows-settled branch September 18, 2024 23:15
mergify bot added a commit that referenced this pull request Sep 19, 2024
closes: #9925
refs: #9193

## Description
- This PR primarily hardens the `zoeTools` implementation for orchestrated async-flows by:
  - ensuring payments handled in `zoeTools.localTransfer` are recovered to the original seat in the event of failure or partial failure
  - providing a `zoeTools.withdrawFromSeat` retriable function to facilitate withdrawing funds from a LocalChainAccount to a User seat. Ensures all changes are rolled back in the event of partial failure.
   - using `asVow` instead of `retriable` since these operations are not idempotent
- Creates `src/fixtures/zoe-tools.contract.js` to facilitate testing error paths
- To facilitate the change, `vowTools.allVowsSettled` was implemented in `@agoric/vow`. See #10077 which this PR depends on

### Security Considerations
Improves safety around Payment handling in async-flow contracts in `@agoric/orchestration`

### Scaling Considerations
n/a

### Documentation Considerations
Updates jsdoc strings for `localTransfer` and `withdrawToSeat`. As maintainer notes for considerations around `asVow` and promptness.

### Testing Considerations
Includes tests with different failure paths previously unaccounted for.

### Upgrade Considerations
Unreleased code that will be part of an npm release
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.

3 participants