Skip to content

Commit

Permalink
fix: make all functions virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Jul 31, 2023
1 parent ab148a6 commit a092b93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions contracts/RlnBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ abstract contract RlnBase {

/// Allows a user to register as a 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) {
revert InsufficientDeposit(MEMBERSHIP_DEPOSIT, msg.value);
}
Expand All @@ -98,7 +98,7 @@ abstract contract RlnBase {
/// Registers a member
/// @param idCommitment The idCommitment of 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 (idCommitmentIndex >= SET_SIZE) revert FullTree();

Expand All @@ -114,7 +114,7 @@ abstract contract RlnBase {

/// @dev Allows a user to slash a 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);
_slash(idCommitment, receiver, proof);
}
Expand All @@ -123,7 +123,7 @@ abstract contract RlnBase {
/// stake to the receiver's available withdrawal balance
/// @param idCommitment The idCommitment of the member
/// @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)) {
revert InvalidReceiverAddress(receiver);
}
Expand Down Expand Up @@ -157,7 +157,7 @@ abstract contract RlnBase {
virtual;

/// 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];

if (amount == 0) revert InsufficientWithdrawalBalance();
Expand All @@ -181,6 +181,7 @@ abstract contract RlnBase {
function _verifyProof(uint256 idCommitment, address receiver, uint256[8] calldata proof)
internal
view
virtual
returns (bool)
{
return verifier.verifyProof(
Expand Down
12 changes: 6 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ constructor(uint256 membershipDeposit, uint256 depth, address _poseidonHasher, a
### register

```solidity
function register(uint256 idCommitment) external payable
function register(uint256 idCommitment) external payable virtual
```

Allows a user to register as a member
Expand All @@ -1082,7 +1082,7 @@ Allows a user to register as a member
### \_register

```solidity
function _register(uint256 idCommitment, uint256 stake) internal
function _register(uint256 idCommitment, uint256 stake) internal virtual
```

Registers a member
Expand All @@ -1105,7 +1105,7 @@ _Inheriting contracts MUST override this function_
### slash

```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_
Expand All @@ -1121,7 +1121,7 @@ _Allows a user to slash a member_
### \_slash

```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
Expand All @@ -1144,7 +1144,7 @@ function _validateSlash(uint256 idCommitment, address payable receiver, uint256[
### withdraw

```solidity
function withdraw() external
function withdraw() external virtual
```

Allows a user to withdraw funds allocated to them upon slashing a member
Expand All @@ -1167,7 +1167,7 @@ NOTE: The variant of Poseidon we use accepts only 1 input, assume n=2, and the s
### \_verifyProof

```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_
Expand Down

0 comments on commit a092b93

Please sign in to comment.