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

Consume gasRefund From Potential ethereumjs-vm Addition #141

Merged
merged 6 commits into from
Aug 15, 2018

Conversation

davidmurdoch
Copy link
Member

This is the same as PR #80 with added tests. Fixes issue #26: estimateGas returns invalid value when tx has a gasRefund.

mikeseese and others added 4 commits March 7, 2018 22:14
Also had to tweak the `add`/`transfer` gas estimation tests as on `transfer` we'll estimate `15000` too high due to the `transfer` call setting storage back to `0` (and we don't account for this `15000` refund in our estimate). To work around the issue I increased the amount initially added to the recipient to `10` so that transfering `5` out in the transfer test doesn't set it to `0`.
…s will work

I wanted to test against geth using the web3 http provider and it wouldn't work the way the tests were written.
@mikeseese
Copy link
Contributor

@davidmurdoch FYI, sometimes you can push directly to the PR branch if they checked the box to "allow reviewers to modify it". no problem though!

@davidmurdoch
Copy link
Member Author

@seesemichaelj I used Github's "open this in GitHub Desktop" link on the PR and it automatically created a new branch instead of just opening your branch and so I just rolled with it from there. ¯\_(ツ)_/¯

I'll be sure to do it The Right Way next time.

@@ -594,7 +594,7 @@ StateManager.prototype.processGasEstimate = function (from, rawTx, blockNumber,
}
var result = '0x0'
if (!results.error) {
result = to.hex(results.gasUsed)
result = results.gasRefund ? to.hex(results.gasUsed.add(results.gasRefund)) : to.hex(results.gasUsed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We expect the gasRefund field to always be there, right? If so, this squelches an error and makes things look like they're working if the gasRefund field suddenly disappears.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in latest commits

@benjamincburns
Copy link
Contributor

It might be worth adding a test to check whether our gas estimation accounts for explicit gas stipends properly (e.g. something like mycontract.depth.gas(100000)(y-1))

Relevant docs here.

…h it anyway.

Reason: if it this value gets renamed in a future version of ethereumvm-js for whatever reason we don't want to just ignore the `undefined` error.
@mikeseese mikeseese self-requested a review August 14, 2018 20:17
Copy link
Contributor

@mikeseese mikeseese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@benjamincburns benjamincburns merged commit 81e8f59 into develop Aug 15, 2018
@davidmurdoch davidmurdoch deleted the pr/80 branch November 8, 2018 23:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants