From f1e38cdb0852d0b5e94514be68d27e9019e5d072 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Mon, 27 Nov 2023 03:19:10 -0800 Subject: [PATCH] fix: always recover senders on mismatch (#5575) --- crates/primitives/src/block.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 9e703faaab..61f2468107 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -57,10 +57,16 @@ impl Block { /// /// # Panics /// - /// If the number of senders does not match the number of transactions in the block. + /// 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(self, senders: Vec
) -> BlockWithSenders { - assert_eq!(self.body.len(), senders.len(), "Unequal number of senders"); + let senders = if self.body.len() == senders.len() { + senders + } else { + TransactionSigned::recover_signers(&self.body, self.body.len()) + .expect("stored block is valid") + }; BlockWithSenders { block: self, senders } }