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

Remove GovernorCompatibilyBravo and add simpler GovernorStorage #4360

Merged
merged 69 commits into from
Aug 3, 2023

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Jun 16, 2023

As discussed.

Fixes LIB-946
Fixes LIB-944

On of the challenge is that in order to provide the queue(uint256) endpoint, I needed to hook into the queue(address[], uint256[], bytes[], bytes32) function, which is defined in IGovernorTimelock and not in IGovernor.

I did not move the propotype declaration, because that would mess up the interfaceId, and I just implemented a base version of the function (that just reverts for now) in Governor. This requires some new overrides. Moving the interface declaration would possibly reduce the need for override, but it would also either break the interfaceIds or require a lot of "xor tricks".

No tests yet, will do them if we agree on the solidity part.

Also

  • refactor public/internal functions for queue/_queue and cancel/_cancel, following the execute/_execute pattern
    • public version computes the proposalId from the details AND check the current status of the proposal
    • internal version get the proposalId as a parameter
      • internal no longer recompute / return the proposalId
  • new _validateStateBitmap function to avoid code duplication when checking the current state.

To discuss

Need for overrides would be improved if we moved the public declaration of the queue function from IGovernorTimelock to IGovernor. This was not (yet) implemented because of the ERC-165 consequences. However, this comment makes me think that the ERC165 will likely change anyway, and that we are ok with that. So maybe we should also do that change.

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2023

🦋 Changeset detected

Latest commit: 1853702

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Amxx Amxx marked this pull request as draft June 16, 2023 13:26
@Amxx Amxx requested review from frangio and ernestognw June 19, 2023 16:08
contracts/governance/Governor.sol Outdated Show resolved Hide resolved
contracts/governance/extensions/GovernorStorage.sol Outdated Show resolved Hide resolved
contracts/governance/extensions/GovernorStorage.sol Outdated Show resolved Hide resolved
contracts/governance/extensions/GovernorStorage.sol Outdated Show resolved Hide resolved
contracts/governance/extensions/GovernorStorage.sol Outdated Show resolved Hide resolved
contracts/governance/extensions/GovernorStorage.sol Outdated Show resolved Hide resolved
contracts/governance/README.adoc Outdated Show resolved Hide resolved
contracts/governance/Governor.sol Outdated Show resolved Hide resolved
contracts/governance/Governor.sol Outdated Show resolved Hide resolved
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

We still need to remove the bravo module mentions from Governor, IGovernor, GovernorCountingSimple, and governance.adoc

contracts/governance/extensions/GovernorStorage.sol Outdated Show resolved Hide resolved
@Amxx Amxx mentioned this pull request Jun 28, 2023
3 tasks
@Amxx
Copy link
Collaborator Author

Amxx commented Jun 29, 2023

I did an overall refactor of the public and internal functions

Types of functions

  • public
    • compute proposalId
    • check restrictions
    • call internal
  • internal
    • check state is consistent
    • write flags
    • setup before operation is done
    • calls "internalCalls"
    • cleanup
    • emit event
  • "internalCalls"
    • does the external call

Rational

  • you can override the public one if you want to add restrictions for the public invocations.
    • In that case you call super
  • you can override the internal one if you want to insert extra logic (like storing more stuff in _propose)
    • In that case you call super
  • you can override the internalCalls one to reconfigure the logic (execute trough a timelock).
    • In that case you do not call super

Also:

  • you can call the internal version directly if you want to bypass the public checks (for example do a proposal without the threshold check). this will check state consistency, set flags, and emit events. We used to have that for _cancel but not the other functions
  • you should never call the "internalCalls" directly (can't enforce that)

WDYT @frangio @ernestognw

This was referenced Sep 10, 2024
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