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(zoe): caretaker-style revocable, ownable #8745

Merged
merged 12 commits into from
Feb 5, 2024

Conversation

erights
Copy link
Member

@erights erights commented Jan 12, 2024

closes: #XXXX
refs: #8020 #8517 #2070

Description

Alternative to #8020 and #8517

Unlike #8020 provides a caretaker-style revoker, which is a much better base for building ownables

Unlike #8517 provides ownables that are much easier to layer on top of existing implementations.

The basic idea of an "ownable object" is to provide general and lower level support for approximately the pattern that vaults implement manually in an adhoc manner: A ownable object is an object with a makeTransferInvitation method that revokes the object itself, in the sense of inactivating it — it no longer provides any authority. Instead, the exclusively transferable portion of its authority is encapsulated by the returned invitation, in an allegedly legible manner. That invitation can be redeemed, via an offer , for a new ownable object in which the transferable authority from the original ownable object is now exercisable.

We call this an "ownable object" since rights of ownership include

  • the right to exercise (use)
  • the right to exclusively transfer the rights of ownership
  • the right to exclude others from being able to exercise and transfer
  • the ability to legibly offer the exclusive transfer of ownership

Objects are about rights to exercise (use) and share, but not exclusive transfer, and not legibly.

ERTP is about legible exclusive transfer but not exercise.

The lifecycle of an ownable object, transmuting between an ephemeral ownable object and an invitation to get a new “equivalent” ownable object, combines all attributes together. But the attributes are never directly present at the same time. That’s why it is the lifecycle that combines these.

This notion of "ownable" and "ownership rights" has strong echoes in programming language notions of "ownership types", "linear types", "affine types", and "reference capabilities", in languages ranging from Rust to Pony to Move, enable mutable objects that can be exercised (use) and exclusive transfer, but not legibility.

However, none of these, as far as we are aware, has the two-phase lifecycle of our ownable objects. Thus, they do they provide for legibility of offers to transfer, which is crucial for secure exchange and offer safety. To produce a legible description of the transferable right (which we include in the invitation customDetails), we need to simultaneously stabilize the object, denying any further exercise until the invitation is redeemed. Otherwise, the "seller" could seem to be selling something whose value is invalidated by the seller's own further use.

See Necessity specifications for robustness

See https://groups.google.com/g/cap-talk/c/9OU9ZNoB3os/m/gXeu2zs4AgAJ?utm_medium=email&utm_source=footer for a useful real-world analogy for the two-phase ownership cycle.

Security Considerations

Must ensure that revocation really denies all further authority from the original ownable object, even from messages that are already in the air but not yet delivered.

Need to verify that the legibility can meet invitation legibility goals.

Scaling Considerations

The kind of intrinsic revocability of #8020 could provide scaling benefits of dropping bookkeeping for used-up objects such as payments. However, we are not currently pursuing that revocation plan. It is conceivable that we could do something similar with the caretaker-like revocability of this PR, but we do not currently plan to do so.

Documentation Considerations

Once ready to be used, not only should this be documented, we should be able to simplify several other APIs in ways that should make them more explainable.

Testing Considerations

First tests are included.

Upgrade Considerations

Given that these are used with the durable zone, as intended:

  • The transfer invitations have durable handlers and so are themselves durable and should survive upgrade.
  • The ownable objects themselves are defined to be durable, so they can survive upgrade if their underlying object can.

@erights erights self-assigned this Jan 12, 2024
@erights erights force-pushed the markm-ownable-kit-caretaker branch 2 times, most recently from 6d41337 to 1ed06db Compare January 12, 2024 20:41
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

I don't see any important problems.

I defer to @Chris-Hibbert to approve.

packages/vat-data/test/test-prepare-revocable.js Outdated Show resolved Hide resolved
packages/vat-data/test/test-prepare-revocable.js Outdated Show resolved Hide resolved
packages/vat-data/test/test-prepare-revocable.js Outdated Show resolved Hide resolved
packages/zoe/src/typeGuards.js Outdated Show resolved Hide resolved
@erights erights requested a review from dckc February 1, 2024 06:21
@erights
Copy link
Member Author

erights commented Feb 1, 2024

looks pretty good.

Before I approve... is this expected to be part of the developer API product? If so, I would try to generate docs and see what they look like.

@dckc
I've never done that before, but I'd love to! Where do I start?

@dckc
Copy link
Member

dckc commented Feb 1, 2024

For adding generated docs, an example to follow is

After you add stuff like that, run yarn typedoc from the top agoric-sdk directory. I think the results go in an api-doc directory.

@erights
Copy link
Member Author

erights commented Feb 2, 2024

For adding generated docs, an example to follow is

After you add stuff like that, run yarn typedoc from the top agoric-sdk directory. I think the results go in an api-doc directory.

api-docs.zip

At api-docs/modules/_agoric_zoe.src_contractSupport_prepare_ownable.html
and api-docs/modules/_agoric_zoe.src_contractSupport_prepare_revocable.html

I like it!

@erights erights force-pushed the markm-ownable-kit-caretaker branch from ac042a2 to cd4e790 Compare February 2, 2024 02:23
@erights
Copy link
Member Author

erights commented Feb 2, 2024

@dckc
I don't think I did that right. New commit coming up

@erights
Copy link
Member Author

erights commented Feb 2, 2024

api-docs.zip

Done. Now they are just in the zoe/contractSupport module. They get kinda lost in there, bit altogether it seems like the right thing to do. Opinions?

@dckc
Copy link
Member

dckc commented Feb 2, 2024

... Now they are just in the zoe/contractSupport module. They get kinda lost in there, but altogether it seems like the right thing to do. Opinions?

Yeah... I think we're at the "better than nothing" stage of developing reference docs.
I don't have any better sense of what this stuff should look like.

@erights
Copy link
Member Author

erights commented Feb 3, 2024

@dckc , do you have any remaining concerns?

@erights erights force-pushed the markm-ownable-kit-caretaker branch from ef316d3 to 512239d Compare February 4, 2024 23:18
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

I had some concerns about how this integrates with upcoming releases (cf. #8578) but it doesn't impact any existing on-chain bundles, and that seems to address these concerns to @mhofman 's satisfaction, which makes it fine by me.

@erights erights added the automerge:squash Automatically squash merge label Feb 5, 2024
@mergify mergify bot merged commit f30b379 into master Feb 5, 2024
74 checks passed
@mergify mergify bot deleted the markm-ownable-kit-caretaker branch February 5, 2024 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants