From ea116c3fac0fecc6cd5343cf36b99eeaf00348c2 Mon Sep 17 00:00:00 2001 From: vladimir Date: Fri, 15 Dec 2023 14:58:07 +0400 Subject: [PATCH] adds dd selector --- src/zkbob/manager/MPCGuard.sol | 6 ++++-- src/zkbob/utils/CustomABIDecoder.sol | 2 +- test/zkbob/manager/MPCGuard.t.sol | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/zkbob/manager/MPCGuard.sol b/src/zkbob/manager/MPCGuard.sol index 41a62ff..852658b 100644 --- a/src/zkbob/manager/MPCGuard.sol +++ b/src/zkbob/manager/MPCGuard.sol @@ -94,6 +94,7 @@ contract MPCGuard is Ownable, CustomABIDecoder { require(signatures.length == guards.length * SIGNATURE_SIZE, "MPCWrapper: wrong quorum"); bytes memory mpc_message = abi.encodePacked( + ZkBobPool(pool).appendDirectDeposits.selector, _root_after, _indices, _out_commit, @@ -115,11 +116,12 @@ contract MPCGuard is Ownable, CustomABIDecoder { function propagate() internal { address contractAddress = pool; + uint256 _calldatasize = _mpc_signatures_pos(); //we don't need to propagate signatures assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. - calldatacopy(0, 0, calldatasize()) + calldatacopy(0, 0, _calldatasize) // Call the implementation. // out and outsize are 0 because we don't know the size yet. @@ -128,7 +130,7 @@ contract MPCGuard is Ownable, CustomABIDecoder { contractAddress, 0, 0, - calldatasize(), + _calldatasize, 0, 0 ) diff --git a/src/zkbob/utils/CustomABIDecoder.sol b/src/zkbob/utils/CustomABIDecoder.sol index 09d2459..801ed30 100644 --- a/src/zkbob/utils/CustomABIDecoder.sol +++ b/src/zkbob/utils/CustomABIDecoder.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.15; -import "forge-std/console2.sol"; + contract CustomABIDecoder { uint256 constant transfer_nullifier_pos = 4; uint256 constant transfer_nullifier_size = 32; diff --git a/test/zkbob/manager/MPCGuard.t.sol b/test/zkbob/manager/MPCGuard.t.sol index e017028..c321600 100644 --- a/test/zkbob/manager/MPCGuard.t.sol +++ b/test/zkbob/manager/MPCGuard.t.sol @@ -48,8 +48,8 @@ contract MPCOperatorManagerTest is } function withMPC(bytes memory data) internal returns (bytes memory) { - (address guard1Addr, uint256 guard1Key) = makeAddrAndKey("guard1"); - (address guard2Addr, uint256 guard2Key) = makeAddrAndKey("guard2"); + (, uint256 guard1Key) = makeAddrAndKey("guard1"); + (, uint256 guard2Key) = makeAddrAndKey("guard2"); return abi.encodePacked( data, @@ -115,11 +115,12 @@ contract MPCOperatorManagerTest is ); // vm.expectEmit(true, false, false, true); emit Message(128, bytes32(0), message); - vm.prank(user2); + uint256 root_afer = _randFR(); uint256[8] memory batch_deposit_proof = _randProof(); uint256[8] memory tree_proof = _randProof(); bytes memory mpcMessage = abi.encodePacked( + ZkBobPool.appendDirectDeposits.selector, root_afer, indices, outCommitment, @@ -130,7 +131,7 @@ contract MPCOperatorManagerTest is (, uint256 guard1Key) = makeAddrAndKey("guard1"); (, uint256 guard2Key) = makeAddrAndKey("guard2"); - + vm.prank(makeAddr("operatorEOA")); MPCGuard(wrapper).appendDirectDepositsMPC( root_afer, indices,