Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
r0wdy1 committed Dec 18, 2023
1 parent 96c1e5e commit 8acc9d3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 43 deletions.
1 change: 0 additions & 1 deletion src/interfaces/IOperatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
pragma solidity 0.8.15;

interface IOperatorManager {

function operator() external returns (address);

function isOperator(address _addr) external view returns (bool);
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/IZkBobPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ interface IZkBobPool {
uint256 _out_commit,
uint256[8] memory _batch_deposit_proof,
uint256[8] memory _tree_proof
) external;
)
external;
}
53 changes: 13 additions & 40 deletions src/zkbob/manager/MPCGuard.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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 {
Expand All @@ -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()) }
}
}
}
2 changes: 1 addition & 1 deletion src/zkbob/manager/MutableOperatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 8acc9d3

Please sign in to comment.