-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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(rpc): remove use of extensible transaction + receipt types #9774
Conversation
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.
+1 on the direction
equivalent to main in hive tests https://github.com/paradigmxyz/reth/actions/runs/10928588345/job/30337917567 |
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.
ty for suffering through this.
I get now why we need the compat trait, although I believe once we have primitive traits we can simplify a few things here. I'm fine with this trait since this unlocks a few things and further separates op from eth.
only have a few questions
@@ -54,13 +51,14 @@ use crate::{ | |||
}; | |||
|
|||
/// Alias for [`reth_rpc_eth_types::EthApiBuilderCtx`], adapter for [`FullNodeComponents`]. | |||
pub type EthApiBuilderCtx<N> = reth_rpc_eth_types::EthApiBuilderCtx< | |||
pub type EthApiBuilderCtx<N, Eth> = reth_rpc_eth_types::EthApiBuilderCtx< | |||
<N as FullNodeTypes>::Provider, | |||
<N as FullNodeComponents>::Pool, | |||
<N as FullNodeComponents>::Evm, | |||
<N as FullNodeComponents>::Network, | |||
TaskExecutor, |
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.
I'd actually like to remove the Tasks generic everywhere and use Box dyn (followup)
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.
it's an unnecessary perf downgrade to use dynamic dispatch for types that are called (i) often and (ii) always return a trait object originating from the same type. I'd try to reserve dynamic dispatch for builders that are called once. or where trait objects are returned that originate from different types for each call.
let signer = tx.signer(); | ||
let signed_tx = tx.into_signed(); | ||
/// Builds RPC transaction w.r.t. network. | ||
pub trait TransactionCompat: Send + Sync + Unpin + Clone + fmt::Debug { |
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.
I get why we currently need this.
but I worry that this could cause more trouble once we have network specific transaction types.
this is also not stateful, so these conversions are limited to the function input
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.
yes agreed, this is a first step, hence parallel work on alloy-rs/alloy#1173, alloy-rs/alloy#1315
/// Truncates the input of a transaction to only the first 4 bytes. | ||
fn otterscan_api_truncate_input(tx: &mut Self::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.
I find this a bit weird, this could also be solved by introducing a trait for the the transaction and not baking this into the compat trait.
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.
yes absolutely, will open an issue, not to block anymore for alloy changes here. asides merge conflicts getting out of hand, I don't want to block this any longer since sdk work from arseni is moving fast and I'm uncertain if it's taking consideration of changes in this pr. I want to avoid anymore collisions by getting this in as is.
other: Default::default(), | ||
/// Create a new rpc transaction result for a _pending_ signed transaction, setting block | ||
/// environment related fields to `None`. | ||
fn fill(tx: TransactionSignedEcRecovered, tx_inf: TransactionInfo) -> Self::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.
I also think this would go away once we have network specific primitives
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.
again ref problem described here alloy-rs/alloy#1315
source_hash: signed_tx.source_hash(), | ||
mint: signed_tx.mint(), | ||
is_system_tx: signed_tx.is_deposit().then_some(signed_tx.is_system_transaction()), | ||
deposit_receipt_version: None, // todo: how to fill this field? |
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.
how are we currently filling this?
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.
also with None
, the field feels a bit off on the tx type, or we need to figure our how to set it, as sep issue
reth/crates/rpc/rpc-types-compat/src/transaction/mod.rs
Lines 101 to 111 in c3d090a
// Optimism fields | |
#[cfg(feature = "optimism")] | |
other: reth_rpc_types::optimism::OptimismTransactionFields { | |
source_hash: signed_tx.source_hash(), | |
mint: signed_tx.mint(), | |
// only include is_system_tx if true: <https://github.com/ethereum-optimism/op-geth/blob/641e996a2dcf1f81bac9416cb6124f86a69f1de7/internal/ethapi/api.go#L1518-L1518> | |
is_system_tx: (signed_tx.is_deposit() && signed_tx.is_system_transaction()) | |
.then_some(true), | |
deposit_receipt_version: None, | |
} | |
.into(), |
signed_tx.chain_id(), | ||
); | ||
|
||
WithOtherFields { |
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.
do we still nicht WithOtherFields here?
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 I implemented this is it wasn't possible to use Ethereum
instead of AnyNetwork
, may have changed now, though appreciate if this can be tackled in a follow pr, will open issue
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.
cool,
this gets us at least closer to where we want to go, the transactioncompat is necessary, tmp weirdness that will improve shortly
pub trait EthApiBuilderProvider<N: FullNodeComponents>: BuilderProvider<N> + EthApiTypes { | ||
/// Returns the eth api builder. | ||
#[allow(clippy::type_complexity)] | ||
fn eth_api_builder() -> Box<dyn Fn(&EthApiBuilderCtx<N>) -> Self + Send>; | ||
fn eth_api_builder() -> Box<dyn Fn(&EthApiBuilderCtx<N, Self>) -> Self + Send>; | ||
} |
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.
I assume this will go away, if we do #10769 ?
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.
this trait is very useful to avoid the very long generics that node builder has now, ref #9543
Ref #8780. Closes #8988. Closes #10632.
optimism
feature fromreth-rpc-types-compat
reth-rpc-types-compat
transaction type conversion, which was previously optimism-feature gated, into new traitTransactionCompat
. These are called many times during the program, hence are not used as trait objects.EthApiTypes::TransactionCompat
, allowing different networks to use same transaction type but with different reth compatibility methods.EthApiTypes::TransactionCompat
, allows for implementation of conversion reth types ->op-alloy-rpc-types
to be implemented in reth repo as opposed to op-alloy repo.Alt. solution:
alloy_network::Network
associated types must provide reth compatibility viaTransactionResponse
,ReceiptResponse
, etc. traits, then no additional associated typeEthApiTypes::TransactionCompat
is needed: alloy-rs/alloy#1173.