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(run-protocol): RUNstake contract only, without payoff from rewards #4741

Merged
merged 43 commits into from
Mar 29, 2022

Conversation

dckc
Copy link
Member

@dckc dckc commented Mar 4, 2022

refs: #3788

Description

getRUN contract only, without rewards integration (#4244) and without integration with bootstrap, front end / wallet, etc.

Security Considerations

We plan to grant this contract access to mint RUN.

Documentation Considerations

Performance Considerations

  • re-consider diagnostic value of checkAccountState(address, lienDelta) given performance implications noted by @JimLarson

Testing Considerations

@dckc dckc force-pushed the dc-getRUN-contract branch 4 times, most recently from 13992d2 to 586e16f Compare March 5, 2022 00:05
@dckc dckc changed the title getRUN: contract only getRUN: contract only, without interest Mar 5, 2022
@dckc
Copy link
Member Author

dckc commented Mar 5, 2022

@Chris-Hibbert @dtribble @turadg What do you think about landing this much; that is; without interest, and without integration with the front end and bootstrap?

@dckc
Copy link
Member Author

dckc commented Mar 5, 2022

What made me think of landing this much is: it basically handles the cases that @rowgraus and @JimLarson and I worked out in a spreadsheet in December:

I'm going to take a break and think it over...

Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

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

Oops. I started looking at this, and noticed a few things. Sending them on so they don't get lost.

Sorry I didn't make more progress with the review.

Comment on lines 53 to 55
* @returns {Promise<Payment>}
*/
const mintZCFMintPayment = (zcf, zcfMint, amountToMint) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why does addReturnableLien want to return a payment directly, rather than adding an allocation to a seat so Zoe can manage offer safety and invitations and such?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know. It could be left over from when there were to kinds of attestations. I got rid of the timed attestation code and tested that the remaining stuff passes its tests but I haven't gotten as far as I'd like getting down to only the essential code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I figured it out and added a comment:

 * To support `makeAttestation`, we directly mint attestation payments.
 * We still use a ZCFMint because returning attestations is done
 * through Zoe offers.

@dckc dckc changed the title getRUN: contract only, without interest RUNstake: contract only, without interest Mar 14, 2022
@dckc dckc force-pushed the dc-getRUN-contract branch 2 times, most recently from 016514c to 3c522e0 Compare March 17, 2022 20:33
@dckc dckc changed the title RUNstake: contract only, without interest RUNstake: contract only, without payoff from rewards Mar 18, 2022
@dckc dckc force-pushed the dc-getRUN-contract branch 7 times, most recently from 6baba27 to aadbc35 Compare March 21, 2022 16:10
*
* @type {<K, V>(store: Store<K, V>, key: K, thunk: () => V) => V}
*/
const getOrElse = (store, key, make) => {
Copy link
Member

Choose a reason for hiding this comment

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

is this something Store itself will support @FUDCo ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I confess I don't understand what you are asking.

Copy link
Member

Choose a reason for hiding this comment

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

This PR defines a getOrElse function that lets the caller say "give me the value for this key from the store, or if it's not there define it in the store". That seems generally useful so I asked if the Store API might offer that in the future. If not the MapStore type then perhaps a helper like this within @agoric/store ?

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 there are any plans for anything like this. The authority to consult would be @erights, who I tentatively predict, on the basis of no knowledge whatsoever on my part, will have a subtle and nuanced argument why doing this is would be a bad idea.

Copy link
Member

Choose a reason for hiding this comment

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

@dtribble I remember you had a good verb to mean something like this getOrElse. Do you remember what it was?

@FUDCo I will try to avoid taking that as a challenge ;) .

I would be fine with a helper. I am reluctant to extend the type itself, but I do not currently have any principled objection. Just a general sense that the object's own API should remain reasonably small and any addition must pay for itself.

Whether helper or method, should the make function take the key as a parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

should the make function take the key as a parameter?

Interesting idea. I can see some utility. The design here is inspired by ELib, where fetch/2 took a Thunk, which takes no args.

For reference, monte adopted the same design:
https://monte.readthedocs.io/en/latest/runtime.html#safeScope.Map.fetch
https://github.com/monte-language/typhon/blob/master/typhon/objects/collections/maps.py#L138

Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

Did a cursory review

@@ -0,0 +1,55 @@
// The proposal is not allowed to include any keys other than these,
Copy link
Member

Choose a reason for hiding this comment

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

looks like this was meant to be part of a doc comment for assertOnlyKeys

* @param {Amount} fromGains
* @param {Keyword} key
*/
export const transfer = (fromSeat, toSeat, fromLoses, fromGains, key) => {
Copy link
Member

Choose a reason for hiding this comment

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

+1 to pulling this out in a shared module. Heads up there will be some merge conflicts after #4877 (e.g. transfer -> stageDelta atm)

@@ -442,3 +443,163 @@ export const startRewardDistributor = async ({
);
};
harden(startRewardDistributor);

/**
* @typedef { import('@endo/eventual-send/').Unpromise<T> } Unpromise<T>
Copy link
Member

Choose a reason for hiding this comment

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

Unpromise is deprecated (in agoric-sdk before those changes were globbered). Instead use Awaited built into TS

// TODO: remove publicFacet wart
const attestBrand = await E(att.publicFacet).getBrand();

const paramManager = await makeRunStakeParamManager(
Copy link
Member

Choose a reason for hiding this comment

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

#4868 will make it so you don't have to hold the full paramManager or check that electorate matches.

*
* @type {ReallocateWithFee}
*/
const reallocateWithFee = (fee, fromSeat, otherSeat = undefined) => {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

my eyes are getting blurry. I'm struggling to see the motivation or something.

Copy link
Member

Choose a reason for hiding this comment

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

sorry, I considered being more specific and should have been. The link shows an in-flight PR where reallocateWithFee has been expanded in scope to mintAndReallocate. I thought you might want to consider the same for parity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ugh. I'm struggling to get this change right.

*
* @param {ZCF} zcf
* @param {ZCFSeat} startSeat
* @param {ReturnType<import('./runStakeManager.js').makeRunStakeManager>} manager
Copy link
Member

Choose a reason for hiding this comment

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

consider defining RunStakeManager in its file and importing that.

this may become standard practice for makeFoo functions.

const asset = async ref =>
new URL(await metaResolve(ref, import.meta.url)).pathname;

t.log('bundling...', contractRoots);
Copy link
Member

Choose a reason for hiding this comment

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

How I wish we could cache bundling builds.

@Chris-Hibbert
Copy link
Contributor

Dan asked

What do you think about landing this much; that is; without interest, and without integration with the front end and bootstrap?

I don't mind omitting frontend integration from first merge.

I have found integration with bootstrap to be informative, and based on conversations with you, I've attempted to make test setup consistent with it, which has made that integration valuable to do early.

Interest is straightforward.

But parameter governance and interest charging and other library support have been evolving quickly. Perhaps merging early eases migration support enough to be worth the added pain. If it's not ready for use in the economy, the obvious step is to not activate in bootstrap.

dckc and others added 20 commits March 29, 2022 16:14
 - makeAttestationIssuerKit, makeAttestationFacets
 - await attestation payment before commit
 - makeAttestationFacets: clean up type details
    via mintZCFMintPayment
 - rename zcfMint -> attMint
 - MakeZCFMint is missing? add type for getIssuerRecord return
 - keep getLiened after all, since it's used so much in tests,
   but don't expose via runStake creatorFacet nor AttestationMaker
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

Big one!

@dckc dckc changed the title RUNstake: contract only, without payoff from rewards feat(run-protocol): RUNstake contract only, without payoff from rewards Mar 29, 2022
@dckc dckc added the automerge:squash Automatically squash merge label Mar 29, 2022
@mergify mergify bot merged commit 52f60eb into master Mar 29, 2022
@mergify mergify bot deleted the dc-getRUN-contract branch March 29, 2022 21:41
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.

5 participants