diff --git a/beacon-light-client/solidity/contracts/Errors.sol b/beacon-light-client/solidity/contracts/Errors.sol new file mode 100644 index 000000000..9db1f9325 --- /dev/null +++ b/beacon-light-client/solidity/contracts/Errors.sol @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.19; + +/// @dev Proxy contract address is zero +error ZeroAddressError(); diff --git a/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifier.sol b/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifier.sol index 8371738e9..24d9c31df 100644 --- a/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifier.sol +++ b/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifier.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.20; import {PlonkVerifier} from './verifier.sol'; import {IBalanceVerifier} from './interfaces/IBalanceVerifierDiva.sol'; +import {ZeroAddressError} from '../Errors.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; abstract contract BalanceVerifier is Ownable, IBalanceVerifier { @@ -28,12 +29,19 @@ abstract contract BalanceVerifier is Ownable, IBalanceVerifier { address _verifier, address _owner ) Ownable(_owner) { + if (_verifier == address(0)) { + revert ZeroAddressError(); + } + verifier = _verifier; + VERIFIER_DIGEST = verifierDigest; GENESIS_BLOCK_TIMESTAMP = genesisBlockTimestamp; - verifier = _verifier; } function setVerifier(address _verifier) external override onlyOwner { + if (_verifier == address(0)) { + revert ZeroAddressError(); + } verifier = _verifier; } diff --git a/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifierDiva.sol b/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifierDiva.sol index 76b63b4d5..0b8a426d7 100644 --- a/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifierDiva.sol +++ b/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifierDiva.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.19; import {BalanceVerifier} from './BalanceVerifier.sol'; import {IBalanceVerifierDiva} from './interfaces/IBalanceVerifierDiva.sol'; import {IValidatorsAccumulator} from '../validators_accumulator/interfaces/IValidatorsAccumulator.sol'; +import {ZeroAddressError} from '../Errors.sol'; contract BalanceVerifierDiva is BalanceVerifier, IBalanceVerifierDiva { /// @notice The address of the validators accumulator contract. @@ -18,6 +19,9 @@ contract BalanceVerifierDiva is BalanceVerifier, IBalanceVerifierDiva { address _accumulator, address _owner ) BalanceVerifier(verifierDigest, genesisBlockTimestamp, _verifier, _owner) { + if (_accumulator == address(0)) { + revert ZeroAddressError(); + } ACCUMULATOR = _accumulator; } @@ -81,6 +85,9 @@ contract BalanceVerifierDiva is BalanceVerifier, IBalanceVerifierDiva { } function setAccumulator(address _accumulator) external override onlyOwner { + if (_accumulator == address(0)) { + revert ZeroAddressError(); + } ACCUMULATOR = _accumulator; } diff --git a/beacon-light-client/solidity/contracts/validators_accumulator/ValidatorsAccumulator.sol b/beacon-light-client/solidity/contracts/validators_accumulator/ValidatorsAccumulator.sol index a697228dc..4e2866edc 100644 --- a/beacon-light-client/solidity/contracts/validators_accumulator/ValidatorsAccumulator.sol +++ b/beacon-light-client/solidity/contracts/validators_accumulator/ValidatorsAccumulator.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.18; import {IDeposit} from './interfaces/IDeposit.sol'; import {IValidatorsAccumulator} from './interfaces/IValidatorsAccumulator.sol'; +import {ZeroAddressError} from '../Errors.sol'; contract ValidatorsAccumulator is IValidatorsAccumulator { // The depth of the validator accumulator tree @@ -21,6 +22,9 @@ contract ValidatorsAccumulator is IValidatorsAccumulator { mapping(uint256 => DepositData) internal snapshots; constructor(address _depositAddress) { + if (_depositAddress == address(0)) { + revert ZeroAddressError(); + } depositAddress = _depositAddress; // Compute hashes in empty Merkle tree