Skip to content

Commit 6efe3d1

Browse files
rmeissnerholgerd77
authored andcommitted
Handle revert in create2 with message
1 parent a8abcfa commit 6efe3d1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/opFns.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ module.exports = {
539539
outLength: new BN(0)
540540
}
541541

542-
// Deduct gas costs for hashingq
542+
// Deduct gas costs for hashing
543543
subGas(runState, new BN(runState._common.param('gasPrices', 'sha3Word')).imul(length.divCeil(new BN(32))))
544544
checkCallMemCost(runState, options, localOpts)
545545
checkOutOfGas(runState, options)
@@ -1011,7 +1011,7 @@ function makeCall (runState, callOptions, localOpts, cb) {
10111011
if (results.vm.return && (!results.vm.exceptionError || results.vm.exceptionError.error === ERROR.REVERT)) {
10121012
memStore(runState, localOpts.outOffset, results.vm.return, new BN(0), localOpts.outLength, false)
10131013

1014-
if (results.vm.exceptionError && results.vm.exceptionError.error === ERROR.REVERT && runState.opName === 'CREATE') {
1014+
if (results.vm.exceptionError && results.vm.exceptionError.error === ERROR.REVERT && isCreateOpCode(runState.opName)) {
10151015
runState.lastReturned = results.vm.return
10161016
}
10171017

@@ -1049,6 +1049,10 @@ function makeCall (runState, callOptions, localOpts, cb) {
10491049
}
10501050
}
10511051

1052+
function isCreateOpCode (opName) {
1053+
return opName === 'CREATE' || opName === 'CREATE2'
1054+
}
1055+
10521056
function getContractStorage (runState, address, key, cb) {
10531057
if (runState._common.gteHardfork('constantinople')) {
10541058
async.parallel({

lib/runCall.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const BN = ethUtil.BN
55
const exceptions = require('./exceptions.js')
66

77
const ERROR = exceptions.ERROR
8-
const EMPTY_CODE_HASH = ethUtil.keccak256()
98

109
/**
1110
* runs a CALL operation
@@ -103,7 +102,7 @@ module.exports = function (opts, cb) {
103102
return
104103
}
105104

106-
if ((account.nonce && new BN(account.nonce) > 0) || account.codeHash.compare(EMPTY_CODE_HASH) !== 0) {
105+
if ((account.nonce && new BN(account.nonce) > 0) || account.codeHash.compare(ethUtil.KECCAK256_NULL) !== 0) {
107106
toAccount = account
108107
code = new Buffer('fe', 'hex') // Invalid init code
109108
done()
@@ -221,7 +220,6 @@ module.exports = function (opts, cb) {
221220
var totalGas = results.gasUsed
222221
if (!results.runState.vmError) {
223222
var returnFee = new BN(results.return.length * self._common.param('gasPrices', 'createData'))
224-
225223
totalGas = totalGas.add(returnFee)
226224
}
227225
// if not enough gas

0 commit comments

Comments
 (0)