diff --git a/src/zkbob/manager/MPCWrapper.sol b/src/zkbob/manager/MPCWrapper.sol index e2d6b3c..29adfbc 100644 --- a/src/zkbob/manager/MPCWrapper.sol +++ b/src/zkbob/manager/MPCWrapper.sol @@ -52,17 +52,12 @@ contract MPCWrapper is Ownable, CustomABIDecoder { vs := calldataload(add(32, offset)) offset := add(offset, 64) } - console2.log("step", index); - console2.logBytes32(r); - console2.logBytes32(vs); address signer = ECDSA.recover( ECDSA.toEthSignedMessageHash(keccak256(_mpc_message())), r, vs ); if (signer != signers[index]) { - console2.log("signer", signer); - console2.log("signers[index]", signers[index]); return false; } } diff --git a/src/zkbob/utils/CustomABIDecoder.sol b/src/zkbob/utils/CustomABIDecoder.sol index edc3822..09d2459 100644 --- a/src/zkbob/utils/CustomABIDecoder.sol +++ b/src/zkbob/utils/CustomABIDecoder.sol @@ -209,8 +209,6 @@ contract CustomABIDecoder { message.length := message_length } - console2.log("_mpc_message"); - console2.logBytes(message); } uint256 constant signatures_count_size = 1; diff --git a/test/zkbob/ZkBobPool.t.sol b/test/zkbob/ZkBobPool.t.sol index ec8bb80..bb10552 100644 --- a/test/zkbob/ZkBobPool.t.sol +++ b/test/zkbob/ZkBobPool.t.sol @@ -30,7 +30,6 @@ import "../../src/zkbob/ZkBobPoolBOB.sol"; import "../../src/zkbob/ZkBobPoolETH.sol"; import "../../src/infra/UniswapV3Seller.sol"; import {EnergyRedeemer} from "../../src/infra/EnergyRedeemer.sol"; -import "forge-std/console2.sol"; abstract contract AbstractZkBobPoolTest is AbstractForkTest { address constant permit2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3; @@ -56,12 +55,12 @@ abstract contract AbstractZkBobPoolTest is AbstractForkTest { address token; address weth; address tempToken; - address wrapper; bool autoApproveQueue; PoolType poolType; PermitType permitType; uint256 denominator; uint256 precision; + bool isMPC = false; bytes constant zkAddress = "QsnTijXekjRm9hKcq5kLNPsa6P4HtMRrc3RxVx3jsLHeo2AiysYxVJP86mriHfN"; @@ -148,14 +147,18 @@ abstract contract AbstractZkBobPoolTest is AbstractForkTest { 0 ); pool.setAccounting(accounting); - address relayer = makeAddr("relayer"); - wrapper = address(new MPCWrapper(relayer, address(pool))); - (address signer1Addr, uint256 signer1Key) = makeAddrAndKey("signer1"); - (address signer2Addr, uint256 signer2Key) = makeAddrAndKey("signer2"); - signers.push(signer1Addr); - signers.push(signer2Addr); - MPCWrapper(wrapper).setSigners(signers); - operatorManager = new MutableOperatorManager(wrapper, user3, "https://example.com"); + address operatorEOA = makeAddr("operatorEOA"); + if(isMPC) { + address operatorContract = address(new MPCWrapper(operatorEOA, address(pool))); + operatorManager = new MutableOperatorManager(operatorContract, user3, "https://example.com"); + (address signer1Addr, uint256 signer1Key) = makeAddrAndKey("signer1"); + (address signer2Addr, uint256 signer2Key) = makeAddrAndKey("signer2"); + signers.push(signer1Addr); + signers.push(signer2Addr); + MPCWrapper(operatorContract).setSigners(signers); + } else { + operatorManager = new MutableOperatorManager(operatorEOA, user3, "https://example.com"); + } pool.setOperatorManager(operatorManager); queue.setOperatorManager(operatorManager); queue.setDirectDepositFee(uint64(0.1 ether / D)); diff --git a/test/zkbob/manager/MPCWrapper.t.sol b/test/zkbob/manager/MPCWrapper.t.sol index 6f6ba58..12e438c 100644 --- a/test/zkbob/manager/MPCWrapper.t.sol +++ b/test/zkbob/manager/MPCWrapper.t.sol @@ -5,15 +5,13 @@ import "../ZkBobPool.t.sol"; import "../../shared/Env.t.sol"; import "../../shared/ForkTests.t.sol"; -import "forge-std/console2.sol"; contract MPCOperatorManagerTest is AbstractZkBobPoolTest, AbstractPolygonForkTest { - // address[] signers; - constructor() { + isMPC = true; D = 1; token = address(0xB0B195aEFA3650A6908f15CdaC7D92F8a5791B0B); weth = address(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270); @@ -25,34 +23,40 @@ contract MPCOperatorManagerTest is precision = 1_000_000_000; } - function testTransact() public { - bytes memory data = _encodeDeposit(1 ether, 0.1 ether); //752 - // data = abi.encodePacked(data, ); //753 - (address signer1Addr, uint256 signer1Key) = makeAddrAndKey("signer1"); - (address signer2Addr, uint256 signer2Key) = makeAddrAndKey("signer2"); - data = abi.encodePacked( - data, - uint8(2), - sign(data, signer1Key), - sign(data, signer2Key) - ); - console2.log("full data length", data.length); - console2.logBytes(data); - address operator = makeAddr("operator"); + function testDepositMPC() public { + vm.prank(user1); + IERC20(token).approve(address(pool),1 ether); + bytes memory data = withMPC(_encodeDeposit(0.1 ether, 0.01 ether)); //752 + _transactMPC(data); + } + function testPermitDepositMPC() public { + bytes memory data = withMPC(_encodePermitDeposit(0.1 ether, 0.01 ether)); //752 + _transactMPC(data); + } + + function _transactMPC(bytes memory data) internal { + address operator = makeAddr("operatorEOA"); + address wrapper = operatorManager.operator(); vm.prank(operator); (bool status, ) = address(wrapper).call(data); require(status, "transact() reverted"); } + function withMPC(bytes memory data) internal returns (bytes memory){ + (address signer1Addr, uint256 signer1Key) = makeAddrAndKey("signer1"); + (address signer2Addr, uint256 signer2Key) = makeAddrAndKey("signer2"); + return abi.encodePacked( + data, + uint8(2),//753 + sign(data, signer1Key),//817 + sign(data, signer2Key)//881 + ); + } function sign( bytes memory data, uint256 key ) internal returns (bytes memory signatureData) { - console2.log("data being sigend"); - console2.logBytes(data); bytes32 digest = ECDSA.toEthSignedMessageHash(keccak256(data)); - console2.log("digest"); - console2.logBytes32(digest); (uint8 v, bytes32 r, bytes32 s) = vm.sign(key, digest); signatureData = abi.encodePacked( r,