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

fix(governance): some governance invitations use proposal patterns #7041

Merged
merged 2 commits into from
Aug 29, 2023

Conversation

erights
Copy link
Member

@erights erights commented Feb 21, 2023

Start replacing uses of the deprecated assertProposalShape with makeInvitations direct support for proposalShape patterns. This provides better protection for contracts against malformed offers. When an offer's proposal violates the contract's required proposalShape pattern, it is rejected in Zoe and the contract never even sees the malformed offer.

This PR is somewhat empirical, revising the provided proposal patterns so that they were tighter than the assertProposalPattern call it replaced, while still passing all tests. For each modified contract, it would be good for someone who knows the meaning of the contract to do a sanity check on the proposalShape pattern.

One particular way these patterns could be tighter, to protect the contract from seeing more malformed offers, is to use the amountShape specific to the brand the contract is willing to accept in that position. I skipped that additional work, leaving a TODO there instead. Reviewers, if you know what brand-specific amountShape I should use in any such case, please let me know.

Upgrade considerations

We definitely need to think hard about whether this PR introduces any representation changes that create an upgrade issue. The proposal shapes that we're less worried about were extracted into #8268 , leaving only some governance cases here.

@erights erights self-assigned this Feb 21, 2023
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch 3 times, most recently from fce8418 to ef35a91 Compare February 28, 2023 03:34
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 commented on the ones I know.

packages/governance/src/committee.js Outdated Show resolved Hide resolved
packages/governance/src/committee.js Show resolved Hide resolved
packages/governance/src/electorateTools.js Show resolved Hide resolved
packages/governance/src/noActionElectorate.js Show resolved Hide resolved
packages/inter-protocol/src/stakeFactory/attestation.js Outdated Show resolved Hide resolved
Comment on lines 371 to 372
// Or should this be more like the AdjustBalancesProposalShape in
// vaultFactory, that allows both records to have both properties?
Copy link
Member

Choose a reason for hiding this comment

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

I don't think so... but only because I don't see a case where you would want to give both collateral and debt-brand, or want both. Why is that allowed in vaultFactory?

Copy link
Member

@turadg turadg Feb 28, 2023

Choose a reason for hiding this comment

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

The requirement for VaultFactory AdjustBalances is that you can "give" or "want" without specifying the other.

I don't know either of a good use case for giving the same brands as you're wanting, but there's also not a strong reason to forbid that and allowing it makes the shape simpler to implement the above requirement.

Doesn't the StakeFactory have the same requirement? i.e. that you can specify one and the other is implied by your staked holdings. If so we lack test coverage for that case because this shape isn't throwing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't tell whether this is redundant with what @turadg said, but I want to be explicit:

with VF AdjustBalances, you can give both or want both or give one and want the other. I don't think it ever makes sense to have the same keyword in both give and want.

Copy link
Member

Choose a reason for hiding this comment

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

If so we lack test coverage for that case ...

That's where my mind went too.

I'm not sure I can justify the time to swap in the relevant context for this just now.

Copy link
Member Author

Choose a reason for hiding this comment

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

The goal for this PR is to express with patterns at least the restrictions that were expressed by assertProposalShape and similar, but still be unrestrictive enough to allow everything we should be allowing. So, based on what I think I understood of the above comments, I did revise this pattern to be like the AdjustBalancesProposalShape from VF, that is more accepting.

PTAL and let me know if I misunderstood. Leaving this Conversation unresolved until I hear back.

packages/pegasus/src/pegasus.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/vaultFactory/vault.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/vaultFactory/vault.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/vaultFactory/vaultManager.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/vpool-xyk-amm/addLiquidity.js Outdated Show resolved Hide resolved
packages/pegasus/src/pegasus.js Outdated Show resolved Hide resolved
packages/zoe/src/contractSupport/zoeHelpers.js Outdated Show resolved Hide resolved
packages/zoe/src/contracts/auction/index.js Outdated Show resolved Hide resolved
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from fdcf70d to 933d539 Compare February 28, 2023 20:23
Comment on lines 371 to 372
// Or should this be more like the AdjustBalancesProposalShape in
// vaultFactory, that allows both records to have both properties?
Copy link
Member Author

Choose a reason for hiding this comment

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

The goal for this PR is to express with patterns at least the restrictions that were expressed by assertProposalShape and similar, but still be unrestrictive enough to allow everything we should be allowing. So, based on what I think I understood of the above comments, I did revise this pattern to be like the AdjustBalancesProposalShape from VF, that is more accepting.

PTAL and let me know if I misunderstood. Leaving this Conversation unresolved until I hear back.

Comment on lines 205 to 214
zcf.makeInvitation(
seatx => helper.closeHook(seatx),
'CloseVault',
undefined,
StakeFactoryCloseProposalShape,
),
Copy link
Member Author

Choose a reason for hiding this comment

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

Seems annoyingly similar to the zcf.makeInvitation call in stakeFactoryKit function makeCloseInvitation. As a result, the proposalShape used here is annoyingly like the one used there. Can we consolidate both?

Leaving Conversation unresolved until I hear back.

Copy link
Contributor

Choose a reason for hiding this comment

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

seems like they could be unified. What's the obstacle? The factory has the branded amounts. Can the kit get them from there? Is there an obstacle to the Kit making the branded amounts itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Chris-Hibbert I recall we discussed this, but I no longer remember where we landed. Do you?

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 remember the conversation. Shall we try again?

