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

Pack Governor's ProposalCore into a single slot #4268

Merged
merged 13 commits into from
Jun 23, 2023

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented May 22, 2023

Fixes #3208
Fixes LIB-803

Note: we could merge canceled and executed into a single byte using an enum. That would increase the space for duration to uint40.

This is purely internal, no interface change:

  • no test changes
  • no documentation change ?

PR Checklist

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

@changeset-bot
Copy link

changeset-bot bot commented May 22, 2023

🦋 Changeset detected

Latest commit: 802d4d8

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 ready for review May 22, 2023 11:01
@@ -161,7 +156,8 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive
* @dev See {IGovernor-state}.
*/
function state(uint256 proposalId) public view virtual override returns (ProposalState) {
ProposalCore storage proposal = _proposals[proposalId];
// ProposalCore is just one slot
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the intention with this comment? Is it that we're reading it into memory because it's one slot and that will be more efficient? If so, let's write that explicitly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that is the intention.

contracts/governance/Governor.sol Outdated Show resolved Hide resolved
contracts/governance/Governor.sol Outdated Show resolved Hide resolved
Comment on lines +292 to +293
voteStart: SafeCast.toUint48(snapshot),
voteDuration: SafeCast.toUint32(duration),
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we documenting these bounds anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not yet.

Copy link
Collaborator Author

@Amxx Amxx Jun 13, 2023

Choose a reason for hiding this comment

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

Documentation added in IGovernor (in the natspec for votingDelay and votingPeriod)

@frangio
Copy link
Contributor

frangio commented May 29, 2023

Let's change GovernorSettings in here as well.

@Amxx Amxx changed the base branch from next-v5.0 to master June 9, 2023 09:25
@Amxx Amxx requested review from ernestognw and frangio June 19, 2023 13:44
contracts/governance/Governor.sol Outdated Show resolved Hide resolved
contracts/governance/Governor.sol Outdated Show resolved Hide resolved
contracts/governance/IGovernor.sol Outdated Show resolved Hide resolved
contracts/governance/IGovernor.sol Outdated Show resolved Hide resolved
Co-authored-by: Ernesto García <ernestognw@gmail.com>
frangio
frangio previously approved these changes Jun 23, 2023
contracts/governance/IGovernor.sol Outdated Show resolved Hide resolved
contracts/governance/extensions/GovernorSettings.sol Outdated Show resolved Hide resolved
@frangio
Copy link
Contributor

frangio commented Jun 23, 2023

LGTM except for the comments above.

Co-authored-by: Francisco <fg@frang.io>
@frangio frangio merged commit da89c43 into OpenZeppelin:master Jun 23, 2023
@Amxx Amxx deleted the next/storage-packing/Governor branch June 26, 2023 12:12
ernestognw added a commit to ernestognw/openzeppelin-contracts that referenced this pull request Jun 29, 2023
Co-authored-by: Ernesto García <ernestognw@gmail.com>
Co-authored-by: Francisco <fg@frang.io>
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.

Governor: Use smaller integers for timing parameters
3 participants