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

refactor NewTx and NewContract arguments #1402

Merged
merged 23 commits into from
Feb 21, 2023
Merged

refactor NewTx and NewContract arguments #1402

merged 23 commits into from
Feb 21, 2023

Conversation

facs95
Copy link
Contributor

@facs95 facs95 commented Feb 16, 2023

Description

This PR refactors NewTx and NewContract function at x/evm/types/msg.go. Instead of passing an enourmous amount of arguments, we accomplish the same goal through a new struct EvmTxArgs .

This will make the test Txs helper function migration into a global common util package easier and cleaner.

The PR aims to make things simpler for the testing suite refactor, specifically the global tx util functions that are so repetitive throughout the codebase.

This PR does NOT change any tests functionality nor tries to do a refractor on this tests. Just changes tests to pass the arguments through the struct.

Test refactor and migration into a common package will come on a following PR.


Closes #XXX

@facs95 facs95 requested review from ramacarlucho, hanchon and a team as code owners February 16, 2023 03:48
@facs95 facs95 requested review from 0a1c and removed request for a team February 16, 2023 03:48
@facs95 facs95 changed the title refactor NewTx and NewContract argument list refactor NewTx and NewContract arguments Feb 16, 2023
@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Merging #1402 (ca5d3d9) into main (1138487) will decrease coverage by 0.08%.
The diff coverage is 69.23%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1402      +/-   ##
==========================================
- Coverage   72.40%   72.32%   -0.08%     
==========================================
  Files         260      260              
  Lines       17725    17723       -2     
==========================================
- Hits        12833    12818      -15     
- Misses       4322     4336      +14     
+ Partials      570      569       -1     
Impacted Files Coverage Δ
x/evm/types/tx.go 0.00% <ø> (ø)
x/evm/types/msg.go 73.36% <69.23%> (-6.73%) ⬇️
app/ante/evm/eth.go 81.05% <0.00%> (+0.88%) ⬆️

Copy link
Contributor

@0a1c 0a1c left a comment

Choose a reason for hiding this comment

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

Nice PR @facs95. One suggestion: Can we define a few test EvmTxArgs types in a testutils directory, then use the same objects everywhere?

There's a lot of duplicate code in the current state, and doing this would simplify the implementation a lot.

app/ante/evm/ante_test.go Outdated Show resolved Hide resolved
tx.From = addr.Hex()
err = tx.Sign(suite.ethSigner, testutil.NewSigner(privKey))
suite.Require().NoError(err)

tx2 := evmtypes.NewTx(suite.app.EvmKeeper.ChainID(), 1, &to, big.NewInt(10), 1000, big.NewInt(1), nil, nil, nil, nil)
ethTxParamsNonce1 := &evmtypes.EvmTxArgs{
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can wrap these with a helper function?

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.

Requested changes to prevent additional breaking changes. Don't forget adding the changelog entry

x/evm/types/msg.go Outdated Show resolved Hide resolved
@fedekunze fedekunze marked this pull request as draft February 16, 2023 09:37
@facs95
Copy link
Contributor Author

facs95 commented Feb 16, 2023

Nice PR @facs95. One suggestion: Can we define a few test EvmTxArgs types in a testutils directory, then use the same objects everywhere?

There's a lot of duplicate code in the current state, and doing this would simplify the implementation a lot.

@austinchandra Yes that's exactly the idea! Will be done on a follow up PR for ease of reviewing

@facs95 facs95 marked this pull request as ready for review February 16, 2023 14:48
@facs95 facs95 requested review from 0a1c and removed request for ramacarlucho February 21, 2023 11:47
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, pending changelog entry and removing NewTxContract function

x/evm/types/msg.go Outdated Show resolved Hide resolved
@facs95 facs95 merged commit 57e7423 into main Feb 21, 2023
@facs95 facs95 deleted the facs95/eth-msg-refactor branch February 21, 2023 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants