Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.

Commit 46e2f65

Browse files
authored
require relayer fee transfer success (#117)
1 parent 664fb1b commit 46e2f65

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

contracts/optimistic-ethereum/OVM/accounts/OVM_ECDSAContractAccount.sol

+5-1
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
8787
// Transfer fee to relayer.
8888
address relayer = Lib_SafeExecutionManagerWrapper.safeCALLER();
8989
uint256 fee = decodedTx.gasLimit * decodedTx.gasPrice;
90-
Lib_SafeExecutionManagerWrapper.safeCALL(
90+
(bool success, ) = Lib_SafeExecutionManagerWrapper.safeCALL(
9191
gasleft(),
9292
ETH_ERC20_ADDRESS,
9393
abi.encodeWithSignature("transfer(address,uint256)", relayer, fee)
9494
);
95+
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
96+
success == true,
97+
"Fee was not transferred to relayer."
98+
);
9599

96100
// Contract creations are signalled by sending a transaction to the zero address.
97101
if (decodedTx.to == address(0)) {

test/contracts/OVM/accounts/OVM_ECDSAContractAccount.spec.ts

+26
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,31 @@ describe('OVM_ECDSAContractAccount', () => {
269269
'Gas is not sufficient to execute the transaction.'
270270
)
271271
})
272+
273+
it(`should revert if fee is not transferred to the relayer`, async () => {
274+
const message = serializeNativeTransaction(DEFAULT_EIP155_TX)
275+
const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX)
276+
Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([false, '0x'])
277+
278+
await callPrecompile(
279+
Helper_PrecompileCaller,
280+
OVM_ECDSAContractAccount,
281+
'execute',
282+
[
283+
message,
284+
0, //isEthSignedMessage
285+
`0x${sig.v}`, //v
286+
`0x${sig.r}`, //r
287+
`0x${sig.s}`, //s
288+
],
289+
40000000
290+
)
291+
292+
const ovmREVERT: any =
293+
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
294+
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
295+
'Fee was not transferred to relayer.'
296+
)
297+
})
272298
})
273299
})

0 commit comments

Comments
 (0)