Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
303 stars 191 forks source link

feat(vow): Support reliable retry-send #9608

Open erights opened 3 days ago

erights commented 3 days ago

closes: #XXXX refs: #XXXX

Description

Retry idempotent eventual sends with reliable durable result vows that mask upgrade trauma.

The goal here is to support something like E(bob).foo(carol) but with several differences:

In this first PR, you can only express a retry-send of const p = E(bob).foo(carol); by saying

const v = retry(bob, 'foo', [carol]);

but the intention is that the next PR will provide a more natural E-like syntax.

Note we already have variations on E, like heapVowE that is scoped to the heap zone and have extra static methods. We can make similar variants of E that are scoped to the durable zone and have an extra retry method. Suppose this E variant is called durableVowE.

We already have static methods on E that express variants of E, such as E.sendOnly(bob).foo(carol) saying to just send the message to bob as a one-way send without any result. Similarly, I imagine that the next PR may provide something like

const v = durableVowE.retry(bob).foo(carol);

But hopefully we can invent something shorter but just as clear.

The internal API also provides a means to cancel the retry loop, so it doesn't go on forever after it is no longer relevant. Using the precedent of E taking an options bag as second argument, I imagine something like

const v = durableVowE.retry(bob, { cancelToken }).foo(carol);

once we have adapted a cancellation token proposal such as https://github.com/tc39/proposal-cancellation . So this would be farther into the future.

Security Considerations

unpredicable resends of non-idempotent operations may be accidents threatening integrity. We currently have no in-band way to mark an operation as idempotent, and so no current means to check the consistency of these assumptions.

Scaling Considerations

Perpetual retries threaten availability and scalability. Though not much if they are only triggered by upgrade. Nevertheless, it would be nice to better support cancellation.

Documentation Considerations

Will need to be explained, including the caution to avoid retry-send on non-idempotent operations, which requires explaining idempotence.

Testing Considerations

As with the current state of async-flow, this only uses the lightweight low-fidelity upgrade testing framework. See https://github.com/Agoric/agoric-sdk/issues/9303

Upgrade Considerations

The point. Retry-sent messages will be retried across upgrade at either end until they settle to something else, masking upgrade trauma. Rather than a promise, a durable retry-send returns a reliable durable vow that itself survives upgrades.

cloudflare-pages[bot] commented 3 days ago

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3152f63
Status: ✅  Deploy successful!
Preview URL: https://96503a3a.agoric-sdk.pages.dev
Branch Preview URL: https://markm-retrier.agoric-sdk.pages.dev

View logs

erights commented 11 hours ago

See https://github.com/Agoric/agoric-sdk/pull/9621 for an experiment of a different approach.