Skip to content

Commit

Permalink
adds dd selector
Browse files Browse the repository at this point in the history
  • Loading branch information
r0wdy1 committed Dec 15, 2023
1 parent 25d442b commit ea116c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/zkbob/manager/MPCGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -128,7 +130,7 @@ contract MPCGuard is Ownable, CustomABIDecoder {
contractAddress,
0,
0,
calldatasize(),
_calldatasize,
0,
0
)
Expand Down
2 changes: 1 addition & 1 deletion src/zkbob/utils/CustomABIDecoder.sol
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 5 additions & 4 deletions test/zkbob/manager/MPCGuard.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit ea116c3

Please sign in to comment.