From 2dfacb6322627d58a883803035f7b3b0c57f22ea Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Fri, 21 Oct 2022 11:51:49 -0300 Subject: [PATCH] fix: remove unnecessary L2 gas check (OZ N-01 from #700) --- contracts/gateway/L1GraphTokenGateway.sol | 10 +--------- test/gateway/l1GraphTokenGateway.test.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/contracts/gateway/L1GraphTokenGateway.sol b/contracts/gateway/L1GraphTokenGateway.sol index e84f6c207..fbcbcf724 100644 --- a/contracts/gateway/L1GraphTokenGateway.sol +++ b/contracts/gateway/L1GraphTokenGateway.sol @@ -217,15 +217,7 @@ contract L1GraphTokenGateway is GraphTokenGateway, L1ArbitrumMessenger { extraData.length == 0 || callhookWhitelist[msg.sender] == true, "CALL_HOOK_DATA_NOT_ALLOWED" ); - require(maxSubmissionCost > 0, "NO_SUBMISSION_COST"); - - { - // makes sure only sufficient ETH is supplied as required for successful redemption on L2 - // if a user does not desire immediate redemption they should provide - // a msg.value of AT LEAST maxSubmissionCost - uint256 expectedEth = maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)); - require(msg.value >= expectedEth, "WRONG_ETH_VALUE"); - } + require(maxSubmissionCost != 0, "NO_SUBMISSION_COST"); outboundCalldata = getOutboundCalldata(_l1Token, from, _to, _amount, extraData); } { diff --git a/test/gateway/l1GraphTokenGateway.test.ts b/test/gateway/l1GraphTokenGateway.test.ts index 4a022e88a..70984717a 100644 --- a/test/gateway/l1GraphTokenGateway.test.ts +++ b/test/gateway/l1GraphTokenGateway.test.ts @@ -52,6 +52,10 @@ describe('L1GraphTokenGateway', () => { ['uint256', 'bytes'], [maxSubmissionCost, emptyCallHookData], ) + const defaultDataNoSubmissionCost = utils.defaultAbiCoder.encode( + ['uint256', 'bytes'], + [toBN(0), emptyCallHookData], + ) const notEmptyCallHookData = '0x12' const defaultDataWithNotEmptyCallHookData = utils.defaultAbiCoder.encode( ['uint256', 'bytes'], @@ -471,7 +475,7 @@ describe('L1GraphTokenGateway', () => { ) await testValidOutboundTransfer(mockRouter.signer, routerEncodedData, emptyCallHookData) }) - it('reverts when called with the wrong value', async function () { + it('reverts when called with no submission cost', async function () { await grt.connect(tokenSender.signer).approve(l1GraphTokenGateway.address, toGRT('10')) const tx = l1GraphTokenGateway .connect(tokenSender.signer) @@ -481,12 +485,12 @@ describe('L1GraphTokenGateway', () => { toGRT('10'), maxGas, gasPriceBid, - defaultData, + defaultDataNoSubmissionCost, { - value: defaultEthValue.sub(1), + value: defaultEthValue, }, ) - await expect(tx).revertedWith('WRONG_ETH_VALUE') + await expect(tx).revertedWith('NO_SUBMISSION_COST') }) it('reverts when called with nonempty calldata, if the sender is not whitelisted', async function () { await grt.connect(tokenSender.signer).approve(l1GraphTokenGateway.address, toGRT('10'))