Remove activated feature that checks tx signature len (#21747)

This commit is contained in:
Justin Starry
2021-12-14 09:23:05 -05:00
committed by GitHub
parent 746869fdac
commit e5476913fe
5 changed files with 13 additions and 32 deletions

View File

@ -303,11 +303,6 @@ impl Transaction {
Signature::default()
}
/// Verify the length of signatures matches the value in the message header
pub fn verify_signatures_len(&self) -> bool {
self.signatures.len() == self.message.header.num_required_signatures as usize
}
/// Verify the transaction and hash its message
pub fn verify_and_hash_message(&self) -> Result<Hash> {
let message_bytes = self.message_data();

View File

@ -200,11 +200,6 @@ impl SanitizedTransaction {
}
}
/// Verify the length of signatures matches the value in the message header
pub fn verify_signatures_len(&self) -> bool {
self.signatures.len() == self.message.header().num_required_signatures as usize
}
/// Verify the transaction signatures
pub fn verify(&self) -> Result<()> {
let message_bytes = self.message_data();

View File

@ -12,6 +12,7 @@ use {
transaction::{Result, Transaction, TransactionError},
},
serde::Serialize,
std::cmp::Ordering,
};
// NOTE: Serialization-related changes must be paired with the direct read at sigverify.
@ -29,11 +30,12 @@ impl Sanitize for VersionedTransaction {
fn sanitize(&self) -> std::result::Result<(), SanitizeError> {
self.message.sanitize()?;
// Once the "verify_tx_signatures_len" feature is enabled, this may be
// updated to an equality check.
if usize::from(self.message.header().num_required_signatures) > self.signatures.len() {
return Err(SanitizeError::IndexOutOfBounds);
}
let num_required_signatures = usize::from(self.message.header().num_required_signatures);
match num_required_signatures.cmp(&self.signatures.len()) {
Ordering::Greater => Err(SanitizeError::IndexOutOfBounds),
Ordering::Less => Err(SanitizeError::InvalidValue),
Ordering::Equal => Ok(()),
}?;
// Signatures are verified before message keys are mapped so all signers
// must correspond to unmapped keys.