Skip to content

Commit

Permalink
audit: fix reentrancy in vote function (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
pscott authored Jun 16, 2023
1 parent edb987f commit 2c5b49f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/VoteSigComp.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
50709
50700
2 changes: 1 addition & 1 deletion .forge-snapshots/VoteSigCompMetadata.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
52252
52243
2 changes: 1 addition & 1 deletion .forge-snapshots/VoteTxComp.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
44279
44270
2 changes: 1 addition & 1 deletion .forge-snapshots/VoteTxCompMetadata.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
45863
45854
3 changes: 2 additions & 1 deletion src/Space.sol
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ contract Space is ISpace, Initializable, IERC4824, UUPSUpgradeable, OwnableUpgra
if (proposal.finalizationStatus != FinalizationStatus.Pending) revert ProposalFinalized();
if (voteRegistry[proposalId][voter]) revert UserAlreadyVoted();

voteRegistry[proposalId][voter] = true;

uint256 votingPower = _getCumulativePower(
voter,
proposal.snapshotTimestamp,
Expand All @@ -263,7 +265,6 @@ contract Space is ISpace, Initializable, IERC4824, UUPSUpgradeable, OwnableUpgra
);
if (votingPower == 0) revert UserHasNoVotingPower();
votePower[proposalId][choice] += votingPower;
voteRegistry[proposalId][voter] = true;

if (bytes(metadataURI).length == 0) {
emit VoteCast(proposalId, voter, choice, votingPower);
Expand Down

0 comments on commit 2c5b49f

Please sign in to comment.