Skip to content

Commit

Permalink
Check if constantinople hard fork is active in the SHL/SHR/SAR implem…
Browse files Browse the repository at this point in the history
…entation
  • Loading branch information
axic committed Jul 23, 2018
1 parent e9c8512 commit 0540c16
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/opFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,27 @@ module.exports = {
return new BN(word.shrn((31 - pos.toNumber()) * 8).andln(0xff))
},
SHL: function (a, b, runState) {
if (!runState._common.gteHardforl('constantinople')) {
trap(ERROR.INVALID_OPCODE)
}
if (a.gten(256)) {
return new BN(0)
}
return b.shln(a.toNumber())
},
SHR: function (a, b, runState) {
if (!runState._common.gteHardforl('constantinople')) {
trap(ERROR.INVALID_OPCODE)
}
if (a.gten(256)) {
return new BN(0)
}
return b.shrn(a.toNumber())
},
SAR: function (a, b, runState) {
if (!runState._common.gteHardforl('constantinople')) {
trap(ERROR.INVALID_OPCODE)
}
b = b.fromTwos(256)
if (a.gten(256)) {
if (b.ltn(0)) {
Expand Down

0 comments on commit 0540c16

Please sign in to comment.