From a208a1f9492dca803642240cfa96e93e9de943a3 Mon Sep 17 00:00:00 2001 From: nicholaspai <9457025+nicholaspai@users.noreply.github.com> Date: Fri, 9 Feb 2024 16:01:29 -0500 Subject: [PATCH] improve: Make MockSpokePool.depositV2 virtual (#430) * feat: Add depositV2 to MockSpokePool to support relayer-v2/sdk-v2 unit tests These unit tests expect to query FundsDeposited events so we should add a function to the MockSpokePool so that they can access these older events using functions exported out of dist/test-utils * Add back logic * Update package.json * Update MockSpokePool.sol * Update package.json * WIP * Update HubPool.Fixture.ts --- contracts/test/MockSpokePool.sol | 20 ++------------------ package.json | 2 +- test/fixtures/HubPool.Fixture.ts | 6 +++--- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/contracts/test/MockSpokePool.sol b/contracts/test/MockSpokePool.sol index b44948dfe..e37137316 100644 --- a/contracts/test/MockSpokePool.sol +++ b/contracts/test/MockSpokePool.sol @@ -122,30 +122,14 @@ contract MockSpokePool is SpokePool, OwnableUpgradeable { uint32 quoteTimestamp, bytes memory message, uint256 // maxCount - ) public payable nonReentrant unpausedDeposits { - // Check that deposit route is enabled. - require(enabledDepositRoutes[originToken][destinationChainId], "Disabled route"); - - // We limit the relay fees to prevent the user spending all their funds on fees. - require(SignedMath.abs(relayerFeePct) < 0.5e18, "Invalid relayer fee"); - require(amount <= MAX_TRANSFER_SIZE, "Amount too large"); - - // Require that quoteTimestamp has a maximum age so that depositors pay an LP fee based on recent HubPool usage. - // It is assumed that cross-chain timestamps are normally loosely in-sync, but clock drift can occur. If the - // SpokePool time stalls or lags significantly, it is still possible to make deposits by setting quoteTimestamp - // within the configured buffer. The owner should pause deposits if this is undesirable. This will underflow if - // quoteTimestamp is more than depositQuoteTimeBuffer; this is safe but will throw an unintuitive error. - - // slither-disable-next-line timestamp - require(getCurrentTime() - quoteTimestamp <= depositQuoteTimeBuffer, "invalid quoteTimestamp"); - + ) public payable virtual nonReentrant unpausedDeposits { // Increment count of deposits so that deposit ID for this spoke pool is unique. uint32 newDepositId = numberOfDeposits++; // If the address of the origin token is a wrappedNativeToken contract and there is a msg.value with the // transaction then the user is sending ETH. In this case, the ETH should be deposited to wrappedNativeToken. if (originToken == address(wrappedNativeToken) && msg.value > 0) { - require(msg.value == amount, "msg.value must match amount"); + require(msg.value == amount); wrappedNativeToken.deposit{ value: msg.value }(); // Else, it is a normal ERC20. In this case pull the token from the user's wallet as per normal. // Note: this includes the case where the L2 user has WETH (already wrapped ETH) and wants to bridge them. diff --git a/package.json b/package.json index bf920f650..62bf695aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@across-protocol/contracts-v2", - "version": "2.5.0-beta.4", + "version": "2.5.0-beta.5", "author": "UMA Team", "license": "AGPL-3.0-only", "repository": { diff --git a/test/fixtures/HubPool.Fixture.ts b/test/fixtures/HubPool.Fixture.ts index 5bc74bc87..7559fe296 100644 --- a/test/fixtures/HubPool.Fixture.ts +++ b/test/fixtures/HubPool.Fixture.ts @@ -8,7 +8,7 @@ export const hubPoolFixture = hre.deployments.createFixture(async ({ ethers }) = return await deployHubPool(ethers); }); -export async function deployHubPool(ethers: any) { +export async function deployHubPool(ethers: any, spokePoolName = "MockSpokePool") { const [signer, crossChainAdmin] = await ethers.getSigners(); // This fixture is dependent on the UMA ecosystem fixture. Run it first and grab the output. This is used in the @@ -44,7 +44,7 @@ export async function deployHubPool(ethers: any) { // Deploy a mock chain adapter and add it as the chainAdapter for the test chainId. Set the SpokePool to address 0. const mockAdapter = await (await getContractFactory("Mock_Adapter", signer)).deploy(); const mockSpoke = await hre.upgrades.deployProxy( - await getContractFactory("MockSpokePool", signer), + await getContractFactory(spokePoolName, signer), [0, crossChainAdmin.address, hubPool.address], { kind: "uups", unsafeAllow: ["delegatecall"], constructorArgs: [weth.address] } ); @@ -55,7 +55,7 @@ export async function deployHubPool(ethers: any) { const mainnetChainId = await hre.getChainId(); const mockAdapterMainnet = await (await getContractFactory("Mock_Adapter", signer)).deploy(); const mockSpokeMainnet = await hre.upgrades.deployProxy( - await getContractFactory("MockSpokePool", signer), + await getContractFactory(spokePoolName, signer), [0, crossChainAdmin.address, hubPool.address], { kind: "uups", unsafeAllow: ["delegatecall"], constructorArgs: [weth.address] } );