Skip to content

Conversation

@HananeBendisari
Copy link
Contributor

@HananeBendisari HananeBendisari commented Apr 19, 2025

This PR removes redundant overrides of quorum(), votingDelay(), and votingPeriod() functions in the Governor contract generator.

Governor.sol has virtual functions which are not implemented, while extensions such as GovernorVotesQuorumFraction.sol and GovernorSettings.sol already overrides these functions.

Therefore, there is no need to override both Governor and the extension when using these functions.

Related discussion: openzeppelin/openzeppelin-contracts#3948

Fixes #218

@github-actions
Copy link
Contributor

github-actions bot commented Apr 19, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@HananeBendisari HananeBendisari force-pushed the cleanup-governor-overrides branch from 1d9adb9 to 5ba4ade Compare April 19, 2025 04:49
@HananeBendisari HananeBendisari force-pushed the cleanup-governor-overrides branch from 5ba4ade to 84a66b9 Compare April 19, 2025 04:53
@HananeBendisari
Copy link
Contributor Author

I confirm that I have read and hereby agree to the OpenZeppelin Contributor License Agreement

@CoveMB
Copy link
Contributor

CoveMB commented Apr 21, 2025

Hi @HananeBendisari , thanks for your PR
Here is the preview deployed of your changes https://deploy-preview-522--openzeppelin-contracts-wizard.netlify.app/#governor it seem it is missing the quorum function override for percentage?

@HananeBendisari
Copy link
Contributor Author

Oh sorry about that. Thanks for the update. I’m finishing the checks on delegation + votes in Remix, I’ll push a new commit soon.

@HananeBendisari
Copy link
Contributor Author

Thanks for the heads-up @CoveMB !

Confirmed everything again step-by-step:

  • GovernorVotesQuorumFraction now properly overrides quorum() when used with percent mode
  • The redundant Governor override was removed
  • No double override remains
  • Contract compiles and deploys on Remix
  • delegate() and getVotes() work correctly
  • Output is clean and consistent

Tested with the following setup:

  • ERC20Votes
  • Quorum mode: percent
  • GovernorSettings enabled
  • Manual inspection of output confirms the override is injected only once

Let me know if you'd like me to include a safeguard or conditional override fallback. Otherwise, I think this patch is good to go

@ericglau
Copy link
Member

@HananeBendisari Would you be able to remove all of the changes from this PR except for packages/core/solidity/src/governor.ts? The other changes do not seem directly related to this, so they should not be included.

Additionally, can you please also add an entry to the Unreleased section of packages/core/solidity/CHANGELOG.md

@HananeBendisari
Copy link
Contributor Author

All set! This PR now only includes the necessary Governor override for quorum() in absolute mode, restored at the correct location inside addQuorum().

No other files are touched.

Thanks for your feedback earlier — let me know if anything else is needed!

@ericglau ericglau changed the title fix: remove redundant quorum() override in Governor generator (#218) Remove redundant overrides in Governor Apr 23, 2025
@ericglau
Copy link
Member

I've updated the PR description and removed some additional function overrides for votingDelay and votingPeriod. We'll review this further before proceeding to merge. Thanks!

@ericglau ericglau requested a review from a team April 23, 2025 15:35
@HananeBendisari
Copy link
Contributor Author

Hey @ericglau ,
Thanks a lot for the recent changes and for the clarification!

I realize now that my original fix only addressed a small part of a broader cleanup you had in mind regarding redundant overrides. Sorry if my limited scope caused extra noise or delay on your side.

It’s been a great learning opportunity for me — I’ll be more careful next time to better understand the context before jumping in.

Appreciate the thoughtful feedback throughout.
Let me know if there's anything else I can do!

@ericglau ericglau merged commit 0a650c9 into OpenZeppelin:master Apr 23, 2025
13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Governor redundant overrides

4 participants