Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gas Refund to Transaction Results #284

Merged
merged 1 commit into from
Apr 5, 2018
Merged

Add Gas Refund to Transaction Results #284

merged 1 commit into from
Apr 5, 2018

Conversation

mikeseese
Copy link
Contributor

Fixes #283

Excerpt to #283 that this PR implements:

I can see why we shouldn't change the reported gasUsed, because it's the amount of net gas that was removed from the sending account. However, ethereumjs-vm should at a minimum report the gasRefund to let callers know that additional gas may be needed to actually execute the transaction. I believe this proposal makes sense, but I'd love to talk alternatives if it's not quite right. I'm going to go ahead open a PR that implements this proposal.

@coveralls
Copy link

coveralls commented Mar 8, 2018

Coverage Status

Coverage remained the same at 85.436% when pulling 6ea041d on seesemichaelj:report-gas-refund into 2eb03fd on ethereumjs:master.

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

You have a linting error causing the tests to fail, ; is not allowed to end a line.

See also my other comment.

lib/runTx.js Outdated
@@ -140,6 +140,7 @@ module.exports = function (opts, cb) {
// process any gas refund
var gasRefund = results.vm.gasRefund
if (gasRefund) {
results.gasRefund = gasRefund;
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better if results.vm.gasRefund is always assigned to gasRefund than this always has a value, being it BN(0) or something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I'm not following for some reason.

Do you mean something along the lines of:
var gasRefund = results.vm.gasRefund || BN(0)

or are you looking for me to make sure that results.vm.gasRefund has a value?

Copy link
Member

Choose a reason for hiding this comment

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

Along the lines of the first assignment, but you can leave the || BN(0) part, results.vm.gasRefund is already initialized with 0 I think (you might want to cross-check this).

@mikeseese
Copy link
Contributor Author

Sad day; I'll make sure to enable linting on the project to make sure I get rid of those semicolons.

@mikeseese
Copy link
Contributor Author

mikeseese commented Mar 20, 2018

Let me know if these changes aren't sufficient; thanks!

@holgerd77
Copy link
Member

Can you rebase this (we have deactivated the "Rebase and merge" feature for this library for security reasons, thanks for the tip with "Squash and merge" for the other PR, will use this in the future)? Then I will approve and merge.

@mikeseese
Copy link
Contributor Author

I believe that should be properly rebased now

@mikeseese
Copy link
Contributor Author

Just following up @holgerd77 to see if there's anything else I need to do for this PR

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

Looks good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Out of Gas Issues Due to Interpreting "gasUsed" as "gasConsumed"
4 participants