Skip to content

refactor: use Recovered<Tx> when setting up TxEnv#14580

Merged
klkvr merged 1 commit intoklkvr/wip-exec-transactionfrom
klkvr/use-recovered
Feb 19, 2025
Merged

refactor: use Recovered<Tx> when setting up TxEnv#14580
klkvr merged 1 commit intoklkvr/wip-exec-transactionfrom
klkvr/use-recovered

Conversation

@klkvr
Copy link
Member

@klkvr klkvr commented Feb 19, 2025

Based on #14480

Towards #14551

Changes all Tx -> TxEnv conversions to operate on Recovered<Tx> instead of passing sender separately. This should be better for the API because we can now hide this behind a FillTxEnv/IntoTxEnv trait and have fn transact(&self, tx: impl IntoTxEnv<Self::Tx>) directly on Evm. This would not have been possible with transact(tx, sender) API

}

let tx_env = self.evm_config.tx_env(tx.tx(), tx.signer());
let tx_env = self.evm_config.tx_env(tx.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be okay because we convert the tx anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah it would get fixed with alloy-rs/alloy#2082

fn tx_env(&self, transaction: &TransactionSigned, sender: Address) -> Self::TxEnv {
fn tx_env<T: Borrow<Self::Transaction>>(
&self,
transaction: impl Borrow<Recovered<T>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should just operate on Recovered<&T> instead

because this Borrow forces &Recovered<Tx> which should be fine as long as the input here wraps a tx: Recovered<Tx>
but the additional Borrow on T should also cover use cases where the sender is stored separately
but effectively this is just Recovered<&T>
so this seems fine.

but I think we should also consider the consuming use case Recovered<T>
which should probably be a separate function?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, the optimization of consuming vs borrowing would only really exist if those would be two separate code paths

@klkvr klkvr merged commit e080dec into klkvr/wip-exec-transaction Feb 19, 2025
38 checks passed
@klkvr klkvr deleted the klkvr/use-recovered branch February 19, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants