-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: transaction trait #11877
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
Merged
Merged
feat: transaction trait #11877
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e0faa6e
add transaction trait
edisontim 04153d0
Merge branch 'main' of github.com:paradigmxyz/reth into feat/transact…
edisontim 7eb0cf3
Add documentation + trait bounds for arbitrary
edisontim 2d09455
Cleanup trait
edisontim 47e5645
Merge branch 'main' of github.com:paradigmxyz/reth into feat/transact…
edisontim 5392bb8
fix CI
edisontim f1eabe3
lint
edisontim da7cf2e
remove unnecessary trait bound + methods + change visibility of Trans…
edisontim 5a2afc8
Merge branch 'main' of github.com:paradigmxyz/reth into feat/transact…
edisontim e170f32
address PR comments
edisontim 978a4ec
Add/remove supertraits + documentation
edisontim 2ce2ba7
add maybe arbitrary trait to transaction
edisontim 7fc755e
Remove feature gate for FullTransaction implementation
edisontim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,61 @@ | ||
| //! Transaction abstraction | ||
|
|
||
| pub mod signed; | ||
| use core::{fmt::Debug, hash::Hash}; | ||
|
|
||
| use alloc::fmt; | ||
| use alloy_primitives::{TxKind, B256}; | ||
|
|
||
| use reth_codecs::Compact; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// 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 {} | ||
|
Comment on lines
-10
to
-13
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert this, we don't want to require |
||
| pub mod signed; | ||
|
|
||
| #[allow(dead_code)] | ||
| /// Abstraction of a transaction. | ||
| pub trait Transaction: | ||
| alloy_consensus::Transaction | ||
| Debug | ||
| + Default | ||
| + Clone | ||
| + fmt::Debug | ||
| + PartialEq | ||
| + Eq | ||
| + Default | ||
| + PartialEq | ||
| + Hash | ||
| + Serialize | ||
| + alloy_rlp::Encodable | ||
| + alloy_rlp::Decodable | ||
| + Serialize | ||
| + for<'de> Deserialize<'de> | ||
| + alloy_consensus::Transaction | ||
| + MaybeArbitrary | ||
| { | ||
| /// Heavy operation that return signature hash over rlp encoded transaction. | ||
| /// It is only for signature signing or signer recovery. | ||
| fn signature_hash(&self) -> B256; | ||
|
|
||
| /// Gets the transaction's [`TxKind`], which is the address of the recipient or | ||
| /// [`TxKind::Create`] if the transaction is a contract creation. | ||
| fn kind(&self) -> TxKind; | ||
|
|
||
| /// Returns true if the tx supports dynamic fees | ||
| fn is_dynamic_fee(&self) -> bool; | ||
|
|
||
| /// Returns the effective gas price for the given base fee. | ||
| fn effective_gas_price(&self, base_fee: Option<u64>) -> u128; | ||
|
|
||
| /// This encodes the transaction _without_ the signature, and is only suitable for creating a | ||
| /// hash intended for signing. | ||
| fn encode_without_signature(&self, out: &mut dyn bytes::BufMut); | ||
|
|
||
| /// Calculates a heuristic for the in-memory size of the [Transaction]. | ||
| fn size(&self) -> usize; | ||
| } | ||
|
|
||
| #[cfg(not(feature = "arbitrary"))] | ||
| /// Helper trait that requires arbitrary implementation if the feature is enabled. | ||
| pub trait MaybeArbitrary {} | ||
|
|
||
| #[cfg(feature = "arbitrary")] | ||
| /// Helper trait that requires arbitrary implementation if the feature is enabled. | ||
| pub trait MaybeArbitrary: for<'a> arbitrary::Arbitrary<'a> {} | ||
|
|
||
| /// 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 {} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.