-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: transaction trait #11877
base: main
Are you sure you want to change the base?
feat: transaction trait #11877
Conversation
Hey @emhane ! Could you have a look at this one please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job so far
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with these things I recommend starting smol, we can always add more functionality later
/// 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 {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this, we don't want to require Compact
be a super trait for Transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there
pub trait Transaction: | ||
alloy_consensus::Transaction | ||
#[allow(dead_code)] | ||
/// Inner trait for a raw transaction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Inner trait for a raw transaction. | |
/// Abstraction of a transaction. |
@@ -1,28 +1,65 @@ | |||
//! Transaction abstraction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave this module docs here, remove them from lib.rs for this module
/// Trait that defines methods of a raw transaction. | ||
/// | ||
/// Transaction types were introduced in [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718). | ||
#[cfg(feature = "arbitrary")] | ||
pub trait FullTransaction<T>: Transaction<T> + Compact + for<'b> arbitrary::Arbitrary<'b> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when asked to revert, please also revert the code docs. one should always think, that the docs and the code are glued together and are inseparable.
/// Trait that defines methods of a raw transaction. | |
/// | |
/// Transaction types were introduced in [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718). | |
#[cfg(feature = "arbitrary")] | |
pub trait FullTransaction<T>: Transaction<T> + Compact + for<'b> arbitrary::Arbitrary<'b> {} | |
/// Helper trait that unifies all behaviour required by transaction to support full node operations. | |
#[cfg(feature = "arbitrary")] | |
pub trait FullTransaction<T>: Transaction<T> + Compact + for<'b> arbitrary::Arbitrary<'b> {} |
/// Trait that defines methods of a raw transaction. | ||
/// | ||
/// Transaction types were introduced in [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Trait that defines methods of a raw transaction. | |
/// | |
/// Transaction types were introduced in [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718). | |
/// Helper trait that unifies all behaviour required by transaction to support full node operations. |
+ Serialize | ||
+ for<'de> Deserialize<'de> | ||
+ From<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ From<T> |
we don't need this
alloy_consensus::Transaction | ||
#[allow(dead_code)] | ||
/// Inner trait for a raw transaction. | ||
pub trait Transaction<T>: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub trait Transaction<T>: | |
pub trait Transaction: |
we don't this to have a generic, if anything, give it an associated type
|
||
use alloy_rlp::Encodable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use alloy_rlp::Encodable; |
+ alloy_rlp::Encodable | ||
+ alloy_rlp::Decodable | ||
+ PartialEq | ||
+ Encodable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ Encodable |
revert to
+ alloy_rlp::Encodable
+ alloy_rlp::Decodable
we like to have the longer path to know what encoding this is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another idea for arbitrary feature, is to do smthg like this in order to use it as super trait independently of FullTransaction
, as you initially thought, but without requiring impl of another trait TransactionInner
on transaction types alloy-rs/core#766 (comment)
so for this case it would be
#[cfg(not(feature = "arbitrary"))]
trait MaybeArbitrary {}
#[cfg(feature = "arbitrary")]
trait MaybeArbitrary: for<'a> arbitrary::Arbitrary<'a> {}
pub trait Transaction: .. + MaybeArbitrary {
..
}
but we can merge this pr as is and make that change in a follow up pr
That makes sense! |
Transaction trait has been partially implemented but it's missing a few trait bounds as well as the behavior of
reth_primitives::Transaction
Closes #11533