Skip to content

Commit 61ed0e1

Browse files
committed
feat: add check in approve if proposal has moved to vote (#450)
1 parent 056a7ec commit 61ed0e1

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

packages/contracts-bedrock/snapshots/semver-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@
172172
"sourceCodeHash": "0x9baa0f9e744cc0ecc61d0fade8bffc18321b228833ea0904dc645f3975be9ed1"
173173
},
174174
"src/governance/ProposalValidator.sol:ProposalValidator": {
175-
"initCodeHash": "0xd072e288107128a1b0f26f41c4b257295919777cadfc06514d2a4738fb96e1d1",
176-
"sourceCodeHash": "0x725efcbb68cb4a23af492983ba22969ddaa5d472878fb8490a437eaaa88812a8"
175+
"initCodeHash": "0x30d570ce61624852476452d9660567bae2346002878a45703cf60e44809730ca",
176+
"sourceCodeHash": "0xe5272e8176b0ddf3ff589629f7872b5dc6c18b900f413f0f8682865bf310faa7"
177177
},
178178
"src/legacy/DeployerWhitelist.sol:DeployerWhitelist": {
179179
"initCodeHash": "0x53099379ed48b87f027d55712dbdd1da7d7099925426eb0531da9c0012e02c29",

packages/contracts-bedrock/src/governance/ProposalValidator.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver {
578578
revert ProposalValidator_ProposalAlreadyApproved();
579579
}
580580

581+
// check if proposal has already moved to vote
582+
if (proposal.movedToVote) {
583+
revert ProposalValidator_ProposalAlreadyMovedToVote();
584+
}
585+
581586
// validate the attestation
582587
_validateTopDelegateAttestation(_attestationUid, _msgSender());
583588

packages/contracts-bedrock/test/governance/ProposalValidator.t.sol

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,6 +1881,23 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init {
18811881
validator.approveProposal(_proposalHash, topDelegateAttestation_A);
18821882
}
18831883

1884+
function test_approveProposal_proposalAlreadyMovedToVote_reverts(
1885+
bytes32 _proposalHash,
1886+
uint8 proposalTypeValue
1887+
)
1888+
public
1889+
{
1890+
// Bound the proposal type to valid enum values (0-4)
1891+
proposalTypeValue = uint8(bound(proposalTypeValue, 0, 4));
1892+
ProposalValidator.ProposalType proposalType = ProposalValidator.ProposalType(proposalTypeValue);
1893+
// set proposal data so that the proposal exists and set movedToVote to true
1894+
validator.setProposalData(_proposalHash, topDelegate_A, proposalType, true, 0, CYCLE_NUMBER);
1895+
1896+
vm.expectRevert(IProposalValidator.ProposalValidator_ProposalAlreadyMovedToVote.selector);
1897+
vm.prank(topDelegate_A);
1898+
validator.approveProposal(_proposalHash, topDelegateAttestation_A);
1899+
}
1900+
18841901
function test_approveProposal_invalidSchema_reverts(bytes32 _proposalHash, uint8 proposalTypeValue) public {
18851902
// Bound the proposal type to valid enum values (0-4)
18861903
proposalTypeValue = uint8(bound(proposalTypeValue, 0, 4));

0 commit comments

Comments
 (0)