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 decoders to class hierarchy #7354

Merged
merged 8 commits into from
Sep 2, 2024

Conversation

LukaszRozmej
Copy link
Member

@LukaszRozmej LukaszRozmej commented Aug 22, 2024

Changes

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

@LukaszRozmej LukaszRozmej marked this pull request as ready for review August 23, 2024 09:22
@Scooletz Scooletz changed the title Refactor decoders to class hierarhy Refactor decoders to class hierarchy Aug 27, 2024
Copy link
Contributor

@emlautarom1 emlautarom1 left a comment

Choose a reason for hiding this comment

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

Personally I'm not a fan of using inheritance for code sharing but I can't argue with the fact that we can remove ~600 LOC with this change.

Some rigidity of a class based approach might make future refactors a bit trickier (ex. TxType will be removed`) but we can deal with it once it becomes a problem.

Overall LGTM and I would not have any issues merging it with the existing refactor PR but I would like to hear some additional opinions on this kind of design.

src/Nethermind/Nethermind.Serialization.Rlp/TxDecoder.cs Outdated Show resolved Hide resolved
using Nethermind.Serialization.Rlp.Eip2930;

namespace Nethermind.Serialization.Rlp.MyTxDecoder;
namespace Nethermind.Serialization.Rlp.TxDecoders;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also move the files to a TxDecoders folder (I forgot about that and left MyTxDecoder during development)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I actually did it, but reverted it as it made reviewing on github experience awful as it lost track they are edits. Will do it just before the merge.

@LukaszRozmej
Copy link
Member Author

LukaszRozmej commented Aug 29, 2024

Personally I'm not a fan of using inheritance for code sharing but I can't argue with the fact that we can remove ~600 LOC with this change.

Some rigidity of a class based approach might make future refactors a bit trickier (ex. TxType will be removed`) but we can deal with it once it becomes a problem.

Overall LGTM and I would not have any issues merging it with the existing refactor PR but I would like to hear some additional opinions on this kind of design.

  1. Yes it will evolve with further refactors.
  2. Do we want class hierarchy? IMO it is not a problem, because, the base classes are fixed and should never change - worst-case scenario we will move some parts of the code to new virtual methods. New classes can then override fine-grained stuff or, if bigger changes are needed, override some base methods. Or if they need to be completely different, they can implement the interface.
  3. If we really really don't want class hierarchy we can move some stuff to (static?) reusable methods and call them in the different classes.
  4. I would leave TxType even after we go to class hierarchy for transactions.
  5. In .net 9 we might be able to unify code for RlpStream and ValueDevcoderContext

@emlautarom1
Copy link
Contributor

If there are no more comments on the approach then I'll merge this with the existing PR so we can wrap up the work on the decoders.

@emlautarom1 emlautarom1 merged commit 87fdec0 into refactor/tx-decoder Sep 2, 2024
60 checks passed
@emlautarom1 emlautarom1 deleted the refactor/tx-decoder-class-hierarhy branch September 2, 2024 20:11
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.

3 participants