diff options
Merge pull request #796 from MetaMask/IncreaseGasBuffer
Increase gas buffer
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 3 | ||||
-rw-r--r-- | test/unit/idStore-test.js | 10 |
3 files changed, 8 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e75502159..bc8cc5fa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## Current Master -- Fix gas estimation bug. +- Fix bug where gas estimate would sometimes be very high. +- Increased our gas estimate from 100k gas to 20% of estimate. - Fix github link on info page to point at current repository. ## 2.13.6 2016-10-26 diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 1010a5789..0ce91f471 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -287,9 +287,10 @@ IdentityStore.prototype.checkForDelegateCall = function (codeHex) { } } -const gasBuffer = new BN('100000', 10) IdentityStore.prototype.addGasBuffer = function (gas) { const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16) + const five = new BN('5', 10) + const gasBuffer = bnGas.div(five) const correct = bnGas.add(gasBuffer) return ethUtil.addHexPrefix(correct.toString(16)) } diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js index 46b3d4809..064483ba0 100644 --- a/test/unit/idStore-test.js +++ b/test/unit/idStore-test.js @@ -159,7 +159,7 @@ describe('IdentityStore', function() { assert.equal(result.indexOf('0x'), 0, 'include hex prefix') }) - it('buffers reasonably', function() { + it('buffers 20%', function() { const idStore = new IdentityStore({ configManager: configManagerGen(), ethStore: { @@ -168,20 +168,18 @@ describe('IdentityStore', function() { }) const gas = '0x04ee59' // Actual estimated gas example - const tooBigOutput = '0x80674f9' // Actual bad output const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16) - const correctBuffer = new BN('100000', 10) + const five = new BN('5', 10) + const correctBuffer = bnGas.div(five) const correct = bnGas.add(correctBuffer) - const tooBig = new BN(tooBigOutput, 16) const result = idStore.addGasBuffer(gas) const bnResult = new BN(ethUtil.stripHexPrefix(result), 16) assert.equal(result.indexOf('0x'), 0, 'included hex prefix') assert(bnResult.gt(bnGas), 'Estimate increased in value.') - assert.equal(bnResult.sub(bnGas).toString(10), '100000', 'added 100k gas') + assert.equal(bnResult.sub(bnGas).toString(10), correctBuffer.toString(10), 'added 20% gas') assert.equal(result, '0x' + correct.toString(16), 'Added the right amount') - assert.notEqual(result, tooBigOutput, 'not that bad estimate') }) }) |