Commit 87d1b3cc authored by Alina's avatar Alina Committed by GitHub

require relayer fee transfer success (#117)

parent 09936907
......@@ -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)) {
......
......@@ -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.'
)
})
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment