forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add Proposal Validator #367
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
Merged
0xChin
merged 33 commits into
sc-feat/permissionless-proposals
from
feat/add-delegate-proposal-validator
May 6, 2025
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
bd40311
feat: add initial interface and logic
0xChin c978296
refactor: remove installed governor submodule
0xChin e0fffdf
chore: remove xERC20
0xChin bf3218e
feat: add proposal routing full flow
0xChin 1eff3c6
feat: check voting power and required proposals
0xChin e6d256c
refactor: rename to ProposalValidator
0xChin c1f1abf
feat: add EAS validation for certain Proposal Types
0xChin 53a8b06
chore: fix attestation schema approved address naming
0xChin e6721e5
chore: remove management functions
0xChin 2786406
chore: run pre-pr
0xChin 0e9a403
refacto: follow style guide for function parameters and return variables
0xChin 0c0dc9b
docs: add natspec, remove unused errors
0xChin 389b3c7
chore: remove management functions from interface
0xChin 3a06bd1
chore: make voting token immutable
0xChin 0fbc510
perf: make governor immutable
0xChin 7ecb908
feat: add validator management functions
0xChin d588a1e
chore: add comments for imports in ProposalValidator
0xChin d87a2c1
test: add unit tests
0xChin c5ab973
fix: semgrep warnings
0xChin 3266bff
chore: rename MaintenanceUpgradeProposals --> MaintenanceUpgrade
0xChin 4337e06
chore(semgrep): add excluded governance files
0xChin 01d4bb3
chore: fix coding style
0xChin 7557215
chore: add ImmutableProposalTypeData
0xChin f1ad385
chore: improve errors naming
0xChin a2879ff
docs: improve natspec
0xChin 1eef92c
docs: add technical explanation on attestation validation function
0xChin 30c171b
feat: add _proposalTypeData mapping
0xChin 5ff0692
chore: keep private functions consistency
0xChin d95a3d7
chore: improve required attestation naming
0xChin 33230de
docs: improve documents legibility
0xChin e062c4b
chore: fix immutable variables coding style
0xChin 078915b
chore: explain governor external call
0xChin a6cc075
docs: explicit Validator/Governor contract interaction in events natspec
0xChin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/contracts-bedrock/interfaces/governance/IOptimismGovernor.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import {VotingModule} from "src/governance/VotingModule.sol"; | ||
| interface IOptimismGovernor { | ||
| function propose( | ||
| address[] memory targets, | ||
| uint256[] memory values, | ||
| bytes[] memory calldatas, | ||
| string memory description, | ||
| uint8 proposalType | ||
| ) external returns (uint256 proposalId); | ||
|
|
||
| function proposeWithModule( | ||
| VotingModule module, | ||
| bytes memory proposalData, | ||
| string memory description, | ||
| uint8 proposalType | ||
| ) external returns (uint256 proposalId); | ||
| } |
125 changes: 125 additions & 0 deletions
125
packages/contracts-bedrock/interfaces/governance/IProposalValidator.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import {IGovernanceToken} from "./IGovernanceToken.sol"; | ||
| import {IOptimismGovernor} from "./IOptimismGovernor.sol"; | ||
|
|
||
| /// @title IProposalValidator | ||
| /// @notice Interface for the ProposalValidator contract. | ||
| interface IProposalValidator { | ||
| error ProposalValidator_InsufficientApprovals(); | ||
| error ProposalValidator_ProposalAlreadyApproved(); | ||
| error ProposalValidator_ProposalAlreadyInVoting(); | ||
| error ProposalValidator_InsufficientVotingPower(); | ||
| error ProposalValidator_InvalidAttestation(); | ||
|
|
||
| struct ProposalData { | ||
| address proposer; | ||
| address[] targets; | ||
| uint256[] values; | ||
| bytes[] calldatas; | ||
| string description; | ||
| ProposalType proposalType; | ||
| bool inVoting; | ||
| mapping(address => bool) delegateApprovals; | ||
| uint256 remainingApprovalsRequired; | ||
| } | ||
|
|
||
| struct ImmutableProposalTypeData { | ||
| address[] targets; | ||
| uint256[] values; | ||
| string[] signatures; | ||
| } | ||
|
|
||
| enum ProposalType { | ||
| ProtocolOrGovernorUpgrade, | ||
| MaintenanceUpgrade, | ||
| CouncilMemberElections, | ||
| GovernanceFund, | ||
| CouncilBudget | ||
| } | ||
|
|
||
| event ProposalSubmitted( | ||
| uint256 indexed proposalId, | ||
| address indexed proposer, | ||
| address[] targets, | ||
| uint256[] values, | ||
| bytes[] calldatas, | ||
| string description, | ||
| ProposalType proposalType | ||
| ); | ||
|
|
||
| event ProposalApproved( | ||
| uint256 indexed proposalId, | ||
| address indexed approver | ||
| ); | ||
|
|
||
| event ProposalMovedToVote( | ||
| uint256 indexed proposalId, | ||
| address indexed executor | ||
| ); | ||
|
|
||
| event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | ||
|
|
||
| event MinimumVotingPowerSet(uint256 newMinimumVotingPower); | ||
|
|
||
| event VotingCycleBlockSet(uint256 newVotingCycleBlock); | ||
|
|
||
| event DistributionThresholdSet(uint256 newDistributionThreshold); | ||
|
|
||
| event ProposalApprovalThresholdSet(ProposalType proposalType, uint256 newApprovalThreshold); | ||
|
|
||
| function submitProposal( | ||
| address[] memory _targets, | ||
| uint256[] memory _values, | ||
| bytes[] memory _calldatas, | ||
| string memory _description, | ||
| ProposalType _proposalType, | ||
| bytes32 _attestationUid | ||
| ) external returns (uint256 proposalId_); | ||
|
|
||
| function approveProposal(uint256 _proposalId) external; | ||
|
|
||
| function moveToVote(uint256 _proposalId) external returns (uint256 governorProposalId_); | ||
|
|
||
| function setMinimumVotingPower(uint256 _minimumVotingPower) external; | ||
|
|
||
| function setVotingCycleBlock(uint256 _votingCycleBlock) external; | ||
|
|
||
| function setDistributionThreshold(uint256 _distributionThreshold) external; | ||
|
|
||
| function setProposalRequiredApprovals(ProposalType _proposalType, uint256 _requiredApprovals) external; | ||
|
|
||
| function renounceOwnership() external; | ||
|
|
||
| function canSignOff(address _delegate) external view returns (bool canSignOff_); | ||
|
|
||
| function transferOwnership(address newOwner) external; | ||
|
|
||
| function minimumVotingPower() external view returns (uint256); | ||
|
|
||
| function votingCycleBlock() external view returns (uint256); | ||
|
|
||
| function distributionThreshold() external view returns (uint256); | ||
|
|
||
| function VOTING_TOKEN() external view returns (IGovernanceToken); | ||
|
|
||
| function GOVERNOR() external view returns (IOptimismGovernor); | ||
|
|
||
| function owner() external view returns (address); | ||
|
|
||
| function ATTESTATION_SCHEMA_UID() external view returns (bytes32); | ||
|
|
||
| function __constructor__( | ||
| address _owner, | ||
| IOptimismGovernor _governor, | ||
| IGovernanceToken _votingToken, | ||
| bytes32 _attestationSchemaUid, | ||
| uint256 _minimumVotingPower, | ||
| uint256 _votingCycleBlock, | ||
| uint256 _distributionThreshold, | ||
| ProposalType[] memory _proposalTypes, | ||
| uint256[] memory _requiredApprovals, | ||
| ImmutableProposalTypeData[] memory _immutableProposalTypeDatas | ||
| ) external; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.