From 0540c164c2fcbefd76036685a978b38ab9f6dc68 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 20 Jul 2018 11:29:08 +0100 Subject: [PATCH] Check if constantinople hard fork is active in the SHL/SHR/SAR implementation --- lib/opFns.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/opFns.js b/lib/opFns.js index 3793070053f..2c73f8c9d29 100644 --- a/lib/opFns.js +++ b/lib/opFns.js @@ -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)) {