Skip to content

fix: remove unnecessary L2 gas check (OZ N-01 from #700) #735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions contracts/gateway/L1GraphTokenGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
{
Expand Down
12 changes: 8 additions & 4 deletions test/gateway/l1GraphTokenGateway.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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)
Expand All @@ -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'))
Expand Down