From 8acc9d31488e1c9d85a2eaecb73e072dcf23e096 Mon Sep 17 00:00:00 2001 From: vladimir Date: Mon, 18 Dec 2023 17:17:22 +0400 Subject: [PATCH] clean up --- src/interfaces/IOperatorManager.sol | 1 - src/interfaces/IZkBobPool.sol | 3 +- src/zkbob/manager/MPCGuard.sol | 53 +++++--------------- src/zkbob/manager/MutableOperatorManager.sol | 2 +- 4 files changed, 16 insertions(+), 43 deletions(-) diff --git a/src/interfaces/IOperatorManager.sol b/src/interfaces/IOperatorManager.sol index 35bc2d2..22f62c9 100644 --- a/src/interfaces/IOperatorManager.sol +++ b/src/interfaces/IOperatorManager.sol @@ -3,7 +3,6 @@ pragma solidity 0.8.15; interface IOperatorManager { - function operator() external returns (address); function isOperator(address _addr) external view returns (bool); diff --git a/src/interfaces/IZkBobPool.sol b/src/interfaces/IZkBobPool.sol index 868b8ea..b62dc9d 100644 --- a/src/interfaces/IZkBobPool.sol +++ b/src/interfaces/IZkBobPool.sol @@ -19,5 +19,6 @@ interface IZkBobPool { uint256 _out_commit, uint256[8] memory _batch_deposit_proof, uint256[8] memory _tree_proof - ) external; + ) + external; } diff --git a/src/zkbob/manager/MPCGuard.sol b/src/zkbob/manager/MPCGuard.sol index 4fefdb2..48315af 100644 --- a/src/zkbob/manager/MPCGuard.sol +++ b/src/zkbob/manager/MPCGuard.sol @@ -1,4 +1,6 @@ +// SPDX-License-Identifier: MIT pragma solidity 0.8.15; + import "../../../src/zkbob/ZkBobPool.sol"; import "../../utils/Ownable.sol"; import "../utils/CustomABIDecoder.sol"; @@ -51,25 +53,14 @@ contract MPCGuard is Ownable, CustomABIDecoder { uint256 transferRoot = poolContract.roots(_transfer_index()); require( checkQuorum( - signatures, - digest( - abi.encodePacked( - _mpc_message(), - transferRoot, - currentRoot, - poolContract.pool_id() - ) - ) + signatures, digest(abi.encodePacked(_mpc_message(), transferRoot, currentRoot, poolContract.pool_id())) ), "MPCWrapper: wrong quorum" ); _; } - function checkQuorum( - bytes calldata signatures, - bytes32 _digest - ) internal view returns (bool) { + function checkQuorum(bytes calldata signatures, bytes32 _digest) internal view returns (bool) { uint256 offset = 0; assembly { offset := signatures.offset @@ -105,11 +96,11 @@ contract MPCGuard is Ownable, CustomABIDecoder { uint256[8] calldata _batch_deposit_proof, uint256[8] memory _tree_proof, bytes calldata signatures - ) external onlyOperator { - require( - signatures.length == guards.length * SIGNATURE_SIZE, - "MPCWrapper: wrong quorum" - ); + ) + external + onlyOperator + { + require(signatures.length == guards.length * SIGNATURE_SIZE, "MPCWrapper: wrong quorum"); ZkBobPool poolContract = ZkBobPool(pool); @@ -125,13 +116,7 @@ contract MPCGuard is Ownable, CustomABIDecoder { ); require(checkQuorum(signatures, digest(mpc_message))); - IZkBobPool(pool).appendDirectDeposits( - _root_after, - _indices, - _out_commit, - _batch_deposit_proof, - _tree_proof - ); + IZkBobPool(pool).appendDirectDeposits(_root_after, _indices, _out_commit, _batch_deposit_proof, _tree_proof); } function propagate() internal { @@ -145,27 +130,15 @@ contract MPCGuard is Ownable, CustomABIDecoder { // Call the implementation. // out and outsize are 0 because we don't know the size yet. - let result := call( - gas(), - contractAddress, - 0, - 0, - _calldatasize, - 0, - 0 - ) + let result := call(gas(), contractAddress, 0, 0, _calldatasize, 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. - case 0 { - revert(0, returndatasize()) - } - default { - return(0, returndatasize()) - } + case 0 { revert(0, returndatasize()) } + default { return(0, returndatasize()) } } } } diff --git a/src/zkbob/manager/MutableOperatorManager.sol b/src/zkbob/manager/MutableOperatorManager.sol index 35ccf8a..effed4f 100644 --- a/src/zkbob/manager/MutableOperatorManager.sol +++ b/src/zkbob/manager/MutableOperatorManager.sol @@ -42,7 +42,7 @@ contract MutableOperatorManager is IOperatorManager, Ownable { emit UpdateOperator(_operator, _feeReceiver, _operatorURI); } - function isOperator(address _addr) public view virtual returns (bool) { + function isOperator(address _addr) external view override returns (bool) { return operator == _addr || operator == address(0); }