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

fix: don't revert gas refund logic when transaction reverted #751

Merged
merged 5 commits into from
Nov 16, 2021

Conversation

yihuang
Copy link
Contributor

@yihuang yihuang commented Nov 16, 2021

Description

Problem: When there are hooks and the transaction reverted, gas refund logic is reverted too.
Solution: Don't revert the gas refund logic


For contributor use:

  • 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.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@yihuang yihuang changed the title fix gas consumption when transaction reverted fix: fix gas consumption when transaction reverted Nov 16, 2021
@yihuang yihuang changed the title fix: fix gas consumption when transaction reverted fix: don't revert gas refund logic when transaction reverted Nov 16, 2021
@codecov
Copy link

codecov bot commented Nov 16, 2021

Codecov Report

Merging #751 (295e53e) into main (e96a4b9) will increase coverage by 0.01%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #751      +/-   ##
==========================================
+ Coverage   55.84%   55.86%   +0.01%     
==========================================
  Files          64       64              
  Lines        5857     5859       +2     
==========================================
+ Hits         3271     3273       +2     
  Misses       2386     2386              
  Partials      200      200              
Impacted Files Coverage Δ
x/evm/keeper/state_transition.go 76.89% <50.00%> (+0.15%) ⬆️

x/evm/handler_test.go Outdated Show resolved Hide resolved
Comment on lines 71 to 72
// CompiledContract2 support json format of newer solc
type CompiledContract2 struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename this struct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remoevd.

return crypto.CreateAddress(suite.from, nonce)
}

func (suite *EvmTestSuite) TestGasWhenReverted() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we refactor this test? it's not maintainable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realize we don't need a special contract to reproduce the contract revert, so I changed it to the existing erc20 contract, is it good now?

Apply suggestions from code review

changelog
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
@fedekunze fedekunze enabled auto-merge (squash) November 16, 2021 14:26
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.

2 participants