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

Problem: state transition code is duplicated #674

Merged
merged 2 commits into from
Oct 22, 2021
Merged

Conversation

yihuang
Copy link
Contributor

@yihuang yihuang commented Oct 14, 2021

Closes: #672

Description

The refactor is separated into three commits:

  • move gas refund out from ApplyMessage
  • move check into ApplyMessage
  • move evm construction into ApplyMessage

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 marked this pull request as draft October 14, 2021 07:36
@yihuang yihuang force-pushed the ctxstack branch 2 times, most recently from ea35bc4 to d7bd298 Compare October 14, 2021 07:47
@yihuang yihuang marked this pull request as ready for review October 14, 2021 07:51
@codecov
Copy link

codecov bot commented Oct 14, 2021

Codecov Report

Merging #674 (3352dba) into main (b1aedf9) will increase coverage by 0.16%.
The diff coverage is 63.20%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #674      +/-   ##
==========================================
+ Coverage   57.20%   57.36%   +0.16%     
==========================================
  Files          63       63              
  Lines        5545     5505      -40     
==========================================
- Hits         3172     3158      -14     
+ Misses       2209     2180      -29     
- Partials      164      167       +3     
Impacted Files Coverage Δ
x/evm/types/errors.go 100.00% <ø> (ø)
x/evm/keeper/state_transition.go 76.43% <58.88%> (+2.44%) ⬆️
x/evm/keeper/grpc_query.go 62.95% <71.42%> (+0.87%) ⬆️
app/ante/eth.go 88.20% <100.00%> (+0.21%) ⬆️
x/evm/keeper/keeper.go 75.42% <100.00%> (+0.28%) ⬆️

Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

Refactor changes look good, although I believe that there are changes that are not related to the duplicated code. Please undo those and open new issues/PRs to review them individually

rpc/ethereum/namespaces/eth/filters/filters.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Show resolved Hide resolved
x/evm/keeper/state_transition.go Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
@@ -314,72 +338,40 @@ func (k *Keeper) ApplyMessage(evm *vm.EVM, msg core.Message, cfg *params.ChainCo
ret, leftoverGas, vmErr = evm.Call(sender, *msg.To(), msg.Data(), leftoverGas, msg.Value())
}

refundQuotient := params.RefundQuotient
refundQuotient := ethparams.RefundQuotient
Copy link
Contributor

Choose a reason for hiding this comment

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

undo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The module name is in conflict with the variable name, thus the rename.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit, I think you can undo this with the latest change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Show resolved Hide resolved
@yihuang yihuang force-pushed the ctxstack branch 2 times, most recently from 5881c0e to 388e413 Compare October 21, 2021 07:57
Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

ACK, minor comments. Pending changelog entry

@@ -314,72 +338,40 @@ func (k *Keeper) ApplyMessage(evm *vm.EVM, msg core.Message, cfg *params.ChainCo
ret, leftoverGas, vmErr = evm.Call(sender, *msg.To(), msg.Data(), leftoverGas, msg.Value())
}

refundQuotient := params.RefundQuotient
refundQuotient := ethparams.RefundQuotient
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, I think you can undo this with the latest change

x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
@yihuang
Copy link
Contributor Author

yihuang commented Oct 21, 2021

ACK, minor comments. Pending changelog entry

fixed, changelog added.

@yihuang
Copy link
Contributor Author

yihuang commented Oct 22, 2021

The test-solidity test case failure seems to also happens on the main branch, I've opened an issue for that: #690

@fedekunze
Copy link
Contributor

@yihuang there seems to be a significant performance regression, can you check that?

Closes: evmos#672

Solution:
- move gas refund out from ApplyMessage
- move check into ApplyMessage
- move evm construction into ApplyMessage
- ensure context stack is clean after ApplyMessage return

fix unit tests

undo rename

add underflow check
- don't duplicate params loading
- passing EVMConfig around as pointer
@yihuang
Copy link
Contributor Author

yihuang commented Oct 22, 2021

@yihuang there seems to be a significant performance regression, can you check that?

it seems fixed.

@fedekunze fedekunze merged commit 1fe07ed into evmos:main Oct 22, 2021
yihuang added a commit to yihuang/ethermint that referenced this pull request Nov 15, 2021
* Problem: state transition code is duplicated

Closes: evmos#672

Solution:
- move gas refund out from ApplyMessage
- move check into ApplyMessage
- move evm construction into ApplyMessage
- ensure context stack is clean after ApplyMessage return

fix unit tests

undo rename

add underflow check

* improve performance

- don't duplicate params loading
- passing EVMConfig around as pointer
@yihuang yihuang deleted the ctxstack branch November 16, 2021 09:31
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.

Problem: state transition code is duplicated
2 participants