From 13b581914264cbce75c9b244ed7424fa30ac2822 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:02:10 -0400 Subject: [PATCH] feat: add _with_senders_unchecked methods to SealedBlock (#9002) --- crates/primitives/src/block.rs | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 3bd41e2cdacf..4980ebe73d5a 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -380,6 +380,43 @@ impl SealedBlock { } } + /// Transform into a [`SealedBlockWithSenders`]. + /// + /// # Panics + /// + /// If the number of senders does not match the number of transactions in the block + /// and the signer recovery for one of the transactions fails. + #[track_caller] + pub fn with_senders_unchecked(self, senders: Vec
) -> SealedBlockWithSenders { + self.try_with_senders_unchecked(senders).expect("stored block is valid") + } + + /// Transform into a [`SealedBlockWithSenders`] using the given senders. + /// + /// If the number of senders does not match the number of transactions in the block, this falls + /// back to manually recovery, but _without ensuring that the signature has a low `s` value_. + /// See also [`TransactionSigned::recover_signer_unchecked`] + /// + /// Returns an error if a signature is invalid. + #[track_caller] + pub fn try_with_senders_unchecked( + self, + senders: Vec, + ) -> Result