8000 chore(api): use func to return txData by GAtom22 · Pull Request #2884 · evmos/evmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore(api): use func to return txData #2884

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

Merged
merged 3 commits into from
Sep 26, 2024
Merged

chore(api): use func to return txData #2884

merged 3 commits into from
Sep 26, 2024

Conversation

GAtom22
Copy link
Contributor
@GAtom22 GAtom22 commented Sep 26, 2024

Description

This change assures were not re-using the same pointer on calls to the GetSigner functions.
More context here

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the correct branch (see PR Targeting)

Reviewers Checklist

All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

Summary by CodeRabbit

  • New Features

    • Introduced a new method, GetSingers, enhancing the API's ability to retrieve transaction data.
  • Improvements

    • Updated transaction type handling to enhance safety and prevent potential reuse or race conditions.

Copy link
Contributor
coderabbitai bot commented Sep 26, 2024

Walkthrough

The changes introduce a new feature in the API by refactoring the GetSingers method to utilize a function that returns TxDataV2. Additionally, the handling of Ethereum transaction types in the msg.go file is modified to store functions returning new pointers instead of direct pointers to instances. This aims to enhance the safety and structure of the code.

Changes

File Change Summary
api/ethermint/evm/v1/msg.go Refactored supportedTxs to store functions returning new pointers to transaction types, enhancing safety.
CHANGELOG.md Added entry for the introduction of a function in GetSingers to return TxDataV2, improving code structure.

Poem

In the code where rabbits hop,
A function now helps data swap.
With safety in each little byte,
Our API shines, oh what a sight!
Let’s celebrate with joyful cheer,
For changes made, we hold so dear! 🐇✨

Warning

Review ran into problems

🔥 Problems

Error running LanguageTool: LanguageTool error: Unknown error


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@GAtom22 GAtom22 marked this pull request as ready for review September 26, 2024 13:40
@GAtom22 GAtom22 requested a review from a team as a code owner September 26, 2024 13:40
@GAtom22 GAtom22 requested review from hanchon and Vvaradinov and removed request for a team September 26, 2024 13:40
@GAtom22
Copy link
Contributor Author
GAtom22 commented Sep 26, 2024

https://github.com/Mergifyio backport rama/release-v20

Copy link
Contributor
mergify bot commented Sep 26, 2024

backport rama/release-v20

✅ Backports have been created

Copy link
Contributor
@MalteHerrmann MalteHerrmann left a comment

Choose a reason for hiding this comment

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

thanks for porting this @GAtom22 🙏

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
api/ethermint/evm/v1/msg.go (2)

15-21: Excellent change to prevent pointer reuse!

The modification of supportedTxs to return new instances of transaction types is a great improvement. It effectively addresses the concern of pointer reuse and potential race conditions, aligning perfectly with the PR objectives.

Consider slightly rewording the comment for clarity:

- // Use a function to return a new pointer and avoid
- // possible reuse or racing conditions when using the same pointer
+ // Use functions to return new pointers, avoiding
+ // potential reuse or race conditions that could occur with shared pointers

42-46: Good implementation of the new approach

The changes to the GetSigners function correctly utilize the updated supportedTxs map. This ensures that a new instance of the transaction data is created each time, preventing any potential issues with shared state.

Consider a small optimization to reduce the number of map lookups:

-txDataFn, found := supportedTxs[msgEthTx.Data.TypeUrl]
-if !found {
-    return nil, fmt.Errorf("invalid TypeUrl %s", msgEthTx.Data.TypeUrl)
-}
-txData := txDataFn()
+if txDataFn, found := supportedTxs[msgEthTx.Data.TypeUrl]; found {
+    txData := txDataFn()
+} else {
+    return nil, fmt.Errorf("invalid TypeUrl %s", msgEthTx.Data.TypeUrl)
+}

This change combines the lookup and error checking, slightly improving performance and readability.

CHANGELOG.md (1)

Line range hint 110-1037: LGTM: CHANGELOG.md is well-maintained and provides a comprehensive history.

The CHANGELOG.md file maintains a consistent format throughout its history, providing a detailed record of changes for each version from v15.0.0 back to v0.1.0. This comprehensive changelog is valuable for users and developers to understand the evolution of the project.

Consider adding a note at the beginning of the file mentioning whether the project follows Semantic Versioning (SemVer). This information helps users understand the versioning scheme used in the project.

🧰 Tools
🪛 Markdownlint

61-61: Expected: 120; Actual: 133
Line length

(MD013, line-length)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 27de898 and 13bb5bf.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • api/ethermint/evm/v1/msg.go (2 hunks)
🔇 Additional comments (3)
api/ethermint/evm/v1/msg.go (1)

Line range hint 1-58: Summary: Excellent improvements to transaction handling

The changes in this file significantly enhance the safety and correctness of Ethereum transaction handling. By modifying supportedTxs to return new instances of transaction types, the code now prevents potential issues related to shared pointers and race conditions.

Key improvements:

  1. Enhanced safety by avoiding pointer reuse
  2. Clear comments explaining the rationale behind the changes
  3. Consistent implementation throughout the file

These changes align perfectly with the PR objectives and represent a valuable improvement to the codebase. Great work!

CHANGELOG.md (2)

64-64: LGTM: Unreleased section is well-structured and informative.

The Unreleased section is organized clearly with appropriate subsections for State Machine Breaking changes, Improvements, and Bug Fixes. Each entry is properly formatted with the affected module/area and includes links to the corresponding pull requests. This structure makes it easy for users to understand the upcoming changes in the next release.


Line range hint 66-108: LGTM: v15.0.0 section is comprehensive and well-formatted.

The v15.0.0 section provides a detailed overview of the changes in this release. It includes API Breaking, State Machine Breaking, Improvements, and Bug Fixes subsections, each with well-documented changes and links to the corresponding pull requests. The format is consistent with the Unreleased section, maintaining readability throughout the changelog.

🧰 Tools
🪛 Markdownlint

61-61: Expected: 120; Actual: 133
Line length

(MD013, line-length)

@GAtom22 GAtom22 enabled auto-merge (squash) September 26, 2024 13:52
@GAtom22 GAtom22 merged commit 30ef902 into main Sep 26, 2024
50 of 52 checks passed
@GAtom22 GAtom22 deleted the GAtom22/msg-data branch September 26, 2024 14:45
mergify bot pushed a commit that referenced this pull request Sep 26, 2024
* chore(api): use func to return txData

* add changelog entry

* update comment

(cherry picked from commit 30ef902)

# Conflicts:
#	CHANGELOG.md
GAtom22 added a commit that referenced this pull request Sep 26, 2024
* chore(api): use func to return txData (#2884)

* chore(api): use func to return txData

* add changelog entry

* update comment

(cherry picked from commit 30ef902)

# Conflicts:
#	CHANGELOG.md

* update chlog

---------

Co-authored-by: Tom <54514587+GAtom22@users.noreply.github.com>
Co-authored-by: tom <tomasguerraalda@hotmail.com>
@coderabbitai coderabbitai bot mentioned this pull request Oct 31, 2024
8758 9 tasks
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.

4 participants
0