alloy-rs / alloy

Transports, Middleware, and Networks for the Alloy project
https://alloy.rs
Apache License 2.0
664 stars 239 forks source link

consensus: impl `recover_signers` for `BlockBody<TxEnvelope>` #1541

Open tcoratger opened 1 month ago

tcoratger commented 1 month ago

Related https://github.com/paradigmxyz/reth/issues/11208

The ideal for the reth issue is to restrict the functions to be implemented as much as possible to the alloy Transaction trait however it doesn't make much sense to add a recover_signer or recover_signers method to the Transaction trait because we can only fetch the signer in the Signed<Tx> case, which is almost never the case when trying to implement Transaction.

So I think the simplest approach to replace https://github.com/paradigmxyz/reth/blob/0270128d4f7a9f6fad27dff69273095abdfa7452/crates/primitives/src/block.rs#L564-L566 is to do the similar implementation here in alloy using what already exists in TxEnvelope to recover the signers from an iterator of transactions TxEnvelope.

tcoratger commented 1 month ago

@emhane Maybe we should keep this for a follow up PR right? My reasoning was as follows:

cc @mattsse