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

fix(notifier): Make makeNotifierFromAsyncIterable lossy #5695

Closed
wants to merge 5 commits into from

Conversation

gibson042
Copy link
Member

@gibson042 gibson042 commented Jun 30, 2022

Fixes #5413

Description

Separate iterable consumption from getUpdateSince peeking.

Security Considerations

Because the consumption is now greedy, there is a risk of getting stuck in a produce–consume pattern where each step enqueues a subsequent turn and forward progress halts. But I don't think any of our code fits that pattern, and at any rate I don't know if any mitigation is even possible.

Documentation Considerations

n/a

Testing Considerations

WIP

@gibson042 gibson042 marked this pull request as draft June 30, 2022 17:00
);
const update1 = await notifier.getUpdateSince();
const governorSubscription = await E(publicFacet).getSubscription();
const governorUpdates = await E(governorSubscription)[Symbol.asyncIterator]();
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not clear on why such use of makeNotifierFromAsyncIterable for testing in governance and run-protocol causes lockup (e.g., https://github.com/Agoric/agoric-sdk/runs/7138160731?check_suite_focus=true : "unitTests › paramGovernance › change multiple params … Error: Promise returned by test never resolved"). It could be related to use of a fake timer, or could be an actual bug. But the tests don't appear to have been expecting lossyness, so I feel mostly fine about direct use of await … next().

Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned that we don't understand why it's failing. If it's isolated to these cases then I can agree to sweep it under the rug as something not worth getting to the bottom of.

I'm not sure it's isolated though. #5704 attempts to use makeNotifierFromAsyncIterable for notifiers (necessary for #5386 ) and it also hangs the same way.

next: () => {
const resultP = E.get(tailP).head;
next: async () => {
const resultP = await E.get(tailP).head;
Copy link
Member Author

Choose a reason for hiding this comment

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

This one might not be necessary, but it does seem problematic to eagerly to let an eager consumer (such as the new makeNotifierFromAsyncIterable) read an arbitrarily long sequence of results that might never materialize.

Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

Recapping from our meeting per request:

gibson042 added a commit that referenced this pull request Jul 8, 2022
@gibson042
Copy link
Member Author

Superseded by #5737.

@gibson042 gibson042 closed this Jul 8, 2022
gibson042 added a commit that referenced this pull request Jul 8, 2022
Cherry-picked from gh-5413-lossy-makeNotifierFromAsyncIterable.
See #5695 .
gibson042 added a commit that referenced this pull request Jul 8, 2022
Eager consumption led to infinite loops; see
#5695 for context.
gibson042 added a commit that referenced this pull request Jul 8, 2022
Cherry-picked from gh-5413-lossy-makeNotifierFromAsyncIterable.
See #5695 .
gibson042 added a commit that referenced this pull request Jul 8, 2022
Eager consumption led to infinite loops; see
#5695 for context.
mergify bot added a commit that referenced this pull request Jul 14, 2022
* fix(notifier): Make makeAsyncIterableFromNotifier lossy

Cherry-picked from gh-5413-lossy-makeNotifierFromAsyncIterable.
See #5695 .

* fix(notifier): Revert "Make makeAsyncIterableFromNotifier lossy"

Eager consumption led to infinite loops; see
#5695 for context.

* feat(notifier): Add makeNotifierFromSubscriber

Fixes #5413

* test(notifier): Update per code review

* chore(notifier): Resolve lint warnings

* fix(notifier): Align makeNotifierFromSubscriber with makeNotifierKit

getUpdateSince() always consults the source subscribeAfter() rather than
using a possibly-stale local cache.

* fix master merge

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Turadg Aleahmad <turadg@agoric.com>
turadg added a commit that referenced this pull request Jul 14, 2022
* fix(notifier): Make makeAsyncIterableFromNotifier lossy

Cherry-picked from gh-5413-lossy-makeNotifierFromAsyncIterable.
See #5695 .

* fix(notifier): Revert "Make makeAsyncIterableFromNotifier lossy"

Eager consumption led to infinite loops; see
#5695 for context.

* feat(notifier): Add makeNotifierFromSubscriber

Fixes #5413

* test(notifier): Update per code review

* chore(notifier): Resolve lint warnings

* fix(notifier): Align makeNotifierFromSubscriber with makeNotifierKit

getUpdateSince() always consults the source subscribeAfter() rather than
using a possibly-stale local cache.

* fix master merge

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Turadg Aleahmad <turadg@agoric.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

notifier returned by makeNotifierFromAsyncIterable is lossless
2 participants