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

[Utility] Refactor and rename some existing functions related to handling transactions #771

Merged
merged 35 commits into from
Jun 2, 2023

Conversation

Olshansk
Copy link
Member

@Olshansk Olshansk commented May 19, 2023

Description

Summary generated by Reviewpad on 02 Jun 23 18:33 UTC

This pull request includes various changes across multiple files. These changes involve adding new interfaces and methods, renaming functions, refactoring code, improving error handling, updating documentation, and making modifications to the mempool and transaction validation logic.

Issue

NA

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation
  • Other

List of changes

  • Avoid using the utilityUnitOfWork in the rpc module because we do not want to have it run utility's business logic
  • Added GetIndexedTransaction to the UtilityModule interface to be able to retrieve an indexed transaction without running the underlying business logic
  • Renamed HydrateIdxTx to HandleTransaction in the UtilityUnitOfWorkinterface so its more descriptive of what the function does
  • Moved over all the business logic related to getting "signer candidates" into its own file for readability purposes
  • Renamed anteHandleMessage to basicValidateTransaction
  • Split the logic in basicValidateTransaction into multiple smaller functions for readability and so adding new business logic will be clearer

TODO_IN_THIS_COMMIT:

  • Add an E2E test that leverages txProtoBytesToRPCIdxTxs in the RPC module
  • Add unit tests for GetIndexedTransaction in the utility module
  • Add a few unit tests for basicValidateTransaction

Testing

  • make develop_test; if any code changes were made
  • make test_e2e on k8s LocalNet; if any code changes were made
  • e2e-devnet-test passes tests on DevNet; if any code was changed
  • Docker Compose LocalNet; if any major functionality was changed or introduced
  • k8s LocalNet; if any infrastructure or configuration changes were made

Required Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added, or updated, godoc format comments on touched members (see: tip.golang.org/doc/comment)
  • I have tested my changes using the available tooling
  • I have updated the corresponding CHANGELOG

If Applicable Checklist

  • I have updated the corresponding README(s); local and/or global
  • I have added tests that prove my fix is effective or that my feature works
  • I have added, or updated, mermaid.js diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@Olshansk Olshansk added utility Utility specific changes code health Nice to have code improvement labels May 19, 2023
@Olshansk Olshansk self-assigned this May 19, 2023
@reviewpad reviewpad bot added the large Pull request is large label May 19, 2023
@Olshansk Olshansk marked this pull request as ready for review May 19, 2023 01:11
@Olshansk
Copy link
Member Author

@h5law @dylanlott @adshmh I marked this as ready for review because all the core business logic changes I intend to have in this PR is complete. This touches some code that all of us are working on, so I want to get this in and avoid more complex merge conflicts in the future.

I left a few TODO_IN_THIS_COMMIT items in the GitHub description regarding tests I need to add and will focus on those tomorrow. Just wanted to start getting 👀 at this in parallel and give all of you a heads-up of the change.

@Olshansk Olshansk force-pushed the minor_tx_processing_improvement branch from 52dc6f4 to 6a4330a Compare May 24, 2023 04:21
@Olshansk
Copy link
Member Author

@h5law @dylanlott @adshmh I haven't added an E2E test that leverages txProtoBytesToRPCIdxTxs and will do that tomorrow. Might also leave it for a follow-up PR depending on how long the review on this one takes.

Otherwise, this is ready to go.

@Olshansk Olshansk requested a review from h5law May 30, 2023 19:48
@codecov
Copy link

codecov bot commented May 30, 2023

Codecov Report

Patch coverage: 52.30% and project coverage change: +1.11 🎉

Comparison is base (fe4780b) 30.12% compared to head (12104a8) 31.24%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #771      +/-   ##
==========================================
+ Coverage   30.12%   31.24%   +1.11%     
==========================================
  Files         103      106       +3     
  Lines        8836     8958     +122     
==========================================
+ Hits         2662     2799     +137     
+ Misses       5857     5824      -33     
- Partials      317      335      +18     
Impacted Files Coverage Δ
persistence/indexer/indexer.go 60.82% <ø> (ø)
utility/types/idx_tx.go 0.00% <ø> (ø)
utility/types/message.go 57.02% <ø> (ø)
utility/unit_of_work/tx_message_handler.go 34.51% <ø> (-1.81%) ⬇️
utility/unit_of_work/uow_leader.go 0.00% <0.00%> (ø)
shared/core/types/error.go 6.15% <33.33%> (+6.15%) ⬆️
utility/unit_of_work/tx_message_signers.go 43.75% <43.75%> (ø)
shared/core/types/signature.go 62.50% <50.00%> (ø)
utility/unit_of_work/transaction.go 45.20% <52.27%> (+3.10%) ⬆️
utility/transaction.go 72.22% <75.00%> (+72.22%) ⬆️
... and 2 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@h5law h5law left a comment

Choose a reason for hiding this comment

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

LGTM I think the GetIndexedTransaction simplification is spot on, everything else looks in order, :shipit:

@Olshansk Olshansk added the e2e-devnet-test Runs E2E tests on devnet label May 30, 2023
func ErrSignatureVerificationFailed() Error {
return NewError(CodeSignatureVerificationFailedError, SignatureVerificationFailedError)
}

func ErrRetrievingSignableBytes(err error) Error {
return NewError(CodeRetrievingSignableBytesError, fmt.Sprintf("%s: %s", RetrievingSignableBytesError, err.Error()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrapping errors in general makes more sense IMO (although I understand it would not be very consistent with current codebase)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not a fan of error.go myself (didn't create it), but we're just staying consistent with this approach we work on #556 to standardize it.

utility/transaction.go Outdated Show resolved Hide resolved
utility/transaction.go Outdated Show resolved Hide resolved
@Olshansk Olshansk requested a review from adshmh June 1, 2023 20:36
utility/transaction.go Outdated Show resolved Hide resolved
@Olshansk Olshansk requested a review from adshmh June 1, 2023 21:50
@Olshansk Olshansk merged commit 10a931a into main Jun 2, 2023
@Olshansk Olshansk deleted the minor_tx_processing_improvement branch June 2, 2023 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Nice to have code improvement e2e-devnet-test Runs E2E tests on devnet large Pull request is large utility Utility specific changes waiting-for-review
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants