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: add the ability for a contract to get a synchronous seat #1389

Merged
merged 4 commits into from
Aug 9, 2020

Conversation

Chris-Hibbert
Copy link
Contributor

zcf.addEmptySeat() would return a zcfSeat that the contract could use
to hold allocations.

untested

@Chris-Hibbert Chris-Hibbert force-pushed the syncEmptySeat branch 2 times, most recently from c5379cb to 9db00c7 Compare August 7, 2020 22:31
Copy link
Contributor

@katelynsills katelynsills left a comment

Choose a reason for hiding this comment

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

I think we don't want to burn the associated assets, and will need a way to get the payouts. I think the seats made this way should be indistinguishable from other seats after being made - there should be an associated UserSeat that gets made.

const instanceAdmin = instanceToInstanceAdmin.get(instance);
instanceAdmin.removeZoeSeatAdmin(seatAdmin);

// burn the holdings to keep Zoe's book straight
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we ever want to burn the holdings - the contract or someone else probably wants them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay. Made available to contract. This needs a test.


const { notifier, updater } = makeNotifierKit();

const seatAdmin = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use the same seatAdmin code and not have duplication here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -209,6 +209,34 @@ function makeZoe(vatAdminSvc) {
brandToPurse.init(brand, E(issuer).makeEmptyPurse());
}
}),
makeEmptySeat: (keyword, initialAllocation) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is an empty seat, why does it have an initial allocation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dropped


E(zoeInstanceAdmin)
.makeEmptySeat(keyword, initialAllocation, proposal)
.then(({ seatAdmin: zoeSeatAdmin, seatData }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's call this the ZoeSeatAdmin in the returned object too. It's called that in Zoe.

});
const { zcfSeat, zcfSeatAdmin } = makeSeatAdmin(
allSeatStagings,
zoeSeatAdminPromiseKit.promise,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, since this is remote anyways, and we need to call E(zoeSeatAdmin), we can use a promise. Cool!

@@ -225,6 +241,33 @@ export function buildRootObject() {
issuerTable.getIssuerRecordByIssuer(issuer).brand,
getAmountMath,
makeZCFMint,
addEmptySeat: keyword => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is there a keyword?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's gone now.

zcf.addEmptySeat() would return a zcfSeat that the contract could use
to hold allocations.

untested
drop keyword parameter in addEmptySeat()
extract makeZoeSeatAdminKit, use it for emptySeat, too.
rename zcf seat construction to use 'Kit'
@@ -164,6 +166,20 @@ export function buildRootObject() {
return zcfMint;
};

function updateNotiferFrom(updater, notifier, nextCount = undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you just use updateFromNotifier in packages/notifier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, of course.

@@ -164,6 +166,20 @@ export function buildRootObject() {
return zcfMint;
};

function updateNotiferFrom(updater, notifier, nextCount = undefined) {
notifier.getUpdateSince(nextCount).then(
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this notifier actually a reference to a remote notifier, the one in the zoe vat? If so, this would need to be E(notifier).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moot.

erights
erights previously requested changes Aug 9, 2020
@@ -64,7 +64,7 @@

/**
* Make the ZCF seat and seat admin
* @callback MakeSeatAdmin
* @callback MakeZcfSeatAdmin
Copy link
Member

Choose a reason for hiding this comment

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

MakeZcfSeatAdminKit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@@ -207,35 +230,24 @@ function makeZoe(vatAdminSvc) {
brandToPurse.init(brand, E(issuer).makeEmptyPurse());
}
}),
makeEmptySeat: (initialAllocation, proposal) => {
Copy link
Member

Choose a reason for hiding this comment

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

I like the generality of leaving it up to zcf to determine the initialAllocation and proposal. But in that case, this method needs a new name.

Copy link
Member

Choose a reason for hiding this comment

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

I see it returns a kit so its name should reflect that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makeOfferlessSeat is my starting point.

const offerResultPromiseKit = makePromiseKit();
const exitObjPromiseKit = makePromiseKit();
const { notifier, updater } = makeNotifierKit();
let currentAllocation = initialAllocation;

const instanceAdmin = instanceToInstanceAdmin.get(instance);

/** @type {ZoeSeatAdmin} */
Copy link
Member

Choose a reason for hiding this comment

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

ZoeSeatAdminKit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved

@@ -207,35 +230,24 @@ function makeZoe(vatAdminSvc) {
brandToPurse.init(brand, E(issuer).makeEmptyPurse());
}
}),
makeEmptySeat: (initialAllocation, proposal) => {
Copy link
Member

Choose a reason for hiding this comment

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

Add a declaration of makeEmptySeat (or whatever it's called) to the ZoeInstanceAdmin type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup

brandToPurse,
promises = {},
) => {
const payoutPromiseKit = promises.payout || makePromiseKit();
Copy link
Member

Choose a reason for hiding this comment

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

This payout option is unused. Is it needed?

import { assert } from '@agoric/assert';
import { E } from '@agoric/eventual-send';

export const makeZoeSeatAdminKit = (
Copy link
Member

Choose a reason for hiding this comment

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

Good. Pulling this out into a separately reusable function made everything better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not quite everything, but it did help a lot.

@@ -256,15 +258,44 @@ export function buildRootObject() {
issuerTable.getIssuerRecordByIssuer(issuer).brand,
getAmountMath,
makeZCFMint,
addEmptySeat: () => {
Copy link
Member

Choose a reason for hiding this comment

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

Does addEmptySeat sound like it's adding one that already exists?

Should it be makeEmptySeatKit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't much like the name here for a user-facing method, but it fits our model for a makeFooKit, so done.

improved type annotations
rename makeEmptySeat to makeOfferlessSeat
don't return the zcfSeatAdmin to the contract
@Chris-Hibbert Chris-Hibbert dismissed stale reviews from erights and katelynsills August 9, 2020 23:53

This is good enough to merge to the branch.

@Chris-Hibbert Chris-Hibbert self-assigned this Aug 9, 2020
@Chris-Hibbert Chris-Hibbert merged commit 32883ab into new-zoe-spike-2 Aug 9, 2020
@Chris-Hibbert Chris-Hibbert deleted the syncEmptySeat branch August 9, 2020 23:55
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.

3 participants