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

Tx: get rid of BaseTransaction #3744

Merged
merged 29 commits into from
Nov 11, 2024
Merged

Tx: get rid of BaseTransaction #3744

merged 29 commits into from
Nov 11, 2024

Conversation

jochem-brouwer
Copy link
Member

@jochem-brouwer jochem-brouwer commented Oct 17, 2024

Part of #3733

This PR is "phase 1" of the big tx refactor. This PR:

  • Gets rid of the inheritance pattern of tx and switches to a composition pattern
  • This means that we fully get rid of src/basetransaction.js

This PR does not intend to change any logic. Besides that, this PR:

The current state is still WIP, need to:

  • Better align shared methods (most of them are in Legacy capabilities, should likely move to some shared folder)
  • Fix tests
  • Fix upstream imports

@jochem-brouwer jochem-brouwer changed the title tx: remove basetx [WIP] [no ci] Tx: get rid of BaseTransaction Nov 8, 2024
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 87.36383% with 58 lines in your changes missing coverage. Please review.

Project coverage is 75.84%. Comparing base (287f960) to head (226135b).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 73.74% <ø> (ø)
blockchain 83.25% <ø> (ø)
client 74.00% <ø> (ø)
common 89.89% <ø> (ø)
devp2p 71.95% <ø> (ø)
evm 64.89% <ø> (ø)
genesis 100.00% <ø> (ø)
mpt 52.27% <ø> (+0.18%) ⬆️
rlp 95.11% <ø> (ø)
statemanager 68.81% <ø> (ø)
tx 76.52% <87.33%> (-0.18%) ⬇️
util 72.73% <ø> (ø)
vm 57.35% <100.00%> (ø)
wallet 79.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

* @param bits Number of bits to check (64 or 256)
* @param cannotEqual Pass true if the number also cannot equal one less the maximum value
*/
export function valueBoundaryCheck( // TODO: better method name
Copy link
Contributor

Choose a reason for hiding this comment

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

For this and the other util methods:
In the context of composition rather than inheritance, I feel like we should be a bit more explicit with the naming (e.g. with reference to "sharedTxConstructor" rather than "shared constructor"). I'm not sure if this method (and the other method utils) are intended to be used outside of a transaction context, but if they are exported outside of the package, I think we have be particularly explicit with naming. This is actually one of the benefits of class-based methods imo (not that I don't prefer this pattern), is they are naturally namespaced by virtue of the class they belong to.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are not supposed to be exported outside of the package! These are only supposed to be used internally. These "shared" methods nevertheless have to be named differently. We also have the opportunity now (due to breaking releases) to give everything a more clear name!

@jochem-brouwer jochem-brouwer marked this pull request as ready for review November 11, 2024 14:47
tx.common = getCommon(opts.common)
tx.common.updateParams(opts.params ?? paramsTx)

validateNotArray(txData) // is this necessary?
Copy link
Contributor

Choose a reason for hiding this comment

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

As I recall, this got added because there was some weird edge case where we were accepting txData where somehow an array got passed in.

Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

LGTM

@acolytec3 acolytec3 merged commit 41f158b into master Nov 11, 2024
41 checks passed
@acolytec3 acolytec3 deleted the tx-remove-basetx branch November 11, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tx: Class names not fully consistent yet
3 participants