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

chore(sdk): improve usability tx primitive traits #12437

Merged
merged 23 commits into from
Nov 13, 2024
Merged

Conversation

emhane
Copy link
Member

@emhane emhane commented Nov 10, 2024

Implements Transaction for SignedTransaction types

@emhane emhane added the A-sdk Related to reth's use as a library label Nov 10, 2024
@emhane emhane requested review from mattsse and klkvr November 10, 2024 17:56
@Rjected Rjected added the C-enhancement New feature or request label Nov 12, 2024
@emhane emhane requested a review from fgimenez November 12, 2024 10:38
Copy link
Collaborator

@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.

don't fully get the motivation here, doesn't this effectively just extend the transaction trait with an AT for txtype?

{
}

impl<T> TxType for T where
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want a default here

Copy link
Member Author

Choose a reason for hiding this comment

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

it's derived for reth_primitives::TxType, so we probably wan't to remove that attribute next before integrating the generic tx type, in order to keep scope meaningful

on the other hand, if a tx type is unknown, don't we fallback to try to decode it as a legacy tx? hence it's kind of like a default? @mattsse

/// Helper trait that unifies all behaviour required by transaction to support full node operations.
pub trait FullTransaction: Transaction + Compact {}

impl<T> FullTransaction for T where T: Transaction + Compact {}

#[allow(dead_code)]
/// Abstraction of a transaction.
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we still need this?
unclear why we need 3 traits now if this trait is now just a default

Copy link
Member Author

@emhane emhane Nov 12, 2024

Choose a reason for hiding this comment

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

I thought about moving the rlp encoding traits to FullTransaction...to make primitive traits more lightweight. I'm also good with removing the Full-traits for the data primitive traits and adding Compact as a super trait always. wdyt? @mattsse

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

@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.

In essence, the new trait AlloyTransactionExt can be removed with #12465 and moving is_dynamic_fee down a level into alloy_consensus::Transaction.

crates/primitives-traits/src/transaction/signed.rs Outdated Show resolved Hide resolved
crates/primitives-traits/src/transaction/signed.rs Outdated Show resolved Hide resolved
Comment on lines +89 to +91
fn signature_hash(&self) -> B256 {
self.transaction().signature_hash()
}
Copy link
Member Author

Choose a reason for hiding this comment

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

imo we can add SigneableTransaction as super trait like I did initially, since all the tx types we now import from alloy, already impl this trait @mattsse

@emhane
Copy link
Member Author

emhane commented Nov 12, 2024

don't fully get the motivation here, doesn't this effectively just extend the transaction trait with an AT for txtype?

it add blanket impl of Transaction for SignedTransaction types, as pr description says. since the type reth_primitives::TransactionSigned which generic T: SignedTransaction aims to replace, defes to reth_primitives::Transaction, which in turn is aimed to be replaced by generic T: Transaction - this facilitates integration, since we do not have to call .transaction() then, everywhere we have before just called reth_primitives::Transaction methods right away on the reth_primitives::TransactionSigned type.

@emhane emhane requested a review from gakonst as a code owner November 12, 2024 12:27
Copy link
Collaborator

@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.

last nits

crates/primitives-traits/src/transaction/mod.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@emhane emhane requested a review from mattsse November 12, 2024 15:57
Copy link
Collaborator

@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.

lgtm

@emhane emhane enabled auto-merge November 13, 2024 13:21
@emhane emhane added this pull request to the merge queue Nov 13, 2024
Merged via the queue into main with commit 9e77d91 Nov 13, 2024
40 checks passed
@emhane emhane deleted the emhane/signed-tx branch November 13, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sdk Related to reth's use as a library C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants