Skip to content

Fix: Enforce proposal status when calling Governor.execute depending on proposalNeedsQueuing#6386

Merged
Amxx merged 8 commits intomasterfrom
fix/governor-enforce-queue
Mar 4, 2026
Merged

Fix: Enforce proposal status when calling Governor.execute depending on proposalNeedsQueuing#6386
Amxx merged 8 commits intomasterfrom
fix/governor-enforce-queue

Conversation

@Amxx
Copy link
Collaborator

@Amxx Amxx commented Mar 3, 2026

Fixes H-03

PR Checklist

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

@Amxx Amxx added this to the 5.7 milestone Mar 3, 2026
@Amxx Amxx requested a review from ernestognw March 3, 2026 09:52
@Amxx Amxx requested a review from a team as a code owner March 3, 2026 09:52
@Amxx Amxx added the security Pull requests that address a security vulnerability label Mar 3, 2026
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: 73ee8d5

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 Minor

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

Comment on lines -97 to -99
if (etaSeconds == 0) {
revert GovernorNotQueuedProposal(proposalId);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is no longer necessary because Governor.execute enforces status = Queued

await this.helper.connect(this.voter1).vote({ support: VoteType.For });
await this.helper.waitForDeadline();
// Not queueud, so it should revert
await expect(this.helper.execute()).to.be.reverted;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Before this change, this would not have reverted

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

Walkthrough

The changes introduce dynamic queuing logic to the Governor contract. The proposalNeedsQueuing function now determines whether a proposal must be in the Queued state during execution. When proposalNeedsQueuing returns true, only Queued state is permitted; otherwise, only Succeeded state is permitted. The GovernorNotQueuedProposal error is removed from the interface. The GovernorTimelockCompound._executeOperations method no longer enforces a queued-state guard. Tests are updated across multiple governance extensions to reflect the new conditional state validation logic and use GovernorUnexpectedProposalState errors with corresponding state bitmaps.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: enforcing proposal status in Governor.execute based on the proposalNeedsQueuing condition, which aligns with the core security fix addressed across multiple files.
Description check ✅ Passed The description relates to the changeset by referencing the specific audit issue (H-03) being fixed and describing the enforcement of proposal status based on proposalNeedsQueuing, which matches the implementation changes throughout the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/governor-enforce-queue

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/silver-falcons-lay.md:
- Line 5: Fix the typo in the changeset note by replacing the word "Scrict" with
"Strict" in the backtick-quoted entry for `Governor` so the line reads:
"`Governor`: Strict enforcement of the expected proposal state depending on
`proposalNeedsQueuing` when calling `execute`."

In `@test/governance/extensions/GovernorTimelockAccess.test.js`:
- Around line 265-266: Fix the typo in the comment ("queueud" → "queued") and
make the revert assertion specific by expecting the
GovernorUnexpectedProposalState error when calling this.helper.execute();
replace the generic await expect(this.helper.execute()).to.be.reverted with an
assertion that the call is reverted with the GovernorUnexpectedProposalState
(include the queued-only allowed states message/args if applicable) so the test
verifies the exact failure mode for this.helper.execute().

In `@test/governance/extensions/GovernorTimelockCompound.test.js`:
- Around line 159-164: The revert assertion is checking the wrong proposal id:
update the .withArgs(...) call used with
.to.be.revertedWithCustomError(this.mock, 'GovernorUnexpectedProposalState') to
pass the local duplicate proposal identifier id (the one passed to
this.helper.execute()) instead of this.proposal.id; keep the other args
(ProposalState.Succeeded and
GovernorHelper.proposalStatesToBitMap([ProposalState.Queued])) unchanged so the
assertion targets the duplicate proposal created in this test.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca6f5fa and ca2d1cc.

📒 Files selected for processing (9)
  • .changeset/silver-falcons-lay.md
  • contracts/governance/Governor.sol
  • contracts/governance/IGovernor.sol
  • contracts/governance/extensions/GovernorTimelockCompound.sol
  • test/governance/Governor.test.js
  • test/governance/extensions/GovernorTimelockAccess.test.js
  • test/governance/extensions/GovernorTimelockCompound.test.js
  • test/governance/extensions/GovernorTimelockControl.test.js
  • test/governance/extensions/GovernorVotesQuorumFraction.test.js
💤 Files with no reviewable changes (2)
  • contracts/governance/extensions/GovernorTimelockCompound.sol
  • contracts/governance/IGovernor.sol

Amxx and others added 5 commits March 3, 2026 11:10
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Amxx Amxx merged commit 4681c1c into master Mar 4, 2026
23 checks passed
@Amxx Amxx deleted the fix/governor-enforce-queue branch March 4, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Pull requests that address a security vulnerability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants