Skip to content

Commit

Permalink
refactor(contracts): add virtual to functions which could be overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 committed Feb 13, 2024
1 parent a0c4c98 commit aefe48a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions contracts/contracts/MACI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ contract MACI is IMACI, Params, Utilities, Ownable {
PubKey memory _pubKey,
bytes memory _signUpGatekeeperData,
bytes memory _initialVoiceCreditProxyData
) public {
) public virtual {
// ensure we do not have more signups than what the circuits support
if (numSignUps == uint256(TREE_ARITY) ** uint256(stateTreeDepth)) revert TooManySignups();

Expand Down Expand Up @@ -200,7 +200,7 @@ contract MACI is IMACI, Params, Utilities, Ownable {
address _verifier,
address _vkRegistry,
bool useSubsidy
) public onlyOwner returns (PollContracts memory pollAddr) {
) public virtual onlyOwner returns (PollContracts memory pollAddr) {
// cache the poll to a local variable so we can increment it
uint256 pollId = nextPollId;

Expand Down Expand Up @@ -240,17 +240,17 @@ contract MACI is IMACI, Params, Utilities, Ownable {
}

/// @inheritdoc IMACI
function mergeStateAqSubRoots(uint256 _numSrQueueOps, uint256 _pollId) public override onlyPoll(_pollId) {
function mergeStateAqSubRoots(uint256 _numSrQueueOps, uint256 _pollId) public onlyPoll(_pollId) {

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

stateAq.mergeSubRoots(_numSrQueueOps);
}

/// @inheritdoc IMACI
function mergeStateAq(uint256 _pollId) public override onlyPoll(_pollId) returns (uint256 root) {
function mergeStateAq(uint256 _pollId) public onlyPoll(_pollId) returns (uint256 root) {

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Parameter MACI.mergeStateAq(uint256)._pollId is not in mixedCase
root = stateAq.merge(stateTreeDepth);
}

/// @inheritdoc IMACI
function getStateAqRoot() public view override returns (uint256 root) {
function getStateAqRoot() public view returns (uint256 root) {
root = stateAq.getMainRoot(stateTreeDepth);
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/Poll.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ contract Poll is Params, Utilities, SnarkCommon, Ownable, EmptyBallotRoots, IPol
}

/// @inheritdoc IPoll
function topup(uint256 stateIndex, uint256 amount) public isWithinVotingDeadline {
function topup(uint256 stateIndex, uint256 amount) public virtual isWithinVotingDeadline {
// we check that we do not exceed the max number of messages
if (numMessages == maxValues.maxMessages) revert TooManyMessages();

Expand All @@ -163,7 +163,7 @@ contract Poll is Params, Utilities, SnarkCommon, Ownable, EmptyBallotRoots, IPol
}

Check warning

Code scanning / Slither

Unused return Medium

Check notice

Code scanning / Slither

Reentrancy vulnerabilities Low


/// @inheritdoc IPoll
function publishMessage(Message calldata _message, PubKey calldata _encPubKey) public isWithinVotingDeadline {
function publishMessage(Message calldata _message, PubKey calldata _encPubKey) public virtual isWithinVotingDeadline {

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

// we check that we do not exceed the max number of messages
if (numMessages == maxValues.maxMessages) revert TooManyMessages();

Expand Down

0 comments on commit aefe48a

Please sign in to comment.