Skip to content

Commit

Permalink
Merge pull request #275 from ethereumjs/totalgas-large-return
Browse files Browse the repository at this point in the history
Properly calculate totalgas for large return values
  • Loading branch information
holgerd77 authored Feb 13, 2018
2 parents 8de73f9 + 5c1a869 commit 688aec6
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/runCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,9 @@ module.exports = function (opts, cb) {
// fee for size of the return value
var totalGas = results.gasUsed
if (!results.runState.vmError) {
var returnFee = results.return.length * fees.createDataGas.v
var returnFee = new BN(results.return.length * fees.createDataGas.v)

// avoid BN assertion failure when returnFee is greater than 0x4000000
if (returnFee > gasLimit.toNumber()) {
returnFee = gasLimit.toNumber() + 1
}

totalGas = totalGas.addn(returnFee)
totalGas = totalGas.add(returnFee)
}
// if not enough gas
if (totalGas.lte(gasLimit) && results.return.length <= 24576) {
Expand Down

0 comments on commit 688aec6

Please sign in to comment.