Skip to content

Commit

Permalink
audit: prevent update of finalized proposals (#216)
Browse files Browse the repository at this point in the history
* feat: prevent update of finalized proposals

* chore renamed update proposal test

* fix: update finalized propsal test

---------

Co-authored-by: Orlando <[email protected]>
  • Loading branch information
Orland0x and Orlando authored Jun 20, 2023
1 parent 56409d5 commit 9f5f1fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Space.sol
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ contract Space is ISpace, Initializable, IERC4824, UUPSUpgradeable, OwnableUpgra
) external override onlyAuthenticator {
Proposal storage proposal = proposals[proposalId];
_assertProposalExists(proposal);
if (proposal.finalizationStatus != FinalizationStatus.Pending) revert ProposalFinalized();
if (author != proposal.author) revert InvalidCaller();
if (block.number >= proposal.startBlockNumber) revert VotingDelayHasPassed();

Expand Down
10 changes: 10 additions & 0 deletions test/UpdateProposalMetadata.t.sol → test/UpdateProposal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ contract UpdateProposalTest is SpaceTest {
space.execute(proposalId, executionStrategy.params);
}

function testUpdateFinalizedProposal() public {
uint256 proposalId = _createProposal(author, proposalMetadataURI, executionStrategy, new bytes(0));
vm.roll(block.number + votingDelay);
_vote(author, proposalId, Choice.For, userVotingStrategies, voteMetadataURI);
space.execute(proposalId, executionStrategy.params);

vm.expectRevert(abi.encodeWithSelector(ProposalFinalized.selector));
_updateProposal(author, proposalId, newStrategy, newMetadataURI);
}

function testUpdateProposalAfterDelay() public {
uint256 proposalId = _createProposal(author, proposalMetadataURI, executionStrategy, new bytes(0));
vm.roll(block.number + votingDelay);
Expand Down

0 comments on commit 9f5f1fe

Please sign in to comment.