diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/L1/libs/LibProving.sol index a7f31a9ddb1..b7ee0fcd699 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/L1/libs/LibProving.sol @@ -153,10 +153,7 @@ library LibProving { IVerifier.Context memory ctx = IVerifier.Context({ metaHash: blk.metaHash, blobHash: meta.blobHash, - // TODO(Brecht): Quite limiting this is required to be the same address as - // msg.sender, less flexibility on the prover's side for proof generation/proof - // submission using multiple accounts. - // Added msgSender to allow the prover to be any address in the future. + // Separate msgSender to allow the prover to be any address in the future. prover: msg.sender, msgSender: msg.sender, blockId: blk.blockId, @@ -319,8 +316,6 @@ library LibProving { // In scenarios where this transition is not the first one, we // straightforwardly reset the transition prover to address // zero. - // TODO(Brecht): Is it sure that in all cases all the neccessary data is stored - // in the transition in this case after this code? ts.prover = address(0); // Furthermore, we index the transition for future retrieval. diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index ead8b460929..d1e819597de 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -137,7 +137,9 @@ contract Bridge is EssentialContract, IBridge { returns (bytes32 msgHash, Message memory _message) { // Ensure the message owner is not null. - if (message.owner == address(0)) revert B_INVALID_USER(); + if (message.srcOwner == address(0) || message.destOwner == address(0)) { + revert B_INVALID_USER(); + } // Check if the destination chain is enabled. (bool destChainEnabled,) = isDestChainEnabled(message.destChainId); @@ -227,7 +229,7 @@ contract Bridge is EssentialContract, IBridge { // Reset the context after the message call _resetContext(); } else { - message.owner.sendEther(message.value); + message.srcOwner.sendEther(message.value); } emit MessageRecalled(msgHash); } else if (!isMessageProven) { @@ -238,7 +240,7 @@ contract Bridge is EssentialContract, IBridge { } /// @notice Processes a bridge message on the destination chain. This - /// function is callable by any address, including the `message.owner`. + /// function is callable by any address, including the `message.destOwner`. /// @dev The process begins by hashing the message and checking the message /// status in the bridge If the status is "NEW", the message is invoked. The /// status is updated accordingly, and processing fees are refunded as @@ -254,10 +256,6 @@ contract Bridge is EssentialContract, IBridge { whenNotPaused sameChain(message.destChainId) { - // TODO(Brecht): `message.owner`, but this is the `msg.sender` on the source chain. - // If the address is not owned by the same entity on the destination chain - // (e.g. can be the case for smart wallets/general contracts) this can give unexpected - // results (especially with refunding). bytes32 msgHash = hashMessage(message); if (messageStatus[msgHash] != Status.NEW) revert B_STATUS_MISMATCH(); @@ -277,7 +275,7 @@ contract Bridge is EssentialContract, IBridge { if (invocationDelay != 0) { proofReceipt[msgHash] = ProofReceipt({ receivedAt: receivedAt, - preferredExecutor: message.gasLimit == 0 ? message.owner : msg.sender + preferredExecutor: message.gasLimit == 0 ? message.destOwner : msg.sender }); } } @@ -292,7 +290,7 @@ contract Bridge is EssentialContract, IBridge { if (block.timestamp >= invocationDelay + receivedAt) { // If the gas limit is set to zero, only the owner can process the message. - if (message.gasLimit == 0 && msg.sender != message.owner) { + if (message.gasLimit == 0 && msg.sender != message.destOwner) { revert B_PERMISSION_DENIED(); } @@ -312,7 +310,7 @@ contract Bridge is EssentialContract, IBridge { } else { // Use the specified message gas limit if called by the owner, else // use remaining gas - uint256 gasLimit = msg.sender == message.owner ? gasleft() : message.gasLimit; + uint256 gasLimit = msg.sender == message.destOwner ? gasleft() : message.gasLimit; if (_invokeMessageCall(message, msgHash, gasLimit)) { _updateMessageStatus(msgHash, Status.DONE); @@ -322,7 +320,7 @@ contract Bridge is EssentialContract, IBridge { } // Determine the refund recipient - address refundTo = message.refundTo == address(0) ? message.owner : message.refundTo; + address refundTo = message.refundTo == address(0) ? message.destOwner : message.refundTo; // Refund the processing fee if (msg.sender == refundTo) { @@ -343,7 +341,7 @@ contract Bridge is EssentialContract, IBridge { /// @notice Retries to invoke the messageCall after releasing associated /// Ether and tokens. /// @dev This function can be called by any address, including the - /// `message.owner`. + /// `message.destOwner`. /// It attempts to invoke the messageCall and updates the message status /// accordingly. /// @param message The message to retry. @@ -359,9 +357,9 @@ contract Bridge is EssentialContract, IBridge { sameChain(message.destChainId) { // If the gasLimit is set to 0 or isLastAttempt is true, the caller must - // be the message.owner. + // be the message.destOwner. if (message.gasLimit == 0 || isLastAttempt) { - if (msg.sender != message.owner) revert B_PERMISSION_DENIED(); + if (msg.sender != message.destOwner) revert B_PERMISSION_DENIED(); } bytes32 msgHash = hashMessage(message); diff --git a/packages/protocol/contracts/bridge/IBridge.sol b/packages/protocol/contracts/bridge/IBridge.sol index 0a4a6c5e3a0..db509f1e4e8 100644 --- a/packages/protocol/contracts/bridge/IBridge.sol +++ b/packages/protocol/contracts/bridge/IBridge.sol @@ -27,11 +27,14 @@ interface IBridge { uint64 srcChainId; // Destination chain ID where the `to` address lives. uint64 destChainId; - // The owner of the message. - address owner; + // The owner of the message on the source chain. + address srcOwner; + // The owner of the message on the destination chain. + address destOwner; // The destination address on the destination chain. address to; - // Alternate address to send any refund. If blank, defaults to owner. + // Alternate address to send any refund on the destination chain. + // If blank, defaults to destOwner. address refundTo; // value to invoke on the destination chain. uint256 value; diff --git a/packages/protocol/contracts/tokenvault/BaseNFTVault.sol b/packages/protocol/contracts/tokenvault/BaseNFTVault.sol index c1e5306aff4..313a5bae018 100644 --- a/packages/protocol/contracts/tokenvault/BaseNFTVault.sol +++ b/packages/protocol/contracts/tokenvault/BaseNFTVault.sol @@ -35,6 +35,8 @@ abstract contract BaseNFTVault is BaseVault { struct BridgeTransferOp { // Destination chain ID. uint64 destChainId; + // The owner of the bridge message on the destination chain. + address destOwner; // Recipient address. address to; // Address of the token. diff --git a/packages/protocol/contracts/tokenvault/ERC1155Vault.sol b/packages/protocol/contracts/tokenvault/ERC1155Vault.sol index 68972d3dc45..83e09bb4c62 100644 --- a/packages/protocol/contracts/tokenvault/ERC1155Vault.sol +++ b/packages/protocol/contracts/tokenvault/ERC1155Vault.sol @@ -65,7 +65,8 @@ contract ERC1155Vault is BaseNFTVault, ERC1155ReceiverUpgradeable { IBridge.Message memory message; message.destChainId = op.destChainId; message.data = data; - message.owner = msg.sender; + message.srcOwner = msg.sender; + message.destOwner = op.destOwner != address(0) ? op.destOwner : msg.sender; message.to = resolve(message.destChainId, name(), false); message.gasLimit = op.gasLimit; message.value = msg.value - op.fee; @@ -81,7 +82,7 @@ contract ERC1155Vault is BaseNFTVault, ERC1155ReceiverUpgradeable { // Emit TokenSent event emit TokenSent({ msgHash: msgHash, - from: _message.owner, + from: _message.srcOwner, to: op.to, destChainId: _message.destChainId, ctoken: ctoken.addr, @@ -152,13 +153,13 @@ contract ERC1155Vault is BaseNFTVault, ERC1155ReceiverUpgradeable { abi.decode(message.data[4:], (CanonicalNFT, address, address, uint256[], uint256[])); // Transfer the ETH and tokens back to the owner - address token = _transferTokens(ctoken, message.owner, tokenIds, amounts); - message.owner.sendEther(message.value); + address token = _transferTokens(ctoken, message.srcOwner, tokenIds, amounts); + message.srcOwner.sendEther(message.value); // Emit TokenReleased event emit TokenReleased({ msgHash: msgHash, - from: message.owner, + from: message.srcOwner, ctoken: ctoken.addr, token: token, tokenIds: tokenIds, diff --git a/packages/protocol/contracts/tokenvault/ERC20Vault.sol b/packages/protocol/contracts/tokenvault/ERC20Vault.sol index 983f091495d..567b709c5d2 100644 --- a/packages/protocol/contracts/tokenvault/ERC20Vault.sol +++ b/packages/protocol/contracts/tokenvault/ERC20Vault.sol @@ -40,6 +40,7 @@ contract ERC20Vault is BaseVault { struct BridgeTransferOp { uint64 destChainId; + address destOwner; address to; address token; uint256 amount; @@ -186,7 +187,8 @@ contract ERC20Vault is BaseVault { _handleMessage({ user: msg.sender, token: op.token, amount: op.amount, to: op.to }); message.destChainId = op.destChainId; - message.owner = msg.sender; + message.srcOwner = msg.sender; + message.destOwner = op.destOwner != address(0) ? op.destOwner : msg.sender; message.to = resolve(op.destChainId, name(), false); message.gasLimit = op.gasLimit; message.value = msg.value - op.fee; @@ -200,7 +202,7 @@ contract ERC20Vault is BaseVault { emit TokenSent({ msgHash: msgHash, - from: _message.owner, + from: _message.srcOwner, to: op.to, destChainId: op.destChainId, ctoken: ctoken.addr, @@ -262,12 +264,12 @@ contract ERC20Vault is BaseVault { abi.decode(message.data[4:], (CanonicalERC20, address, address, uint256)); // Transfer the ETH and tokens back to the owner - address token = _transferTokens(ctoken, message.owner, amount); - message.owner.sendEther(message.value); + address token = _transferTokens(ctoken, message.srcOwner, amount); + message.srcOwner.sendEther(message.value); emit TokenReleased({ msgHash: msgHash, - from: message.owner, + from: message.srcOwner, ctoken: ctoken.addr, token: token, amount: amount diff --git a/packages/protocol/contracts/tokenvault/ERC721Vault.sol b/packages/protocol/contracts/tokenvault/ERC721Vault.sol index f4c774c9a4f..b87663d3fb2 100644 --- a/packages/protocol/contracts/tokenvault/ERC721Vault.sol +++ b/packages/protocol/contracts/tokenvault/ERC721Vault.sol @@ -55,7 +55,8 @@ contract ERC721Vault is BaseNFTVault, IERC721ReceiverUpgradeable { IBridge.Message memory message; message.destChainId = op.destChainId; message.data = data; - message.owner = msg.sender; + message.srcOwner = msg.sender; + message.destOwner = op.destOwner != address(0) ? op.destOwner : msg.sender; message.to = resolve(message.destChainId, name(), false); message.gasLimit = op.gasLimit; message.value = msg.value - op.fee; @@ -69,7 +70,7 @@ contract ERC721Vault is BaseNFTVault, IERC721ReceiverUpgradeable { emit TokenSent({ msgHash: msgHash, - from: _message.owner, + from: _message.srcOwner, to: op.to, destChainId: _message.destChainId, ctoken: ctoken.addr, @@ -133,12 +134,12 @@ contract ERC721Vault is BaseNFTVault, IERC721ReceiverUpgradeable { abi.decode(message.data[4:], (CanonicalNFT, address, address, uint256[])); // Transfer the ETH and tokens back to the owner - address token = _transferTokens(ctoken, message.owner, tokenIds); - message.owner.sendEther(message.value); + address token = _transferTokens(ctoken, message.srcOwner, tokenIds); + message.srcOwner.sendEther(message.value); emit TokenReleased({ msgHash: msgHash, - from: message.owner, + from: message.srcOwner, ctoken: ctoken.addr, token: token, tokenIds: tokenIds, diff --git a/packages/protocol/genesis/GenerateGenesis.g.sol b/packages/protocol/genesis/GenerateGenesis.g.sol index 31d15f65065..596694eb9bc 100644 --- a/packages/protocol/genesis/GenerateGenesis.g.sol +++ b/packages/protocol/genesis/GenerateGenesis.g.sol @@ -160,7 +160,8 @@ contract TestGenerateGenesis is Test, AddressResolver { from: address(0), srcChainId: 1, destChainId: 167, - owner: address(0), + srcOwner: address(0), + destOwner: address(0), to: address(0), refundTo: address(0), value: 0, @@ -185,7 +186,8 @@ contract TestGenerateGenesis is Test, AddressResolver { from: address(0), srcChainId: 1, destChainId: 167, - owner: address(0), + srcOwner: address(0), + destOwner: address(0), to: address(0), refundTo: address(0), value: 0, diff --git a/packages/protocol/test/bridge/Bridge.t.sol b/packages/protocol/test/bridge/Bridge.t.sol index c7dd95a4992..5a9c4895d1a 100644 --- a/packages/protocol/test/bridge/Bridge.t.sol +++ b/packages/protocol/test/bridge/Bridge.t.sol @@ -129,7 +129,8 @@ contract BridgeTest is TaikoTest { from: address(bridge), srcChainId: uint64(block.chainid), destChainId: destChainId, - owner: Alice, + srcOwner: Alice, + destOwner: Alice, to: Alice, refundTo: Alice, value: 1000, @@ -166,7 +167,8 @@ contract BridgeTest is TaikoTest { from: address(bridge), srcChainId: uint64(block.chainid), destChainId: destChainId, - owner: Alice, + srcOwner: Alice, + destOwner: Alice, to: Alice, refundTo: Alice, value: 1000, @@ -222,7 +224,8 @@ contract BridgeTest is TaikoTest { from: address(bridge), srcChainId: uint64(block.chainid), destChainId: destChainId, - owner: Alice, + srcOwner: Alice, + destOwner: Alice, to: Alice, refundTo: Alice, value: 1000, @@ -273,7 +276,8 @@ contract BridgeTest is TaikoTest { from: address(bridge), srcChainId: uint64(block.chainid), destChainId: destChainId, - owner: Alice, + srcOwner: Alice, + destOwner: Alice, to: address(goodReceiver), refundTo: Alice, value: 1000, @@ -310,7 +314,8 @@ contract BridgeTest is TaikoTest { from: address(bridge), srcChainId: uint64(block.chainid), destChainId: destChainId, - owner: Alice, + srcOwner: Alice, + destOwner: Alice, to: address(goodReceiver), refundTo: Alice, value: 1000, @@ -586,12 +591,12 @@ contract BridgeTest is TaikoTest { vm.stopPrank(); - vm.prank(message.owner); + vm.prank(message.destOwner); destChainBridge.retryMessage(message, false); Bridge.Status postRetryStatus = destChainBridge.messageStatus(msgHash); assertEq(postRetryStatus == Bridge.Status.RETRIABLE, true); - vm.prank(message.owner); + vm.prank(message.destOwner); destChainBridge.retryMessage(message, true); postRetryStatus = destChainBridge.messageStatus(msgHash); assertEq(postRetryStatus == Bridge.Status.FAILED, true); @@ -658,7 +663,8 @@ contract BridgeTest is TaikoTest { from: 0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39, srcChainId: 1336, destChainId: dest, - owner: 0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39, + srcOwner: 0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39, + destOwner: 0xDf08F82De32B8d460adbE8D72043E3a7e25A3B39, to: 0x200708D76eB1B69761c23821809d53F65049939e, refundTo: 0x10020FCb72e27650651B05eD2CEcA493bC807Ba4, value: 1000, @@ -687,7 +693,8 @@ contract BridgeTest is TaikoTest { returns (IBridge.Message memory) { return IBridge.Message({ - owner: owner, + srcOwner: owner, + destOwner: owner, destChainId: destChain, to: to, value: value, diff --git a/packages/protocol/test/tokenvault/ERC1155Vault.t.sol b/packages/protocol/test/tokenvault/ERC1155Vault.t.sol index 779877714a4..e59015104ab 100644 --- a/packages/protocol/test/tokenvault/ERC1155Vault.t.sol +++ b/packages/protocol/test/tokenvault/ERC1155Vault.t.sol @@ -237,7 +237,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 2; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: 140_000 }(sendOpts); @@ -260,7 +269,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 2; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(0), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(0), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); vm.expectRevert(BaseNFTVault.VAULT_INVALID_TOKEN.selector); @@ -281,7 +299,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 0; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); vm.expectRevert(BaseNFTVault.VAULT_INVALID_AMOUNT.selector); @@ -305,7 +332,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 2; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: 140_000 }(sendOpts); @@ -360,7 +396,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 2; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: 140_000 }(sendOpts); @@ -404,7 +449,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 1; sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: 140_000 }(sendOpts); @@ -449,7 +503,16 @@ contract ERC1155VaultTest is TaikoTest { uint256 etherValue = 0.1 ether; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, David, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + David, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: etherValue }(sendOpts); @@ -503,7 +566,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 2; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); @@ -538,7 +610,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[1] = 5; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: 140_000 }(sendOpts); @@ -594,7 +675,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 1; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: 140_000 }(sendOpts); @@ -644,7 +734,16 @@ contract ERC1155VaultTest is TaikoTest { ERC1155(deployedContract).setApprovalForAll(address(destChainErc1155Vault), true); sendOpts = BaseNFTVault.BridgeTransferOp( - chainId, Bob, address(deployedContract), tokenIds, amounts, 140_000, 140_000, Bob, "" + chainId, + address(0), + Bob, + address(deployedContract), + tokenIds, + amounts, + 140_000, + 140_000, + Bob, + "" ); vm.prank(Bob, Bob); @@ -690,7 +789,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 1; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: 140_000 }(sendOpts); @@ -740,7 +848,16 @@ contract ERC1155VaultTest is TaikoTest { ERC1155(deployedContract).setApprovalForAll(address(destChainErc1155Vault), true); sendOpts = BaseNFTVault.BridgeTransferOp( - chainId, Alice, address(deployedContract), tokenIds, amounts, 140_000, 140_000, Bob, "" + chainId, + address(0), + Alice, + address(deployedContract), + tokenIds, + amounts, + 140_000, + 140_000, + Bob, + "" ); vm.prank(Alice, Alice); @@ -762,7 +879,16 @@ contract ERC1155VaultTest is TaikoTest { amounts[0] = 2; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(ctoken1155), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(ctoken1155), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); erc1155Vault.sendToken{ value: 140_000 }(sendOpts); diff --git a/packages/protocol/test/tokenvault/ERC20Vault.t.sol b/packages/protocol/test/tokenvault/ERC20Vault.t.sol index 7a84218c4f2..0d9f07988bf 100644 --- a/packages/protocol/test/tokenvault/ERC20Vault.t.sol +++ b/packages/protocol/test/tokenvault/ERC20Vault.t.sol @@ -176,7 +176,7 @@ contract TestERC20Vault is TaikoTest { vm.expectRevert("ERC20: insufficient allowance"); erc20Vault.sendToken( ERC20Vault.BridgeTransferOp( - destChainId, Bob, address(erc20), 1 wei, 1_000_000, 1, Bob, "" + destChainId, address(0), Bob, address(erc20), 1 wei, 1_000_000, 1, Bob, "" ) ); } @@ -192,7 +192,7 @@ contract TestERC20Vault is TaikoTest { erc20Vault.sendToken( ERC20Vault.BridgeTransferOp( - destChainId, Bob, address(erc20), amount, 1_000_000, 0, Bob, "" + destChainId, address(0), Bob, address(erc20), amount, 1_000_000, 0, Bob, "" ) ); @@ -212,7 +212,7 @@ contract TestERC20Vault is TaikoTest { vm.expectRevert(); erc20Vault.sendToken( ERC20Vault.BridgeTransferOp( - destChainId, Bob, address(erc20), amount, 1_000_000, amount - 1, Bob, "" + destChainId, address(0), Bob, address(erc20), amount, 1_000_000, amount - 1, Bob, "" ) ); } @@ -229,6 +229,7 @@ contract TestERC20Vault is TaikoTest { erc20Vault.sendToken{ value: amount }( ERC20Vault.BridgeTransferOp( destChainId, + address(0), Bob, address(erc20), amount - 1, // value: (msg.value - fee) @@ -254,7 +255,7 @@ contract TestERC20Vault is TaikoTest { vm.expectRevert(ERC20Vault.VAULT_INVALID_AMOUNT.selector); erc20Vault.sendToken( ERC20Vault.BridgeTransferOp( - destChainId, Bob, address(erc20), amount, 1_000_000, 0, Bob, "" + destChainId, address(0), Bob, address(erc20), amount, 1_000_000, 0, Bob, "" ) ); } @@ -266,7 +267,9 @@ contract TestERC20Vault is TaikoTest { vm.expectRevert(ERC20Vault.VAULT_INVALID_TOKEN.selector); erc20Vault.sendToken( - ERC20Vault.BridgeTransferOp(destChainId, Bob, address(0), amount, 1_000_000, 0, Bob, "") + ERC20Vault.BridgeTransferOp( + destChainId, address(0), Bob, address(0), amount, 1_000_000, 0, Bob, "" + ) ); } @@ -447,7 +450,7 @@ contract TestERC20Vault is TaikoTest { IBridge.Message memory _messageToSimulateFail = erc20Vault.sendToken( ERC20Vault.BridgeTransferOp( - destChainId, Bob, address(erc20), amount, 1_000_000, 0, Bob, "" + destChainId, address(0), Bob, address(erc20), amount, 1_000_000, 0, Bob, "" ) ); diff --git a/packages/protocol/test/tokenvault/ERC721Vault.t.sol b/packages/protocol/test/tokenvault/ERC721Vault.t.sol index 754370575b9..1e33cc68df9 100644 --- a/packages/protocol/test/tokenvault/ERC721Vault.t.sol +++ b/packages/protocol/test/tokenvault/ERC721Vault.t.sol @@ -245,6 +245,7 @@ contract ERC721VaultTest is TaikoTest { BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -273,7 +274,16 @@ contract ERC721VaultTest is TaikoTest { amounts[0] = 0; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( - destChainId, Alice, address(0), tokenIds, amounts, 140_000, 140_000, Alice, "" + destChainId, + address(0), + Alice, + address(0), + tokenIds, + amounts, + 140_000, + 140_000, + Alice, + "" ); vm.prank(Alice, Alice); vm.expectRevert(BaseNFTVault.VAULT_INVALID_TOKEN.selector); @@ -293,6 +303,7 @@ contract ERC721VaultTest is TaikoTest { amounts[0] = 1; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -324,6 +335,7 @@ contract ERC721VaultTest is TaikoTest { BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -376,6 +388,7 @@ contract ERC721VaultTest is TaikoTest { BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -423,6 +436,7 @@ contract ERC721VaultTest is TaikoTest { sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -465,6 +479,7 @@ contract ERC721VaultTest is TaikoTest { uint256 etherValue = 0.1 ether; BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), David, address(canonicalToken721), tokenIds, @@ -523,6 +538,7 @@ contract ERC721VaultTest is TaikoTest { BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -563,6 +579,7 @@ contract ERC721VaultTest is TaikoTest { BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -617,6 +634,7 @@ contract ERC721VaultTest is TaikoTest { BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -666,7 +684,16 @@ contract ERC721VaultTest is TaikoTest { ERC721(deployedContract).approve(address(destChainErc721Vault), 1); sendOpts = BaseNFTVault.BridgeTransferOp( - chainId, Bob, address(deployedContract), tokenIds, amounts, 140_000, 140_000, Bob, "" + chainId, + address(0), + Bob, + address(deployedContract), + tokenIds, + amounts, + 140_000, + 140_000, + Bob, + "" ); vm.prank(Bob, Bob); @@ -706,6 +733,7 @@ contract ERC721VaultTest is TaikoTest { BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds, @@ -756,7 +784,16 @@ contract ERC721VaultTest is TaikoTest { // Alice puts together a malicious bridging back message sendOpts = BaseNFTVault.BridgeTransferOp( - chainId, Alice, address(deployedContract), tokenIds, amounts, 140_000, 140_000, Bob, "" + chainId, + address(0), + Alice, + address(deployedContract), + tokenIds, + amounts, + 140_000, + 140_000, + Bob, + "" ); vm.prank(Alice, Alice); @@ -780,6 +817,7 @@ contract ERC721VaultTest is TaikoTest { BaseNFTVault.BridgeTransferOp memory sendOpts = BaseNFTVault.BridgeTransferOp( destChainId, + address(0), Alice, address(canonicalToken721), tokenIds,