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

Durable contracts #1255

Merged
merged 6 commits into from
Dec 5, 2024
Merged

Durable contracts #1255

merged 6 commits into from
Dec 5, 2024

Conversation

Chris-Hibbert
Copy link
Collaborator

@Chris-Hibbert Chris-Hibbert commented Dec 3, 2024

closes: #1126

Description

Collect the details on creating durable contracts in one place. Update to cover use of meta with start and stop recommending prepare for this.

Also provide some cross-linking between various descriptions of the approach.

Copy link

cloudflare-workers-and-pages bot commented Dec 3, 2024

Deploying documentation with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0335f86
Status: ✅  Deploy successful!
Preview URL: https://8944fae8.documentation-7tp.pages.dev
Branch Preview URL: https://durablecontracts.documentation-7tp.pages.dev

View logs

@Chris-Hibbert
Copy link
Collaborator Author

Lint is failing and claiming there are warnings for two files. When I run yarn prettier locally, it doesn't find any issues.

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.

Fixing the links is important.

The rest of the comments are just suggestions.


The first step toward contracts that can be upgraded is storing all the data that a later incarnation will
need. This means putting relevant state in
[Baggage](http://localhost:5173/guides/zoe/contract-upgrade.html#baggage), and ensuring that reachable objects
Copy link
Member

Choose a reason for hiding this comment

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

some localhost links crept in. And "links should ... exclude the file extension" per contributing docs on writing links

Suggested change
[Baggage](http://localhost:5173/guides/zoe/contract-upgrade.html#baggage), and ensuring that reachable objects
[Baggage](/guides/zoe/contract-upgrade#baggage), and ensuring that reachable objects

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Our persistent objects are designed to encapsulate their state, and can present different facets to different
clients to distinguish different aspects of authority. `zone.exoClass()` defines a kind with a single facet,
while `zone.exoClassKit()` defines a kind with multiple facets. (Here are some relevant [naming
conventions](https://docs.agoric.com/guides/ertp/#method-naming-structure).)
Copy link
Member

Choose a reason for hiding this comment

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

use relative links to facilitate local preview:

Suggested change
conventions](https://docs.agoric.com/guides/ertp/#method-naming-structure).)
conventions](/guides/ertp/#method-naming-structure).)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

The result of starting a contract includes the right to upgrade the contract instance. A call to [E(zoe).startInstance(...)](/reference/zoe-api/zoe.md#e-zoe-startinstance-installation-issuerkeywordrecord-terms-privateargs) returns a record of several objects that represent different levels of access.
The `publicFacet` and `creatorFacet` are defined by the contract.
The `adminFacet` is defined by Zoe and includes methods to upgrade the contract.
The return value when starting a contract includes a capability that conveys the right to upgrade
Copy link
Member

Choose a reason for hiding this comment

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

"a capability that conveys the right" seems wordy; how about...

Suggested change
The return value when starting a contract includes a capability that conveys the right to upgrade
The return value when starting a contract includes a capability to upgrade

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay

The return value when starting a contract includes a capability that conveys the right to upgrade
the contract instance. A call to
[E(zoe).startInstance(...)](/reference/zoe-api/zoe.md#e-zoe-startinstance-installation-issuerkeywordrecord-terms-privateargs)
returns a record of several objects that carry different powers. The `publicFacet` and
Copy link
Member

Choose a reason for hiding this comment

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

The change from "represent different levels of access" to "carry different powers" seems to make things more obscure. I think typical readers are much more likely to be familiar with levels access than "powers".

Perhaps "... returns a kit of facets; that is: a record of several objects that represent different ways to access the contract instance" with kit and facets linked to glossary entries.

Another option would be to leave most of that to the startInstance docs: "Recall that E(zoe).startInstance(...) returns a record including an adminFacet property. This adminFacet includes methods to upgrade the contract instance."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like "levels of access". "kit of facets" (with links) works for me.

Comment on lines 68 to 69
`start`. (We used to indicate upgradability by using `prepare` instead of `start`, but that
approach is deprecated.)`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`start`. (We used to indicate upgradability by using `prepare` instead of `start`, but that
approach is deprecated.)`
`start`. (_We used to indicate upgradability by using `prepare` instead of `start`, but that
approach is deprecated._)`

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines 61 to 62
Fields of the object returned by the `init` function become fields of the persistent state. (These cannot
currently be changed on upgrade, though we're considering relaxing that restriction.) Within methods they can
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Fields of the object returned by the `init` function become fields of the persistent state. (These cannot
currently be changed on upgrade, though we're considering relaxing that restriction.) Within methods they can
Fields of the object returned by the `init` function become fields of the persistent state. (_These cannot
currently be changed on upgrade, though we're considering relaxing that restriction._) Within methods they can

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


### Methods: defining behavior

The methods argument of `exoClass()` is a bag of methods, written in [concise method
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The methods argument of `exoClass()` is a bag of methods, written in [concise method
The methods argument of `exoClass()` is a collection of methods, written in [concise method

or "... record of methods ..."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done. I like "record" here.

syntax](https://github.com/Agoric/agoric-sdk/wiki/Arrow-Function-Style#far-classes-do-not-use-arrow-function-style).
`exoClass()` defines a single facet.

The methodKit parameter to `exoClassKit` is a record of labelled bags of methods. Each label defines a facet
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The methodKit parameter to `exoClassKit` is a record of labelled bags of methods. Each label defines a facet
The methodKit parameter to `exoClassKit` is a record where each value is a collection of methods. Each property defines a facet

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

enhanced


[Zone](http://localhost:5173/glossary/#zone) provides an interface for defining objects and classes that
supports both ephemeral objects (allocated on the heap), and durable objects that can persist and that
SwingSet will page in or out on demand.
Copy link
Member

Choose a reason for hiding this comment

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

Is "SwingSet" in the reader's vocabulary at this point? Link to glossary entry?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

result matches before invoking the method. When a guard is written this latter way, the method doesn't have to
be `async`. In both cases, the method doesn't have to check for compliance with the guard.

[Shapes can specify](https://endojs.github.io/endo/interfaces/_endo_patterns.PatternMatchers.html) simple
Copy link
Member

Choose a reason for hiding this comment

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

I made a patterns cheat-sheet at https://docs.agoric.com/reference/zoe-api/zoe-contract-facet.html#proposal-shapes, but that context is specialized to proposal shapes. hm.

Perhaps using glossary entries for Pattern and Shape would help. Perhaps I should do that in a follow-up PR.

@Chris-Hibbert Chris-Hibbert requested a review from dckc December 5, 2024 00:56
@Chris-Hibbert Chris-Hibbert merged commit 537427b into main Dec 5, 2024
6 checks passed
@Chris-Hibbert Chris-Hibbert deleted the durableContracts branch December 5, 2024 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

describe upgrade contract meta info
2 participants