Skip to content

Commit

Permalink
add EXTCODEHASH rules for nonexistent accounts and precompiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jwasinger committed Jul 30, 2018
1 parent 23d21b4 commit b92530a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/opFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,28 @@ module.exports = {
EXTCODEHASH: function (address, runState, cb) {
var stateManager = runState.stateManager
address = addressToBuffer(address)
stateManager.getContractCode(address, function (err, code) {

if (runState._precompiled[address.toString('hex')]) {
cb(null, new BN(0))
return
}

stateManager.exists(address, function (err, exists) {
if (err) return cb(err)
if (code.length == 0) {
cb(null, new BN(Buffer.from(utils.KECCAK256_NULL_S, 'hex')))
if (!exists) {
cb(null, new BN(0))
return
}

cb(null, new BN(utils.keccak256(code)))
stateManager.getContractCode(address, function (err, code) {
if (err) return cb(err)
if (code.length === 0) {
cb(null, new BN(utils.KECCAK256_NULL))
return
}

cb(null, new BN(utils.keccak256(code)))
})
})
},
RETURNDATASIZE: function (runState) {
Expand Down

0 comments on commit b92530a

Please # to comment.