Skip to content
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

audit: fix reentrancy in vote function #211

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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