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: separate transaction builders for tx types #1259

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Sep 9, 2024

Motivation

Not all netwoks support 7702 and 4844 transactions, however, current network abstraction requires TransactionRequest to contain setters for both of those tx types. This results in custom network implementations either having no-op setters/getters on builders, or introducing additional fallible steps during transaction conversion pipeline to reject attempts to construct unsupported transactions.

Solution

Extracts part of TransactionBuilder methods into TransactionBuilder4844 and TransactionBuilder7702. Extracts blob fee filling from GasFiller into BlobGasFiller which enforces N::TxRequest: TransactionBuilder4844 bound.

Given that filling logic now depends on transaction request properties, I've extracted recomended fillers into RecommendedFillers trait which can be implemented on custom network implementations, adding support for filling custom transaction types. Right now it is implemented on Ethereum and AnyNetwork.

This makes it a bit harder to use transaction builder due to need to import 2 additional traits, so I'm wondering if we should consider adding some of the methods directly to it?

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

type safety ftw

@@ -210,8 +157,6 @@ impl<N: Network> TxFiller<N> for GasFiller {
{
if tx.gas_price().is_some() || tx.access_list().is_some() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Our GasFiller automatically treats transaction as legacy if it has an accessList set which is not really correct. We also have a test enforcing this, wondering if this should be changed?

Copy link
Member

@mattsse mattsse Sep 9, 2024

Choose a reason for hiding this comment

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

I believe this is a bug, should be changed

Copy link
Member Author

Choose a reason for hiding this comment

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

updated in 5697944

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

This makes it a bit harder to use transaction builder due to need to import 2 additional traits, so I'm wondering if we should consider adding some of the methods directly to it?

this should be okay

Comment on lines +313 to +315
pub trait RecommendedFillers {
/// Recommended fillers for this network.
type RecomendedFillters: TxFiller;
Copy link
Member

Choose a reason for hiding this comment

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

I think this makes a ton of sense, so we can network specific defaults

@klkvr
Copy link
Member Author

klkvr commented Sep 9, 2024

should we merge this now or hold off until next breaking release?

@mattsse
Copy link
Member

mattsse commented Sep 9, 2024

I'd like to hold off and see if we can do a smaller patch soon because @tcoratger is flagging a few more missing features

@klkvr klkvr merged commit 099e64d into main Sep 17, 2024
30 checks passed
@klkvr klkvr deleted the klkvr/separate-tx-builders branch September 17, 2024 11:30
lwedge99 pushed a commit to sentioxyz/alloy that referenced this pull request Oct 8, 2024
* refactor: txtype-specific transaction builders

* enforce legacy if access list

* ignore access list
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