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

R4R: Fix runTx Gas Consumption during Tx Aborting #3244

Merged
merged 3 commits into from
Jan 8, 2019

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Jan 7, 2019

For a given block, if a tx fails/aborts, we currently do not update the context and as such the defered function call in BaseApp#runTx still uses the infiniteGasMeter and subsequent txs may well exceed the limit.

closes: #3242


  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@alexanderbez alexanderbez added C:baseapp wip T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). labels Jan 7, 2019
@codecov
Copy link

codecov bot commented Jan 7, 2019

Codecov Report

Merging #3244 into develop will decrease coverage by <.01%.
The diff coverage is 80%.

@@             Coverage Diff             @@
##           develop    #3244      +/-   ##
===========================================
- Coverage    54.88%   54.87%   -0.01%     
===========================================
  Files          133      133              
  Lines         9555     9553       -2     
===========================================
- Hits          5244     5242       -2     
  Misses        3989     3989              
  Partials       322      322

Copy link
Contributor

@hendrikhofstadt hendrikhofstadt left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Contributor

@hendrikhofstadt hendrikhofstadt left a comment

Choose a reason for hiding this comment

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

		stdTx, ok := tx.(StdTx)
		if !ok {
			return ctx, sdk.ErrInternal("tx must be StdTx").Result(), true
		}

One could still provoke the infinite gas meter to be used by including a non stdtx

@alexanderbez
Copy link
Contributor Author

Updated @SLAMPER

@alexanderbez alexanderbez changed the title WIP: Fix runTx Gas Consumption during Tx Aborting R4R: Fix runTx Gas Consumption during Tx Aborting Jan 7, 2019
@jackzampolin
Copy link
Member

Nice! Is there any way we can add a test for this behavior?

@alexanderbez
Copy link
Contributor Author

It would have to bypass checkTx I think? So I'm not totally sure.

Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

Despite the lack of a test case, I give my nihil obstat. I think we are excused here to go ahead and validate this anyway, having seen the difficulty of testing this in an automated fashion. Furthermore, the bug fixed by this PR is easily reproducible by hand.

Copy link
Member

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

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

Good fix @alexanderbez

@jackzampolin jackzampolin merged commit 9eef341 into develop Jan 8, 2019
@jackzampolin jackzampolin deleted the bez/3242-baseapp-gas-fix branch January 8, 2019 23:56
@ValarDragon
Copy link
Contributor

Can a follow-up issue be written up for getting a test for this? It is very critical that we have tests for these fundamental baseapp responsibilities, we've had lots of severe bugs regarding this lately.

@alexanderbez
Copy link
Contributor Author

Completely agree @ValarDragon -- suggestions on how to test something like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:baseapp T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpectedly high gas usage in delegate transaction on game_of_stakes_3
5 participants