Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Update binsearch to use inverse of 64ths rule
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjpaterno committed Dec 10, 2019
1 parent fcfb50f commit baf9d37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/utils/gas/binSearch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { BN } = require("ethereumjs-util");
const hexToBn = (val = 0) => new BN(parseInt("0x" + val.toString("hex"), 16));
const MULTIPLE = 64 / 63;

module.exports = async function binSearch(generateVM, runArgs, result, callback) {
const MAX = hexToBn(runArgs.block.header.gasLimit);
Expand All @@ -15,7 +16,7 @@ module.exports = async function binSearch(generateVM, runArgs, result, callback)

if (!(await isEnoughGas(range.hi))) {
do {
range.hi = range.hi.muln(1.015625); // multiply by 1 + 1/64th
range.hi = range.hi.muln(MULTIPLE);
} while (!(await isEnoughGas(range.hi)));
while (range.lo.addn(1).lt(range.hi)) {
const mid = range.lo.add(range.hi).divn(2);
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/gas/guestimation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const RuntimeError = require("./runtimeerror");
const RuntimeError = require("../runtimeerror");

const { BN } = require("ethereumjs-util");
const bn = (val = 0) => new BN(val);
Expand Down

0 comments on commit baf9d37

Please sign in to comment.