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

chore(run-protocol): improve comments and naming #4764

Merged
merged 4 commits into from
Mar 10, 2022

Conversation

turadg
Copy link
Member

@turadg turadg commented Mar 8, 2022

Description

  • Fixes a state error
  • replace 'run' with 'debt' where safe to do
  • add some comments

Security Considerations

--

Documentation Considerations

Gotcha documented in https://github.com/Agoric/agoric-sdk/wiki/Typescript-using-JSDoc/

Testing Considerations

--

@turadg turadg requested a review from dckc March 8, 2022 17:00
@turadg turadg force-pushed the ta/fixup-vault-state-type branch from 6f7b043 to b484af5 Compare March 8, 2022 17:49
@turadg turadg changed the title chore(run-protocol): fix vault state def chore(run-protocol): improve comments and naming Mar 8, 2022
@Tartuffo Tartuffo added audit-restival Purple Team review of RUN Protocol Inter-protocol Overarching Inter Protocol labels Mar 8, 2022
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.

looks good. just a few minor comments to consider.

@@ -142,8 +144,8 @@ export const makeInnerVault = (

// Two values from the same moment
interestSnapshot: manager.getCompoundedInterest(),
// @ts-expect-error until https://github.com/Agoric/agoric-sdk/pull/4736
runSnapshot: AmountMath.makeEmpty(runBrand),
/** @type {any} cast */
Copy link
Member

Choose a reason for hiding this comment

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

This contract only handles fungible debt, right? Have you tried declaring the debtBrand about (around line 120) to Brand<'nat'> to see if this cast becomes unnecessary? I wonder if getIssuerRecord gives you the assetKind so that you could do a runtime check to be sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Brand is not parameterized yet in master. #4736 will fix this and the expect-error will error to be cleaned up.

Comment on lines +296 to 297
// XXX 'run' is implied by the brand in the amount
debtSnapshot: { run, interest },
Copy link
Member

Choose a reason for hiding this comment

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

perhaps rename things to { amount, interest }?

Copy link
Member Author

@turadg turadg Mar 10, 2022

Choose a reason for hiding this comment

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

naming and organization to be cleaned up in #4482

Comment on lines -621 to +624
runMint.mintGains(harden({ RUN: toMint }), vaultSeat);
mint.mintGains(harden({ RUN: toMint }), vaultSeat);
Copy link
Member

Choose a reason for hiding this comment

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

not ready to change the RUN keyword yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

No that's queued up in #4800 and blocked on a design decision for what it will be.

/**
* Public API of the vault.
*
* @see {InnerVault} for the internal API it wraps.
Copy link
Member

Choose a reason for hiding this comment

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

That's perhaps expedient, but for actual clients of this contract, referring them to the inner guts doesn't seem like the way to go.

mostly thinking out loud... I suppose it's more relevant for agoric.com/documentation , but I have hopes of generating that from this.

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 agree and see that as out of scope. We need a bigger discussion around naming of contract facets.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not talking about the name of the facets. I'm talking about information hiding, or lack thereof. Clients of this API should not need to be aware of the inner API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohhh. Just this jsdoc @see.

I'm not sure. Developers of agoric-sdk should know about it. End users of a GUI or REPL shouldn't (and won't see the jsdoc). What other case is there? Developers building other contracts that compose the vaultFactory contract? In that case I think it behooves them to understand the inner/outer relationship (e.g. to understand how transfers work).

runMint.burnLosses,
debtMint.burnLosses,
Copy link
Member

Choose a reason for hiding this comment

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

debtMint is a bit nicer than bare mint.

@turadg turadg added the automerge:squash Automatically squash merge label Mar 10, 2022
@mergify mergify bot merged commit 0ef67d0 into master Mar 10, 2022
@mergify mergify bot deleted the ta/fixup-vault-state-type branch March 10, 2022 17:10
dtribble pushed a commit that referenced this pull request Mar 13, 2022
* chore(run-protocol): improve comments and naming

* refactor(run-protocol): use key encoding from @agoric/store

* refreshLoanTracking -> updateDebtAccounting

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit-restival Purple Team review of RUN Protocol automerge:squash Automatically squash merge Inter-protocol Overarching Inter Protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants