Skip to content

Commit

Permalink
add EXTCODEHASH opcode implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jwasinger committed Jul 30, 2018
1 parent 85870fa commit 9cb48e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/opFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ module.exports = {
cb(null)
})
},
EXTCODEHASH: function (address, runState, cb) {
var stateManager = runState.stateManager
address = addressToBuffer(address)
stateManager.getContractCode(address, function (err, code) {
if (err) return cb(err)
if (code.length == 0) {
cb(null, new BN(Buffer.from(utils.KECCAK256_NULL_S, 'hex')))
}

cb(null, new BN(utils.keccak256(code)))
})
},
RETURNDATASIZE: function (runState) {
return new BN(runState.lastReturned.length)
},
Expand Down
1 change: 1 addition & 0 deletions lib/opcodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const codes = {
0x3c: ['EXTCODECOPY', 700, 4, 0, true, true],
0x3d: ['RETURNDATASIZE', 2, 0, 1, true],
0x3e: ['RETURNDATACOPY', 3, 3, 0, true],
0x3f: ['EXTCODEHASH', 400, 1, 1, true, true],

// '0x40' range - block operations
0x40: ['BLOCKHASH', 20, 1, 1, true, true],
Expand Down

0 comments on commit 9cb48e0

Please sign in to comment.