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

Make txpool independent of primitive tx types #8668

Closed
mattsse opened this issue Jun 7, 2024 · 2 comments · Fixed by #10504
Closed

Make txpool independent of primitive tx types #8668

mattsse opened this issue Jun 7, 2024 · 2 comments · Fixed by #10504
Labels
A-tx-pool Related to the transaction mempool C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Jun 7, 2024

Describe the feature

we need a tx trait abstraction for these conversions:

/// Trait for transaction types used inside the pool
pub trait PoolTransaction:
fmt::Debug
+ Send
+ Sync
+ FromRecoveredPooledTransaction
+ TryFromRecoveredTransaction
+ IntoRecoveredTransaction
{

pub trait FromRecoveredPooledTransaction {
/// Converts to this type from the given [`PooledTransactionsElementEcRecovered`].
fn from_recovered_pooled_transaction(tx: PooledTransactionsElementEcRecovered) -> Self;
}
/// The inverse of [`TryFromRecoveredTransaction`] that ensure the transaction can be sent over the
/// network
pub trait IntoRecoveredTransaction {
/// Converts to this type into a [`TransactionSignedEcRecovered`].
///
/// Note: this takes `&self` since indented usage is via `Arc<Self>`.
fn to_recovered_transaction(&self) -> TransactionSignedEcRecovered;
}

this likely requires additional associated types on the pool trait, where we use it, for example when returning the pooled variant.
like type PooledTx; which then have the conversions

/// The transaction type of the pool
type Transaction: PoolTransaction;

Update

after ##9916 we can continue with trying to gradually remove the bounds:

+ From<PooledTransactionsElementEcRecovered>
+ TryFrom<TransactionSignedEcRecovered>
+ Into<TransactionSignedEcRecovered>

we can approach this by identifying where these are used, and trying to enforce these bounds there, for example T: Trasactionpool < Consensus = TransactionSignedEcRecovered> etc...

and also remove these types from the Transactionpool trait and use the AT instead, this likely requires some additional bounds or traits on the impl:

fn get_pooled_transaction_elements(
&self,
tx_hashes: Vec<TxHash>,
limit: GetPooledTransactionLimit,
) -> Vec<PooledTransactionsElement>;
/// Returns converted [PooledTransactionsElement] for the given transaction hash.
///
/// This adheres to the expected behavior of
/// [`GetPooledTransactions`](https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getpooledtransactions-0x09):
///
/// If the transaction is a blob transaction, the sidecar will be included.
///
/// Consumer: P2P
fn get_pooled_transaction_element(&self, tx_hash: TxHash) -> Option<PooledTransactionsElement>;

FYI @tcoratger in case you want to continue

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request S-needs-design This issue requires design work to think about how it would best be accomplished A-tx-pool Related to the transaction mempool labels Jun 7, 2024
@mattsse mattsse added D-good-first-issue Nice and easy! A great choice to get started and removed S-needs-design This issue requires design work to think about how it would best be accomplished labels Jun 23, 2024
@JackG-eth
Copy link
Contributor

Will take this

@JackG-eth
Copy link
Contributor

@mattsse Sorry for the delay, will be picking this up again now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tx-pool Related to the transaction mempool C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Archived in project
2 participants