diff --git a/beacon-light-client/plonky2/input_fetchers/balance_verification/abi/validators_accumulator_abi.json b/beacon-light-client/plonky2/input_fetchers/balance_verification/abi/validators_accumulator_abi.json index 1950af76c..e0f43cbbc 100644 --- a/beacon-light-client/plonky2/input_fetchers/balance_verification/abi/validators_accumulator_abi.json +++ b/beacon-light-client/plonky2/input_fetchers/balance_verification/abi/validators_accumulator_abi.json @@ -10,6 +10,11 @@ "stateMutability": "nonpayable", "type": "constructor" }, + { + "inputs": [], + "name": "ZeroAddressError", + "type": "error" + }, { "anonymous": false, "inputs": [ 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 ecc8b9bd0..bd3bfc8be 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 73e8a9b4f..6412e8446 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; } @@ -80,6 +84,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 19d254818..1b591d7f6 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 { uint256[] internal blockNumbers; constructor(address _depositAddress) { + if (_depositAddress == address(0)) { + revert ZeroAddressError(); + } depositAddress = _depositAddress; // Compute hashes in empty Merkle tree