Skip to content

Commit

Permalink
Implement EIP150.1b (all but 64th rule)
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Oct 31, 2016
1 parent b7555d9 commit 4bedff2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/opFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ module.exports = {

checkCallMemCost(runState, options, localOpts)

gasLimit = calcCallLimit(runState, gasLimit)

stateManager.exists(toAddress, function (err, exists) {
if (err) {
done(err)
Expand Down Expand Up @@ -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)
}

0 comments on commit 4bedff2

Please sign in to comment.