Skip to content

Commit

Permalink
require relayer fee transfer success (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
axchu authored Dec 11, 2020
1 parent 0993690 commit 87d1b3c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ contract OVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
// Transfer fee to relayer.
address relayer = Lib_SafeExecutionManagerWrapper.safeCALLER();
uint256 fee = decodedTx.gasLimit * decodedTx.gasPrice;
Lib_SafeExecutionManagerWrapper.safeCALL(
(bool success, ) = Lib_SafeExecutionManagerWrapper.safeCALL(
gasleft(),
ETH_ERC20_ADDRESS,
abi.encodeWithSignature("transfer(address,uint256)", relayer, fee)
);
Lib_SafeExecutionManagerWrapper.safeREQUIRE(
success == true,
"Fee was not transferred to relayer."
);

// Contract creations are signalled by sending a transaction to the zero address.
if (decodedTx.to == address(0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,31 @@ describe('OVM_ECDSAContractAccount', () => {
'Gas is not sufficient to execute the transaction.'
)
})

it(`should revert if fee is not transferred to the relayer`, async () => {
const message = serializeNativeTransaction(DEFAULT_EIP155_TX)
const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX)
Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([false, '0x'])

await callPrecompile(
Helper_PrecompileCaller,
OVM_ECDSAContractAccount,
'execute',
[
message,
0, //isEthSignedMessage
`0x${sig.v}`, //v
`0x${sig.r}`, //r
`0x${sig.s}`, //s
],
40000000
)

const ovmREVERT: any =
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
'Fee was not transferred to relayer.'
)
})
})
})

0 comments on commit 87d1b3c

Please sign in to comment.