From 7549d35f09ea39ef826e875270c80cf4fe4b82d6 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 1 May 2024 15:07:46 +0100 Subject: [PATCH 1/6] build: install OZ as npm module --- packages/contracts-rfq/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/contracts-rfq/package.json b/packages/contracts-rfq/package.json index 3c7447623e..b434cfec13 100644 --- a/packages/contracts-rfq/package.json +++ b/packages/contracts-rfq/package.json @@ -7,6 +7,9 @@ "files": [ "src/*.sol" ], + "dependencies": { + "@openzeppelin/contracts": "5.0.1" + }, "devDependencies": { "@synapsecns/solidity-devops": "^0.3.3", "prettier": "^2.5.1", From b7d83758a99820c59e182bf75b02a90589026070 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 1 May 2024 15:10:43 +0100 Subject: [PATCH 2/6] chore: update remappings --- packages/contracts-rfq/remappings.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/contracts-rfq/remappings.txt b/packages/contracts-rfq/remappings.txt index af46238c2f..edd83b8f83 100644 --- a/packages/contracts-rfq/remappings.txt +++ b/packages/contracts-rfq/remappings.txt @@ -1,4 +1,3 @@ -@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ -@synapsecns/solidity-devops=node_modules/@synapsecns/solidity-devops/ -forge-std/=lib/forge-std/src/ -ds-test/=lib/forge-std/lib/ds-test/src/ \ No newline at end of file +@openzeppelin/=node_modules/@openzeppelin/ +@synapsecns/=node_modules/@synapsecns/ +forge-std/=node_modules/forge-std/src/ \ No newline at end of file From 62083a45a691d4b59a03221020ed6ecc3b785621 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 1 May 2024 15:19:36 +0100 Subject: [PATCH 3/6] refactor: fix compiler warnings in test contract --- packages/contracts-rfq/test/FastBridge.t.sol | 60 +++++++++---------- .../test/UniversalTokenLib.t.sol | 2 +- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/packages/contracts-rfq/test/FastBridge.t.sol b/packages/contracts-rfq/test/FastBridge.t.sol index 0efc45ef6a..264ebe3b79 100644 --- a/packages/contracts-rfq/test/FastBridge.t.sol +++ b/packages/contracts-rfq/test/FastBridge.t.sol @@ -53,11 +53,11 @@ contract FastBridgeTest is Test { uint256 protocolFeeRate ) internal + view returns (bytes memory request, bytes32 transactionId) { // Define input variables for the bridge transaction address to = user; - address oldRelayer = relayer; uint32 originChainId = uint32(chainId); uint32 dstChainId = 1; address originToken = address(arbUSDC); @@ -96,11 +96,11 @@ contract FastBridgeTest is Test { uint256 protocolFeeRate ) internal + view returns (bytes memory request, bytes32 transactionId) { // Define input variables for the bridge transaction address to = user; - address oldRelayer = relayer; uint32 originChainId = uint32(chainId); uint32 dstChainId = 1; address originToken = UniversalTokenLib.ETH_ADDRESS; @@ -139,11 +139,11 @@ contract FastBridgeTest is Test { uint256 protocolFeeRate ) internal + view returns (bytes memory request, bytes32 transactionId) { // Define input variables for the bridge transaction address to = user; - address oldRelayer = relayer; uint32 originChainId = uint32(chainId); uint32 dstChainId = 1; address originToken = address(arbUSDC); @@ -182,11 +182,11 @@ contract FastBridgeTest is Test { uint256 protocolFeeRate ) internal + view returns (bytes memory request, bytes32 transactionId) { // Define input variables for the bridge transaction address to = user; - address oldRelayer = relayer; uint32 originChainId = uint32(chainId); uint32 dstChainId = 1; address originToken = UniversalTokenLib.ETH_ADDRESS; @@ -237,7 +237,7 @@ contract FastBridgeTest is Test { } /// @notice Test to check if the owner is correctly set - function test_owner() public { + function test_owner() public view { assertTrue(fastBridge.hasRole(fastBridge.DEFAULT_ADMIN_ROLE(), owner)); } @@ -498,7 +498,7 @@ contract FastBridgeTest is Test { // get expected bridge request and tx id uint256 currentNonce = fastBridge.nonce(); - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndIdWithETH(block.chainid, currentNonce, 0); + (, bytes32 transactionId) = _getBridgeRequestAndIdWithETH(block.chainid, currentNonce, 0); // Execute the bridge transaction IFastBridge.BridgeParams memory params = IFastBridge.BridgeParams({ @@ -730,8 +730,7 @@ contract FastBridgeTest is Test { // get expected bridge request and tx id uint256 currentNonce = fastBridge.nonce(); - (bytes memory request, bytes32 transactionId) = - _getBridgeRequestAndIdWithETHAndChainGas(block.chainid, currentNonce, 0); + (, bytes32 transactionId) = _getBridgeRequestAndIdWithETHAndChainGas(block.chainid, currentNonce, 0); // Execute the bridge transaction IFastBridge.BridgeParams memory params = IFastBridge.BridgeParams({ @@ -1233,7 +1232,7 @@ contract FastBridgeTest is Test { setUpRoles(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(42_161, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(42_161, 0, 0); // Start a prank with the relayer vm.startPrank(relayer); @@ -1255,7 +1254,7 @@ contract FastBridgeTest is Test { setUpRoles(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(42_161, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(42_161, 0, 0); // Start a prank with the relayer vm.startPrank(relayer); @@ -1303,7 +1302,7 @@ contract FastBridgeTest is Test { setUpRoles(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(42_161, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(42_161, 0, 0); // Start a prank with the relayer vm.startPrank(guard); @@ -1424,7 +1423,7 @@ contract FastBridgeTest is Test { setUpRoles(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); // We start a prank with the relayer vm.startPrank(relayer); @@ -1445,7 +1444,7 @@ contract FastBridgeTest is Test { setUpRoles(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); // We provide the relay proof expectUnauthorized(address(this), fastBridge.RELAYER_ROLE()); @@ -1498,7 +1497,7 @@ contract FastBridgeTest is Test { test_successfulBridgeWithETH(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndIdWithETH(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndIdWithETH(block.chainid, 0, 0); vm.startPrank(relayer); fastBridge.prove(request, bytes32("0x04")); @@ -1570,7 +1569,7 @@ contract FastBridgeTest is Test { // get bridge request and tx id uint256 protocolFeeRate = fastBridge.protocolFeeRate(); - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndIdWithETH(block.chainid, 0, protocolFeeRate); + (bytes memory request,) = _getBridgeRequestAndIdWithETH(block.chainid, 0, protocolFeeRate); vm.startPrank(relayer); fastBridge.prove(request, bytes32("0x04")); @@ -1630,7 +1629,7 @@ contract FastBridgeTest is Test { test_successfulBridge(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.startPrank(relayer); @@ -1643,7 +1642,7 @@ contract FastBridgeTest is Test { vm.stopPrank(); } - function test_failedClaimNotoldRelayer() public { + function test_failedClaimNotOldRelayer() public { setUpRoles(); test_successfulBridge(); @@ -1652,7 +1651,7 @@ contract FastBridgeTest is Test { vm.stopPrank(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.warp(block.timestamp + 31 minutes); @@ -1668,7 +1667,7 @@ contract FastBridgeTest is Test { test_successfulBridge(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.startPrank(relayer); fastBridge.prove(request, bytes32("0x04")); @@ -1685,7 +1684,7 @@ contract FastBridgeTest is Test { test_successfulRelayProof(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.warp(block.timestamp + 31 minutes); @@ -1700,7 +1699,7 @@ contract FastBridgeTest is Test { test_successfulRelayProof(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.startPrank(guard); @@ -1727,7 +1726,7 @@ contract FastBridgeTest is Test { test_successfulRelayProof(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.warp(block.timestamp + 25 minutes); @@ -1750,7 +1749,7 @@ contract FastBridgeTest is Test { test_successfulBridge(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.startPrank(guard); @@ -1766,7 +1765,7 @@ contract FastBridgeTest is Test { test_successfulRelayProof(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.startPrank(guard); @@ -1784,7 +1783,7 @@ contract FastBridgeTest is Test { test_successfulRelayProof(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); expectUnauthorized(address(this), fastBridge.GUARD_ROLE()); fastBridge.dispute(transactionId); @@ -1830,7 +1829,7 @@ contract FastBridgeTest is Test { test_successfulBridgeWithETH(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndIdWithETH(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndIdWithETH(block.chainid, 0, 0); vm.startPrank(refunder); @@ -1892,7 +1891,7 @@ contract FastBridgeTest is Test { // get bridge request and tx id uint256 protocolFeeRate = fastBridge.protocolFeeRate(); - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndIdWithETH(block.chainid, 0, protocolFeeRate); + (bytes memory request,) = _getBridgeRequestAndIdWithETH(block.chainid, 0, protocolFeeRate); vm.startPrank(refunder); @@ -1952,7 +1951,7 @@ contract FastBridgeTest is Test { test_successfulBridge(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.startPrank(refunder); @@ -2005,7 +2004,7 @@ contract FastBridgeTest is Test { test_successfulBridge(); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); vm.startPrank(user); @@ -2025,7 +2024,7 @@ contract FastBridgeTest is Test { vm.startPrank(refunder); // get bridge request and tx id - (bytes memory request, bytes32 transactionId) = _getBridgeRequestAndId(block.chainid, 0, 0); + (bytes memory request,) = _getBridgeRequestAndId(block.chainid, 0, 0); skip(TX_DEADLINE + 1 seconds); @@ -2093,7 +2092,6 @@ contract FastBridgeTest is Test { vm.startPrank(governor); - uint256 preSweepProtocolFees = fastBridge.protocolFees(address(arbUSDC)); uint256 preSweepBalanceUser = arbUSDC.balanceOf(user); fastBridge.sweepProtocolFees(address(arbUSDC), user); diff --git a/packages/contracts-rfq/test/UniversalTokenLib.t.sol b/packages/contracts-rfq/test/UniversalTokenLib.t.sol index 260663c360..19e796e52d 100644 --- a/packages/contracts-rfq/test/UniversalTokenLib.t.sol +++ b/packages/contracts-rfq/test/UniversalTokenLib.t.sol @@ -122,7 +122,7 @@ contract UniversalTokenLibraryTest is Test { libHarness.universalApproveInfinity(libHarness.ethAddress(), recipient, amount); } - function testEthAddress() public { + function testEthAddress() public view { // ETH address should have all bytes set to 0xEE address ethAddress = libHarness.ethAddress(); for (uint256 i = 0; i < 20; i++) { From 675e8ab9dca625e05bce8321d3cfea48a18d074d Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 1 May 2024 15:26:40 +0100 Subject: [PATCH 4/6] chore: remove forge-std submodule --- .gitmodules | 3 --- packages/contracts-rfq/lib/forge-std | 1 - 2 files changed, 4 deletions(-) delete mode 160000 packages/contracts-rfq/lib/forge-std diff --git a/.gitmodules b/.gitmodules index 7b16f4f880..22876ea395 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,9 +11,6 @@ [submodule "packages/contracts-core/lib/create3-factory"] path = packages/contracts-core/lib/create3-factory url = https://github.com/zeframlou/create3-factory -[submodule "packages/contracts-rfq/lib/forge-std"] - path = packages/contracts-rfq/lib/forge-std - url = https://github.com/foundry-rs/forge-std [submodule "packages/contracts-rfq/lib/openzeppelin-contracts"] path = packages/contracts-rfq/lib/openzeppelin-contracts url = https://github.com/OpenZeppelin/openzeppelin-contracts diff --git a/packages/contracts-rfq/lib/forge-std b/packages/contracts-rfq/lib/forge-std deleted file mode 160000 index 80a8f6ea93..0000000000 --- a/packages/contracts-rfq/lib/forge-std +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 80a8f6ea9362849b2a8f2dc28df40c77a64f9c16 From e1ed7562e3f85b2d304a4512ffa324cb19f2e786 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 1 May 2024 15:28:55 +0100 Subject: [PATCH 5/6] chore: remove `openzeppelin-contracts` submodule --- .gitmodules | 29 +++++++++---------- .../contracts-rfq/lib/openzeppelin-contracts | 1 - 2 files changed, 13 insertions(+), 17 deletions(-) delete mode 160000 packages/contracts-rfq/lib/openzeppelin-contracts diff --git a/.gitmodules b/.gitmodules index 22876ea395..a465e67a97 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,22 +1,19 @@ [submodule "packages/contracts-core/lib/forge-std"] - path = packages/contracts-core/lib/forge-std - url = https://github.com/foundry-rs/forge-std - branch = v1 +path = packages/contracts-core/lib/forge-std +url = https://github.com/foundry-rs/forge-std +branch = v1 [submodule "ethergo/internal/test-data"] - path = ethergo/internal/test-data - url = https://github.com/synapsecns/synapse-contracts +path = ethergo/internal/test-data +url = https://github.com/synapsecns/synapse-contracts [submodule "services/cctp-relayer/external/synapse-contracts"] - path = services/cctp-relayer/external/synapse-contracts - url = https://github.com/synapsecns/synapse-contracts +path = services/cctp-relayer/external/synapse-contracts +url = https://github.com/synapsecns/synapse-contracts [submodule "packages/contracts-core/lib/create3-factory"] - path = packages/contracts-core/lib/create3-factory - url = https://github.com/zeframlou/create3-factory -[submodule "packages/contracts-rfq/lib/openzeppelin-contracts"] - path = packages/contracts-rfq/lib/openzeppelin-contracts - url = https://github.com/OpenZeppelin/openzeppelin-contracts +path = packages/contracts-core/lib/create3-factory +url = https://github.com/zeframlou/create3-factory [submodule "services/rfq/external/canonical-weth"] - path = services/rfq/external/canonical-weth - url = https://github.com/gnosis/canonical-weth +path = services/rfq/external/canonical-weth +url = https://github.com/gnosis/canonical-weth [submodule "services/cctp-relayer/external/evm-cctp-contracts"] - path = services/cctp-relayer/external/evm-cctp-contracts - url = https://github.com/circlefin/evm-cctp-contracts.git +path = services/cctp-relayer/external/evm-cctp-contracts +url = https://github.com/circlefin/evm-cctp-contracts.git diff --git a/packages/contracts-rfq/lib/openzeppelin-contracts b/packages/contracts-rfq/lib/openzeppelin-contracts deleted file mode 160000 index 6ba452dea4..0000000000 --- a/packages/contracts-rfq/lib/openzeppelin-contracts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6ba452dea4258afe77726293435f10baf2bed265 From 221848bc8d29924b013278e1b76dcbb46fbf3755 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Wed, 1 May 2024 15:37:48 +0100 Subject: [PATCH 6/6] fix: restore padding in `.gitmodules` --- .gitmodules | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.gitmodules b/.gitmodules index a465e67a97..ed78571e52 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,19 +1,19 @@ [submodule "packages/contracts-core/lib/forge-std"] -path = packages/contracts-core/lib/forge-std -url = https://github.com/foundry-rs/forge-std -branch = v1 + path = packages/contracts-core/lib/forge-std + url = https://github.com/foundry-rs/forge-std + branch = v1 [submodule "ethergo/internal/test-data"] -path = ethergo/internal/test-data -url = https://github.com/synapsecns/synapse-contracts + path = ethergo/internal/test-data + url = https://github.com/synapsecns/synapse-contracts [submodule "services/cctp-relayer/external/synapse-contracts"] -path = services/cctp-relayer/external/synapse-contracts -url = https://github.com/synapsecns/synapse-contracts + path = services/cctp-relayer/external/synapse-contracts + url = https://github.com/synapsecns/synapse-contracts [submodule "packages/contracts-core/lib/create3-factory"] -path = packages/contracts-core/lib/create3-factory -url = https://github.com/zeframlou/create3-factory + path = packages/contracts-core/lib/create3-factory + url = https://github.com/zeframlou/create3-factory [submodule "services/rfq/external/canonical-weth"] -path = services/rfq/external/canonical-weth -url = https://github.com/gnosis/canonical-weth + path = services/rfq/external/canonical-weth + url = https://github.com/gnosis/canonical-weth [submodule "services/cctp-relayer/external/evm-cctp-contracts"] -path = services/cctp-relayer/external/evm-cctp-contracts -url = https://github.com/circlefin/evm-cctp-contracts.git + path = services/cctp-relayer/external/evm-cctp-contracts + url = https://github.com/circlefin/evm-cctp-contracts.git