fix: make all functions virtual

This commit is contained in:
rymnc 2023-07-31 10:49:29 +05:30
parent ab148a6497
commit a092b934a6
No known key found for this signature in database
GPG Key ID: AAA088D5C68ECD34
2 changed files with 12 additions and 11 deletions

View File

@ -87,7 +87,7 @@ abstract contract RlnBase {
/// Allows a user to register as a member /// Allows a user to register as a member
/// @param idCommitment The idCommitment of the member /// @param idCommitment The idCommitment of the member
function register(uint256 idCommitment) external payable { function register(uint256 idCommitment) external payable virtual {
if (msg.value != MEMBERSHIP_DEPOSIT) { if (msg.value != MEMBERSHIP_DEPOSIT) {
revert InsufficientDeposit(MEMBERSHIP_DEPOSIT, msg.value); revert InsufficientDeposit(MEMBERSHIP_DEPOSIT, msg.value);
} }
@ -98,7 +98,7 @@ abstract contract RlnBase {
/// Registers a member /// Registers a member
/// @param idCommitment The idCommitment of the member /// @param idCommitment The idCommitment of the member
/// @param stake The amount of eth staked by the member /// @param stake The amount of eth staked by the member
function _register(uint256 idCommitment, uint256 stake) internal { function _register(uint256 idCommitment, uint256 stake) internal virtual {
if (members[idCommitment] != 0) revert DuplicateIdCommitment(); if (members[idCommitment] != 0) revert DuplicateIdCommitment();
if (idCommitmentIndex >= SET_SIZE) revert FullTree(); if (idCommitmentIndex >= SET_SIZE) revert FullTree();
@ -114,7 +114,7 @@ abstract contract RlnBase {
/// @dev Allows a user to slash a member /// @dev Allows a user to slash a member
/// @param idCommitment The idCommitment of the member /// @param idCommitment The idCommitment of the member
function slash(uint256 idCommitment, address payable receiver, uint256[8] calldata proof) external { function slash(uint256 idCommitment, address payable receiver, uint256[8] calldata proof) external virtual {
_validateSlash(idCommitment, receiver, proof); _validateSlash(idCommitment, receiver, proof);
_slash(idCommitment, receiver, proof); _slash(idCommitment, receiver, proof);
} }
@ -123,7 +123,7 @@ abstract contract RlnBase {
/// stake to the receiver's available withdrawal balance /// stake to the receiver's available withdrawal balance
/// @param idCommitment The idCommitment of the member /// @param idCommitment The idCommitment of the member
/// @param receiver The address to receive the funds /// @param receiver The address to receive the funds
function _slash(uint256 idCommitment, address payable receiver, uint256[8] calldata proof) internal { function _slash(uint256 idCommitment, address payable receiver, uint256[8] calldata proof) internal virtual {
if (receiver == address(this) || receiver == address(0)) { if (receiver == address(this) || receiver == address(0)) {
revert InvalidReceiverAddress(receiver); revert InvalidReceiverAddress(receiver);
} }
@ -157,7 +157,7 @@ abstract contract RlnBase {
virtual; virtual;
/// Allows a user to withdraw funds allocated to them upon slashing a member /// Allows a user to withdraw funds allocated to them upon slashing a member
function withdraw() external { function withdraw() external virtual {
uint256 amount = withdrawalBalance[msg.sender]; uint256 amount = withdrawalBalance[msg.sender];
if (amount == 0) revert InsufficientWithdrawalBalance(); if (amount == 0) revert InsufficientWithdrawalBalance();
@ -181,6 +181,7 @@ abstract contract RlnBase {
function _verifyProof(uint256 idCommitment, address receiver, uint256[8] calldata proof) function _verifyProof(uint256 idCommitment, address receiver, uint256[8] calldata proof)
internal internal
view view
virtual
returns (bool) returns (bool)
{ {
return verifier.verifyProof( return verifier.verifyProof(

View File

@ -1068,7 +1068,7 @@ constructor(uint256 membershipDeposit, uint256 depth, address _poseidonHasher, a
### register ### register
```solidity ```solidity
function register(uint256 idCommitment) external payable function register(uint256 idCommitment) external payable virtual
``` ```
Allows a user to register as a member Allows a user to register as a member
@ -1082,7 +1082,7 @@ Allows a user to register as a member
### \_register ### \_register
```solidity ```solidity
function _register(uint256 idCommitment, uint256 stake) internal function _register(uint256 idCommitment, uint256 stake) internal virtual
``` ```
Registers a member Registers a member
@ -1105,7 +1105,7 @@ _Inheriting contracts MUST override this function_
### slash ### slash
```solidity ```solidity
function slash(uint256 idCommitment, address payable receiver, uint256[8] proof) external function slash(uint256 idCommitment, address payable receiver, uint256[8] proof) external virtual
``` ```
_Allows a user to slash a member_ _Allows a user to slash a member_
@ -1121,7 +1121,7 @@ _Allows a user to slash a member_
### \_slash ### \_slash
```solidity ```solidity
function _slash(uint256 idCommitment, address payable receiver, uint256[8] proof) internal function _slash(uint256 idCommitment, address payable receiver, uint256[8] proof) internal virtual
``` ```
_Slashes a member by removing them from the set, and adding their _Slashes a member by removing them from the set, and adding their
@ -1144,7 +1144,7 @@ function _validateSlash(uint256 idCommitment, address payable receiver, uint256[
### withdraw ### withdraw
```solidity ```solidity
function withdraw() external function withdraw() external virtual
``` ```
Allows a user to withdraw funds allocated to them upon slashing a member Allows a user to withdraw funds allocated to them upon slashing a member
@ -1167,7 +1167,7 @@ NOTE: The variant of Poseidon we use accepts only 1 input, assume n=2, and the s
### \_verifyProof ### \_verifyProof
```solidity ```solidity
function _verifyProof(uint256 idCommitment, address receiver, uint256[8] proof) internal view returns (bool) function _verifyProof(uint256 idCommitment, address receiver, uint256[8] proof) internal view virtual returns (bool)
``` ```
_Groth16 proof verification_ _Groth16 proof verification_