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

dev: simplify WithOtherFields<T> usage #1398

Open
tcoratger opened this issue Sep 23, 2024 · 9 comments
Open

dev: simplify WithOtherFields<T> usage #1398

tcoratger opened this issue Sep 23, 2024 · 9 comments
Labels
enhancement Enhancement of the code, not introducing new features. good first issue Good first issue for people wanting to contribute to this project.

Comments

@tcoratger
Copy link
Collaborator

In our codebase, we use the other field of transactions to store isRunOutOfResources information. This leads to extensive usage of WithOtherFields<T> throughout the code after the merge of #1389, especially when handling conversions between RPC and primitive types, as seen in https://github.com/paradigmxyz/reth/blob/fba837468cac5143b415c9dd4fdc9218d71a926b/crates/primitives/src/alloy_compat.rs#L55-L212.

However, this approach is complex and can be optimized for better readability and management.

Proposal

  1. Simplify where possible: identify and remove unnecessary uses of WithOtherFields<T>, replacing them with just T where the extra fields aren't needed.
  2. Define a reusable type: introduce a type alias such as ExtendedTransaction = WithOtherFields<Transaction> (and similar for blocks) to standardize its usage where necessary.
@tcoratger tcoratger added enhancement Enhancement of the code, not introducing new features. good first issue Good first issue for people wanting to contribute to this project. labels Sep 23, 2024
@Samrath49
Copy link

Hi @tcoratger, I would like to contribute to this issue, kindly assign me.

Copy link

onlydustapp bot commented Sep 23, 2024

Hey @Samrath49!
Thanks for showing interest.
We've created an application for you to contribute to Kakarot zkEVM.
Go check it out on OnlyDust!

@tcoratger
Copy link
Collaborator Author

@Samrath49 Assigned

@greged93
Copy link
Collaborator

greged93 commented Oct 1, 2024

@Samrath49 any update on this?

@maxslimb
Copy link

@tcoratger can you explain more about the issue with references to simplifying WithOtherFields usages?

@sajalbnl
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I want to work on this

@udyan13
Copy link

udyan13 commented Oct 14, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

As a seasoned Rust developer, I have a proven track record of optimizing complex codebases for both performance and readability. My experience includes refactoring legacy code, implementing type aliases, and working with RPC systems. I'm confident in my ability to improve the clarity and maintainability of our WithOtherFields code while ensuring functionality remains intact. I'm a collaborative problem-solver who is committed to producing high-quality code.

How I plan on tackling this issue

The summary you provided is clear and well-structured. Here are a few points to consider for improvement and clarity:

Strengths
Clarity: The steps are articulated in a logical order, making it easy to follow your approach.
Comprehensive: It covers all essential aspects, from analysis to documentation and communication.
Focus on Collaboration: Emphasizing team communication is a great addition, as it highlights a collaborative mindset.
Minor Suggestions
Conciseness: While the paragraph is clear, you might condense some phrases to enhance readability.
Terminology Consistency: Ensure terms like "redundant" and "essential" are clearly defined if the audience may not be familiar with them.
Revised Version
Here’s a slightly refined version:

To approach the problem, I would start with a thorough code review to identify all instances of WithOtherFields and assess their necessity. These usages would be categorized into three groups: essential cases required for functionality, redundant cases that can be safely removed, and ambiguous cases needing further team discussion. For the redundant cases, I would develop a plan to replace WithOtherFields with T, documenting the rationale for retaining it in essential cases. Additionally, I would introduce type aliases, such as ExtendedTransaction and ExtendedBlock, to standardize usage. Ensuring comprehensive testing is crucial; I would run existing tests and add new ones following the changes. I would also update relevant documentation to reflect these modifications and provide guidelines for future usage. Throughout the process, maintaining open communication with the team would be essential for gathering feedback and ensuring alignment. This structured approach aims to reduce complexity while preserving functionality and enhancing code readability.

@chigozzdevv
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hey there! I'm really excited about this task - it's right up my alley. I've been working with Rust and blockchain tech for a while now, and I love digging into codebases to make them cleaner and more efficient.

How I plan on tackling this issue

For this problem, here's how I'd tackle it:
First off, I'd dive into the code and really get a feel for how we're using WithOtherFields. It's always good to understand the full picture before making changes.
Then, I'd go through and look for any easy wins - places where we can just use T instead of WithOtherFields without losing anything important. It's surprising how often we can simplify things with a fresh pair of eyes.
I like the idea of creating those type aliases. It'd make the code much easier to read and understand. I'd probably call them something like ExtendedTransaction and ExtendedBlock, and make sure to add some clear comments about when to use them.
When it comes to making changes, I prefer to take it step by step. Start with the obvious stuff, test it out, then move on to the trickier parts. It helps catch any issues early on.

@PabloVillaplana
Copy link
Contributor

PabloVillaplana commented Oct 15, 2024

Hey Thomas @tcoratger Can I take this one? ☝️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the code, not introducing new features. good first issue Good first issue for people wanting to contribute to this project.
Projects
Status: 🆕 Backlog
Development

No branches or pull requests

8 participants