Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
327 stars 206 forks source link

Report bridge inbound result to cosmic-swingset #8441

Open mhofman opened 1 year ago

mhofman commented 1 year ago

What is the Problem Being Solved?

Currently a bridge inbound (cosmos messages delivered into swingset) is an operation that does not return a result. From the cosmic-swingset side, the message is queued and forgot about. The bridge is a multiplexed channel, and handlers for each channel can actually return a promise for the result, but it's currently dropped to the floor by the bridge implementation.

For multiple reasons, we would like for the result of the bridge handlers to be reported back to cosmic swingset, or if no handler is registered, and error to be reported. In particular:

Description of the Design

Like in #6741, add a special channel used to communicate results between the bridge vat and cosmic swingset. To avoid allocating and managing a reference ID, we could use the whole action context added in #7102.

The complication come in the durability of result pipeline. The bridge vat can use a durable watcher, but that's not resilient to the handler's vat getting upgraded. Alternatively, the bridge vat could pass a promise watcher object along with the reference, but that requires an upgrade of the handler vats to start using.

Security Considerations

None

Scaling Considerations

None

Test Plan

TBD

Upgrade Considerations

This requires an upgrade to the bridge vat itself, which would likely be performed as one of the core proposals, and must be ordered first through #8370. If we enforce that core proposals must succeed, this specific one must report a result somehow. @warner suggested that buildRootObject of the upgraded bridge vat could generate and "upgrade" bridge result as last step, and that the check for successful core eval execution could be satisfied by such a special message being received during execution. Since these would run in the same block, we can use a memory only flag.

mhofman commented 1 month ago

The complication come in the durability of result pipeline. The bridge vat can use a durable watcher, but that's not resilient to the handler's vat getting upgraded. Alternatively, the bridge vat could pass a promise watcher object along with the reference, but that requires an upgrade of the handler vats to start using.

We have experienced some UnhandledPromiseRejectionWarning in the bridge vat when upgrading the smart wallet for outstanding bid offers. See #10111

These days we have vows that solve that problem. The smart wallet bridge handler would return a vow, that can be watched by the bridge vat.