Skip to content

Commit 53b6e14

Browse files
committed
Check if constantinople hard fork is active in the SHL/SHR/SAR implementation
1 parent de7d02e commit 53b6e14

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/opFns.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,27 @@ module.exports = {
158158
return new BN(word.shrn((31 - pos.toNumber()) * 8).andln(0xff))
159159
},
160160
SHL: function (a, b, runState) {
161+
if (!runState._common.hardforkIsActiveOnBlock("constantinople", runState.block.header.number)) {
162+
trap(ERROR.INVALID_OPCODE)
163+
}
161164
if (a.gten(256)) {
162165
return new BN(0)
163166
}
164167
return b.shln(a.toNumber())
165168
},
166169
SHR: function (a, b, runState) {
170+
if (!runState._common.hardforkIsActiveOnBlock("constantinople", runState.block.header.number)) {
171+
trap(ERROR.INVALID_OPCODE)
172+
}
167173
if (a.gten(256)) {
168174
return new BN(0)
169175
}
170176
return b.shrn(a.toNumber())
171177
},
172178
SAR: function (a, b, runState) {
179+
if (!runState._common.hardforkIsActiveOnBlock("constantinople", runState.block.header.number)) {
180+
trap(ERROR.INVALID_OPCODE)
181+
}
173182
b = b.fromTwos(256)
174183
if (a.gten(256)) {
175184
if (b.ltn(0)) {

0 commit comments

Comments
 (0)