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 tree shaking opportunity -> TxFactory #3485

Closed
acolytec3 opened this issue Jul 5, 2024 · 4 comments · Fixed by #3514
Closed

tx tree shaking opportunity -> TxFactory #3485

acolytec3 opened this issue Jul 5, 2024 · 4 comments · Fixed by #3514

Comments

@acolytec3
Copy link
Contributor

acolytec3 commented Jul 5, 2024

Part of #3446

Earliest start together with official breaking release work!

One small opportunity for tree shaking is to convert the existing TxFactory class into a series of single functions that are exported from the tx package or something similar. The class itself serves no essential purpose beyond offering an entry point to the transaction factory. We should pick this up when we get into tree shaking.

@jochem-brouwer
Copy link
Member

I'm not entirely sure why this is breaking?

@holgerd77
Copy link
Member

This substantially changes how a TXFactory is implemented and the exposed API changes completely, so users will likely adopt to the new methods and can't use their old imports and instantiations anymore.

@acolytec3
Copy link
Contributor Author

acolytec3 commented Jul 5, 2024

Instead of doing something like TxFactory.fromTxData, it would become simply:

import { fromTxData } from '@ethereumjs/tx'`
//...
const tx = await fromTxData(...txData)

We could consider an alternative approach which is a single txFactory function that accepts either an object of txData, uint8Array (assumes RLP encoded), or else uint8Array[] (assumes "raw" format) and then produces a tx using the correct static constructor from the transaction library

@holgerd77 holgerd77 changed the title tx tree shaking opportunity tx tree shaking opportunity -> TxFactory Jul 9, 2024
@holgerd77
Copy link
Member

One thing to note here, I think this also goes very much along with #3487 and one thing to make sure is that the respective tx type specific not-used from* static constructor methods are tree-shaked out when a specific from* method is used from within the tx factory.

So if e.g. fromTxData() is used from the tx factory that only the create1559TxFromTxData() (or however we name, we should actually align naming here and within the tx type implementations) and the like are kept and the other static constructors (create1559TxFromValuesArray(),...) are thrown out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants