From 4bedff2ff3d2763ce5c18b23bab0f6f635ff3312 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 26 Oct 2016 22:44:42 +0100 Subject: [PATCH] Implement EIP150.1b (all but 64th rule) --- lib/opFns.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/opFns.js b/lib/opFns.js index a678388182..b60d46ccd7 100644 --- a/lib/opFns.js +++ b/lib/opFns.js @@ -549,6 +549,8 @@ module.exports = { checkCallMemCost(runState, options, localOpts) + gasLimit = calcCallLimit(runState, gasLimit) + stateManager.exists(toAddress, function (err, exists) { if (err) { done(err) @@ -883,3 +885,14 @@ function makeCall (runState, callOptions, localOpts, cb) { } } } + +function calcCallLimit (runState, gas) { + if (!runState.enableHomesteadReprice) { + return gas + } + + // div should round down + const max = runState.gasLimit.sub(runState.gasLimit.div(64)) + + return BN.min(gas, max) +}