Skip to content

Commit

Permalink
Properly calculate totalgas for large return values
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Feb 13, 2018
1 parent 8de73f9 commit 5c1a869
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 5c1a869

Please sign in to comment.