packages/inter-protocol/src/vaultFactory/vault.js Outdated Show resolved Hide resolved
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from 995f366 to 05b90ff Compare March 1, 2023 01:46
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch 6 times, most recently from 601f312 to 31551ac Compare March 3, 2023 23:56
@datadog-full-agoric
Copy link

datadog-full-agoric bot commented Mar 4, 2023

Datadog Report

Branch report: markm-more-invitation-proposal-patterns
Commit report: 9fb3e17

agoric-sdk: 0 Failed, 0 New Flaky, 3661 Passed, 57 Skipped, 19m 47.42s Wall Time

@erights erights requested a review from gibson042 March 4, 2023 20:51
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch 2 times, most recently from b0bd0e0 to 1b7cc36 Compare March 9, 2023 04:02
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from 1b7cc36 to 7570893 Compare March 14, 2023 07:08
@datadog-full-agoric
Copy link

datadog-full-agoric bot commented Mar 14, 2023

Datadog Report

Branch report: markm-more-invitation-proposal-patterns
Commit report: dbbd635

agoric-sdk: 1 Failed (0 Known Flaky), 0 New Flaky, 2910 Passed, 29 Skipped, 17m 30.73s Wall Time

❌ Failed Tests (1)

  • bootstrapTests › demo-config › sim/demo config provides home with .myAddressNameAdmin - agoric.vats - Details

    Expand for error
     ---
         name: AssertionError
         assertion: deepEqual
         values:
           'Difference (- actual, + expected):': |2-
               [
                 'agoricNames',
             -   'bank',
             +   'attMaker',
             -   'behaviors',
     ...
    

@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from 7570893 to 2b38651 Compare March 19, 2023 23:54
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from 2b38651 to f56aa87 Compare April 19, 2023 04:19
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from 342e10f to ae5ea19 Compare August 28, 2023 05:43
@erights erights requested review from turadg and dckc August 28, 2023 06:16
@erights
Copy link
Member Author

erights commented Aug 28, 2023

Reviewers,

Enough has changed that it is worth asking afresh: What's needed for me to move this forward? Because

  • this contributes to defensiveness against incoming messages,
  • may be easy since it has stayed green for a long time
  • makes more of our code a better example for others to follow

I would like to make progress on this. But no great urgency.

@erights
Copy link
Member Author

erights commented Aug 28, 2023

If some cases remain problematic, I'd rather just postpone those to a later PR and make progress now on the non-problematic ones. Thanks.

@dckc
Copy link
Member

dckc commented Aug 28, 2023

What's needed for me to move this forward?

The emerging norm is to have upgrade tests for any contracts deployed in production; in particular, committee.js.

Pegasus is not (yet) in production, so landing that seems un-problematic. I think auction.js likewise.

For the helper functions, I'd like to see them traced back to any production bundles that they might appear in.

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'm not sure about landing changes to committee.js without at least a scheduled issue for upgrade testing. @turadg ?

@turadg
Copy link
Member

turadg commented Aug 28, 2023

I'm not sure about landing changes to committee.js without at least a scheduled issue for upgrade testing. @turadg ?

Given the low urgency of landing this and that we have upgrade-12 scheduled, I'd request such a test be included in this PR before considering landing it.

We definitely need to think hard about whether this PR introduces any representation changes that create an upgrade issue.

Please include this in an "Upgrade considerations" section in the main PR description.

@erights
Copy link
Member Author

erights commented Aug 29, 2023

Please include this in an "Upgrade considerations" section in the main PR description.

Done

@erights
Copy link
Member Author

erights commented Aug 29, 2023

I'm not sure about landing changes to committee.js without at least a scheduled issue for upgrade testing. @turadg ?

Given the low urgency of landing this and that we have upgrade-12 scheduled, I'd request such a test be included in this PR before considering landing it.

What if I postponed the committee.js changes to a later PR? What if I postponed all the packages/governance changes to a later PR?

@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from ae5ea19 to 4cd5f10 Compare August 29, 2023 00:28
@erights erights requested a review from dckc August 29, 2023 00:28
@dckc
Copy link
Member

dckc commented Aug 29, 2023

Separating governance might do it. Would have to check whether the zoe changes affect any production bundles too.

@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from 4cd5f10 to 9372909 Compare August 29, 2023 04:01
@erights erights changed the base branch from master to markm-afew-invitation-proposal-patterns August 29, 2023 04:02
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from 9372909 to b023677 Compare August 29, 2023 04:05
@erights erights changed the base branch from markm-afew-invitation-proposal-patterns to master August 29, 2023 04:05
@erights erights changed the title fix: more invitations use proposal patterns fix(governance): some governance invitations use proposal patterns Aug 29, 2023
@erights
Copy link
Member Author

erights commented Aug 29, 2023

Zoe and Pegasus cases extracted to #8268 , leaving only the governance cases here.

@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from b023677 to 2df9334 Compare August 29, 2023 04:17
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.

Looks good.

@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from 113fc49 to a620aaf Compare August 29, 2023 20:01
@erights erights added the automerge:rebase Automatically rebase updates, then merge label Aug 29, 2023
@erights erights force-pushed the markm-more-invitation-proposal-patterns branch from a620aaf to 1a0db7d Compare August 29, 2023 22:51
@mergify mergify bot merged commit 1eed398 into master Aug 29, 2023
70 checks passed
@mergify mergify bot deleted the markm-more-invitation-proposal-patterns branch August 29, 2023 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge devex developer experience patterns Zoe package: Zoe
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants