Commit 7ebc11d5 authored by Kelvin Fichter's avatar Kelvin Fichter Committed by GitHub

Fix revert string generated by EM wrapper (#274)

* Fix revert string

* Fix a few tests

* Apparently ethers is broken

* Fix last failing test

* More reliable codesize test
parent 2ca8fa39
......@@ -258,7 +258,10 @@ library Lib_SafeExecutionManagerWrapper {
_safeExecutionManagerInteraction(
abi.encodeWithSignature(
"ovmREVERT(bytes)",
bytes(_reason)
abi.encodeWithSignature(
"Error(string)",
_reason
)
)
);
}
......
......@@ -13,6 +13,7 @@ import {
DEFAULT_EIP155_TX,
serializeEthSignTransaction,
signEthSignMessage,
decodeSolidityError,
} from '../../../helpers'
const callPrecompile = async (
......@@ -182,7 +183,7 @@ describe('OVM_ECDSAContractAccount', () => {
)
const ovmREVERT: any =
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
expect(decodeSolidityError(ovmREVERT._data)).to.equal(
'Signature provided for EOA transaction execution is invalid.'
)
})
......@@ -209,7 +210,7 @@ describe('OVM_ECDSAContractAccount', () => {
)
const ovmREVERT: any =
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
expect(decodeSolidityError(ovmREVERT._data)).to.equal(
'Transaction nonce does not match the expected nonce.'
)
})
......@@ -236,7 +237,7 @@ describe('OVM_ECDSAContractAccount', () => {
)
const ovmREVERT: any =
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
expect(decodeSolidityError(ovmREVERT._data)).to.equal(
'Transaction chainId does not match expected OVM chainId.'
)
})
......@@ -266,7 +267,7 @@ describe('OVM_ECDSAContractAccount', () => {
const ovmREVERT: any =
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
expect(decodeSolidityError(ovmREVERT._data)).to.equal(
'Gas is not sufficient to execute the transaction.'
)
})
......@@ -292,7 +293,7 @@ describe('OVM_ECDSAContractAccount', () => {
const ovmREVERT: any =
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
expect(decodeSolidityError(ovmREVERT._data)).to.equal(
'Fee was not transferred to relayer.'
)
})
......
......@@ -6,7 +6,7 @@ import { ContractFactory, Contract, Wallet } from 'ethers'
import { MockContract, smockit } from '@eth-optimism/smock'
/* Internal Imports */
import { remove0x } from '../../../helpers'
import { remove0x, decodeSolidityError } from '../../../helpers'
const callPrecompile = async (
Helper_PrecompileCaller: Contract,
......@@ -117,7 +117,7 @@ describe('OVM_ProxyEOA', () => {
])
const ovmREVERT: any =
Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
expect(decodeSolidityError(ovmREVERT._data)).to.equal(
'EOAs can only upgrade their own EOA implementation'
)
})
......
......@@ -5,7 +5,9 @@ import {
OVM_TX_GAS_LIMIT,
NON_NULL_BYTES32,
VERIFIED_EMPTY_CONTRACT_HASH,
fromHexString,
} from '../../../../helpers'
import { getContractDefinition } from '../../../../../src'
const test_ovmCREATEEOA: TestDefinition = {
name: 'Basic tests for CREATEEOA',
......@@ -68,7 +70,9 @@ const test_ovmCREATEEOA: TestDefinition = {
address: '0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff',
},
expectedReturnStatus: true,
expectedReturnValue: 1678,
expectedReturnValue: fromHexString(
getContractDefinition('OVM_ProxyEOA').deployedBytecode
).length,
},
],
},
......
......@@ -6,7 +6,7 @@ import { ContractFactory, Contract, Wallet } from 'ethers'
import { MockContract, smockit } from '@eth-optimism/smock'
/* Internal Imports */
import { ZERO_ADDRESS, remove0x } from '../../../helpers'
import { decodeSolidityError, ZERO_ADDRESS, remove0x } from '../../../helpers'
const callPrecompile = async (
Helper_PrecompileCaller: Contract,
......@@ -105,7 +105,7 @@ describe('OVM_ProxySequencerEntrypoint', () => {
)
const ovmREVERT: any = Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
expect(decodeSolidityError(ovmREVERT._data)).to.equal(
'ProxySequencerEntrypoint has already been inited'
)
})
......@@ -137,7 +137,7 @@ describe('OVM_ProxySequencerEntrypoint', () => {
[`0x${'12'.repeat(20)}`]
)
const ovmREVERT: any = Mock__OVM_ExecutionManager.smocked.ovmREVERT.calls[0]
expect(ethers.utils.toUtf8String(ovmREVERT._data)).to.equal(
expect(decodeSolidityError(ovmREVERT._data)).to.equal(
'Only owner can upgrade the Entrypoint'
)
})
......
export * from '../../../src/utils'
export * from './eth-time'
export * from './sol-utils'
export * from './custom-deployer'
import { ethers } from 'ethers'
const errorABI = new ethers.utils.Interface([
{
type: 'function',
inputs: [
{
type: 'string',
},
],
name: 'Error',
stateMutability: 'pure',
},
])
export const decodeSolidityError = (err: string): string => {
return errorABI.decodeFunctionData('Error', err)[0]
}
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